akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

ll three_base(ll num){
    ll ret = 0;
    ll d = 1;
    while(num){
        ret += num%4 * d;
        num /= 4;
        d *= 10;
    }

    return ret;
}

pair<ll, bool> convert_753(ll num){
    ll ret_first = 0;
    ll d = 1;
    bool three = false;
    bool five = false;
    bool seven = false;
    bool flg = true;
    while(num){
        ll n = num%10;
        if(n==1) {
            ret_first += 3*d;
            three = true;
        }
        else if(n==2) {
            ret_first += 5*d;
            five = true;
        }
        else if(n==3) {
            ret_first += 7*d;
            seven = true;
        }
        else flg = false;
        
        num /= 10;
        d *= 10;
    }

    pair<ll, bool> ret = make_pair(ret_first, (three && five && seven && flg));

    return ret;
}

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

    ll n;
    cin >> n;

    ll res = 0;
    ll base = 0;
    while(1){
        ll threed = three_base(base);
        pair<ll, bool> converted = convert_753(threed);

        if(converted.first>n) break;
        if(converted.second) ++res;
        // cout << converted.first << " " << converted.second << endl;
        ++base;
    }

    cout << res << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define oo 3005
using namespace std;
int n, m;
long long g[oo][oo], f[oo], ans, c[oo][oo];
inline long long fpow (long long x, int k, int mod)
{
    long long ret = 1;
    while(k) {if(k & 1) ret = ret * x % mod; k >>= 1; x = x * x % mod;}
    return ret;
}
void init ()
{
    for(int i = 0; i <= n; ++ i)
    c[i][0] = c[i][i] = 1;
    for(int i = 2; i <= n; ++ i)
    for(int j = 1; j < i; ++ j)
    c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % m;
}
int main ()
{
    scanf("%d%d", &n, &m); init();
    for(int i = 0; i <= n; ++ i) g[0][i] = 1;
    for(int i = 1; i <= n; ++ i)
    for(int j = i; j <= n; ++ j)
    g[i][j] = (g[i - 1][j - 1] + g[i][j - 1] * (i + 1)) % m;
    for(int i = 0; i <= n; ++ i)
    {
        long long p = fpow(2, fpow(2, n - i, m - 1), m);
        long long x = fpow(2, n - i, m), y = 1;
        for(int j = 0; j <= i; ++ j)
        (f[i] += g[j][i] * p % m * y) %= m, y = y * x % m;
    }
    for(int i = 0; i <= n; ++ i)
    {
        if(i & 1) (ans -= c[n][i] * f[i]) %= m;
        else (ans += c[n][i] * f[i]) %= m;
    }
    printf("%lld", (ans + m) % m); return 0;
}

Measured memory_bytes: 138112
#include <iostream>
using namespace std;
int main() {
  int a, i;
  while (cin >> a) {
    for (i = 0; i <= 9; i++) {
      if (a & 1 << i) {
        cout << (1 << i);
        if (a < 2 << i)
          break;
        cout << ' ';
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n, k, d;
    cin >> n >> k;
    vector<int> flag(n, 0);
    
    for(int i = 0; i < k; i++){
        cin >> d;
        vector<int> A(d);
        for(int j = 0; j < d;j++){
            cin >> A.at(j);
            flag.at(A.at(j)-1) = 1;
            // cout << A.at(j) << " ";    
        }
    }
    
    int ans = 0;
    
    for(int i = 0; i < n ; i ++){
        if(flag.at(i) == 0){
            ans++;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3608
def solve_145e():
    from collections import namedtuple
    from operator import attrgetter
    import sys
    input = sys.stdin.readline

    Food = namedtuple('Food', 'time_to_eat deliciousness')

    N, T = map(int, input().split())
    foods = []
    for _ in range(N):
        row = map(int, input().split())
        foods.append(Food(*row))
    foods.sort(key=attrgetter('time_to_eat'))
    # 同じ料理の組を食べるなら時間のかかるものを後回しにしても結果は悪くならない

    dp = [-1] * T
    dp[0] = 0
    # dp[time]:=timeに食べ終わる注文の仕方で得られる最大満足度

    ma = 0  # 回答候補
    ca = 0  # フィニッシュ前候補
    for food in foods:
        # これでフィニッシュの場合
        ma = max(ma, ca + food.deliciousness)

        # まだ食べる場合
        for time in range(T - 1 - food.time_to_eat, -1, -1):
            if ~dp[time]:
                when_eat = dp[time] + food.deliciousness
                if dp[time + food.time_to_eat] < when_eat:
                    dp[time + food.time_to_eat] = when_eat
                    ca = max(ca, when_eat)

    print(ma)
    return


if __name__ == '__main__':
    solve_145e()


Measured memory_bytes: 44524
n,m = gets.split.map(&:to_i)
matrix_a = []
matrix_b = []
n.times{matrix_a << gets.split.map(&:to_i)}
m.times{matrix_b << gets.to_i}

matrix_a.each do |line|
  result = 0
  ite_a = line.each
  ite_b = matrix_b.each
  m.times do
    a,b = ite_a.next,ite_b.next
    result += a * b
  end
  puts result
end



Measured memory_bytes: 9048
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#include<map>
#include<iostream>
#include<cmath>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;


int main(){
   int N,K;
   cin >> N >> K;
   vector<int> p(N);
   rep(i,N){
      cin >> p[i];
   }
   sort(p.begin(), p.end());
   int ans = 0;
   rep(i,K){
      ans += p[i];
   }
   cout << ans << endl;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <string.h>

int main(void)
{
	int out, base[3], n, i, j, point;
	char input[8];
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		out = 0;
		point = 0;
		for (j = 0; j < 3; j++){
			base[j] = 0;
		}
		
		while (1){
			scanf("%s", input);
			if (strcmp(input, "OUT") == 0){
				out++;
				if (out == 3){
					break;
				}
			}
			
			else if (strcmp(input, "HIT") == 0){
				if (base[2] == 1){
					base[2] = 0;
					point++;
				}
				for (j = 1; j >= 0; j--){
					base[j + 1] = base[j];
					base[j] = 0;
				}
				base[0] = 1;
				
				continue;
			}
			
			else if (strcmp(input, "HOMERUN") == 0){
				point++;
				for (j = 0; j < 3; j++){
					if (base[j] == 1){
						base[j] = 0;
						point++;
					}
				}
				
				continue;
			}
		}
		
		printf("%d\n", point);
	}
	
	return (0);
}

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

int main() {
  int N,M;
  cin>>N>>M;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin>>A.at(i);
  }
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  int sum =0;
  for(int i=0; i<N; i++){
    sum += A.at(i);
  }
  int ave =0;
  if(sum%(4*M)==0){
    ave =sum/(4*M) ;
  }
  else{
    ave = sum/(4*M)+1;
  }
  bool ans = true;
  for(int i=0; i<M; i++){
    if(A.at(i)<ave){
      ans = false;
    }
  }
  if(ans){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

int main() {
	int s,t,count=0;
	
	cin>>s;
	vector <int> sset(s);
	for(int i=0;i<s;i++){
		cin >> sset[i];
	}
	cin>>t;
	vector <int> tset(t);
	for(int i=0;i<t;i++){
		cin >> tset[i];
	}
	
	for(int i=0;i<t;i++){
		for(int j=0;j<s;j++){
			if(sset[j]==tset[i]){
				count++;
				break;
			}	
		}
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 3100
N = int(input())

# 1. n で始まり m で終わるN(2 * 10^5)以下の数をカウントしてテーブルを作る
# 2. table[n][m] * table[m][n] が条件を満たす組み合わせ
# 3. これを 1 <= n <= 9, 1 <= m <= 9 でループして足し合わせる

table = [[0] * 10 for _ in range(10)]

for i in range(1, N + 1):
  s = str(i)
  table[int(s[0])][int(s[-1])] += 1

total = 0

for n in range(1, 10):
  for m in range(1, 10):
    total += table[n][m] * table[m][n]
    
print(total)

Measured memory_bytes: 40428
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,N) for(int i=0;i<N;i++)

long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){

int N;
cin>>N;
string s;
cin>>s;

int right=0;
int left=0;
rep(i,N){
    if(s[i]==')'){
        if(left>0){
            left--;
        }
        else{
        right++;
        }
    }
    else{
        left++;
    }
}
//cout<<left<<" "<<right<<endl;

rep(i,right){
    cout<<'(';
}
cout<<s;
rep(i,left){
    cout<<')';
}
 return 0;
}
/*
3
())

(())

6
)))())

(((()))())

8
))))((((

(((())))(((())))
*/

Measured memory_bytes: 256
#include <cstdio>
const int MOD = 1000000007;
int a[200001],b[200001],fac[8001],ni[8001],f[4001][4001];
int n,x,y,p,q;
long long ans;

void read(int &k) {
    char c=getchar();
    while (c<48||c>57) c=getchar();
    k=0;
    while (c>=48&&c<=57) {
        k=k*10+c-48;
        c=getchar();
    }
}
int C(int n,int m) {
    return 1ll*fac[n]*ni[m]%MOD*ni[n-m]%MOD;
}
long long fun(long long a,int k) {
    long long s=1;
    while (k) {
        if (k&1) s=s*a%MOD;
        a=a*a%MOD;
        k>>=1;
    }
    return s;
}

int main() {
    fac[0]=1;
    for (long long i=1; i<=8000; ++i) fac[i]=fac[i-1]*i%MOD;

    ni[8000]=fun(fac[8000],MOD-2);
    for (long long i=7999; i>0; --i) ni[i]=ni[i+1]*(i+1)%MOD;

    read(n);
    for (int i=1; i<=n; ++i) {
        scanf("%d%d",&a[i],&b[i]);
        if (a[i]>x) x=a[i];
        if (b[i]>y) y=b[i];
        f[2000-a[i]][2000-b[i]]++;
    }

    for (int i=2000-x; i<=2000+x; ++i)
        for (int j=2000-y; j<=2000+y; ++j) {
            if (i>0) {
                p=f[i][j]+f[i-1][j];
                f[i][j]= p>=MOD ? p-MOD : p;
            }
            if (j>0) {
                p=f[i][j]+f[i][j-1];
                f[i][j]= p>=MOD ? p-MOD : p;
            }
        }

    for (int i=1; i<=n; ++i) {
        p=ans+f[2000+a[i]][2000+b[i]];
        ans = p>=MOD ? p-MOD : p;
        p=ans+MOD - C(a[i]+b[i]+a[i]+b[i],a[i]+a[i]);
        ans = p>=MOD ? p-MOD : p;
    }

    ans=ans*(MOD/2+1)%MOD;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 64256
def max(a,b) a>b ? a:b end

N=gets.to_i
A=N.times.map{gets.to_i}
b= A.sort.reverse
m1 = b[0]
m2 = b[1]
ans = Array.new(N)
N.times do |i|
  if A[i] == m1
    ans[i] = m2
  else
    ans[i] = m1
  end
end
puts ans.join(" ")

Measured memory_bytes: 9604
#include<bits/stdc++.h>
#define ll long long
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define swap(x,y) (x^=y^=x^=y)
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
#define MN 100005
#define mod 1000000007
int ans,x[MN],y[MN];
int cnt,a[MN],b[MN],B[MN],id[MN];
inline bool cmp(const int&o,const int&oo){return a[o]==a[oo]?b[o]<b[oo]:a[o]<a[oo];}
int t[MN],s[MN];
void C(int x,int v){for(;x<MN;x+=(x&-x))(t[x]+=v)%=mod;}
int G(int x){int r=0;for(;x;x-=(x&-x))(r+=t[x])%=mod;return r;}
int main()
{
	register int i,j,n,m;
	n=read(),m=read();
	for(i=1;i<=n;++i) x[i]=read();
	for(j=1;j<=m;++j) y[j]=read();
	std::sort(x+1,x+n+1);std::sort(y+1,y+m+1);
	for(i=1;i<=n;++i)
	{
		int p=std::lower_bound(y,y+m+1,x[i])-y;
		if(p<=1||p>m||x[i]==y[p]) continue;
		a[++cnt]=x[i]-y[p-1];B[cnt]=b[cnt]=y[p]-x[i];id[cnt]=cnt;
	}
	std::sort(B+1,B+cnt+1);
	int Bcnt=std::unique(B+1,B+cnt+1)-B-1;
	for(i=1;i<=cnt;i++) b[i]=std::lower_bound(B+1,B+Bcnt+1,b[i])-B;
	std::sort(id+1,id+cnt+1,cmp);
	for(i=1,j=1;i<=cnt;++i)
	{
		if(a[id[i]]==a[id[i-1]]&&b[id[i]]==b[id[i-1]]) continue;
		for(;a[id[j]]<a[id[i]];++j) if(a[id[j]]!=a[id[j-1]]||b[id[j]]!=b[id[j-1]]) C(b[id[j]],s[j]%mod);
		s[i]=1+G(b[id[i]]-1);
		(ans+=(s[i]%mod))%=mod;
	}
	printf("%d\n",ans+1);
	return 0;
}

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

using namespace std;

int n, m;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int temp;
		cin >> temp;
		n -= temp;
	}
	if (n < 0) cout << -1;
	else cout << n;

	return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<stdio.h>
#include<string>
#include <math.h>
using namespace std;
# define maxn 200000

int main(){
  int r,D,x[11];
  cin>>r>>D>>x[0];
  for (int i(0);i<10;i++){
    x[i+1]=x[i]*r-D;
    cout<<x[i+1]<<endl;
  }
  // int a,b;
  // cin>>a>>b;
  // if(a>=13){
  //   cout<<b;
  // }else if(a >=6){
  //   cout<<b/2;
  // }else{
  //   cout <<0;
  // }
  // long long a,b,x,cnt(0);
  // cin>>a>>b>>x;
  // cout<<(b/x)-(a/x);
  // int n,a[maxn],b[maxn],cnt(0),sum(0);
  // cin>>n;
  // for(int i(0);i<n;i++){
  //   cin>>a[i]>>b[i];
  // }
  // for(int i(0);i<n;i++){
  //   if(a[i]==b[i]){
  //     cout << -1<<endl;
  //   }else{
  //     cout << abs(a[i] - b[i])<<endl;
  //   }
  // }
  return 0;
}

Measured memory_bytes: 256
X = int(input())
i=2
j=2
l = []
if(X<=3):
	print(1)
else:
	while((i**j)<=X):
		while((i**j)<=X):
			l.append(i**j)
			j= j+1
		i= i+1
		j=2
	print(max(l))	

Measured memory_bytes: 3060
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
L = defaultdict(int)
R = defaultdict(int)
for i in range(N):
    L[i + A[i]] += 1
    R[i - A[i]] += 1

ans = 0
for k, v in L.items():
    ans += v * R[k]
print(ans)

Measured memory_bytes: 163700
"""
2, 4, 5, 7, 9 -> "hon"
0, 1, 6, 8 -> "pon"
3 -> "bon
"""
N = str(input())
list_hon = ["2", "4", "5", "7", "9"]
list_pon = ["0", "1", "6", "8"]
list_bon = ["3"]

N_1 = N[-1]

if N_1 in list_hon:
    print("hon")
elif N_1 in list_pon:
    print("pon")
else:
    print("bon")


Measured memory_bytes: 8968
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int sum = 0;
        for (int i = 0; i < N; i++) {
            sum += sc.nextInt() - 1;
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 25580
#include <stdio.h>

int main(void)
{
	int h;
	int w;
	int a;
	int b;
	
	while ((h != 0) || (w != 0)){
		scanf("%d %d", &h, &w);
		if ((h != 0) && (w != 0)){
			for (a = 1; a <= h; a++){
				printf("#");
				for (b = 2; b <= w; b++){
					printf("#");
				}
				printf("\n");
			}
			printf("\n");
		}
		else if ((h == 0) && (w == 0)){
			break;
		}
	}
	
	return (0);
}

Measured memory_bytes: 572
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# # input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
# mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

a, b = inpm()
ans = a - 2 * b
if(ans < 0):
    ans = 0
print(ans)


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

int N,M,d,p;
pair<int,int> prin[20000];
int main(){
	cin >> N >> M;
	while((N!=0)||(M!=0)) {
		for(int i=0; i<N; ++i) {
			cin >> d >> p;
			prin[i] = make_pair(-p,d);
		}
		sort(prin,prin+N);
		int money=prin[0].second;
		int k = 0;
		while(money <= M) {
			++k;
			if(k>N-1) break;
			money += prin[k].second;
		}
		if(money<=M) cout << 0 << endl;
		else {
			int ex = -prin[k].first * (money - M);
			for(int l=k+1; l<N; ++l) {
				ex += -prin[l].first * prin[l].second;
			}
			cout << ex << endl;
		}
		cin >> N >> M;
	}
}

Measured memory_bytes: 1320
let () =
    let s = "0" ^ (read_line ()) in
    let rec loop i acc =
        if i < 0 then acc else loop (i - 1) ((int_of_char s.[i] - int_of_char '0') :: acc)
    in

    let arr = Array.of_list (loop (String.length s - 1) []) in
    let sum = Array.fold_left (+) 0 arr in
    let rec loop i m a b =
        if i < 0 then m else
            let d = arr.(i) in
            if d < 5 || d = 5 && i > 0 && arr.(i - 1) < 5 then loop (i - 1) m a b else
                if i > 0 then (
                    if arr.(i - 1) = 9 then (
                        let rec loop2 i a =
                            if arr.(i - 1) = 9 then (
                                loop2 (i - 1) (a - 9) 
                            ) else (a, i)
                        in
                        let b = b + 10 - arr.(i) in
                        let a, i = loop2 i (a - arr.(i)) in
                        let a = a + 1 in
                        arr.(i - 1) <- arr.(i - 1) + 1;
                        let m = min m (a + b) in
                        loop (i - 1) m a b
                    ) else (
                        let a = a      - arr.(i) in
                        let b = b + 10 - arr.(i) in
                        let a = a + 1 in
                        arr.(i - 1) <- arr.(i - 1) + 1;
                        let m = min m (a + b) in
                        loop (i - 1) m a b
                    )
                ) else (
                        let a = a      - arr.(i) in
                        let b = b + 10 - arr.(i) in
                        let a = a + 1 in
                        let m = min m (a + b) in
                        loop (i - 1) m a b
                )
    in
    loop (Array.length arr - 1) sum sum 0 |> Printf.printf "%d\n"

Measured memory_bytes: 37116
import java.io.*;

 
public class Main {
 
	public static void main(String[] args) throws IOException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(bf.readLine());
		double [] array = new double[n+1];
		array[0] =1;
		String[] line2 = bf.readLine().split(" ");
		for( int i = 0; i < n; i++) {
			Double k = Double.parseDouble(line2[i]);
			for(int j = i+1 ;j >= 0; j--) {
				if( j == 0)
					array[j] = array[j]* (1-k);
				else
					array[j] = array[j-1]* k + array[j]* ((double)1-k);
			
			}
		}
		double fin = 0;
		for(int i = n/2 + 1; i <= n; i++)
			fin += array[i];
		System.out.println(fin);
	       
	}

}


Measured memory_bytes: 27848
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
/* テンプレートここまで */

int main() {
  ll n; cin >> n;
  vector<ll> a(n+1), b(n);
  REP(i,n+1) cin >> a[i];
  REP(i,n) cin >> b[i];

  ll ans = 0;
  REP(i,n){
    if(a[i] <= b[i]){
      ans += a[i];
      b[i] -= a[i];
      if(a[i+1] <= b[i]){
        ans += a[i+1];
        a[i+1] = 0;
      }else{
        ans += b[i];
        a[i+1] -= b[i];
      }
    }else{
      ans += b[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<string> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];

    int cc[26];
    fill(cc, cc+26, 1e9+1);
    for(int i = 0; i < n; i++) {
        for(char c = 'a'; c <= 'z'; c++) {
            cc[c-'a'] = min(cc[c-'a'], (int)count(v[i].begin(), v[i].end(), c));
        }
    }

    string ans;
    for(int i = 0; i < 26; i++) {
        ans += string(cc[i], (char)i + 'a');
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n,i;
    map<string,int>ma;
    map<string,int>::iterator it;
    set<string>st;
    string s;
    int maxi=0;
    cin>>n;
    it=ma.begin();
    for(i=0; i<n; i++)
    {
        cin>>s;
        ma[s]++;
    }
    for(it=ma.begin(); it!=ma.end(); it++)
    {
        if((it->second)>maxi)
        {
            maxi=it->second;
        }
    }
    for(it=ma.begin(); it!=ma.end(); it++)
    {
        if((it->second)==maxi)
        {
            st.insert(it->first);
        }
    }
    for(auto it=st.begin();it!=st.end();it++)
        cout<<*it<<endl;
    return 0;
}



Measured memory_bytes: 34560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ll N;
    cin >>N;
    
        ll fis,end;
        vector<ll>m(N,-1);
        rep(i,N){
            ll a;
            cin>>a;
            a--;
            if(m[a]==-1){
                m[a]=i;
            }else{
                fis=m[a];
                end=i;
            }
        }
    if(N!=1){
        COMinit();
        cout<<N<<endl;
        rep3(i,2,N+2){
            //cout<<"OK"<<endl;
            ll ans=(COM(N+1,i)-COM(N+1-(end-fis+1),i-1)+MOD)%MOD;
            //cout<<"OK2"<<endl;
            //cout<<COM(N+1,i)<<" "<<COM(N-(end-fis+1),i-1)<<endl;
            cout<<ans<<endl;
        }
    }else{
        cout<<1<<endl;
        cout<<1<<endl;
    }



    return 0;
    

}

Measured memory_bytes: 15920
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ff first
#define ss second
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

void Main() {
  int N;
  cin >> N;
  int a[N];
  rep(i, 0, N) { cin >> a[i]; }
  rep(i, 0, N) { int next = a[i]; }
  int next = 0;
  int cnt = 0;
  while (cnt < N) {
    cnt++;
    int button = a[next];
    next = button - 1;
    if (button == 2) {
      cout << cnt << endl;
      return;
    }
  }
  cout << -1 << endl;
}

int main() {
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15);  // 小数を10進数表示
  Main();
}

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

#define pb push_back
#define mp make_pair
#define ll long long int
#define all(x) x.begin(), x.end()

struct pair_hash {
  template <class T1, class T2>
  std::size_t operator()(const std::pair<T1, T2> &p) const {
    auto h1 = std::hash<T1>{}(p.first);
    auto h2 = std::hash<T2>{}(p.second);

    size_t seed = 2;
    seed ^= h1 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
    seed ^= h2 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
    return seed;
  }
};

unordered_map<int, int> color;
unordered_map<pair<int, int>, int, pair_hash> wts;

void dfs(int start, vector<vector<int>> &graph) {

  // already seen
  if (color.find(start) != color.end()) {
    return;
  }

  int child_color = -1;
  bool same_color = false;
  for (auto child : graph[start]) {

    if (color.find(child) != color.end()) {
      child_color = color[child];

      if (wts[mp(start, child)] % 2 == 0) {
        same_color = true;
        break;
      } else {
        same_color = false;
        break;
      }
    }
  }

  // assign
  if (child_color == -1) {
    color[start] = 0; // random
  } else if (same_color) {
    color[start] = child_color;
  } else {
    if (child_color == 1) {
      color[start] = 0;
    } else {
      color[start] = 1;
    }
  }

  // call on children
  for (auto child : graph[start]) {
    dfs(child, graph);
  }
}

void solve() {

  int n;
  cin >> n;

  vector<vector<int>> graph(n);
  for (int i = 0; i < n - 1; i++) {

    int u, v, w;
    cin >> u >> v >> w;

    u--;
    v--;

    wts[mp(u, v)] = w;
    wts[mp(v, u)] = w;

    graph[u].push_back(v);
    graph[v].push_back(u);
  }

  // start
  dfs(0, graph);

  for (int i = 0; i < n; i++) {
    cout << color[i] << "\n";
  }
}

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

  solve();
  return 0;
}

Measured memory_bytes: 24008
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    ll n,a,b;
    cin>>n>>a>>b;
    ll cnt=b-a-1;
    if(cnt%2==0){
        ll ans=min(b-1,n-a);
        ll x=a-1,y=n-b;
        //cout<<x<<' '<<y<<endl;
        if(cnt>=1){
            ll now=cnt-1;
            //cout<<now<<' '<<2*x+1+(now+1)/2<<endl;
            ans=min(ans,x+1+(now+1)/2);
        }
        if(cnt>=1){
            ll now=cnt-1;
            //cout<<now<<' '<<2*y+1+(now+1)/2<<endl;
            ans=min(ans,y+1+(now+1)/2);
        }
        cout<<ans<<endl;
    }else{
        cout<<(cnt+1)/2<<endl;
    }
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	int a, b, c, tmp=0;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);

	if (a > b){
		tmp = 0;
		tmp = b;
		b = a;
		a = tmp;
	}

	if (b > c){
		tmp = 0;
		tmp = c;
		c = b;
		b = tmp;
	}
	if (a > b){
		tmp = 0;
		tmp = b;
		b = a;
		a = tmp;

	}
	
	

	printf("%d %d %d\n", a, b, c);

	return 0;
}

Measured memory_bytes: 1024
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

int main(){
  const int n = getInt();
  int cnt = 0;
  REP(i,n) cnt += getInt() % 2;
  puts(cnt % 2 == 0 ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long

using namespace std;

ll n, a[100005], d[100005], mx1, mx2;
map<ll, int> m;

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        if (m[a[i]]) d[i] = 1;
        m[a[i]]++;
    }
    for (int i = 1; i <= n; i++)
        if (d[i] && a[i] > mx1) mx1 = a[i];
    if (m[mx1] >= 4)
        cout << mx1 * mx1 << endl;
    else {
        for (int i = 1; i <= n; i++)
            if (d[i] && a[i] != mx1 && a[i] > mx2) mx2 = a[i];
        cout << mx1 * mx2 << endl;
    }


	return 0;
}


Measured memory_bytes: 7424
n=int(input())
m=[]
M=[]
for _ in range(n):
    x,y=map(int,input().split())
    m.append(x)
    M.append(y)
m=sorted(m)
M=sorted(M)

z=n//2
if n%2==1:
    a=m[z]
    b=M[z]
    print(b-a+1)
else:
    a=m[z]+m[z-1]
    b=M[z]+M[z-1]
    print(b-a+1)

Measured memory_bytes: 27024
#include <stdio.h>
#include <math.h>

int main(int argc, char const *argv[]) {
  int n,k,o;
  scanf("%d\n%d", &n, &k);
  o = 1;
  for(int i = 0; i < n; i++) {
    o = fmin(o * 2, o + k);
  }
  printf("%d\n", o);
  return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {

	void solve() {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		if(x == 3 || x == 5 || x == 7) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		scan.close();
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}


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


int main(){
    long double M;
    int N;
    cin >> N >> M;
    int sum=0;
    vector<int>A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
        sum+=A[i];
    }

    int counter=0;
    long double num=1.0*sum/(4*M);
    for(int i=0;i<N;i++){
        if(A[i]>=num){
            counter++;
        }
    }
    if(counter>=M){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#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 << endl; }
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__) << "] "

using ll = long long;

const int nax = 105;
vector<int> w[nax];
int s[nax];
int m;
void add_edge(int a, int b) {
  ++m;
  w[a].push_back(b);
  w[b].push_back(a);
  s[a] += b;
  s[b] += a;
}

int main() {
  int n;
  scanf("%d", &n);
  for(int i = 1; i <= n; ++i) {
    for(int j = i + 1; j <= n; ++j) {
      if(i + j == n + (1 - n % 2)) {
        continue;
      }
      add_edge(i, j);
    }
  }
  printf("%d\n", m);
  for(int i = 1; i <= n; ++i) {
    for(int j : w[i]) {
      if(i < j) {
        printf("%d %d\n", i, j);
      }
    }
  }
  for(int i = 1; i <= n; ++i) {
    assert(s[i] == s[1]);
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define node first
#define weight second
#define MOD 1000000007
typedef pair <int, int> ii;

int cost(int a, int b)
{
	return (max(a,b) - min(a,b));
}

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef LOCAL_PROJECT
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	int n;
	cin >> n;
	int height[n+5], dp[n+5] = {(1LL<<62)};
	for(int i = 1; i <= n; i++)
		cin >> height[i];
	for(int i = 2; i <= n; i++)
		dp[i] = min(cost(height[i], height[i-1]) + dp[i-1], cost(height[i], height[i-2]) + dp[i-2]);
	cout << dp[n];
}

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

using namespace std;


#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VC vector<char>
#define VS vector<string>
#define VVS vector<vector<string>>



int main() {
	long long h, w;
	cin >> h >> w;
	if (h % 3 == 0 || w % 3 == 0) {
		cout << 0 << endl;
		return 0;
	}
	long long res = min(h, w);
	REP(i, h) {
		long long a = i * w;
		long long b = (h - i)*(w / 2);
		long long c = (h - i)*((w + 1) / 2);
		res = min(max({ abs(a - b),abs(b - c),abs(c - a) }),res);
	}
	swap(h, w);
	REP(i, h) {
		long long a = i * w;
		long long b = (h - i)*(w / 2);
		long long c = (h - i)*((w + 1) / 2);
		//cout << a << ' ' << b << ' ' << c << endl;
		res = min(max({ abs(a - b),abs(b - c),abs(c - a) }), res);
	}
	cout << res << endl;
	return 0;
}

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

/*----------------------------- DEFINES ------------------------------*/

#define eps 1e-9
#define mod 1000000007
#define ump unordered_map // operations take less time compared to map
#define pb push_back
#define pf push_front
#define pof pop_front()
#define pob pop_back()
#define mp make_pair
#define ps(x) push(x) // for stack and queue
#define T top() //  for stack
#define FR front()// for queue
#define BA back()// for queue
#define PP pop()// for queue and stack
#define B begin()
#define E end()
#define F first
#define S second
#define tostr(x) to_string(x)
#define SZ(x) ((int)x.size())
#define ins insert
#define MAE max_element
#define MIE min_element
#define cnt(x) count(x)
#define lb(x) lower_bound(x) // returns an it ptng to the element >=x if no such returns end
#define ub(x) upper_bound(x) // returns an it ptng to the element >x if no such returns end
#define rep(i,x,y) for(int i=x;i<y;i++)
#define per(i,x,y) for(int i=x;i>y;i--)
#define repi(i,x,y) for(int i=x;i<=y;i++)
#define peri(i,x,y) for(int i=x;i>=y;i--)
#define reps(i,x,y,k) for(int i=x;i<y;i+=k)
#define sper(i,x,y,k) for(int i=x;i>y;i-=k) 
#define all(x) ((x.B),(x.E))
#define inf (ll)LLONG_MAX
#define ds1(i,x) for(auto i=x.begin();i!=x.end();i++)
#define ds2(i,x) for(auto i:x) // easy method to iterate through a ds
#define sq(a) (a)*(a)
#define fib(n) ceil(pow((1+sqrt(5),n)-pow((1-sqrt(5),n)/(float)(pow(2,n)*sqrt(5)// compute fib(n) in O(1)
#define FIO {ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);}// fast i/o
#define dig(n) (int)(log10(n)+1) // num of digits
#define ss(x,k) substr(x,k)  // x is the start pos and k is the length of substr.
#define f(x) find(x)
#define set(x,k) memset(x,k,sizeof x)

/*------------------------------ TYPEDEFS-----------------------------*/

typedef long long ll;
typedef long l;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<pair<int,int> > vpii;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef ump<int,int> umpii;

/*-----------------------------START FROM HERE -----------------------*/

int main(){
	FIO
	
	str s;cin>>s;
	int i=0,j=SZ(s)-1;
	//int ans=0;
	rep(k,0,SZ(s))if(s[k]=='A'){i=k;break;}
	per(k,SZ(s)-1,-1)if(s[k]=='Z'){j=k;break;}
	cout<<j-i+1;
	return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=1;
	cin >>n;
	while(ans*2<=n){
		ans<<=1;
	}
	if(n==1){
		ans=1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys

r, c = [ int( val ) for val in sys.stdin.readline().split( " " ) ]
csums = [0]*c
rsum = 0
output = []
for k in range( r ):
	matrix = [ int( val ) for val in sys.stdin.readline().split( " " ) ]

	rsum = 0
	for i in range( c ):
		rsum += matrix[i]
		output.append( "{:d} ".format( matrix[i] ) )	
		csums[i] += matrix[i]
		
	output.append( "{:d}\n".format( rsum ) )

rsum = 0
for val in csums:
	rsum += val
	output.append( "{:d} ".format( val ) )	
	
output.append( "{:d}".format( rsum ) )
print( "".join( output ) )

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

map<int, vi> wonAgainst;

int getDepth(int pos) {
	if (wonAgainst[pos].empty()) return 0;
	vi depths;
	for (int opp : wonAgainst[pos]) depths.push_back(getDepth(opp));
	sort(depths.rbegin(), depths.rend());
	int big = 0;
	F0R(i, depths.size()) big = max(big, depths[i] + i);
	return big + 1;
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	F0R(i, N - 1) {
		int x; cin >> x;
		wonAgainst[x-1].push_back(i+1);
	}

	print(getDepth(0));
}

Measured memory_bytes: 22144
n = int(input())
a=list(map(int, input().split()))

max_num = max(a)

if a.count(1) == 1:
    print(1)
    exit()
if a.count(1) >= 2:
    print(0)
    exit()
a.sort()
d = {}

ans = 0



for i in range(n):
    if a[i] not in d.keys():
        ans += 1
        j = 1
        #for j in range(1,100):
        while(a[i]*j <= max_num):
            if j == 1:
                d[a[i]*j] = 1
            else:
                #if a[i]*j > max_num:
                #    break
                d[a[i]*j] = 0
            j += 1
    else:
        if d[a[i]] == 1:
            ans -= 1
            d[a[i]] = 2

print(ans)

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

int memo[101][10001];
int w[101], v[101];
int dp(int i, int j)
{
    if (i == 0)
        return 0;
    if (memo[i][j] >= 0)
        return memo[i][j];
    if (j - w[i - 1] < 0)
        return memo[i][j] = dp(i - 1, j);

    return memo[i][j] = max(dp(i - 1, j), dp(i - 1, j - w[i - 1]) + v[i - 1]);
}

int main()
{
    for (int i = 0; i < 101; i++)
    {
        for (int j = 0; j < 10001; j++)
        {
            memo[i][j] = -1;
        }
    }
    int N, W;
    scanf("%d %d", &N, &W);
    for (int k = 0; k < N; k++)
    {
        scanf("%d %d", &v[k], &w[k]);
    }
    printf("%d\n", dp(N, W));
}


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

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

template<class T> struct Edge{
    int rev,from,to; // rev:逆向きの辺の番号
    T cap, original_cap;
    Edge(int r, int f, int t, T c):
        rev(r), from(f), to(t), cap(c), original_cap(c) {}
};

template<class T> struct Graph{
    vector<vector<Edge<T>>> G;
    Graph(int n=0): G(n){}
    vector<Edge<T>>& operator[](int i){
        return G[i];
    }
    const size_t size() const{
        return G.size();
    }

    Edge<T>& redge(Edge<T> e){// 逆向きの辺を返す
        return G[e.to][e.rev];// 自己ループはないと仮定（あれば G[e.to][e.rev + 1] とする必要がある）
    }

    void add_edge(int from, int to, T cap){// 有向辺を加える
        G[from].push_back(Edge<T>((int)G[to].size(), from, to, cap));
        G[to].push_back(Edge<T>((int)G[from].size() - 1, to, from, 0));
    }

};

/* FordFulkerson: Ford-Fulkersonのアルゴリズムで最大流を求める構造体
    max_flow(G,s,t)：sからtへのグラフGの最大流を求める
    副作用：G は最大流の残余ネットワークになる
    計算量: O(|f*||E|) (f*:最大流) (この最悪ケースになることはほぼ無い)
*/

template<class T> struct FordFulkerson{
    vector<int> used;

    FordFulkerson(){};
    T dfs(Graph<T>& G, int v, int t, T f){
        if(v==t) return f;
        used[v] = true;
        for(auto& e: G[v]){
            if(!used[e.to] && e.cap>0){
                T d = dfs(G, e.to, t, min(f, e.cap));
                if(d>0){
                    e.cap -= d;
                    G.redge(e).cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    T max_flow(Graph<T>& G, int s, int t){
        T flow = 0;
        while(1){
            used.assign(G.size(), 0);
            T f = dfs(G,s,t,INF);
            if(f==0) return flow;
            else flow += f;
        }
        return 0;
    }
};

int main() {
    int N; cin >> N;
    Graph<int> G(2*N+2);

    vector<pair<int,int>> red(N), blue(N);
    REP(i,N) cin >> red[i].first >> red[i].second;
    REP(i,N) cin >> blue[i].first >> blue[i].second;

    REP(i,N){
        G.add_edge(0,i+1, 1);
    }
    REP(i,N){
        G.add_edge(N+i+1,2*N+1, 1);
    }

    REP(i,N){
        REP(j,N){
            if(red[i].first<blue[j].first && red[i].second<blue[j].second){
                G.add_edge(i+1, N+j+1, 1);
            }
        }
    }

    FordFulkerson<int> ff;
    cout << ff.max_flow(G,0,2*N+1) << endl;




    return 0;
}

/*
貪欲に解く
最右の赤に対して、それより右にある条件を満たす青のうちy座標が最も小さいものを選ぶ
これにより以降の選択肢を狭めることなく選択していくことができる！
*/

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

#define pb     push_back
#define mp     make_pair
#define all(v) v.begin() , v.end()
#define allr(v) v.rbegin(), v.rend()
const ll INF =  0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int MOD = 1e9+7;
const int MAX = 12e5+5;

string s;
int a[MAX];
int dp[1<<26];
int ans[MAX];

int main(int argc, char const *argv[])
{
	// ios_base::sync_with_stdio(false);

	// #ifndef ONLINE_JUDGE
	// freopen("in","r",stdin);
	// freopen("out","w",stdout);
	// #endif

	cin >> s;
	a[0] = 0;
	for(int i = 0 ; i < (int)s.size() ; i++){
		int bit = s[i] - 'a';
		a[i+1] = (a[i] ^ (1 << bit));
	}

	for(int i = 0 ; i < (int)(1 << 26) ; i++)
		dp[i] = inf;

	dp[0] = 0;
	ans[0] = 0;

	for(int i = 1 ; i <= (int)s.size() ; i++){
		ans[i] = inf;
		for(int j = -1 ; j < 26 ; j++){
			int msk = a[i];
			if(j >= 0)
				msk ^= (1 << j);
			ans[i] = min(ans[i], 1 + dp[msk]);
		}
		dp[a[i]] = min(ans[i], dp[a[i]]);
	}

	cout << ans[s.size()];
	return 0;
}  

Measured memory_bytes: 265604
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
  ll res = 1;
  while(b){
    if(b&1)res = res * x % MOD;
    x = x * x % MOD;
    b>>=1;
  }
  return res;
}

ll modinv(ll x){
  return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
  if(was_output)cout << " ";
  cout << a;
  was_output = true;
}
void outendl(){
  was_output = false;
  cout << endl;
}
ll in(){
  ll res;
  scanf("%lld", &res);
  return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
  for(auto &i:x)is >> i;
  return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
  is >> x.first >> x.second;
  return is;
}

template<class t>
void in(t&x){
  cin >> x;
}

int n;
vector<int> sum;

void out(){
  rep(i,n){
    cout << (char)('a'+sum[i]);
  }
  cout << endl;
}
void func(int place,int usemax){
  if(place==n){
    out();
    return;
  }
  rep(i,usemax+2){
    sum[place] = i;
    func(place+1,max(usemax,i));
  }
}

int main(){
  n = in();
  sum.resize(n);

  func(0,-1);


  return 0;
}


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

R = []

for i in range(min(A), max(A)):
    cost = 0
    for j in range(len(A)):
        cost += (i - A[j])**2
    R.append(cost)

if R == []:
    print(0)
else:
    print(min(R))


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#define rep(i,a,b) for(int (i)=(a);i<(b);i++)
#define INF 100000000
#define MAX_N 1000000
using namespace std;

int main(){
    int n;
    string a,b;
    set<string>s;
    cin>>n;
    rep(i,0,n){
        cin>>a>>b;
        if(a=="insert"){
            s.insert(b);
        }else if(a=="find"){
            if(s.find(b)!=s.end())cout<<"yes"<<endl;
            else cout<<"no"<<endl;
        }
    }
    return 0;
}

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

int main()
{
    int N;
    int l;
    int r;
    int ans = 0;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> l >> r;
        ans += (r - l) + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stack>
#include <cstring>
#include <queue>

using namespace std;

const int maxN = 110;

#define FORU(i, l, r) for (int i = l; i <= r; ++i)
#define FORD(i, r, l) for (int i = r; i >= l; --i)
#define REPU(i, r) for (int i = 0; i < r; ++i)
#define F first
#define S second
#define PB push_back
#define LL long long

LL f[maxN][2], res;
int l, k;

int main() {
    cin >> l >> k;
    res = 0;
    f[0][0] = 1;
    FORU(i, 1, l)
        REPU(j, 2) {
            f[i][j] = f[i - 1][1 - j];
            if (j && i >= k)
                f[i][j] += f[i - k][1 - j];
            if (j) res += f[i][j];
        }
    cout << res << endl;
}



Measured memory_bytes: 3136