akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)((x).size())
#define mp make_pair

using namespace std;

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

template<class U,class T>ostream& operator<<(ostream& out, pair<U,T> & P){
    return out << "[" << P.first << ", " << P.second << "]";
}
template<class T>ostream& operator<<(ostream& out, vector<T> & V){
    if(!V.empty())out << "[";
    for(int i = 0; i < sz(V); i++)out << V[i] << (i+1==sz(V)?"]":", ");
    return out;
}

vector<ll> V;
ll mod = 1e9+7;

ll mypow(ll a, ll p){
    ll res = 1;
    for(;p;p>>=1, (a*=a)%=mod)
        if(p&1)(res*=a)%=mod;
    return res;
}

ll inverse(ll a){
    return mypow(a,mod-2);
}

int primes[1000001];

vector<ll> p;
bool remember[1000001];

void init(){
    bool used[1000001] {};
    for(int i = 2; i < 1000001; i++){
        if(!used[i]) p.push_back(i), remember[i] = 1;
        for(int j = i*2; j < 1000001; j+=i)used[j] = 1;
    }
}

void factor(ll a){
    if(remember[a]){
        primes[a] = max(primes[a],1);
        remember[a] = 1;
        return;
    }
    int i = 0, br = 0;
    while(a>1) {
        if(a%p[i]==0){
            a/=p[i];
            br++;
        }
        else {
            primes[p[i]] = max(primes[p[i]], br);
            i++;
            br = 0;
            if(remember[a]){
                primes[a] = max(primes[a],1);
                return;
            }
        }
    }
    primes[p[i]] = max(primes[p[i]], br);
}

int main(){
    ios_base::sync_with_stdio(false);
    int N;
    cin >> N;
    init();
    V.resize(N);
    for(auto& i: V)cin >> i, factor(i);


    ll lcm = 1, res = 0;
    for(int i = 2; i < 1000001; i++){
        if(primes[i])
            lcm *= mypow(i, primes[i]), lcm%=mod;
    }
    for(int i = 0; i < N; i++){
        res += (lcm * inverse(V[i]))%mod;
        res%=mod;
    }
    cout << res << endl;
}

Measured memory_bytes: 6388
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char in[60];
char target[100]="AKIHABARA";
int main(){
	scanf("%s",in);
	int at=0;
	for(int i=0;i<9;i++){
		if(in[at]==target[i]){
			at++;continue;
		}
		if(target[i]=='A')continue;
		printf("NO\n");return 0;
	}
	if(strlen(in)==at)printf("YES\n");
	else printf("NO\n");
}

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

const int N = 7;

char s[N][N];

int main(){
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    for (int i = 0; i < n; ++ i){
        scanf("%s", s[i]);
    }
    int cnt = 0;
    for (int i = 0; i < 1 << n; ++ i){
        for (int j = 0; j < 1 << m; ++ j){
            int ccnt = 0;
            for (int u = 0; u < n; ++ u){
                for (int v = 0; v < m; ++ v){
                    if (i >> u & 1){
                        continue;
                    }
                    if (j >> v & 1){
                        continue;
                    }
                    ccnt += s[u][v] == '#';
                }
            }
            cnt += ccnt == k;
        }
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 3836
#include "bits/stdc++.h"
using namespace std ;

int w[100005] , v[100005] ;
long long  dp[100005][101];
int main(){
	int N , W ;
	cin >> N >> W ;
	for( int i = 1 ; i <= N ; i++ ){
		cin >> w[i] >> v[i] ;
	}
	for( int i = 1 ; i <= W ; i++  ){
		for( int j = 1 ; j <= N ; j++  ){
			dp[i][j] = dp[i][j-1] ;
			if( i - w[j] >= 0 ) dp[i][j] = max(dp[i][j],v[j]+dp[i-w[j]][j-1]);
			// if( i == 3 && j == 3 ) cout << v[j] << " " << dp[i-w[j]][j-1] << max(dp[i][j-1] ,(v[j]+dp[i-w[j]][j-1])) << endl ;
			// cout << dp[i][j] << " " ;
		}
		// cout << endl ;
	}
	cout << dp[W][N] << endl ;


	return 0 ;
}

Measured memory_bytes: 79104
#include<stdio.h>
#include<math.h>
int main(){
	int step,i;
	double Cos,Sin,turnAngle;
	double _turnAngle=0;
	double angle=90;
	double p[2]={0};
	for(i=0;scanf("%d,%lf",&step,&turnAngle)&& (step||turnAngle) ;i++){
		angle=(angle-_turnAngle);
		p[0]+=(( double)step)*cos((angle*M_PI)/180.0);
		p[1]+=(( double)step)*sin((angle*M_PI)/180.0);
		_turnAngle=turnAngle;
	}
	printf("%d\n%d\n",(int)p[0],(int)p[1]);
	return 0;
}

Measured memory_bytes: 0
N, K = map(int, input().split())
oknums = set(range(10)) - set(map(int, input().split()))

def can(ans):
	digits = map(int, list(str(ans)))
	for d in digits:
		if not d in oknums:
			return False
	return True

ans = N
while True:
	if can(ans):
		print(ans)
		break
	ans += 1

Measured memory_bytes: 3064
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]

INF = pow(10, 9)

    #cur: 棒の番号 0~N-1

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a,b,c) > 0 else INF
    ret0 = dfs(cur+1, a, b, c)
    ret1 = dfs(cur+1, a + l[cur], b, c) + 10
    ret2 = dfs(cur+1, a, b + l[cur], c) + 10
    ret3 = dfs(cur+1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0,0,0,0))


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

int main(){
    int n;
    cin >> n;
    vector<ll> L(n+1);
    L[0] = 2; L[1] = 1;
    for(int i=2; i<=n; i++) L[i]=0;
    for(int i=2; i<=n; i++){
        L[i] = L[i-1] + L[i-2];
    }
    cout << L[n] << endl;
    return 0;
}

Measured memory_bytes: 3608
def main():
  n = int(input())
  hs = tuple(map(int, input().split()))

  a, b = 0, abs(hs[1] - hs[0])

  for i in range(2, n):
    d1 = a + abs(hs[i] - hs[i-2])
    d2 = b + abs(hs[i] - hs[i-1])
    a, b = b, d1 if d1 <= d2 else d2

  print(b)

if __name__ == "__main__":
  main()

Measured memory_bytes: 14184
/***
        ***Fresher***
    Md Mahfujur Rahman Khan(So..a;)
    Dept. of CSE
    CSE-28 Batch
    JU-48 Batch
    Jahangirnagar University

    FSTREAM10573

***/
#include<iostream>
#include<fstream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<array>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<numeric>
#include<utility>
using namespace std;
/***PAIR***/
#define pll pair<ll,ll>
#define pcl pair<char,ll>
#define psl pair<string, ll>
#define pls pair<ll,string>
#define plc pair<ll, char>
/***MAP***/
#define mll map<ll,ll>
#define msl map<string, ll>
#define mls map<ll, string>
#define mlb map<ll,bool>
#define msb map<string,bool>
#define mcl map<char, ll>
/***VECTOR***/
#define vl vector<ll>
/*** FAST ***/
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/***FUNCTIONS AND MACROS***/
#define IT_ ::iterator
#define F first
#define S second
#define M_P(x, y) make_pair(x, y)
#define PB(v,x) v.push_back(x)
#define PP(x) push(x)
#define RSZ(a , n) a.resize(n)
#define POB pop_back()
#define P_ pop()
#define CL_ clear()
#define LEN(s,cst) (cst)s.length()
#define SZ(s, a) (ll)s.size()
#define CNT(x) count(x)
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second
#define B_ begin()
#define E_ end()
#define F_ front()
#define t_ top()
#define IN(s, a) s.insert(a)
#define ER_  erase
#define GT(x) getline(cin , x)
#define NL_   "\n"
#define SP_ " "
#define R_0 return 0
#define R_ return

#define ul unsigned long long int
#define ll long long int
/***
//bit prime
#define most_prime_loop 1001
#define most_prime_number 1000010
#define prime_MAX_arr 1000010/64 +1
ll PRIME[prime_MAX_arr];
void Set(ll n){ll m= n%64;n/=64;ll x = 1;x <<=m;PRIME[n] |=x;return ;}
bool check(ll n){if(n==2) return true;if(n%2==0) return false;ll m= n%64;n/=64;ll x = 1;x <<=m;return !(x&PRIME[n]);}
void seivee(){fa(x, PRIME)x = 0;Set(2);for(ll i= 3; i <=most_prime_loop; i+=2){if(check(i)){for(ll j = i*i; j <=most_prime_number; j+=i){Set(j);}}}}
***/
#define TEST      ll test; cin >> test; while(test--)

/**template<typename T>inline T POW(T b, T p){T res = 1;while(p){if(p%2)res*=b;b*=b;p/=2;}return res;}**/

#define lcm(a, b) (a/__gcd(a,b))*b
#define INT(dp, v) memset(dp,v, sizeof(dp))
#define all(v) v.B_,v.E_
#define rall(v) v.rbegin(),v.rend()

#define fr(i ,a,  n) for( ll i = a; i <= n; i++)
#define fe(x, n) for( ll i = x; i <= n; i++)
#define fa(x,a)    for(auto &x : a)

#define mod(a) a%1000000007
#define pi acos(-1)
#define SFL(a) scanf("%lld",&a)
#define SFS(a) scanf("%s",&a)
//#define SFD(a) scanf("%lf",&a)
#define PFS(s) printf("%s",s)
#define PFL(s) printf("%lld",s)
#define PFC(s) printf("%c",s)
//#define PFD(s) printf("%lf",s)
#define UMP unordered_map


int main()
{
    FAST;
    int a, b;
    cin >> a >> b;
    if(a > 9 || b> 9) cout << -1;
    else cout << a *b;


}



Measured memory_bytes: 3652
#include<stdio.h>

typedef struct {
	char mark;
	int num;
}card;

void swap(card *a,card *b);
int partition(card A[], int p, int r);
void quickSort(card A[], int p, int r);

int partition(card A[], int p, int r){
	int x=A[r].num;
	int i=p-1,j;
	for(j=p;j<r;j++){
		if(A[j].num<=x){
			i++;
			swap(&(A[i]),&(A[j]));
		}
	}
	swap(&(A[i+1]),&(A[r]));
	return i+1;
}

void swap(card *a,card *b){
	card tmp;
	tmp=*a;
	*a=*b;
	*b=tmp;
}

void quickSort(card A[],int p,int r){
	if(p<r){
		int q = partition(A,p,r);
		quickSort(A,p,q-1);
		quickSort(A,q+1,r);
	}
}

int main(void){
	static card A[100000],copy[100000];
	int n,base;
	int i,j;
	char mark_checker[4],checker_crt,check_num;
	int s_flag=1;
	scanf("%d%*c",&n);
	for(i=0;i<n;i++){
		scanf("%c%d%*c",&(A[i].mark),&(A[i].num));
	}
	for(i=0;i<n;i++){
		copy[i]=A[i];
	}
	quickSort(A,0,n-1);
	for(i=0;i<n-1;i++){
		if(A[i].num==A[i+1].num){
			base=A[i].num;
			mark_checker[0]=A[i].mark;
			mark_checker[1]=A[i+1].mark;
			if(i+2<n && base==A[i+2].num){
				mark_checker[2]=A[i+2].mark;
				if(i+3<n && base==A[i+3].num){
					mark_checker[3]=A[i+3].mark;
					i=i+3;
					check_num=3;
				}else{
					i=i+2;
					check_num=3;
				}
			}else{
				i=i+1;
				check_num=2;
			}
			checker_crt=0;
			for(j=0;j<n;j++){
				if(copy[j].num==base){
					if(mark_checker[checker_crt++]!=copy[j].mark){
						s_flag=0;
					}
					if(checker_crt>check_num-1){
						break;
					}
				}
			}
		}
	}		
	if(s_flag){
		printf("Stable\n");
	}else{
		printf("Not stable\n");
	}	
	for(i=0;i<n;i++){
		printf("%c %d\n",A[i].mark,A[i].num);
	}
	return 0;
}

Measured memory_bytes: 2168
from sys import stdin
input = stdin.readline

def cumsum(xs):
    result = [xs[0]]
    for x in xs[1:]:
        result.append(result[-1] + x)
    return result

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

ans = 0
MOD = 1000000007
s = cumsum(list(reversed(a)))

for i in range(n-1):
    ans += a[i] * s[n-2-i] % MOD

ans = ans % MOD

print(ans)


Measured memory_bytes: 31436
// AtCoder Grand Contest 016
// D - XOR Replace

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;


const int MAX_N = 100000;

int N;
ll ab[2][MAX_N + 1];
multiset<ll> ms;
map<ll, vector<ll>> G;
map<ll, bool> visited;

void dfs(int v) {
    if (visited[v]) {
        return;
    }
    visited[v] = true;
    for (ll to : G[v]) {
        dfs(to);
    }
}

int main() {

    ll x;
    int ans;

    cin >> N;
    for (int j = 0; j < 2; j++) {
        x = 0;
        for (int i = 0; i < N; i++) {
            cin >> ab[j][i];
            x = x ^ ab[j][i];
        }
        ab[j][N] = x;
    }

    for (int i = 0; i <= N; i++) {
        ms.insert(ab[0][i]);
    }
    for (int i = 0; i <= N; i++) {
        auto itr = ms.find(ab[1][i]);
        if (itr == ms.end()) {
            cout << -1 << endl;
            return 0;
        }
        ms.erase(itr);
    }

    ans = 0;
    for (int i = 0; i <= N; i++) {
        if (i != N && ab[0][i] == ab[1][i]) {
            continue;
        }
        ans++;
        G[ab[0][i]].push_back(ab[1][i]);
    }

    for (auto &kv : G) {
        ll v = kv.first;
        if (visited[v]) {
            continue;
        }
        ans++;
        dfs(v);
    }
    ans = max(0, ans - 2);
    cout << ans << endl;

    return 0;

}





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

#define INDEX 1001

int main(void) {
  long long int x;
  scanf("%lld", &x);
  
  long long int num[INDEX];
  for (int i = 0; i < INDEX; i++) {
    num[i] = (long long int ) i * (long long int ) i * (long long int ) i * (long long int ) i * (long long int ) i; 
    // printf("%lld\n", num[i]);
  }

  int flag = 0;
  for (int i = 0; i < INDEX; i++) {
    for (int j = 0; j < INDEX; j++) {
      // printf("i, j: %d %d\n", i, j);
      if ((num[i] - num[j]) == x) {
        printf("%d %d\n", i, j);
        flag = 1;
        break;
      } else if ((num[i] + num[j]) == x) {
        printf("%d %d\n", i, (-1) * j);
        flag = 1;
        break;
      }
    }
    if (flag) break;
  }

  return 0;
}


Measured memory_bytes: 1740
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x; cin >> x;
  int rate[] = {600, 800, 1000, 1200, 1400, 1600, 1800, 2000};
  rep(i, 8) {
    if(x < rate[i]) {
      cout << 8-i << "\n";
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3644
#include <cstdio>
#include <cstdlib>

using namespace std;

const int N=1000010;
int n,a[N],p[N];
bool pd;

inline void re(int &x)
{
	x=0;
	bool flag=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') flag|=(ch=='-'),ch=getchar();
	while(ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	x=flag ? -x : x;
}

void divd(int x)
{
    int i;
    for(i=2;i*i<=x;i++)
    {
        if(x%i==0)
        {
            p[i]++;
            while(x%i==0) x/=i;
        }
    }
    if(x>1) p[x]++;
}

int gcd(int x,int y)
{
    if(y==0) return x;
    return gcd(y,x%y);
}

int main()
{
    int i;
    re(n);
    for(i=1;i<=n;i++)
    {
        re(a[i]);
        divd(a[i]);
    }
    for(i=1;i<=N-10;i++)
        if(p[i]>1) pd=1;
    if(!pd)
    {
        printf("pairwise coprime");
    }
    else
    {
        int g=a[1];
        for(i=2;i<=n;i++) g=gcd(g,a[i]);
        if(g==1) printf("setwise coprime");
        else printf("not coprime");
    }
    return 0;
}

Measured memory_bytes: 9328
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define forA(i,a,n,x) for(auto i=a;i<n;i+=x)
#define forD(i,a,n,x) for(auto i=n-1;i>=0;i-=x)
#define ranit(it,n) for(auto it:n)
#define testCases ll t;cin>>t;while(t--)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define init(a,x) memset(a,x,sizeof(a))

vll adj[100003]; ll visited[100003]; ll dp[100003];

ll solve(ll v)
{
	visited[v]=1;
	if(adj[v].size()==0)return 0;
	if(dp[v]!=-1)return dp[v];
	else
	{
		ll m=-1;
		ranit(it,adj[v])
		{m = max(solve(it),m);}
		return dp[v]=1+m;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
	init(dp,-1);
	ll n,m,u,v,ans=-1; cin>>n>>m; forA(i,0,m,1)cin>>u>>v,adj[u].pb(v);
	forA(i,1,n+1,1)
	{if(visited[i]==0)ans=max(ans,solve(i));}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 12624
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE LambdaCase #-}

module Main where

import qualified Data.ByteString.Char8 as B8
import Data.Maybe (fromJust)
import Data.Char (toUpper,isDigit)
import Data.List
import qualified Data.Map as M
import Data.Ix (range)
import Control.Monad
import Control.Applicative
import Text.Printf
import Data.Time.Calendar
import Debug.Trace

readDigits = map read <$> words <$> getLine :: IO [Int]
readDigits' = map read <$> lines <$> getContents :: IO [Int]

main = do
    [a,b,c] <- readDigits
    putStrLn $ case (a <= c && c <= b) of
        True -> "Yes"
        False -> "No"

Measured memory_bytes: 508
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
 
int main(){
  int n,c,k;
  cin >> n >> c >> k;
  vector<int> s(n);
  for(int i=0;i<n;i++){
  	cin >> s[i];
  }
  std:sort(s.begin(), s.end());
  
  int bus=0,time=0,passenger=0;
  for(auto it = s.begin();it !=s.end(); it++){
  	if(passenger==c){
      passenger=0;  
    }
    if(*it - time>k){
      passenger=0;
    }
    if(passenger==0){  
      time= *it;
      bus=bus+1;
    }      
    passenger++;
  }
  cout << bus << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int ans=1;
    int temp=1;
    while(temp<=n){
        temp*=2;
        if(temp<=n){
            ans=temp;
        }
    }
    
    cout<<ans<<endl;
    return 0;
}

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

ans = ''
stack_neg = []
stack_pos_neg = []
pos_neg_flag = True
ans_flag = False
answer_list = []

A = sorted(A)

while A:
    tmp = A.pop()
    
    if not ans_flag:
        ans = tmp
        ans_flag = True
        continue
        
    if ans_flag and ans < 0 and tmp >= 0:
        tmp2 = ans
        ans = tmp
        tmp = tmp2
    
    if tmp >= 0 and pos_neg_flag and ans_flag:
        stack_pos_neg.append(tmp)

    elif tmp < 0 and pos_neg_flag:
        stack_pos_neg.append(tmp)

        while stack_pos_neg:
            a = stack_pos_neg.pop()
            if not stack_pos_neg:
                stack_pos_neg.append(a)
                pos_neg_flag = False
                break
            b = stack_pos_neg.pop()
            answer_list.append((a, b))
            stack_pos_neg.append(a - b)

    elif tmp >= 0 and not pos_neg_flag:
        a = stack_pos_neg.pop()
        answer_list.append((a, tmp))
        stack_pos_neg.append(a - tmp)

    elif tmp < 0 and not pos_neg_flag:
        stack_neg.append(tmp)
        
if pos_neg_flag:
    stack_pos_neg.append(ans)
    stack_pos = sorted(stack_pos_neg)
    
    ans = stack_pos.pop()
    
    if stack_pos:
        target = stack_pos.pop(0)
    while stack_pos:
        tmp = stack_pos.pop()
        answer_list.append((target, tmp))
        target = target - tmp
    answer_list.append((ans, target))
    ans = ans - target

else:
    tmp = stack_pos_neg.pop()
    answer_list.append((ans, tmp))
    ans = ans - tmp
    
    while stack_neg:
        tmp = stack_neg.pop()
        answer_list.append((ans, tmp))
        ans = ans - tmp

print(ans)

if N != 1:
    for answer in answer_list:
        i, j = answer
        print(i, j)

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

int main() {
	int a, b;
	cin >> a >> b;

	if (a == b) {
		cout << "Draw" << endl;
	}
	else if (a == 1) {
		cout << "Alice" << endl;
	}
	else if (b == 1) {
		cout << "Bob" << endl;
	}
	else if (a < b) {
		cout << "Bob" << endl;
	}
	else if (a > b) {
		cout << "Alice" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Map;
import java.util.HashMap;

public class Main
{
    String[] p = new String[3];
    
    public static void main(String args[])
    {
	new Main().solve();
    }
    
    void solve()
    {
	in();

	char[] abc = {'A', 'B', 'C'};

	int t = 0;
	while(p[t].length() > 0) {
	    char c = p[t].charAt(0);
	    p[t] = p[t].substring(1, p[t].length());
	    if(c == 'a') t = 0;
	    if(c == 'b') t = 1;
	    if(c == 'c') t = 2;
	}

	out(abc[t]);
    }

    void in()
    {
	Scanner sc = new Scanner(System.in);
	p[0] = sc.next();
	p[1] = sc.next();
	p[2] = sc.next();
    }

    void out()
    {
	
    }
    
    void out(int n)
    {
	System.out.println(n);
    }

    void out(double n)
    {
	System.out.println(n);
    }

    void out(long n)
    {
	System.out.println(n);
    }
    
    void out(char c)
    {
	System.out.println(c);
    }
    
    void out(String s)
    {
	System.out.println(s);
    }
}


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

typedef long long LL;

const int N = 1010;

int x[N], y[N];

int main() {
    int n, t = -1; scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d%d", &x[i], &y[i]);
        int wkr = abs(x[i] + y[i]) & 1;
        if (t == -1) t = wkr;
        else if (t != wkr) { return puts("-1"), 0; }
    }
    if (!t) for (int i = 1; i <= n; i++) y[i]--;
    int m = (t == 0) + 1, nw = 1;
    for (int i = 1; i <= n; i++) {
        int wkr = abs(x[i] + y[i]);
        while (wkr > (LL)nw * 2 - 1) nw *= 2, m++;
    }
    int tp = m - (t == 0);
    cout << m << endl;
    for (int i = 1; i <= m; i++) printf("%d ", max(1, nw >> (i - 1)));
    puts("");
    for (int i = 1; i <= n; i++) {
        int tx = 0, ty = 0;
        for (int j = 1; j <= tp; j++) {
            int step = nw >> (j - 1), dx = x[i] - tx, dy = y[i] - ty;
            if (abs(dy) > abs(dx)) {
                if (dy > 0) ty += step, putchar('U');
                else ty -= step, putchar('D'); 
            } else {
                if (dx > 0) tx += step, putchar('R');
                else tx -= step, putchar('L');
            }
        }
        if (tp != m) putchar('U');
        puts("");
    }
}

Measured memory_bytes: 3844
A = int(input())
B = int(input())
C = int(input())
X = int(input())

L = []

a = 0
b = 0
c = 0
count = 0

for i in range((X // 500) + 1):
    a = i
    for j in range(((X - 500 * i) // 100) + 1):
        b = j
        c = int((X - 500 * a - 100 * b) / 50)
        L.append([a, b, c])

for i in L:
    if i[0] <= A and i[1] <= B and i[2] <= C:
        count += 1

print(count)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define pii pair<int,int>
#define eb emplace_back
#define MOD 1000000007
#define int long long
using namespace std;
#define s second
#define f first

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n; cin >> n;
    int a[n];
    int sum = 0;
    for(auto& x:a)
    {
        cin >> x;
        sum += x;
    }
    int m;  cin>> m;
    pii b[m];
    for(auto& x:b)  cin >> x.f >> x.s;

    for(int i=0;i<m;i++)
    {
        cout << sum - a[b[i].f-1] + b[i].s << '\n';
    }
}

Measured memory_bytes: 3620
#pragma GCC compiler("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> v;
vector<ll> t;
int main(){
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  ios_base::sync_with_stdio(0);
  ll N;
  cin>>N;
  for(ll i=0;i<N;i++){
    ll p;
    cin>>p;
    v.push_back(p);
  }
  ll o=v[N/2]*2;
  for(ll i=N/2-1;i>=0;i--){
    o=(v[i]+v[N-i-1])*2-o;
  }
  ll s=o/2;
for(ll i=0;i<N;i++){
    cout<<s<<" ";
    s=2*v[i]-s;
  }
  return 0;
}


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

bool isprime(long long int x){
  if(x == 2) return true;
  if(x == 1 || x%2 == 0) return false;

  int i = 3, sq = sqrt(x);
  while(i<=sq){
    if(x%i == 0) return false;
    i+=2;
  }
  return true;
}

int main(){
  int n,cnt=0;
  cin >> n;

  for(int i=0;i<n;i++){
    long long int a;

    cin >> a;
    if(isprime(a))  cnt+=1;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 3136
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int t = sc.nextInt();
		int[] a = new int[t];
		for(int i = 0 ; i < t ; i++) a[i] = sc.nextInt();
		Arrays.sort(a);
		int min = a[t - 1];
		System.out.println(Math.max(min - 1 - (k - min), 0));
	}
}

Measured memory_bytes: 23764
require 'set'
h, w = gets.split.map(&:to_i)
a = (1..h).map { gets.split.map(&:to_i) }
pos = {}
(0..h-1).each do |i|
    (0..w-1).each do |j|
        pos[a[i][j]] = [i, j]
    end
end

goal = {}
(1..h*w).each do |k|
    i, j = pos[k]
    if i - 1 >= 0 and a[i-1][j] < k
        goal[k] ||= Set.new
        goal[k] += goal[a[i-1][j]]
    end
    if i + 1 < h and a[i+1][j] < k
        goal[k] ||= Set.new
        goal[k] += goal[a[i+1][j]]
    end
    if j - 1 >= 0 and a[i][j-1] < k
        goal[k] ||= Set.new
        goal[k] += goal[a[i][j-1]]
    end
    if j + 1 < w and a[i][j+1] < k
        goal[k] ||= Set.new
        goal[k] += goal[a[i][j+1]]
    end
    goal[k] ||= Set[k]
end

p goal.select {|_, v| v.size > 1}.size


Measured memory_bytes: 719012
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

int main(){
   ll n;
   cin>>n;
   ll ans=1000000000000000;
   for(int i=1;i<=sqrt(n);i++){
      if(i*ll(n/i)==n){
         ans=min(ans,i+n/i-2);
      }
   }
   cout<<ans;

return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

const std::vector<std::string> week{
    "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

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

    for (int i = 0; i < 7; ++i) {
        if (s == week[i]) {
            std::cout << 7 - i << std::endl;
            break;
        }
    }
    return 0;
}


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

int main()
{
    int N;
    cin >> N;
    int A, B;
    cin >> A >> B;
    for (int i = A; i <= B; i++)
    {
        if(i%N==0){
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define INF 1<<64
#define sf(a) scanf("%d",&a)
using namespace std;
int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
typedef pair<int,int> pii;
vector<pii> vii;
int n=0;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    int ans=0;
    for(int i=1;i<=n;i++){
        ans+=i;
    }
    cout << ans << endl;
return 0;
}


Measured memory_bytes: 764
#include<cstdio>
#include<algorithm>
const long long mod = 1e9+7;
long long f[201][100001];
int s[201];

int main(){
	int n,x;
	scanf("%d%d",&n,&x);
	for(int i = 1; i <= n; i++) scanf("%d",&s[i]);
	std::sort(s+1,s+1+n);
	for(int i = 0; i <= x; i++) f[1][i] = i%s[1];
	for(int i = 2; i <= n; i++){
		f[i][0] = 0;
		for(int j = 1; j <= x; j++){
			f[i][j] = f[i-1][j%s[i]] + (long long)(i-1)*f[i-1][j]%mod;
			if(f[i][j]>=mod) f[i][j] -= mod;
			//printf("f[%d][%d] = %lld\n",i,j,f[i][j]);
		}
	}
	printf("%lld\n",f[n][x]);
	return 0;
}


Measured memory_bytes: 156416
#include <stdio.h>

int main(void){
    int a, b, c;
    int tmp;

    scanf("%d %d %d", &a, &b, &c);

    if(b < c){
        tmp = c;
        c = b;
        b = tmp;
    }

    if(a < b){
        tmp = b;
        b = a;
        a = tmp;
    }

    printf("%d\n", 10*a + b + c);
    return 0;
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;

const double PI=acos(-1.0);

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

struct Coor
{
    int y;
    int x;
    int depth;
};


int main() {
    int h, w, gh, gw;
    cin >> h >> w;
    gh = h - 1, gw = w - 1;
    vector<string> g(h);
    rep(i, h) cin >> g[i];

    int black = 0;
    rep(i, h) rep(j, w) if(g[i][j] == '#') black++;

    Coor start = {0, 0, 0};

    queue<Coor> q;
    q.emplace(start);

    int cnt = 810;
    while(!q.empty()) {
        Coor now = q.front(); q.pop();
        int y = now.y, x = now.x, d = now.depth;

        if(y == gh && x == gw) cnt = d;

        rep(i, 4) {
            int ny = y + dy[i], nx = x + dx[i], nd = d + 1;
            Coor next = {ny, nx, nd};

            if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
            if(g[ny][nx] == '#') continue;

            g[ny][nx] = '#';
            q.emplace(next);
        }
    }

    cout << (cnt == 810 ? -1 : h * w - cnt - black - 1) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>

int main()
{
	long long x, k, d;
	std::cin >> x >> k >> d;
	
	if (x < 0) x = -x;
	if (x / d > k) {
		std::cout << x - d * k << std::endl;
		return 0;
	}
	k -= x / d;
	x %= d;
	if (k % 2 == 1) {
		x -= d;
	}
	
	std::cout << std::abs(x) << std::endl;
	
	return 0;
}


Measured memory_bytes: 3184
from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7


def inp(): return int(sys.stdin.readline())


def inpl(): return list(map(int, sys.stdin.readline().split()))


def inpl_str(): return list(sys.stdin.readline().split())


S = input()
N = len(S)
LS = S[:(N-1)//2]
RS = S[(N+1)//2:]

if S == S[::-1] and LS == LS[::-1] and RS == RS[::-1]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#define RET(ans) {cout<<ans<<endl;return 0;} 

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    string s; cin >> s;
    int n;
    cin >> n;
    int ss = s.size()/n;
    if(s.size()%n!=0)ss++;

    rep(i,ss){
        cout << s[i*n];
    }
    cout << endl;
    return 0;
}
 
 


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


int main(){
	int n;cin>>n;
  	vector<long long int> c(n);
  	long long int ans=0;
  	for(int i=0;i<n;i++){
    	int a,b;
      	cin>>a>>b;
      	c[i]=a+b;
      	ans-=b;
    }
  	sort(c.begin(),c.end());
  	reverse(c.begin(),c.end());
  	for(int i=0;i<n;i=i+2){
 		ans+=c[i];
    }
  	cout<<ans<<endl;  	
}
     

Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define enter putchar('\n')
#define space putchar(' ')
#define fi first
#define se second
//#define ivorysi
#define pii pair<int,int>
using namespace std;
typedef long long int64;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}

template<class T>
void out(T x) {
    if(x < 0) {putchar('-');x = -x;}
    if(x >= 10) out(x / 10);
    putchar('0' + x % 10);
}
int N;
int a[2][55][55],fa[2][55],used[55],ind[55],vis[55],ans;
struct node {
    int to,next;
}E[205];
int sumE,head[55];
void add(int u,int v) {
    E[++sumE].to = v;
    E[sumE].next = head[u];
    head[u] = sumE;
}
void dfs(int id,int u,int f) {
    fa[id][u] = f;if(id == 1) used[u] = (used[f] && (fa[0][u] == fa[1][u]));
    for(int i = 1 ; i <= N ; ++i) {
        if(i != f && a[id][u][i]) dfs(id,i,u);
    }
}
bool dfs2(int u) {
    vis[u] = 1;
    for(int i = head[u] ; i ; i = E[i].next) {
        int v = E[i].to;
        if(!vis[v]) {if(!dfs2(v)) return false;}
        else if(vis[v] == 1) return false;
    }
    vis[u] = 2;
    return true;
}
void check_r(int r) {
    used[0] = 1;
    dfs(0,r,0);dfs(1,r,0);
    memset(head,0,sizeof(head));sumE = 0;
    int s = 0;
    for(int i = 1 ; i <= N ; ++i) {
        if(!used[i]) {
            if(!used[fa[0][i]]) add(fa[0][i],i);
            if(!used[fa[1][i]]) add(i,fa[1][i]);
            ++s;
        }
    }
    memset(vis,0,sizeof(vis));
    for(int i = 1 ; i <= N ; ++i) {
        if(!vis[i] && !dfs2(i)) return;
    }
    ans = min(ans,s + 1);
}
void Solve() {
    read(N);
    memset(a,0,sizeof(a));
    memset(ind,0,sizeof(ind));
    int u,v;
    for(int i = 1 ; i < N ; ++i)  {
        read(u);read(v);
        a[0][u][v] = a[0][v][u] = 1;
        ind[u]++;ind[v]++;
    }
    for(int i = 1 ; i < N ; ++i) {
        read(u);read(v);
        a[1][u][v] = a[1][v][u] = 1;
    }
    used[0] = 1;
    dfs(0,1,0);dfs(1,1,0);
    int cnt = 0;
    for(int i = 1 ; i <= N ; ++i) {
        if(!used[i]) ++cnt;
    }
    if(!cnt) {puts("0");return;}
    ans = N + 1;
    for(int i = 1 ; i <= N ; ++i) {
        if(ind[i] == 1) {
            int f = 0;
            for(int j = 1 ; j <= N ; ++j) if(a[0][i][j]) f = j;
            a[0][i][f] = a[0][f][i] = 0;
            for(int j = 1 ; j <= N ; ++j) {
                a[0][i][j] = a[0][j][i] = 1;
                check_r(i);
                a[0][i][j] = a[0][j][i] = 0;
            }
            a[0][i][f] = a[0][f][i] = 1;
        }
    }
    if(ans == N + 1) {puts("-1");}
    else {out(ans);enter;}
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    int T;
    read(T);
    while(T--) {
        Solve();
    }
    return 0;
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())
s = input()
tuka = 0
br = 0
for i in range(n):
    if s[i] == 'a':
        if tuka < a+b:
            print('Yes')
            tuka += 1
        else:
            print('No')
    elif s[i] == 'b':
        if tuka < a+b and br < b:
            print('Yes')
            tuka += 1
            br += 1
        else:
            print('No')
            br += 1
    else:
        print('No')

Measured memory_bytes: 4024
n,l=[int(x) for x in input().rstrip().split()]
a=[i for i in range(l,l+n)]

if 0<=a[0]:
  print(sum(a)-a[0])
elif a[0]:
  if 0<=a[-1]:
    print(sum(a))
  else:
    print(sum(a)-a[-1])

Measured memory_bytes: 3060
#include<iostream>
#include<queue>
#include<vector>
#include<string>
#include<list>
#define ll long long
using namespace std;
int main() {
	list<char>str;
	char c;
	int n, k; cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		cin >> c;
		str.push_back(c);
	}
	int cnt = 0;
	for (auto itl = str.begin(); itl != str.end();) {
		if (cnt >= k) break;
		if (++itl == str.end()) break;
		--itl;
		if (*itl < *(++itl)) {
			itl = str.erase(--itl);
			if(itl!=str.begin()) --itl;
			++cnt;
		}
	}
	for (int i = 0; i < n - k; ++i) {
		cout << *str.begin();
		str.erase(str.begin());
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 9372
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
int solve(){
	int n,k;
	scanf("%d%d",&n,&k);
	for (;n%k!=0;){
		int v=n%k,dif=n/k+1;
		int T=v/dif+(v%dif!=0);
		n-=T*dif;
	}
	return n/k;
}
int main(){
	int T,ans=0;
	scanf("%d",&T);
	while (T--) ans^=solve();
	puts(ans?"Takahashi":"Aoki");
}

Measured memory_bytes: 384
from math import ceil
import bisect


N, D, A = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(N)]
L = [[pos, ceil(hp/A)] for pos, hp in L]
L = sorted(L, key=lambda pos: pos[0])

POS = [v[0] for v in L]
ES = [0]*(N+1)
ans, c = 0, 0
for i in range(N):
    c -= ES[i]
    if L[i][1] > c:
        t = L[i][1]-c
        ans += t
        c += t
        ES[bisect.bisect_right(POS, POS[i]+2*D)] += t
print(ans)


Measured memory_bytes: 124240
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
int main() {
  int r;
  cin >> r;
  cout << 3 * r * r << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	vector<int>vec(N);
	rep(i, 0, N)cin >> vec[i];
	unordered_map<int, int>mp;
	rep(i, 0, N) {
		mp[vec[i]]++;
		mp[vec[i] + 1]++;
		mp[vec[i] - 1]++;
	}
	int ans = 0;
	for (auto p : mp) {
		chmax(ans, p.second);
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 4644
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<stdio.h>
using namespace std;
 
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<25
 
int main()
{
	int a, b, c, s;
	cin >> s;
	a = s / 100 & 1;
	b = s / 10 & 1;
	c = s & 1;
	cout << a + b + c << endl;
	return 0;
}

Measured memory_bytes: 256
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        n: usize,
    }

    let mut s = std::collections::HashSet::new();

    for i in 1..1000001 {
        if i * i > n {
            break;
        }
        if (n - 1) % i == 0 {
            if i > 1 {
                s.insert(i);
            }
            if (n - 1) / i > 1 {
                s.insert((n - 1) / i);
            }
            continue;
        }
        if n % i == 0 {
            let mut nn = n;
            while nn % i == 0 {
                nn /= i;
            }
            if (nn - 1) % i == 0 {
                s.insert(i);
                continue;
            }
        }
    }
    println!("{}", s.len() + 1);
}


Measured memory_bytes: 4352
import numpy as np
from collections import defaultdict

N = int(input())
A = np.array(input().split(), dtype=np.int32)
total_medians = N*(N+1)//2
# n件のデータ
# (上側中央値 >= x) iff (a > x となる a が(n-1)//2以下)

def test(x):
  # 「答はx以下である」
  # 「xより真に大きな区間中央値が(total_medians-1)//2個以下」
  # xより真に大きな値を1、他を-1とする。
  # 1の個数が-1の個数以上になっている区間
  current = 0 # 累積和
  memo = defaultdict(int) # 過去の累積和の分布, incl empty
  memo[0] = 1
  cnt_below = 1 # sum memo[y] for y <= x
  result = 0
  for a in A:
    if a > x:
      current += 1
      cnt_below += memo[current]
    else:
      cnt_below -= memo[current]
      current -= 1
    result += cnt_below
    memo[current] += 1
    cnt_below += 1
  return result <= (total_medians-1)//2

AA = sorted(A)
left = -1 # 答はAA[left]より大きい
right = len(AA)-1 # 答はAA[right]以下である
while right - left > 1:
  mid = (left+right)//2
  if test(AA[mid]):
    right = mid
  else:
    left = mid
    
answer = AA[right]
print(answer)


Measured memory_bytes: 33728
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
	int n; cin>>n;
	vector<vector<int>> a(n,vector<int>(n));
	for(auto &i:a){
		for(auto &j:i) cin>>j;
	}
	vector<pair<int,int>> p;
	bool flg2{};
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			bool flg{1};
			for(int k=0; k<n; k++){
				if(i==j||j==k||k==i) continue;
				if(a.at(i).at(j)>a.at(i).at(k)+a.at(k).at(j)){
					flg2=1;
				}
				if(a.at(i).at(j)==a.at(i).at(k)+a.at(k).at(j)){
					flg=0;
				}
			}
			if(flg) p.push_back({i,j});
		}
	}
	if(flg2) {
		cout << -1 << endl;
		return 0;
	}
	ll sum{};
	for(auto i:p) sum += a.at(i.first).at(i.second);  
	cout << sum/2 << endl;
}



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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
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<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
  gearup;
  string s; cin >> s;
  int n = s.size();
  vl dp(n+100);
  dp[0] = 1;
  string t[4] = {"dream","dreamer","erase","eraser"};
  rep(i,n+10){
      if(dp[i]){
          rep(j,4){
              string s1 = s.substr(i,t[j].size());
              if(s1 == t[j]){
                  dp[i+t[j].size()] = 1;
              }
          }
      }
  }
  if(dp[n])out("YES");
  else out("NO");
}


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

int main(){
	long long n, a, b;
	cin >> n >> a >> b;
	
	cout << n/(a+b)*a + min(n%(a+b), a) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int i,j,k,n,m,l,a[100][100],b[100][100];
	long int c[100][100]={0};
	scanf("%d %d %d",&n,&m,&l);
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&a[i][j]);
		}
	}
	for(i=0;i<m;i++){
		for(j=0;j<l;j++){
			scanf("%d",&b[i][j]);
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			for(k=0;k<m;k++){
				c[i][j]+=a[i][k]*b[k][j];
			}
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			if(j>0){
				printf(" ");
			}
			printf("%ld",c[i][j]);
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2128
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n,x;
    cin>>n>>x;
    vector<int> v(n);
    rep(i,n) cin>>v[i];
    int ans = 1;
    int now = 0;
    rep(i,n){
        now+=v[i];
        if(now<=x){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

ll dp[51], ub[51];

void init() {
	dp[0] = 1; ub[0] = 1;
	for (int i = 0; i < 50; i++) {
		dp[i + 1] = dp[i] * 2 + 1;
		ub[i + 1] = ub[i] * 2 + 3;
	}
}

ll calc(ll n, ll x) {
	if (x <= 0) return 0;
	if (n == 0) return 1;
	if (x == ub[n - 1] + 1) return dp[n - 1];
	if (x >= ub[n - 1] + 1) return dp[n - 1] + 1 + calc(n - 1, x - ub[n - 1] - 2);
	return calc(n - 1, x - 1);
}

int main()
{
	init();
	ll N, X;
	cin >> N >> X;
	cout << calc(N, X) << endl;
	return 0;
}


Measured memory_bytes: 256