akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll x;
    cin >> x;

    if(x == 1) {
        out(1);
        re0;
    }

    ll ans = 0;
    exrep(b, 2, 33) {
        exrep(p, 2, 10) {
            ll y = b;
            rep(i, p-1) {
                y *= b;
            }
            if(y <= x) {
                chmax(ans, y);
            }
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define endl '\n'
using ll=long long;

const int INF=1e9+5;
const int N=1e5+5;
const int mod=1e9+7;
const ll oo=1e18+5;

int n;
vector<int> v[N];

int mul(int a,int b){
	return (ll)a*b%mod;
}

pair<int,int> dfs(int u,int par){
	int all_white=1;
	int some_black=0;
	for(int x:v[u]){
		if(x!=par){
			pair<int,int> p=dfs(x,u);
			// p.first is the ways to color the subtree
			int m_all_white=all_white;
			all_white=mul(all_white,p.second);
			some_black=(mul(m_all_white,p.first)+mul(some_black,p.first+p.second))%mod;
		}
	}
	return make_pair(all_white,(all_white+some_black)%mod);
}

int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
	cin>>n;
	for(int i=1;i<=n-1;++i){
		int x,y;
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(1,-1);
	pair<int,int> p=dfs(1,0);
	int ans=(p.first+p.second)%mod;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 12672
n,m=gets.split(" ").map(&:to_i)
h = Array.new(n+1).map {Array.new(m+1,0)} 

for i in 1..n

a= gets.split.map(&:to_i)
    for j in 1..m
    h[i-1][j-1] = a[j-1]
    h[i-1][m] += a[j-1]
    h[n][j-1] += a[j-1]
    h[n][m] += a[j-1]
    end
end
for i in 0..n
    for j in 0..m
      print " " unless j == 0
      print h[i][j]
    end
    print "\n"
  end



Measured memory_bytes: 7040
#include <algorithm>
#include <cstdio>

const int N = 200050;
const int L = 30;

int n, A[N], B[N];
int S[L][N];

inline bool check(int x, int k) { return ((x >> k) & 1) == 1; }
inline int get(int x, int k) { return k < 0 ? 0 : x & ((1 << k) - 1); }

int SortBit(int *X, int k) {
  static int T[N];
  int t = 0;

  for (int i = 0; i < n; ++i)
    if (!check(X[i], k)) T[t++] = X[i];
  int _tmp = t;
  for (int i = 0; i < n; ++i)
    if (check(X[i], k)) T[t++] = X[i];
  for (int i = 0; i < n; ++i)
    X[i] = T[i];

  return _tmp;
}

int Solve(int k, int *A, int n, int *B, int m, bool opp) {
  int ans = 0, j = m - 1;
  for (int i = 0; i < n; ++i) {
    while (j >= 0 && check(get(A[i], k) + get(B[j], k), k)) --j;
    if (j % 2 == 0) ans ^= 1;
  }
  if (opp && (n % 2 == 1) && (m % 2 == 1)) ans ^= 1;
  return ans;
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &A[i]);
  for (int i = 0; i < n; ++i) scanf("%d", &B[i]);
  
  int ans = 0;
  for (int k = 0; k < 29; ++k) {
    int la = SortBit(A, k), ra = n - la;
    int lb = SortBit(B, k), rb = n - lb;

    ans ^= (Solve(k, A, la, B, lb, true)
          ^ Solve(k, A + la, ra, B, lb, false)
          ^ Solve(k, A, la, B + lb, rb, false)
          ^ Solve(k, A + la, ra, B + lb, rb, true)) << k;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 3456
n, k = map(int, input().split())
a = [int(x) for x in input().split()]

# point = 1
# for i in range(k):
#     point *= a[i]

for i in range(k, n):
    if a[i] > a[i-k]:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 31560
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
int main(void){
  string s;
  cin >> s;
  string ans;
  int i;
  for(i=0;i<(int)(s.length());i++){
   if(s[i] == '0'){
    ans += "0"; 
   }
    if(s[i] == '1'){
     ans += "1"; 
    }
    if(s[i] == 'B'){
      if((int)(ans.length()) != 0) ans.erase(ans.end()-1);
    }
  }
  cout << ans << endl;
return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
#include <stdlib.h>
int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}


int main(void){
  int n;
  scanf("%d", &n);
  int v[n];
  
  for(int i = 0; i < n; i++){
    scanf("%d", &v[i]);
  }
 
  qsort(v, sizeof(v) / sizeof(int), sizeof(int), asc);
  
  double sum = 0;
  for(int i = 0; i < n; i++){
    sum += v[i];
    if(i != 0){
      sum /= 2;
    }
  }
  printf("%f", sum);
  return 0;
}


Measured memory_bytes: 128
X, K, D = map(int, input().split())

times = abs(X) // D

if times >= K:
    print(abs(X) - abs(D * K))
else:
    K -= times
    if K % 2 == 0:
        print(abs(X) - abs(D * times))
    else:
        print(D - (abs(X) - abs(D * times)))

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

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

  int sl = s.length();
  int flag, ans = 0;

  for (int i = sl; i >= sl / 2; i--) {
    for (int j = sl - i; j < i; j++) {
      if (j == sl - i) flag = s[j];
      if (flag != s[j]) break;
      if (j == i - 1) ans = i;
    }
    if (ans != 0) break;
  }

  if (ans == 0) ans = sl / 2;

  cout << ans << endl;


  return 0;

}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10 ** 6)


def input():
    return sys.stdin.readline()[:-1]


def main():
    N = int(input())
    a = [-1]+list(map(int, input().split()))
    b = [0] * (N+1)
    for i in reversed(range(1,N+1)):
        total = 0
        for j in range(i,N+1,i):
            total += b[j]
        if a[i] != (total%2):
            b[i] = 1
    ans = []
    cnt = 0
    for i, n in enumerate(b):
        if n!=0:
            ans.append(i)
            cnt += 1
    print(cnt)
    print(*ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 14124
Module Module1

    Sub Main()

        Dim N As Integer = Console.ReadLine()
        Dim arr As String() = Split(Console.ReadLine())
        Dim x As Integer
        Dim ar(N) As Long
        Dim i As Integer
        Dim kaisu As Integer = 0
        Dim saidai As Integer = 0

        For x = 0 To N - 1
            ar(x) = CLng(arr(x))
        Next

        kaisu = 0
        For x = N - 1 To 1 Step -1
            If ar(x - 1) >= ar(x) Then
                kaisu += 1
            Else
                If saidai < kaisu Then
                    saidai = kaisu
                End If
                kaisu = 0
            End If
            If kaisu > saidai Then
                saidai = kaisu
            End If
        Next

        Console.WriteLine(saidai)

        'Console.ReadLine()

    End Sub

End Module


Measured memory_bytes: 28564
// g++ -std=c++14

//Difficulty according to solve count during contest:
//A B C D H F E I G K L M N P S O Q R J U Z Y X T V W

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

#define int long long
const int mod = 1e9 + 7;

int n, k;
vector<int> a;
vector<vector<int> > dp;
vector<vector<int> > prefix;

int32_t main(){
  cin >> n >> k;
  a.resize(n);
  for(int i = 0; i < n; i++)
    cin >> a[i];
  dp.resize(n, vector<int>(k + 1, 0));
  prefix.resize(n, vector<int>(k + 1, 0));
  for(int j = 0; j <= k; j++){
    if(j >= 0 and j <= a[0])
      dp[0][j] = 1;
      if(j == 0)
        prefix[0][j] = dp[0][j];
      else
        prefix[0][j] = dp[0][j] + prefix[0][j - 1];
      prefix[0][j] %= mod;
  }
  for(int i = 1; i < n; i++){
    for(int j = 0; j <= k; j++){
      dp[i][j] = prefix[i - 1][j];
      if(j - a[i] - 1 >= 0)
        dp[i][j] -= prefix[i - 1][j - a[i] - 1];
      dp[i][j] = (dp[i][j] + mod) % mod;
      if(j == 0)
        prefix[i][j] = dp[i][j];
      else
        prefix[i][j] = prefix[i][j - 1] + dp[i][j];
      prefix[i][j] %= mod;
    }
  }
  cout << dp[n - 1][k] << endl;
}


Measured memory_bytes: 160376
#include <cstdio>
#include <algorithm>
using namespace std;

int w, h, c[50][52];

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

void dfs(int x, int y){
    c[x][y] = 0;
    for(int z = 0; z < 8; z++){
        int nx = x + dx[z], ny = y + dy[z];
        if( 0 <= nx && nx < h && 0 <= ny && ny < w &&
            c[nx][ny] ){
            dfs(nx, ny);
        }
    }
}

int main(){
    for(; scanf("%d%d", &w, &h), w||h;){
        for(int x = 0; x < h; x++){
            for(int y = 0; y < w; y++){
                scanf("%d", &c[x][y]);
            }
        }
        int ans = 0;
        for(int x = 0; x < h; x++){
            for(int y = 0; y < w; y++){
                if( c[x][y] ){
                    ++ans;
                    dfs(x, y);
                }
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 1104
# include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b, n = 0, c, d, e, f;
    cin >> a >> b;
    for (int i = a; i <= b; i++)
    {
        c = i / 10000;
        d = i % 10;
        e = (i / 10) % 10;
        f = (i / 1000) % 10;
        if (c == d && e == f) n++;
    }
    cout << n;
}

Measured memory_bytes: 3564
#include<iostream>
using namespace std;
int  main()
{int n,i,a;
     cin>>n;
   int  arr[n+1]={0};
     for(i=1;i<n;i++)
     {
          cin>>a;
          arr[a]++;
     }
      for(i=1;i<=n;i++)
          cout<<arr[i]<<endl;
      return 0;
}


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

typedef long long int ll;

ll dp[401][401];
ll a[401];

void solve(ll n, ll m)
{
    if(dp[n][m]!=-1)
    {
        return;
    }
    dp[n][m]=LONG_LONG_MAX;
    
    ll sum=0;
    if(n==m)
    {
        dp[n][m]=0;
        return;
    }
    for(int i=n; i<=m; i++)
    {
        sum+=a[i];
    }
    
    for(int i=n; i<m; i++)
    {
        solve(n, i);
        solve(i+1, m);
        dp[n][m]=min(dp[n][m], dp[n][i]+dp[i+1][m]+sum);
    }
}

int main()
{
    ll n;
    cin >> n;
    for(int i=0; i<n; i++)
    {
        cin >> a[i];
    }
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            dp[i][j]=-1;
        }
    }
    solve(0, n-1);
    cout << dp[0][n-1];
}

Measured memory_bytes: 4884
import java.util.*;
public 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();
		int D = sc.nextInt();
 
		int train = Math.min(A, B);
		int bus = Math.min(C, D);
 
			System.out.println(train + bus);
	}
}

Measured memory_bytes: 23252
# coding: utf-8

class Circles
  def solve
    n = gets.chomp.to_i
    n.times do
      xa, ya, ra, xb, yb, rb =
        gets.chomp.split.map{|s| s.to_f}

      d = Math::sqrt((xa - xb) ** 2 + (ya - yb) ** 2)

      if d < ra - rb then
        puts 2
      elsif d < rb - ra then
        puts -2
      elsif d > ra + rb then
        puts 0
      else
        puts 1
      end
    end
  end
end

Circles.new.solve

Measured memory_bytes: 6144
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <string>
using namespace std;

bool isSameColor(string a){
	char b=a[0];
	int s=a.size();
	
	for(int i=0; i<s; ++i){
		if(a[i]!=b) return false;
	}
	
	return true;	
}

int main(){
	string s;
	while(cin>>s){
		if(s=="0") break;
		
		queue<string> que;
		map<string, long> mp;
		
		que.push(s);
		mp[s]=0;	
		
		bool found=false;
		while(!que.empty()){
			string v=que.front();
			que.pop();
			
			int size=v.size();
			for(int i=0; i<size-1; ++i){
				string tmp=v;
				
				if((tmp[i]=='r'&&tmp[i+1]=='g') || (tmp[i]=='g'&&tmp[i+1]=='r')) tmp[i]=tmp[i+1]='b';
				else if((tmp[i]=='r'&&tmp[i+1]=='b') || (tmp[i]=='b'&&tmp[i+1]=='r')) tmp[i]=tmp[i+1]='g';
				else if((tmp[i]=='b'&&tmp[i+1]=='g') || (tmp[i]=='g'&&tmp[i+1]=='b')) tmp[i]=tmp[i+1]='r';
				
				if(mp.find(tmp) == mp.end()){
					que.push(tmp);
					mp[tmp]=mp[v]+1;	
				}
				
				if(isSameColor(tmp)){
					cout << mp[tmp] << endl;	
					found=true;
					break;
				}	
			}	
			
			if(found) break;
		}
		
		if(!found) printf("NA\n");
		
	}
}

Measured memory_bytes: 2652
#include <cstdio>
    int main()
    {
    	char a,b,c,d,e,f;
    	scanf("%c%c%c %c%c%c",&a,&b,&c,&d,&e,&f);
    	if(a==f&&b==e&&c==d)
    	{
    		printf("YES");
    	}
    	else
    	{
    		printf("NO");
    	}
    }

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    vector<vector<int>> V(9,vector<int>(9,0));
    rep(i,1,10){
        rep(j,1,10){
            rep(k,1,7){
                if(i!=j && k==1) continue;
                if(k==1){
                    if(i<=N) V.at(i-1).at(j-1)++;
                    continue;
                }

                int n=i*pow(10,k-1)+j;
                rep(l,0,pow(10,k-2)){
                    int _n=n+10*l;
                    if(_n<=N) V.at(i-1).at(j-1)++;
                }
            }
        }
    }

    int64_t ans=0;
    rep(i,0,9)rep(j,0,9){
        ans+=V.at(i).at(j)*V.at(j).at(i);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 384
#単純な全探索-->TLE-->Cの配列を扱うときに工夫
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

lst = []
for i in A:
    for j in B:
        lst += [i + j]

lst.sort(reverse = True)
C.sort(reverse = True)

ans = []
for i in range(min(K, len(lst))):
    for j in range(min(K, len(C))):
        ans += [lst[i]+C[j]]

ans.sort(reverse = True)
for i in range(K):
    print (ans[i])


Measured memory_bytes: 150048
/*
ID: vamaddu1
LANG: C++11
TASK: cowfood
*/

#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <deque>
#include <string.h>
#include <sstream>
#include <bitset>
#include <math.h>
#include <assert.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
template <class T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
template <class T>
using ordered_multiset = __gnu_pbds::tree<T, __gnu_pbds::null_type, less_equal<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

#define PI atan2(0, -1)
#define epsilon 1e-9
#define INF 5000000000000000000
#define MOD 1000000007

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

int N;
pair<pair<int, int>, long long> arr [1010];
long long dp [10000010];

bool cmp(pair<pair<int, int>, long long> a, pair<pair<int, int>, long long> b){ return a.f.f+a.f.s < b.f.f+b.f.s; }

int main(){
    //freopen("sort.in", "r", stdin); freopen("sort.out", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10);
    cin >> N;
    for(int i = 0; i < N; i++) cin >> arr[i].f.f >> arr[i].f.s >> arr[i].s;
    sort(arr, arr+N, cmp);
    for(int i = 0; i < N; i++)
        for(int j = min(10000000-arr[i].f.f, arr[i].f.s); j > -1; j--)
            dp[j+arr[i].f.f] = max(dp[j+arr[i].f.f], dp[j]+arr[i].s);
    cout << *max_element(dp, dp+10000010) << '\n';
    return 0;
}

/******************************
Kateba ii dake no hanashi darou
Success is only a victory away
- No Game No Life Opening
******************************/


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string ans = "No";
    for (int i = 1; i < 10; ++i) {
        if (N%i == 0 && N/i < 10) {
            ans = "Yes";
            break;
        }
    }
    puts(ans.c_str());
    return 0;
}


Measured memory_bytes: 256
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll a,b,k;
	cin>>a>>b;
	a = a+b;
	if(a%2){
			cout<<"IMPOSSIBLE";
		return 0;		
	}
	cout<<a/2;
	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int kazu,sum,i,j,count;
  
  while(1){
    scanf("%d",&kazu);
    if(kazu==0)break;
    count=0;
    for(i=1;i<=1000;i++){
      sum=0;
      j=0;
      j=i;
      while(sum<kazu){
	sum+=j;
	if(sum==kazu && j!=kazu){count++;break;}
	j++;
      }
    }
    printf("%d\n",count);
  }
  
    
  return 0;
  
}

Measured memory_bytes: 600
from math import gcd

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

# 解説AC(a*loga)
ans = 0
cnt = [0] * (max(a) + 1)
for ai in a:
    ans = gcd(ans, ai)
    cnt[ai] += 1

if ans != 1:
    print('not coprime')
elif any(sum(cnt[i::i]) > 1 for i in range(2, max(a) + 1)):
    print('setwise coprime')
else:
    print('pairwise coprime')


Measured memory_bytes: 132708
#include <iostream>
#include <algorithm>
#include <vector>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


ll com[53][53] = {};

int main(void) {
	int n, a, b, i, j, k1, k2, lim;
	ll v[53], dv[53], pt;
	double amax;

	scanf("%d%d%d", &n, &a, &b);
	for (i = 0; i < n; i++) {
		scanf("%lld", &v[i]);
		dv[i] = v[i];
	}

	sort(v, v + n, greater<ll>());
	sort(dv, dv + n);

	amax = 0.0;
	for (i = 0; i < a; i++) {
		amax += v[i];
	}

	printf("%.12lf\n", amax / a);

	for (i = 0; i <= n; i++) for (j = 0; j <= i; j++) {
		if (j == 0 || j == i) {
			com[i][j] = 1;
		}
		else {
			com[i][j] = com[i - 1][j - 1] + com[i - 1][j];
		}
	}

	k1 = dv + n - upper_bound(dv, dv + n, v[a - 1]);
	k2 = dv + n - lower_bound(dv, dv + n, v[a - 1]);

	lim = min(b, k2);

	if (amax / a > (double)v[a - 1]) {
		pt = com[k2 - k1][a - k1];
	}
	else {
		pt = 0;
		for (i = a - k1; i <= lim - k1; i++) {
			pt += com[k2 - k1][i];
		}
	}

	printf("%lld\n", pt);

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
	string str;
	bool flag = true;
	int i,cnt = 0;
	vector<int> subRec;
	cin>>str;
	if(str[0] != 'A') flag = false;
	for(i=2;i<str.length()-1;i++) if(str.at(i)=='C')
	{
		cnt++;
		subRec.push_back(i);
	}
	if(cnt!=1) flag = false;
	if(str[1]>='A'&&str[1]<='Z') flag = false;
	if(str[str.length()-1]>='A'&&str[str.length()-1]<='Z') flag = false;
	for(i=2;i<str.length()-1;i++) if(str.at(i)>='A'&&str.at(i)<='Z'&&str.at(i)!='C') flag = false;
	if(flag) cout<<"AC";
	else cout<<"WA";
	return 0;
}


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

int main()
{
	int N, K;
	scanf("%d%d", &N, &K);
	std::vector<int> a(N);
	for (auto& e: a) scanf("%d", &e);
	std::vector<int64_t> sum;
	sum.reserve(N * (N + 1) / 2);
	for (int i{}; i < N; i++)
	{
		int64_t tmp{};
		for (int j{i}; j < N; j++)
		{
			tmp += a[j];
			sum.push_back(tmp);
		}
	}
	int64_t ans{};
	for (int digit{40}; digit >= 0; digit--)
	{
		std::sort(sum.rbegin(), sum.rend());
		int left{-1}, right{(int)sum.size()};
		while (right - left > 1)
		{
			int mid{(right + left) / 2};
			if (sum[mid] >= (1ll << digit)) left = mid;
			else right = mid;
		}
		if (right >= K)
		{
			while (sum.back() < (1ll << digit)) sum.pop_back();
			ans += (1ll << digit);
		}
		for (auto& e: sum) e = e & (-1 ^ (1ll << digit));
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

vector<int> diff(const vector<int>& a, const vector<int>& b)
{
    vector<int> res(10);
    for (int i = 1; i <= 9; i++) {
        res[i] = a[i] - b[i];
    }
    return res;
}

bool check_diff(const vector<int>& a, const vector<int>& b)
{
    for (int i = 1; i <= 9; i++) {
        if (a[i] < b[i]) return 0;
    }
    return 1;
}

map<vector<int>, int> mem;
vector<vector<int>> pat;

int sum(const vector<int>& p)
{
    int res = 0;
    for (int i = 1; i <= 9; i++) {
        res += p[i] * i;
    }
    return res;
}

void make_pattern(int n, const vector<int>& p)
{
    if (n == 10) {
        if (sum(p) == 10) {
            pat.emplace_back(p);
        }
        return;
    }
    for (int i = 0; i <= 10 / n; i++) {
        vector<int> np = p;
        np[n] += i;
        make_pattern(n + 1, np);
    }
}

int solve(const vector<int>& m_cnt)
{
    int res = 0;
    if (mem.count(m_cnt) != 0) {
        return mem[m_cnt];
    }

    for (const auto& p : pat) {
        if (check_diff(m_cnt, p)) {
            res = max(res, solve(diff(m_cnt, p)) + 1);
        }
    }
    return mem[m_cnt] = res;
}

int main()
{
    int N;
    make_pattern(1, vector<int>(10));
    while (cin >> N, N > 0) {
        vector<int> m_cnt(10);
        for (int i = 0; i < N; i++) {
            int m;
            cin >> m;
            m_cnt[m]++;
        }

        int res = 0;
        for (int i = 1; i <= 5; i++) {
            int mini = min(m_cnt[i], m_cnt[10 - i]); 
            if (i == 5) mini /= 2;
            res += mini;
            m_cnt[i] -= mini;
            m_cnt[10 - i] -= mini;
        }
        mem.clear();
        res += solve(m_cnt);
        cout << res << endl;
    }        
    return 0;
}

Measured memory_bytes: 9620
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main()
{
	string str;
	getline(cin, str);
	
	for (char &c : str) {
		if (isalpha(c)) c = isupper(c) ? tolower(c) : toupper(c);
		cout << c;
	}
	cout << endl;
}

Measured memory_bytes: 3156
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var nm = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            var n = nm[0];
            var m = nm[1];

            var count = 0;

            count += n * (n - 1);
            count += m * (m - 1);

            Console.WriteLine(count / 2);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision


#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

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

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

	vector<int> p(n), q(n), loop(n);
	rep(i, n) cin >> p[i];
	rep(i, n) cin >> q[i];
	rep(i, n) loop[i] = i + 1;
	int i = 0, pi = 0, qi = 0;
	do {
        i++;
		bool pok = true, qok = true;
		rep(i, n) {
			pok &= p[i] == loop[i];
			qok &= q[i] == loop[i];
		}
        if (pok) pi = i;
        if (qok) qi = i;
	} while (next_permutation(loop.begin(), loop.end()));

		cout << abs(pi - qi) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define ull unsigned long long int
#define boost ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0)
#define vi vector<int>
#define P push_back
#define F first
#define S second
#define debug(x) cout<<x<<" "
#define pi vector<pair<int,int> >
#define FOR(i,x,n) for(int i=x;i<n;i++)
#define all(a) a.begin(),a.end()
ll mod=1e9+7;
#define N 99999999
//#define int ll
using namespace std;
#define int ll
signed main(){
    boost;
	int a;
    cin>>a;
    string s;
    cin>>s;
    if(a>=3200)cout<<s;
    else cout<<"red";

    return 0;
}

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

int main(){
    int n,ans=1;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0;i < n;i ++){
        cin >> a[i];
    }
    int state=0;
    if(a[1]>a[0]) state=1;
    else if(a[1]<a[0]) state=-1;
    for(int i = 2;i < n;i ++){
        if(a[i]-a[i-1]>0){
            if(state==0) state=1;
            else if(state==-1){ans ++;state=0;}
        }
        if(a[i]-a[i-1]<0){
            if(state==0) state=-1;
            else if(state==1){ans ++;state=0;}
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func next() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func main() {
	scanner.Split(bufio.ScanWords)

	a := nextInt()
	op := next()
	b := nextInt()

	switch op {
	case "+":
		fmt.Println(a + b)
		return
	case "-":
		fmt.Println(a - b)
		return
	}
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(x) cout << x << endl;

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

    string ans = "Yes";
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'U' || s[i] == 'D') continue;
        if((i + 1) % 2 == 0 && s[i] == 'L') continue;
        if((i + 1) % 2 != 0 && s[i] == 'R') continue;
        ans = "No";
        break;
    }
    OP(ans);
}


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

int n, m;
int a[50][1000];

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

	while (n != 0 && m != 0) {
		int t = 0;

		for (int i = 0; i < m; i++)
			for (int j = 0; j < n; j++)
				cin >> a[i][j];

		for (int j = 0; j < n; j++) {
			int s = 0;

			for (int i = 0; i < m; i++)
				s += a[i][j];

			t = max(t, s);
		}
		cout << t << endl;

		cin >> n >> m;
	}

	return 0;
}


Measured memory_bytes: 3212
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;

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

    int n;
    cin >> n;
    vector<pair<int, int>> in(n);
    for (int i = 0; i < n; i++) {
        cin >> in[i].first >> in[i].second;
    }

    vector<pair<int, int>> w(n);
    for (int i = 0; i < n; i++) {
        int x = in[i].first, l = in[i].second;

        w[i].first = x + l;
        w[i].second = x - l;
    }
    sort(w.begin(), w.end());

    int ans = 0;
    int cur = -1100000000;
    for (int i = 0; i < n; i++) {
        if (cur <= w[i].second) {
            ans++;
            cur = w[i].first;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	s := scanString()

	if s[0] != s[1] || s[1] != s[2] || s[2] != s[0] {
		fmt.Fprintln(wr, "Yes")
	} else {
		fmt.Fprintln(wr, "No")
	}
}


Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

void Solve(string s, vector<int> &xNums, string &seps)
{
	int xNum = 0;
	for (const char ch : s)
	{
		if (ch == 'x')
		{
			++xNum;
		}
		else
		{
			xNums.push_back(xNum);
			seps.push_back(ch);
			xNum = 0;
		}
	}
	xNums.push_back(xNum);
}

int main()
{
	string s; cin >> s;
	int l = 0, r = s.length() - 1;
	int ans = 0;
	while (l < r)
	{
		if (s[l] == s[r])
		{
			// 文字が等しいとき，操作せず内側へ進む
			++l; --r;
		}
		else if (s[l] == 'x')
		{
			// 先頭だけがｘのとき，末尾にｘを加えて進む
			++l;
			++ans;
		}
		else if (s[r] == 'x')
		{
			// 末尾だけがｘのとき，先頭にｘを加えて進む
			--r;
			++ans;
		}
		else
		{
			// 互いにｘ以外の文字で異なるとき，回分にはならない
			ans = -1;
			break;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;

int main() {
  int N, M;
  cin >> N >> M;
  auto A = priority_queue<int, vector<int>>();
  REP(i, N) {
    int n;
    cin >> n;
    A.push(n);
  }
  REP(i, M) {
    int max = A.top();
    A.pop();
    A.push(max / 2);
  }

  ll ans = 0;
  while(!A.empty()) {
    int temp = A.top();
    A.pop();
    ans += temp;
  }

  cout << ans << endl;
}


Measured memory_bytes: 892
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		String t = scan.next();
		char[] cs = new char[s.length()];
		for (int i = 0; i < s.length(); i++) {
			cs[i] = s.charAt(i);
		}
		boolean f = false;
		for (int i = 0; i < s.length(); i++) {
			String u = new String(cs);
			if (t.equals(u)) {
				f = true;
			}
			char a = cs[s.length()-1];
          	char[] cu = new char[s.length()];
			for (int j = 0; j < s.length()-1; j++) {
				cu[j+1] = cs[j]; 
			}
			cu[0] = a;
			cs = cu;
		}
		if (f) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define r_0 return 0
#define ld long double
#define TIME ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
    const ll N = 1e5 + 7;///
ll n , k ,mn = 1e18;
void solve(){
    cin >> n >> k;
    if(n % k == 0){
        cout << 0;
    }
    else{
        if(n < k){
            cout << min(abs(n - k) , abs(abs(n - k) - k));
        }
        else{
            cout << min(abs((n % k) - k) ,n % k);
        }
    }
}
int main(){
    TIME
    int tt = 1;
    //cin >> tt;
    while(tt --){
        solve();
    }
}
/**

**/


Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
res = b[a[0]-1]
for i in range(1,n):
  #print(i,res,a[i])
  res += b[a[i]-1]
  if a[i-1] + 1 == a[i]:
    res += c[a[i-1]-1]
print(res)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  map<int,int> memo;
  memo[1] = 1;
  rep(i,N){
    map<int,int> tmp;
    FOR(it,memo){
      int v = it->first;
      tmp[2*v] = 1;
      tmp[v+K] = 1;
    }
    memo = tmp;
  }

  int ret = 100000000;
  FOR(it,memo){
    ret = min(ret, it->first);
  }

  cout << ret << endl;
  
  return 0;
}


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

int Narry[10001] = {0};

int main(){
  int N,A,B,C,X;

  while(cin >>N>>A>>B>>C>>X){
    if(N == 0 and A == 0 and B == 0 and C == 0 and X == 0)break;
    int ans = -1,ind = 0;
    for(int i = 0; i < N ; i++){
      cin >>Narry[i];
    }

    int randnum = X;
    while(ind <= N-1){
      ans++;
      if(randnum == Narry[ind])ind++;
      if(ans > 10000){
        ans = -1;
        break;
      }
      randnum = (A*randnum + B)%C;
    }
    cout <<ans<<endl;
  }

  return 0;
}



Measured memory_bytes: 2996
/**
 *    author:   abdullahkhilji.github.io
 *    created:  27.04.19
**/
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
int main()
{
    std::ios::sync_with_stdio(false);
    int T,i;
    cin>>T;
    int n = T;
    // cin.ignore(); must be there when using getline(cin, s)
    int v[n], c[n], sum[n];
    mem(sum, 0);

    for (i = 0; i < n; ++i) {
        cin>>v[i];
        sum[i]+=v[i];
    }
    for (i = 0; i < n; ++i) {
        cin>>c[i];
        sum[i]-=c[i];
    }

    int final_sum=0;
    for (i = 0; i < n; ++i) {
        if(sum[i]>0){
            final_sum+=sum[i];
        }
    }
    
    cout<<final_sum;

    return 0;
}


Measured memory_bytes: 256
n = input()
length = len(n)
ans = 10

#2桁,1桁混合
lst = []
ind = 0
while ind < length:
  if n[ind] == "1" and ind + 1 <= length - 1:
    lst.append(int(n[ind:ind + 2]))
    ind += 2
  else:
    lst.append(int(n[ind]))
    ind += 1
if len(lst) >= 2:
  ans = min(ans, max(lst) - min(lst))

#n桁のみ
divisors = []
for i in range(1, length // 2 + 1):
  if length % i == 0:
    divisors.append(i)

for i in divisors:
  lst = []
  for j in range(0, length, i):
    lst.append(int(n[j:j + i]))
  ans = min(ans, max(lst) - min(lst))

print(ans)


Measured memory_bytes: 7120
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 1e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};


int main() {
    ll a;
    double b; 
    cin >> a >> b;
    ll ib = b*100+0.5;
    a *= ib;
    cout << a/100 << endl;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main()
{
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h + 2; i++) {
        for (int j = 0; j < w + 2; j++) {
            if (i == 0 || i == h + 1 || j == 0 || j == w + 1) {
                cout << "#";
            } else {
                char c;
                cin >> c;
                cout << c;
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
	int ans = 0;
    for (int i=0;(i+3) <= N;i++){
//      System.out.println("i" + i);
//      System.out.println(S.substring(i,(i+3)));
      if(S.substring(i,(i+3)).equals("ABC")){
        ans++;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22100
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    fori (i, 0, n) cin >> a[i];
    int all = 0;
    for (int i = 0; i < n; i += 2) {
        all ^= a[i] ^ a[i + 1];
    }
    fori (i, 0, n) {
        int mine = all ^ a[i];
        cout << mine << " ";
    }
    cout << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
        solve();
    return 0;
}



Measured memory_bytes: 4044
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        SemiCommonMultiple solver = new SemiCommonMultiple();
        solver.solve(1, in, out);
        out.close();
    }

    static class SemiCommonMultiple {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long m = in.nextLong();

            long x = Long.parseLong(in.next()) / 2;
            long div_num = divNum(x);

            for (int i = 1; i < n; i++) {
                long a = Long.parseLong(in.next()) / 2;
                x = lcm(x, a);

                long dnum = divNum(a);
                if (div_num != dnum) {
                    out.print(0);
                    return;
                }
            }
            if (m < x) {
                out.print(0);
                return;
            }

            long p = 0;
            while (1 <= x * (2 * p + 1) && x * (2 * p + 1) <= m) {
                p++;
            }
            out.print(p);
        }

        static long divNum(long a) {
            long num = 0;
            while (a % 2 == 0) {
                num++;
                a /= 2;
            }
            return num;
        }

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

        static long gcd(long a, long b) {
            return b == 0 ? a : gcd(b, a % b);
        }

    }
}



Measured memory_bytes: 59432
/*
 *
 */
#include <cstdio>
#include <iostream>

#define DEBUG 0

using namespace std;

int a[105];

int main(){
    //freopen("c4.in", "r", stdin);

    int n;
    cin >> n;
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    int avg = sum / n;

    // answer is either avg or avg+1
    int ans1 = 0;
    int ans2 = 0;
    for (int i = 0; i < n; ++i) {
        ans1 += (a[i] - avg) * (a[i] - avg);
        ans2 += (a[i] - avg - 1) * (a[i] - avg - 1);
    }

    cout << min(ans1, ans2) << endl;

    return 0;
}


Measured memory_bytes: 384
"use strict";
const Main = (input) =>{
   let xs = input.trim().split('\n');
   let xs1 = xs[1].trim().split(' ');
   let N = xs[0];
   let S = xs1[0].trim().split('');
   let T = xs1[1].trim().split('');
   let ans = [];
   for(let i=0; i<N; i++){
      ans.push(S[i]+T[i]);
   }
   let ans1 = '';
   for(let i=0; i<N; i++){
      ans1+=ans[i];
   }
   console.log(ans1);
   
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 21064
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#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 REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

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 MOD = 1000099253;
const int MOD2 = 1000311461;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 100010;



int like[100010];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N; cin >> N;
	REP(i, N) {
		cin >> like[i];
		like[i]--;
	}
	int ans = 0;
	REP(i, N) {
		if (i == like[like[i]])ans++;
	}
	print(ans/2);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
    using namespace std;
    #define inp(k)           ll k;cin>>k;
    #define in2(n,k)       ll n, k; cin>>n;cin>>k;
    #define in3(n,k,r)       ll n, k,r; cin>>n;cin>>k;cin>>r;
    #define ll long long
    #define dl double
    #define ch char
    #define f(i,a,b) for(ll i=a;i<b;i++)
    #define rf(i,a,b) for(ll i=a-1;i>=b;i--)
    #define Godspeed                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define vpl vector< pair<ll,ll> >
    #define vpi vector< pair<int,int> >
    #define vi vector<int>
    #define vl vector<ll>
    #define vdl vector<dl>
    #define vch vector<char>
    #define pll pair<ll,ll>
    #define pb push_back
    #define mp make_pair
    #define fr first
    #define se second
    #define PI 3.14159265

    void solve()
    {
        string s,t;cin>>s>>t;ll c=0;
      f(i,0,s.length())
      {
       	if(s[i]!=t[i])c++; 
      }
      cout<<c;
    }


    int32_t main(void)
    {
        Godspeed;
        int q;
        q=1;
        //cin >> q;
        while (q--)
        {
            solve();cout<<endl;
        }
        return 0;
    }


Measured memory_bytes: 3888
while True :
    n = int(input())
    if n == 0 :
        break
    
    S = 1
    for i in range(n) :
        S *= (i+1)
    
    ans = 0
    while True :
        if S % 5 != 0 :
            break
        else :
            S = S // 5
            ans += 1
    print(ans)
        


Measured memory_bytes: 5628
package main

import (
	"fmt"
)

func main() {
	var h int
	fmt.Scan(&h)

	sum := 1
	k := 1
	for {
		h = h / 2
		if h == 0 {
			break
		}
		k *= 2
		sum += k
	}

	fmt.Println(sum)
}


Measured memory_bytes: 1768
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<int> b(n - 1);
    for (auto &e : b) std::cin >> e;
    int ret = b.front() + b.back();
    for (int i = 1; i < n - 1; i++) ret += std::min(b[i], b[i - 1]);
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

int main() {
     string taroCard, hanakoCard;;
     int count, taroScore = 0, hanakoScore = 0;
     cin >> count;

     for (int i = 0; i < count; i++) {
         cin >> taroCard >> hanakoCard;
         if (taroCard > hanakoCard) {
             taroScore += 3;
         } else if (taroCard == hanakoCard) {
             taroScore += 1;
             hanakoScore += 1;
         } else {
             hanakoScore += 3;
         }
     }

     printf("%d %d\n", taroScore, hanakoScore);
}

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

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int x = gcd(a,b);
  if(c%x == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256