akhauriyash/Code-Regression huggingface dataset:
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];puts("");}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int a,b,c;
	cin>>a>>b>>c;
	for(int i=min(a,b);;i--){
		if(a%i==0&&b%i==0)c--;
		if(!c){
			cout<<i<<endl;
			return 0;
		}
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
ll n,a,b;
main ()  {
	cin>>n>>a>>b;
	
	if (abs(a-b)%2==0) cout<<abs(a-b)/2<<endl;
		else cout<<min((b-1+a-1+1)/2,(n-a+n-b+1)/2)<<endl;	
}

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

int main(void){
    int n, x;
    cin >> n >> x;
    vector<int> m(n);
    int ans = 0;
    for(int i=0; i<n; i++){
        cin >> m.at(i);
        x -= m.at(i);
        ans++;
    }

    ans += x / *min_element(m.begin(), m.end());

    cout << ans << endl;

    return 0;
}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    string s;cin>>s;
    int n = SIZE(s);
    REV(s);
    //dump(s)
    REP(i,n){
        s[i] -= '0';
    }

    VVL dp(n);
    REP(i,n){
        dp[i].resize(2);
    }

    if(s[0] == 1){
        dp[0][1] = 0;
        dp[0][0] = 3;
    }
    else{
        dp[0][1] = 2;
        dp[0][0] = 1;
    }

    FOR(i,1,n){
        if(s[i] == 1){
            dp[i][1] += dp[i-1][1]*2;
            dp[i][0] += dp[i-1][0]*2;
            dp[i][0] += dp[i-1][1];
            dp[i][0] += dp[i-1][0];

        }
        else{
            dp[i][1] += dp[i-1][1]*2;
            dp[i][1] += dp[i-1][0]*2;
            dp[i][1] += dp[i-1][1];
            dp[i][0] += dp[i-1][0];
        }
        dp[i][1] %= MOD;
        dp[i][0] %= MOD;
        //cerr<<i<<" "<<dp[i][1]<<" "<<dp[i][0]<<endl;
    }

    cout<<dp[n-1][0]<<endl;

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 5840
#include <stdio.h>

int main(void) {
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}, k;
  scanf("%d", &k);
  printf("%d", a[--k]);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	string s;
	cin>>s;
	for(int i=1;i<s.length();++i){
		string t=s.substr(0,s.length()-i);
		if(t.length()%2!=0){
			continue;
		}
		if(t.substr(0,t.length()/2)==t.substr(t.length()/2)){
			cout<<t.length();return 0;
		}
	}
	cout<<s.length();
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#define mod 1000000007
using namespace std;
typedef long long ll;
bool chmax(ll &a,ll b){
    if(a>b)return 0;
    a=b; return 1;
}
bool chmin(ll &a,ll b){
    if(a<b)return 0;
    a=b; return 1;
}

#define N 100010
ll h,w,d;
ll c[510][510];
int main(){
    cin>>h>>w>>d;
    for(int i=0;i<h;i++)for(int j=0;j<w;j++){
	ll x=(i+j)%(2*d); if(x<0)x+=2*d;
	ll y=(i-j)%(2*d); if(y<0)y+=2*d;
	c[i][j]=0;
	if(x<d)c[i][j]++;
	if(y<d)c[i][j]+=2;
    }
    for(int i=0;i<h;i++){
	for(int j=0;j<w;j++){
	    string s="RYGB";
	    cout<<s[c[i][j]];
	}cout<<endl;
    }
}



Measured memory_bytes: 2432
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

static const ll max_s = 500000;
ll dp[11][max_s] = {};
ll p[11] = {};
ll c[11] = {};
int main() {
	ll d, g; cin >> d >> g;
	g /= 100;
	repe(i, 1, d) {
		cin >> p[i];
		ll C; cin >> C;
		c[i] = C / 100;
	}
	repe(i, 0, d)rep(j, 0, max_s) dp[i][j] = MAX_L;
	dp[0][0] = 1;

	repe(i, 1, d) {
		rep(point, 0, max_s - 25000) {
			repe(k, 1, p[i]) {
				ll points = k * i;
				if (k == p[i]) {
					points += c[i];
				}

				if (dp[i - 1][point] != 0) {
					dp[i][point + points] = min(dp[i][point + points], dp[i - 1][point] + k);
					dp[i][point] = min(dp[i][point], dp[i - 1][point]);
				}
			}
		}
	}

	ll minS = MAX_L;
	rep(s, 1, max_s) {
		if (dp[d][s] != MAX_L && g <= s) {
			minS = min(minS, --dp[d][s]);
		}
	}
	cout << minS << endl;

	return 0;
}

Measured memory_bytes: 43264
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,n;
	scanf("%d %d %d",&n,&a,&b);
	if((b-a)%2)
	{
		printf("Borys");
	}
	else
	{
		printf("Alice");
	}
	return 0;
}

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

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

Measured memory_bytes: 3924
import bisect
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
a=sorted(A)
b=sorted(B)
c=sorted(C)
ans=0
for i in range(len(b)):
    index_a=bisect.bisect_left(a,b[i])
    index_c=bisect.bisect_right(c,b[i])
    ans+=(index_a*(len(c)-index_c))
print(ans)

Measured memory_bytes: 29372
h = int(input())
w = int(input())
n = int(input())

sum = 0
if h > w:
  for i in range(n):
    sum += h
    if sum >= n:
      print(i+1)
      break
else:
  for i in range(n):
    sum += w
    if sum >= n:
      print(i+1)
      break

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <numeric>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
    // 整数の入力
    int N, M, i;
    vector<long> x;
    vector<long> y;
    vector<long> z;

    cin >> N >> M;

    x = vector<long>(N, 0);
    y = vector<long>(N, 0);
    z = vector<long>(N, 0);

    vector<long> sum_ppp;
    vector<long> sum_ppn;
    vector<long> sum_pnp;
    vector<long> sum_pnn;
    vector<long> sum_npp;
    vector<long> sum_npn;
    vector<long> sum_nnp;
    vector<long> sum_nnn;

    for(i = 0; i < N; ++i) {
        cin >> x[i] >> y[i] >> z[i];
    }

    for(i = 0; i < N; ++i) {
        sum_ppp.push_back( +x[i] +y[i] +z[i]);
        sum_ppn.push_back( +x[i] +y[i] -z[i]);
        sum_pnp.push_back( +x[i] -y[i] +z[i]);
        sum_pnn.push_back( +x[i] -y[i] -z[i]);
        sum_npp.push_back( -x[i] +y[i] +z[i]);  
        sum_npn.push_back( -x[i] +y[i] -z[i]);
        sum_nnp.push_back( -x[i] -y[i] +z[i]);
        sum_nnn.push_back( -x[i] -y[i] -z[i]);

        sort(sum_ppp.begin(), sum_ppp.end(), greater<long>());
        sort(sum_ppn.begin(), sum_ppn.end(), greater<long>());
        sort(sum_pnp.begin(), sum_pnp.end(), greater<long>());
        sort(sum_pnn.begin(), sum_pnn.end(), greater<long>());
        sort(sum_npp.begin(), sum_npp.end(), greater<long>());
        sort(sum_npn.begin(), sum_npn.end(), greater<long>());
        sort(sum_nnp.begin(), sum_nnp.end(), greater<long>());
        sort(sum_nnn.begin(), sum_nnn.end(), greater<long>());

        if (sum_ppp.size() > M) {
            sum_ppp.pop_back();
            sum_ppn.pop_back();
            sum_pnp.pop_back();
            sum_pnn.pop_back();
            sum_npp.pop_back();
            sum_npn.pop_back();
            sum_nnp.pop_back();
            sum_nnn.pop_back();
        }
    }

    long retval;

    long sum;
    retval = accumulate(sum_ppp.begin(), sum_ppp.end(), 0LL);
    sum = accumulate(sum_ppn.begin(), sum_ppn.end(), 0LL);
    retval = max(sum, retval);
    sum = accumulate(sum_pnp.begin(), sum_pnp.end(), 0LL);
    retval = max(sum, retval);
    sum = accumulate(sum_pnn.begin(), sum_pnn.end(), 0LL);
    retval = max(sum, retval);
    sum = accumulate(sum_npp.begin(), sum_npp.end(), 0LL);
    retval = max(sum, retval);
    sum = accumulate(sum_npn.begin(), sum_npn.end(), 0LL);
    retval = max(sum, retval);
    sum = accumulate(sum_nnp.begin(), sum_nnp.end(), 0LL);
    retval = max(sum, retval);
    sum = accumulate(sum_nnn.begin(), sum_nnn.end(), 0LL);
    retval = max(sum, retval);

    cout << retval;

    return 0;
}

Measured memory_bytes: 384
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;

int dp[1<<18];

void update(int idx, int num) {
  dp[idx] = num;
  while (idx > 1) {
    idx /= 2;
    dp[idx] = __gcd(dp[idx*2], dp[idx*2+1]);
  }
}

map<int, int> ret;

bool estimate(vector<int>& A, int mult) {
  if (ret.find(mult) != ret.end()) return ret[mult];
  int even = 0;
  for (int i=0; i<A.size(); i++)
    if ((A[i]/mult)%2 == 0) even ++;
  if (even % 2 == 1) return true;

  bool res = false;
  for (int i=0; i<A.size(); i++) {
    if (A[i] == mult) continue;
    A[i] -= mult;
    update(i + (1<<17), A[i]);
//    printf("%d\n", dp[1]);
    if (dp[1] > mult && !estimate(A, dp[1])) res = true;
    A[i] += mult;
    update(i + (1<<17), A[i]);
  }
//  for (int i=0; i<A.size(); i++) printf("%d ", A[i]);
//  printf("%d = %d\n", mult, res);
  return ret[mult] = res;
}

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i=0; i<N; i++) {
    cin >> A[i];
    update((1<<17)+i, A[i]);
  }
  if (estimate(A, 1)) printf("First\n"); else printf("Second\n");
}


Measured memory_bytes: 1408
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define debug(var) cout << #var << ": " << var << endl
using namespace std;
using Int = int64_t;
using Uint = uint64_t;
constexpr Uint mod = 1e9 + 7;
constexpr Int INF = INT_MAX;
using Container = vector<Int>;
template<typename T>
using Grid = vector<vector<T>>; // 二次元配列。[y][x]
template<typename T, typename U>
using Umap = unordered_map<T, U>;
template<typename T>
using Uset = unordered_set<T>;
template<typename T>
using P = pair<T, T>;

int main() {

	string S; cin >> S;
	Int length = S.size();
	rep(i, length)cout << 'x';

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll n, t;
  cin >> n >> t;
  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; }

  ll mn = a[0], mx = 0;
  FOR(i, 1, n) {
    mx = max(mx, a[i] - mn);
    mn = min(mn, a[i]);
  }
  ll ans = 0;
  mn = a[0];
  FOR(i, 1, n) {
    if (a[i] - mn == mx) {
      ans++;
    }
    mn = min(mn, a[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int zettaiti(int x) {
	return x >= 0 ? x : -x;
}

int main(void) {
	int n, m;
	int a, b, c, d;
	int as = 0, bs = 0, cs = 0, ds = 0, ss = -1;
	int heikin, chuuou, score;
	int i;
	if (scanf("%d%d", &n, &m) != 2) return 1;
	if (n == 1) {
		printf("%d\n", m);
	} else if (n == 2) {
		printf("%d %d\n", m, m);
	} else if (n % 2 != 0) {
		for (a = 0; a <= m; a++) {
			for (b = a; b <= m; b++) {
				for (c = b; c <= m; c++) {
					heikin = a * (n / 2) + b + c * (n / 2);
					chuuou = b * n;
					score = zettaiti(heikin - chuuou);
					if (score > ss) {
						as = a;
						bs = b;
						cs = c;
						ss = score;
					}
				}
			}
		}
		for (i = 0; i < n / 2; i++) printf("%d ", as);
		printf("%d", bs);
		for (i = 0; i < n / 2; i++) printf(" %d", cs);
		putchar('\n');
	} else {
		for (a = 0; a <= m; a++) {
			for (b = a; b <= m; b++) {
				for (c = b; c <= m; c++) {
					for (d = c; d <= m; d++) {
					heikin = (a * (n / 2 - 1) + b + c + d * (n / 2 - 1)) * 2;
					chuuou = (b + c) * n;
					score = zettaiti(heikin - chuuou);
					if (score > ss) {
						as = a;
						bs = b;
						cs = c;
						ds = d;
						ss = score;
					}
					}
				}
			}
		}
		for (i = 0; i < n / 2 - 1; i++) printf("%d ", as);
		printf("%d %d", bs, cs);
		for (i = 0; i < n / 2 - 1; i++) printf(" %d", ds);
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
 
long long A, B, C, D, E, F;
 
int main()
{
	cin >> A >> B >> C >> D >> E >> F;
	double db = -1;
	long long t, s;
	for (int i = 0; i <= 30; i++) {
		for (int j = 0; j <= 30; j++) {
			for (int k = 0; k <= 3000; k++) {
				long long tot = (i*A+j*B)*100;
				long long cnt = min((long long)(((double)tot*E/100-k*C)/D), (F-tot-k*C)/D);
				long long sug = k*C+cnt*D;
				if (tot*E-100*k*C < 0 || tot+k*C > F) continue;
				if (sug*100 > tot*E || tot+sug > F || tot+sug == 0) continue;
				if (sug*100.0/(tot+sug) > db) {
					db = sug*100.0/(tot+sug);
					t = tot, s = sug;
				}
			}
		}
	}
	if (db >= 0)
		cout << t+s << " " << s << endl;
	else cout << F << " " << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
//  main.cpp
//  APB3

#include <iostream>
#include <vector>
using namespace std;
int main(int argc, const char * argv[]) {

    {
        long long MOD = 998244353;
        int N;
        cin >> N;
        vector<long long>D(N);
        int dt;
        cin >> dt;
        if (dt!=0) // 頂点０の自分までの距離は０でなければならない。
        {
            cout << 0<<endl;
            return 0;
        }
        else {
            D.at(0) = 1;
        }
        for (int i = 1; i < N; i++) // データの読み込み
        {
            cin >> dt;
            D.at(dt)++;
        }
        if (D.at(0)!=1) // 根が２箇所以上あってはならない。
        {
            cout << 0<<endl;
            return 0;
        }
        bool zero=false;
        for (int j=1; j<N; j++) { // 途中に０個があってはならない。木が繋がらないから。
            if (D.at(j)==0) {
                zero=true;
            }
            if (D.at(j)!=0&&zero==true) {
                cout<<0<<endl;
                return 0;
            }
        }
        long long ans = 1;
        for (int i = 2; i < N; i++) // powを使わないで計算
        {
            for (int j=0; j<D.at(i); j++) {
                ans=ans*D.at(i-1)%MOD;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 1152
program main
	implicit none
    integer::a,b,c,d,i
    real::x,y
    read(*,*)a,b
    c=-1
    do i=1000,1,-1
    	if (int(i*0.08)==a .and. int(i*0.1)==b)then
            c=i
        end if
    end do
    
    write(*,*) c
    stop
end program main

Measured memory_bytes: 256
from fractions import gcd

N, K = map(int, input().split())
As = list(map(int, input().split()))

max_num = max(As)
prev = As[0]
for i in range(1, len(As)):
    prev = gcd(prev, As[i])

if K % prev == 0 and K <= max_num:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 16212
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;



int main(void) {
  string s, t;
  cin >> s >> t;
  ll cs[26]={}, ct[26]={};
  ll i;
  
  for(i=0; i<s.size(); i++) {
    ll ids=s[i]-'a';
    ll idt=t[i]-'a';
    cs[ids]++; ct[idt]++;
  }
  sort(cs, cs+26); sort(ct, ct+26);
  
  ll f=1;
  for(i=0; i<26; i++) {
    if(cs[i]!=ct[i]) f=0;
  }
  
  if(f) pt("Yes");
  else pt("No");
  
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> testimony(n, vector<int>(n, -1));
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        for (int j = 0; j < a; j++) {
            int x, y;
            cin >> x >> y;
            x--;
            testimony[i][x] = y;
        }
    }
    int ans = 0;
    for (int i = 0; i < (1 << n); i++) {
        bitset<15> bit(i);
        bool flag = true;
        for (int j = 0; j < n; j++) {
            if (!bit[j]) continue;
            for (int k = 0; k < n; k++) {
                if (testimony[j][k] == -1) continue;
                if (bit[k] != testimony[j][k]) {
                    flag = false;
                    break;
                }
            }
        }
        if (flag) {
            int temp = 0;
            for (int j = 0; j < 15; j++) {
                if (bit[j]) temp++;
            }
            ans = max(ans, temp);
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;

const int INF = 1 << 30;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 250;

int main() {
	int h; cin >> h;
	int k[N];
	rep(i, h) cin >> k[i];
	for (int i = 1; i <= h; i++) {
		cout << "node " << i << ": key = " << k[i-1] << ", ";
		if (i > 1) cout << "parent key = " << k[i/2-1] << ", ";
		if (2*i <= h) cout << "left key = " << k[2*i-1] << ", ";
		if (2*i+1 <= h) cout << "right key = " << k[2*i] << ", ";
		cout << endl;
	}
}



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

int main()
{
	string s;
	cin >> s;
	int j = 0;
	for(int i = 0; i < s.length();++i){
		if(i%2 == 0){
			if(s[i] == 'L') ++j;
		}
		else{
			if(s[i] == 'R') ++j;
		}
	}
	if(j==0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main(){
    map<char, int> mp;
    for (char str='a'; str<='z'; str++){
        mp[str] = 0;
    }
    string s; cin >> s;
    for (int i=0; i<s.length(); i++){
        mp[s[i]] += 1;
    }
    string ans = "Yes";
    for (char str='a'; str<='z'; str++){
        if (mp[str] % 2 != 0){
            ans = "No";
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,cnt=0;
  cin>>n;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    while(a%2==0){
      a/=2;
      cnt++;
    }
  }
  cout<<cnt<<endl;
  return(0);
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n,abcc[100][27]={0},i,j,ans,max=0;
	char abc[3][101];
	scanf("%d%s%s%s",&n,abc[0],abc[1],abc[2]);
	for(i=0;i<n;i++){
		abcc[i][abc[0][i]-'a']++;
		abcc[i][abc[1][i]-'a']++;
		abcc[i][abc[2][i]-'a']++;
	}
	for(i=0;i<n;i++){
		max=0;
		for(j=0;j<27;j++){
			if(max<abcc[i][j])max=abcc[i][j];
		}
		ans+=3-max;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
K = int(input())
if K >= 50:
  N = 50
  wari = K//N -1
  amari = K%N
  l = [(50+wari)+1]*amari + [(50+wari)-amari]*(N-amari)
if 50>K>1:
  N = K
  l = [K]*K
if K == 1:
  N = 2
  l = [0,2]  
if K == 0:
  N = 2
  l = [1,1]
##
print(N)
print(*l)

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

int main() {
int N;
  cin>>N;
  vector<int> X(N);
  for(int i=0;i<N;i++) cin >> X[i];
  int ans = 10000000;
  for(int i=1;i<=100;i++){
    int wa =0;
    for(int j=0;j<N;j++){
     wa += (i-X[j])*(i-X[j]); 
    }
    ans = min(ans,wa);
  }
  printf("%d\n",ans);
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  for (auto it = vc.begin(); it != vc.end(); ++it)
  {
    if (std::next(it) == vc.end())
      os << *it;
    else
      os << *it << '\n';
  }
  return os;
}

template<class T1, class T2>
inline
std::ostream & operator<<(std::ostream & os, const std::pair<T1, T2> & p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  using std::cin;
  using std::cout;
  ui A{}, B{}, Q{}; std::cin >> A >> B >> Q;
  vector<ll> S(A + 2), T(B + 2), X(Q);
  rep(1, S.size() - 1) cin >> S[i];
  rep(1, T.size() - 1) cin >> T[i];
  rep(0, X.size()) cin >> X[i];
  S[0] = std::numeric_limits<ll>::min() / 5;
  T[0] = std::numeric_limits<ll>::min() / 5;
  S[S.size() - 1] = std::numeric_limits<ll>::max() / 5;
  T[T.size() - 1] = std::numeric_limits<ll>::max() / 5;

  vector<ll> ans(X.size());
  rep(0, X.size())
  {
    auto s1 = boost::lower_bound(S, X[i]);
    auto t1 = boost::lower_bound(T, X[i]);
    auto s0 = std::prev(s1);
    auto t0 = std::prev(t1);
    
    auto dis0 = std::abs(*s0 - X[i]) + std::abs(*t0 - *s0);
    auto dis1 = std::abs(*t0 - X[i]) + std::abs(*s0 - *t0);
    auto dis2 = std::abs(*s0 - X[i]) + std::abs(*t1 - *s0);
    auto dis3 = std::abs(*t1 - X[i]) + std::abs(*s0 - *t1);
    auto dis4 = std::abs(*s1 - X[i]) + std::abs(*t0 - *s1);
    auto dis5 = std::abs(*t0 - X[i]) + std::abs(*s1 - *t0);
    auto dis6 = std::abs(*s1 - X[i]) + std::abs(*t1 - *s1);
    auto dis7 = std::abs(*t1 - X[i]) + std::abs(*s1 - *t1);

    auto dis = std::min({dis0, dis1, dis2, dis3, dis4, dis5, dis6, dis7});

    ans[i] = dis;
  }

  cout << ans << '\n';
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 4480
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
    ll straight = min(K, X / D);
    K -= straight;
    X -= straight * D;
    if (K % 2 == 0) {
        cout << X << endl;
    }
    else {
        cout << D - X << endl;
    }
}

Measured memory_bytes: 3600
from collections import deque

N, M = map(int, input().split())

G = dict()

for i in range(1, 3 * N + 1):
    G[i] = dict()

for _ in range(M):
    u, v = map(int, input().split())
    G[u][N + v] = 1
    G[N + u][2 * N + v] = 1
    G[2 * N + u][v] = 1

S, T = map(int, input().split())

dist_S = [3 * N + 1] * (3 * N + 1)
dist_S[S] = 0

# BFS
queue = deque([S])
while len(queue) > 0:
    p = queue.popleft()
    for q in G[p].keys():
        if dist_S[p] + 1 < dist_S[q]:
            dist_S[q] = dist_S[p] + 1
            queue.append(q)

if dist_S[T] < 3 * N + 1:
    print(dist_S[T] // 3)
else:
    print(-1)


Measured memory_bytes: 136672
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
#define ALL(x) x.begin(),x.end()
#define P pair<int,int>
#define MOD 1000000007

const ll MAX_N = pow(10, 18);

int main()
{
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(a.rbegin(), a.rend());
  ll res = 0;
  ll dual;
  if (a[n - 1] != 0) {
    rep(i, n) {
      if (i == 0) {
        res = a[i];
        dual = MAX_N / res;
      } else {
        if (dual < a[i]) {
          res = -1;
          break;
        } else {
          res *= a[i];
          dual = MAX_N / res;
        }
      }
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 4036
import math
import os
ans = 0
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
n = int(input())
arr = factorization(n)
if n==1:
    print(0)
    exit()

for i in range(len(arr)):
    arfa = arr[i][1]
    ans += math.floor((-1+math.sqrt(1+8*arfa))/2)
print(ans)


Measured memory_bytes: 9512
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
int main() {
    string a,b;
    cin>>a>>b;
    string ans="EQUAL";
    if(a.size()>b.size()) ans="GREATER";
    else if(a.size()<b.size()) ans="LESS";
    else if(a>b) ans="GREATER";
    else if(a<b) ans="LESS";
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define ulli unsigned long long int
#define lli long long int
#define llv vector< ll >
#define llc vector< char >
#define lls vector< string >
#define llb vector< bool >
#define mp make_pair
#define endl "\n"
#define degb cout<<"HI"<<endl;
#define ins insert
#define foo(i,n) for(ll i = 0;i<n;i++)
#define foa(i,a) for(auto i = a.begin();i!=a.end();i++)
#define foe(i,a,b) for(ll i = a;i<=b;i++)
#define INF 2147483647
#define siz size
#define len length

int main(){
   /* #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    lli a,b;
  cin>>a>>b;
  if((a+b)%2==0){
    cout<<(a+b)/2;
  }
  else {
    cout<<"IMPOSSIBLE";
  }
   
 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
 
     
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int s;
    cin>>s;
    map<int,bool>m;
    int sub;
    for(int i=1;true;i++){
        if(m[s]==true){sub=i;break;}
        m[s]=true;
        if(s%2==0){s/=2;}
        else{s=3*s+1;}
    }
    cout<<sub<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

int main()
{
    map <string, vector < pair <int,int> > > mp;
    int n;
    cin >> n;

    string str;
    int score;
    int i;

    for(i = 0; i < n; i ++)
    {
    	cin >> str;
    	cin >> score;

    	mp[str].push_back(make_pair(score, i + 1));
    }

    for(auto it = mp.begin(); it != mp.end(); it ++)
    {
    	int size = it -> second.size();
    	sort(it->second.begin(), it->second.end());
    	for(i = size - 1; i >= 0; i --)
    	{
    		cout << it -> second[i].second << endl;
    	}
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d,count;
  count = 0;
  cin >> n >> d;
  for(int i=0;i<n;i++){
    double x,y;
    cin >> x >> y;
    if(sqrt(x*x+y*y)<=d){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3844
using System;
using System.Linq;

namespace ITP1_2_A_Small_Large_or_Equal
{
    class Program
    {
        static void Main(string[] args)
        {
            var dif = Console.ReadLine().Split(' ').Select(int.Parse).Aggregate((acc,n)=> acc - n);
            Console.WriteLine( dif > 0 ? "a > b" : dif < 0 ? "a < b" : "a == b" );
        }
    }
}

Measured memory_bytes: 7652
n = gets.to_i
a = gets.split.map(&:to_i)
hash = Hash.new
ans = 0
a.each do |e|
   if hash[e]
     hash[e] += 1
   else
     hash[e] = 1
   end
end
hash.each {|k,v|
  if k < v
    ans += v-k
  elsif k > v
    ans += v
  end
}

puts ans


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

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i=0;i<N;i++) {
    cin >> L.at(i);
  }
  int X=0;
  for (int i=0;i<N-2;i++) {
    for (int j=i+1;j<N-1;j++) {
      for (int k=j+1;k<N;k++) {
        int a=L.at(i);
        int b=L.at(j);
        int c=L.at(k);
        if (a+b>c&&b+c>a&&c+a>b) {
          if (a!=b&&b!=c&&c!=a) {
            X++;
          }
        }
      }
    }
  }
  cout << X << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
#define N 1000000
int que[N],l,r;

void push(int x){
  que[r]=x;
  r++;
  if(r>=N) r=0;
}
int pop(){
  int d=que[l];
  l++;
  if(l>=N) l=0;
  return d;
}
int main(){
  l=r=0;
  int n,q,i;
  scanf("%d%d",&n,&q);
  char ch[n][10];
  int c[n];
  for(i=0; i<n; i++) {
    scanf("%s %d",ch[i],&c[i]);
    push(i);
  }
  int sum=0;
  while(l!=r){
    int x=pop();
    if(q<c[x]){
      sum+=q;
      c[x]-=q;
      push(x);
    }else{
      sum+=c[x];
      printf("%s %d\n",ch[x],sum);
    }
  }
  return 0;
}



Measured memory_bytes: 3088
b_list = list(str(input()))
b_list = sorted(b_list)

if b_list[0] == b_list[1] and b_list[1] == b_list[2]:
    print("No")
elif b_list[0] == b_list[1] and  b_list[2] == b_list[3]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
num_list = [int(input()) for _ in range(5)]
res = []
zero = []
one = []
two = []
three = []
four = []
five = []
for n in num_list:
    if n%10 > 5:
        res.append(n)
for n in num_list:
    if n%10 == 0:
        zero.append(n)
    elif n%10 == 1:
        one.append(n)
    elif n%10 == 2:
        two.append(n)
    elif n%10 == 3:
        three.append(n)
    elif n%10 == 4:
        four.append(n)
    elif n%10 == 5:
        five.append(n)
sum = 0
res.extend(zero)
res.extend(five)
res.extend(four)
res.extend(three)
res.extend(two)
res.extend(one)
for i,v in enumerate(res):
    plus = 0
    if v%10==0:
        pass
    else:
        plus = 10-v%10
    if i == 4:
        sum += v
        break
    else:
        sum += v + plus
print(sum)

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

int main(){
    int a,b,x;cin>>a>>b>>x;
    if(a+b>=x&&a<=x){
        cout << "YES" <<endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
A = list(map(int, input().split()))

right = 10**9
left=0

while right-left>1:
    mid=(left+right)//2
    count = 0
    for a in A:
        count+=a//mid
        if a%mid==0:
            count -=1
    if count<=k:
        right = mid
    else:
        left = mid
print(right)


Measured memory_bytes: 30780
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main(){
  ll a,b;
  cin>>a>>b;
  
  ll d=b-a;
  
  cout<<d*(d+1)/2-b<<endl;
  
  return 0;
}

Measured memory_bytes: 3604
import copy

n = int(input())
p = list(map(int, input().split()))

q = copy.copy(p)

q.sort()

kaisu = 0

for i in range(n):
  if p[i] != q[i]:
    kaisu += 1

if kaisu == 0 or kaisu == 2:
  print("YES")
else:
  print("NO")


Measured memory_bytes: 38384
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for(int i=1; i<=5;i++) {
			if(Integer.parseInt(sc.next()) == 0) {
				System.out.println(i);
				return;
			}
		}
	}
}


Measured memory_bytes: 35556
n = int(raw_input())
travel = [map(int, raw_input().split()) for i in range(n)]

loc = (0,0)
now = 0
res = 'Yes'

for dest in travel:
  t, x, y = dest
  minpath = abs(x-loc[0]) + abs(y-loc[1])
  tmp = (t-now)-minpath
  if (tmp%2==0 and tmp>=0 ):
    loc = (x,y)
    now = t
    continue
  else:
    res = 'No'
    break
print res


Measured memory_bytes: 21508
# how many ways can diveide "K"
n = input()
arr = [int(x) for x in input().split()]
arr.sort()
l = len(arr)
ans = 0
if l%2 == 0:
	if arr[l//2] != arr[l//2-1]:
		ans = (arr[l//2] - arr[l//2 -1])
print(ans)

Measured memory_bytes: 52780
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K,X;
    cin >> K >> X;
    cout << (500*K>=X? "Yes":"No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define INF 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

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

	int N,L;
	cin >> N >> L;

	vector<pair<int,int>> v(N);
	rep(i,N){
		v[i].second = L + i;
		v[i].first = abs(v[i].second);
	}

	sort(v.begin(),v.end());

	int ans = 0;
	repk(i,1,N){
		ans += v[i].second;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    A = [input() for _ in range(N)]
    B = [input() for _ in range(M)]
    for i in range(N):
        for j in range(N):
            f = True
            for k in range(M):
                for l in range(M):
                    if i + k >= N or j + l >= N:
                        f = False
                        break
                    if A[i + k][j + l] != B[k][l]:
                        f = False
                        break
                if f is False:
                    break
            if f is True:
                print('Yes')
                exit()
    print('No')


main()


Measured memory_bytes: 3064
N = gets.chomp.to_i

1.upto(10) do |i|
    payment = 1000 * i
    if payment >= N then
        puts (payment - N).to_s
        exit
    end
end

# n = N[-3, 3].to_i
# if n == 0 then
#     puts 0
# else
#     puts (1000 - n)
# end


Measured memory_bytes: 14396
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    """
    n k
    x1, x2, ... xn

    5 3
    -30 -10 10 20 50
    K個は連続する区間で考えればよい。
    区間を決めると、原点から最初に負の方向に行くか、
    正の方向に行くかはすぐに決められる

    つまり
    k = 3なら
    [-30, -10, 10], [-10, 10, 20], [10, 20, 50]
    の３つに分けるっていうこと？
    """
    n,k = readInts()
    X = readInts()

    res = float('inf')
    for i in range(n-k+1):# n =5なら、 i:0 ~ 2まで回す [0:2],[1:3],[2,4]って感じ [3,6]は範囲外だからだめ
        left = X[i]
        right = X[i+k-1]
        #print(left,right,abs(left) + right - left,abs(right) + right - left)
        # abs(X[i] - X[i+k-1])で、端から端までの移動距離を求めて、
        # min(abs(X[i]), abs(X[i+k-1]))で、左、右どっちから始まるかを決める
        # どっちかまでいく移動距離 + 端から端までの移動距離 で最小値を求めることができる!!
        res = min(res, min(abs(left), abs(right)) + right - left)
    print(res)



if __name__ == '__main__':
  main()


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    string k; int d; cin >> k >> d;

    int n = k.length();
    const int mod = 1e9+7;

    int dp[n+1][2][d]; 
    memset(dp[n], 0, sizeof dp[n]);
    dp[n][0][0] = dp[n][1][0] = 1;

    RFOR(i,n-1,0) FOR(bnd,0,1) FOR(x,0,d-1) {
        int& a = dp[i][bnd][x] = 0;
        if (bnd) {
            FOR(y,0,k[i]-'1'){
                a = (a + dp[i+1][0][(x+y)%d]) % mod;
            }
            a = (a + dp[i+1][bnd][(x+(k[i]-'0'))%d]) % mod;
        } else {
            FOR(y,0,9){
                a = (a + dp[i+1][0][(x+y)%d]) % mod;
            }
        }
    }

    cout << (dp[0][1][0]-1+mod)%mod << endl;
}



Measured memory_bytes: 8064
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <fstream>
//#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const ll INF = (1 << 30);
const ll inf = (1LL << 50LL);
const int  maxn = 1e5 + 5;
const int MOD = 1e9 + 7;
int n, k;
int arr[maxn];
int dp[maxn];
int rek(int left){
    if(dp[left] != -1){
        return dp[left];
    }
    int ret = 1;
    for(int i = 0; i <n; i ++){
        if(left >= arr[i]){
            ret &= rek(left - arr[i]);
        }
    }
    return dp[left] = !ret;
}
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
//    ifstream cin("in.txt");
    cin >> n >> k;
    for(int i = 0; i < n; i ++){
        cin >> arr[i];
    }
    memset(dp, -1, sizeof dp);
    if(rek(k)) {
        cout << "First\n";
    }
    else{
        cout << "Second\n";
    }
    return 0;
}


Measured memory_bytes: 5376
using System;
//using System.Collections;
//using System.Collections.Generic;
//using System.Linq;

namespace problem
{
  class Test
  {
    static void Main()
    {
      new Test().Keisan();
    }

    public void Keisan()
    {
      while (true)
      {
        var s = Console.ReadLine().Split();
        int a = int.Parse(s[0]);
        int b = int.Parse(s[2]);

        switch (s[1])
        {
          case "+":
            Console.WriteLine(a + b);
            break;

          case "-":
            Console.WriteLine(a - b);
            break;

          case "*":
            Console.WriteLine(a * b);
            break;

          case "/":
            Console.WriteLine(a / b);
            break;

          case "?": return;
        }
      }
    }
  }
}


Measured memory_bytes: 9192
// https://atcoder.jp/contests/abc113/tasks/abc113_d

#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,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int H_MAX = 100;
const int W_MAX = 8;
const int S_MAX = 1 << (W_MAX - 1);
const int MOD = 1000000007;

int H, W, K;

int S;
int lcnt[W_MAX];
int ccnt[W_MAX];
int rcnt[W_MAX];
ll dp[H_MAX + 1][W_MAX];

void init_tbl() {
  S = 1 << (W - 1);
  REP(i, S) {
    bool valid = true;
    REP(j, W - 2) {
      if ((i >> j & 1 > 0) && (i >> (j + 1) & 1 > 0)) {
        // printf("invalid: i=%d j=%d\n", i, j);
        valid = false;
        break;
      }
    }
    if (!valid) continue;
    // printf("i: %d\n", i);
    REP(j, W) {
      if ((j > 0) && (i >> (j - 1) & 1 > 0)) {
        // turn left
        lcnt[j]++;
        // printf("%d : L\n", j);
      } else if ((j < W - 1) && (i >> j & 1 > 0)) {
        // turn right
        rcnt[j]++;
        // printf("%d : R\n", j);
      } else {
        // go straight
        ccnt[j]++;
        // printf("%d : C\n", j);
      }
    }
  }
}

void solve() {
  init_tbl();
  dp[0][0] = 1;
  REP(i, H) {
    REP(j, W) {
      if (j > 0) dp[i + 1][j - 1] = (dp[i + 1][j - 1] +(dp[i][j] * lcnt[j] % MOD)) % MOD;
      dp[i + 1][j] = (dp[i + 1][j] + (dp[i][j] * ccnt[j] % MOD)) % MOD;
      if (j < W - 1) dp[i + 1][j + 1] = (dp[i + 1][j + 1] + (dp[i][j] * rcnt[j] % MOD)) % MOD;
    }
  }

  printf("%lld\n", dp[H][K - 1]);
}

void input() {
  scanf("%d%d%d", &H, &W, &K);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };
 
vector<int> divisors(int num) {
	unordered_set<int> st;

	int root = sqrt(num);
	REP(i, 1, root + 1) {
		if (num % i == 0) {
			st.insert(i);
			st.insert(num / i);
		}
	}

	vector<int> ret = vector<int>(all(st));
	sort(all(ret));

	return ret;
}

signed main() {
	int N, M;
	cin >> N >> M;

	auto divs = divisors(M);

	int ret = 1;

	for (int div : divs) {
		if (div * N > M) break;
		ret = div;
	}

	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
# include <cmath>
# include <iostream>
# include <queue>
# include <set>
# include <stack>
# include <string>
# include <vector>
# include <map>


using namespace std;


int rate2index (int x) {
    if (1    <= x and x <= 399)  return 0;
    if (400  <= x and x <= 799)  return 1;
    if (800  <= x and x <= 1199) return 2;
    if (1200 <= x and x <= 1599) return 3;
    if (1600 <= x and x <= 1999) return 4;
    if (2000 <= x and x <= 2399) return 5;
    if (2400 <= x and x <= 2799) return 6;
    if (2800 <= x and x <= 3199) return 7;
    else return 8;
}

int main() {
    int n; cin >> n;

    int a;
    int index;
    map<int, int> c;
    for (int i=0; i<n; i++) {
        cin >> a; index = rate2index(a);
        if (c.find(index) == c.end()) c[index] = 1;
        else c[index]++;
    }

    int max = 0;
    int min = 0;
    for (int i=0; i<8; i++) {
        if (c.find(i) != c.end()) {
            max++;
            min++;
        }
    }

    if (c.find(8) != c.end()) {
        max += c[8];
        if (min == 0) min++;
    }

    cout << min << " " << max << endl;
    return 0;
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
typedef pair<int,int> P;
struct edge{int to, id;};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000

int main(){
    int a;
    cin >> a;
    int ans = a + a * a + a * a * a;
    cout << ans << endl;
}

Measured memory_bytes: 3632
#!/usr/bin/env python3
import sys


def solve(N: int, a: "List[int]"):
    ans = 0
    f = True

    while(f):
        d2 = 0
        b3 = 0
        for i in range(N):
            if(a[i]%2 == 0):
                a[i] = int(a[i]/2)
                d2 += 1
            else:
                b3 += 1
            
        if(d2 != 0):
            f = True
            ans += d2
        else:
            f = False

    print(ans)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


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

using namespace std;

const int N = 1e6 + 5;

int n, a[N], cnt[N];
long long dp[N];

int gcd (int x, int y) {
    int r = 0;
    while (y != 0) {
        r = x % y;
        x = y;
        y = r;
    }

    return x;
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i], cnt[a[i]]++;

    int g = 0;
    for (int i = 1; i <= n; i++) g = gcd(g, a[i]);
    for (int i = 1; i < N; i++) {
        for (int j = i + i; j < N; j += i) {
            cnt[i] += cnt[j];
        }
    }

    for (int i = N - 1; i >= 1; i--) {
        dp[i] = 1LL * cnt[i] * (cnt[i] - 1) / 2;
        for (int j = i + i; j < N; j += i) {
            dp[i] -= dp[j];
        }
    }

    if (dp[1] == 1LL * n * (n - 1) / 2) cout << "pairwise coprime" << endl;
    else if (g == 1) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
    return 0;
}


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

int main() {
    string s; cin >> s;
    if (s[0] == s.back()) {
        if (s.size() & 1) puts("Second");
        else puts("First");
    }
    else {
        if (s.size() & 1) puts("First");
        else puts("Second");
    }
}

Measured memory_bytes: 3724
S = input()
cand1 = ["KIHBR", "KIHBRA", "KIHBAR", "KIHBARA", "KIHABR", "KIHABRA", "KIHABAR", "KIHABARA"]
cand2 = ["AKIHBR", "AKIHBRA", "AKIHBAR", "AKIHBARA", "AKIHABR", "AKIHABRA", "AKIHABAR", "AKIHABARA"]

if S in cand1 or S in cand2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060