akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int dp[N], n;
string s;
int popcount(int num)
{
	int ans = 0;
	while (num)
	{
		ans += (num & 1);
		num >>= 1;
	}
	return ans;
}
int cal(int num)
{
	if (num == 0)
		return dp[num] = 0;
	if (dp[num] != 0)
		return dp[num];
	else
		return dp[num] = 1 + cal(num % popcount(num));
}
int pwr(int b, int e, int m)
{
	int ans = 1;
	while (e)
	{
		if (e & 1)
			ans = (1LL * ans * b) % m;
		b = (1LL * b * b) % m;
		e >>= 1;
	}
	return ans;
}
int main(int argc, char const *argv[])
{
	for (int i = 1; i < N; ++i)
	{
		cal(i);
	}
	cin >> n;
	cin >> s;
	int a = 0;
	for (int i = 0; i < n; ++i)
	{
		a += (s[i] == '1');
	}
	if (a == 0)
	{
		for (int i = 0; i < n; ++i)
		{
			cout << 1 << '\n';
		}
	}
	else if (a == 1)
	{
		if (s[n - 1] == '1')
		{
			for (int i = 0; i < n; ++i)
			{
				if (s[i] == '0')
					cout << 2 << '\n';
				else
					cout << 0 << '\n';
			}
		}
		else
		{
			for (int i = 0; i < n; ++i)
			{
				if (s[i] == '0')
				{
					if (i == n - 1)
						cout << 2 << '\n';
					else
						cout << 1 << '\n';
				}
				else
					cout << 0 << '\n';
			}
		}
	}
	else
	{
		int m1 = 0, m2 = 0;
		for (int i = 0; i < n; ++i)
		{
			m1 = (m1 * 2) % (a - 1);
			m1 = (m1 + (s[i] - '0')) % (a - 1);
			m2 = (m2 * 2) % (a + 1);
			m2 = (m2 + (s[i] - '0')) % (a + 1);

		}
		for (int i = 0; i < n; ++i)
		{
			if (s[i] == '1')
			{
				int md = (m1 - pwr(2, n - 1 - i, a - 1) + (a - 1)) % (a - 1);
				cout << 1 + dp[md] << '\n';
			}
			else
			{
				int md = (m2 + pwr(2, n - 1 - i, a + 1)) % (a + 1);
				cout << 1 + dp[md] << '\n';
			}
		}
	}
	return 0;
}

Measured memory_bytes: 4532
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

lli n;
vll a;
lli q;

mat dp;

int main(){
    cin >> n;
    a = vll(n);
    for(lli i = 0;i < n;i++) cin >> a[i];
    dp = mat(n+1,vll(2000*20+1));
    dp[0][0] = 1;
    for(lli i = 0;i < n;i++){
        for(lli j = 0;j < dp[i].size()-a[i];j++){
            dp[i+1][j] |= dp[i][j];
            dp[i+1][j+a[i]] |= dp[i][j];
        }
    }
    cin >> q;
    for(lli i = 0;i < q;i++){
        lli m;
        cin >> m;
        if(dp.back()[m]) cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}

Measured memory_bytes: 9640
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int d, g;
	cin >> d >> g;
	int p[d], c[d];
	int num = 0;
	rep(i, 0, d) {
		cin >> p[i] >> c[i];
		num += p[i];
	}
	int dp[d + 1][num + 1];
	rep(i, 0, d + 1) rep(j, 0, num + 1) dp[i][j] = 0;

	rep(i, 0, d) {
		rep(j, 0, num + 1) {
			rep(k, 0, p[i] + 1) {
				if(j >= k) {
					if(k == p[i]) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - k] + 100 * (i + 1) * k + c[i]);
					dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - k] + 100 * (i + 1) * k);
				} else dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
			}
		}
	}
	
	rep(i, 0, num + 1) {
		if(dp[d][i] >= g) {
			cout << i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main(){
  int n,i,k,ima=1;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>k;
    if(k==ima){
      ima++;
    }
  }
  if(ima==1){
    cout<<-1;
  }else{
    cout<<n-ima+1;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
    char s[200+5];
    scanf("%s", s);
    int n=strlen(s);
    
    for(int i=n-2; i>0; i-=2){
        if(strncmp(s, s+i/2, i/2)==0){
            printf("%d", i);
            return 0;
        }
    }
}


Measured memory_bytes: 1700
#pragma GCC optimize(2)
#include <bits/stdc++.h>

using namespace std;

int n, m, _sum, _move;

int main()
{	
	cin>>n>>m;
	for(int i = 0; i < m; i ++)
	{
		cin>>_move;
		_sum += _move;
	}
	if(_sum >= n) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;

string cj(string s){
	string tmp(s.size(),0);
	for(int i=0;i<s.size()-1;i++){
		tmp[i]=s[i+1];
	}
	tmp[s.size()-1]=s[0];
	return tmp;
}

string cc(string s){
	string tmp(s.size(),0);
	for(int i=1;i<s.size();i++){
		tmp[i]=s[i-1];
	}
	tmp[0]=s[s.size()-1];
	return tmp;
}

string ce(string s){
	string tmp(s.size(),0);
	for(int i=0;i<s.size()/2;i++){
		tmp[i]=s[s.size()-s.size()/2+i];
		tmp[s.size()-s.size()/2+i]=s[i];
	}
	if(s.size()%2==1)tmp[s.size()/2]=s[s.size()/2];
	return tmp;
}

string ca(string s){
	string tmp(s.size(),0);
	for(int i=0;i<s.size();i++){
		tmp[i]=s[s.size()-1-i];
	}
	return tmp;
}

string cp(string s){
	for(int i=0;i<s.size();i++){
		if(s[i]>='0'&&s[i]<='8'){
			int x=s[i]-'0';
			x++;
			char c=x+'0';
			s[i]=c;
		}else if(s[i]=='9')s[i]='0';
	}
	return s;
}

string cm(string s){
	for(int i=0;i<s.size();i++){
		if(s[i]>='1'&&s[i]<='9'){
			int x=s[i]-'0';
			x--;
			char c=x+'0';
			s[i]=c;
		}else if(s[i]=='0')s[i]='9';
	}
	return s;
}

int main(){
	int x;
	cin>>x;
	for(int j=0;j<x;j++){
		string ji,s;
		cin>>ji>>s;
		
		for(int i=ji.size()-1;i>=0;i--){
			if(ji[i]=='J')s=cc(s);
			if(ji[i]=='C')s=cj(s);
			if(ji[i]=='E')s=ce(s);
			if(ji[i]=='A')s=ca(s);
			if(ji[i]=='P')s=cm(s);
			if(ji[i]=='M')s=cp(s);
		}
		cout<<s<<endl;
	}
}

Measured memory_bytes: 3160
n=int(input())
ans=[]
ap=ans.append
def f(s,t):
    if len(s)==n:
        ap(s)
        return
    else:
        for i in range(t):
            f(s+chr(97+i),t)
        else:
            f(s+chr(97+t),t+1)
f("a",1)
for i in ans:
    print(i)

Measured memory_bytes: 12656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define llceil(a, b) ((ll)a + ((ll)b - 1)) / (ll)b

int main()
{
    ll n, a, b ,c ,d, e;
    cin >> n >> a >> b >> c >> d >> e;

    ll ans = llceil(n, min(min(min(a, b), c),min(d, e))) + 4;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

#define ll long long

void set_prime(vector<ll> &v, ll N)
{
    vector<bool> vn(1 + (int)1e6, true);
    vn[1] = false;
    vn[0] = false;
    for (ll i = 0; i * i <= N; i++)
    {
        if (!vn[i])
            continue;
        v.push_back(i);
        //cout << i << endl;
        for (ll j = i * 2; j * j <= N; j += i)
        {
            vn[j] = false;
        }
    }
}

int main()
{
    ll N;
    cin >> N;

    vector<ll> vp;
    set_prime(vp, N);

    int ans = 0;
    bool last_prime = true;
    //cout << N % 6079 << endl;
    for (const ll p : vp)
    {
        //cout << p <<endl;
        ll tp = p;
        while (N % tp == 0)
        {
            //cout << tp << endl;
            //cout << N << endl;
            N /= tp;
            tp *= p;
            ans++;
        }
        while (N % p == 0)
        {
            N /= p;
        }
    }

    if (N != 1)
        ans++;

    cout << ans << endl;
}

Measured memory_bytes: 3988
#include<bits/stdc++.h>
#define M 1000000007
using namespace std;

typedef long long int ll;

int main()
{
    int n,k;
    cin>>n>>k;
    int arr[n+1]={0};
    while(k--)
    {
        int d;
        cin>>d;
        for(int i=0;i<d;i++)
        {   int x;

            cin>>x;
            arr[--x]++;
        }
    }
    int cnt=0;
   for(int i=0;i<n;i++)
   {
       if(arr[i]==0)
        cnt++;
   }
   cout<<cnt<<endl;
}


Measured memory_bytes: 3660
n = int(input())
l = list(map(int, input().split()))
result = 0
loop = 0
while True:
    if all(x % 2 == 0 for x in l):
        result += 1
        for data in range(len(l)):
            l[data] = l[data]//2
    else:
        print(result)
        exit()


Measured memory_bytes: 9088
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		int sumLose = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'x')
				sumLose++;
		}

		String ans = sumLose <= 7 ? "YES" : "NO";
		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	int A,B;
	cin >> A >> B;
	if((A+B)%2!=0)cout << "IMPOSSIBLE"<<endl;
	else cout << (A+B)/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[])
{
    struct data {
        int name;
        double time;
    };
    data kiroku[24];
    for (int i = 0; i < 24; i++) {
        cin >> kiroku[i].name >> kiroku[i].time;
    }
    for (int i = 0; i < 8; i++) {
        for (int j = 0; j < 7; j++) {
            if (kiroku[j].time > kiroku[j+1].time) {
                data tmp = kiroku[j];
                kiroku[j] = kiroku[j+1];
                kiroku[j+1] = tmp;
            }
        }
    }
    for (int i = 8; i < 16; i++) {
        for (int j = 8; j < 15; j++) {
            if (kiroku[j].time > kiroku[j+1].time) {
                data tmp = kiroku[j];
                kiroku[j] = kiroku[j+1];
                kiroku[j+1] = tmp;
            }
        }
    }
    for (int i = 16; i < 24; i++) {
        for (int j = 16; j < 23; j++) {
            if (kiroku[j].time > kiroku[j+1].time) {
                data tmp = kiroku[j];
                kiroku[j] = kiroku[j+1];
                kiroku[j+1] = tmp;
            }
        }
    }
    printf("%d %.2f\n", kiroku[0].name, kiroku[0].time);
    printf("%d %.2f\n", kiroku[1].name, kiroku[1].time);
    printf("%d %.2f\n", kiroku[8].name, kiroku[8].time);
    printf("%d %.2f\n", kiroku[9].name, kiroku[9].time);
    printf("%d %.2f\n", kiroku[16].name, kiroku[16].time);
    printf("%d %.2f\n", kiroku[17].name, kiroku[17].time);
    
    data tmp = {0, 0};
    kiroku[0] = kiroku[1] = kiroku[8] = kiroku[9] = kiroku[16] =kiroku[17] = tmp;
    
    for (int i = 0; i < 24; i++) {
        for (int j = 0; j < 23; j++) {
            if (kiroku[j].time > kiroku[j+1].time) {
                data tmp = kiroku[j];
                kiroku[j] = kiroku[j+1];
                kiroku[j+1] = tmp;
            }
        }
    }
    printf("%d %.2f\n", kiroku[6].name, kiroku[6].time);
    printf("%d %.2f\n", kiroku[7].name, kiroku[7].time);
    return 0;
}

Measured memory_bytes: 1244
#pragma GCC optimize("trapv")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
//using arr = array;
using pi = pair<int, int>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;
using ld = long double;
const int maxn = 202, mod = 119<<23|1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll n;
ll c = 1;
vi suf, ans;

int count() {
	int a = 0;
	for(int i = 0; i < 1<<ans.size(); i++) {
		vi cur;
		for(int j = 0; j < ans.size(); j++) {
			if((i>>j)&1) cur.pb(ans[j]);
		}
		if(cur.size()&1) continue;
		int ok = 1;
		for(int i = 0; i + cur.size()/2 < cur.size(); i++)
			ok &= cur[i] == cur[i + cur.size()/2];
		a += ok;
	}
	return a;
}

const ll MOD = 1000000000000037, MAXA = 60;
ll mul(ll a, ll b) {
	return __int128(a)*b%MOD;
}
ll fact[MAXA], inv[MAXA];
void setup() {
	for(int i = 0; i < MAXA; i++) {
		inv[i] = i > 1 ? MOD - mul(MOD/i, inv[MOD%i]) : 1;
		fact[i] = i + (i == 0);
	}
	partial_sum(fact, fact + MAXA, fact, mul);
	partial_sum(inv, inv + MAXA, inv, mul);
}
ll nck(ll n, ll k) {
	return n >= k ? mul(fact[n], mul(inv[k], inv[n-k])) : 0;
}

ll get(ll n, ll k) {
	k = min(k, n-k);
	ll res = 0;
	for(int i = 0; i <= k; i++) {
		res += nck(n-k, i)*nck(k, i);
	}
	return res;
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	setup();
	cin >> n;
	n++; //empty string
	
	while((1ll<<c) <= n) c++;
	n -= 1ll<<(c-1);
	for(int a = 2, i = 0; i <= c; i++) {
		if(i >= c-i) {
			ll t = get(c, i);
			while(n >= t && t) {
				ans.pb(a);
				suf.pb(a);
				a++;
			
				n -= t;
			}
		}
		if(i != c)
			ans.pb(1);
	}
	
	reverse(all(suf));
	for(auto i : suf) ans.pb(i);
	
	
	cout << ans.size() << '\n';
	for(auto i : ans) cout << i << " ";
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int compare_char(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
}

int fact_cal(int L){
    int fact = 1;
    for(int i=1; i<=L; ++i) fact = fact * i;
    return fact;
}

int main(void){
    char s[5050];
    int K;
    scanf("%s %d",s,&K);

    char substr[K+1][strlen(s)+1];
    char a[strlen(s)],b[strlen(s)],tmp[strlen(s)];
    int count = 0;
    strcpy(b,"z");
    for(int j=0;j<strlen(s)-1;j++) strcat(b,"z");
    for(int i=0;i<K+1;i++){
        strcpy(substr[i],b);
    }

    for(int i = 0; i < strlen(s); i++){
        for(int j = i; j < strlen(s);j++){
            a[0] = '\0';
            strncpy(a,s+i,j+1-i);
            a[j+1-i]='\0';
            if(strlen(a) <= K){
                strcpy(substr[K],a);
                for(int l=1;l<K+1;l++){
                    for(int k=1;k<K+1;k++){
                        if(strcmp(substr[k-1], substr[k]) == 0){
                            strcpy(substr[k],b);
                        }
                        if(strcmp(substr[k-1], substr[k])>0){
                            strcpy(tmp, substr[k-1]);
                            strcpy(substr[k-1], substr[k]);
                            strcpy(substr[k], tmp);
                        }
                    }
                }
            }
        }
    }
    printf("%s\n",substr[K-1]);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int N;
	cin >> N;

	vector<long long> A(N, 0);

	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}

	long long current_money = 1000;

	for (int i = 0; i < N - 1; i++)
	{
		long long stock_count = 0;
		if (A[i] < A[i + 1]) stock_count = current_money / A[i];
		current_money += (A[i + 1] - A[i]) * stock_count;
	}

	cout << current_money;

	return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;

int main(){
  while(1){
    int H, W;
    cin>>H>>W;
    if(H == 0 && W == 0) break;

    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
        if((i + j) %2 == 0) cout<<"#";
        else cout<<".";
      }

      cout<<endl;
    }

    cout<<endl;
  }

  return 0;

}


Measured memory_bytes: 3056
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
const int INF = 1001001001;
const int BG = 1000000007;

int cnt_digit_base(int n, int k)
{
    int ret = 1;
    while (n / k > 0)
    {
        ret++;
        n /= k;
    }
    return ret;
}

int main()
{
    int N, K;
    cin >> N >> K;
    cout << cnt_digit_base(N, K) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;

int main(){
   ll x;cin >>x;
   ll ans=x/11*2;
   x%=11;
   if(x>6){
       ans+=2;
   }
   else if(x)ans++;
   cout <<ans <<endl;
}


Measured memory_bytes: 3588
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
int INF = INT_MAX / 2;
double EPS = 1e-10;

int main() {
	int n; cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++)
		cin >> a[i] >> b[i];
	vector<bool> used(n);
	int ans = 0;
	for (int t = 1; t <= 31; t++) {
		int _i, mini = INT_MAX;
		for (int i = 0; i < n; i++)
			if (a[i] <= t && t <= b[i] && b[i] + used[i] * 100 < mini) {
				_i = i;
				mini = b[i] + used[i] * 100;
			}
		ans += used[_i] ? 50 : 100;
		used[_i] = true;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1196
def solve(g,i):
    if i==0:
        return 10**9
    n=min(g//(100*i),PC[i][0])
    s=n*i*100
    if n==PC[i][0]:
        s+=PC[i][1]
    if s<g:
        n+=solve(g-s,i-1)
    return min(n,solve(g,i-1))

d,g=map(int,input().split())
PC=[0]+list(list(map(int,input().split())) for i in range(d))

print(solve(g,d))

Measured memory_bytes: 3064
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    b = list(set(s))
    a = len(list(set(s)))
    if a == 2 and s.count(b[0]) == s.count(b[1]) == 2:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    n = II()
    p = LI()
    ans = 0
    for i in range(1,n-1):
        if (p[i - 1] < p[i] and p[i] < p[i + 1]) or (p[i + 1] < p[i] and p[i] < p[i - 1]):
            ans += 1
    print(ans)
    return

#C
def C():
    n = II()
    d = LI()
    d.sort()
    ans = 0
    for i in range(d[-1]):
        if n // 2 == bisect_left(d, i):
            ans += 1
    print(ans)
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 5608
from heapq import heappop, heappush
from collections import Counter


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)

    def find_root(self, x):
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.find_root(self.root[x])
            return self.root[x]

    def unite(self, x, y):
        x = self.find_root(x)
        y = self.find_root(y)
        if x == y:
            return 
        elif self.rnk[x] > self.rnk[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rnk[x] == self.rnk[y]:
                self.rnk[y] += 1
    
    def is_same_group(self, x, y):
        return self.find_root(x) == self.find_root(y)

    def count(self, x):
        return -self.root[self.find_root(x)]


N, M, K = list(map(int, input().split()))
edges1 = [[] for _ in range(N + 1)]
edges2 = [[] for _ in range(N + 1)]
uf = UnionFind(N)

A, B = [], []
C, D = [], []
for _ in range(M):
    _a, _b = list(map(int, input().split()))
    A.append(_a)
    B.append(_b)
    uf.unite(_a, _b)
    edges1[_a].append(_b)
    edges1[_b].append(_a)

for _ in range(K):
    _c, _d = list(map(int, input().split()))
    C.append(_c)
    D.append(_d)
    edges2[_c].append(_d)
    edges2[_d].append(_c)

i, blocked = 1, 0
for b in edges2[1]:
    if uf.is_same_group(i, b):
        blocked += 1
print(uf.count(i) - 1 - len(edges1[i]) - blocked, end='')

for i in range(2, N + 1):
    print(' ', end='')
    blocked = 0
    for b in edges2[i]:
        if uf.is_same_group(i, b):
            blocked += 1
    print(uf.count(i) - 1 - len(edges1[i]) - blocked, end='')
print()

Measured memory_bytes: 128796
def solve(P):
    A, B, C, D = P
    if A<B or D<B:
        return False
    if C >= B-1:
        return True
    g = gcd(B,D)
    return B + A%g - g <= C

from math import gcd

T = int(input())
for _ in range(T):
    P = map(int, input().split())
    print("Yes" if solve(P) else "No")

Measured memory_bytes: 65548
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class FLaminate {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, k;
      cin >> n >> k;
      vector<vector<ll>> dp1(k + 1, vector<ll>(n + 1, LLONG_MAX / 2));
      vector<vector<ll>> dp2(k + 1, vector<ll>(n + 1, LLONG_MAX / 2));
      vector<ll> h(n + 1);
      rep(i, n) {
        cin >> h[i + 1];
      }
      dp1[0][0] = 0;
      rep(i, n) {
        rep(j, k + 1) {
          rep(l, n + 1) {
            if (dp1[j][l] == LLONG_MAX/2) continue;
            // no move: dp1[j][l] -> dp2[j][i+1];
            chmin(dp2[j][i + 1], dp1[j][l] + max(0LL, h[i + 1] - h[l]));
            // move: dp1[j][l] -> dp2[j+1][l];
            if (j == k) continue;
            chmin(dp2[j + 1][l], dp1[j][l]);
          }
        }
        swap(dp1, dp2);
        rep(j, k + 1) {
          rep(l, n + 1) {
            dp2[j][l] = LLONG_MAX / 2;
          }
        }
      }

      ll ans = LLONG_MAX;
      rep(j, k+1) {
        rep(l, n+1) {
          chmin(ans, dp1[j][l]);
        }
      }
      cout << ans << endl;
    }

};

signed main() {
  FLaminate solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 1664
#include<iostream>
//#inlcude<cmath>

int main(){
  long long int n,num,s = 0,a;
  std::cin >> n;
  num = n;
  while(n){
    a = n % 10;
    s += a;
    n /= 10;
  }
  if(num % s == 0)
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;


public class Main{
	
	public static void main(String[] args){
		
		boolean[][] cards = new boolean[4][13];
		Scanner sc = new Scanner(System.in);
		for(int i = 0; i < cards.length; i++) {
			Arrays.fill(cards[i], false);
		}
		
		//input
		int n = sc.nextInt();
		for(int i = 0; i < n; i++) {
			char suit= sc.next().charAt(0);
			int num = sc.nextInt();
			cards[suitToIndex(suit)][numToIndex(num)] = true;
		}
		sc.close();
		
		//output
		for(int i = 0; i < cards.length; i++) {
			for(int j = 0; j < cards[0].length; j++) {
				if(!cards[i][j]) System.out.println(indexToSuit(i) + " " + indexToNum(j));
			}
		}
	}

	static int suitToIndex(char suit) {
		switch(suit) {
			case 'S':
				return 0;
			case 'H':
				return 1;
			case 'C':
				return 2;
			case 'D':
			default:
				return 3;
		}
	}
	
	static char indexToSuit(int i) {
		if(i == 0) return 'S';
		else if(i == 1) return 'H';
		else if(i == 2) return 'C';
		else return 'D';
	}
	
	static int numToIndex(int n) {
		return n-1;
	}
	
	static int indexToNum(int i) {
		return i + 1;
	}
}

Measured memory_bytes: 18080
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  vector<int> q(n);
  rep(i, n) cin >> p[i];
  rep(i, n) cin >> q[i];
  vector<int> a(n);
  rep(i, n) a[i] = i + 1;
  map<vector<int>, int> m;
  do {
    m[a] = m.size();
  } while (next_permutation(a.begin(), a.end()));

  int ans = abs(m[p] - m[q]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5248
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

struct Card{char suit,value;};

void bubble(struct Card A[],int N){
    rep(i,N){
        for(int j=N-1;j>=i;j--){
            if(A[j].value<A[j-1].value){
                Card t=A[j];
                A[j]=A[j-1];
                A[j-1]=t; 
            }
        }
    }
}

void selection(struct Card A[],int N){
    rep(i,N){
        int minj=i;
        for(int j=i;j<N;j++){
            if(A[j].value<A[minj].value)minj=j;
        }
        Card t=A[i];
        A[i]=A[minj];
        A[minj]=t; 
    }
}

void print(struct Card A[], int N){
    rep(i,N){
        if(i)cout<<" ";
        cout<<A[i].suit<<A[i].value;
    }
    cout<<endl;
}

bool isStable(struct Card C1[], struct Card C2[],int N){
    rep(i,N){
        if(C1[i].suit!=C2[i].suit)return false;
    }
    return true;
}

int N;

int main(){
    cin>>N;
    Card C1[N],C2[N];
    rep(i,N){
        cin>>C1[i].suit>>C1[i].value;
        C2[i]=C1[i];
    }
    bubble(C1,N);
    selection(C2,N);

    print(C1,N);
    cout<<"Stable"<<endl;
    print(C2,N);
    if(isStable(C1,C2,N))cout<<"Stable"<<endl;
    else cout<<"Not stable"<<endl;
}



Measured memory_bytes: 3108
N,X = map(int, input().split())
x = list(map(int, input().split()))

for i in range(N):
    x[i] = abs(x[i] - X)

from fractions import gcd

ans = x[0]
for i in range(1,N):
    ans = gcd(ans,x[i])
print(ans)

Measured memory_bytes: 82964
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	static final int MAX = 1000000;
	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			int e = Integer.parseInt(br.readLine());
			
			if(e == 0){
				break;
			}
			
//			int m = e;
//			
//			
//			int z = 0;
//			for(int i = 2; i <= MAX && Math.pow(i, 3) <= e ; i++){
//				z = i;
//			}
//			
//			if(z != 0) e -= Math.pow(z, 3);
//			
//			int y = 0;
//			for(int i = 1; i <= MAX && Math.pow(i, 2) <= e ; i++){
//				y = i;
//			}
//			
//			if(y != 0) e -= Math.pow(y, 2);
//			
//			int x = 0;
//			for(int i = 1; i <= MAX && i <= e ; i++){
//				x = i;
//			}
//			
//			System.out.printf("x %d y %d z %d\n",x,y,z);
			System.out.println(numXYZ(e));
		}
	}
	
	static int numXYZ(int e){
		int min = Integer.MAX_VALUE;
		
		for(int i = 0; i <= MAX && e - Math.pow(i, 3) >= 0 ; i++){
//			if(e - (int)Math.pow(i, 3))
			int tmpmin = i + numXY(e - (int)Math.pow(i, 3)) ;
			
			if(min > tmpmin){
				min = tmpmin;
			}
		}
		
		return min;
	}
	
	static int numXY(int e){
		if(e < 0){
			return -1;
		}
		else if(e == 0){
			return 0;
		}
		int min = Integer.MAX_VALUE;
		
		for(int i = 0; i <= MAX && e - Math.pow(i, 2) >= 0 ; i++){
			int tmpmin = i + (e - (int)Math.pow(i, 2)) ;
			
			if(min > tmpmin){
				min = tmpmin;
			}
		}
//		System.out.println("min "+min);
		return min;
	}

}

Measured memory_bytes: 28440
n,m=map(int,input().split())
H=list(map(int,input().split()))
ans = [1]*n
for i in range(m):
  a,b=map(int,input().split())
  if H[a-1]>H[b-1]:
    ans[a-1] *= 1 
    ans[b-1] *= 0
  elif H[a-1]<H[b-1]:
    ans[a-1] *= 0
    ans[b-1] *= 1
  else:
    ans[a-1] *= 0
    ans[b-1] *= 0
print(sum(ans))

Measured memory_bytes: 86364
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int N = 3;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int a = parseInt(sc.next());
		int b = parseInt(sc.next());
		int h = parseInt(sc.next());
		sc.close();
		out.println((a+b)*h/2);
	}
}


Measured memory_bytes: 21588
n = int(input())
a = []
ans = -1
for i in range(n):
  a.append(int(input()))
btn = 1
cnt = 0
for i in range(n):
  btn = a[btn-1]
  cnt += 1
  if btn == 2:
    ans = cnt
    break
  if btn == 1:
    break
print(ans)    

Measured memory_bytes: 7084
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define ull unsigned long long 
int main(){ 
  ll h;cin>>h;
  ll cnt=0;
  ll p=1;
  while(h>1)
  {
    h/=2;
    cnt++;
  }
  ll ans=1;
  ll k=1;
  for(int i=0;i<cnt;i++)
  {
    k*=2;
    ans+=k;
  }
  cout<<ans;
}
    
    

    
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;

int32_t main(){
	string s,t;
    cin >> s >> t;
    int count=0;
    for(int i=0;i<s.length();i++){
    	if(s[i]!=t[i])
        	count++;
    }
    cout << count ;
}

Measured memory_bytes: 3908
n = gets.to_i
s = gets.chomp.split("")

cnt = 0
n2 = n/2

n2.times do |x|
  cnt+=1 if s[x]!=s[x+n2]
end

if n.odd?
  puts "No"
elsif cnt==0
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 1788
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    string s;
    scan(s);
    foreach (i ; 0 .. s.length) {
        if (i & 1 ^ 1) {
            write(s[i]);
        }
    }
    writeln();
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 508
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<random>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    ll ans = (n / k) * (n / k) * (n / k);
    if(k & 1){
        cout << ans << '\n';
    }else{
        ll temp = n / (k / 2) - n / k;
        ans += temp * temp * temp;
        cout << ans << '\n';
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,power,sum=0;
    cin>>n;
    string a=to_string(n);
    if(a.size()%2==0)
        power=a.size()/2;
    else
    {
        power=(a.size()-1)/2;
        x=pow(10,a.size()-1);
        sum+=(n-x+1);
    }
    sum+=9*(pow(100,power)-1)/99;
    cout<<sum<<endl;
}




Measured memory_bytes: 4064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define rep(i,n) for (int i=0; i<(n); i++)
#define reps(i,s,n) for (int i=(s); i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define repr(i,s,n) for (int i=(s)-1; i>=(n); i--)
#define print(a) cout << (a) << endl
#define all(v) v.begin(), v.end()
#define rsort(v) sort(v.rbegin(), v.rend())

struct BIT {
  ll n;
  vector<ll> dat;
  BIT(ll n) : n(n), dat(n+1,0){}
  void add(ll i,ll x) {
    for (; i<=n; i+=(i&-i))
      dat[i] += x;
  }
  ll sum(ll i) {
    ll res = 0;
    for (; i>0; i-=(i&-i))
      res += dat[i];
    return res;
  }
  ll range_sum(ll l,ll r) { //[l,r]
    return sum(r)-sum(l-1);
  }
  ll lower_bound(ll x) {
    if (x<=0) return 0;
    ll i=0, r=1;
    while (r<n) r=r<<1;
    for (; r>0; r=r>>1) {
      if (i+r<n && dat[i+r]<x) {
        x-=dat[i+r];
        i+=r;
      }
    }
    return i+1;
  }
};


int main() {
  int N,Q;
  cin >> N >> Q;
  vector<int> c(N+1);
  vector<vector<pii>> q(N+1);
  rep1(i,N) {
    cin >> c[i];
  }
  rep(i,Q) {
    int l,r;
    cin >> l >> r;
    q[r].push_back({l,i});
  }
  BIT bit(N);
  vector<int> p(N+1,0),ans(Q);
  rep1(i,N) {
    if (p[c[i]]>0)
      bit.add(p[c[i]],-1);
    bit.add(i,1);
    p[c[i]] = i;
    for (pii p : q[i]) {
      ans[p.second] = bit.range_sum(p.first,i);
    }
  }
  rep(i,Q) {
    print(ans[i]);
  }
  return 0;
}

Measured memory_bytes: 35120
#include <bits/stdc++.h>
using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  LL N, Q;
  cin >> N >> Q;

  VL as(N*2), bs(N*2);
  cin >> as >> bs;

  if(N == 1){
    while(Q--){
    int p, x, y;
    cin >> p >> x >> y;
    --p;
    as[p] = x;
    bs[p] = y;
    cout<<as[0]+as[1]<<endl;      
    }
    return 0;
  }

  int par = 0;
  LL sum = as[0] + as.back();
  multiset<LL> dels;
  FOR(i,1,2*N-1){
    LL mx = max(as[i], bs[i]);
    LL mn = min(as[i], bs[i]);
    sum += mx;
    if(mx == as[i]) par ^= 1;
    dels.insert(mn - mx);
  }

  while(Q--){
    LL p, x, y;
    cin >> p >> x >> y;
    --p;
if(p==0||p==2*N-1){
sum-=as[p]-x;as[p]=x;
cout<<sum+(par?*dels.rbegin():0ll)<<endl;continue;
}
    LL mx = max(as[p], bs[p]);
    LL mn = min(as[p], bs[p]);
    sum -= mx;
    if(mx == as[p]) par ^= 1;
    auto it = dels.find(mn - mx);
    dels.erase(it);

    as[p] = x;
    bs[p] = y;
    LL mx2 = max(as[p], bs[p]);
    LL mn2 = min(as[p], bs[p]);
    sum += mx2;
    if(mx2 == as[p]) par ^= 1;
    dels.insert(mn2 - mx2);

    LL ans = 0;
    if(par == 0){
      ans = sum;
    }
    else{
      auto it = dels.rbegin();
      assert(it != dels.rend());
      ans = sum + *it;
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 14208
#include <iostream>
using namespace std;

int main(){
  int a,b,c,d;
  cin >> a >> b>> c>> d;
  
  if(abs(b-c)<d && abs(b-a)<=d)cout << "Yes";
  else if(abs(c-a)<=d)cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 256
# ABC121
# B Can you solve this?
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]
ans = 0
ANS = []
ct = 0
for i in range(N):
    for j in range(M):
        ans += A[i][j] * B[j]
        if j == M-1:
            ANS.append(ans)
            ans = 0
for x in ANS:
    if x + C > 0:
        ct += 1
print(ct)


Measured memory_bytes: 9092
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 998244353;






int main() {

	int n;
	cin >> n;
	string s;
	cin >> s;
	map<int, int> m;
	VI a(10, 0), b;
	b = a;
	REP(i, n) {
		b[s[i] - '0']++;
	}

	REP(i, n) {
		b[s[i] - '0']--;
		REP(j, 10) {
			if (a[j] == 0)continue;
			REP(k, 10) {
				if (b[k] == 0)continue;
				int l = j * 100 + (int)(s[i] - '0') * 10 + k;
				m[l]++;
			}
		}
		a[s[i] - '0']++;
	}
	cout << m.size() << endl;



}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)

int main() {
  vector<char> s(26);
  int ans;
  s = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
                        'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u',
                        'v', 'w', 'x', 'y', 'z'};
  char C;
  cin>>C;
  rep(i,25) {
    if (C == s[i]) ans=i+1;
  }
  cout<<s[ans]<<endl;
}

Measured memory_bytes: 256
from collections import defaultdict
import sys
input = sys.stdin.readline


def main():
    N, W = map(int, input().split())
    items = [tuple(map(int, input().split())) for _ in range(N)]
    dd = defaultdict(int)
    dd[0] = 0
    for w, v in items:
        for tw, tv in list(dd.items()):
            if tw + w <= W:
                dd[tw + w] = max(tv + v, dd[tw + w])
    print(max(dd.values()))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3944
#include <bits/stdc++.h>
using ll = long long;
using namespace std;

int main() {
  int A,B,C;
  cin>>A>>B>>C;
  for (int i(0);i<=B;i++){
    if ((A*i-C)%B==0&&(A*i-C)>=0){
      cout << "YES"<<endl;
      return 0;
    }
  }
  cout << "NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int n,k,s;
int ans;
 
void dfs(int num,int cnt,int sum){
  if(sum==s && cnt == k)
    ans++;
  if(num > n)
    return;
  if(cnt == k)
    return;
  dfs(num+1,cnt,sum);
  dfs(num+1,cnt+1,sum+num);
}
 
int main(){
   
  while(scanf("%d%d%d",&n,&k,&s),n+k+s!=0){
    ans=0;
    dfs(1,0,0);
    printf("%d\n",ans);
  }
   
  return 0;
}

Measured memory_bytes: 1740
#include<stdio.h>

int main()
{
int a,b;
scanf("%d%d",&a,&b);
if(a < b)
 {printf("a < b\n");
 }
 else
 {if(a > b)
  {printf("a > b\n");
  }
  else
  {printf("a == b\n");
  }
 }
return 0;
}

Measured memory_bytes: 580
#include "bits/stdc++.h"

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  for (auto& a : A)
    cin >> a;
  
  cout << A[0];
  for (int p = 1; p < n; ++p)
    cout << " " << A[p];
  cout << endl;

  for (int i = 1; i < n; ++i) {
    int key = A[i];
    int j = i - 1;
    while (j >= 0 && A[j] > key) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = key;
    cout << A[0];
    for (int p = 1; p < n; ++p)
      cout << " " << A[p];
    cout << endl;
  }
  
}

Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

// #define MAX_N 100000
// ll n, a, b;
// ll h[MAX_N];

int main(){
  int n;
  ll a, b;
  cin >> n >> a >> b;
  ll h[n];
  REP(i,n)cin >> h[i];

  ll lb = 0, ub = 10000000000;
  while(ub - lb > 1){
    ll res = (lb + ub)/ 2;

    ll ct = 0;

    REP(i,n){
      if(h[i] - b * res > 0){
        // ct += ll(ceil((h[i] - b * res) / double(a-b)));
        ct+=(h[i] - b * res + a - b - 1) / (a-b);
      }
    }

    // REP(i,n){
    //     ct += max(0LL,(h[i] - b * res + a - b - 1) / (a-b));
    // }



    if(ct <= res){
      ub = res;
    }else{
      lb = res;
    }

  }

  cout << ub << endl;


  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;

uint getResult(const vector<pair<uint, uint>> &scales,
               const uint height, const uint width){
  uint result = 0;
  for(pair<uint, uint> scale : scales){
    if(scale.first >= height && scale.second >= width){
      result++;
    }
  }
  return result;
}

int main(){
  uint N, H, W;
  cin >> N >> H >> W;
  
  vector<pair<uint, uint>> AB(N);
  for(uint i = 0; i < N; i++){
    cin >> AB[i].first >> AB[i].second;
  }

  uint result = getResult(AB, H, W);
  cout << result;
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <climits>
#include <cstring>
using namespace std;

int n, m[22], d[22][32];
int cnt[32];
string name[22];

int main(){
  while(cin >> n, n){
    memset(cnt, 0, sizeof(cnt));

    for(int i = 0; i < n; i++){
      cin >> name[i] >> m[i];
      for(int j = 0; j < m[i]; j++){
        cin >> d[i][j];
        cnt[d[i][j]]++;
      }
    }

    string ansName = "";
    int ansScore = INT_MAX;

    for(int i = 0; i < n; i++){
      int score = 0;

      for(int j = 0; j < m[i]; j++){
        score += n - cnt[d[i][j]] + 1;
      }

      if(ansScore > score || ansScore == score && ansName > name[i]){
        ansName = name[i];
        ansScore = score;
      }
    }

    cout << ansScore << " " << ansName << endl;
  }
}

Measured memory_bytes: 1224
s = input()
n = len(s)
ans = "Yes"
if s != s[::-1]:
    ans = "No"
else:
    if s[:(n//2):-1] != s[:(n//2)]:
        ans = "No"
    if s[n//2 + 1::] != s[:(n//2):-1]:
        ans = "No"

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, A;
  cin >> N >> A;
  
  if (N <= A) {
    cout << "Yes" << endl;
    return 0;
  }
  // N > A 
  int modulo = N % 500;
  if (modulo > A) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lf;

ll N, M, LI, RI;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> N >> M;
    ll curl = 1, curr = N;
    for (ll i = 0; i < M; i++) {
        cin >> LI >> RI;
        curl = max(curl, LI);
        curr = min(curr, RI);
    }
    cout << max(curr-curl+1, 0LL) << "\n";
    
}

Measured memory_bytes: 256
fn main() {
    let nl = read_vec::<i32>();
    let n = nl[0];
    let l = nl[1];

    let mut mi_abs = i32::max_value();
    let mut sum = 0;
    for i in 1..n+1 {
        let taste = l + i - 1;
        sum += taste;
        if mi_abs.abs() > taste.abs() {
            mi_abs = taste;
        }
    }

    println!("{}", sum - mi_abs);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
#include <cstdio>
#include <complex>
#include <vector>
using namespace std;
typedef complex<double> P;

int main(){
    vector<P> ps;
    double x,y;
    while(~scanf("%lf,%lf\n",&x,&y)){
        ps.push_back(P(x,y));
    }
    double S=0;
    for(int i=1;i+1<ps.size();i++){
        S+=abs((conj(ps[i]-ps[0])*(ps[i+1]-ps[0])).imag())/2;
    }
    printf("%.8f\n",S);
}

Measured memory_bytes: 1084
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;
const int N = 2333;

int v[11],n,m,c[11][11],ans;

inline int check(){
	for(int i=1;i <= m;i++)
		if(v[i] == 0)
			return 0;
	return 1;
}

inline void dfs(int x){
	if(x > n){
		if(check())
			ans++;
		return;
	}
	dfs(x+1);
	for(int i=1;i <= m;i++)
		v[i] ^= c[x][i];
	dfs(x+1);
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i <= m;i++){
		int k,x;
		scanf("%d",&k);
		while(k--)
			scanf("%d",&x) , c[x][i] = 1;
	}
	int l;
	for(int i=1;i <= m;i++)
		scanf("%d",&l) , v[i] = !l;
	dfs(1);
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long a, b, c; cin >> a >> b >> c;
	long long ca = a, cb = b, cc = c;
	for(int i = 0; ; i++){
		if((a&1)+(b&1)+(c&1)) return !printf("%d\n", i);
		if(i && a == ca && b == cb && c == cc) return !printf("-1\n");
		long long na = (b + c)/2;
		long long nb = (a + c)/2;
		long long nc = (a + b)/2;
		a = na;
		b = nb;
		c = nb;
	}
	assert(0);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
  int n;
  cin >> n;
  int a = n / 100;
  int b = n % 10;
  if (a == b) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256