akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

typedef long long ll;

ll a,b;
ll ans;
int main() {
  cin >> a >> b;
  ll test = 1;
  ll k = 1;

  if((a % 2 == 0) && (b % 2 == 0)) {
    if((b - a) % 4 != 0) ans++;
  }
  else if((a % 2 == 1) && (b % 2 == 1)) {
    if((b - a) % 4 == 0) ans++;
  }
  else {
    if((b - a + 3) % 4 == 0) ans++;
  }
 
  while(test< b) {
    ll aa;
    if((a >> k) & 1) {
      aa = (1ll << k) - (a & test);
    }
    else aa = 0;
    ll bb;
    if((b >> k) & 1) {
     bb = (b & test) + 1;
    }
    else bb = 0;
    //  cout << aa << "   "<<bb <<"   "<<test<<endl;
    if((aa % 2) != (bb % 2)) ans |= (1ll << k);  
    k++;
    test <<= 1;
    test++;  
  }

  cout << ans << endl;
}
  
  
    
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

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

    int n; cin >> n;
    vector<ll> a(n), s(n+1);
    rep(i, n) cin >> a[i];
    sort(all(a));
    rep(i, n) s[i+1] += s[i]+a[i];
    debug(a);
    debug(s);
    int ans = 1;
    for(int i=n-1; i>0; i--) {
        if (s[i]*2>=a[i]) ans++;
        else break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n,i = 1;
		
		while((n = sc.nextInt()) != 0) {
			System.out.printf("Case %d: %d\n",i,n);
			i++;
		}
	}
}



Measured memory_bytes: 67800
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define ABS(a,b) max(a,b) - min(a,b)

ll n, in[2][114514], ans = 1, m[2];
bool okasii = false;
int main() {
	cin >> n;
	REP(i, 2) {
		REP(j, n) {
			cin >> in[i][j];
			m[i] = max(m[i], in[i][j]);
		}
	}
	if (m[0] != m[1]) okasii = true;
	REP(i, n) {
		if (i != 0 && i != n - 1) {
			if (in[0][i - 1] == in[0][i] and in[1][i + 1] == in[1][i]) ans *= min(in[0][i], in[1][i]);
		}
		if (in[0][i - 1] != in[0][i] and in[0][i] > in[1][i]) okasii = true;
		ans %= 1000000007;
	}
	cout << (okasii ? 0 : ans) << endl;
}
	


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

#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;


int main(){
  ll n, k;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i,0,n){
    cin >> h.at(i);
  }
  
  if(n <= k)
    cout << 0 << endl;
  else{
    sort(all(h));
    ll ans = 0;
    rep(i, 0, n-k){
      ans += h.at(i);
    }
    
    cout << ans << endl;
  }
  
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  if(x+r<=W && x-r>=0){if(y+r<=H && y-r>=0 )printf("Yes\n");
    else printf("No\n");}
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 584
S = list(input())
T = list(input())

S = [ord(s)-97 for s in S]
T = [ord(t)-97 for t in T]

N = len(S)

dp = [[-1 for j in range(26)] for i in range(N)]

for i,s in enumerate(S):
    if dp[N-1][s] == -1:
        dp[N-1][s] = i

for i in range(N-2,-1,-1):
    for j in range(26):
        dp[i][j] = dp[i+1][j]
    dp[i][S[i+1]] = i+1

M = len(T)
ans = dp[N-1][T[0]] + 1
now = dp[N-1][T[0]]
if now == -1:
    print(-1)
    exit()
for i in range(1,M):
    t = T[i]
    if dp[now][t] == -1:
        print(-1)
        exit()
    if now < dp[now][t]:
        ans += dp[now][t] - now
    else:
        ans += N + dp[now][t] - now
    now = dp[now][t]

print(ans)




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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    string S; cin>>S;
    set<char> M;
    rep(i,S.size()){
        M.insert(S[i]);
    }
    if(M.size()==S.size())cout<<"yes"<<endl;
    else cout<<"no"<<endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> Q;

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		vector< vector<int> > w(n, vector<int>(2));
		for (int i = 0; i < n; i++) {
			cin >> w[i][0];
		}
		for (int i = 0; i < n; i++) {
			cin >> w[i][1];
		}
		vector< vector<int> > dp1(n, vector<int>(2, 500));
		dp1[0][0] = 0;
		queue<Q> q;
		int k = 0;
		while (k < n-1 && w[k][0] == 1 && w[k+1][0] == 1) {
			k++;
		}
		dp1[k][0] = 0;
		q.push(Q(1, P(k, 1)));
		k++;
		if (k < n) {
			q.push(Q(1, P(k, 1)));
			k++;
			if (k < n) {
				q.push(Q(1, P(k, 1)));
			}
		}
		while (!q.empty()) {
			Q qq = q.front();
			q.pop();
			P p = qq.second;
			if (dp1[p.first][qq.first] <= p.second) {
			} else {
				dp1[p.first][qq.first] = p.second;
				if (w[p.first][qq.first] == 2) {
					dp1[p.first][qq.first] = 500;
				}
				while (w[p.first][qq.first] == 2) {
					p.first--;
				}
				while (p.first < n-1 && w[p.first][qq.first] == 1 && w[p.first+1][qq.first] == 1) {
					p.first++;
				}
				if (dp1[p.first][qq.first] < p.second) {
				} else {
					dp1[p.first][qq.first] = p.second;
					q.push(Q(1-qq.first, P(p.first, p.second+1)));
					p.first++;
					if (p.first < n) {
						q.push(Q(1-qq.first, P(p.first, p.second+1)));
						p.first++;
						if (p.first < n) {
							q.push(Q(1-qq.first, P(p.first, p.second+1)));
						}
					}
				}
			}
		}
		/*for (int i = 0; i < n; i++) {
			cout << dp1[i][0] << ' ';
		}
		cout << endl;
		for (int i = 0; i < n; i++) {
			cout << dp1[i][1] << ' ';
		}
		cout << endl;*/
		vector< vector<int> > dp2(n, vector<int>(2, 500));
		dp2[0][1] = 0;
		k = 0;
		while (k < n-1 && w[k][1] == 1 && w[k+1][1] == 1) {
			k++;
		}
		dp2[k][1] = 0;
		q.push(Q(0, P(k, 1)));
		k++;
		if (k < n) {
			q.push(Q(0, P(k, 1)));
			k++;
			if (k < n) {
				q.push(Q(0, P(k, 1)));
			}
		}
		while (!q.empty()) {
			Q qq = q.front();
			q.pop();
			P p = qq.second;
			if (dp2[p.first][qq.first] <= p.second) {
			} else {
				dp2[p.first][qq.first] = p.second;
				if (w[p.first][qq.first] == 2) {
					dp2[p.first][qq.first] = 500;
				}
				while (w[p.first][qq.first] == 2) {
					p.first--;
				}
				while (p.first < n-1 && w[p.first][qq.first] == 1 && w[p.first+1][qq.first] == 1) {
					p.first++;
				}
				if (dp2[p.first][qq.first] < p.second) {
				} else {
					dp2[p.first][qq.first] = p.second;
					q.push(Q(1-qq.first, P(p.first, p.second+1)));
					p.first++;
					if (p.first < n) {
						q.push(Q(1-qq.first, P(p.first, p.second+1)));
						p.first++;
						if (p.first < n) {
							q.push(Q(1-qq.first, P(p.first, p.second+1)));
						}
					}
				}
			}
		}
		/*for (int i = 0; i < n; i++) {
			cout << dp2[i][0] << ' ';
		}
		cout << endl;
		for (int i = 0; i < n; i++) {
			cout << dp2[i][1] << ' ';
		}
		cout << endl;*/
		int cc = min(dp1[n-1][0], min(dp1[n-1][1], min(dp2[n-1][0], dp2[n-1][1])));
		if (cc == 500) {
			cout << "NA" << endl;
		} else {
			cout << cc << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1240
#include <stdio.h>
int main() {
  int N;
  scanf("%d", &N);
  if(N%2==0){
    printf("%d\n",(N-2)/2);    
  }
  else if(N%2==1){
    printf("%d\n",(N-1)/2);    
  }
  
  return 0;
}


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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int takashi, custo;
    cin >> takashi >> custo;
    if (takashi >= 13)
    {
        cout << custo << endl;
    }
    else if (takashi >= 6 && takashi <= 12)
    {
        cout << custo / 2 << endl;
    }
    else
    {
        cout << '0' << endl;
    }
     
    return 0;
}

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

int main(){
  int n;
  string s;
  cin>>n>>s;
  int ch=0;
  int right=0,left=0;
  for(int i = 0; i < n; i++){
    if(s[i]==')'){
      if(ch>0) ch--;
      else left++;
    }else ch++;
  } 
  ch=0;
  for(int i = n-1; i >= 0; i--){
    if(s[i]=='('){
      if(ch>0) ch--;
      else right++;
    }else ch++;
  }
  string l,r;
  rep(i,left) l+='(';
  rep(i,right) r+=')';
  cout<< l+s+r <<endl;
}



Measured memory_bytes: 3636
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

ans = 0
n = int(input())
for j in range(n):
	i = j + 1
	if i % 2 == 1 and len(make_divisors(i)) == 8:
		ans += 1
print(ans)

Measured memory_bytes: 3188
#include <iostream>

using namespace std;

int main()
{
    int m[100];
    int n=0;
    for(int i=1;i<=9;i++){
        for(int j=i;j<=9;j++){
            m[n]=i*j;
            n++;
        }
    }
    int a;
    cin >>a;
    bool flg=false;
    for(int i=0;i<n;i++){
        if(m[i]==a){
            flg=true;
        }
    }
    if(flg)puts("Yes");
    else puts("No");
    return 0;
}


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

int main(void) {
  int n,m;
  cin >> n >> m;

  vector<pair<int,int>> d;

  for (int i = 0; i < n; i++) {
    int a,b;
    cin >> a >> b;
    d.emplace_back(a,b);
  }

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

  ll res=0;
  for (int i = 0; i < n; i++) {
    if(d[i].second<=m){
      res+=(ll)d[i].first * d[i].second;
      m-=d[i].second;
    } else {
      res+=(ll)d[i].first * m;
      break;
    }
  }

  cout << res << endl;
    
  return 0;
}


Measured memory_bytes: 1400
#include <iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(2*c>(b-a)+1)
	{
		for(int i=a; i<=b; i++)
		{
			cout<<i<<endl;
		}
	}
	else
	{
		for(int i=0; i<c; i++)
		{
			cout<<a+i<<endl;
		}
		for(int i=c-1; i>=0; i--)
		{
			cout<<b-i<<endl;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
using namespace std;

int main() {
	while(true){
		int h, w;
		cin >> h >> w;
		if(h == 0 && w == 0)break;
		REP(i, h){
			REP(j, w){
				if(i == 0 || j == 0 || i == h-1 || j == w-1) cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3084
#include<cstdio>
void cmax(int&a,int b){b>a?a=b:1;}
int main(){
	int N;
	while(scanf("%d",&N)==1){
		int mn=0,val[3]={0};
		for(int i=0;i<=N;i++){
			int x=0;if(i<N)scanf("%d",&x);
			int tmp[4]={-1,-1,x,x},la=val[2];
			if(x>=la){
				for(int j=0;j<3;j++)cmax(tmp[j],val[j]),cmax(tmp[j+1],val[j]+x-la);
			}
			else{
				for(int j=0;j<3;j++){
					if(val[j]+x-la>=0)cmax(tmp[j],val[j]+x-la);
					if(val[j]>=x)cmax(tmp[j+1],x);
					else cmax(tmp[j+1],val[j]);
				}
				for(int j=0;j<3;j++)cmax(tmp[j+1],tmp[j]);
			}
			int a=tmp[0]==-1;
			for(int j=0;j<3;j++)val[j]=tmp[j+a];
			mn+=a;
		//printf("i=%d x=%d val=(%d,%d,%d) mn=%d\n",i,x,val[0],val[1],val[2],mn);
		}
		printf("%d\n",mn);
	}
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
#include<vector>
#include<functional>
#include<limits>
template<typename T>
struct segtree{
	using F=function<T(T,T)>;
	const F calcfn,updatefn;
	int n;
	T defvalue;
	vector<T>dat;
	segtree(int n_=0,T defvalue_=numeric_limits<T>::max(),
		const F calcfn_=[](T a,T b){return a<b?a:b;},
		const F updatefn_=[](T a,T b){return b;}
	):defvalue(defvalue_),calcfn(calcfn_),updatefn(updatefn_)
	{
		n=1;
		while(n<n_)n<<=1;
		dat.assign(2*n-1,defvalue);
	}
	void copy(const vector<T>&v)
	{
		for(int i=0;i<v.size();i++)dat[i+n-1]=v[i];
		for(int i=n-2;i>=0;i--)dat[i]=calcfn(dat[i*2+1],dat[i*2+2]);
	}
	void update(int i,T a)
	{
		i+=n-1;
		dat[i]=updatefn(dat[i],a);
		while(i>0)
		{
			i=(i-1)/2;
			dat[i]=calcfn(dat[2*i+1],dat[2*i+2]);
		}
	}
	T query(int a,int b)//[a,b)
	{
		int L=(a<0?0:a>n?n:a)+n-1;
		int R=(b<0?0:b>n?n:b)+n-1;
		T lret=defvalue,rret=defvalue;
		for(;L<R;L>>=1,R>>=1)
		{
			if(!(L&1))lret=calcfn(lret,dat[L]);
			if(!(R&1))rret=calcfn(dat[--R],rret);
		}
		return calcfn(lret,rret);
	}
};
int N,M;
string s;
int dp[1<<17];
main()
{
	cin>>N>>M;
	cin>>s;
	segtree<pair<int,pair<int,int> > >P(N+1,make_pair(1e9,make_pair(0,0)));
	P.update(N,make_pair(0,make_pair(N,-1)));
	dp[N]=0;
	for(int i=N-1;i>=0;i--)
	{
		if(s[i]=='1')continue;
		pair<int,pair<int,int> >ret=P.query(i+1,i+M+1);
		dp[i]=1e9;
		if(ret.first<1e9)
		{
			P.update(i,make_pair(ret.first+1,make_pair(i,ret.second.first)));
			dp[i]=ret.first+1;
		}
	}
	if(dp[0]>=1e9)
	{
		cout<<-1<<endl;
		return 0;
	}
	int id=0,flag=0;
	while(id<N)
	{
		pair<int,pair<int,int> >ret=P.query(id,id+1);
		cout<<(flag++?" ":"")<<ret.second.second-ret.second.first;
		id=ret.second.second;
	}
	cout<<endl;
}


Measured memory_bytes: 4096
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
using namespace std;
typedef pair<ll, ll> P;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


int main(void){
	string s;
	cin >> s;
	int ans1 = 0, ans2 = 0;
	for (int i = 0;i < s.length();i++) {
		if (i % 2 == 0) {
			if (s[i] == '1')ans1++;
		}
		else {
			if (s[i] == '0')ans1++;
		}
	}
	for (int i = 0;i < s.length();i++) {
		if (i % 2 == 0) {
			if (s[i] == '0')ans2++;
		}
		else {
			if (s[i] == '1')ans2++;
		}
	}
	cout << min(ans1, ans2) << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
string divide[4] = {"dream", "dreamer", "erase", "eraser"};
int main() {

  string S;
  cin >> S;

  reverse(S.begin(), S.end());
  for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

  bool can = true;
  for (int i = 0; i < S.size();) {
    bool can2 = false;
    for (int j = 0; j < 4; ++j) {
      string d = divide[j];
      if (S.substr(i, d.size()) == d) {
        can2 = true;
        i += d.size();
      }
    }
    if (!can2) {
        can = false;
        break;
      }
  }
  if (can) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
int main() {
	int n;

	cin >> n;
	VE vec(n);
	REP(i, n) {
		cin >> vec[i];
	}
	double ans = 0;
	REP(i, n) {
		ans += static_cast<double>(1) / vec[i];
	}

	cout << 1 / ans << endl;
	return 0;
}


Measured memory_bytes: 256
# C - Write and Erase
import collections
N = int(input())
a = [int(input()) for i in range(N)]
c = collections.Counter(a)
ans = 0
#print(c)
#print(len(c))
val = list(c.values())
for j in range(len(val)):
    if val[j] % 2 == 0:
        pass
    else:
        ans += 1

print(ans)

Measured memory_bytes: 62168
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
using namespace std;




int main(){
    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    sort(p.rbegin(), p.rend());

    vector<int> ans;
    for(int i = -10; i <= 110; i++){
        bool exist = true;
        rep(j, n){
            if(i == p[j]) exist = false; 
        }
        if(exist) ans.push_back(i);
    }
    //rep(i, ans.size()) cout << ans[i] << endl;
    

    int left = -1;
    int right = (int)ans.size();

    while(right - left > 1){
        bool exist = true;
        int mid = left + (right - left) / 2;
        if (ans[mid] >= x) exist = true;
        else exist = false;
        if(exist) right = mid;
        else left = mid;
    }
    //cout << ans[left] << " " << ans[right] << endl;
    //cout << x-ans[left] << " " << ans[right]-x << endl;
    
    if(ans[right] == x){
        cout << x << endl;
        return 0;
    }
    if(abs(x-ans[left]) <= abs(ans[right]-x)){
        cout << ans[left] << endl;
    }else{
        cout << ans[right] << endl;
    }

}

Measured memory_bytes: 3636
#include <stdio.h>

#define S_LENGTH (4 + 1)
#define STRING_PLS '+'
#define STRING_MIN '-'

int main(void)
{
    int output = 0;
    char str[S_LENGTH];
    char input[S_LENGTH];
  
    fgets(str, sizeof(str), stdin);
    sscanf(str, "%s%*s", input);
    
    for(int i=0; i < S_LENGTH; i++){
      if (input[i] == STRING_PLS){
        output++;
      }else if (input[i] == STRING_MIN){
        output--; 
      }
    }
    
    printf("%d", output);
    return 0;
}



Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

vector<long long> calc_divisor(long long n) {
    vector<long long> res;
    long long mx=n;
    for (long long i = 1LL; i*i <= mx; ++i) {
	if(n%i==0)res.push_back(i);
        while(n % i == 0 and i!=1) {
          n /= i;
        }
    }
    res.push_back(n);
    sort(res.begin(), res.end());
    return res;
}

int main()
{
	long long cnt=0;
	long long a,b;
	cin >> a >> b;
	
	if(b>a)
	{
		swap(a,b);
	}
		

	vector<long long> aa=calc_divisor(a);
	set<long long> st;
	for(int i=0;i<aa.size();i++)
	{
		long long sz=st.size();
		st.insert(aa[i]);
		if(st.size()>sz)
			if(b%aa[i]==0)cnt++;
	}
	cout << cnt << endl;




}

Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))

dp = [-1] * N
for n in range(N):
    if n == 0:
        dp[n] = 0
    elif n == 1:
        dp[n] = abs(A[0] - A[1])
    else:
        dp[n] = min(abs(A[n] - A[n - 1]) + dp[n - 1], abs(A[n] - A[n - 2]) + dp[n - 2])
print(dp[-1])

Measured memory_bytes: 13928
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
const ll nmax = 1e9 + 7;
const ll MOD = 998244353;
const double PI = 2 * asin(1);

int main(){
  int A, B; cin >> A >> B;
  int M = max(A, B), m = min(A, B);

  for (int i = 0; i < M; i++){
    cout << m;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
use ascii::AsciiChar;
use ascii::AsciiStr;
use itertools::Itertools as _;
use permutohedron::LexicalPermutation as _;
use petgraph::algo::dijkstra;
use petgraph::algo::min_spanning_tree;
use petgraph::data::FromElements;
use petgraph::graph::NodeIndex;
use petgraph::graph::UnGraph;
use petgraph::unionfind::UnionFind;
use proconio::fastout;
use proconio::input;
use proconio::marker::Chars;
use proconio::marker::Usize1;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use superslice::Ext as _;

// 自分で正答した後に答えを見た。
// 自分は二分探索の着想を得ていたが、二分探索の内側でやっていたO(N)の処理を最初からやればよかった

#[fastout]
fn main() {
    input! {
        orig_N: usize,
        mut As: [i64; orig_N],
    }

    // どこかに境界線があるはず。ある強さ以上のモンスターは生き残る可能性があり、
    // ある強さ未満のモンスターはどうやっても生き残れない

    // 2分探索しつつ、「このモンスター生き残れますか」のクエリをO(N)くらいで回答できればよさそう。

    // 2分探索でis_ngを持つために、絶対に絶滅するモンスターを便宜的に投入しておく。
    // 必ず死ぬので、答えの値が大きくなることは無い。
    As.push(0); // 0しか吸収できないが、他のモンスターは1以上なので必ず死ぬ
    let N = orig_N + 1;
    As.sort();

    // 自分より弱いモンスターを全て食ってその和の大きさになるので、累積和を使うと効率が良い
    let mut acc = vec![0i64; N + 1];
    for i in 0..N {
        acc[i + 1] = acc[i] + As[i];
    }

    let mut ans = 0;
    // ind=Nが勝てるのは自明なのでチェックしない
    for i in 0..N - 1 {
        if As[i + 1] > 2 * acc[i + 1] {
            ans = max(ans, i);
        }
    }

    println!("{}", N - (ans + 1));
}


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

struct node{
  string exp;
  int left=-1;
  int right=-1;
};

int num;
bool v[11],result;
vector<char> s;

int find(char c){
  int i;
  for(i=0;i<s.size();i++)
    if(s[i]==c) break;
  if(i<s.size()) return i; 
  else return -1;
}

int prior(char c){
  if(c=='=') return 0;
  else if(c=='>') return 1;
  else if(c=='+') return 2;
  else if(c=='*') return 3;
  else if(c=='-') return 4;
  else if(c=='T'||c=='F') return 5;
  else{
    if(find(c)==-1) s.push_back(c);
    return 5;
  }
}

void divide(int self,string exp,node nodes[]){
  int cnt=0,min=5,min_index=-1;
  bool inter=false;
  for(int i=0;i<exp.size();i++){
    if(exp[i]=='('){
      cnt++;
      if(i==0) inter=true;
    } else if(exp[i]==')'){
      cnt--;
      if(cnt==0&&i!=exp.size()-1) inter=false;
    } else if(cnt==0){
      if(exp[i]=='-')
	if(exp[i+1]=='>') i++;
      int p=prior(exp[i]);
      if(p<min){
	min=p; min_index=i;
      }
    }
  }
  if(inter){
    divide(self,exp.substr(1,exp.size()-2),nodes); return;
  }
  if(min_index>=0){
    if(min==1)
      divide(nodes[self].left=++num,exp.substr(0,min_index-1),nodes);
    else if(min<4)
      divide(nodes[self].left=++num,exp.substr(0,min_index),nodes);
    divide(nodes[self].right=++num,exp.substr(min_index+1),nodes);
    nodes[self].exp=exp[min_index];
  } else nodes[self].exp=exp;
}

bool solve(int n,node nodes[]){
  if(nodes[n].exp=="F") return false;
  else if(nodes[n].exp=="T") return true;
  else{
    if(nodes[n].exp=="+")
      return solve(nodes[n].left,nodes)||solve(nodes[n].right,nodes);
    else if(nodes[n].exp=="*")
      return solve(nodes[n].left,nodes)&&solve(nodes[n].right,nodes);
    else if(nodes[n].exp==">")
      return !solve(nodes[n].left,nodes)||solve(nodes[n].right,nodes);
    else if(nodes[n].exp=="=")
      return solve(nodes[n].left,nodes)==solve(nodes[n].right,nodes);
    else if(nodes[n].exp=="-")
      return !solve(nodes[n].right,nodes);
    else return v[find(nodes[n].exp[0])];
  }
}

void all(node nodes[],int depth){
  if(!result) return;
  if(depth==s.size()){
    if(!solve(0,nodes)) result=false;
    return;
  }
  v[depth]=false; all(nodes,depth+1);
  v[depth]=true; all(nodes,depth+1);
}

int main(){
  string exp;

  for(;;){
    cin>>exp;
    if(exp=="#") break;
    num=0; s.clear(); result=true;
    struct node nodes[1000];
    divide(0,exp,nodes);
    all(nodes,0);
    if(result) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}


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

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

  int cn=0;
  bool flag=true;
  for(int i=0; i<n; i++){
    string str;
    cin >> str;
    if(str=="A"){
      cn++;
    }else if(str=="Un"){
      cn--;
      if(cn<0) flag=false; 
    }
  }

  if(flag && cn==0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3136
/* Bismillahirrahmanirrahim
   Semoga Dapet AC ya Allah
   Amin.................. :)
   Ps. SelfRemainder #1: Variabel gak otomatis nilainya 0
					 #2: Output harus sama persis formatnya sama di contoh
					 #3: Jangan lama2 mikirin 1 soal. Kalo dah gabisa, stop
					 #4: Kalau for bersarang, variabelnya jangan sama
*/
#include<bits/stdc++.h>
#define forA for(int i=0; i<a; i++)
#define Fora for(int i=1; i<=a; i++)
#define ll long long
#define F first
#define S second
using namespace std;

int main(){
	int arr[] = {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 };
	int a;
	cin >> a;
	a--;
	cout << arr[a];
}

Measured memory_bytes: 256
import math

def plot(x,y):
    print(f'{x:.8f} {y:.8f}')
    
def Koch(n, x1,y1,x2,y2):
    if n == 0:
        plot(x1,y1)
        return
    sx = (2 * x1 + x2) / 3
    sy = (2 * y1 + y2) / 3
    tx = (x1 + 2 * x2) / 3
    ty = (y1 + 2 * y2) / 3
    ux = (tx-sx) * (1/2) - (ty-sy) * (math.sqrt(3)/2) + sx
    uy = (tx-sx) * (math.sqrt(3)/2) + (ty-sy) * (1/2) + sy
    Koch(n-1, x1,y1, sx,sy)
    Koch(n-1, sx,sy, ux,uy)
    Koch(n-1, ux,uy, tx,ty)
    Koch(n-1, tx,ty, x2,y2)
    
n=int(input())
Koch(n, 0,0, 100,0)
plot(100,0)


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

int main()
{


        int D;
        cin >> D;
        if (D == 25) {
                cout << "Christmas" << endl;

        }
        else if (D == 24) {
                cout << "Christmas Eve" << endl;
        }
        else if (D == 23) {
                cout << "Christmas Eve Eve" << endl;
        }
        else {
                cout << "Christmas Eve Eve Eve" << endl;
        }

}


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

"""
ボールの数が入ったリストと，赤い玉が一回でもきたことがあるかのリスト
どちらもが０じゃないのが，終わったときに赤が入っている可能性のあるリスト
ただし，ボールリストが０になる時，seenは０になる
"""
ball_list = [1] * (N+1)
seen = [0] * (N+1)
ball_list[0] = 0
seen[1] = 1

for i in range(M):
    x = XY[i][0]
    y = XY[i][1]
    if seen[x] == 1:
        seen[y] = 1
        ball_list[x] -= 1
        ball_list[y] += 1
        if ball_list[x] == 0:
            seen[x] = 0
    else:
        ball_list[x] -= 1
        ball_list[y] += 1

print(seen.count(1))

Measured memory_bytes: 28964
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+50;
int maxn[N<<2],a[N],f[N];
/*void change(int rt,int l,int r,int pos,int v)
{
	if(l==r&&l==pos)
	{
		maxx[rt]=v;
		return ;
	}
	int mid=(l+r)>>1;
	if(pos>mid) change(rt<<1|1,mid+1,r,pos,v);
	else change(rt<<1,l,mid,pos,v);
	maxx[rt]=max(maxx[rt<<1],maxx[rt<<1|1]);
}
int query(int rt,int l,int r,int x,int y)
{
	if(x>=l&&r<=y)
	{
		return maxx[rt];
	}
	int ans=0;
	int mid=(l+r)>>1;
	if(x<=mid) ans=max(ans,query(rt<<1,l,mid,x,y));
	if(mid<y) ans=max(ans,query(rt<<1|1,mid+1,r,x,y));
	return ans;
}*/
void change(int k,int l,int r,int pos,int v)
{
	if (l==pos && pos==r)
	{
		maxn[k]=v;
		return;
	}
	int mid=l+r>>1;
	if (pos<=mid) change(k<<1,l,mid,pos,v);
	else change(k<<1|1,mid+1,r,pos,v);
	maxn[k]=max(maxn[k<<1],maxn[k<<1|1]); 
}

int query(int k,int l,int r,int qx,int qy)
{
	if (qx<=l && r<=qy) return maxn[k];
	int mid=l+r>>1;
	int ans=0;
	if (qx<=mid) ans=max(ans,query(k<<1,l,mid,qx,qy));
	if (mid<qy) ans=max(ans,query(k<<1|1,mid+1,r,qx,qy));
	return ans;
}
int n,k;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;++i) cin>>a[i];
	f[1]=1;
	change(1,0,3e5,a[1],1);
	for(int i=2;i<=n;++i)
	{
		int now=query(1,0,3e5,max(a[i]-k,0),min(300000,a[i]+k));
		f[i]=max(1,now+1);
		now=query(1,0,3e5,a[i],a[i]);
		if(now<f[i]) change(1,0,3e5,a[i],f[i]);
	}
	int Max=0;
	for(int i=1;i<=n;++i) Max=max(f[i],Max);
	cout<<Max<<endl; 
	return 0;
}

Measured memory_bytes: 10032
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a:u32 = read();
    println!("{}", a + a.pow(2) + a.pow(3));
}


Measured memory_bytes: 2140
#include <iostream>
#include <vector>

using namespace std;

vector<int> solve(const vector<int>& a, int L){
    const int n = a.size();
    for(int i=1;i<n;i++){
        if(a[i-1]+a[i] < L) continue;
        vector<int> res;
        for(int j=1;j<i;j++) res.push_back(j);
        for(int j=n-1;j>i;j--) res.push_back(j);
        res.push_back(i);
        return res;
    }
    return vector<int>();
}

int main(){
    int N, L;
    while(cin >> N >> L){
        vector<int> a(N);
        for(auto& t : a) cin >> t;
        vector<int> res = solve(a, L);
        cout << (res.empty() ? "Impossible" : "Possible") << endl;
        for(auto& t : res) cout << t << endl;
    }    
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD1 1000000007
#define MOD2 998244353
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ll t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<ll,ll> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m,ll MOD){if(m==0)return 1;ll t=mpowe(n,m/2,MOD);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;if(n==0) return -1;return logtwo(n/2)+1;}
ll m=1e9;
int main()
{
    fastio();
    
    ll n,m;
    cin>>m>>n;
    ll a[n];
    cn(a,n);
    ll sum=0;
    for(int i=0;i<n;i++)
        sum+=a[i];
    ll ans= m-sum;
    if(ans<0)
        ans=-1;
    cout<<ans<<endl;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n, x, y;
  cin >> n >> x >> y;
  vector<int> G[n];
  vector<vector<int>> dist(n,vector<int>(n,-1));// dist[i][j]:=iからjへの距離
  x--, y--;
  G[x].pb(y);
  G[y].pb(x);
  rep(i, n - 1) {
    G[i].pb(i + 1);
    G[i + 1].pb(i);
  }
  rep(st,n){
    dist[st][st] = 0;
    queue<int> q;
    q.push(st);
    while(!q.empty()){
      int p = q.front();
      q.pop();
      for(auto nx : G[p]){
        if (dist[st][nx] != -1) continue;
        dist[st][nx] = dist[st][p] + 1;
        q.push(nx);
      }
    }
  }
  vector<int> ans(n,0);
  rep(i, n) rep(j, n) ans[dist[i][j]]++;
  for (int i = 1; i < n; i++){
    cout << ans[i]/2 << endl;
  } 
  return 0;
}

Measured memory_bytes: 19448
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c,d=0,0
for i in range(n):
    if a[i]>b[i]:
        c+=a[i]-b[i]
    else:
        d+=(b[i]-a[i])//2
if d>=c:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef long long ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

int n, k;
ll p[3], ans = 0;
string t, te = "rsp";
char lg[inf];

int main() {
    cin >> n >> k;
    rep(i, 3) cin >> p[i];
    cin >> t;
    rep(i, k)
        rep(j, 3)
            if(t[i] == te[j]) {ans += p[(j + 2) % 3]; lg[i] = te[(j + 2) % 3];}
    for(int i = k; i < n; i++)
        rep(j, 3)
            if(t[i] == te[j] && te[(j + 2) % 3] != lg[i - k]){ans += p[(j + 2) % 3]; lg[i] = te[(j + 2) % 3];}
    cout << ans << endl;
}

Measured memory_bytes: 512
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
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 ) * } } ; }
#[allow(unused_macros)]
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 ) * } } ; }
#[allow(unused_macros)]
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" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input!{a:i64,b:i64,c:i64};
    println!("{}", if (b-a)==(c-b) {"YES"} else {"NO"});
}


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

int N, P;
string S;

signed main(){
  cin >> N >> P >> S;

  if(P==2) {
    int ans = 0;
    for(int i=N-1; i>=0; i--) 
      if((int)(S[i]-'0')%2 == 0) ans += (i+1);
    cout << ans << endl;
    return 0;
  }

  if(P==5) {
    int ans = 0;
    for(int i=N-1; i>=0; i--) 
      if(S[i] == '0' || S[i] == '5') ans += (i+1);
    cout << ans << endl;
    return 0;
  }

  vector<int> C(N);
  C[0] = (int)(S[N-1] - '0') % P;
  int p10 = 10;
  for(int i=1; i<N; i++) {
    int si = S[N-1-i] - '0';
    C[i] = (p10 * si + C[i-1]) % P;
    p10 = (p10*10) % P;
  }

  int ans = 0;
  vector<int> A(P+1);
  for(int i=0; i<N; i++) {
    if(C[i] == 0) ans++;
    ans += A[C[i]];
    A[C[i]]++;
  }
  cout << ans << endl; 
}


Measured memory_bytes: 2180
#include<iostream>
using namespace std;
int main(){
while(1){
int h;
cin>>h;
if(h==0)
break;
int x[h][5];
for(int i=0;i<h;i++){
for(int j=0;j<5;j++){
cin>>x[i][j];
}
}
int sum=0;
while(1){
int flag=0;

for(int i=0;i<h;i++){
if(x[i][0]==x[i][1]&&x[i][1]==x[i][2]&&x[i][2]==x[i][3]&&x[i][3]==x[i][4]&&x[i][0]!=0){
flag=1;
sum+=x[i][0]*5;
x[i][0]=0;
x[i][1]=0;
x[i][2]=0;
x[i][3]=0;
x[i][4]=0;
}
else if(x[i][0]==x[i][1]&&x[i][1]==x[i][2]&&x[i][2]==x[i][3]&&x[i][0]!=0){
flag=1;
sum+=x[i][0]*4;
x[i][0]=0;
x[i][1]=0;
x[i][2]=0;
x[i][3]=0;
}
else if(x[i][3]==x[i][4]&&x[i][1]==x[i][2]&&x[i][2]==x[i][3]&&x[i][3]!=0){
flag=1;
sum+=x[i][1]*4;
x[i][4]=0;
x[i][1]=0;
x[i][2]=0;
x[i][3]=0;
}
else if(x[i][0]==x[i][1]&&x[i][1]==x[i][2]&&x[i][0]!=0){
flag=1;
sum+=x[i][0]*3;
x[i][0]=0;
x[i][1]=0;
x[i][2]=0;
}else if(x[i][2]==x[i][3]&&x[i][1]==x[i][2]&&x[i][1]!=0){
flag=1;
sum+=x[i][1]*3;
x[i][3]=0;
x[i][1]=0;
x[i][2]=0;
}else if(x[i][2]==x[i][3]&&x[i][3]==x[i][4]&&x[i][4]!=0){
flag=1;
sum+=x[i][2]*3;
x[i][3]=0;
x[i][4]=0;
x[i][2]=0;
}

}

if(flag==0)break;

int x1[h];
int x2[h];
int x3[h];
int x4[h];
int x5[h];
int len1=0;
int len2=0;
int len3=0;
int len4=0;
int len5=0;
for(int i=h-1;i>=0;i--){
if(x[i][0]!=0){
x1[len1]=x[i][0];
len1++;
}
if(x[i][1]!=0){
x2[len2]=x[i][1];
len2++;
}
if(x[i][2]!=0){
x3[len3]=x[i][2];
len3++;
}
if(x[i][3]!=0){
x4[len4]=x[i][3];
len4++;
}
if(x[i][4]!=0){
x5[len5]=x[i][4];
len5++;
}
}
for(int j=len1;j<h;j++){
x1[j]=0;
}
for(int j=len2;j<h;j++){
x2[j]=0;
}
for(int j=len3;j<h;j++){
x3[j]=0;
}
for(int j=len4;j<h;j++){
x4[j]=0;
}
for(int j=len5;j<h;j++){
x5[j]=0;
}
for(int i=0;i<h;i++){
x[i][0]=x1[h-i-1];
x[i][1]=x2[h-i-1];
x[i][2]=x3[h-i-1];
x[i][3]=x4[h-i-1];
x[i][4]=x5[h-i-1];
}
}
cout<<sum<<endl;
}
return 0;
}


Measured memory_bytes: 3084
#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>
#include<functional>
#include<assert.h>
#include<numeric>
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)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
    ll X; cin >> X; ll begin = 100;
    for(int i=1; i<=10000000; i++){
        begin*=1.01;
        if(begin>=X){
            cout << i << endl; break;
        }
    }
}

Measured memory_bytes: 3632
import scala.io.StdIn.readInt
object Main {
    def main(args: Array[String]) = {
        val a = readInt()
        println(watch(a))
    }
    def div(a: Int, b: Int): (Int, Int) = (a / b, a % b)
    def watch(sec: Int): String = {
        val a = div(sec, 3600)
        val b = div(a._2, 60)
        return s"${a._1}:${b._1}:${b._2}"
    }
}


Measured memory_bytes: 43664
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    System.out.println((a+b)*c/2);
  }
}

Measured memory_bytes: 21844
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int a, b;
 
int main(){
    cin >> a >> b;
    cout << (a < 10 && b < 10 ? a * b : -1) << endl;
}

Measured memory_bytes: 256
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll n;
    cin>>n;
    V vec(n);
    rep(i,n)cin>>vec[i];
    ll k=0;
    rep(i,n)k^=vec[i];
    rep(i,n){
        ll res=vec[i]^k;
        cout<<res<<endl;
    }
}


Measured memory_bytes: 4668
import sys
input = sys.stdin.buffer.readline

def main():
    N,K = map(int,input().split())
    MOD = 10**9+7
    
    fac = [0]*(N+1)
    invfac = [0]*(N+1)
    fac[0],fac[1] = 1,1
    invfac[0],invfac[1] = 1,1
    
    for i in range(2,N+1):
        fac[i] = (fac[i-1]*i)%MOD
        
    invfac[-1] = pow(fac[-1],MOD-2,MOD)
    for i in range(N,0,-1):
        invfac[i-1] = (invfac[i]*i)%MOD
        
    def comb(x,y):
        return (fac[x]*invfac[y]*invfac[x-y])%MOD
        
    ans = 0
    for i in range(min(N,K+1)):
        a = comb(N,i)
        b = comb(N-1,N-i-1)
        ans += (a*b)%MOD
        
    print(ans%MOD)

if __name__ == "__main__":
    main()


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

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

const int MOD = 1e9 + 7;
const int INFi = 2e9 + 1;
const lli INFl = (lli)(9e18) + 1;
// const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(i, vec) for(auto (i) = (vec).begin(); (i) != (vec).end(); (i)++)
#define vrREP(i, vec) for(auto (i) = (vec).end()-1;(i) != (vec).begin()-1;(i)--)

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



int main(void){
  int a, b; cin >> a >> b;
  if(b % a == 0) cout << b + a << "\n";
  else cout << b - a << "\n";
  return 0;
}

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

int main() {
  int X, A;
  cin >> X >> A;
  cout << (X < A ? 0 : 10) << endl;
}


Measured memory_bytes: 256
INPUT_LINE = gets.chomp!.split(" ").map! { |i| i.to_i }
N = INPUT_LINE[0]
A = INPUT_LINE[1]
B = INPUT_LINE[2]
S = gets.chomp!.split("")

confirm_a = 0
confirm_b = 0

S.each do |_s|
  if confirm_a + confirm_b < A + B
    case _s
    when "a"
      puts "Yes"
      confirm_a += 1
    when "b"
      if confirm_b < B
        confirm_b += 1
        puts "Yes"
      else
        puts "No"
      end
    when "c"
      puts "No"
    end
  else
    puts "No"
  end
end


Measured memory_bytes: 22564
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <stdio.h>
#include <sstream>

#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1LL<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int h,w,c[10][10];

int main() {
  cin>>h>>w;
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++)cin>>c[i][j];
  }
  for(int k=0;k<10;k++){
    for(int i=0;i<10;i++){
      for(int j=0;j<10;j++)c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
    }
  }
  ll ans=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      int t;
      cin>>t;
      if(t!=-1)ans+=c[t][1];
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

using namespace std;

int main(){

    int n;
    cin >> n;
  
    vector<int> prime(55556,1);

    prime[0] = 0;
    prime[1] = 0;

    for(int i = 2; i <= 55555; i++){
        if(i * i > 55555) break;

        if(prime[i] == 1){
            for(int j = i * i; j <= 55555; j = j + i){
                prime[j] = 0;
            }
        }
    }

    vector<int> ans;
    int tmpn = n;

    for(int i = 1; i <= 55555; i = i + 5){
        if(tmpn == 0) break;

        if(prime[i] == 1){
            ans.pback(i);
            tmpn--;
        }
    }

    rep(i,n){
        cout << ans[i] << " ";
    }

    cout << endl;
}


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

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

  if (N < 10) {
    cout << N << endl;
  } else if (N < 100) {
    cout << 9 << endl;
  } else if (N < 999) {
    cout << N - 90 << endl;
  } else if (N < 10000) {
    cout << 909 << endl;
  } else if (N < 100000) {
    cout << N - 9090 << endl;
  } else {
    cout << 90909 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, maxlen = 0, sum = 0;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		int v;
		cin >> v;

		sum += v;
		maxlen = max(maxlen, v);
	}

	if (maxlen < sum - maxlen)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256