akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    string s; cin >> s;
    if(s=="hi" || s=="hihi" || s=="hihihi" || s=="hihihihi" || s=="hihihihihi") cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main() {
  int n,m;
  cin >> n >> m;
  UnionFind uf(n); //引数は頂点数
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;b--;
    uf.unite(a,b);
  }
  int ans = 0;
  rep(i,n) ans = max(ans,uf.size(i));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4052
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int m;
	scanf("%d",&m);
	if(n%m==0)
	printf("0\n");
	else
	printf("1\n");
	for(int i=0;i<n;i++)
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1000000007;
const int inv2=500000004;
char s[5050];
int dp[2][5050];
int main()
{
	int n,l,now,to;
	scanf("%d",&n);
	scanf("%s",s);
	l=strlen(s);
	memset(dp,0,sizeof(dp));
	now=0;
	to=1;
	dp[now][0]=1;
	for(int i=0;i<n;i++)
	{
		dp[to][1]=((long long)dp[now][0]*2+dp[to][1])%mod;
		(dp[to][0]+=dp[now][0])%=mod;
		dp[now][0]=0;
		for(int j=1;j<=i;j++)
			if(dp[now][j])
			{
				dp[to][j+1]=((long long)dp[now][j]*2+dp[to][j+1])%mod;
				(dp[to][j-1]+=dp[now][j])%=mod;
				dp[now][j]=0;
			}
		swap(now,to);
	}
	int ans=dp[now][l];
	for(int i=0;i<l;i++)
		ans=(long long)ans*inv2%mod;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <stack>
#include <cmath>
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
using namespace std;
//
const int inf=1e9+7;
const int mod=1e9+7;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
ll GCD(ll a,ll b){
	return (b==0)?(a):(GCD(b,a%b));
}
ll LCM(ll a,ll b){
	return a/GCD(a,b)*b;
}
//
//
int main(){
	int W,H,N;
	cin>>W>>H>>N;
	vector<pair<int,int> > V(N);
	pair<int,int> cnt[100000];
	fill(cnt,cnt+W,make_pair(-1,-1));
	FOR(i,0,N){
		int X,Y;
		cin>>X>>Y;
		if(cnt[X].first<Y){
			cnt[X]=make_pair(Y,i);
		}
		V[i]=make_pair(X,Y);
	}
	vector<pair<int,int> > vv;
	FOR(i,0,W){
		if(cnt[i].first!=-1){
			vv.push_back(V[cnt[i].second]);
		}
	}
	sort(vv.rbegin(),vv.rend());
	int now=-1;
	vector<pair<int,int> > v;
	FOR(i,0,vv.size()){
		if(now<vv[i].second){
			v.push_back(vv[i]);
			now=vv[i].second;
		}
	}
	reverse(v.begin(),v.end());
	if((int)v.size()==1){
		cout<<min(v[0].first,v[0].second)<<endl;
	}else{
		int ans=min(v[0].second,v[v.size()-1].first);
		FOR(i,0,v.size()-1){
			ans=min(ans,v[i].first+v[i+1].second);
		}
		cout<<ans<<endl;
	}
	return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<int(n);i++)
#define all(a)  (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using Pint = pair<int, int>;
const ll mod = 1e9+7;

int main()
{
  int n;
  string s, t;

  cin>>n;
  cin>>s>>t;

  rep(i,s.size()) {
    cout<<s[i]<<t[i];
  }
  cout<<endl;

  return 0;
}

Measured memory_bytes: 3588
N=int(input())
A=[]
B=[]
for n in range(N):
    a,b=map(int,input().strip().split())
    A.append(a)
    B.append((b,n))

B=sorted(B)

sumA=0
fin=True
for n in range(N):
    tmp=B[n][1]
    sumA+=A[tmp]
    if sumA>B[n][0]:
        fin=False
        break

if fin==True:
    print("Yes")
else:
    print("No")


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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def bisearch_max(mn, mx, func):
    """ 条件を満たす最大値を見つける二分探索 """

    ok = mn
    ng = mx
    while ok+1 < ng:
        mid = (ok+ng) // 2
        if func(mid):
            # 上を探しに行く
            ok = mid
        else:
            # 下を探しに行く
            ng = mid
    return ok

T1, T2 = MAP()
A1, A2 = MAP()
B1, B2 = MAP()

# a,bの状態からT1,T2の操作を行った後のa,bと、この操作での交差回数を返す
def calc(a, b):
    cnt = 0
    a1 = a + T1 * A1
    b1 = b + T1 * B1
    if a > b and a1 <= b1 or a < b and a1 >= b1:
        cnt += 1
    a2 = a1 + T2 * A2
    b2 = b1 + T2 * B2
    if a1 > b1 and a2 <= b2 or a1 < b1 and a2 >= b2:
        cnt += 1
    return a2, b2, cnt

# x+1回目の操作でまだ交差するか
def check(x):
    a = (T1 * A1 + T2 * A2) * x
    b = (T1 * B1 + T2 * B2) * x
    _, _, cnt = calc(a, b)
    return cnt >= 1

# 初回で同値に飛んだらその先もずっと繰り返す
a, b, cnt = calc(0, 0)
if a == b:
    print('infinity')
    exit()

# 最後に交差する直前までの操作回数を調べる
res = bisearch_max(-1, 10**18, check)
# 初回でも交差しなければ0
if res == -1:
    print(0)
    exit()

# 直前までの操作では、初回は1回、以降は2回ずつ交差する
ans = max(0, res * 2 - 1)
# 最後に交差する直前までa,bを移動させる
a = (T1 * A1 + T2 * A2) * res
b = (T1 * B1 + T2 * B2) * res
# 最後が1回か2回か確認
_, _, cnt = calc(a, b)
ans += cnt
print(ans)


Measured memory_bytes: 38384
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<string>
#include<cstring>
#include<list>
using namespace std;
typedef vector<int>VI;
typedef vector<VI>VVI;
typedef vector<string>VS;
typedef pair<int,int>PII;
typedef long long LL;
typedef pair<LL,LL>PLL;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define PB push_back
#define EACH(i,c) for(typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define F first
#define S second


bool check(int S){
    for(int x=1;2*x*(x+1)<=S;x++){
        if((S-x)%(2*x+1)==0)return true;
    }
    return false;
}



int main(){
    int N;
    cin>>N;
    int cnt=0;
    while(N--){
        int S;
        cin>>S;
        if(!check(S))cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 1164
#include <iostream>

using namespace std;

void dfs(int n) 
{
    if (n != 0) {
        dfs(n / 4);
        cout << n % 4;
    }        
}

int main()
{
    int n;

    while (cin >> n, n != -1) {
        if (n == 0)
            cout << 0;
        else
            dfs(n);
        cout << endl;
    }

    return 0;
}

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

#define ll long long

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	if(k <= a)
		cout << k;
	else if(k <= a+b)
		cout << a;
	else
		cout << a - (k-(a+b));
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
#include<cassert>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

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

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

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

int main() {
	ll N;
	cin >> N;
	vector<bool> D(N,0);
	rep(i, N) {
		ll a, b;
		cin >> a >> b;
		if (a == b) { D[i] = 1; }
	}

	rep(i, N - 2) {
		if (D[i] && D[i + 1] && D[i + 2]) { cout << "Yes" << endl; return 0; }
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.OptionalInt;
import java.util.regex.Pattern;
import java.util.stream.Stream;

public class Main {
  public static void main(String[] args) {

    new Main().run();
  }

  public void run() {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String line = br.readLine();
      final Pattern delim = Pattern.compile("\\s");
      int[] arrayS = delim
        .splitAsStream(line)
        .mapToInt(Integer::parseInt)
        .toArray();

      OptionalInt max =
        Arrays.stream(arrayS).max();

      dispIntArray( countingSort(arrayS, max.getAsInt()) );
    }
    catch ( IOException e ) {
      System.out.println("IOException!");
    }

  }

  public int[] countingSort(int[] a, int k) {

    int   aLength = a.length;
    int[] result  = new int[aLength];
    int[] counter = new int[k+1];

    for (int var : a) {
      counter[var]++;
    }

    for (int i=1, max=k+1; i < max; i++) {
      counter[i] += counter[i-1];
    }

    for (int i=aLength-1, val=0; i>=0; i--) {
      val = a[i];
      result[counter[val]-1] = val;
      counter[val]--;
    }

    return result;
  }

  public void dispIntArray(int[] target) {
    StringBuilder s = new StringBuilder();

    for (int i : target) { s.append(i).append(" "); }
    s.setLength(s.length()-1);

    System.out.println(s);
  }
}


Measured memory_bytes: 168940
import sys


def main():
    # input = sys.stdin.readline
    S = list(input())
    rev = list(reversed(S))

    count = 0

    for i in range(len(S)):
        if S[i] != rev[i]:
            count += 1

    print(count//2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <stdio.h>

int main(void){
	int n, k, x, y, cost;
	
	scanf("%d\n%d\n%d\n%d", &n, &k, &x, &y);
	
	if(n > k){
		cost = k*x+(n-k)*y;
	} else{
		cost = n*x;
	}
	
	printf("%d\n", cost);
	
	return 0;
}	


Measured memory_bytes: 128
from operator import lt

def main():
    N = int(input())
    A = list(input().split(' '))

    Ab = bubbleSort(A[:], N, lambda a, b: int(a[1]) < int(b[1]))
    As = selectionSort(A[:], N, lambda a, b: int(a[1]) < int(b[1]))

    print(' '.join([str(a) for a in Ab]))
    print('Stable')

    print(' '.join([str(a) for a in As]))
    print('Stable' if Ab == As else 'Not stable')

def bubbleSort(A, N, comp=lt):
    flag = True

    while flag:
        flag = False

        for j in range(N-1, 0, -1):
            if comp(A[j], A[j-1]):
                A[j], A[j-1] = A[j-1], A[j]
                flag = True

    return A

def selectionSort(A, N, comp=lt):
    for i in range(0, N-1):
        minj = i

        for j in range(i, N):
            if comp(A[j], A[minj]):
                minj = j

        if i != minj:
            A[i], A[minj] = A[minj], A[i]

    return A

if __name__ == '__main__':
    main()

Measured memory_bytes: 7828
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int ans = 0;
        for (int i = 0; i < n; i++) {
            // 1行ずつ数字取得
        	int a = sc.nextInt();
			int b = sc.nextInt();
			
			ans = ans + b - a + 1;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 25452
#!ruby -pal
$c={}
def f l,*a
a[0]?($c[a.sort<<l]||=a.map{f(*a.rotate!)+(4*a[0]*l)**0.5}.min):l
end
m,*r=$F.map &:to_i
$_=r.any?{f(*r.rotate!)+r[0]<=m}?:OK:"NA"

Measured memory_bytes: 7796
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


//E 
int main(){FIN

    ll n;cin>>n;
    int sm=0;
    vector<int> a(n); 
    REP(i,n) {
        cin>>a[i];
        sm =sm^a[i];
    }
    REP(i,n){
        a[i]=sm^a[i];
        cout<<a[i]<<' ';
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3932
#!/usr/bin/env python3
# -*- coding: utf-8 -*-



def main():
    A, B = map(int, input().split())

    A = 14 if A == 1 else A
    B = 14 if B == 1 else B

    if A == B:
        print("Draw")
    elif A > B:
        print("Alice")
    else:
        print("Bob")

if __name__ == "__main__": main()


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;

signed main(){
  int n;
  cin>>n;
  vector<int> a(n);
  vector<int> ch(101,0);
  for(int i=0;i<n;i++){
    cin>>a[i];
    ch[a[i]]++;
  }
  sort(a.begin(),a.end(),greater<int>());
  if(a[0]%2==0){
    bool f=true;
    int sum=0;
    for(int i=a[0]/2+1;i<=a[0];i++){
      if(ch[i]<2)f=false;
      sum+=ch[i];
    }
    if(f&&sum==n-1&&ch[a[0]/2]==1)cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
    return 0;
  }else{
    bool f=true;
    int sum=0;
    for(int i=a[0]/2+1;i<=a[0];i++){
      if(ch[i]<2)f=false;
      sum+=ch[i];
    }
    if(f&&sum==n&&ch[a[0]/2+1]==2)cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
    return 0;
  }
}


Measured memory_bytes: 256
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.ST                 as ST
import qualified Data.Array.Unboxed            as AU
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Foldable                 as DF
import           Data.Int
import qualified Data.IntMap                   as IM
import           Data.List
import qualified Data.Map                      as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                      as S
import qualified Data.Sequence                 as SQ
import           Data.Time
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
readInts n = replicateM n readInt
readString = map BS.unpack . BS.words <$> BS.getLine
readStrings n = replicateM n <$> readString
toPair [x, y] = (x, y)

main = do
  [n, m] <- readInt
  print $ solve n m

solve n m = f n + f m

f n | n < 2     = 0
    | otherwise = (n * (n - 1)) `div` 2


Measured memory_bytes: 380
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+1
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

string S,T;
string dp[2][3001];

string max(string A, string B, string C){
	if(A.size() >= B.size() && A.size() >= C.size()) return A;
	if(B.size() >= C.size()) return B;
	return C;
}

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

	cin >> S >> T;
    for(int i=0; i<=1; i++) dp[i][T.size()] = "";
    for(int j=0; j<=T.size(); j++) dp[S.size()%2][j] = "";
    for(int i=S.size()-1; i>=0; i--){
        for(int j=T.size()-1; j>=0; j--){
            dp[i%2][j] = max(dp[(i+1)%2][j], dp[i%2][j+1], S[i]==T[j] ? S[i]+dp[(i+1)%2][j+1] : "");
        }
    }
    cout << dp[0][0] << endl;

	return 0;
}

Measured memory_bytes: 4864
#include <stdio.h>
 
int main()
{
  int a=0,n,i;
  scanf("%d",&n);
  int x = n;
  for(i=0;i<=8;i+=1){
    a += n%10;
    n = n/10;
  }
  if(x%a==0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
using namespace std;

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

	vector<long long> v;
	int num;
	long long total = 0;
	for (int i = 0; i < N; i++) {
		cin >> num;
		total += num;
		v.push_back(num);
	}

	long long  m = LLONG_MAX;
	long long  x = 0;
	for (int i = 0; i < N - 1; i++) {
		x += v[i];

		if ( x > total - x)
			m = min(m, x - (total - x));
		else
			m = min(m, (total - x) - x);
//		cout << x << ' ' << m << endl;
	}

	cout << m << endl;

	return 0;

}

Measured memory_bytes: 2420
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

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

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pld;
typedef pair<string, string> pss;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define tab                         '\t'
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

inline ll input() {
    ll n;
    cin >> n;
    return n;
}

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

set_random;

const ll MAXN = 3010;
const ll INF = 8e18;
const ll MOD1 = 998244353;
const ll MOD2 = 1e9 + 7;
const ll MOD3 = 1e9 + 9;

ll n , m;
string s , t , ans;
pair<ll , pll> dp[MAXN][MAXN];

int main() {
    fast_io;

    cin >> s >> t;
    n = s.size();
    m = t.size();
    s = "." + s;
    t = "." + t;

    for(ll i = 1 ; i <= n ; i++)
    {
        for(ll j = 1 ; j <= m ; j++)
        {
            dp[i][j] = max(dp[i][j] , {dp[i][j - 1].X , {i , j - 1}});
            dp[i][j] = max(dp[i][j] , {dp[i - 1][j].X , {i - 1 , j}});
            dp[i][j] = max(dp[i][j] , {dp[i - 1][j - 1].X + (s[i] == t[j]) , {i - 1 , j - 1}});
        }
    }

    ll x = n , y = m;
    while(dp[x][y].X != 0)
    {
        if(dp[x][y].Y == pll({x - 1 , y - 1}) && s[x] == t[y])
        {
            ans = string(1 , s[x]) + ans;
            x--;
            y--;
        }
        else
        {
            pll p = dp[x][y].Y;
            x = p.X;
            y = p.Y;
        }
    }
    cout << ans << endl;

    return 0;
}
/*
todo :
    1- set constants
    2- check TimeLimit and MemoryLimit
    3- check special test cases
    4- don't forget BS can help you that is good idea(use for loop for floats)
    5- don't forget printf and scanf can help you in your code speed
*/


Measured memory_bytes: 211968
#include<stdio.h>

int main(void)
{
	int S;
	int h,m,s;

	scanf("%d",&S);

	h=S/3600;

	m=(S%3600)/60;

	s=(S%3600)%60;

	printf("%d:%d:%d\n",h,m,s);

	return 0;
}

Measured memory_bytes: 2704
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
bool is_not_out_of_range(size_t now, size_t max_num)
{
	return !(now < 0 || max_num <= now);
}
int main()
{
	int n;
	cin >> n;
	vector<map<char, int>> v(n);
	rep(i, n)
	{
		str tmp;
		cin >> tmp;
		rep(j, tmp.size())
		{
			v[i][tmp.at(j)]++;
		}
	}
	str ans = "";
	for (char a = 'a'; a <= 'z';)
	{
		bool is_push_back = true;
		rep(i, n)
		{
			if (v[i][a] == 0)
			{
				is_push_back = false;
				a++;
				break;
			}
			else
			{
				v[i][a]--;
			}
		}
		if (is_push_back)
		{
			ans.push_back(a);
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int T;
  cin >> T;
  for (int t=0; t<T; t++) {
    int m, n;
    cin >> m >> n;
    int count = 0;
    for (int p=-200; p<200; p++) {
      for (int q=-200; q<200; q++) {
	if (p == 0 && q == 0) continue;
	int c = p*p+q*q;
	if ((p*m+q*n + c*20000)%c == 0 && (p*n-q*m + c*20000)%c == 0) count++;
      }
    }
    cout << (count == 8 ? 'P' : 'C') << endl;
  }
}

Measured memory_bytes: 1152
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
    auto N = readln.split.to!(uint[])[0];
    //writeln(countB(12, 25));
    writeln(iota(1,N+1).map!( x => countB(x,N) ).sum());
}

uint countB(uint A, uint N) {
    auto hA = head(A), tA = tail(A);
    if (tA == 0) return 0;
    
    string h = to!string(hA), t = to!string(tA);
    uint result;
    
    if (hA == tA) result++;
    auto th = t~h;
    if ( parse!uint(th) <= N ) result++;
    
    auto d = digit(N);
    auto hN = head(N), tN = tail(N);
    if (digit(N) <= 2) return result;
    uint center = ( N - hN*10^^(d-1) - tN ) / 10;
    
    if      ( hN >  tA )         result += 10^^(d-2);
    else if ( hN == tA )
             if ( tN >= hA )     result += center+1;
             else                result += center;
    else                         {}
    
    result += iota(1,d-2).map!(x => 10^^x).sum();
    
    return result;
}

uint countZeros(string a, string b, uint N) {
    uint result;
    
    string ab = a ~ b;
    if (parse!uint(ab) <= N) result++;
    else return 0;
    
    for (uint i=1; ; i++) {
        string a_zeros_b = a ~ "0".repeat(i).reduce!"a~b" ~ b;
        if ( parse!uint(a_zeros_b) <= N ) result++;
        else break;
    }
    return result;
}

uint tail(uint n) {
    return n%10;
}

uint head(uint n) {
    if (n<10) return n;
    else return head(n/10);
}

uint digit(uint n) {
    if (n<10) return 1;
    else return digit(n/10) + 1;
}

Measured memory_bytes: 1276
def solve():
    N,M = map(int,input().split())
    res = [None]*N
    for _ in range(M):
        s,c = map(int,input().split())
        if res[s-1] is not None and res[s-1] != c:
            return -1
        res[s-1] = c

    if N > 1 and res[0] == 0:
        return -1
    else:
        if res[0] is None:
            res[0] = 1 if N > 1 else 0
        for i in range(1,N):
            if res[i] is None:
                res[i] = 0
        return ''.join(map(str,res))

print(solve())

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

int main(void){

  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  for (int i=0; i<N; i++) cin >> a[i];

  sort((a).begin(), (a).end());
  int count = 0;
  for (int i=0; i<N-1; i++){
    x -= a[i];
    if(x >= 0) count++; 
    else break;
  }
  if(x - a[N-1] ==0) count++;
  
  cout << count << "\n";
}


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

int main() {
  vector<char> vec(3);
  cin >> vec.at(0) >> vec.at(1) >> vec.at(2);
  
  if(vec.at(0) == vec.at(1) && vec.at(1) == vec.at(2)) {
    cout << "No" << endl;
  }
  
  else cout << "Yes" << endl;
}
 



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int x; cin >> x;
  int r = 8;
  for (int i = 600; i<= 1800; i += 200) {
    if (x < i) {
      break;
    }
    r--;
  }
  cout << r << endl;
  return 0;
}


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

const int mod = 1000000007;
void go(int &a){
	a = (a % mod + mod) % mod;
}

int ver[100010], nxt[400010], to[400010], d[400010], tot;
void addedge(int from, int t, int dist){
	nxt[++tot] = ver[from];
	to[tot] = t;
	d[tot] = dist;
	ver[from] = tot;
}

struct Inf{
	int vertex;long long dist;
	Inf(int v=0,long long d=0):vertex(v), dist(d){}
};
bool operator < (const Inf& a , const Inf& b){
	return a.dist > b.dist;
}
priority_queue<Inf> heap;

int n, m;

bool flag[100010];long long d1[100010], d2[100010];
int g1[100010], g2[100010];

void dijkstra(int source, long long dist[], int g[]){
	for(int i = 1 ; i <= n ; i++)
		flag[i] = false, dist[i] = 1e18;
	heap.push(Inf(source, 0));
	dist[source] = 0;
	g[source] = 1;
	while(!heap.empty()){
		auto now = heap.top();heap.pop();
		if(flag[now.vertex])continue;
		flag[now.vertex] = true;
		for(int i = ver[now.vertex] ; i ; i = nxt[i]){
			if(dist[now.vertex] + d[i] < dist[to[i]]){
				dist[to[i]] = dist[now.vertex] + d[i];
				g[to[i]] = g[now.vertex];
				heap.push(Inf(to[i], dist[to[i]]));
			}
			else if(dist[now.vertex] + d[i] == dist[to[i]]){
				g[to[i]] += g[now.vertex];
				go(g[to[i]]);
			}
		}
	}
}


int s, t;



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

	for(int i = 1 ; i <= m ; i++){
		int u, v, d;
		scanf("%d%d%d" , &u , &v , &d);
		addedge(u, v, d);
		addedge(v, u, d);
	}

	dijkstra(s, d1, g1);
	dijkstra(t, d2, g2);

	long long shortest_path = d1[t];

	int ans = (long long)g1[t] * g2[s] % mod;

	for(int i = 1 ; i <= n ; i++){
		// meet at the node
		if(d1[i] != d2[i])continue;

		// printf("meet at node %d\n", i);

		int n1 = (long long)g1[i] * g2[i] % mod;

		int now = (long long)n1 * n1 % mod;
		ans -= now;
		go(ans);
	}

	for(int i = 1 ; i <= n ; i++){
		for(int _ = ver[i] ; _ ; _ = nxt[_]){
			if(d1[i] + d[_] + d2[to[_]] == shortest_path){

				if(d1[i] + d[_] > d2[to[_]] && d2[to[_]] + d[_] > d1[i]){

					// printf("meet at <%d,%d>\n", i, to[_]);

					int n1 = (long long)g1[i] * g2[to[_]] % mod;

					ans -= (long long)n1 * n1 % mod;
					go(ans);
				}
			}
		}
	}

	printf("%d\n" , ans);

	return 0;
}

Measured memory_bytes: 9456
import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    int k = Integer.parseInt(sc.next());
    int n = Integer.parseInt(sc.next());
    int[] a = new int[n];
    for(int i = 0 ; i < n ; i++){
      a[i] = Integer.parseInt(sc.next());
    }
      Arrays.sort(a);
  int max = 0;
    for(int i = 0 ; i < n ; i++){
      int meter = 0;
      if(i != n - 1)
      meter = Math.abs(a[i] - a[i + 1]);
        else
          meter = k - Math.abs(a[i] - a[0]);
      if(max < meter)
        max = meter;
    }
  System.out.println(k - max);
    }
      
      
      
}

Measured memory_bytes: 51136
import java.util.*

fun main(args: Array<String>) {
    val cin = Scanner(System.`in`)
    val N = cin.nextInt()
    val K = cin.nextInt()
    val L = emptyList<Int>().toMutableList()
    (0 until N).forEach {
        L.add(cin.nextInt())
    }
    val M = L.sorted().reversed()
    var out = 0
    (0 until K).forEach {
        out += M[it]
    }
    println(out)
}

Measured memory_bytes: 34000
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=[0 for i in range (N)]
counter=0
for i in range(N):  
    counter+=min(A[N-i]+A[N-1-i],B[N-1-i]) 
    if B[N-1-i]>A[N-i]:       
      A[N-1-i]=max(A[N-1-i]-B[N-1-i]+A[N-i],0)
print(counter)

Measured memory_bytes: 18624
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

B = Counter(A)
Key = list(B.keys())
Key.sort()

M = 10 ** 6
table = [1] * (M + 1)
cnt = 0
for k in Key:
    if B[k] == 1 and table[k] == 1:
        cnt += 1
    
    for i in range(M):
        if k * i > M:
            break
        else:
            table[k * i] = 0
print(cnt)

Measured memory_bytes: 134708
#include<stdio.h>
#include<stdlib.h>

struct node{
    struct node *right;
    struct node *left;
    struct node *parent;
    int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insert(int k){
    Node y = NIL;
    Node x = root;
    Node z;
    
    z = malloc(sizeof(struct node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    
    while(x!=NIL){
        y=x;
        if(z->key < x->key){
            x=x->left;
        }
        else x=x->right;
    }
    z->parent=y;
    if(y==NIL) root=z;
    else if(z->key<y->key) y->left=z;
    else y->right=z;
}



void inorder(Node u){
    if(u->left!=NIL){
        inorder(u->left);
    }
    printf(" %d",u->key);
    
    if(u->right!=NIL){
        inorder(u->right);
    }
}

void preorder(Node u){
    printf(" %d",u->key);
    
    if(u->left!=NIL){
        preorder(u->left);
    }
    if(u->right!=NIL){
        preorder(u->right);
    }
    
}


int main(){
    int n, i, x;
    char com[20];
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
        scanf("%s", com);
        if ( com[0] == 'i' ){
            scanf("%d", &x);
            insert(x);
        } else if ( com[0] == 'p' ){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    
    return 0;
}

Measured memory_bytes: 24036
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define int long long
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 1e5 + 10 ;
const ll INF = 1e18 + 10 ;
vector<int> ans ; 
int d(int x){
    int cnt = 0 ; 
    while(x != 0){
        x /= 10 ; 
        cnt++ ; 
    }
    return cnt ; 
}
void gen(int x, int len){
    if ( d(x) > len ) return ;
    if ( d(x) == len ){
        ans.push_back(x) ; 
        return ;
    }
    if ( x == 0 ){
        for(int i = 1; i < 10; i++){
            gen(10 * x + i, len) ; 
        }
    }
    else{
        int lastDigit = x % 10 ; 
        if ( lastDigit == 0 ){
            gen(10 * x, len) ; 
            gen(10 * x + 1, len) ; 
        }
        else if ( lastDigit == 9 ){
            gen(10 * x + 8, len) ; 
            gen(10 * x + 9, len) ; 
        }
        else{
            for(int i = lastDigit - 1; i <= lastDigit + 1; i++){
                gen(10 * x + i, len);
            }
        }
    }
}
signed main(){
    fastio 
    for(int i = 1; i <= 10; i++){
        gen(0, i);
    }
    int k ; 
    cin >> k ; 
    cout << ans[k - 1] << endl;
    return 0 ; 
}

Measured memory_bytes: 2420
line = input()
line = line.split(" ")
S = line[0]
T = line[1]
line = input()
line = line.split(" ")
A = int(line[0])
B = int(line[1])
U = input()
if U == S:
	A-=1
else:
	B-=1
print("{} {}".format(A,B))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007
int n, k;
map<int, int>m1;

bool is_possible(int n)
{
	while (n > 0)
	{
		int x = n % 10;
		n /= 10;
		if (m1[x] > 0)
		{
			return false;
		}
	}
	return true;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________



	cin >> n >> k;
	int d[k];

	zip(i, 0, k)
	{
		cin >> d[i];
		m1[d[i]]++;
	}
	int min_number;
	rep(i, 0, 9)
	{
		if (m1[i] == 0)
		{
			min_number = i;
			break;
		}
	}
	string s = to_string(n);
	string t = s;
	int n1 = s.size();
	int var = 0;
	while (1)
	{
		if (is_possible(n))
			break;
		else
		{
			n++;
		}

	}
	cout << n << en;
	//cout << m1[1] << en;
	// zip(i, 0, n1)
	// {
	// 	int x = s[i] - '0';
	// 	// if (i == 0)
	// 	// {
	// 	// 	cout << x << en;
	// 	// }
	// 	if (m1[x] > 0 && var == 0)
	// 	{
	// 		while (m1[x] > 0)
	// 		{
	// 			x++;
	// 		}
	// 		s[i] = char(x + '0');
	// 		var++;
	// 	}
	// 	else if (var > 0 && m1[x] > 0)
	// 	{
	// 		s[i] = char(min_number + '0');
	// 	}
	// 	if(i==n-1&&s==t&&m1[x]>0)
	// 	{

	// 	}

	// 	// else if (m1[x] == 0 && var == 0 && i == n1 - 1)
	// 	// {
	// 	// 	x++;
	// 	// 	while (m1[x] > 0)
	// 	// 	{
	// 	// 		x++;
	// 	// 	}
	// 	// 	s[i] = char(x + '0');
	// 	// }
	// }
	//cout << s << en;

	return 0;
}



Measured memory_bytes: 3664
H,W = map(int,input().split())

def split2(h,w):
    if h%2==0 or w%2==0:
        return h*w//2,h*w//2
    else:
        h,w = max(h,w),min(h,w)
        return h//2*w,(h+1)//2*w

ans = H*W
for i in range(1,H):
    h = H-i
    w = W
    s1 = W*i
    s2,s3 = split2(h,w)
    ans = min(max(s1,s2,s3)-min(s1,s2,s3),ans)

for i in range(1,W):
    h = H
    w = W-i
    s1 = H*i
    s2,s3 = split2(h,w)
    ans = min(max(s1,s2,s3)-min(s1,s2,s3),ans)

print(ans)

Measured memory_bytes: 43888
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define inc(a) scanf("%c", &(a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
int main(void){
    ll alph[26]={0};
    char S[100100];
    ins(S);
    rep(i, strlen(S)) alph[S[i]-'a']++;
    rep(i, 26){
        if(!alph[i]){
            putchar('a'+i);
            return 0;
        }
    }
    puts("None");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int a[9],n,b,c[9];
    for(int i=0;i<9;i++){
        cin >> a[i];
    }
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> b;
        for(int j=0;j<9;j++){
            if(a[j]==b){
                c[j]=1;
            }
        }
    }
    string ans="No";
    for(int i=0;i<3;i++){
        if(c[0+i*3]==1&&c[1+i*3]==1&&c[2+i*3]==1) ans="Yes";
        else if(c[0+i]==1&&c[3+i]==1&&c[6+i]==1) ans="Yes";
    }
    if(c[0]==1&&c[4]==1&&c[8]==1) ans="Yes";
    else if(c[2]==1&&c[4]==1&&c[6]==1) ans="Yes";
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    ll N; cin >> N;
    int ans = 0;
    while(N != 1) {
        ll d = N / 3, m = N % 3;
        ans++;
        N = d + (m > 0);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3124
#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) {
    
    

    int n;
    cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    bool ch=true;
    rep(i,n){
        if(v[i]%2==0){
            if(v[i]%3!=0&&v[i]%5!=0){
                ch=false;
            }
        }
    }
    if(ch){
        fin("APPROVED");
    } else {
        fin("DENIED");
    }
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <iostream>
#include <deque>
#include <functional>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

using namespace std;

// #define int long long

#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

#define debug(x) cerr << #x << ": " << x << endl;

const int MOD = 1e9 + 7;

signed main(void)
{
  int num;
  int n;
  cin >> n;
  int k;
  cin >> k;
  num = 0;
  for (int i = 0; i < n; ++i)
  {
    int h;
    cin >> h;
    if (h >= k)
      ++num;
  }

  cout << num << endl;
}


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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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;
}

struct Edge {
	ll to, cap, rev, col;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


void solve(){
    ll n;
    cin>>n;
    Graph g(n);
    REP(i,n-1){
        ll a,b;
        cin>>a>>b;
        a--;b--;
        add_edge(g,a,b,true,1,true);
    }
    ll k;
    cin>>k;
    Array p(n,-1);
    int s=0;
    Array l(n,-INF);
    Array r(n,INF);
    Array odd(n,0);
    REP(i,k){
        ll v,pp;
        cin>>v>>pp;
        v--;
        p[v]=pp;
        s=v;
        l[v]=pp;
        r[v]=pp;
        if(pp%2) odd[v]=1;
    }


    auto dfs = [&](auto &&self, int v, int pre)->bool{
        for(auto e:g[v]){
            if(e.to==pre) continue;
            if(p[e.to]!=-1){
                if(odd[v]==odd[e.to]) return false;
                l[e.to]=max(l[v]-1,l[e.to]);
                r[e.to]=min(r[v]+1,r[e.to]);
                if(l[e.to]>r[e.to]) return false;//範囲外
            }else{
                odd[e.to]=!odd[v];
                l[e.to]=max(l[v]-1, l[e.to]);
                r[e.to]=min(r[v]+1, r[e.to]);
                if(l[e.to]>r[e.to]) return false;//範囲外
            }
            if(self(self,e.to,v)){
                l[v]=max(l[v], l[e.to]-1);
                r[v]=min(r[v], r[e.to]+1);
                if(l[v]>r[v]) return false;
            }else{
                return false;
            }
        }
        return true;
    };
    dfs(dfs,s,-1);
    if(dfs(dfs,s,-1)){
        cout<<"Yes"<<en;
        REP(i,n) cout<<r[i]<<en;
    }else{
        cout<<"No"<<en;
        return;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 19456
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1LL<<60;
const ll mod = 1e9 + 7;
 
int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}
 
ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}
 
ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}
 
double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}
 
 
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
 
 
///////////////////////////////////////////////////////////////////////////////////

int main(){
    int s;
    cin >> s;
    ll ans = 0;
    ll dp[2100];
    dp[3] = 1;
    for (int i = 4;i <= s;i++){
        dp[i] = (dp[i-1] + dp[i-3]) % mod;
    }
    
    cout << dp[s] << endl;
}

Measured memory_bytes: 3592