akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

int n;
vi mn, sitting;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

P f(int x){
    int r = x/n;
    int c = x%n;
    return P(r, c);       
}
  
int g(int r, int c){
    return r * n + c;
}

void printall(){
    rep(r, n){
        rep(c, n){
            cout << mn[r*n + c] << " ";
        }
        cout << "| ";
        rep(c, n){
            cout << sitting[r*n + c] << " ";
        }
        cout << endl;
    }
    rep(i, n) cout << "-";
    cout << endl;
    return;
}

void Main(){
    // ABC044 - B - Joker //
    
    cin >> n;

    mn.resize(n*n);
    sitting.resize(n*n, 1);
    vi p(n*n);

    rep(i, n*n) {
        cin >> p[i];
        p[i]--;
        int rmn = min(n - 1 - f(i).fi, f(i).fi);
        int cmn = min(n - 1 - f(i).se, f(i).se);
        mn[i] = min(rmn, cmn);
    }

	//printall();
    
    /*        
    rep(i, n*n){
        auto [r, c] = f(i+1);
        cout << i+1 << ": " << r << "," << c << ": " << mn[i] << endl;
    }
	*/
	
	ll ans = 0;
	rep(i, n*n){
	    ans += mn[p[i]];
	    auto [px, py] = f(p[i]);
	    rep(k, 4){
	        auto [nx, ny] = P(px + dx[k], py + dy[k]);
	        if(nx < 0 || nx >= n || ny < 0 || ny >= n) {
	            mn[p[i]] = 0;
	            break;
	        }
	        int next = g(nx, ny);
	        mn[p[i]] = min(mn[p[i]], mn[next] + sitting[next]);
	    }
        sitting[p[i]] = 0;
        
	    // bfs
	    queue<int> q;
	    q.push(p[i]);
	    while(!q.empty()){
	        auto now = q.front(); q.pop();
    	    auto [px, py] = f(now);
	        rep(k, 4){
	            auto [nx, ny] = P(px + dx[k], py + dy[k]);
	            if(nx < 0 || nx >= n || ny < 0 || ny >= n) {
	                continue;
	            }
	            int next = g(nx, ny);
	            if(mn[next] > mn[now] + sitting[now]){
	                mn[next] = mn[now] + sitting[now];
	                q.push(next);
	            } 
	        }
	    }
	    //cout << p[i] << ": " << ans << endl;
	    //printall();
	}
	
	cout << ans << endl;
	return;
}

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

Measured memory_bytes: 6112
#include <bits/stdc++.h>
#include <boost/foreach.hpp>
using namespace std;
#define pi 2*asin(1.0)
#define MAX 10000000
#define MOD 1000000007
#define _GLIBCXX_DEBUG
 
vector<long> fac(MAX);
vector<long> finv(MAX);
vector<long> inv(MAX);
vector<long> Primelist;
//template functions
/////////////////////////
void Prinit(){
long PR=10000001;
vector<long> P(PR,0);
for(long i=2;i*i<PR;i++){
    if(P.at(i)==0){
        long j=i;
      j+=i;
        while(j<PR){
            P.at(j)=1;
             j+=i;         
        }
    }
}

for(long i=2;i*i<PR;i++){//Primelist.size()=446
    if(P.at(i)==0){
        Primelist.push_back(i);
    }
}
}

void Cominit(){
  fac.at(0)=fac.at(1)=1;
  finv.at(0)=finv.at(1)=1;
  inv.at(1)=1;
  for(long i=2;i<MAX;i++){
      fac.at(i)=(fac.at(i-1)*i)%MOD;
      inv.at(i)=MOD-inv.at(MOD%i)*(MOD/i)%MOD;
      finv.at(i)=finv.at(i-1)*inv.at(i)%MOD;
  }
}

long facComb(long N,long M){// nCm%
if(N<M) return 0;
if(N<0||M<0) return 0;
return fac.at(N)*(finv.at(M)*finv.at(N-M)%MOD)%MOD;
}

long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}

long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}

long GCM(long A,long B){
            long W,r;
    if(A<B){

        W=B;
        B=A;
        A=W;
    }
    while(A%B!=0){
        r=A%B;
        A=B;
        B=r;
    }
    return B;
}
long LCM(long A,long B){
    return (A*B)/GCM(A,B);
}

long upDiv(long a,long b){
  return (a+b-1)/b;
}

long strtolong(string str){
istringstream ss;
ss=istringstream(str);
long num;
ss>>num;
return num;
}

long chartolong(char ch){
long num;
num=ch-'0';
return num;
}

string longtostr(long N){
    string str;
    str=to_string(N);
    return str;
}









/////////////////////////


//Answer


int main() {
Cominit();
long S,a,b,now,ans=0;
cin>>S;
a=S/3;
b=S%3;
for(long i=0;i<a;i++){
now=facComb(a+b-1+2*i,a-1-i);
ans+=now;
ans=ans%MOD;
}
cout<<ans<<endl;

}




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


int compare_int(const void *a, const void *b)
{
//    return *(int*)a - *(int*)b;
    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

//long long  factorial(long long n) {
//    if (n > 0) {
//        return n * factorial(n - 1);
//    } else {
//        return 1;
//    }
//}
long long  factorial(long long n, long long depth) {
    if (n > 1) {
        depth++;
        return factorial(n / 2, depth);
    } else {
        return depth;
    }
}

int min(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}



//int ()
/*
int triangle(int a, int b, int c){
  if(a<b+c){
    if(b<c+a){
      if(c<a+b){
        printf("1\n");
        return 1;
      }
    }
  }
  printf("1\n");
  return 0;
}
*/

int main()
{
//  int  a ,b, c, d, e, X, Y ,r;
  unsigned long long  a, b, c, d, e, X, Y;
  //  double  c;
// long long  A[200003]={};
  int  A[100003]={};
  int  B[100003]={};
//  int  C[100003][100001]={};
  int  C[100003]={};

  int  flg=0;

//  char s[101][101]={};
  char s[100001]={};
  char t[100001]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p=0,q=0;
//  int flag=0;
//  int tmp=0;
//  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  long long min =100000001;
  int len=0;
  int l=0;
//  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  long long  ans=0;
  int ans_ac=0;
  int ans_wa=0;
  int max=0;
  long long sum=0;
  int addr=0;
  int ptn=0;
  int  tmp=0;
  double per=0; 
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
  scanf("%s", &s);
  if(s[2]==s[3] && s[4]==s[5]) printf("Yes\n");
  else printf("No\n");
return 0;
}


Measured memory_bytes: 256
num_V, num_E = map(int, input().split())
inf = float('inf')

d = [[inf] * num_V for _ in range(num_V)]

for _ in range(num_E):
	ts,tt,td = map(int, input().split())
	d[ts][tt] = td

dp = [[-1] * num_V for _ in range(1 << num_V)]

def solve(s,v,dp):
	if dp[s][v] >= 0:
		return dp[s][v]

	if s == ((1 << num_V) - 1) and v == 0:
		return 0

	tmp = inf
	for u in range(num_V):
		if s >> u & 1 == 0:
			tmp = min(tmp, solve(s|1 << u, u, dp) + d[v][u])

	dp[s][v] = tmp
	return dp[s][v]

ans = solve(0,0,dp)
if ans == inf:
	print(-1)
else:
	print(ans)


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;
const ll MOD = 998244353;

// n^m%MOD を求める。O( log(m) )
ll modpow(ll n, int m){
	ll ret=1;
	for(int i=1; i<=m; i<<=1, (n*=n)%=MOD){
		if( m&i ) (ret *= n) %= MOD;
	}
	return ret;
}

// 逆元を求める
ll modinv(ll n){
	return modpow( n, MOD-2 );
}

// 階乗を求める。O(1)  準備O( n*log(n) )
// fact[n]     : nの階乗
// fact.inv[n] : nの階乗の逆元
class FACTORIAL{
public:
	vector<ll> fact, inv;
	FACTORIAL(int MAX_NUM): fact(MAX_NUM), inv(MAX_NUM) {
		fact[0] = inv[0] = 1;
		for(ll i=1; i<MAX_NUM; i++){
			fact[i] = (fact[i-1] * i) % MOD;
			inv[i] = modinv( fact[i] );
		}
	}
	const ll& operator [ ] ( const int i ) const {
		return fact[i];
	}
} fact(1000006); // nの最大値を指定


// 組み合わせ(Combinationを求める) O(1)
ll cmb(unsigned int n, unsigned int r){
	if( n < r ) return 0;
	return fact[n] * fact.inv[r] % MOD * fact.inv[n-r] % MOD;
}



int main(){
	//ios_base::sync_with_stdio(false);
	ll N, A, B, K, ans=0;

	cin >> N >> A >> B >> K;

	rep(i,N+1){
		ll a = i;
		ll b = (K - a*A) / B;
		if(a*A + b*B == K && b <= N){
			ans += (cmb(N, a) * cmb(N, b)) % MOD;
			ans %= MOD;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 15872
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

x,y = map(int,input().split())
if x%y == 0:print(-1)
else: print(x)

Measured memory_bytes: 3572
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

string swapstr(string s)
{
	char out[120] = "";
	int idx = 0;
	for (int i = s.size()-1; i>= 0; i--)
	{
		out[idx] = s[i];
		idx++;
	}
	return out;
}

int main()
{
	string s; cin >> s;
	int center;
	center = s.size() / 2;

	string a, b;
	a = s.substr(0, center);
	if (s.size() % 2 == 0) b = s.substr(center);
	else b = s.substr(center+1);
	//cout << a << endl;
	b = swapstr(b);
	//cout << b << endl;

	int cnt = 0;
	for (int i = 0; i < a.size(); i++)
	{
		if (a[i] != b[i]) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
//                                      KiSmAt
#include "bits/stdc++.h"
using namespace std;
 
using ll = long long;
 
const ll inf = 1e18;
const int N = 2 * 1e5 + 10;

ll res;
ll a[N];
ll b[N];
ll c[N];
ll dp[N][3];

void solve(){
	ll n;
	cin >> n;
	for(int i = 1; i <= n; ++i){
		cin >> a[i] >> b[i] >> c[i];
	}
	for(int i = 1; i <= n; ++i){
		dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = b[i] + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = c[i] + max(dp[i - 1][0], dp[i - 1][1]); 
	}
	cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
}
 
int main(int argc, char const *argv[]){
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
    	solve();
    }
}
// nEro

Measured memory_bytes: 8832
#include <stdio.h>
int main(){
  int n ,coin=0 ,money;
  while ( scanf( "%d" ,&n ) ){
    if( n == 0 ){
      break;
    } 
    
    money = 1000 - n;
    
    if( money >= 500 ){
      coin++;
      money -= 500;
    }
    
    if( money >= 100 ){
      while( money >= 100 ){
	coin++;
	money -= 100;
      }
    }
    
    if( money >= 50 ){
      while( money >= 50 ){
	coin++;
	money -= 50;
      }
    }
    
    if( money >= 10 ){
      while( money >= 10 ){
	coin++;
	money -= 10;
      }
    }
    
    if( money >= 5 ){
      while( money >= 5 ){
	coin++;
	money -= 5;
      }
    }
    
    coin += money;
    
    printf( "%d\n" ,coin );
    coin = 0;
    money = 0;
  }
  return 0;
}
    

Measured memory_bytes: 600
a, b = map(int, input().split())
tmp=str(a)
c=0
for i in range(a,b+1):
    tmp=str(i)
    tmp2=""
    for s in range(len(tmp)):
        tmp2=tmp2+tmp[len(tmp)-1-s]
    if tmp==tmp2:
        c=c+1
print(c)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
int K,X,Y,Z;
vi D;
int C[1000];
int func(int P){
  int sum=0;
  rep(i,0,Z){
    sum+=X*Y-dislow(D,P-C[i]);
  }
  return sum;
}
signed main(){
  cin>>X>>Y>>Z>>K;
  vi A(X),B(Y);
  rep(i,0,X) cin>>A[i];
  rep(i,0,Y) cin>>B[i];
  rep(i,0,Z) cin>>C[i];
  rep(i,0,X){
    rep(j,0,Y) D.pb(A[i]+B[j]);
  }
  sort(ALL(D));
  D.pb(INF);
  int left=0,right=INF,memo=-1;
  while(left+1<right){
    int mid=(left+right)/2;
    if(func(mid)==K){
      memo=mid;
      break;
    }
    else if(func(mid)<K){
      right=mid;
    }
    else{
      left=mid;
    }
  }
  if(memo==-1){
    if(func(right)==K) memo=right;
    else memo=left;
  }
  vi ans;
  rep(i,0,Z){
    rep(j,dislow(D,memo-C[i]),X*Y){
      ans.pb(C[i]+D[j]);
    }
  }
  sort(ALL(ans),greater<int>());
  rep(i,0,K) cout<<ans[i]<<endl;
  }




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

int main(){
  int N;
  cin >> N;
  string str1, str2;
  cin >> str1 >> str2;

  rep(i, N){
    cout << str1.at(i) << str2.at(i);
  }
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  string S, T;
  cin >> S;
  cin >> T;
  for(int i = 0; i < N; i++) cout << S[i] << T[i];
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    string S;
    cin >> S;
    char b = '-';
    for (auto e:S) {
        if(e=='?') cout << 'D';
        else  cout << e;
    }
    cout << endl;
}


Measured memory_bytes: 3752
package main

import "fmt"

func main() {
	var s int
	fmt.Scan(&s)
	var h int = s / 3600
	s -= h * 3600
	var m int = s / 60
	s -= m * 60
	fmt.Print(h)
	fmt.Print(":")
	fmt.Print(m)
	fmt.Print(":")
	fmt.Println(s)
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

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

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

  int N, M;
  cin >> N >> M;

  vector<int> s(M);
  vector<char> c(M);
  rep(i, M){
    cin >> s[i] >> c[i];
  }

  int max10 = 1;
  for(int i = 0; i < N; i++) max10 *= 10;

  int start;
  if(N >= 2){
    start = max10/10;
  }else{
    start = 0;
  }

  for(int i = start; i < max10; i++){

    string snum = to_string(i);
    bool ok = true;
    rep(j, M){
      if(snum[s[j]-1] != c[j]){
        ok = false;
      }
    }

    if(ok){
      cout << i << endl;
      return 0;
    }

  }

  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int a[1000000];
int b[1000000];
int main()
{
    int n, k ,q;
    cin >>n>>k>>q;
    for(int i=0;i<q;i++){
        cin >>b[i];
        a[b[i]]++;
    }
    for(int i=1;i<=n;i++){
        if(q-a[i]<k)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;
const int MOD = 1'000'000'007;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << 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;
}

// const int MAX = 1010;

int main()
{
    // aが高い剣以外のmaxi_aより高い剣を投げてaでたたく
    ll n, h;
    cin >> n >> h;
    vector<ll> a(n), b(n);
    ll maxi = 0;
    int index = -1;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
        if (maxi <= a[i])
        {
            maxi = a[i];
            index = i;
        }
    }
    vector<int> tws;
    for (int i = 0; i < n; i++)
    {
        if (b[i] > maxi && i != index)
        {
            tws.push_back(b[i]);
        }
    }
    sort(tws.begin(), tws.end());
    reverse(tws.begin(), tws.end());
    int tws_index = 0;
    int ans = 0;
    while (h > 0)
    {
        if (h <= b[index])
        {
            h -= b[index];
        }
        else if (tws_index != tws.size())
        {
            h -= tws[tws_index];
            ++tws_index;
        }
        else
        {
            ans += (h - b[index] + maxi - 1) / maxi;
            h = b[index];
            --ans;
        }
        ++ans;
        if (h <= 0)
        {
            cout << ans << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 5496
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'
template <class T> bool updmax(T& a, T b) { if (b > a) { a = b; return true;} return false;}
template <class T> bool updmin(T& a, T b) { if (b < a) { a = b; return true;} return false;}
template <class T> T permutation(ll n, ll k) { T f(1); for (ll i=0; i<k; ++i, --n) f *= n; return f; }
template <class T> T factorial(ll n) { return permutation<T>(n,n); }
template <class T> T binomial(ll n, ll k) { return permutation<T>(n,k) /= factorial<T>(k); }

template <ll Mod>
class modint {
    public:
    ll n=0;
    modint(){}
    modint(ll n):n(n){ clamp(); }
    modint& operator = (modint const& a) = default;
    modint& operator = (int a) { n = a; clamp(); return *this; }
    modint operator - () { modint t = *this; t.n = -t.n; t.clamp(); return t; }
    modint& operator *= (modint const& a) { n *= a.n; clamp(); return *this; }
    modint& operator *= (ll a) { n *= a; clamp(); return *this; }
    modint& operator /= (modint const& a) { *this *= a.inv(); return *this; }
    modint& operator += (modint const& a) { n += a.n; if (n >= Mod) n -= Mod; return *this; }
    modint& operator -= (modint const& a) { n -= a.n; if (n < 0) n += Mod; return *this; }
    modint& operator %= (modint const& a) { n %= a.n; clamp(); return *this; }
    friend modint operator * (modint a, modint b) { modint t(a); t.n *= b.n; t.clamp(); return t; }
    friend modint operator + (modint a, modint b) { modint t(a); t.n += b.n; t.clamp(); return t; }
    friend modint operator - (modint a, modint b) { modint t(a); t.n -= b.n; t.clamp(); return t; }
    friend ostream& operator << (ostream& os, modint const& a) { os << a.n; return os; }
    friend bool operator == (modint const& a, int b) { return a.n == b; }
    void clamp() { n %= Mod; if (n < 0) n += Mod; }
    modint inv() const { return this->pow(Mod-2); }
    ll get() { return n; }
    modint pow(ll p) const {
        ll a=1, e=n;
        while (p > 0) {
            if (p&1) { a *= e; a %= Mod; }
            e *= e; e %= Mod; p >>= 1;
        }
        return modint(a);
    }
};

const ll Mod = (ll)1e9+7;
using mint = modint<Mod>;

int main() {
    fastio;
    ll x,y;
    cin >> x >> y;
    for (int rn=0; rn*2<=x; ++rn) {
        int w = rn*2;
        int un = x - w;
        if (un < 0)
            break;
        if (rn + un*2 == y) {
            mint m = binomial<mint>(rn + un, rn);
            cout << m.get() << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}


Measured memory_bytes: 3584
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

class Program
{
    static void Main(string[] args)
    {
        var S = sc.ReadStr();
        var reg = new Regex("^(dream|dreamer|erase|eraser)+$");
        var ok = reg.IsMatch(S);
        Console.WriteLine(ok ? "YES" : "NO");
    }

    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


Measured memory_bytes: 19532
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>

#define ll long long int
#define all(x) x.begin(), x.end()
#define MOD 998244353

using namespace std;

void solve()
{
    int n;
    cin >> n;

    int d = n % 10;

    if (d == 3)
    {
        cout << "bon\n";
    }
    else if (d == 1 || d == 0 || d == 6 || d == 8)
    {
        cout << "pon\n";
         
    }
    else {
        cout << "hon\n";
    }
}

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

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



Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n-1);0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define DUMP(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<": "<<(x)<< " (L"<<__LINE__<<")"<<endl;
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;
using ll = long long;

int main() {
    ll n, m; cin >> n >> m;
    if(m <= 2 * n) {
        cout << min(n, m / 2) << endl;
    } else {
        ll ans = n;
        m -= 2 * n;
        cout << ans + (m / 4) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int h,w,n;
    cin >> h >> w >> n;
    vector<int> v(n);
    rep(i,n){
        cin >> v[i];
    }
    vector<vector<int>> s(h,vector<int> (w,0));
    rep(i,h) s[i].resize(w);
    int x = 0, y = 0;
    rep(i,n){
        rep(j,v[i]){
            s[x][y] = (i+1) ;
            //cout<<x<<" "<<y<<" "<< (i+1) << endl;
            y++;
            if(y==w){
                x++;
                y = 0;
            } 
        }
    }
    rep(i,h){
        if((i+1)%2==0) reverse(s[i].begin(),s[i].end());
    }
    //cout<<h<<" "<<w<<endl;
    rep(i,h){
        rep(j,w){
            if(j!=w-1)cout<<s[i][j]<<" ";
            else cout<<s[i][j];
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 384
class BeTogether:
	def getMinimumValue(self,N,a):
		average = round(float(sum(a))/len(a),0)
		cost = [(a[i]-int(average))**2 for i in range(len(a))]
		print sum(cost)

if __name__ == "__main__":
	N = int(raw_input())
	x = [int(i) for i in raw_input().split()]
	b = BeTogether()
	b.getMinimumValue(N,x)

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

pair<int,int> book[1<<11];
int n;

void solve() {
    int ans=0;
    int rest=0;
    for(int i=1; i<n; ++i) {
        rest+=book[i].first;
    }
    if(rest>=book[0].first) {
        ans=rest+book[0].first;
        for(int i=0; i<n; ++i) {
            ans+=book[i].second;
        }
    } else {
        ans=book[0].first*2;
        rest=book[0].first-rest;
        bitset<1010> bs;
        bs[0]=1;
        int mx=0;
        int tmp=0;
        for(int i=0; i<n; ++i) tmp+=book[i].second;
        for(int i=1; i<n; ++i) {
            bs|=bs<<book[i].second;
        }
        for(int i=0; i<=rest; ++i) {
            if(bs[i]) mx=i;
        }
        tmp-=mx;
        ans+=tmp;
    }
    cout<<ans<<endl;
}

int main() {
    while(cin>>n,n) {
        for(int i=0; i<n; ++i) cin>>book[i].first>>book[i].second;
        sort(book,book+n,greater<pair<int,int>>());
        solve();
    }
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll mod=INF;

int main() {
    int n;
    cin >> n;
    n++;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> m(n+1);
    m[0]=1;
    ll o=1;
    bool t=true;
    rep(i,n){
        o=2*(o-a[i]);
        if (o*2>INF) o=INF/2;
        if (o<0){
            t=false;
            break;
        }
        m[i+1]=o;
    }
    if (!t){
        cout << -1 << endl;
        return 0;
    }
    ll ans=0,b=0;
    for (int i=n-1;i>=0;i--){
        ans+=min(a[i]+b,m[i]);
        b=min(a[i]+b,m[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1e8;
typedef long long ll;
ll mod = 1e9+7;
long long fast_exp(long long a, long long b)
{
    if(b == 0)
	   return 1;
    else
    {
	   long long res = 1;
	   res = fast_exp(a,b/2);
	   res = (res*res)%mod;
	   if(b%2 == 1)
		  res = (res*a)%mod;
	   return res;
 
    }
}
const ll N = 1e6;
ll n,m;
//string s,t;
int s[3000],t[3000];
ll dp[3000][3000]={};
bool vis[3000][3000]={};
ll num_common(ll first, ll second)
{
	//cout<<"euler\n";
	
	if(first == -1 || second == -1)
		{
			//cout<<"first : "<<first<<"  second: "<<second<<"  ans : "<<1<<endl;
			return 1;
		}	
	else if(vis[first][second] == 1)
		{
			//cout<<"first : "<<first<<"  second: "<<second<<"  ans : "<<dp[first][second]<<endl;

			return dp[first][second];
		}

	
	else
	{
		ll ways = 0;
		//if(first-1>=0)
			ways = (ways + num_common(first-1,second))%mod;
		//if(second-1>=0)
			ways = (ways + num_common(first,second-1))%mod;
		//if(second-1>=0 && first-1>=0)
			ways = (ways - num_common(first-1,second-1)+mod)%mod;
		if(s[first] == t[second])
		{
			
				ways = (ways + num_common(first-1,second-1))%mod;
			
		}
		dp[first][second] = ways;
		vis[first][second] = 1;
		//cout<<"first : "<<first<<"  second: "<<second<<"  ans : "<<dp[first][second]<<endl;

		return dp[first][second];
	}
}


 int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	cin>>n>>m;
	
	for(ll i = 0; i<n ; i++)
	{	
		cin>>s[i];

	}
	for(ll j = 0; j<m ; j++)
		cin>>t[j];

	vis[0][0] = 1;
	dp[0][0] = 1;
	if(s[0] == t[0])
		dp[0][0]+=1;

	cout<<num_common(n-1,m-1)<<endl;
	return 0;
	
}


Measured memory_bytes: 55808
// C.

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[])
{
	int n, i;
	cin >> n;
	vector<string> v;
	for (i = 0; i < n; ++i) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		v.push_back(s);
	}
	string ans;
	while (v[0].length()) {
		char c = v[0].front();
		v[0] = v[0].substr(1);
		for (i = 1; i < n; ++i) {
			if (v[i].find(c) == string::npos) {
				break;
			}
		}
		if (i >= n) {
			for (i = 1; i < n; ++i) {
				char d = -1;
				while (d != c) {
					d = v[i].front();
					v[i] = v[i].substr(1);
				}
			}
			ans += c;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>

using std::cout;
using std::endl;
using std::cin;
using std::string;

int main(){
  string s,t;
  cin >> s;
  cin >> t;
  if(s.length()+1==t.length()){
    if(s.substr(0,s.length())==t.substr(0,s.length())){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else{
    cout << "No" << endl;
  }   
}


Measured memory_bytes: 3636
import java.util.Scanner;
public class Main{
 
  public static void main(String[] args){
   
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long x = sc.nextLong();
    long ops = 0;
    long[] candies = new long[n];
    for(int i = 0; i < n; i++){
      candies[i] = sc.nextLong(); 
    }
    for(int i = 0; i < n - 1; i++){
      long diff = (candies[i] + candies[i + 1]) - x;
      if (diff > 0){
        ops += diff;
        if (diff < candies[i + 1]){
         candies[i + 1] -= diff; 
        }
        else{
         candies[i + 1] = 0; 
        }
      }
    }
    System.out.println(ops);
    sc.close();
    
  }
  
}

Measured memory_bytes: 60808
#include<stdio.h>
int main()
{
	long long int w, h, x, y;
	scanf("%lld %lld %lld %lld", &w, &h, &x, &y);
	if (2 * x == w && 2 * y == h)
		printf("%.20lf 1\n", (double)(h * w) / 2);
	else
		printf("%.20lf 0\n", (double)(h * w) / 2);
	return 0;
}

Measured memory_bytes: 128
#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;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  string s,t; cin >> s >> t; string sa,ta;
  ll slong,tlong; slong = s.size(); tlong = t.size();
  vector<char> schar(slong); vector<char> tchar(tlong);
  
  rep(i,slong) schar.at(i) = s.at(i);
  rep(i,tlong) tchar.at(i) = t.at(i);
  
  sort(all(schar)); sort(all(tchar)); reverse(all(tchar));
  
  rep(i,slong) sa += schar.at(i);
  rep(i,tlong) ta += tchar.at(i);
  
  if(sa < ta) cout << "Yes" << endl;
  else cout << "No" << endl;
}
  
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    getline(cin,s);
    int i;
    for(i=0;i<s.length();i++){
        if(s[i]==' '){
            cout<<"A"<<s[i+1]<<"C"<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3632
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

int a[MAXN];
int r[MAXN];
int l[MAXN];

int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    int n = readInt();
    for (int i = 1; i <= n; i++) {
    	a[i] = readInt();	
    }
    	stack <int> s;
	for (int i = 1; i <= n; i++) {
		while (!s.empty() && a[s.top()] >= a[i]) {
			s.pop();
		} if (s.empty()) {
			l[i] = 0;
		} else {
			l[i] = s.top();
		}
		s.push(i);
	}
	stack <int> s1;
	for (int i = n; i >= 1; i--) {
		while (!s1.empty() && a[s1.top()] >= a[i]) {
			s1.pop();
		} if (s1.empty()) {
			r[i] = n + 1;
		} else {
			r[i] = s1.top();
		}
		s1.push(i);
	}
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
	    //cout << l[i] << ' ' << r[i] << endl;
	    int dist1 = abs(l[i] - i);
	    int dist2 = abs(r[i] - i);
		ans += (1ll * dist1 * dist2) * a[i];
	}
	cout << ans;
    return 0;
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
#define W_MAX 1000000001
using namespace std;

long long solve(vector<vector<int>>& dp,vector<vector<bool>>& v,int r,int i,int* wt,int* val,int n)
{
    if(r<=0)
        return 0;
    if(i==n)
        return W_MAX;
    if(v[r][i])
        return dp[r][i];
    v[r][i]=1;
    dp[r][i]=min(solve(dp,v,r,i+1,wt,val,n),wt[i]+solve(dp,v,r-val[i],i+1,wt,val,n));
    
    return dp[r][i];
}
int max_value_with_wt(int v_max,vector<vector<int>>& dp,vector<vector<bool>>& v,int* wt,int* val,int n,int W)
{
    for(int i=v_max;i>=0;i--)
    {
        if(solve(dp,v,i,0,wt,val,n)<=W)
        {
            return i;
        }
    }
    return 0;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,W;
    cin>>n>>W;
    int wt[n],val[n],v_max=0;
    for(int i=0;i<n;i++)
    {
        cin>>wt[i]>>val[i];
        v_max+=val[i];
    }
    vector<vector<int>> dp(v_max+1,vector<int> (n+1,0));
    vector<vector<bool>> v(v_max+1,vector<bool> (n+1,0));
    cout<<max_value_with_wt(v_max,dp,v,wt,val,n,W);
    
    return 0;
}

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

const ll INF = 1LL << 50;
typedef ll Capacity;
struct Edge{
	int src, dst; Capacity cap;
	Edge(int s, int d, Capacity c) : src(s), dst(d), cap(c){}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

struct Dinic{
	int n, s, t;
	vector<int> level, prog, que;
	vector<vector<Capacity> > cap, flow;
	// map<int, Capacity> cap[MAX_V], flow[MAX_V];//MLE,TLEする場合は試す
	vector<vector<int> > g;
	Capacity inf;
	Dinic(){}
	Dinic(const Graph &graph)
		: n(graph.size()),
		cap(n, vector<Capacity>(n)), flow(n, vector<Capacity>(n)),
		g(n, vector<int>()), inf((int)1e9){
		for(int i = 0; i < n; i++){
			for(int j = 0; j < graph[i].size(); j++){
				const Edge& e = graph[i][j];
				int u = e.src, v = e.dst;
				Capacity c = e.cap;
				add_edge(u, v, c);
			}
		}
	}
	Dinic(int n_) : n(n_), cap(n, vector<Capacity>(n)), flow(n, vector<Capacity>(n)),
		g(n, vector<int>()), inf((int)1e9){
	}
	void add_edge(int u, int v, Capacity c){
		cap[u][v] += c; cap[v][u] += c; flow[v][u] += c;
		g[u].push_back(v); g[v].push_back(u);
	}
	void reset(){
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				cap[i][j] = flow[i][j] = 0;
			}
			g[i].clear();
		}
	}
	inline Capacity residue(int u, int v){ return cap[u][v] - flow[u][v]; }
	Capacity solve(int s_, int t_){
		this->t = t_, this->s = s_;
		que.resize(n + 1);
		Capacity res = 0;
		while(levelize()){ prog.assign(n, 0); res += augment(s, inf); }
		return res;
	}
	bool levelize(){
		int l = 0, r = 0;
		level.assign(n, -1); level[s] = 0; que[r++] = s;
		while(l != r){
			int v = que[l++]; if(v == t) break;
			for(int i = 0; i < g[v].size(); i++){
				const int& d = g[v][i];
				if(level[d] == -1 && residue(v, d) != 0){
					level[d] = level[v] + 1; que[r++] = d;
				}
			}
		}
		return level[t] != -1;
	}
	Capacity augment(int v, Capacity lim){
		Capacity res = 0;
		if(v == t) return lim;
		for(int &i = prog[v]; i < (int)g[v].size(); i++){
			const int &d = g[v][i];
			if(residue(v, d) == 0 || level[v] >= level[d]) continue;
			const Capacity aug = augment(d, min(lim, residue(v, d)));
			flow[v][d] += aug; flow[d][v] -= aug;
			res += aug; lim -= aug;
			if(lim == 0) break;
		}
		return res;
	}
};

ll a[100];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

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

	Dinic d(N + 2);
	int S = N, T = S + 1;
	ll sum = 0;
	for(int i = 0; i < N; i++){
		if(a[i] >= 0){
			sum += a[i];
			d.add_edge(S, i, 0);
			d.add_edge(i, T, abs(a[i]));

		}
		else{
			d.add_edge(S, i, abs(a[i]));
			d.add_edge(i, T, 0);
		}
	}
	for(int i = 0; i < N; i++){
		for(int j = i + 1; j < N; j++){
			int x = i + 1, y = j + 1;
			if(y % x == 0){
				//cout << x << " -> " << y << endl;
				d.add_edge(i, j, INF);
			}
		}
	}
	ll sub = d.solve(S, T);
	cout << sum - sub << endl;
}


Measured memory_bytes: 384
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	n = I()
	a_list = LI()
	a_xor = a_list[0]
	for a in a_list[1:]:
		a_xor = a ^ a_xor
	for a in a_list:
		print(a_xor ^ a)



if __name__ == '__main__':
    main()

Measured memory_bytes: 45748
T = int(input())

def check_base(bases, A):
	for n, b in bases:
		if A & (1 << n) != 0:
			A ^= b
	if A == 0:
		return None
	n = 0
	d = 1
	while True:
		if A & d != 0:
			return n, A
		n += 1
		d <<= 1

def append_base(bases, A):
	pair = check_base(bases, A)
	if pair != None:
		bases.append(pair)

def check(N, A_list, S):
	bases = []
	for i in range(N - 1, -1, -1):
		A = A_list[i]
		if S[i] == "0":
			append_base(bases, A)
		else:
			if check_base(bases, A):
				return False
	return True

for i in range(T):
	N = int(input())
	A_list = list(map(int, input().split()))
	S = input().strip()
	
	if check(N, A_list, S):
		print("0")
	else:
		print("1")




Measured memory_bytes: 9168
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;

int main(){
  
  int q, com, x;
  string key;
  map<string, int> M;
  
  cin >> q;
  for(int i = 0;i < q;i++){
    cin >> com;
    
    if(com == 0){
      cin >> key >> x;
      M[key] = x;
    }else if(com == 1){
      cin >> key;
      cout << M[key] << endl;
    }else if(com == 2){
      cin >> key;
      M.erase(key);
    }
  }
  
  return 0;
}


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

#define rep(i,n) for(int (i)=0; (i)<(int)(n); (i)++)
#define all(x) (x).begin(), (x).end()
#define sqr(x) (x)*(x)
#define CEIL(a,b) ((a)+(b)-1) /(b)

typedef long long ll;
const int INF = 1001001001;

void sort_second(vector<pair<ll, ll>> &A, int N); //A:array of pair, N:size of array

int main() {
    string s;
    cin >> s;
    rep(i, s.length()) {
        cout << 'x';
    }
    cout << endl;
    return 0;
}

void sort_second(vector<pair<ll, ll>> &A, int N) {
    rep(i, N) swap(A.at(i).first, A.at(i).second);
    sort(all(A));
    rep(i, N) swap(A.at(i).first, A.at(i).second);
}

Measured memory_bytes: 256
io = STDIN
a,b,c,d=io.gets.chomp.split(//)
def calc(a,b,c,d)
  %w(+ -).each do |op1|
    %w(+ -).each do |op2|
      %w(+ -).each do |op3|
        str = a + op1 + b + op2 + c + op3 + d
        ans = eval str
        return "#{str}=#{ans}" if ans == 7
      end
    end
  end
end
puts calc(a,b,c,d)


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
using namespace std;

int main() {
	string s;
	cin >> s;
	int nl = 0;
	int nr = 0;
	string sl = s;
	string sr = s;
	for (size_t i = 1; i < s.size(); ++i ) {
		if (sl.substr(i,1) == sl.substr(i - 1,1)) {
			int t = (stoi(sl.substr(i,1)) + 1) % 2;
			sl.replace(i, 1, to_string(t));
			++nl;
		}
		if (sr.substr(sr.size() - 1 - i,1) == sr.substr(sr.size() - i,1)) {
			int tr = (stoi(sr.substr(sr.size() - 1 - i,1)) + 1) % 2;
			sr.replace(sr.size() - 1 - i, 1, to_string(tr));
			++nr;
		}
	}
	cout << min(nr, nl) << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main()
{
    int n,m;
    cin>>n>>m;
    cout<<(n-1)*(m-1)<<endl;
}

Measured memory_bytes: 256
while True:
	try:
		[x, y] = map(int, raw_input().split())
		if x < y:
			a = y
			b = x
		else:
			a = x
			b = y
		while a % b:
			c = a % b
			a = b
			b = c
		print "%d %d" % (b, x*y/b)
	except (EOFError):
		break
	

Measured memory_bytes: 4200
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
const int INF = 1e9;
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int N, K; cin >> N >> K;
    vector<Int> A(N); for (auto &a : A) cin >> a;
    vector<Int> S(N + 1); for (int i = 0; i < N; i++) S[i + 1] = S[i] + A[i];
    for (int i = 0; i <= N; i++) S[i] = (S[i] - i % K + K) % K;
    map<int, int> M;
    int j = 0;
    Int ans = 0;
    for (int i = 0; i < N; i++) {
        while (j < N + 1 && j < i + K) {
            M[S[j]] += 1;
            j++;
        }
        M[S[i]] -= 1;
        ans += M[S[i]];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int ar[100005];
int32_t main(){
	int n,ans=0;cin>>n;
	for(int i=1;i<=n;i++){
		cin>>ar[i];
	}
	for(int i=1;i<=n;i++){
		ans+=(i==ar[ar[i]]);
	}
	cout<<ans/2;
}


Measured memory_bytes: 1024
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, C = MAP()
D = [LIST() for _ in range(C)]
c = [LIST() for _ in range(N)]

c_kind = [[0]*(C+1) for _ in range(3)]

cost = [[0]*(C+1) for _ in range(3)]


for i in range(N):
	for j in range(N):
		c_kind[(i+j+2)%3][c[i][j]] = 1


for color in range(1, C+1):
	for i in range(N):
		for j in range(N):
			cost[(i+j+2)%3][color] += D[c[i][j]-1][color-1]

ans = INF
for a, b, c in permutations(range(1, C+1), 3):
	ans = min(ans, cost[0][a]+cost[1][b]+cost[2][c])

print(ans)


Measured memory_bytes: 75712
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//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/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  ll n;
  cin>>n;
  vi ans;
  while(n>0){
    if(n%26==0){
      ans.eb(26);
      n/=26; n--;
    }
    else{
      ans.eb(n%26);
      n/=26;
    }
  }
  reverse(all(ans));
  string s="";
  rep(i,ans.size()){
    s+=ans[i]-1+'a';
  }
  out(s);
}

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


Measured memory_bytes: 3652