#include<bits/stdc++.h>
using namespace std;
int y, n;
int main() {
cin >> y >> n;
for(int i = y;;++i) {
unordered_set<char> st;
string s = to_string(i);
if(s.length() < 4) st.insert('0');
for(auto& x : s) {
st.insert(x);
}
if((int)st.size() == n) {
printf("%d %04d", i - y, i);
break;
}
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int n, k, x, maxx, flag;
map<int, int>mp;
int main() {
cin >> n;
while(n--) {
cin >> k;
for(int i = 0; i < k; ++i) {
cin >> x;
++mp[x];
}
}
for(auto& [key, value] : mp) {
if(value >= maxx) {
maxx = value, flag = key;
}
}
cout << flag << " " << maxx;
return 0;
}
#include<bits/stdc++.h>
using namespace std;
string s1, s2, s;
int cnt;
int main() {
while(cin >> s, ++cnt) {
if(s == ".") break;
if(cnt == 2) s1 = s;
else if(cnt == 14) s2 = s;
}
if(s1.empty()) puts("Momo... No one is for you ...");
else if(s2.empty()) printf("%s is the only one for you...", s1.c_str());
else printf("%s and %s are inviting you to dinner...", s1.c_str(), s2.c_str());
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int a, b;
int main() {
cin >> a >> b;
cout << a * b;
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int a, b;
int main() {
cin >> a >> b;
if(b < 0) printf("%d/(%d)=%.2f", a, b, double(a) / b);
else if(!b) printf("%d/%d=Error", a, b);
else printf("%d/%d=%.2f", a, b, double(a) / b);
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main() {
puts("Hello World\nHello New World");
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
stack<char> st[105];
int main() {
cin >> n, getchar(), getline(cin, s);
for(int i = 0; i < s.length(); ++i) {
st[i % n].push(s[i]);
}
for(int i = 1; i < n; ++i) {
if(st[i].size() != st[0].size()) {
st[i].push(' ');
}
}
for(int i = 0; i < n; ++i) {
while(!st[i].empty()) {
cout <<st[i].top();
st[i].pop();
}
putchar('\n');
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
double n, h;
char c;
int main() {
cin >> n;
for(int i = 0; i < n; ++i) {
cin >> c >> h;
printf("%.2f\n", (c == 'M' ? h / 1.09 : h * 1.09));
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
long long n, cnt1, cnt2;
const int N = 1e5 + 5;
int a[N];
int main() {
cin >> n;
for(int i = 1; i <= n; ++i) {
cin >> a[i];
}
sort(a + 1, a + n + 1, greater<int>());
for(int i = 0; i <= n; ++i) {
if(i <= ((n + 1) >> 1)) cnt1 += a[i];
else cnt2 += a[i];
}
printf("Outgoing #: %lld\nIntroverted #: %lld\nDiff = %lld", (n + 1) >> 1, n - ((n + 1) >> 1), cnt1 - cnt2);
return 0;
}
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
double a[N], b[N], c[N], mid;
int n, x, max_a = -1, max_b = -1;
void read(double s[], int& maxx) {
cin >> n;
for(int i = 0; i < n; ++i) {
cin >> x >> s[x];
maxx = max(maxx, x);
}
}
void print(double s[], int maxx) {
int cnt = 0;
for(int i = 0; i <= maxx; ++i) if(abs(s[i]) >= 0.05) ++cnt;
cout << cnt;
if(!cnt) cout << " 0 0.0";
for(int i = maxx; i >= 0; --i) {
if (abs(s[i]) >= 0.05) printf(" %d %.1lf", i, s[i]);
}
cout << endl;
}
int main() {
read(a, max_a), read(b, max_b);
int maxx = max_a - max_b;
while(max_a - max_b >= 0) {
mid = a[max_a] / b[max_b], c[max_a - max_b] = mid;
for(int i = max_a, j = max_b; i >= 0 && j >= 0; --i, --j) {
a[i] -= mid * b[j];
}
while(!a[max_a]) --max_a;
}
print(c, maxx), print(a, max_a);
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int n, cnt, x, flag;
string s;
map<string, int>mp;
set<string>st;
int main() {
cin >> n;
for(int i = 0; i < n; ++i) {
cin >> s;
st.insert(s);
}
cin >> n;
for(int i = 0; i < n; ++i) {
cin >> s >> x;
mp.insert({s, x}), cnt+= x;
}
for(auto& [key, value] : mp) {
if(value * n > cnt && !st.count(key)) {
cout << key << endl;
++flag;
}
}
if(!flag) puts("Bing Mei You");
return 0;
}
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
double ans, z, r;
int n, k, x;
int d[N];
vector<int> master[N];
void dfs(int i, int cnt) {
if(!master[i].size()) {
ans += d[i] * z * pow(r, cnt - 1);
}
for(int j = 0; j < master[i].size(); ++j) {
dfs(master[i][j], cnt + 1);
}
}
int main() {
cin >> n >> z >> r;
r = (100 - r) / 100;
for(int i = 0; i < n; ++i) {
cin >> k;
if(!k) cin >> d[i];
for(int j = 0;j < k; ++j) {
cin >> x;
master[i].push_back(x);
}
}
dfs(0, 1);
printf("%d", (int)ans);
return 0;
}