akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<limits>
#include<algorithm>
#include<numeric>
#include<utility>
#include<iomanip>

using ULLI = unsigned long long int;
using LLI = long long int;

using namespace std;

template<class T>
class ModCal{
private:
    const ULLI MAX = 1000000;
    ULLI mod;

    std::vector<T> fac;
    std::vector<T> finv;
    std::vector<T> inv;

    void COMinit() {
        fac.resize(MAX);
        finv.resize(MAX);
        inv.resize(MAX);

        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++){
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod%i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
public:
    ModCal(ULLI _mod){
        this->mod = _mod;
        ModCal<T>::COMinit();
    }
    ModCal(){
        this->mod = 0;
    }

    T add(T a, T b){
        T tmp;
        tmp = a + b;
        if(mod != 0) tmp %= mod;
        return tmp;
    }

    T sub(T a, T b){
        T tmp;
        tmp = a - b;
        if(mod != 0){
            if(tmp < 0) tmp += mod;
            tmp %= mod;
        }
        return tmp;
    }

    T mul(T a, T b){
        T tmp;
        tmp = a * b;
        if(mod != 0) tmp %= mod;
        return tmp;
    }

    T modinv(T a, T m){
        T b = m, u = 1, v = 0;
        while (b) {
            T t = a / b;
            a -= t * b; std::swap(a, b);
            u -= t * v; std::swap(u, v);
        }
        u %= m;
        if (u < 0) u += m;
        return u;
    }

    T div(T a, T b){
        if(mod == 0){
            return a / b;
        }
        a %= mod;
        T tmp = a * ModCal<T>::modinv(b, mod) % mod;
        return tmp;
    }

    T pow(T a, T b){
        T tmp = 1;
        while(b > 0){
            if(mod != 0){
                if(b & 1) tmp = tmp * a % mod;
                a = a * a % mod;
            }else{
                if(b & 1) tmp *= a;
                a *= a;
            }
            b >>= 1;
        }
        return tmp;
    }

    // 以下の関数はMODを設定しない限り使えない
    // 無理やり使う場合は "ModCal<T> cal(Tの最大値)" でオブジェクトを作る
    T com(T n, T k){
        if(n < k) return 0;
        if(n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
    }

    T fact(T n){
        return fac[n];
    }
};

struct S{
    int A;
    int B;
    double v;

    S(int A, int B){
        this->A = A;
        this->B = B;
    }

    bool operator<(const S &l) const{
        return static_cast<double>(B)/A < static_cast<double>(l.B)/l.A;
    };
};

struct P{
    int x;
    int y;

    P(int x, int y){
        this->x = x;
        this->y = y;
    }
};

int main() {
    int a,b;

    cin >> a >> b;

    if(a>=b){
        for(int i=0;i<a;i++) cout << b;
    }else {
        for(int i=0;i<b;i++) cout << a;
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define INFTY (1<<30)

int m[101][101];
int p[101];
int n;

void multiplyMatrix(){
	int i, l, j, k;
	for(i = 1;i <= n;i++)
		m[i][i] = 0;
	
	for(l = 2;l <= n;l++){
		for(i = 1;i <= n - l + 1;i++){
			j = i + l - 1;
			m[i][j] = INFTY;
			for(k = i;k < j;k++)
				m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
		}
	}
}

int main(void){
	int i;
	scanf("%d", &n);
	for(i = 0;i < n;i++)
		scanf("%d %d", &p[i], &p[i + 1]);
	multiplyMatrix();
	printf("%d\n", m[1][n]);
	return 0;
}

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

int main( void ) {
    
    long long a, b, x;
    cin >> a >> b >> x;
    
    if( a > 0 )
        cout << b / x - (a - 1) / x << endl;
    else
        cout << b / x + 1 << endl;
    
    return 0;
}

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

struct Problem {

    void Solve() {
        while (true) {
            string S; cin >> S; if (S == "-") return;
            UL N = S.size();
            UL p = 0;
            UL Q; cin >> Q;
            rep(q, Q) { UL a; cin >> a; p = (p + a) % N; }
            rep(i, N) {
                cout << S[(p + i) % N];
            } cout << endl;
        }
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    cout << fixed << setprecision(10);
    p->Solve();
    return 0;
}



Measured memory_bytes: 3128
#include <stdio.h>
#include <string.h>
                                                                                                
  
int main(void){
                                                                                                
   

    char s[101];

    char t[101];

    int i,j;

    char tm;
   
      
    scanf("%s", s );
   
    scanf("%s", t );
   


    for( i = 0 ; i <= strlen(s) - 1 ; i = i + 1 ){

        for( j = i + 1 ; j <= strlen(s) - 1 ; j = j + 1 ){        

             if( s[j] < s[i] ){

                 tm = s[j];

                 s[j] = s[i];

                 s[i] = tm;

                 }

              }

         }


    for( i = 0 ; i <= strlen(t) - 1 ; i = i + 1 ){

         for( j = i + 1 ; j <= strlen(t) - 1 ; j = j + 1 ){        

             if( t[j] > t[i] ){

                 tm = t[i];

                 t[i] = t[j];

                 t[j] = tm;

                 }

              }

         }
    
    
    if( strcmp( s, t ) >= 0 ) printf("No\n");

    else printf("Yes\n");


    return 0;
                                                          
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N; cin >> N;
    vector<string> S(N);
    REP(i, N) cin >> S[i];

    int ans = 0;
    REP(A, N){
        bool b = true;
        REP(i, N){
            REP(j, N){
                if(S[(i + A) % N][j] != S[(j + A) % N][i]) b = false;
            }
        }
        if(b) ans += N;
    }

    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	ll x,y;
	cin>>x>>y;
	ll cnt=1;
	while(x<y){
		x*=2;
		cnt++;
	}
    if(x>y)cnt--;
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

const int MAXH = 410;
const int MAXW = 410;

int h, w;
string s[MAXH];
bool visited[MAXH][MAXW];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

bool check(int x, int y) {
  return 0 <= x && x < w && 0 <= y && y < h;
}

void dfs(int x, int y, ll& white, ll& black) {
  if (s[y][x] == '.') {
    white++;
  } else {
    black++;
  }
  visited[y][x] = true;
  for (int i=0;i<4;i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if (check(nx, ny) && !visited[ny][nx] && s[ny][nx] != s[y][x]) {
      dfs(nx, ny, white, black);
    }
  }
}

void solve() {
  ll cnt = 0;
  for (int i=0;i<h;i++) {
    for (int j=0;j<w;j++) {
      if (!visited[i][j]) {
        ll white = 0, black = 0;
        dfs(j, i, white, black);
        cnt += white * black;
      }
    }
  }
  cout << cnt << endl;
}

int main() {
  cin >> h >> w;
  for (int i=0;i<h;i++) {
    cin >> s[i];
  }
  solve();
}


Measured memory_bytes: 18176
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 998244353;
int t,n,m,k,x,y;
 
 
int main()
{
	IOS;
	cin>>n>>m;
	v32 a(n);
	int sum=0;
	forn(i,n) cin>>a[i],sum+=a[i];
	sort(a.begin(),a.end(),greater<int>());
	if(a[m-1]*4*m >=sum)
		cout<<"Yes"<<ln;
	else cout<<"No"<<ln;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define M1 1000000007
#define M2 998244353
#define ll long long int
#define N (int)1e5+3
#define test(t) while(t--)
#define PI acos(-1.0)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mii map<int,int>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repp(i,b,a) for(ll i=b-1;i>=a;i--)
#define clr(ar, val) memset(ar, val, sizeof(ar))
#define F first
#define S second
#define PB push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define V(a) vector<a>
#define M(a,b) map<a,b>
#define endl '\n'
#define all(x) begin(x),end(x)
#define allr(x) rbegin(x),rend(x)
#define pr(a) cout<<a<<endl;
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int dx[4] = { 0, -1, 0, 1 };
const int dy[4] = { -1, 0, 1, 0 };
using namespace std;

ll CalculateMex(set<ll> Set){
    ll Mex = 0;
    while(Set.find(Mex)!=Set.end()){
        Mex++;
    }
    return Mex;
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}

void solve()
{
    ll n;
    cin>>n;
    ll a[n];
    rep(i,0,n) cin >> a[i];
    rep(i,0,n){
        if (a[i]%2 == 0 && (a[i]%3 == 0 || a[i]%5 == 0)){
            continue;
        }
        else if (a[i]%2  == 0){
            cout << "DENIED" << endl;
            return;
        }
    }
    cout << "APPROVED" << endl;
    return;

}

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    test(t){
        solve();
    }
    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 vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)
const double eps = 1e-10;
const double pi = acos(-1.0);
const double inf = (int)1e8;

int main(){
  double n;
  while(cin>>n&&n!=0){
    int cnt=0;
    loop(i,2,n+1){
      if(i%2==0&&n/i-floor(n/i)==0.5&&i/2<n/i)cnt++;
      else if(i%2==1&&n/i-floor(n/i)==0&&i/2<n/i)cnt++;
      else if(i/2>n/i) break;
    }
    cout << cnt << endl;
  }
}

Measured memory_bytes: 1220
// Problem : E - Simple String Queries
// Contest : AtCoder - AtCoder Beginner Contest 157
// URL : https://atcoder.jp/contests/abc157/tasks/abc157_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 500005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
int st[5*maxn][26];
int n,q;
string str;
void build(int p,int l,int r)
{
	if(l ==r)
	{
		st[p][str[l]-'a']++;
		return;
	}
	int mid=(l+r)/2;
	build(2*p,l,mid);
	build(2*p+1,mid+1,r);
	rep(i,0,26)
		st[p][i]=st[2*p][i]+st[2*p+1][i];
}
void update(int p,int l,int r,int i,int val)
{
	if(l > i || r < i)
	return;
	if(l == r)
	{
		rep(j,0,26)
		st[p][j]=0;
		st[p][val]=1;
		return;
	}
	int mid=(l+r)/2;
	update(2*p,l,mid,i,val);
	update(2*p+1,mid+1,r,i,val);
	rep(k,0,26)
		st[p][k]=st[2*p][k]+st[2*p+1][k];
}
int ans[26];
void query(int p,int l,int r,int i,int j)
{
	if(i<=l and j>=r)
	{
		rep(k,0,26)
		ans[k]+=st[p][k];
		return;
	}
	int mid=(l+r)/2;
	if(i <= mid)
	query(2*p,l,mid,i,j);
	if(j > mid)
	query(2*p+1,mid+1,r,i,j);
}
void solve()
{
	cin >> n;
	cin >> str;
	cin >> q;
	build(1,0,n-1);
	//query(1,0,n-1,0,0);
	while(q--)
	{
		int t;
		cin >> t;
		if(t==1)
		{
			int i;
			char x;
			cin >> i >> x;
			update(1,0,n-1,i-1,x-'a');
		}
		else{
			int i,j;
			cin >> i >> j;
			i--,j--;
			//cout << i <<" "<<j<<"\n";
			query(1,0,n-1,i,j);
			int cnt=0;
			rep(k,0,26){
				if(ans[k]>0)
				{
					//cout << (char)(k+'a') <<" ";
					cnt++;
					}
				ans[k]=0;
			}
			cout << cnt <<"\n";
		}
	}
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 216940
#include<cstdio>
int main(){
	int x,a,b;
	scanf("%d %d %d",&x,&a,&b);
	if(b<=a){
		printf("delicious\n");
		
	}else if(b<=a+x){
		printf("safe\n");
	}else{
		printf("dangerous\n");
	}
	return 0;
}

Measured memory_bytes: 128
def cmb(n, r, mod):
  if ( r < 0 or r > n ):
    return 0
  r = min(r, n - r)
  return g1[n] * g2[r] * g2[n - r] % mod
 
MOD = 10 ** 9 + 7 #出力の制限
N = 10 ** 5 * 2 + 1
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
 
for i in range(2, N + 1 ):
  g1.append((g1[-1] * i) % MOD)
  inverse.append((-inverse[MOD % i] * (MOD // i) ) % MOD)
  g2.append((g2[-1] * inverse[-1]) % MOD)

H, W, A, B = map(int, input().split())

answer = 0
for w in range(B, W):
  answer = (answer + cmb((H - A - 1) + w, w, MOD) * cmb((A - 1) + (W - 1 - w), W - 1 - w, MOD)) % MOD

print(answer)

Measured memory_bytes: 27116
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
#define MN 100005
char s[MN],t[MN];
int q,a,b,c,d,nums[MN],numt[MN],lens,lent;
bool get(int a,int b){
	if(a<b) swap(a,b);
	return (a-b)%3==0;
}
int getn(bool k){
	if(k) return 1;
	else return 2;
}
int main(){
	scanf("%s",s);scanf("%s",t);
	register int i;
	lens=strlen(s);lent=strlen(t);
	for(i=1;i<=lens;i++) nums[i]=nums[i-1]+getn(s[i-1]=='A');
	for(i=1;i<=lent;i++) numt[i]=numt[i-1]+getn(t[i-1]=='A');
	q=read();
	while(q--){
		a=read(),b=read(),c=read(),d=read();
		printf(get(nums[b]-nums[a-1],numt[d]-numt[c-1])?"YES\n":"NO\n");
	}
	return 0;
}

Measured memory_bytes: 1536
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;

typedef long long LL;

int main()
{
	LL N, A, B;
	scanf("%lld %lld %lld", &N, &A, &B);
	if(A > B) printf("0\n");
	else{
		if(N == 1){
			if(A == B) printf("1\n");
			else printf("0\n");
		}
		else{
			LL sum = B * (N - 1) + A - (A * (N - 1) + B) + 1;
			printf("%lld\n", sum);
		}
	}
}

Measured memory_bytes: 128
#include <stdio.h>

int horie_yui(int isikawa_kaito) {
	if (isikawa_kaito % 3 == 0) return 1;
	do {
		if (isikawa_kaito % 10 == 3) return 1;
	} while ((isikawa_kaito /= 10));
	return 0;
}

int main(void) {
	int n, i = 1;
	if (scanf("%d", &n) != 1) return 1;
	do {
		if (horie_yui(i)) printf(" %d", i);
	} while (++i <= n);
	putchar('\n');
	return 0;
}


Measured memory_bytes: 2096
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);
	public void run() {
		while(sc.hasNext()){
			String n = sc.nextLine();
			if(n.equals("#"))break;
			else calc(n);
			
		}
	}
	public void calc(String line){
		int[] retsu = {0, 1, 2, 3, 1, 0, 3, 1, 2, 3};
		int[] dp = new int[2];
		int panel = Integer.valueOf(line.substring(0,1)); 
		for(int i = 1; i < line.length(); i++){
			int nowPanel = Integer.valueOf(line.substring(i, i+1));
			int[] d = new int[2];
			//left
			int t = Integer.MAX_VALUE;
			if(retsu[nowPanel] <= retsu[panel]) t = dp[1];
			d[0] = Math.min(dp[0] + 1, t);
			//right
			int t2 = Integer.MAX_VALUE;
			if(retsu[panel] <= retsu[nowPanel]) t2 = dp[0];
			d[1] = Math.min(t2, dp[1]+1);
			
			panel = nowPanel;
			dp = d;
		}
		System.out.println(Math.min(dp[0], dp[1]));
	}

	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 56384
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = 1000000007;

const ll com_max = 1000000;

ll fac[com_max], inv[com_max], finv[com_max];

void com_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;

    for (ll i = 2; i < com_max; i++) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

ll com(ll n, ll k) {
    if (n < k) {
        return 0;
    }
    if (n < 0 || k < 0) {
        return 0;
    }

    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main() {
input:
    ll x, y;
    cin >> x >> y;

calculate:
    if ((x + y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    ll n = (2 * x - y) / 3;
    ll m = (-x + 2 * y) / 3;

    if (n < 0 | m < 0) {
        cout << 0 << endl;
        return 0;
    }

    com_init();

    ll ans = com(n + m, n);
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 23808
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

ll gcd(ll x, ll y) {
    if (x > y) swap(x, y);
    ll m = 1;
    while (m != 0) {
        m = y % x;
        y = x;
        x = m;
    }
    return y;
}

int main() {

    int n;
    cin >> n;
    vector<ll> monsters(n);
    rep(i, n) cin >> monsters[i];
    ll g = monsters.front();
    for (ll l : monsters) g = gcd(g, l);

    cout << g << endl;

}


Measured memory_bytes: 4044
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
 
int main(){
  int a,b;
  cin >> a >> b;
  if(b%a==0)cout <<a+b << endl;
  else cout << b-a << endl;
return 0;}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n;
    int exist7 = 0;

    scanf("%d", &n);

    while(n != 0) {
        if (n % 10 == 7) {
            exist7 = 1;
            break;
        }
        n = n/10;
    }

    if (exist7) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 1580
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::num;

fn main() {
    input! {
        n: i32,
        ver: [(i32, i32, i32); n],
    }
    let v = ver;
    if n == 1 {
        let x = v[0].1;
        let y = v[0].2;
        let t = v[0].0;
        if x + y > t || (x + y) % 2 != t % 2 {
            println!("No");
            return;
        } else {
            println!("Yes");
            return;
        }
    }
    for i in 1..n as usize {
        let dist = (v[i - 1].1 - v[i].1).abs() + (v[i - 1].2 - v[i].2).abs();
        let time = v[i].0 - v[i - 1].0;
        if dist > time {
            println!("No");
            return;
        } else {
            if dist % 2 != time % 2 {
                println!("No");
                return;
            }
        }
    }
    println!("Yes");
}


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

# define ll long long
ll mod=pow(10,9)+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int ar[n];
    map<int,int> mp;
    for(int i=0;i<n;i++){
        cin>>ar[i];
        mp[ar[i]]++;
    }
    int cnt=n;
    sort(ar,ar+n);
    for(int i=0;i<n;i++){
        int temp=ar[i];
        mp[temp]--;
        for(int j=1;j*j<=temp;j++){
            if(temp%j==0){
                if(mp[temp/j]||mp[j]){
                    cnt--;
                    break;
                }
            }
        }
        mp[temp]++;
    }

    cout<<cnt<<endl;
}


Measured memory_bytes: 33160
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;


template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

 struct UF {
	vector<int>par;//親
	vector<int>Rank;//木の深さ
    vector<int>sz;//要素数

    UF(int n){init(n);}

	//初期化
	void init(int n) {
		par.resize(n); Rank.resize(n);sz.resize(n);
		for (int i = 0; i < n; i++) {
			par[i]= i;
			Rank[i] = 0;
            sz[i]=1;
		}
	}

	//木の根を求める
	int find(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			return par[x] = find(par[x]);
		}
	}

	//xとyの属する集合を併合
	bool unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return false;//すでに同じ集合に属している

		if (Rank[x] < Rank[y]) {//高さが小さい方を下に
			par[x] = y;
            sz[y]+=sz[x];
		}
		else {
			par[y] = x;
			if (Rank[x] == Rank[y])Rank[x]++;//同じだとrankが変わらないままになるので増やす（それ以外は大きい方のrankが採用される）
            sz[x]+=sz[y];
		}
		return true;
	}

	//xとyが同じ集合に属するかを判定
	bool same(int x, int y) {
		return find(x) == find(y);
	}

    int size(int k){//要素数を求める
        return sz[find(k)];
    }
};

void solve(){
	ll n;
	cin>>n;
	vector<ll>a(n);
	rep(i,n)cin>>a[i];
	vector<int>v(1e6+5);
	bool ng=false;
	rep(i,n){
		v[a[i]]++;
		if(a[i]!=1&&v[a[i]]>=2)ng=true;
	}
	ll x=0;
	rep(i,n)x=gcd(x,a[i]);
	if(x==1){
		for(int i=2;i<=1e6;++i){
			int c=0;
			for(int j=i;j<=1e6;j+=i){
				if(v[j]>=1)++c;
			}
			if(c>1){
				ng=true;
				break;
			}
		}
		if(ng)cout<<"setwise coprime";
		else cout<<"pairwise coprime";
	}
	else{
		cout<<"not coprime";
	}
}

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


Measured memory_bytes: 15072
import java.util.Scanner;
public class Main {

	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		String str = scan.next();
		int ans = 0;
		for(char a :str.toCharArray()){
			if(a == '1'){
				ans ++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
int main()
{
	long long int a, b;
	scanf("%lld %lld", &a, &b);
	long long int g, r = a % b;
	while (r > 0)
	{
		a = b;
		b = r;
		r = a % b;
	}
	g = b;
	long long int ans = 1, i;
	for (i = 2; i * i <= g; i++)
	{
		if (g % i == 0)
		{
			ans++;
			while (g % i == 0)
				g /= i;
		}
	}
	if (g > 1)ans++;
	printf("%lld\n", ans);
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int h[n];
    rep(i, n) cin >> h[i];

    vector<int> dp(n + 1, 1e9);
    dp[0] = 0;
    rep(i, n) {
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }

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


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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int>vec;
  for(int i = 0 ; i < N ; i++){
    int a;
    cin >> a;
    vec.push_back(a);
  }
  sort(vec.begin(),vec.end());
  int s,e;
  s = 0;
  e = 1;
  int res = 1e9 + 1;
  while(s < N && e <= N){
    if(e - s == K){
      res = min(res, vec[e-1] - vec[s]);
    }
    if(e - s < K){
      e++;
    }
    else {
      s++;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 892
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from collections import defaultdict
from collections import deque
import bisect
from decimal import *
from functools import reduce
def main():
    N = I()
    Dots = defaultdict()
    xpyp = []
    xpyn = []
    xnyp = []
    xnyn = []
    for i in range(N):
        x, y = MI()
        Dots[i] = (x, y)
        xpyp.append(x + y)
        xpyn.append(x - y)
        xnyp.append(- x + y)
        xnyn.append(- x - y)
    xpyp_max = max(xpyp) - min(xpyp)
    xpyn_max = max(xpyn) - min(xpyn)
    xnyp_max = max(xnyp) - min(xnyp)
    xnyn_max = max(xnyn) - min(xnyn)
    print(max(xpyp_max, xpyn_max, xnyp_max, xnyn_max))

if __name__ == "__main__":
    main()



Measured memory_bytes: 141660
N, M = map(int, input().split())
XYZs = [list(map(int, input().split())) for _ in range(N)]

ans = 0
for op in range(1 << 3):
    lst = []
    for xyz in XYZs:
        v = 0
        for j in range(3):
            v += xyz[j] * ((-1) ** ((op >> j) & 1))
        lst.append(v)
    ans = max(ans, sum(sorted(lst, reverse=True)[:M]))

print(ans)

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

int main()
{
  int n,a,b;
  cin >>n>>a>>b;
  int ans;
  if(n*a<=b)
    ans = n*a;
  else
    ans = b;
  cout << ans;
  
  return 0;
}

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

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define int long long
#define pb push_back
#define pii pair<int,int>
#define fr(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int MOD = 1e9+7;
int32_t main()
{   fastio;
    int n , m;
    cin>>n>>m;
    string arr[n];
    for(int i=0; i<n; i++)cin>>arr[i];

    int dp[n][m];

    memset(dp , 0 , sizeof(dp));
    dp[0][0] = 1;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
        {
            if(arr[i][j] == '#')continue;
            if(i>0 && arr[i-1][j] == '.') {
                dp[i][j] += dp[i-1][j];
            }
            if(j>0 && arr[i][j-1] == '.' ) {
                dp[i][j] += dp[i][j-1];
            }
            dp[i][j] %= MOD;
        }
    }
    cout<<dp[n-1][m-1]<<"\n";
}

Measured memory_bytes: 12472
#include <bits/stdc++.h>
using namespace std;
int a[9];
int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int temp;
    for(int i=0;i<n;++i)
    {
        cin>>temp;
        if(temp>=3200)
        {
            a[8]++;
        }
        else
        {
            a[temp/400]++;
        }
    }
    int cnt=0;
    for(int i=0;i<8;i++)
    {
        if(a[i]>0)
        {
            ++cnt;
        }
    }
    if(cnt==0)
    {
        cout <<1<<" "<<a[8]<<endl;
        return 0;
    }
    int maximum=(cnt+a[8]);
    int minimum=cnt;
    cout <<minimum<<" "<<maximum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}

using Graph=vector<vector<int>>;
Graph G;

int main(){
  int n; string s;
  cin >> n >> s;
  
  int cnt=0;
  rep(i,1000){
    int c[3] = {i/100,(i/10)%10,i%10};
    int f = 0;
    rep(j,n){
      if(s[j]==('0'+c[f])) f++;
      if(f==3)break;
    }
    if(f==3) cnt++;
  }
  
  cout << cnt << endl;
  
}
    


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0 
for i in range(A + 1):
  for j in range(B + 1):
    for k in range(C + 1):
      if 500 * i + 100 * j + 50 * k == X:
        count += 1

print(count)

Measured memory_bytes: 3060
/*
tarun360
IIT Indore
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define forn_s(i,start,lim) for(ll_s i=start;i<lim;i++)
#define forn_d_s(i,start,lim) for(ll_s i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define debug1(a) cout<<a<<endl
#define debug2(a,b) cout<<a<<" "<<b<<endl
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define debug4(a) cout<<"chu "<<a<<endl

ll a[3005];
ll memo[3005][3005];

ll f(ll s,ll e){
  if(s==e)
    return a[s];
  if(s==e-1)
    return max(a[s],a[e]);
  if(memo[s][e]!=-1)
    return memo[s][e];
  ll q1,q2,q3,Q1,Q2;
  q1=f(s+2,e);
  q2=f(s+1,e-1);
  q3=f(s,e-2);
  Q1=a[s] + min(q1,q2);
  Q2=a[e] + min(q2,q3);
  return memo[s][e]=max(Q1,Q2);
}

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  forn(i,0,3005){
    forn(j,0,3005)
      memo[i][j]=-1;
  }
  ll n,sum=0;
  cin>>n;
  forn(i,0,n) cin>>a[i],sum+=a[i];
  ll s=0,e=n-1;
  ll x=f(s,e);
  ll ans=2*x-sum;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 70912
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<string> iS;
  in<int> Q;
  deque<char> S(iS.begin(), iS.end());
  bool rev = false;
  
  REP(i, Q) {
    int T;
    cin >> T;
    if (T == 1)
      rev = !rev;
    else {
      int F;
      char C;
      cin >> F >> C;
      
      if ((F == 1) ^ (rev))
        S.push_front(C);
      else
        S.push_back(C);
    }
  }

  if (rev)
    bst::reverse(S);
  
  for (auto i : S)
    cout << i;
  cout << endl;
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define LL long long
#define P pair<int,int>
#define LP pair<LL,LL>

int N;
vector<LL> V;
LL ans;

int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        LL A, B;
        cin >> A >> B;
        ans -= B;
        V.push_back(A + B);
    }
    sort(V.rbegin(), V.rend());
    for(int i = 0; i < N; i++){
        if(i % 2 == 0) ans += V[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		out.println(ir.next() + ir.next() + ir.next());
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return Character.toString(sb.toString().charAt(0)).toUpperCase();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


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

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

typedef long long LL;
const LL A_MAX = 1e9;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    LL N, counter = 0;
    cin >> N;
    set<LL> A;
    LL input;

    for (int i=0;i<N;i++)
    {
        set<LL>::iterator it;
        cin >> input;
        it = A.find(input);
        if (it!=A.end())
        {
            A.erase(it);
            counter --;
        } else{
            A.insert(input);
            counter++;
        }
    }
    cout << counter;
    return 0;
}


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

using namespace std;
using ll = long long int;

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

    constexpr long MOD = 1e9+7;
    auto pow = [&](ll a, ll b) {
        ll r = 1;
        while(b) {
            if(b&1) (r *= a) %= MOD;
            (a *= a) %= MOD;
            b >>= 1;
        }
        return r % MOD;
    };
    auto fac = [&](ll n) -> map<ll,ll> {
        map<ll,ll> res;
        for(ll a=2; a*a<=n; a++) {
            while(n % a == 0) n /= a, res[a]=1;
        }
        if(n!=1) res[n]=1;
        return res;
    };

    ll n, k;
    cin >> n >> k;
    ll res = 0;
    for(ll g=1; g<=k; g++) {
        ll cnt = pow(k/g, n);
        (res += g * cnt) %= MOD;
        map<ll,ll> f = fac(g);
        map<ll,ll> s;
        s[1]=0;
        for(auto &t: f) {
            map<ll,ll> ps = s;
            for(auto &e: ps) {
                for(ll i=0; i<t.second; i++)
                    s[e.first * pow(t.first, t.second)] = e.second + t.second;
            }
        }
        for(auto &t: s) {
            ll e, c;
            tie(e, c) = t;
            if(e != 1)
                (res += MOD + (c&1?-1:1) * g/e * cnt) %= MOD;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3664
N,M = map(int,input().split())
X = [0] * N
Y = [0] * N
Z = [0] * N
cake_point1 = [0] * N
cake_point2 = [0] * N
cake_point3 = [0] * N
cake_point4 = [0] * N
cake_point5 = [0] * N
cake_point6 = [0] * N
cake_point7 = [0] * N
cake_point8 = [0] * N


for i in range(N):
    X[i], Y[i], Z[i] = map(int,input().split())
    cake_point1[i] = X[i]+Y[i]+Z[i]
    cake_point2[i] = -X[i]-Y[i]-Z[i]
    cake_point3[i] = X[i]-Y[i]-Z[i]
    cake_point4[i] = -X[i]+Y[i]-Z[i]
    cake_point5[i] = -X[i]-Y[i]+Z[i]
    cake_point6[i] = -X[i]+Y[i]+Z[i]
    cake_point7[i] = X[i]-Y[i]+Z[i]
    cake_point8[i] = X[i]+Y[i]-Z[i]

cake_point1 = list(reversed(sorted(cake_point1)))
cake_point2 = list(reversed(sorted(cake_point2)))
cake_point3 = list(reversed(sorted(cake_point3)))
cake_point4 = list(reversed(sorted(cake_point4)))
cake_point5 = list(reversed(sorted(cake_point5)))
cake_point6 = list(reversed(sorted(cake_point6)))
cake_point7 = list(reversed(sorted(cake_point7)))
cake_point8 = list(reversed(sorted(cake_point8)))

sum_point1 = 0
sum_point2 = 0
sum_point3 = 0
sum_point4 = 0
sum_point5 = 0
sum_point6 = 0
sum_point7 = 0
sum_point8 = 0
sum_point = [0] * 8
for i in range(M):
    sum_point1 += cake_point1[i]
    sum_point2 += cake_point2[i]
    sum_point3 += cake_point3[i]
    sum_point4 += cake_point4[i]
    sum_point5 += cake_point5[i]
    sum_point6 += cake_point6[i]
    sum_point7 += cake_point7[i]
    sum_point8 += cake_point8[i]

sum_point[0] = sum_point1
sum_point[1] = sum_point2
sum_point[2] = sum_point3
sum_point[3] = sum_point4
sum_point[4] = sum_point5
sum_point[5] = sum_point6
sum_point[6] = sum_point7
sum_point[7] = sum_point8

print(max(sum_point))


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

int main(){
  int n,m,x,y;
  cin >> n >> m >> x >> y;
  vector<int> p(n);
  vector<int> q(m);
  for(int i = 0; i < n; i++){
    cin >> p[i];
  }
  for(int i = 0; i < m; i++){
    cin >> q[i];
  }
  int count = *max_element(p.begin(),p.end())+1;
  if(count <= *min_element(q.begin(),q.end()) && x < count && count <= y){
    cout << "No War" << endl;
  }else{
    cout << "War" << endl;
  }
}

Measured memory_bytes: 3580
def main():
    N, K = map(int, input().split())
    a = tuple(map(int, input().split()))
    l = [1 if a[0] >= j else 0 for j in range(K+1)]
    lt= [1 if a[0] >= j else 0 for j in range(K+1)]
    s = a[0]
    for i in a[1:]:
        lt, l = l, lt
        s += i
        l[0] = 1
        t = 1
        for j in range(1, i+1):
                t += lt[j]
                l[j] = t
        for j in range(i+1, min(K+1, s+1)):
                t += (lt[j] - lt[j - i - 1])
                l[j] = t
    return l[-1] % (10 ** 9 + 7)
            
print(main())


Measured memory_bytes: 37616
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

const int mod = 1000000007;

struct mint{
  ll x;
  mint(ll x = 0):x((x % mod + mod) % mod){};
  mint pow(ll y) const {
    mint res(1);
    mint a(x);
    while(y>0){
      if(y&1) res *= a;
      a *= a;
      y >>= 1;
    }
    return res;
  }
  mint inv() const{ return pow(mod-2); }
  mint& operator+= (const mint a) noexcept {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-= (const mint a) noexcept {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*= (const mint a) noexcept {
    (x *= a.x) %= mod;
    return *this;
  }
  mint& operator/= (const mint a) noexcept {
    return (*this) *= a.inv();
  }
  mint operator+ (const mint a) const noexcept {
    mint res(*this);
    return res += a;
  }
  mint operator- (const mint a) const noexcept {
    mint res(*this);
    return res -= a;
  }
  mint operator* (const mint a) const noexcept {
    mint res(*this);
    return res *= a;
  }
  mint operator/ (const mint a) const noexcept{
    mint res(*this);
    return res /= a;
  }
};

ostream& operator<<(ostream& stream, const mint& n){
  stream << n.x;
  return stream;
};

struct comb{
  vector<mint> fact, ifact;
  comb(int n): fact(n+1), ifact(n+1){
    fact[0] = 1;
    for(int i = 1; i <= n; i++) fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i >= 1; i--) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k) const noexcept{
    if(k < 0 || n < k) return 0;
    return fact[n] * ifact[k] * ifact[n-k];
  }
};

int main(void){
  ll n;
  cin >> n;
  vector<string> s(2);
  REP(i, 2) cin >> s[i];
  string t;
  REP(i, n){
    if(s[0][i] == s[1][i]) t += 'X';
    else{
      t += 'Y';
      i++;
    }
  }
  int m = t.size();
  mint ans = (t[0] == 'X') ? 3 : 6;
  FOR(i, 1, m){
    if(t[i-1] == 'X'){
      ans *= 2;
    }else{
      ans *= (t[i] == 'X') ? 1 : 3;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
# ABC169 D Div Game

n = int(input())

def factorization(n):
    arr = []
    if n == 1:
        return 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

f_list = factorization(n)
cnt = 0
for i in range(len(f_list)):
    _tmp = f_list[i][1]
    j = 1
    while _tmp >= 0:
        _tmp -= j
        j += 1
        cnt += 1
    cnt -= 1

print(cnt)

Measured memory_bytes: 9472