akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 17;
const ll MOD = 998244353;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

ll gcd(ll a, ll b) {
	return a == 0 ? b : gcd(b%a, a);
}
ll mypow(ll a, ll b, ll m) {
	ll rv = 1;
	while (b) {
		if (b % 2) rv = rv * a % m;
		a = a * a%m;
		b /= 2;
	}
	return rv;
}

bool pchk[10050];
vector <int> Vp;
ll in[10050];

ll u[10050];
int main() {
	int N, i, j;
	for (i = 2; i <= 10001; i++) {
		if (pchk[i]) continue;
		Vp.push_back(i);
		for (j = 2 * i; j <= 10001; j += i) pchk[j] = true;
	}

	vector <pll> Vl;
	scanf("%d", &N);
	for (i = N; i >= 0; i--) {
		scanf("%lld", &in[i]);
		if (in[i]) Vl.emplace_back(in[i], i);
	}

	ll G = 0;
	for (i = N; i >= 0; i--) G = gcd(G, abs(in[i]));

	srand(13524);
	vector <int> Va;
	for (auto it : Vp) {
		if (it > N+1) break;
		if (G%it == 0) {
			Va.push_back(it);
			continue;
		}
		if (in[0] % it) continue;
		
		int x = rand() % (it - 1);
		if (it != 2) {
			while (gcd(x, (it - 1)) != 1) x = rand() % (it - 1);
		}
		else x = 1;

		for (i = 0; i < it - 1; i++) u[i] = 0;
		for (i = 0; i <= N; i++) u[(x*i) % (it - 1)] = (u[(x*i) % (it - 1)] + in[i]) % it;
		for (i = 1; i < it; i++) {
			ll v = 0;
			for (j = it-2; j >= 0; j--) v = (v*i + u[j]) % it;
			if (v) break;
		}
		if (i >= it) Va.push_back(it);
	}

	for (i = 2; i * i <= G; i++) {
		if (G%i) continue;
		Va.push_back(i);
		while (G % i == 0) G /= i;
	}
	if (G != 1) Va.push_back(G);

	sort(all(Va));
	Va.erase(unique(all(Va)), Va.end());
	for (auto it : Va) printf("%d\n", it);
	return 0;
}

Measured memory_bytes: 768
from fractions import gcd

n = int(input())
a = [int(i) for i in input().split()]

gcd_to = [0] + a[:]
gcd_from = a[:] + [0]
for i in range(1, n+1):
    gcd_to[i] = gcd(gcd_to[i-1], gcd_to[i])
    gcd_from[n-i] = gcd(gcd_from[n-i+1], a[n-i])

gcd_exclude = []
for i in range(n):
    gcd_exclude.append(gcd(gcd_to[i], gcd_from[i+1]))

print(max(gcd_exclude))


Measured memory_bytes: 16076
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
typedef long long ll;
const ll MAX=510000;
const ll mod = 1e9 + 7;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,D,Q,K,R,W,H,P,L,G;
ll ans;
string S,T;
ll h[101010];
ll y[101010];
ll a[201010];
ll c[101010];
ll k[101010];
ll b[201010];
ll d[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll r[101010];
ll v[101010];
ll s[101010];
ll x[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
struct Edge{
	ll to,cost;
	 Edge(ll to, ll cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	vector<ll> size;
    UnionFind(ll N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
		for(ll i = 0; i < N; i++) size[i] = 1;
    }

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

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

    }

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

int main(){
    cin>>N;
    rep(i,0,N-1){
        cin>>b[i];
    }
    ans=b[N-2];
    urep(i,N-2,0){
        ans+=min(b[i],b[i+1]);       
        cerr<<ans<<endl;
    }
    ans+=b[0];
    cout<<ans<<endl;
    return 0;
}


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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en 


constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

void Main(){
    int n, k;
    cin >> n >> k;
    VI av(n);
    REP(i, n) cin >> av[i];
    ll ans = LINF;
    for (int bit = 0; bit < (1<<n); ++bit) {
        ll tmp = 0;
        int count = 0;
        int max_b = 0;
        for (int i = 0; i < n; ++i) {
            if (bit & (1 << i)) {
                count++;
            }
        }
        if (count < k) {
            continue;
        }
        REP(i, n) {
            if(bit & (1<<i)) {
                if(max_b >= av[i]) {
                    tmp += max_b + 1 - av[i];
                }
                max_b = max(max_b + 1, av[i]);
            } else {
                max_b = max(av[i], max_b);
            }
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

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

int main()
{
  int M1, M2, D1, D2;
  cin >> M1 >> D1 >> M2 >> D2;
  int ans = 1;
  if (M1 == M2)
    ans = 0;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	long n;
	long trans[5];
	int i;
	cin >> n;
	for(i=0;i<5;i++){
		cin >> trans[i];
	}
	long ans = 0;
	sort(trans,trans+5);
	if(n%trans[0] == 0) ans+= n/trans[0];
	else ans += n/trans[0] + 1;
	ans += 4;
	cout << ans;
}

Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
void defe(ll &a,ll &b,ll &ans){
  if(a>=b){
    ans += b;
    a -= b;
    b = 0;
  }else{
    ans += a;
    b -= a;
    a = 0;
  }
}
signed main(){
  init_io();
  ll n,ans=0;
  cin >> n;
  vector<ll> a(n+1),b(n);
  for(int i=0;i<n+1;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    cin >> b[i];
  }
  for(int i=0;i<n;i++){
    defe(a[i],b[i],ans);
    defe(a[i+1],b[i],ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1920
s,k=input(),int(input())
n=[int(i) for i in s]
l=len(s)
dp=[[[0]*(k+1),[0]*(k+1)] for i in range(l+1)]
dp[0][0][0]=1
for i in range(l):
    for smaller in range(2):
        for x in range(10 if smaller else n[i]+1):
            if x==0:
                for y in range(k+1):
                    dp[i+1][smaller or x<n[i]][y]+=dp[i][smaller][y]
            else:
                for y in range(k):
                    dp[i+1][smaller or x<n[i]][y+1]+=dp[i][smaller][y]
print(dp[-1][0][-1]+dp[-1][1][-1])

Measured memory_bytes: 3064
inpl = lambda: list(map(int,input().split()))
N, M = inpl()
st = []
roadfrom = [set() for _ in range(N)]
for m in range(M):
    s, t = inpl()
    s, t = s-1, t-1
    st.append((s,t))
    roadfrom[s].add(t)
nb_branches = [len(roadfrom[i]) for i in range(N)]
START, GOAL = 0, N-1
exps = [0]*N
for r in range(GOAL-1,START-1,-1):
    exps[r] = 1 + sum(exps[c] for c in roadfrom[r])/nb_branches[r]
probs = [0]*N
probs[START] = 1
for r in range(N):
    for c in roadfrom[r]:
        probs[c] += probs[r]/nb_branches[r]
ans = 0
for r in range(N):
    nb = nb_branches[r]
    if nb <= 1:
        continue
    new_exp = ((exps[r]-1)*nb - max(exps[c] for c in roadfrom[r]))/(nb-1) + 1
    diff_exp = (exps[r] - new_exp) * probs[r]
    if diff_exp > ans:
        ans = diff_exp
print(exps[START] - ans)

Measured memory_bytes: 79320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    string s;cin>>s;
    ll maxi=0;
    ll now=0;
    rep(i,0,s.size()-1){
        if(s[i]=='R'){
            now++;
        }else{
            now=0;
        }
        maxi=max(maxi,now);
    }
    cout<<maxi<<endl;

    return 0;
}





Measured memory_bytes: 3616
# -*- coding: utf-8 -*-
import sys
import collections
import copy
import math
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
a,b = map(int,input().split())
if a*b ==15:
    print("*")
elif a+b == 15:
    print("+")
else:
    print("x")

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define     ll          long long
#define     MOD         10e9+7
#define     pb          push_back
#define     vll         vector<long long>
#define     vi          vector<int>
#define     vl          vector<long>
#define     pii         pair<int, int>
#define     pll         pair<ll,ll>
#define     mp          make_pair
#define     all(a)      (a).begin(),(a).end()
#define     rep(i,a,b)  for(int i=a;i<b;i++)
#define     MAX         100002 
#define     ios	      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;


int main() {
    
    ios
   	ll n,q,b,c,sum=0,ans;
   	ll dp[100002]={0};
   	cin >> n;
   	vll a(n);
   	for(ll i=0;i<n;i++){
   		cin >> a[i];
   		sum+=a[i];
   		dp[a[i]]++;
   	}
   	cin >> q;
   	while(q--){
   		ans=0;
   		cin >> b >> c;
   		if(dp[b]){
   			ans+=dp[b]*c;
   			sum-=dp[b]*b;
   			dp[c]+=dp[b];
   			dp[b]=0;
   			ans+=sum;
   			sum=ans;
   			cout << ans << "\n";
   		}
   		else cout << sum << "\n";
   	}

    return 0;
}



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

int main(){
    ll L,R;
    cin >>L>>R;
    if(abs(L-R)>=2019){
        cout<<0;
        return 0;
    }
    int a=min(L%2019,R%2019);
    int b=max(L%2019,R%2019);
    int ans=2019;
    for(int i=a;i<b;i++){
        for(int j=a+1;j<=b;j++){
            ans=min(ans,(i*j)%2019);
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <string>
    #include <algorithm>
    #include <set>
    #include <map>
    #include <list>
    #include <queue>
    #include <stack>
    #include <deque>
    #include <vector>
    #include <bitset>
    #include <cmath>
    #include <utility>
    #define Maxn 100005
    #define Maxm 1000005
    #define lowbit(x) x&(-x)
    #define lson l,m,rt<<1
    #define rson m+1,r,rt<<1|1
    #define PI acos(-1.0)
    #define eps 1e-7
    #define LL long long 
    #define Inf (1LL<<62)
    #define inf 0x3f3f3f3f
    #define input freopen("input.txt","r",stdin)
    #define output freopen("output.txt","w",stdout)
    using namespace std;
    bool calc(int n,LL m,LL a,LL b,int *arr)
    {
    	LL sum=0;
    	for(int i=n-1;i>=0;i--)
    	{
    		LL cnt=(arr[i]-m*b)%(a-b)?(arr[i]-m*b)/(a-b)+1:(arr[i]-m*b)/(a-b);
    		if(arr[i]-m*b>=0)
    			sum+=cnt;
    	}
    	return sum<=m?true:false;
    }
    LL solve(int *arr,int n,LL a,LL b)
    {
    	LL l=1,r=0,ans;
    	for(int i=0;i<n;i++)
    		r+=arr[i]%b?arr[i]/b+1:arr[i]/b;
    	while(r>=l)
    	{
    		LL m=(l+r)>>1;
    		if(calc(n,m,a,b,arr))
    		{
    			ans=m;
    			r=m-1;
    		}
    		else
    			l=m+1;
    	}
    	return ans;
    }
    int main()
    {
    	int n;
    	LL a,b;
    	int arr[Maxn];
    	//input;output;
    	while(~scanf("%d%lld%lld",&n,&a,&b))
    	{
    		for(int i=0;i<n;i++)
    			scanf("%d",arr+i);
    		sort(arr,arr+n);
    		printf("%lld\n",solve(arr,n,a,b));
    	}
    	return 0;
    }

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>

#define ll long long
#define ull unsigned long long

using namespace std;

const long long mod = 1000000007;

struct number{
    int a;
    ll count;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    ll k;
    number* numbers;
    cin >> n >> k;
    numbers = new number[n];
    for(int i = 0; i < n; ++i){
        cin >> numbers[i].a;

        int counter = 0;
        for(int j = 0; j < i; ++j){
            if(numbers[j].a > numbers[i].a) ++counter;
        }
        numbers[i].count = counter;
    }

    ll sumF = 0;
    ll sumS = 0;
    for(int i = 0; i < n; ++i){
        int counter = 0;
        for(int j = i+1; j < n; ++j){
            if(numbers[j].a > numbers[i].a) ++counter;
        }

        sumF += numbers[i].count;
        sumS += numbers[i].count + counter;
    }

    ll ans = sumF * k % mod;
    ll K = (k * (k-1)) / 2;
    K %= mod;
    ans += sumS * K;
    ans %= mod;

    cout << ans << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
typedef pair<int, bool> sP;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;

void solve() {
	int n; cin >> n;
	ld ans = 0;
	rep1(i, n) {
		if (i % 2)ans += 1 / (ld)n;
	}
	cout << ans << endl;
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(7);
	//init();
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int a = sc.nextInt();
    	int b = sc.nextInt();
    	int k = sc.nextInt();

    	for (int i = 0; i < k; i++) {
    		if ((a % 2) != 0) {
    			a--;
    		}
    		a /= 2;
    		b += a;
    		i++;
    		
    		if (i < k) {
    			if ((b % 2) != 0) {
        			b--;
        		}
        		b /= 2;
        		a += b;
    		}
    	}
    	System.out.println(a + " " + b);
    	sc.close();
    }
}

Measured memory_bytes: 22356
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;
const int INF=2e9;


int main() {
    ios_base::sync_with_stdio(false);


    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> dp(n,1);
    rep(i,n) {
        int j=upper_bound(dp.begin(),dp.end(),-a[i])-dp.begin();
        dp[j]=-a[i];
    }
    int ans=0;
    rep(i,n) {
        if (dp[i]!=1) ans=i;
    }
    cout << ans+1 << endl;
    

    return 0;   
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	string s;
	if( a < b )		{ s = "a < b"; }
	else if( a > b )	{ s = "a > b"; }
	else			{ s = "a == b"; }
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3116
# coding:utf-8

itemCount = int(input().rstrip())
items = [int(input().rstrip()) for i in range(itemCount)]
max_items = [i for i in reversed(sorted(items))][0:2]

for i in items:
    if i == max_items[0]:
        print(max_items[1])
    else:
        print(max_items[0])


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

int main(void){
    int a,b,c; cin >> a >> b >> c;
    ll cnt=0;
    if(a%2==b%2 && b%2!= c%2) c--,cnt++;
    else if(b%2==c%2 && c%2!= a%2) a--,cnt++;
    else if(c%2==a%2 && a%2!= b%2) b--,cnt++;

    int max_abc = max(a,max(b,c));
    cout << cnt+(max_abc-a)/2+(max_abc-b)/2+(max_abc-c)/2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include<cstdio>
#include<cmath>
#define endl '\n'
using namespace std;
int main()
{
	int n,k,x[101] = {0};
	cin>>n>>k;
	for(int i = 1; i<=n; i++)
		cin>>x[i];
	int sum = 0,da,db;
	for(int i = 1; i<=n; i++){
		da = x[i]*2;
		db = abs(k - x[i])*2;
		sum+=min(da,db);
		//cout<<da<<" "<<db<<" "<<sum<<endl;
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main(void) {

    ll h,w;
    cin>>h>>w;
    ll ans=LLINF;
    for(int i=0;i<w-1;i++){
        ll Sa=(i+1)*h;
        ll hb=h/2;
        ll hc=h-hb;
        ll Sb=hb*(w-(i+1));
        ll Sc=hc*(w-(i+1));
        ans=min(ans,max({Sa,Sb,Sc})-min({Sa,Sb,Sc}));
        hb=(w-i-1)/2;
        hc=w-hb-(i+1);
        Sb=hb*h;
        Sc=hc*h;
        ans=min(ans,max({Sa,Sb,Sc})-min({Sa,Sb,Sc}));
        // cout<<i<<" "<<Sa<<" "<<Sb<<" "<<Sc<<endl;
    }
    for(int i=0;i<h-1;i++){
        ll Sa=(i+1)*w;
        ll hb=w/2;
        ll hc=w-hb;
        ll Sb=hb*(h-(i+1));
        ll Sc=hc*(h-(i+1));
        ans=min(ans,max({Sa,Sb,Sc})-min({Sa,Sb,Sc}));
        hb=(h-i-1)/2;
        hc=h-hb-(i+1);
        Sb=hb*w;
        Sc=hc*w;
        ans=min(ans,max({Sa,Sb,Sc})-min({Sa,Sb,Sc}));
        // cout<<i<<" "<<Sa<<" "<<Sb<<" "<<Sc<< " " <<hb<<" "<<hc<<endl;
    }
    fin(ans);
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

     public static void main(String []args){
      int N, H;
      Scanner sc = new Scanner(System.in);
      N = sc.nextInt();
      H = sc.nextInt();
      int[] kthrow = new int[N];
      int[] attack = new int[N];
      int temp;
      int sum = 0;
      int count = 0;
      int num = 0;
      
      for(int i = 0; i<N; i++){
          attack[i] = sc.nextInt();
          kthrow[i] = sc.nextInt();
      }
      
      if(N == 1){
          H = H - kthrow[0];
          count++;
          if(H >0){
              if(H%attack[0] == 0)
              count += H/attack[0];
              else
              count += H/attack[0]+1;
          }
          System.out.println(count);
          return;
      }
      else{
      
        Arrays.sort(kthrow);
        Arrays.sort(attack);
       
          
          for(int i = 0; i<N; i++){
              if(attack[N-1] > kthrow[i])
                num++;
          }
    
          for(int i = N-1; i>=num; i--){
              sum = sum + kthrow[i];
              count++;
              if(H <= sum){
                  System.out.println(count);
                  return;
              }
          }
           
          H = H - sum;
          if((H % attack[N-1]) == 0)
            count += H/attack[N-1];
          else
            count += H/attack[N-1] + 1;
          
            System.out.println(count);
      }
     }
}

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


struct CustomCompare
{
    bool operator()(const pair<int, int>& lhs, const pair<int, int>& rhs)
    {
        return lhs.second > rhs.second;
    }
};

int main()
{
  priority_queue<pair<int, int>, vector<pair<int,int>>, CustomCompare> pq;
  int N; cin>>N;
  int i, j=0;
  for(int i=0;i<N;i++)
  {
    cin>>j;
    pq.push(make_pair(i,j));
  }
  while(!pq.empty())
  {
    pair<int, int> temp = pq.top();
    cout<<temp.first+1<<" ";
    pq.pop();
  }
  return 0;
}


Measured memory_bytes: 1780
#include <cstdio> 
#include <cstdlib> 
#include <cmath> 
#include <cstring> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <numeric>
#include <cassert>

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

int main(void)
{
    ll N, K;
    cin >> N >> K;
    ll ret = N;
    set<ll> visited;
    while (visited.count(N) == 0) {
        visited.insert(N);
        if (N >= 2*K) {
            ll a = N/K-1;
            N = N - a*K;
            while (N >= K) {
                N -= K;
            }
            N += K;
        }
        else if (N >= K) {
            N -= K;
        }
        else {
            assert(N < K);
            N = (K-N);
        }
        ret = min(N, ret);
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define X first
#define Y second
#define rep(i,a,n) for (long long i = a; i < n; i++)
#define ms(a, b) memset(a, b, sizeof(a))
#define mp(a, b) make_pair(a, b)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int MAXN = 2e5 + 10;
const int INF = 0x3fffffff;

struct Reader {
    static const int MX = 1e6;
    bool fail;
    char buf[MX], *p1, *p2;

    inline char nc() {
        if (p1 == p2) {
            p2 = (p1 = buf) + fread(buf, 1, MX, stdin);
            if (p1 == p2) return 0;
        }
        return *p1++;
    }

    template<class T> inline void read(T &x) {
        fail = true;
        char c = nc();
        bool b = 0;
        for (; c && !isdigit(c); c = nc()) if (c == '-') b = 1;
        if (c) fail = false;
        for (x = 0; isdigit(c); x = x * 10 + c - '0', c = nc());
        if (b) x = -x;
    }

    template<class T> inline Reader & operator >> (T &x) {
        if (!fail) read(x);
        return *this;
    }

    operator void*() {
        return fail ? 0 : (Reader*)this;
    }
} rd;

int n;

void solve() {
    rd >> n;
    printf("%s", n % 10 == 9 || n / 10 % 10 == 9 ? "Yes" : "No");
}

int main() {
#ifdef LOCAL
    freopen("case.in", "r", stdin);
#endif

    int T, cas = 0;
//    rd >> T;
//    while (T--) {
//        printf("Case #%d: ", ++cas);
        solve();
//    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    int num=0;
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        if(a == b){
            num++;
            if(num == 3){
                cout << "Yes" << endl;
                return 0;
            }
        }else{
            num = 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int N;
bool is_exist=false;
int main(){
    cin >> N;
    for(int cake=0;cake<N/4+1;++cake){
        for(int donuts=0;donuts<N/7+1;++donuts){
            if(4*cake + 7*donuts == N) is_exist=true;
        }
    }
    if(is_exist)cout << "Yes" << endl;
    else cout << "No" << endl;
}

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


int main()
{
	long long int N, K;

	long long int pos, neg;

	cin >> N >> K;

	
	long long int c = N/K;
	pos = N-K*c;
	neg = N-K*(c+1);

	cout << min(pos, abs(neg));

	return 0;
}

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

int a[112345];

int n;
int main () {
    cin >> n;
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a,a+n,greater<int>());
    int tmp = 1e9+7;
    int ans = 0;
    for(int i=1;i<n;i++) {
        int r = abs(a[0] / 2 - a[i]);
        if( r < tmp ) tmp = r, ans = i;
    }
    cout << a[0] << " " << a[ans] << endl;
    return 0;
}

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

bool can(int n, const vector<int> &a, int x) {
  if (x == 1)
    for (int i = 1; i < n; ++i)
      if (a[i] <= a[i - 1])
        return false;
  map<int, int> ma;
  for (int i = 1; i < n; ++i) {
    if (a[i] > a[i - 1])
      continue;
    int k = a[i];
    auto p = ma.upper_bound(k);
    if (p != ma.end())
      ma.erase(p);
    ++ma[k];
    while (k > 0 && ma[k] == x) {
      ma.erase(k);
      ++ma[--k];
    }
    if (k == 0)
      return false;
  }
  return true;
}

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i)
    scanf("%d", &a[i]);
  int low = 0, high = n + 1;
  while (low + 1 < high) {
    int mid = (low + high) / 2;
    (can(n, a, mid) ? high : low) = mid;
  }
  printf("%d\n", high);
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main() {
	int H, h1 = 0, W, w1 = 0, N, j, i, a[100][100], A[10000];
	scanf("%d%d%d", &H, &W, &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	for (i = 0; i < N; i++) {
		for (j = 0; j < A[i]; j++) {
			a[h1][w1]=i+1;
			if (h1 % 2 == 0) {
				w1++;
			} else {
				w1--;
			}
			if (w1 == W) {

				w1--;
				h1++;
			} else if (w1 == -1) {

				w1++;
				h1++;
			}
		}
	}
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			printf("%d ",a[i][j]);
		}
		printf("\n");
	}
	return 0;
}


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

using namespace std;
using ll = long long;

int main() {
    ll n,k = 0;
    cin >> n >> k;
    vector<ll> a(n);
    for(ll i = 0;i < n;i++){
        cin >> a[i];
    }
    ll j = 0;
    for(ll i = k;i < n;i++){
        if(a[i] > a[j]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
        j++;
    }
    
    return 0;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int hour = h2 - h1;
    int min  = m2 - m1;
    int ret  = hour * 60 + min - k;
    cout << ret << "\n";
    return 0;
}

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

using namespace std;

int main(void){
    int N, M; cin >> N >> M;
    vector<pair<int, int>> AB(N);

    int a, b;
    for(int i=0; i<N; i++){
        cin >> a >> b;
        AB[i] = make_pair(a, b);
    }
    sort(AB.begin(), AB.end());

    int i = 0;
    long long ans = 0;
    int rest = M;
    while (rest) {
        long long t = min(AB[i].second, rest);
        rest -= t;
        ans += t * AB[i].first;
        i++;
    }

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

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

using namespace std;

using int64 = long long;


const int mod = 1e9 + 7;

int N;
vector< int > g[100000];
int64 dp[100000][2];

void dfs(int idx, int par) {
  int64 latte = 1, malta = 1;
  for(auto &to : g[idx]) {
    if(to == par) continue;
    dfs(to, idx);
    (latte *= (dp[to][0] + dp[to][1]) % mod) %= mod;
    (malta *= dp[to][0]) %= mod;
  }
  dp[idx][0] = latte;
  dp[idx][1] = malta;
}

int main() {
  cin >> N;
  for(int i = 1; i < N; i++) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    g[x].emplace_back(y);
    g[y].emplace_back(x);
  }
  dfs(0, -1);
  cout << (dp[0][0] + dp[0][1]) % mod << endl;
}



Measured memory_bytes: 14208
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

int main() {
    ios_base::sync_with_stdio(false);

    ll h;
    cin >> h;
    ll x = 1;
    while(x <= h) x *= 2LL;
    cout << x-1 << endl;
}

Measured memory_bytes: 256
function Main(input) {
    input = input.split("\n");
    var N =Number(input[0]);
    var inputA = input[1].split(' ').map(Number);
    var inputB = input[2].split(' ').map(Number);
    var inputC = input[3].split(' ').map(Number);
    var count = 0;
    for(var i=0; i < N;i++){
        count +=  inputB[ inputA[i] - 1 ] ;
            //if( inputA[i-1] === inputA[i] -1  ){
        if( inputA[i] === (inputA[i-1]+1)  ){
            //count += inputC[  inputA[i-1] -1 ];
            count += inputC[inputA[i] -2];
        }
    }
    console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))
//Main(require("fs").readFileSync("data.txt", "utf8"))

Measured memory_bytes: 7372
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<queue>
#include<algorithm>
using namespace std;
#define N 5000
struct mzls
{
	int to;
	double cost;
}as;
struct mzls1
{
	double x,y,z;
}a1[N+5];
vector<mzls>g[N+5];
queue<int>q;
bool f[N+5],f1;
int n;
double dist[N+5];
inline void prepare()
{
	scanf("%lf%lf%lf%lf",&a1[1].x,&a1[1].y,&a1[2].x,&a1[2].y);
	a1[1].z=a1[2].z=0;
	dist[1]=dist[2]=1e18;
	scanf("%d",&n);
	n+=2;
	for(int i=3;i<=n;i++)
	{
		scanf("%lf%lf%lf",&a1[i].x,&a1[i].y,&a1[i].z);
		dist[i]=1e18;
	}
	for(int i=2;i<=n;i++)
		for(int j=1;j<i;j++)
		{
			double ml=sqrt((a1[i].x-a1[j].x)*(a1[i].x-a1[j].x)+(a1[i].y-a1[j].y)*(a1[i].y-a1[j].y));
			ml-=a1[i].z+a1[j].z;
			if(ml<0.0)
				ml=0.0;
			as.cost=ml;
			as.to=j;
			g[i].push_back(as);
			as.to=i;
			g[j].push_back(as);
		}
}
inline void SPFA(int s)
{
	dist[s]=0,f[s]=1;
	q.push(s);
	while(!q.empty())
	{
		int v=q.front();q.pop();
		f[v]=0;
		for(int i=0;i<g[v].size();i++)
		{
			mzls ml=g[v][i];
			if(dist[ml.to]>dist[v]+ml.cost)
			{
				dist[ml.to]=dist[v]+ml.cost;
				if(!f[ml.to])
				{
					q.push(ml.to);
					f[ml.to]=1;
				}
			}
		}
	}
}
int main()
{
	prepare();
	SPFA(1);
	printf("%.10lf\n",dist[2]);
	return 0;
}



Measured memory_bytes: 16512
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll S; cin >> S;
    if (S < 3) {
        cout << 0 << endl;
        return 0;
    }
    ll MOD = 1000000007;
    vector<int> DP(S+1);
    DP[0] = 1; DP[1] = 0; DP[2] = 0;
    for (int i = 3; i <= S; i++) {
        DP[i] = DP[i-1] + DP[i-3];
        DP[i] %= MOD;
    }
    cout << DP[S] << endl;
}


Measured memory_bytes: 3592
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * 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;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        E solver = new E();
        solver.solve(1, in, out);
        out.close();
    }

    static class E {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            long N = in.nextLong();
            if (N % 2 == 1) {
                out.println(0);
                return;
            }

            long count = 0;
            N /= 2;
            while (N >= 5) {
                N /= 5;
                count += N;
            }
            out.println(count);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 23124
n, m = map(int, input().split())

ab = []
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    ab.append((a, b))
ab.sort()

ans = 1
s = -10**9
t = 10**9
for a, b in ab:
    if a >= t:
        ans += 1
        t = b
    else:
        t = min(t, b)

print(ans)


Measured memory_bytes: 16996
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

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

//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int N;
int ans;
int main()
{
  int x;
  ans = 0;
  cin >>N;
  for(int i = 0;i < N;i++){
    cin >>x;
    for(int j =2;j <=ceil(sqrt(x));j++){
      if(x%j ==0 &&x !=2){
	ans++;
	break;
      }
    }
  }
  cout <<N-ans<<endl;
  return 0;
}

Measured memory_bytes: 1164
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#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>
#include<array>


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 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 double long double
#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;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 998244353; constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;



int calc(int n, int k) {
	if (n < k)return 0;
	if (n%k == 0)return n / k;
	else {
		int d = n / k;
		int rem = n - d * k;
		int cnt = rem / (d + 1);
		cnt = max(1LL, cnt);
		return calc(n-(d+1)*cnt, k);
	}
}

void solve() {
	int N; cin >> N;
	int g = 0;
	REP(i, N) {
		int A, K; cin >> A >> K;
		g ^= calc(A, K);
	}
	cout << (g == 0 ? "Aoki" : "Takahashi") << endl;

}

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>

using namespace std;
#define BUF (1000)
#define ll long long 

char s[BUF] ;

int main(void){
	cin >> s;

	char str[16][BUF] = {
		"KIHBR",
		"KIHBRA",
		"KIHBAR",
		"KIHBARA",
		"KIHABR",
		"KIHABRA",
		"KIHABAR",
		"KIHABARA",
		"AKIHBR",
		"AKIHBRA",
		"AKIHBAR",
		"AKIHBARA",
		"AKIHABR",
		"AKIHABRA",
		"AKIHABAR",
		"AKIHABARA",
		};

	for(int i=0;i<16;i++){
		if(0==strcmp(s,str[i])){
			cout << "YES";
			return 0;
		}
	}

	cout << "NO";
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string.h>
using namespace std;

int main()
{
    char palabra[1000];
    int tam,lon;
    cin >>tam;
    cin >>palabra;
    lon=strlen(palabra);

    if(lon<=tam)
    {
        for(int i = 0; i < lon; i++)
        {
            cout << palabra[i];
        }
    }
    else
    {
        for(int a = 0; a < tam; a++)
        {
            cout << palabra[a];

        }
       cout <<"...";
    }
    cout << "\n";
    return 0;
}


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 301;
const i64 P = 998244353;
i64 dp[maxn][maxn][maxn];
int reach[maxn][maxn][maxn];
i64 c[2][maxn];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    string s;
    cin >> s;
    int n = s.size();
    forn(i, n) forn(z, 2) c[z][i + 1] = c[z][i] + int(s[i] == (char)('0' + z));
    dp[0][0][0] = 1;
    forn(i, n) forn(c0, i + 1) forn(c1, i - c0 + 1) {
        int p = n - i - 1 + c0 + c1;
        forn(z, 2) {
            int nc0 = c0, nc1 = c1;
            if (s[p] - '0' != z) (z ? nc1 : nc0)++;
            (dp[i + 1][nc0][nc1] += dp[i][c0][c1]) %= P;
        }
    }

    forn(i, maxn) forn(j, maxn) forn(k, maxn) reach[i][j][k] = -1e9;
    reach[0][0][0] = 0;
    forn(i, n) forn(c0, i + 1) forn(c1, i - c0 + 1) {
        if (reach[i][c0][c1] < 0) continue;
        int nc0 = c0, nc1 = c1;
        ++(s[i] == '0' ? nc0 : nc1);
        uax(reach[i + 1][c0][c1], reach[i][c0][c1]);
        if (reach[i][c0][c1] > 0) uax(reach[i + 1][nc0][nc1], reach[i][c0][c1] - 1);
        if (i + 2 <= n) {
            uax(reach[i + 2][c0][c1], reach[i][c0][c1] + 1);
            uax(reach[i + 2][nc0][nc1], reach[i][c0][c1]);
            int mc0 = c0, mc1 = c1;
            ++(s[i + 1] == '0' ? mc0 : mc1);
            uax(reach[i + 2][mc0][mc1], reach[i][c0][c1]);
        }
    }

    i64 ans = 0;
    for1(i, n) forn(c0, i + 1) forn(c1, i - c0 + 1) {
        int p = n - i + c0 + c1;
        if (reach[p][c0][c1] >= 0) {
//            cerr << i << ' ' << c0 << ' ' << c1 << ' ' << p << ' ' << dp[i][c0][c1] << '\n';
            (ans += dp[i][c0][c1]) %= P;
        }
    }
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 217348
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr int mo2 = 998244353;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string s;ll k;
    cin>>s>>k;
    
    ll one = 0;
    int count = 0;
    int n = (int)s.size(); 
    for(int i=0;i<n-1;++i){
        if(s[i] == s[i+1])count++;
    }
    for(int i=0;i<n-1;++i){
        if(s[i] == s[i+1]){
            one++;
            i++;
        }
      }
    if(s[0] == s[n-1])count++;
    ll two = 0;
    s = s + s;
    int len = n;
    n = (int)s.size();
    for(int i=0;i<n-1;++i){
        if(s[i] == s[i+1]){
            two++;
            i++;
        }
    }
    ll diff = max(0ll,two - 2ll*one);
    if(count ==len  and len%2){
        if(k%2) cout << 1ll*two*(k/2) + one << endl;
        else cout << 1ll*two*k << endl;
    }
    else cout << 1ll*one * k + 1ll*diff*(k-1)<< endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
string a,b;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>a>>b;
	cout<<b<<a;
	return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
vector <ll> used;
ll A[int(1e5+5)];
map <ll, int> cnt;

int main(){
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> A[i];
    if (cnt[A[i]] == 0) used.push_back(A[i]);
    cnt[A[i]]++;
  }

  if (used.size() > 3){
    No(); return 0;
  }
  if (used.size() == 1){
    if (used[0] == 0) Yes();
    else No();
    return 0;
  }
  if (N % 3 != 0){
    No(); return 0;
  }
  if (used.size() == 2){
    if (cnt[0] * 3 == N) Yes();
    else No();
    return 0;
  }

  ll res = 0;
  for (int i = 0; i < 3; i++){
    res ^= used[i];
    if (cnt[used[i]] * 3 != N){
      No(); return 0;
    }
  }
  if (res == 0) Yes();
  else No();

  return 0;
}


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

int main(){
  int x;
  cin >> x;
  if(x>=30)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3628