akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line


const int MOD = 1e9+7;

int H, W;
vector<string> a;

int dp[1100][1100] = {0};

void add(int &a, int b){
	a+=b;
	if(a>=MOD) a -= MOD;
}
int main()
{
	cin >> H >> W;
	a.resize(H);
	rep(i,H) cin >> a[i];

	dp[0][0] = 1;

	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			if(i+1 < H && a[i+1][j] == '.') add(dp[i+1][j], dp[i][j]);
			if(j+1 < W && a[i][j+1] == '.') add(dp[i][j+1], dp[i][j]);
		}
	}
	cout << dp[H-1][W-1] << endl;
}


Measured memory_bytes: 5632
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int C[4100][4100],A,B;
int f[4100][4100],g[4100][4100];
const int N=4000,mo=1e9+7;
int getw(int j,int k){
	int ans=0;
	for (int i=0;i<=k;i++)
		ans=(ans+1ll*C[j-k][i]*g[k][k-i])%mo;
	return ans;
}
int main(){
	for (int i=0;i<=N;i++){
		C[i][0]=1;
		for (int j=1;j<=i;j++)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%mo;
	}
	/*for (int j=0;j<=N;j++)
		for (int k=0;k<=j;k++)
			for (int i=0;i<=k;i++)
				f[j][k]=(f[j][k]+C[j-k][i])%mo;*/
	for (int del=0;del<=N;del++)
		for (int j=del;j<=N;j++){
			int k=j-del;
			if (k) f[j][k]=f[j-1][k-1];
			f[j][k]=(f[j][k]+C[j-k][k])%mo;
		}
	for (int j=0;j<=N;j++){
		g[j][j]=1;
		for (int k=0;k<j;k++){
			if (k) g[j][k]=g[j-1][k-1];
			g[j][k]=(g[j][k]+f[j-1][k])%mo;
		}
		//	for (int i=0;i<=k;i++)
		//		g[j][k]=(g[j][k]+f[j-i-1][k-i])%mo;
	}
	/*for (int j=0;j<=N;j++)
		for (int k=0;k<=j;k++)
			for (int i=0;i<=k;i++)
				w[j][k]=(w[j][k]+1ll*C[j-k][i]*g[k][k-i])%mo;*/
	int ans=0;
	scanf("%d%d",&A,&B);
	for (int j=0;j<=A;j++)
		ans=(ans+getw(A+B-j-1,A-j))%mo;
	printf("%d\n",ans);
}

Measured memory_bytes: 195456
#pragma GCC optimize("Ofast")
#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;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
void print() { cout << "\n"; }
template <class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////

const int dy[4] = {-1,0,1,0};
const int dx[4] = {0,-1,0,1};
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> x(N*N),y(N*N);
    rep(i,N*N) {
        int a; cin >> a;
        a--;
        y[i] = a/N;
        x[i] = a%N;
    }

    vector<vector<int>> A(N, vector<int>(N));
    auto check = A;
    rep(i,N) {
        rep(j,N) {
            A[i][j] = min({i,N-1-i,j,N-1-j});
            if (A[i][j]) check[i][j] = 1;
        }
    }
    auto func=[&](auto&& self, int y, int x)->void {
        rep(i,4) {
            int ny = y + dy[i];
            int nx = x + dx[i];
            if (ny < 0 or ny >= N or nx < 0 or nx >= N) continue;
            if (chmin(A[ny][nx],A[y][x] + check[y][x])) {
                self(self,ny,nx);
            }
        }
    };
    int ans = 0;
    rep(i,N*N) {
        ans += A[y[i]][x[i]];
        check[y[i]][x[i]] = 0;
        func(func,y[i],x[i]);
    }

    cout << ans << ln;
}


Measured memory_bytes: 26084
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int n,a,b,c,d;
vec x;
int cnt_rock=0,cnt_emp=0,max_rock=0,max_emp=0;
bool f(){
    if(max_rock>1)return false;
    if(c<d){
        return true;
    }else{
      return max_emp>=3;
    }
}
int main(){
    n=in();
    a=in();
    b=in();
    c=in();
    d=in();
    string s=stin();
    x.resize(n+1);
    rep(i,n){
        if(s[i+1]=='#'){
            x[i+1]=1;
        }
        else{
            x[i+1]=0;
        }
    }
    rep2(i,a+1,c-1){
        if(x[i]==1){
            cnt_rock++;
        }
        else{
            cnt_rock=0;
        }
        max_rock=max(max_rock,cnt_rock);
    }
    cnt_rock=0;
    rep2(i,b,d){
        if(x[i]==1){
            cnt_rock++;
        }
        else{
            cnt_rock=0;
        }
        max_rock=max(max_rock,cnt_rock);
    }
    rep2(i,b-2,d){
        if(x[i]==1){
            cnt_emp=0;
        }
        else{
            cnt_emp++;
        }
        max_emp=max(max_emp,cnt_emp);
    }
    string ans=f()?"Yes":"No";
    cout<<ans<<endl;
}

Measured memory_bytes: 1284
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	int n, a, b, a_p, b_p;
	
	while(true){
		cin >> n;
		if(n == 0){
			break;
		}
		a_p = 0;
		b_p = 0;
		for(int i = 0; i < n; i++){
			cin >> a >> b;
			if(a > b){
				a_p += a + b;
			}else if(a == b){
				a_p += a;
				b_p += b;
			}else{
				b_p += a + b;
			}
		}
		printf("%d %d\n", a_p, b_p);
	}
	
	return 0;
}

Measured memory_bytes: 1144
#include <iostream>
#include <string>
using namespace std;
int counter(int n) {
	int sum = 0;
	while (n > 0) {
		sum = sum + n % 10;
		n = n / 10;
	}
	return sum;

}
int main() {
	int N ,a, b,total=0;
	cin >> N >> a >> b;
	for (int i = 1; i <= N;  i++) {
		int sum = counter(i);
		if (a <= sum && sum <= b)
			total = total + i;
	
	
	
	}

	cout << total<< endl;
	
	return 0;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
import sys
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
    
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])

def f(x):
    ans = 0
    if x%4 == 0:
        return 0^x
    elif x%4 == 1:
        return 1
    elif x%4 == 2:
        return 1^x
    elif x%4 == 3:
        return 0

def main():
    a,b = inpm()
    a -= 1
    print(f(a)^f(b))

if __name__ == "__main__":
    main()

Measured memory_bytes: 38384
/*
これを入れて実行
g++ code.cpp
./a.out
*/

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = { -1, 0, +1, 0 };
int dx4[4] = { 0, +1, 0, -1 };
int dy8[8] = { -1, -1, 0, 1, 1, 1, 0, -1 };
int dx8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
	return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

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

ll nCr(ll n, ll r){
	if (r == 0 || r == n){
		return 1;
	}
	else if (r == 1){
		return n;
	}
	return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
	r = n - r;
	ll ret = 1;
	for (ll i = n; i >= r + 1; i--) ret *= i;
	return ret;
}

//-----------------------ここから-----------
ll factorial[1001000];
ll invfactorial[1001000];

ll extGCD(ll a, ll b, ll &x, ll &y){
	if (b == 0){
		x = 1;
		y = 0;
		return a;
	}

	ll d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

ll nCrM(ll n, ll r){
	ll ret = factorial[n];
	ret *= invfactorial[n - r];
	ret %= MOD;
	ret *= invfactorial[r];
	ret %= MOD;
	return ret;
}

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

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


	ll totalmove1 = (x - 2 * y) / (-3);

	ll totalmove2 = -2 * totalmove1 + y;

	if (totalmove1 < 0 || totalmove2 < 0){
		cout << 0 << endl;
		return 0;
	}


	factorial[0] = 1;

	for (int i = 1; i < 1001000; i++){
		factorial[i] = (factorial[i - 1] * i) % MOD;
	}



	for (int i = 0; i < 1001000; i++){
		ll x, y;
		ll g = extGCD(factorial[i], MOD, x, y);
		while (x < 0) x += MOD;
		x %= MOD;
		invfactorial[i] = x;
	}

	cout << nCrM(totalmove1 + totalmove2, totalmove1) % MOD << endl;







	
}



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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
    LL a;
    double b;
    cin>>a>>b;
    LL x=b*100+.5;
    a=(a*x)/100;
    cout<<a;

}


Measured memory_bytes: 3716
from collections import deque
h, w = map(int, input().split())
a = [[] for i in range(h)]
for i in range(h):
    a[i] = list(input())

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

que = deque()

white = h * w

# スタート地点をqueueに追加
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            que.append([i, j])
            white -= 1

count = 0
while 1:
    if white == 0:
        break
    count += 1
    loop = len(que)
    for i in range(loop):
        p = que.popleft()
        for j in range(4):
            ny = p[0] + dy[j]
            nx = p[1] + dx[j]
            if nx < w and nx >= 0 and ny < h and ny >= 0 and a[ny][nx] == ".":
                a[ny][nx] = "#"
                white -= 1
                que.append([ny, nx])


print(count)

Measured memory_bytes: 164956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
inline bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
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; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,r;cin >> n >> r;
	if(n < 10) cout << r + 100 * (10 - n) << endl;
	else cout << r << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
	long long a, b, x;
	cin >> a >> b >> x;

	long long ans, aa, ab;

	aa = a / x;
	ab = b / x;

	ans = ab - aa;
	if (a % x == 0) ans++;

	cout << ans;

	return 0;
}

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

int main() {
	
	string s;
	cin >> s;
	rep(i, s.size()){
		if(i%2==0) cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main(){
  ll N,T,s[200007],sum=0;
  cin >> N >> T;
  rep(i,N){
    cin >> s[i];
    if(i>0 && s[i]-T<s[i-1]){
      sum+=s[i]-s[i-1];
    }
    else if(i>0){
      sum+=T;
    }
    if(i==N-1){
        sum+=T;
    }
  }
  cout << sum << endl;  
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}


//for(int i = ; i < ; i++){}

int main(){
  string s;
  cin>>s;
  cout<<s[0];
  cout<<s.length()-2;
  cout<<s[s.length()-1]<<endl;
  return 0;
}




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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){ T x; cin >> x; return (x); }
template<typename T=int,typename C=vector<T>>
C vecin(int N){ C x(N);REP(i,N){ x[i]=in<T>(); }return move(x); }

void vout(){ cout << endl; }
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){ cout << ' ' << h;vout(forward<Tail>(t)...); }
void out(){ cout << endl; }
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){ cout << h;vout(forward<Tail>(t)...); }

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	ll 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};
	ll K=in();
	
	out(A[K-1]);
	return 0;
}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
C = sorted(Counter(A).most_common(),reverse=True)
D = list(filter(lambda x: x[1]>=2,C))
if len(D)<2:
    print(0)
else:
    print(D[0][0]**2 if D[0][1]>=4 else D[0][0]*D[1][0])

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

using namespace std;

void Solve(){
    long long n;
    cin>>n;
    long long k = n / 500;
    long long x = n - k * 500;
    long long res = k * 1000 + (x / 5) * 5;
    cout<<res<<'\n';

}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int q = 1;
    //cin>>q;
    while(q--){
        Solve();
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

ll s, cnt;
set<ll>st;

int main() {
	cin >> s;
	cnt = 1;
	while (st.find(s) == st.end()) {
		st.insert(s);
		if (s & 1)
			s = s * 3 + 1;
		else
			s /= 2;
		++cnt;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

struct UnionFind {

    vector < int > node;
    UnionFind(int n) : node(n, -1) {}

    bool unite(int x, int y) {
        x = root(x); 
        y = root(y);
        if (x != y) {
            if (node[y] < node[x]) swap(x, y);
            node[x] += node[y]; 
            node[y] = x;
        }
        return x != y;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int root(int x) {
        return node[x] < 0 ? x : node[x] = root(node[x]);
    }

    int size(int x) {
        return -node[root(x)];
    }
    
};

ll N,M;
int A[100010];
int B[100010];

int main ()
{
    cin >> N >> M;
    REP(i,M) cin >> A[i] >> B[i];

    ll sum = N * (N - 1LL) / 2LL;
    vector < ll > ans;
    UnionFind inst(100010);

    for (int i = M - 1; i >= 0; i--) {
        ans.push_back(sum);
        if (!inst.same(A[i], B[i])) {
            sum -= (ll)inst.size(A[i]) * (ll)inst.size(B[i]);
        }
        inst.unite(A[i], B[i]);
    }

    reverse(ans.begin(), ans.end());
    for (auto x : ans) cout << x << endl;

    return 0;
}


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

const int max_n=2e5+10;
int p[max_n];
int cnt[max_n];
int find(int x) {
    if (p[x] != x) p[x] = find(p[x]);
    return p[x];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {p[i] = i,cnt[i]=1;}
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        int pa=find(a),pb=find(b);
        if (pa!=pb) {
           p[pa]=pb;
           cnt[pb]+=cnt[pa];
        }
    }
    int res = 0;
    for (int i = 1; i <= n; ++i) {
            res = max(res, cnt[i]);
    }
    cout << res<< endl;
    return 0;
}

Measured memory_bytes: 5160
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,w) for (int i = 0;i < (w); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;

int main(){
  int x,y,z,k;cin >> x >> y >> z >> k;
  vector<ll> a(x),b(y),c(z);
  rep(i,x) cin >> a[i];
  rep(i,y) cin >> b[i];
  rep(i,z) cin >> c[i];
  vector<ll> bc(1000005);
  rep(i,y)rep(j,z) bc[i*z+j] = b[i]+c[j];
  sort(bc.rbegin(),bc.rend());
  multiset<ll,greater<ll>> ans;
  rep(i,x)rep(j,k) ans.insert(a[i]+bc[j]);
  multiset<ll>::iterator it = ans.begin();
  rep(i,k) {
    cout << *it << endl;
    it++;
  } 
  
  
}

Measured memory_bytes: 151612
import math
def comb(x,y):
    f = 1
    for i in range(y):
        f *= (x-i)
        f //= (i+1)

    return f

n,m = map(int,input().split())

i = 2
cnt = []
while i*i<=m:
    c = 0
    while m%i == 0:
        m //= i
        c += 1
    if c>0:
        cnt.append(c)
    i+=1
if m>1:
    cnt.append(1)
        

res = 1
r = 10**9 +7
for item in cnt:
    res = (res* comb(item+n-1,item))%r

print(res%r)


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


int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    vector<int>cnt(MX);
    int ans = 0;
    rep(i,n) cin>> a[i];
    for (int x:a){
        if (cnt[x]!=0){
            cnt[x]=2;
            continue;
        }
        for (int j=x;j<MX;j+=x)cnt[j]++;
    }
    for(int i:a){
        if(cnt[i]==1) ans++;
    }
    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 8000
#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);

int fastpow(int x, int n, int m){
    int a = 1;
    IREP(i, 35){
        a = (a * a) % m;
        if(((n >> i) & 1) == 1) a = (a * x) % m;
    }
    return a;
}

class Combination
{

public:

    vec fact, invfact;
    int MAX_N, mod;

    Combination(int MAX_N, int mod): MAX_N(MAX_N), mod(mod) {
        fact = vec(MAX_N + 1);
        invfact = vec(MAX_N + 1);
        fact[0] = 1; invfact[0] = 1;
        FOR(i, 1, MAX_N + 1){
            fact[i] = (fact[i - 1] * i) % mod;
            invfact[i] = fastpow(fact[i], mod - 2, mod);
        }
    }

    int comb(int n, int r){
        if(r > n || r < 0 || n < 0) return 0;
        int a = fact[n];
        a = (a * invfact[r]) % mod;
        a = (a * invfact[n - r]) % mod;
        return a;
    }
};

signed main(){

    int K, N; cin >> K >> N;
    int mod = 998244353;

    Combination C(5000, mod);

    vec pow2(2001);
    REP(i, 2001) pow2[i] = fastpow(2, i, mod);

    FOR(i, 2, 2 * K + 1){
        int ans = 0;
        if(i % 2 == 1){
            int dmax = min(i / 2, (2 * K + 2 - i) / 2);
            int K2 = K - dmax * 2;
            FOR(d, 0, dmax + 1){
                int tmp = (C.comb(dmax, d) * C.comb(N + K2 - 1, N - d)) % mod;
                tmp = (tmp * pow2[d]) % mod;
                ans = (ans + tmp) % mod;
            }
        }

        if(i % 2 == 0){
            int dmax = min(i / 2, (2 * K + 2 - i) / 2) - 1;
            int K2 = K - dmax * 2 - 1;
            FOR(d, 0, dmax + 1){
                // (i/2,i/2)なし
                int tmp = (C.comb(dmax, d) * C.comb(N + K2 - 1, N - d)) % mod;
                tmp = (tmp * pow2[d]) % mod;
                ans = (ans + tmp) % mod;
                // (i/2,i/2)あり
                tmp = (C.comb(dmax, d) * C.comb(N + K2 - 2, N - d - 1)) % mod;
                tmp = (tmp * pow2[d]) % mod;
                ans = (ans + tmp) % mod;
            }   
        }

        cout << ans << endl;
        
    }

    
    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 <iostream>
#include <vector>
using namespace std;

int prime[1000];
int vis[100] = { 0 };

bool isPrime(int x) {
	for (int i = 2; i*i <= x; i++) {
		if (x % i == 0)
			return false;
	}
	return true;
}

void getPrime() {
	int cnt = 0;
	for (int i = 2; cnt < 1000; i++) {
		if (isPrime(i)) {
			prime[cnt++] = i;
		}
	}
}

int getsum(vector<int> seq) {
	int sum = 0;
	for (int i = 0; i < seq.size(); i++)
		sum += seq[i];
	return sum;
}

int main()
{
	getPrime();
	int n;
	int sum = 0;
	vector<int> seq;
	cin >> n;
	for (int i = 0; i < n; i++) {
		while (true) {
			if (prime[sum] % 10 == 3) {
				cout << prime[sum] << " ";
				sum++;
				break;
			}
			sum++;
		}
	}
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
const int INF = 1e9 + 100;
const lli INF64 = (1LL << 61) + 100;
const lli MOD = 1000*1000*1000+7;
const int N = 105;
int nums[N];
lli bpow(lli a, lli b) {
	if(b == 0) return 1;
	if(b == 1) return a % MOD;
	lli r = bpow(a, b >> 1);
	r = (r * r) % MOD;
	return (r * (((b&1)?a:1) % MOD)) % MOD;
}
lli multInverse(lli a) {
	return bpow(a, MOD - 2);
}
lli modMult(lli a, lli b) {
	return (a * b) % MOD;
}
lli modSub(lli a, lli b) {
	a += MOD;
	lli r = a - b;
	if(r >= MOD) return r - MOD;
	return r;
}
lli modAdd(lli a, lli b) {
	lli r = a + b;
	if(r >= MOD) return r - MOD;
	return r;
}
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> nums[i];
	
	int ans = INF;
	for(int cur = -105; cur <= 105; cur++) {
		int temp = 0;
		for(int i = 1; i <= n; i++)
			temp += (nums[i] - cur) * (nums[i] - cur);
		ans = min(ans, temp);
	}
	cout << ans << "\n";
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int two = 0;
    int out = 1;
    rep(i, n){
        if (i%2 != 0) continue;
        int c = 0;
        int k = i;
        while (k > 1){
            k /= 2;
            c ++;
        }
        if (c > two){
            two = c;
            out = i;
        }
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
int main(){
  string s;
  int n;
  cin>>n;
  map<string,int>m;
  for(int i=0;i<n;i++){
    cin>>s;
    m[s]++;
  }
  int maxv=0;
  for(auto&x:m) {
    int v=x.second;
    if(v>maxv){
      maxv=v;
    }
  }
  for(auto &t:m){
    if(t.second==maxv)
      cout<<t.first<<"\n";
  }
  return 0;
}

Measured memory_bytes: 25216
def insertionSort(a, n, g)
    cnt=0
    for i in g..n-1 do
        v = a[i]
        j = i - g
        while j >= 0 && a[j] > v do
            a[j+g] = a[j]
            j = j - g
            cnt+=1
        end
        a[j+g] = v
    end
    return cnt
end
 
def shellSort(a,n,m,g)
    cnt = 0
    for i in 0..m-1 do
        cnt+=insertionSort(a, n, g[i])
    end
    return cnt
end
 
n=gets.to_i
a=Array.new
for i in 1..n do
  a.push(gets.to_i)
end
 
m = (Math.log10(2*n+1)/Math.log10(3)).floor
g = Array.new
for i in 1..m do
   g.push((3**i-1)/2)
end
g.reverse!
cnt=shellSort(a,n,m,g)
 
p m
printf("%s\n",g.join(" "))
p cnt
a.each{|v|
  p v
}



Measured memory_bytes: 15520
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  pair<pair<string, int>, int> p[110];
  for (int i = 0; i < n; i++)
  {
    string in;
    int a;
    cin >> in >> a;
    p[i] = make_pair(make_pair(in, -a), i);
  }
  sort(p, p + n);
  for(int i=0; i<n; i++){
    cout << p[i].second + 1 << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
"""
N K
操作: x を x と K の差の絶対値で置き換える
整数 N の初期値が与えられます。この整数に上記の操作を 0 回以上
好きな回数行った時にとりうる N の最小値を求めてください。
"""
import math
n,k=map(int,input().split())
x0=n
xi=n
#print("xi: "+str(xi))
xi1=abs(xi-k)
#print("xi1: "+str(xi1))
leap=math.floor(xi1/k)-3
xi1,xi=abs(xi1-k*leap),xi1
i=0
while ((i==0)|(xi1 < xi)) :
  #print(i)
  """
  if(math.floor(i/100000)==0):
    print(xi1,xi)
  """
  xi1,xi=abs(xi1-k),xi1
  i=i+1
#print("xi1: "+ str(xi1))
print(xi)
"""
"""  

"""
#b=sorted(a, reverse=True)
#print(sum(b))
if b[m-1]>= (sum(b) /(4*m)) :
  print("Yes")
else:
  print("No")

x,y,z=map(int,input().split())
a,b,c=x,y,z
a,b=b,a
a,c=c,a
print(a,b,c)
"""

Measured memory_bytes: 3064
// Last Change: 06/10/2019 18:36:19.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  int N;
  cin >> N;
  vector<int> wLui(N);

  int tmp = 0;
  for (auto &&e : wLui) {
    cin >> e;
    e += tmp;
    tmp = e;
  }

  wLui.pop_back();
  const int sumAll = tmp;
  int ans = 1e5;
  for (auto &&e : wLui) {
    ans = min(ans, abs(sumAll - e - e));
  }

  cout << ans << endl;

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define pint pair<lli,lli>
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
  lli A,B,C,D,E,L,R,X,Y,W,H,N,M,K,sum=0,num=0,flag=0;string S,T;
  cin >> S;
  N=S.size()-1;
  for(int bit=0;bit<(1<<N);bit++){
    T="";
    T+=S[0];
    rep(i,0,N){
      if(bit&(1<<i))T+="+";
      T+=S[i+1];
    }
    K=0;
    num=0;
    while(T.find("+",K)!=string::npos){
      auto nextpos=T.find("+",K);
      num+=stoll(T.substr(K,nextpos));
      K=nextpos+1;
    }
    sum+=num+stoll(T.substr(K));
  }
  Out(sum);
}


Measured memory_bytes: 256
import kotlin.math.*

fun str() = readLine()!!
fun int() = str().toInt()
fun long() = str().toLong()

fun read(d:String = " ") = str().split(d)
fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
fun list() = list {toInt()}

fun <T> MutableList<T>.removeLast() = this.removeAt(this.lastIndex)

const val mod = 1000000007L

fun main() {
	abc000X()
}

fun abc000X() {
	val n = int()
	val a = list().toIntArray()

	var r = 0L
	for(i in 1 until n) {
		r += max(0,a[i-1]-a[i])
		a[i] = max(a[i-1],a[i])
	}
	println(r)
}


Measured memory_bytes: 64944
#include <stdio.h>
#include <string.h>
int main(void) {
	char str[20];
	int i;
	scanf("%s",str);
	for(i = 0; strlen(str) > i; i++){
		printf("%c",str[strlen(str)-1 - i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 932
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    long long int dp[n+1];
    memset(dp,-1,sizeof(dp));
    dp[1]=0;
    for(int i=2;i<=n;i++)
    {
        if(i==2)
        dp[i]=abs(a[2]-a[1]);
        else
        {
            dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
        }
    }
    cout<<dp[n];
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, a, b) for (ll i = a; i < b; ++i)
#define ll long long
#define M 100000007
#define fr first
#define sc second
#define endl "\n"
#define vc vector
#define pb push_back
#define pii pair<ll, ll>
#define psi pair<string, ll>
#define fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define PI 3.14159265
#define r0 return 0
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define what_is(x) cerr << #x << " is " << x << endl;
using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
const char char_max = (char)(((unsigned char) char(-1)) / 2);

int main() {
  fast
  ll n,k,ans=-100000,prev=0,j=-1;
  cin>>n>>k;
  ll a[n],sum[n];
  rep(i,0,n) cin>>a[i];
  sum[0]=a[0];
  rep(i,1,n) sum[i]=a[i]+sum[i-1];
  rep(i,k-1,n){
    ans=max(ans,sum[i]-prev);
    //cout<<ans<<" ";
    j++;
    prev=sum[j];
    //prev+=a[i];
  }
  cout<<setprecision(10)<<(ans+k)*1.0/2.0;
}



Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define de(x) cout << #x << " = " << x << endl
#define rep(i, a, b) for(int i=(a); i<(b); i++)
//-----
const int N=100010;
int n;
int cnt[4];
int main() {
	scanf("%d", &n);
	rep(i, 0, n){
		int t;
		scanf("%d", &t);
		cnt[t%4]++;
	}
	bool ok=0;
	cnt[1]+=cnt[3];
	if(cnt[2]){
		cnt[1]++;
	}
	if(cnt[0]>=cnt[1]-1)ok=1;
	puts(ok?"Yes":"No");
	return 0;
}


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

void print_vec(vector<int> vec)
{
  cout << "[";
  for (int i = 0; i < vec.size(); i++)
  {
    cout << vec.at(i);
    if (i < vec.size() - 1)
    {
      cout << ", ";
    }
  }
  cout << "]...size: " << vec.size() << endl;
}

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

  for (int i = 1; i <= n; i++)
  {
    int x = i;

    if (x % 3 == 0)
    {
      printf(" %d", i);
    }
    else if (x % 10 == 3)
    {
      printf(" %d", i);
    }
    else
    {
      x /= 10;
      while (x)
      {
        if (x % 10 == 3)
        {
          printf(" %d", i);
          break;
        }
        x /= 10;
      }
    }
  }

  printf("\n");
}



Measured memory_bytes: 3208
S=raw_input()
C="ACGT"

len_S=len(S)

ans=float("-inf")
for i in range(len_S+1):
	for j in range(i,len_S+1):
		s=S[i:j]
		for x in s:
			if x not in C:
				break
		else:
			ans=max(ans,len(s))

print ans


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

int main(){
  int n;
  cin >>n;
  vector<double> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());
  double ans = (a[0]+a[1])/2;
  for(int i = 2; i<n; i++){
    ans = (ans+a[i])/2;
  }
  cout << fixed << setprecision(6) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.*;
import java.util.*;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

import static java.util.stream.Collectors.*;
import static java.util.Map.Entry.*;

public class Main {

	public static void main(String[] args) throws IOException {
		 FastReader in = new FastReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		int k = in.nextInt();
		int ct = 0;
		for (int i = 1; i <= n; i+=2) {
			++ct;
		}
		out.println(ct >= k ? "YES" : "NO");
		out.flush();
		out.close();

	}

	static class FastReader {
		StringTokenizer st;
		BufferedReader br;

		public FastReader(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public FastReader(FileReader fileReader) {
			br = new BufferedReader(fileReader);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

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

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

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}

}

Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

struct BinomialCoefficient  {
    BinomialCoefficient() {}
    BinomialCoefficient(int n) : fac(n + 2), finv(n + 2), inv(n + 2) {
        initialize(n, false);
    }
    
    void initialize(int n, bool resize = true) {
        if (resize) {
            fac.resize(n + 2);
            finv.resize(n + 2);
            inv.resize(n + 2);
        }
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i <= n; 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 factorial(int n) {
        return fac[n];
    }
    
    ll combination(int n, int r) {
        if ((n < r) || (n < 0) || (r < 0)) return 0;
        return fac[n] * (finv[r] * finv[n - r] % mod) % mod;
    }
    
    ll permutation(int n, int r) {
        if ((n < r) || (n < 0) || (r < 0)) return 0;
        return fac[n] * finv[n - r] % mod;
    }
    
private:
    int mod = 1e9 + 7;
    vector<ll> fac, finv, inv;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll mod = 1e9 + 7;
    ll x, y;
    cin >> x >> y;
    if ((x + y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    BinomialCoefficient bc(x + y);
    ll total = (x + y) / 3;
    ll ans = 0;
    rep(xcnt, x) {
        ll ycnt = total - xcnt;
        if (ycnt < 0) continue;
        if (((xcnt * 2 + ycnt) != x) || ((xcnt + ycnt * 2) != y)) continue;
        ans = (ans + bc.combination(total, xcnt)) % mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 47104
fun main(arg: Array<String>) {
    val N = nextInt()
    val A = listOfInt()
    val b0 = A.count { it % 2 != 0 }
    val b1 = A.count { it % 2 == 0 && it % 4 != 0 }
    val b2 = A.count { it % 4 == 0}
    val ans = if (b1 == 0) b0 <= b2 + 1 else b0 <= b2
    println(if (ans) "Yes" else "No")
}
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(vararg deltas: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + deltas[index % deltas.size] }



Measured memory_bytes: 51984
def main():
    N, M = map(int, input().split())

    was = [0 for _ in range(N)]
    acs = [False for _ in range(N)]

    for _ in range(M):
        p, s = input().split()
        p = int(p) - 1
        if s == 'AC':
            acs[p] = True
        elif not acs[p]:
            was[p] += 1

    ans, pen = 0, 0
    for s, c in zip(acs, was):
        if s:
            ans += 1
            pen += c

    print(ans, pen)


if __name__ == '__main__':
    main()


Measured memory_bytes: 48036
#include<iostream>
using namespace std;
int main(){
  int h,m,s,h2,m2,s2,ansh,ansm,anss;
  while(cin>>h>>m>>s>>h2>>m2>>s2){
    ansh = h2 - h;
    ansm = m2 - m;
    anss = s2 - s;
    if(anss<0){
      ansm -= 1;
      anss += 60;
    }
    if(ansm<0){
      ansh -= 1;
      ansm += 60;
    }
    cout << ansh << ' ' << ansm << ' ' << anss << endl;
  }
  return 0;
}    

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

template<class T, class Cond>
struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  bool operator()(T& a, const T& b) const {
    if(cond(a, b)) { a = b; return true; }
    return false;
  }
};
template<class T, class Cond>
chain<T, Cond> make_chain(Cond cond) { return chain<T, Cond>(cond); }

int main() {
  i64 N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;

  vector<i64> L(N + 1);
  vector<i64> R(N + 1);
  i64 b = -1e8;
  i64 now = 0;
  rep(i,0,N) {
    if(i - b > C && S[i] == 'o') {
      L[++now] = i + 1;
      b = i;
    }
  }
  now = 0;
  b = 1e9;
  for(i64 i = N; i --> 0;) {
    if(b - i > C && S[i] == 'o') {
      R[++now] = i + 1;
      b = i;
    }
  }
  rep(i,1,K + 1) {
    if(L[i] == R[K - i + 1]) {
      cout << L[i] << endl;
    }
  }
}


Measured memory_bytes: 4996
#include <iostream>
#include <vector>
#include <cstdio>
#include <string.h>
#include <algorithm>

using namespace std;

typedef long long ll;

int lcs(string X, string Y){
  int x = X.size();
  int y = Y.size();

  int d[y+1][x+1];
  memset(d, 0, sizeof(d));

  for(int i = 1; i <= y; i++){
    char a = Y[i-1];

    for(int j = 1; j <= x; j++){
      char b = X[j-1];

      if(a == b){
        d[i][j] = max(d[i][j], d[i-1][j-1] + 1);
      }else{
        d[i][j] = max(d[i-1][j], d[i][j-1]);
      }
    }
  }

  return d[y][x];
}

int main(){
  int n;
  string x, y;
  cin >> n;

  for(int i = 0; i < n; i++){
    cin >> x;
    cin >> y;

    cout << lcs(x, y) << endl;
  }

  return 0;
}

Measured memory_bytes: 5136
# coding: UTF-8
#@document_it
def document_it(func):
    def new_function(*args,**kwargs):
        print('Running function:', func.__name__)
        print('Positional arguments:', args)
        print('Kewword arguments:', kwargs)
        result = func(*args,**kwargs)
        print('Result:', result)
        return result
    return new_function


def exe():
    C11,C12,C13 = map(int,input().split())
    C21,C22,C23 = map(int,input().split())
    C31,C32,C33 = map(int,input().split())
    
    C = C11
    A2 = C21 - C
    A3 = C31 - C
    B2 = C12 - C
    B3 = C13 - C
    C22 -= C
    C23 -= C
    C32 -= C
    C33 -= C
    
    if C22 == A2+B2 and C23 == A2+B3 and C32 == A3+B2 and C33 == A3+B3:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    exe()

Measured memory_bytes: 3188
S = list(input())
N = len(S)
gp = ["g","p"]
out = 0
for i in range(N):
    if i%2==0:
        hand = "g"
    else:
        hand = "p"
    if hand==S[i]:
        out += 0
    elif hand=="p" and S[i]=="g":
        out += 1
    elif hand=="g" and S[i]=="p":
        out += -1
print(out)

Measured memory_bytes: 71080
// A - Haiku

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	string s;
	cin >> s;

	s[5] = ' ';
	s[13] = ' ';

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#C
#入力
N,K,Q=map(int,input().split())
A=[int(input())-1 for i in range(Q)]

#処理
B=[0 for i in range(N)]

for i in A:
    B[i]+=1

for i in B:
    if Q-i<K:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 8640
n,m=map(int,input().split())
ab=[list(map(int,input().split()))for _ in range(m)]
ab.sort()
l,r=ab[0]
ans=1
for i,j in ab[1:]:
  if j<=l or r<=i:
    ans+=1
    l,r=i,j
  l=max(l,i)
  r=min(r,j)
print(ans)

Measured memory_bytes: 28252
#include <bits/stdc++.h>
#define rep(i, z, n) for(ll i = z; i <= n; i++)
#define repl(i, z, n) for(ll i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

int main(){
  vector<int> a=vector<int>(3);
  vector<int> res;
  int n;
  cin >> n;
  vector<string> s=vector<string>(n);
  repl(i,0,3) cin >> a[i];
  repl(i,0,n) cin >> s[i];
  
  if(accumulate(all(a),0)==0){
    cout << "No\n";
    exit(0);
  }
  repl(i,0,n){
    int x = s[i][0]-'A';
    int y = s[i][1]-'A';
    if(i<n-1 && a[x]==1 && a[y]==1){
      bool found_x=(x==(s[i+1][0]-'A') || x==(s[i+1][1]-'A'));
      if(found_x){
        a[x]++;
        a[y]--;
        res.push_back(x); 
      }else{
        a[x]--;
        a[y]++;
        res.push_back(y); 
      }
    }else{
      if(a[x]<=0 && a[y] <=0){
        cout << "No\n";
        exit(0);
      }
      if(a[x]<a[y]){
        a[x]++;
        a[y]--;
        res.push_back(x);
      }else{
        a[y]++;
        a[x]--;
        res.push_back(y);

      }
    } 
  }
  cout << "Yes\n";
  for(int i:res){
    cout << char(i+'A') << endl;
  }
  return 0; 
}



Measured memory_bytes: 7052
import sys
sys.setrecursionlimit(10**7)

n=int(input())
l=[list(input()) for i in range(n)]
connection=[[] for i in range(n)]
for i in range(n):
  for j in range(n):
    if l[i][j]=='1':
      connection[i].append(j)

colors = [0]*n
def dfs(v,color):
    colors[v] = color
    for to in connection[v]:
        if colors[to] == color:
            return False
        if colors[to] == 0 and not dfs(to, -color):
            return False
    return True

def is_bipartite():
    return dfs(0,1)
if is_bipartite()==0:
  print(-1)
  sys.exit()

def bfs(v):
  distance=[-1]*n
  distance[v]=0
  next=connection[v]
  next2=[]
  visited=[-1]*n
  visited[v]=1
  visitct=1
  ct=0
  while len(next)!=0 and visitct!=n:
    ct+=1
    for i in range(len(next)):
      if visited[next[i]]==-1:
        distance[next[i]]=ct
        visited[next[i]]=1
        visitct+=1
        for j in range(len(connection[next[i]])):
          if visited[connection[next[i]][j]]==-1:
            next2.append(connection[next[i]][j])
    next=next2
    next2=[]
    
  return distance

ans=[]
for i in range(n):
  ans.append(max(bfs(i)))
print(max(ans)+1)

Measured memory_bytes: 45680