A Large Digits
int n;
int main()
{
IOS;
int a, b, resa = 0, resb = 0;
cin >> a >> b;
while(a) resa += a % 10, a /= 10;
while(b) resb += b % 10, b /= 10;
cout << max(resa, resb) << endl;
return 0;
}
B Gentle Pairs
int n;
int x[N], y[N];
int main()
{
scanf("%d", &n);
for(int i = 1; i <= n; ++ i) scanf("%d%d", &x[i], &y[i]);
int res = 0;
for(int i = 1; i <= n; ++ i)
for(int j = i + 1; j <= n; ++ j)
{
if(x[i] - x[j] == 0) continue;
if(x[i] - x[j] > 0)
{
if(y[i] - y[j] >= x[j] - x[i] && y[i] - y[j] <= x[i] - x[j])
res ++;
}
if(x[i] - x[j] < 0)
{
if(y[i] - y[j] <= x[j] - x[i] && y[i] - y[j] >= x[i] - x[j])
res ++;
}
}
printf("%d\n", res);
}
C 1-SAT
int n;
map<string, int=""> mp;
string str;
int main()
{
IOS;
cin >> n;
for(int i = 1; i <= n; ++ i)
{
cin >> str;
if(str[0] == '!' && mp.count(str.substr(1)))
{
cout << str.substr(1) << endl;
return 0;
}
if(str[0] != '!' && mp.count("!" + str))
{
cout << str << endl;
return 0;
}
mp[str] = 1;
}
puts("satisfiable");
return 0;
}