akhauriyash/Code-Regression huggingface dataset:
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from functools import *
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def Golf():
    *a,=map(int,open(0))
def S_():
    return input()
def IS():
    return input().split()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['YES','NO']

mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()
 
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0

h,n=LI()
a=[]
b=[]
for i in range(n):
    x,y=LI()
    a+=[x]
    b+=[y]

dp=[0]+[inf]*h

for i in range(n):
    for j in range(h+1):
        dp[min(h,j+a[i])]=min(dp[j]+b[i],dp[min(h,j+a[i])])

ans=dp[h]

print(ans)


Measured memory_bytes: 51032
N,K=map(int,input().split())
lis=list(map(int,input().split()))
ans=0
anlis=[0]*N
for i in range(K):
  a,b=map(int,input().split())
  if lis[a-1]>lis[b-1]:
    anlis[b-1]=1
  elif lis[b-1]>lis[a-1]:
    anlis[a-1]=1
  else:
    anlis[a-1]=1
    anlis[b-1]=1
for i in range(N):
  if anlis[i]==0:
    ans+=1
print(ans)

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

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

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

    vector<ll> A(N);
    REP(i,N){
        cin >> A[i];
    }

    //偶数番目を正
    ll ansA = 0;
    ll sumA = 0;
    REP(i,N){
        sumA += A[i];
        if(i%2 == 0){//偶数番目を正に
            if (sumA <= 0){
                ansA += (abs(sumA) + 1);
                sumA += (abs(sumA) + 1);
            }
        }
        else{//奇数番目を負に
            if (sumA >= 0){
                ansA += (abs(sumA) + 1);
                sumA -= (abs(sumA) + 1);
            }
        }
    }

    //奇数番目を正
    ll ansB = 0;
    ll sumB = 0;
    REP(i,N){
        sumB += A[i];
        if(i%2 != 0){//奇数番目を正に
            if (sumB <= 0){
                ansB += (abs(sumB) + 1);
                sumB += (abs(sumB) + 1);
            }
        }
        else{//偶数番目を負に
            if (sumB >= 0){
                ansB += (abs(sumB) + 1);
                sumB -= (abs(sumB) + 1);
            }
        }
    }

    cout << min(ansA,ansB) << endl;

    return 0;
}


Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define cans cout << ans << endl
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
typedef long long ll;


int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    vector<int> even(100001),odd(100001);
    rep(i,n){
        if(i%2){
            odd[v[i]]++;
        }
        else{
            even[v[i]]++;
        }
    }
    int o1 = -1,ok1=-1;
    int o2 = -1,ok2=-1;
    int e1 = -1,ek1=-1;
    int e2 = -1,ek2=-1;
    for(int i=1; i<=100000; i++){
        if(o1 <= odd[i]){
            o2 = o1;
            ok2 = ok1;
            o1 = odd[i];
            ok1 = i;
        }else if(o2<=odd[i] && odd[i]<o1){
            o2 = odd[i];
            ok2 = i;
        }
        if(e1 <= even[i]){
            e2 = e1;
            ek2 = ek1;
            e1 = even[i];
            ek1 = i;
        }else if(e2<=even[i] && even[i]<e1){
            e2 = even[i];
            ek2 = i;
        }
    }
    if(ok1 != ek1){
        cout << n-o1-e1 << endl;
    }
    else if(ok1 == ek1){
        cout << min(n-o1-e2,n-o2-e1) << endl;
    }
    return 0;
}

Measured memory_bytes: 4596
def RA():
    return list(map(int, input().split()))

def solve():
    n = int(input())
    bestEnding = RA()
    for i in range(n - 1):
        a = RA()
        newBestEnding = [
            max(bestEnding[1], bestEnding[2]) + a[0],
            max(bestEnding[0], bestEnding[2]) + a[1],
            max(bestEnding[0], bestEnding[1]) + a[2]
        ]
        bestEnding = newBestEnding
    print(max(bestEnding))


solve()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;

int main() {
  int n, m;
  while (cin >> n >> m, m) {
    int sn[n], sm[m], sun = 0, sum = 0, a;
    rep(i, n) {
      cin >> sn[i];
      sun += sn[i];
    }
    rep(i, m) {
      cin >> sm[i];
      sum += sm[i];
    }
    sort(sn, sn + n);
    sort(sm, sm + m);
    a = sun - sum;
    rep(i, n) rep(j, m) if (sun + sm[j] - sn[i] == sum + sn[i] - sm[j]) {
      cout << sn[i] << ' ' << sm[j] << endl;
      goto end;
    }
    cout << -1 << endl;
  end:;
  }
  return 0;
}

Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;

    for (int i = 1; i <= n; i++)
    {
        int idx = i;
        if(i%3 == 0){
            cout << " " << i;
            continue;
        }
        while (idx)
        {
            if(idx%10 == 3){
                cout << " " << i;
                break;
            }
            idx /= 10;
        }
    }
        cout << endl;
    
  
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <math.h>
#include <algorithm>
#include <deque>
#include <climits>

using namespace std;
#define ll long long
#define ve vector
#define umap unordered_map

const int MxN=1e5;
int a[MxN];

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

Measured memory_bytes: 640
# -*- coding: utf-8 -*-

N = int(input())
S = input()

# 全探索だと2^Nで無理

# WWWW...BBBB...となるように変える。(全てW、全てBもOK)
# W: .
# B: #

W = [0] * N
B = [0] * N

if S[0] == ".":
    W[0] = 1
else:
    B[0] = 1

for i in range(1, N):
    if S[i] == ".":
        W[i] = W[i-1]+1
        B[i] = B[i-1]
    else:
        W[i] = W[i-1]
        B[i] = B[i-1]+1

# i-1までをWに、iからをBに変えるとする
# W[i-1]で、i-1までのWの個数が分かる(Wi-1)
# この時、i-(Wi-1)個のBをWに変える必要がある
# W[-1] - W[i-1]で、Bに変える必要のあるWの個数が分かる

mn = min(W[-1], B[-1]) # 全部B, 全部Wに変える場合を計算
for i in range(1, N):
    toW = i - W[i-1]
    toB = W[-1] - W[i-1]
    mn = min(mn, toB+toW)
print(mn)


Measured memory_bytes: 12808
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

#include <inttypes.h>
using namespace std;

int main()
{
	int32_t N;
	scanf("%d", &N);

	vector<pair<int64_t, int32_t>> graph[100000];
	for (int32_t i = 0; i < N - 1; i++) {
		int32_t a, b;
		int64_t c;
		scanf("%d%d%" PRId64, &a, &b, &c);
		a--;
		b--;
		graph[a].push_back(make_pair(c, b));
		graph[b].push_back(make_pair(c, a));
	}

	int32_t Q, K;
	scanf("%d%d", &Q, &K);
	K--;

	int64_t d[100000];
	for (int32_t i = 0; i < N; i++) {
		d[i] = numeric_limits<int64_t>::max();
	}
	priority_queue<pair<int64_t, int32_t>, vector<pair<int64_t, int32_t>>, greater<pair<int64_t, int32_t>>> q;
	q.push(make_pair(0, K));
	d[K] = 0;
	while (!q.empty()) {
		pair<int64_t, int32_t> temp = q.top(); q.pop();
		int32_t node = temp.second;

		if (d[node] < temp.first)
			continue;

		for (int32_t i = 0; i < (int32_t)graph[node].size(); i++) {
			int32_t next_cost = graph[node][i].first;
			int32_t next_node = graph[node][i].second;
			if (d[next_node] > d[node] + next_cost) {
				d[next_node] = d[node] + next_cost;
				q.push(make_pair(d[next_node], next_node));
			}
		}
	}

	for (int32_t i = 0; i < Q; i++) {
		int32_t x, y;
		scanf("%d%d", &x, &y);
		x--;
		y--;
		printf("%" PRId64 "\n", d[x] + d[y]);
	}

	return 0;
}

Measured memory_bytes: 11120
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,int>;

int main() {
  int N;
  cin>>N;
  set<string> S;
  string p;
  for (int i=0; i<N; i++) {
    cin >> p;
    S.insert(p);
  }
  cout << S.size() << endl;
}

Measured memory_bytes: 19224
#include<iostream>
using namespace std;
int main(){
  int n,d;
  cin>>n>>d;
  if(n%(2*d+1)==0){
  	cout<<(n/(2*d+1))<<endl;
  }
  else{
    cout<<(n/(2*d+1))+1<<endl;
  }
  
 return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
//long long
using ll = long long;
 
// pair<int, int>
using PII = pair<int, int>;
 
//最大値、mod
const int MOD = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
 
//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(10) << x << endl
#define printc(x) cout << setw(2) << setfill('0') << x << endl;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()
 
//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
 
//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
 
// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}
 
// a = max(a, b), a = min(a, b)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
// 累乗(MODをとる)
ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}
 
 
 
// 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度)
// COMinit()
// COM(x, y)
// とコンビで使う
 
// テーブルを作る前処理
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};



int main(){
    int N;
    cin >> N;
    vector<int>ab(N);
    ll sum = 0;
        REP(i, N){
        int a, b;
        cin >> a >> b;
        ab.at(i) = a + b;
        sum -= b;
        }
    sort(all(ab));
  	reverse(all(ab));
    for(int i = 0; i < N; i += 2){
        sum += ab.at(i);
    }
    print(sum);
    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
using namespace std;
int A,B,C;
int main()
{
	scanf("%d%d%d",&A,&B,&C);
	if (B>C) swap(B,C);
	if (A>B) swap(A,B);
	int ans=0;
	while (A+2<=C) A+=2,ans++;
	while (B+2<=C) B+=2,ans++;
	if (A!=C&&B!=C) { ans++;A++;B++;}
	if (A!=C&&B==C) { ans+=2;A+=2;B++;C++;}
	if (A==C&&B!=C) { ans+=2;A++;B+=2;C++;}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,l;
  cin>>n>>l;
  long long int all=0;
  for(int i=1; i<=n; i++){
    all+=l+i-1;
  }
  long long int ans=0;
  for(int i=1; i<=n; i++){
    long long int pre=all-l-i+1;
    if(abs(all-pre)<abs(all-ans)){
      ans=pre;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
N = gets.to_i
X, Y = N.times.map{gets.split.map(&:to_i)}.transpose

MX = 100001
edges = Array.new(2*MX){[]}
N.times do |i|
    edges[X[i]].push(Y[i]+MX)
    edges[Y[i]+MX].push(X[i])
end

ans = -N
visited = []
(2*MX).times do |i|
    que = [i]
    cnt = [0, 0]
    while que.size > 0
        x = que.pop
        next if visited[x]
        visited[x] = true
        cnt[x/MX] += 1
        que.concat(edges[x])
    end
    ans += cnt[0]*cnt[1]
end
puts ans

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

const int N = 200 * 1000 + 20;
int n, a[N], Xor;

int main() {
        ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
        cin >> n;
        for (int i = 0; i < n; i++) {
                cin >> a[i];
                Xor ^= a[i];
        }
        for (int i = 0; i < n; i++)
                cout << (Xor ^ a[i]) << " ";
        return cout << "\n", 0;
}

Measured memory_bytes: 4368
n = int(input())

l = []
cnt = 0
t = 0

for i in range(n):
    s = str(input())
    sl = ''.join(sorted(s))
    l.append(sl)

l.sort()

tmp = l[0]

for i in range(1, n):
  if tmp == l[i]:
    cnt += 1
  else:
    tmp = l[i]
    t += int(cnt * (cnt + 1) / 2)
    cnt = 0
else:
    t += int(cnt * (cnt + 1) / 2)

print(t)

Measured memory_bytes: 10640
#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--) //逆ループ
 
//型名省略
typedef long long ll;
//値
static const ll MX = 100005;
static const ll MX_ll = 1e18;
const double PI = acos(-1); //π
 
using namespace std;
 
//ソート
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 
//#include "./lib/generic/search.h"

//文字列入力した小数値を小数点なくして返す
int changeDoubleToInt(string decimal){ 
    decimal.erase(1, 1); //小数点削除
    int n_decimal = atoi(decimal.c_str()); //c_strでchar*に変換後、atoiでintに変換
    return n_decimal;
}

//最大公約数
int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

int main(){
   ll k, n;
   cin >> k >> n;
   vector<int> a(n), b(n);
   rep(i, n) cin >> a[i];
   //最後の点a[n-1]からa[0]への距離を求めるために、a[0]+kを入れる
   //+kしているのはa[0]を1周した前提で考えたほうがa[n-1]に近いため
   a.push_back(a[0]+k); 
   int l = 0;
   rep(i, n){
       l = max(l, a[i+1]-a[i]);
   }
   int ans = k-l;
   cout << ans << endl;
}

Measured memory_bytes: 5616
#include<bits/stdc++.h>
using namespace std;
inline int read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
long long prime[1000003],cnt;
bool v[1000003];
void init(int n) 
{
    v[1]=1;
    for(int i=2;i<=n;++i) 
    {
        if(!v[i]) prime[++cnt]=i;
        for(int j=1;j<=cnt&&i*prime[j]<=n;++j) 
        {
            v[i*prime[j]]=1;
            if(i%prime[j]==0) break;
        }
    }
}
bool f[1000003];
map<int,int> mp;
int main()
{
    init(10000);
    int n=read(),xx=read(),x=xx;
    for(int i=1; i<=cnt; i++) if(x%prime[i]==0) { f[i]=1; while(x%prime[i]==0) x/=prime[i];}
    bool qwq=1;
    mp[x]=1;
    for(int i=2; i<=n; i++) 
    {
        int zkak=read(),t=zkak;
        if(qwq && t>1) 
        {
            for(int j=1; j<=cnt; j++) if(t%prime[j]==0) if(f[j]) qwq=0; else { f[j]=1; while(t%prime[j]==0) t/=prime[j];}
            if(t>1) if(mp[t]) qwq=0; else mp[t]=1;
        }
        xx=__gcd(zkak,xx);
    }
    if(qwq) puts("pairwise coprime"); else if(xx==1) puts("setwise coprime"); else puts("not coprime");
    return 0;
}

Measured memory_bytes: 7292
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> list = new ArrayList<>();
        while (sc.hasNext()) {
            list.add(Integer.parseInt(sc.next()));
        }
        System.out.println(list.get(2));
        System.out.println(list.get(0));
        System.out.println(list.get(1));
        sc.close();
    }

}


Measured memory_bytes: 35520
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, st, n) for (int i = (st); i < (n); ++i)
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
 
template <typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; }
template <typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; }

const int N = 100005;
const int LOG = 61;
int n;
ll a[N];
ll basis[LOG];

void add(ll  x)
{
    for (int i = LOG - 1; i >= 0; --i)
    {
        if (~x & (1LL << i)) continue;
        if (!basis[i])
        {
            basis[i] = x;
            return;
        }
        x ^= basis[i];
    }
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
    freopen("in", "r", stdin);
#endif
    
    cin >> n;
    ll X = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        X ^= a[i];
    }
    for (int i = 0; i < n; ++i)
    {
        add(a[i] & (~X));
    }
    ll A = 0;
    for (int j = LOG - 1; j >= 0; --j) if (~X & (1LL << j))
    {
        ll B = A ^ (1LL << j);
        // want to check if B is representable by the basis in intereseting bits
        ll BB = B;
        bool ok = true;
        for (int i = LOG - 1; i >= j; --i) if (~X & (1LL << i))
        {
            if (~B & (1LL << i)) continue;
            if (!basis[i])
            {
                ok = false;
                break;
            }
            B ^= basis[i];
        }
        if (ok)
            A = BB;
    }
    cout << X + 2 * A << '\n';


    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
    const int num_of_height = 10;
    const int num_of_top = 3;
    const int min = 0;
    const int max = 10000;
    
    int h;
    std::vector<int> height;
    height.reserve(num_of_height);
    
    //std::cout << num_of_height << "個の高さの入力" << std::endl;
    for(int i = 0; i < num_of_height; ++i){
        while(1){
            std::cin >> h;
            if(min <= h && h <= max)
                break;
            else
                std::cout << min << "<=h<=" << max << "に設定" << std::endl;
        }
        height.push_back(h);
    }
    
    sort(height.begin(), height.end(), std::greater<int>());
    
    //std::cout << "高い順から" <<  num_of_top << "個出力" << std::endl;
    for(int i = 0; i < num_of_top; ++i)
        std::cout << height.at(i) << std::endl;
        
    return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(20);
           bool ans=false;
		   int n;
           cin>>n;
           ll l;
           cin>>l;
           vll a(n);
           rep(i,0,n){
             cin>>a[i];
           }
           int h=-1;
           rep(i,0,n-1){
             if(a[i]+a[i+1]>=l){
               ans=1;
               h=i+1;
             }
           }
           if(!ans)cout<<"Impossible"<<endl;
           else{
             cout<<"Possible"<<endl;
             rep(i,0,h-1){
              cout<<i+1<<endl; 
             }
             for(int i=n-1;i>h;i--){
              cout<<i<<endl; 
             }
             cout<<h<<endl;
             
             
           }
}

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

using namespace std;

const int N = 50 + 3;

typedef pair<int, int> ii;

int n;
vector<ii> c;
vector<ii> pq;
set<ii> xy;

int main() {
  scanf("%d", &n);

  for(int i = 0; i < n; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    c.push_back(ii(x, y));
    xy.insert(ii(x, y));
  }

  for(int i = 0; i < n; ++i) {
    for(int j = i + 1; j < n; ++j) {
      int p = c[j].first - c[i].first;
      int q = c[j].second - c[i].second;
      pq.push_back(ii(p, q));
    }
  }

  int ans = n;
  for(ii z: pq) {
    int p = z.first;
    int q = z.second;

    set<ii> s; s.clear();
    int cnt = 0;

    for(int i = 0; i < n; ++i) {
      if(s.count(c[i]) > 0) continue;

      ++cnt;

      int x = c[i].first;
      int y = c[i].second;
      while(s.count(ii(x, y)) == 0 && xy.count(ii(x, y)) > 0) {
        s.insert(ii(x, y));
        x += p; y += q;
      }
      
      x = c[i].first - p;
      y = c[i].second - q;
      while(s.count(ii(x, y)) == 0 && xy.count(ii(x, y)) > 0) {
        s.insert(ii(x, y));
        x -= p; y -= q;
      }
    }

    ans = min(ans, cnt);
  }

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define vint vector<int>

int main()
{
    string s;
    cin >> s;
    int sz = s.size();
    bool ans = true;
    REP(i, sz)
    {
        if (i % 2 == 0){
            if (s[i] == 'L'){
                ans = false;
            }
        }else{
            if (s[i] == 'R'){
                ans = false;
            }
        }
    }
    if (ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(register int i=a;i<=b;i++)
template <typename T>
void read(T &x){
    x=0;
    int flag=1;
    char c=getchar();
    while(c=='-'){
        flag=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=x*10+c-'0';
        c=getchar();
    }
    x*=flag;
}

int n,m,a[110],b[110],id,cnt=1,ans[110];
int main()
{
    read(n);
    m=n;
    rep(i,1,n)read(a[i]);
    while(cnt<=n){
        int flag=1;
        id=0;
        rep(i,1,n)if(a[i]!=0)b[i]=++id;
        for(int i=n;i;i--){
            if(a[i]!=0&&a[i]==b[i]){
                ans[m--]=a[i];
                a[i]=0;
                cnt++;
                flag=0;
                break;
            }
        }
        if(flag){
            cout<<"-1";return 0;
        }
    }
    rep(i,1,n)cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())

l = list(map(int,input().split()))

l.sort()
c = 0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if l[i] < l[j] and l[j] < l[k]:
                if l[i] + l[j] > l[k]:
                    c += 1

print(c)


Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
int main(){
	ll N,M,ans=0;
	cin >> N >> M;
	map<ll,ll> ma;
	FOR(i,0,N){
		ll k;
		cin >> k;
		FOR(j,0,k){
			ll p;
			cin >> p;
			ma[p]++;
		}
	}
	for(auto x:ma){
		if(x.second==N)ans++;
	}
	cout << ans << endl;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    ll x; cin >> x;
    ll ans = 0;
    ans += (x/11)*2;
    x %= 11;

    if(0<x && x<=6) ans += 1;
    else  if(6<x) ans += 2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3548
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
using namespace std;

int main(){

  char a[3], b[3];
  

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

  if(a[0]==b[2] && a[1]==b[1] && a[2]==b[0]){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }


  return 0;
}

Measured memory_bytes: 256
import java.util.*;
    class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        String t = sc.next();

        for(int i=0;i<s.length();i++){
            if(s.charAt(i)!=t.charAt(i)){
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
        
    }
}

Measured memory_bytes: 35632
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define ss second
#define ff first
#define INF 30000000000001
#define ll_max 9000000000000000001
#define mod 1000000007
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;
const ll N = 100001;
const ll M = 1;

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n, m, x = 0, y = 0, ans = 0;
        string s, t;
        cin >> s >> t;
        n = s.size();
        m = t.size();
        s = ' ' + s;
        t = ' ' + t;
        ll dp[n + 1][m + 1] = {};
        for(int i = 1; i <= n; i++)
        {
            for(int j = 1; j <= m; j++)
            {
                if(s[i] == t[j])
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
        string sol(dp[n][m], ' ');
        while(n > 0 && m > 0)
        {
            if(s[n] == t[m])
            {
                sol[dp[n][m] - 1] = s[n];
                n--;
                m--;
            }
            else if(dp[n - 1][m] == dp[n][m])
            {
                sol[dp[n][m] - 1] = s[n];
                n--;
            }
            else
            {
                sol[dp[n][m] - 1] = t[m];
                m--;
            }
        }
        cout << sol << "\n";
    }
    return 0;
}


Measured memory_bytes: 70656
import Data.Functor

rev :: Int -> Int
rev pos = 7 - pos

{- 初期状態。top, front, east-}
firstDice :: (Int, Int, Int)
firstDice = (1, 2, 3)


turn :: (Int, Int, Int) -> Char -> (Int, Int, Int)
turn (top, front, east) cmd = 
    case cmd of
      'N' -> (front     , rev top , east)
      'S' -> (rev front , top     , east)
      'E' -> (rev east  , front   , top )
      'W' -> (east      , front   , rev top)

top (t, _, _) = t

main :: IO ()
main = do
    nums <- map (\x -> read x::Int) . words <$> getLine
    cmds <- getLine
    print $ nums !! (top (foldl turn firstDice cmds) -1)

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		long l = sc.nextLong();
		
		long n = 100;
		long day = 0;
		
		while(n<l)
		{
			day++;
			long gain = (n/100l);
			n += gain;
		}
		
		System.out.println(day);
	}

}


Measured memory_bytes: 27040
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();

        boolean ans = false;
        for (int i = 0; i <= n && !ans; i++) {
            long min = - d * i  + c * (n - i - 1);
            long max = - c * i + d * (n - i - 1);
            if (b - a >= min && b - a <= max)
                ans = true;
        }
        if (ans)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}


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

using namespace std;


void solve() {
    int x, _;
    cin >> x >> _;
    int y;
    cin >> y >> _;
    int res = (y>x)?1:0;
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 384
class UnionFind(object):
 
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]
 
    def find(self, x):
        if self.table[x] < 0:
            return x
        self.table[x] = self.find(self.table[x])
        return self.table[x]
 
    def same(self, x, y):
        return self.find(x) == self.find(y)
 
    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 == s2:
            return False
        if self.table[s1] > self.table[s2]:
            s1, s2 = s2, s1
        self.table[s1] += self.table[s2]
        self.table[s2] = s1
        return True

H, W = list(map(int, input().split()))
S = list(input() for _ in range(H))
uf = UnionFind(H*W)

def get(h, w):
    return h * W + w

for h in range(H):
    for w in range(W):        
        for dh, dw in zip((0, 1), (1, 0)):
            if (h + dh) >= H or (w + dw) >= W:
                continue
            if S[h][w] != S[h+dh][w+dw]:
                uf.union(get(h, w), get(h+dh, w+dw))


from itertools import product

C1 = []
C2 = []

for h in range(H):
    for w in range(W):
        if S[h][w] == ".":
            C1.append((h, w))
        else:
            C2.append((h, w))

white = [0] * (H * W)
black = [0] * (H * W)

for h in range(H):
    for w in range(W):
        n = get(h, w)
        par = uf.find(n)
        # print(h, w, n, par)
        if par < 0:
            par = n
        if S[h][w] == ".":
            white[par] += 1
        else:
            black[par] += 1
            
ans = 0
# print(white)
# print(black)
for h in range(H):
    for w in range(W):
        n = get(h, w)
        ans += white[n] * black[n]
print(ans)
            



Measured memory_bytes: 21176
#include<bits/stdc++.h>
 
 
#define sc(x) scanf("%d",&x)
#define ALL(x) x.begin(),x.end()
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORd(i,a,b) for(int i=a;i>b;i--)
#define ff first
#define ss second
#define reset(x) memset(x,0,sizeof x)
#define sz(x) x.size()
#define pb push_back
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
 
using namespace std;
 
typedef pair<int,int> pii;
typedef vector<pii> vii;
const int con = 1e5+7;
static const int INF = 0x3f3f3f3f;
static const int MOD = 1e9+7;
/*
ll power(ll x,ll y,ll mod){
    int res = 1; // Initialize result
 
    while (y > 0) {
        
        if (y & 1)
            res = (res * x + mod)%mod;
 
 
        y = y >> 1;
        x = (x * x)%mod;
    }
    return res;
}
*/
 
 
int main() {
    FASTIO
 
    int n;cin >> n;
    std::vector<int> arr(n);
    for(auto &x:arr) cin >> x;
    int ans = 0;
    for(int i=1;i<n-1;i++){
        vector<int> v(arr.begin()+i-1,arr.begin()+i+2);
        sort(ALL(v));
        if(v[1] == arr[i]) ++ans;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("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>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;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
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#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 print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;
const int INT_INF = 1e9;
long long gcd(long long x, long long y) {
	long long m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}


void solve() {
	int N; cin >> N;
	int ans = 1;
	FOR(i, 1, N+1) {
		ans *= i;
		ans %= MOD;
	}
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;cin>>q;
	//while(q--)
	solve();
}




Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int N, T;
    std::cin >> N >> T;

    int answer = T;
    int a[200000];

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

    for (int i = 0; i < N-1; i++) {
        answer += std::min(T, a[i+1] - a[i]);
    }

    std::cout << answer << std::endl;

    /*
    if (N != 1) {
        std::vector<int> t(N);
        for (int i = 0; i < N; i++) {
            std::cin >> t[i];
        }

        std::vector<int> dt(N-1);
        for (int i = 0; i < N-1; i++) {
            dt[i] = t[i+1] - t[i];
        }
    
        int ans = 0;
        for (int i = 0; i < N; i++) {
            if (dt[i] <= T) {
                ans += dt[i]; 
            } else {
                ans += T;
            }
        }

        ans += T;
        std::cout << ans << std::endl;
    } else {
        std::cout << T << std::endl;
    }
    */

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#define MAX 100001

typedef struct{
  char name[10];
  int time;
}Que;

void enqueue(Que);
Que dequeue(void);
int min(int,int);
Que Q[MAX];
int head,tail;

int main(void){
  int n,q,i,totalTime=0,c;
  Que que;
  scanf("%d%d",&n,&q);
  for(i=1;i<=n;i++)
    scanf("%s%d",Q[i].name,&Q[i].time);
  head=1;
  tail=n+1;

  //start running
  while(head!=tail){
    que=dequeue();
    c=min(q,que.time);//qか残りのtimeの必要な時間の選択
    que.time-=c;//残り時間の計算
    totalTime+=c;//経過時間
    if(que.time>0)enqueue(que);//処理の終了していないqueをキューの最後に追加
    else printf("%s %d\n",que.name,totalTime);
  }
  return 0;
}

void enqueue(Que x){
  Q[tail]=x;
  tail=(tail+1)%MAX;
}

Que dequeue(){
  Que x=Q[head];
  head=(head+1)%MAX;
  return x;
}

int min(int a,int b){
  return a<b ?a :b;
  // ?はtureの時a  :はfalseの時bを返す
}


Measured memory_bytes: 3260
#include <bits/stdc++.h>
#include <algorithm>
#include <unordered_map>
#define ull unsigned long long
#define int long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
using namespace std;
// const ll MAX = 1e6 + 1;
// typedef vector<vector<ll>> matrix;
// const ll PRIME = 1e9 + 7;
// typedef pair<int,pair<int,int> >  ppi;

void solve()
{
    int n,x,t;
    cin>>n>>x>>t;
    if(n%x==0)
    {
        cout<<(n/x)*t;
        return;
    }
    else
    {
        cout<<(n/x +1)*t;

    }
    
}
int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

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

Measured memory_bytes: 3580
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int N = scanner.nextInt();
        long[] monsters = new long[N+1];
        for(int i = -1; i < N; i++) {
            monsters[i+1] = scanner.nextInt();
        }
        long ans = 0;
        for(int i = 0; i < N; i++) {
            long cur = scanner.nextInt();
            long amt = Math.min(cur, monsters[i]);
            monsters[i] -= amt;
            ans += amt;
            cur -= amt;
            amt = Math.min(cur, monsters[i+ 1]);
            monsters[i+1] -= amt;
            ans += amt;
        }
        out.println(ans);
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        
        int[] readIntArray(int n) {
            int[] a = new int[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextInt();
            }
            return a;
        }
    }
}


Measured memory_bytes: 43484
#include <bits/stdc++.h>
#define double long double
#define int long long
#define mii map<int,int>
#define pii pair<int,int>
#define low lower_bound
#define upp upper_bound
#define mod 1000000007 //10^9+7
#define inf 10000000000000000 //10^16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
	string s;
	cin>>s;
	int n=s.size(),cnt=0,ans=0;
	for(int i=2;i<=n-2;i++) {
		if(s[i]=='C') cnt++;
	}
	rep(i,n) {
		if(isupper(s[i])) ans++;
	}
	if(s[0]=='A'&&cnt==1&&ans==2) cout<<"AC"<<endl;
	else cout<<"WA"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl

using namespace std;
using ll = long long;



int main() {
    int k;
    cin >> k;
    
    queue<ll> q;

    q.push(1);
    q.push(2);
    q.push(3);
    q.push(4);
    q.push(5);
    q.push(6);
    q.push(7);
    q.push(8);
    q.push(9);

    ll ans = 0;
    ll cnt = 0;
    while (true) {
        if (q.empty()) break;
        ll tar = q.front();
        q.pop();
        cnt++;

        if (cnt == k) {
            ans = tar;
            break;
        }

        int keta = tar % 10;
        if (keta == 0) {
            q.push(tar * 10 + keta);
            q.push(tar * 10 + keta + 1);
        } else if (keta == 9) {
            q.push(tar * 10 + keta - 1);
            q.push(tar * 10 + keta);
        } else {
            q.push(tar * 10 + keta - 1);
            q.push(tar * 10 + keta);
            q.push(tar * 10 + keta + 1);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
void main() {
	auto ip = readAs!(int[]), A = ip[0], B = ip[1], X = ip[2];
	(A + B >= X && !(A > X) ? "YES" : "NO").writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
import Text.Printf
import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V
main=putStrLn.printf"%.10f".solve.map(unfoldr(B.readInt.B.dropWhile isSpace)).B.lines=<<B.getContents
solve(_:xys)=sqrt.fromIntegral.V.foldr max 0$V.imap f as::Double where
  n=V.length as
  as=V.fromList$sortBy cmpArg.filter(/=(0,0))$map(\[x,y]->(x,y))xys
  f i a=maximum.snd.mapAccumL h(0,0).takeWhile(g a)$map(\k->as V.!((i+k)`mod`n))[0..n-1]
g a b=c>0 || c==0 && dot a b>=0 where c=cross a b
h(x1,y1)(x2,y2)=((x,y),x^2+y^2)where(x,y)=(x1+x2,y1+y2)
dot(x1,y1)(x2,y2)=x1*x2+y1*y2
cross(x1,y1)(x2,y2)=x1*y2-x2*y1
upperArg(x,y)=y>0 || y==0 && x>0
cmpArg l r=compare(upperArg r,0)(upperArg l,cross l r)

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

using namespace std;

#define fto(i, s, e) for(int i = s; i <= e; ++i)
#define fto1(i, s, e) for(int i = s; i < e; ++i)
#define fdto(i, s, e) for(int i = s; i >= e; --i)
#define fit(var, it) for(__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)
#define frit(var, it) for(__typeof(var.rbegin()) it = var.rbegin(); it != var.rend(); ++it)

#define newl '\n'
#define debugt cerr << 0.001*clock() << newl
#define debug1(x, i) cout << #x << '[' << i << "] = " << x[i] << newl
#define debug(v, l, r) fto(_i, l, r) debug1(v, _i)
#define debug2(x, i, j) cout << #x << '[' << i << "][" << j << "] = " << x[i][j] << newl
#define debug3(x, i, j, k) cout << #x << '[' << i << "][" << j << "][" << k << "] = " << x[i][j][k] << newl

#define ll long long
#define ii pair<int, int>
#define ff first
#define ss second
#define pb push_back
#define glen(v) int((v).size())

template<typename T1, typename T2> ostream& operator<< (ostream &os, pair<T1, T2> const &v) {
	return os << '(' << v.ff << ", " << v.ss << ')';
}

#define eps 1e-15
#define oo 1000000007
#define OO 1000000000000000003LL
#define maxn 403

int n;
int a[maxn];
ll sum[maxn];
ll f[maxn][maxn];

int main() {
	//ios_base::sync_with_stdio(0); cin.tie(0);

	scanf("%d", &n);

	fto (i, 1, n) {
		scanf("%d", &a[i]);
		sum[i] = sum[i-1] + a[i];
	}

	fdto (i, n, 1) {
		fto (j, i+1, n) {
			f[i][j] = OO;
			fto1 (k, i, j) {
				f[i][j] = min(f[i][j], f[i][k] + f[k+1][j] + sum[j] - sum[i-1]);
			}
		}
	}

	printf("%lld\n", f[1][n]);

	return 0;
}


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

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

    int n; cin >> n;
    vector<int> vec(n);
    for (int i = 0; i < n; i++) cin >> vec[i];
    sort(vec.begin(), vec.end());
    cout << vec[n/2] - vec[n/2-1] << endl;
}








Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main() {
	int a,b; char op;
	cin>>a;
	while(true){
		cin>>op;
		if(op == '='){
			cout<< a <<endl; 
		    return 0;
		}
		cin>>b;
		if(op == '+') a += b; 
		if(op == '-') a -= b;
		if(op == '*') a *= b; 
		if(op == '/') a /= b; 
	}
}



Measured memory_bytes: 3092