akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n;
	cin >> n;
	string s = to_string(n);
	if ((s[0] == s[1] && s[0] == s[2]) || (s[1] == s[2] && s[1] == s[3])) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
int main(){
	int i,j,n,flag,a[N],hoge,cnt = 0;
	scanf("%d",&n);
	for( i = 0; i < n; i++) scanf("%d",&a[i]);
	for(i = 0; i < n - 1; i++){
		flag = 1;
		while(flag == 1){
			flag = 0;
			for(j = n - 1; j > i; j--){
				if(a[j] < a[j - 1]){
					hoge = a[j];
					a[j] = a[j - 1];
					a[j - 1] = hoge;
					flag = 1;
					cnt++;
				}
			}
		}
	}
	for( i = 0; i < n; i++) {
		printf("%d",a[i]);
		if(i == (n-1) ) break;
		printf(" ");
	}
	printf("\n%d\n",cnt);
	return 0;
}


Measured memory_bytes: 2104
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <stack>

using namespace std;

struct elem {
	int pos, height;
};

int getArea(int V[], int W) {
	int area = 0;
	stack<elem> S;
	for (int i = 0; i <= W; ++i) {
		elem e;
		e.pos = i;
		if (i == W) {
			e.height = 0;
		} else {
			e.height = V[i];
		}
		if (S.empty() || e.height > S.top().height) {
			S.push(e);
		} else {
			int prepos = i;
			while (!S.empty() && S.top().height > e.height) {
				elem target = S.top();
				S.pop();
				area = max(area, (i - target.pos) * target.height);
				prepos = target.pos;
			}
			e.pos = prepos;
			S.push(e);
		}
	}
	return area;
}
int main() {
	int H, W;
	scanf("%d %d", &H, &W);
	int A[H][W];
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			scanf("%d", &A[i][j]);
		}
	}

	int V[H][W];
	for (int j = 0; j < W; ++j) {
		for (int i = 0; i < H; ++i) {
			if (A[i][j] == 1) {
				V[i][j] = 0;
			} else {
				if (i == 0) {
					V[i][j] = 1;
				} else {
					V[i][j] = V[i - 1][j] + 1;
				}
			}
		}
	}

	int maxv = 0;
	for (int i = 0; i < H; ++i) {
		maxv = max(maxv, getArea(V[i], W));
	}
	cout << maxv << endl;

	return 0;
}

Measured memory_bytes: 18504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
int main(){
    ll n,m; cin>>n>>m;
    vector<ll> toN={};
    map<ll,ll> oneTo;
    rep(i,m){
        ll a,b; cin>>a>>b;
        if(a==1) oneTo[b]=1;
        else if(a==n) toN.push_back(b);
        else if(b==1) oneTo[a]=1;
        else if(b==n) toN.push_back(a);
    }
    bool iftrue=false;
    for(ll i:toN){
        if(oneTo[i]>0) iftrue=true; 
    }
    if(iftrue) cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
}

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

using namespace std;

#define ll long long
#define pb push_back
#define sz size()
#define S second
#define F first
#define all(x) x.begin(), x.end()

typedef vector < int >  vi;
typedef vector < vector < int > >  vvi;

void solve(){
    int h, w, k, cnt = 0;
    cin >> h >> w >> k;
    vvi a(h + 2, vi(w + 2));
    vvi b(h + 2, vi(w + 2));
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            char c;
            cin >> c;
            if(c == '.'){
                a[i][j] = 0;
            }
            else{
                a[i][j] = 1;
            }
            cnt += a[i][j];
        }
    }

    int sum = 0;
    int ans = 0;
    vi dp(h + w + 2, 0);

    while(dp[0] == 0){

        for(int i = 1; i <= h; i++){
            for(int j = 1; j <= w; j++){
                b[i][j] = a[i][j];
            }
        }

        sum = 0;
        for(int i = 1; i <= h + w; i++){
            if(dp[i]){
                if(i > h){
                    int ii = i - h;
                    for(int j = 1; j <= h; j++){
                        sum += b[j][ii];
                        b[j][ii] = 0;
                    }
                }
                else{
                    for(int j = 1; j <= w; j++){
                        sum += b[i][j];
                        b[i][j] = 0;
                    }
                }
            }
        }

        if(cnt - sum == k){
            ans++;
            //cout << cnt << " " << sum << "\n";
        }
        int pos = h + w;
        while(dp[pos]){
            dp[pos] = 0;
            pos--;
        }
        dp[pos] = 1;
    }



    cout << ans;
}

signed main() {
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
        cout << "\n";
    }
}




Measured memory_bytes: 3636
from decimal import *

import math

N, K = map(int, input().split())

# 計算しない範囲を求める
# 100 10 なら 100-10 + 1/100はかつ
result = 0

for i in range(1,N + 1):
    tmp = 1/N
    i_tmp = i
    while i_tmp < K:
        tmp /= 2
        i_tmp *= 2
        #print(i_tmp)
    result += tmp
print(result)





#print(''.join(S))


Measured memory_bytes: 5076
#include <stdio.h>

int main(void)
{
    char S[4];
  
    scanf("%s",S);
    if (S[0] == 'A' && S[1] == 'A' && S[2] == 'A')
      printf("No\n");
    else if (S[0] == 'B' && S[1] == 'B' && S[2] == 'B')
      printf("No\n");
    else
      printf("Yes\n");
    return (0);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int> graph[100002];
int mc[100002]={0};
int cnt=0,ml,cut;
vector<int> main_road;
void dfs_m(int v,int p){
	for(int i=0;i<graph[v].size();i++){
		int y=graph[v][i];
		if(y!=p) dfs_m(y,v);
	}
	if(v==ml){
		main_road.push_back(v);
		ml=p;
	}
}
void dfs_e(int v,int p){
	if(mc[v]>cut) return;
	for(int i=0;i<graph[v].size();i++){
		int y=graph[v][i];
		if(y!=p) dfs_e(y,v);
	}
	cnt++;
}
int main(){
	scanf("%d",&n);
	ml=n;
	for(int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		graph[x].push_back(y);
		graph[y].push_back(x);
	}
	dfs_m(1,0);
	reverse(main_road.begin(),main_road.end());
	for(int i=0;i<main_road.size();i++){
		mc[main_road[i]]=i+1;
	}
	cut=(main_road.size()+1)/2;
	dfs_e(1,0);
	cout<<((cnt*2>n)?"Fennec":"Snuke")<<endl;
	return 0;
}

Measured memory_bytes: 11256
a = int(input())
b = list(map(str,input().split()))


G =0
P =0
W =0
Y =0

for i in b:
    if i == 'G':
        G +=1
    elif i =='P':
        P +=1
    elif i =='W':
        W += 1
    else:
        Y += 1

if G != 0 and P != 0 and W != 0 and Y != 0:
    print('Four')
else:
    print('Three')


Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int N = 21, P = 1000000007;

int n;
bool a[N][N];
int dp[1 << N];

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif

  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      scanf("%d", &a[i][j]);
  dp[0] = 1;
  for (int s = 1; s < 1 << n; ++s) {
    int u = __builtin_popcount(s) - 1;
    for (int v = 0; v < n; ++v)
      if ((s >> v & 1) && a[u][v])
        if ((dp[s] += dp[s ^ 1 << v]) >= P)
          dp[s] -= P;
  }
  printf("%d\n", dp[(1 << n) - 1]);

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 8448
import java.util.Scanner;

class Main{
    
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int A[] = new int[N];
	for(int i = 0;i < N;i++){
	    A[i] = sc.nextInt();
	}
	int cnt = 0, tmp, minj;
	for(int i = 0;i <= N - 1;i++){
	    minj = i;
	    int flag = 0;
	    for(int j = i;j <= N - 1;j++){
		if(A[j] < A[minj]){
		    minj = j;
		}		
	    }
	    tmp = A[i];
	    A[i] = A[minj];
	    A[minj] = tmp;
	    if(i == minj){
		flag = 1;
	    }
	    if(flag == 0){
		cnt++;
		}	   
	}	
	for(int k = 0;k < N;k++){
	    System.out.print(A[k]);
	    if(k == N - 1) break;
	    System.out.print(" ");
	}
	System.out.println("\n" + cnt);
    }
}



Measured memory_bytes: 26300
#include"bits/stdc++.h"

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<string> s(N);
	string ans = "Three";

	for (int i = 0; i < N; i++) {
		cin >> s[i];
		if (s[i] == "Y") {
			ans = "Four";
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	VI w(4);
	string s;
	while(cin>>w[0]>>w[1]>>w[2]>>w[3]) {
		sort(ALL(w));
		VI ref={1,4,7,9};
		cout<<(w==ref?"YES":"NO")<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      int a=sc.nextInt();
       int b=sc.nextInt();
        int c=sc.nextInt();
         int d=sc.nextInt();
          int e=sc.nextInt();
          
      
     if(a==0){
         System.out.println(1);
     }else if(b==0){
         System.out.println(2);
     }else
     if(c==0){
         System.out.println(3);
     }else
     if(d==0){
         System.out.println(4);
     }else if(e==0){
         System.out.println(5);
     }

     
    }
}

Measured memory_bytes: 35692
#include <bits/stdc++.h>
using namespace std;
int i,j,k,count1=0,count2=0;

int main(void){
    int n;
    cin>>n;
    long long int ans=1;
    long long int x;
    string a,b;
    vector<long long int> vec(n);
    for(i=0;i<n;i++){
        cin>>vec[i];
        if(vec[i]==0)ans=0;
    }
    int a1,a2,b1,b2;
    if(ans!=0){
        for(i=0;i<n;i++){
            x=vec[i];
            a=to_string(ans);
            b=to_string(x);
            ans*=x;
            cerr<<a.length()+b.length()<<endl;
            if(ans>1000000000000000000){
                ans=-1;
                break;
            }
            if(a.length()+b.length()-2>=18){
                if(ans==1000000000000000000)continue;
                ans=-1;
                break;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4052
#include<iostream>
//#include<CastingInterop.h>
#include<string>
#include <sstream>
using namespace std;

int main()
{
    char arr[3];
    string s=""; 
   
    for (int i = 0; i < 3; i++)
    {
        cin >> arr[i];
        s += arr[i]; 
    }
   
    stringstream str(s); 
    int num; 
    str >> num; 
    if (num % 4 == 0)
        cout << "YES";
    else
        cout << "NO";
    return 0; 
}

Measured memory_bytes: 3608
import java.util.*;
public class Main {// Main
    public static void main(String[] args){
       	Scanner s = new Scanner(System.in);
        long a = s.nextLong();
        long count = 0;
        for(int i=1;i<=a;i++) {
            if(i % 3 == 0 && i % 5 == 0) {

            } else if(i % 3 == 0) {

            } else if(i % 5 == 0) {

            } else {
                count += i;
            }
        }
        System.out.println(count);
    }
}


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

using namespace std;
const long long mx = 1e18; 

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

    vector<int64_t> vec(N);

    for (int64_t i = 0; i < N; i++) {
        cin >> vec.at(i);
    }

    uint64_t answer = 1;
    bool toobig = false;

    sort(vec.begin(), vec.end());
    for (int64_t i = 0; i < N; i++) {
        uint64_t before_answer = answer;
        answer *= vec.at(i);
        if (answer > mx) {
            toobig = true;
            break; 
        } else if (answer / vec.at(i) != before_answer) {
            toobig = true;
            break;
        }
    }

    if (toobig) {
        cout << "-1"; 
    } else {
        cout << answer;
    }

    return 0;
}

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

int main()
{
    int n,m,k;
    scanf("%d %d %d",&n,&m,&k);
    for(int i = 0; i <= n; ++i)
    {
        for(int j = 0; j <= m; ++j)
        {
            if(i*(m-j)+j*(n-i) == k)
            {
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
par=[i for i in range(N)]
size=[1 for i in range(N)]
def find(x):
  if par[x]==x:
    return x
  else:
    par[x]=find(par[x])
    return par[x]
def union(a,b):
  x=find(a)
  y=find(b)
  if x!=y:
    if size[x]<size[y]:
      par[x]=par[y]
      size[y]+=size[x]
    else: 
      par[y]=par[x]
      size[x]+=size[y]
  else:
    return  

for i in range(M):
  a,b=map(int,input().split())
  union(a-1,b-1)
print(max(size))

Measured memory_bytes: 18636
p $<.to_a[1].split.map(&:to_i).each_slice(2).to_a.transpose
.map{|a|a.group_by{|x|x}.map{|k,v|[k,v.size]}.sort_by{|x|-x[1]}}
.map{|a|[a[0][0]] + [a[1]&.slice(0)] + [a.flat_map{|(x,c)|[x] * c}]}
.transpose
.inject{|m,i|
  i.all?{|ii|ii.class.to_s != 'Array'} ?
  (m + i) :
  (m[0] != m[1] ?
    (i[0].count{|ii|ii != m[0]} + i[1].count{|ii|ii != m[1]}) :
    [
      i[0].count{|ii|ii != m[0]} + i[1].count{|ii|ii != m[3]},
      i[0].count{|ii|ii != m[2]} + i[1].count{|ii|ii != m[1]}
    ].min
  )
}


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

using namespace std;

#define pb            push_back
#define mp            make_pair
#define po            pop_back
#define fi            first
#define se            second
#define mxn           200001
#define ll            long long int
#define ldb           long double
#define fr(i,a,b,k)   for(ll i=a ; i<b ; i+=k)
#define frr(i,a,b,k)  for(ll i=a ; i>b ; i-=k)
#define all(v)        v.begin(),v.end()
#define endl          "\n"
#define deg(x)        cout<<endl<<#x<<" = "<<(x)<<endl;
#define casep(x)      cout<<"Case #"<<(x)<<": ";
#define fast          ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

typedef pair<ll,ll> pp;
typedef vector<ll> vi;
typedef vector<pp> vpp;
typedef vector<vi> vvi;

const int inf = 1e9+7;

ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
ll gcd(ll a,ll b){ return __gcd(a,b);}
ll lcm(ll a,ll b){return a*b/__gcd(a,b);}


void solve(ll test){

    ll n;
    cin >> n;

    ll k = 1;
    while(1000*k < n){
        k++;
    }

    cout << 1000*k-n;

}

int main(){

    fast;
    int t=1;
    // cin >> t;
    for(int i=1 ; i<=t ; i++){
        solve(i);
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3620
using System;
using System.Linq;

namespace Aizu {
    public class OnlineJudge {
        static void Main() {
            var n = Console.ReadLine().Split().Select(int.Parse).First();
            var dp = Enumerable.Repeat(int.MaxValue, n + 1).ToArray();
            var coins = Console.ReadLine().Split().Select(int.Parse).OrderBy(q => q).ToArray();

            dp[0] = 0;

            for (var i = 0; i < dp.Length; ++i) {
                for (var j = 0; j < coins.Length; ++j) {
                    if (i < coins[j]) {
                        break;
                    }
                    dp[i] = Math.Min(dp[i - coins[j]] + 1, dp[i]);
                }
            }

            Console.WriteLine(dp[n]);
        }
    }
}



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

int a,b,c,x,y;
int main(){
  cin >> a >> b >> c >> x >> y;
  int mini = INT_MAX;
  for(int t=0;t<=100000;t++){
    mini = min(mini, 2 * t * c + max(0, x-t) * a + max(0, y-t) * b);
  }
  cout << mini << endl;
}
  

Measured memory_bytes: 256
#include <stdio.h>
#include <sstream>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
#include <ctype.h>
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, char> pic;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
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;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

ll bit[200010];
int max_n = 200000;
int pm = 0;
void add(int x) {

	while (max_n >= x)
	{
		bit[x]++;
		x += x & -x;
	}
}
void sub(int x) {
	while (max_n >= x)
	{
		bit[x]--;
		x += x & -x;
	}
}


void solv() {
	
	ll n;
	cin >> n;
	set<string> st;
	for (size_t i = 0; i < n; i++)
	{
		char s[50];
		scanf("%s", s);
		char v[50];
		scanf("%s", v);
		if (!strcmp(s, "insert")) {
			st.insert(v);
		}
		else {
			auto p = st.find(v);
			if (p == st.end()) {
				cout << "no" << endl;
			}
			else cout << "yes" << endl;
		}
	}
}
int main() {
	//	COMinit();
	solv();
	return 0;
}



Measured memory_bytes: 29028
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#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 << '\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 = 80 + 10 ;
const ll INF = 1e18 + 10 ;
ll n , m ;
ll a[N][N] ; 
ll b[N][N] ; 
ll dp[N][N][12800] ; 
ll dfs(ll x, ll y, ll curDiff){
    if ( x >= n || y >= m ) return INF ; 
    if ( x == n - 1 && y == m - 1 ){
        return min(abs(curDiff + a[x][y] - b[x][y]), abs(curDiff + b[x][y] - a[x][y])) ;
    }
    if ( dp[x][y][curDiff] != -1 ) return dp[x][y][curDiff] ; 
    ll choice1 = dfs(x + 1, y, curDiff + a[x][y] - b[x][y] ) ;
    ll choice2 = dfs(x + 1, y, curDiff + b[x][y] - a[x][y] ) ;
    ll choice3 = dfs(x, y + 1, curDiff + a[x][y] - b[x][y] ) ;
    ll choice4 = dfs(x, y + 1, curDiff + b[x][y] - a[x][y] ) ;
    return dp[x][y][curDiff] = min({choice1, choice2, choice3, choice4});
}
int main(){
    fastio
    memset(dp, -1, sizeof dp) ;
    cin >> n >> m ; 
    for(ll i = 0; i < n; i++){
        for(ll j = 0; j < m; j++){
            cin >> a[i][j] ; 
        }
    }
    for(ll i = 0; i < n; i++){
        for(ll j = 0; j < m; j++){
            cin >> b[i][j] ; 
        }
    }
    cout << dfs(0, 0, 0) << endl;
    return 0; 
}

Measured memory_bytes: 810496
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string s,t;
    cin >> s >> t;
    ll count = s.size()-t.size()+1;
    ll res = INF;
    rep(i,count){
        ll tres = t.size();
        rep(j,t.size()){
            if(s.at(i+j)==t.at(j)) tres--;
        }
        res = min(res, tres);
    }
    cout << res << endl;
}

Measured memory_bytes: 3648
# include <bits/stdc++.h>
 
/*
// ordered_set 
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
# define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
*/
 
using namespace std;
 
typedef long long                                        ll;
typedef long double                                      ld;
typedef pair <int, int>                                  pii;
typedef pair <pii, int>                                  ppi;
typedef pair <int, pii>                                  pip;
typedef pair <pii, pii>                                  ppp;
typedef pair <ll, ll>                                    pll;
 
# define A                                               first
# define B                                               second
# define endl                                            '\n'
# define sep                                             ' '
# define all(x)                                          x.begin(), x.end()
# define kill(x)                                         return cout << x << endl, 0
# define SZ(x)                                           int(x.size())
# define Sort(x)                                         sort(all(x))
# define InTheNameOfGod                                  ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
 
ll power(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));}
 
const int xn = 1e6 + 10;
const int xm = - 20 + 10;
const int SQ = 320;
const int sq = 320 + 10;
const int inf = 1e9 + 10;
const ll INF = 1e18 + 10;
const int MOD = 1e9 + 7;
const int TM = 3;
const int BASE = 257;

int n, m, col[xn], dist[xn];
pii last[xn];
vector <pii> adj[xn];
vector <int> G[xn];
deque <int> q;

int main(){
    InTheNameOfGod;
    
    cin >> n >> m;
    for (int i = 1; i <= m; ++ i){
    	int v, u, w;
    	cin >> v >> u >> w;
    	G[v].push_back(i);
    	G[u].push_back(i);
    	col[i] = w;
	}
	for (int v = 1; v <= n; ++ v){
		for (int u : G[v]){
			int c = col[u];
			if (last[c].A == v){
				adj[u].push_back({last[c].B, 0});
				adj[last[c].B].push_back({u, 0});
			}
			last[c] = {v, u};
			adj[u].push_back({m + v, 0});
			adj[m + v].push_back({u, 1});
		}
	}
	memset(dist, - 1, sizeof dist);
	dist[m + 1] = 0;
	q.push_front(m + 1);
	while (q.size()){
		int v = q.front();
		q.pop_front();
		for (pii u : adj[v]){
			if (dist[u.A] > dist[v] + u.B || dist[u.A] == - 1){
				if (u.B) q.push_back(u.A);
				else q.push_front(u.A);
			}
			dist[u.A] = min(dist[u.A], dist[v] + u.B);
			if (dist[u.A] == - 1) dist[u.A] = dist[v] + u.B;
		}
	}
	cout << dist[m + n] << endl;
    
    return 0;
}


Measured memory_bytes: 81328
X,Y = map(int,input().split())
money=0
if X==1:
    money=money+300000
elif X==2:
    money=money+200000
elif X==3:
    money=money+100000
if Y==1:
    money=money+300000
elif Y==2:
    money=money+200000
elif Y==3:
    money=money+100000
if X==1 and Y==1:
    money=money+400000
print(money)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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;}
/*----------------------------------------------------------------*/
// const int MOD = 998244353;
const int MOD = 1000000007;


/*----------------------------------------------------------------*/
signed main(){


	int k,t;
	cin >> k >> t;
	vll a(t);
	rep(i,t)cin >> a[i];

	Sort(a);
	int m = a[t-1];

	if(m <= (k-m)+1){
		cout << 0 << endl;
	}else{
		cout << m-(k-m)-1 << endl;
	}


	
	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2017-qualb.contest.atcoder.jp/tasks/code_festival_2017_qualb_b
// rm -r -f test;oj dl https://code-festival-2016-qualc.contest.atcoder.jp/tasks/codefestival_2016_qualC_b

Measured memory_bytes: 3624
n,k,q = list(map(int,input().split()))
a = [0]*q
for i in range(q):
    a[i] = int(input())-1

ans = [k-q]*n
for i in range(q):
    ans[a[i]] += 1
for i in range(n):
    print('Yes' if ans[i]>0 else 'No')

Measured memory_bytes: 10412
// Marcin Knapik
#include<bits/stdc++.h>

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

// #include <ext/pb_ds/assoc_container.hpp> // order_of_key
// #include <ext/pb_ds/tree_policy.hpp> // find by order
// using namespace __gnu_pbds; 
// #define ordered_set tree< pair<int, int> , null_type,less<pair<int, int>>, rb_tree_tag,tree_order_statistics_node_update>  

// const ll MAX_LL = 0xFFFFFFFFFFFFFFFF;
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define losuj(a, b) uniform_int_distribution<ull>(a, b)(rng)
#define losuj_real(a, b) uniform_real_distribution<long double>(a, b)(rng)

typedef long double             ld;
typedef long long               ll;
typedef unsigned long long      ull;
typedef pair<ll, ll>            pll;
typedef pair<int, int>          ii;
typedef vector<int>             vi;
typedef vector<ii>              vii;
typedef vector<vi>              vvi;
typedef vector<vector<ii>>      vvii;
typedef vector< ll >            vll;
typedef vector< pll >           vpll;
 
#define sz(a)                   (int)(a).size()
#define pb                      push_back
#define all(c)                  (c).begin(), (c).end()
#define rall(c)                 (c).rbegin(), (c).rend()
#define FOR(i, a)               for (int i = 0; i < (a); i++)
#define f                       first
#define s                       second
 
template <class T> inline bool setmin(T &a, T b){if (a > b)return a = b, 1;return 0;}
template <class T> inline bool setmax(T &a, T b){if (a < b)return a = b, 1;return 0;}
 
template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> inline T russian(T a, T b, T mod) {ll res = 0; while(b){if(b&1) res = (res + a)%mod; a = (a+a)%mod; b>>=1;}return res;}
template <class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<typename T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return a; }
  
const ll INF = 1e9 + 7;
const ll mod = 998244353;
const ll N = 1e5+7;
const ll T = 1<<20;
const ll BIG_INF = 1e18 + 7;

ll n, m, k, q;
	
vi tab;
ll dp[105][N];

void prep(){
	for(int i = n-1; i >= 0; i--)
		for(int j = 0; j <= k; j++){
			dp[i][j] = dp[i][max(0, j-1)];
			if(i == n-1)
				dp[i][j] += (j <= tab[n-1]);
			else{
				dp[i][j] += dp[i+1][j];
				if(j - tab[i] > 0)
					dp[i][j] -= dp[i+1][j - tab[i] - 1];
			}
			dp[i][j] %= INF;
			if(dp[i][j] < 0)
				dp[i][j] += INF;
		}
}

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

    cin >> n >> k;
    tab.resize(n);
    cin >> tab;

    prep();

    cout << (dp[0][k] - dp[0][k-1] + INF)%INF << '\n';
}

Measured memory_bytes: 80128
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
#define int long long

int n;
string s[500];

signed main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    F(i, n) cin >> s[i];
    int c = 0;
    F(i, n) F(j, n) if (s[i][j] == '#') c = 1;
    if (c == 0) cout << -1, exit(0);
    c = 0;
    F(j, n) F(i, n) if (s[i][j] == '.') {c++; break;}
    int k = n;
    F(i, n)
    {
        int x = 0, t = 1;
        F(j, n) if (s[i][j] == '.') x++;
        F(i2, n) if (s[i2][i] == '#') t = 0;
        k = min(k, x + t);
        //cout << x << " " << t << endl;
    }
    cout << k + c;
}


Measured memory_bytes: 512
N=int(input())
CSF=[list(map(int,input().split())) for i in range(N-1)]
for i in range(N-1):
    ans=0
    for j in range(i,N-1):
        c,s,f=CSF[j]
        ans=max(s,ans+abs(ans%-f))
        ans+=c
    print(ans)
print(0)

Measured memory_bytes: 3188
import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
b.sort()
c.sort()
y = 0
bc = [0]
for i in range(1, n+1):
    bc.append(bc[-1] + n - bisect.bisect_right(c, b[-i]))
bc.reverse()
for i in a:
    y += bc[bisect.bisect_right(b, i)]
print(y)

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

double speed(double v) {
	double time = v / 9.8;
	double y = 4.9*time*time;
	double f =(y+5)/5 ;
	double fa = ceil(f);
	return fa;
}

int main() {
	double x;
	while (cin >> x) {
		cout << speed(x) << endl;
	}
	return 0;
}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN

 main() {
int n;
cin >> n;
int ans =0;
for(int i=0;i<n;i++){
   int che = i+1;
   string s = to_string(che);
   if(s.size()%2==1)ans++;
}
cout << ans << endl;
 }


Measured memory_bytes: 256
import collections
n = int(input())
fir = [str(input()) for _ in range(n)]
m = int(input())
sec = [str(input()) for _ in range(m)]
fc = []
sc = []
fn = []
sn = []
fir.sort()
sec.sort()
k = 1
for i in range(n-1):
    if fir[i] != fir[i+1]:
        fc.append(k)
        fn.append(fir[i])
        k = 1
    else:
        k += 1
fc.append(k)
fn.append(fir[-1])
l = 1
for j in range(m-1):
    if sec[j] != sec[j+1]:
        sc.append(l)
        sn.append(sec[j])
        l = 1
    else:
        l += 1
sc.append(l)
sn.append(sec[-1])
for p in sn:
    if p in fn:
        q = fn.index(p)
        fc[q] -= sc[sn.index(p)]
print(max(max(fc),0))

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, 0, N) {
        cin >> a[i];
    }
    int ans = 0;
    int bef = -1;
    int cnt = 1;
    REP(i, 0, N) {
        if (bef == a[i]) {
            cnt++;
        } else {
            bef = a[i];
            ans += cnt / 2;
            cnt = 1;
        }
    }
    ans += cnt / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
int main(){
  int n,k,x=1;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    if(x*2<x+k)x=x*2;
    else x=x+k;
  }
  cout<<x<<endl;
}

Measured memory_bytes: 256
import numpy as np
n = int(input())
A = np.array(list(map(int, input().split())))
mod = 10 ** 9 + 7
ans = 0
for i in range(60):
    tmp = (A >> i) & 1
    x = np.count_nonzero(tmp)
    x *= n - x
    ans = (ans + pow(2, i, mod) * x) % mod
print(ans)

Measured memory_bytes: 48836
a = list(map(int,input().split()))
b = [input() for i in range(a[0])]
c = "#"*(a[1]+2)

for i in range(a[0]+2):
  if i==0 or i==a[0]+1:
    print(c)
  else:
    print("#"+b[i-1]+"#")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = a; i <= b; ++i)
#define PER(i, a, b) for (int i = a; i >= b; --i)
using namespace std;

typedef long long LL;

inline int read(){
	int x = 0, f = 1, ch = getchar();
	while (!isdigit(ch)){if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
	return x * f;
}

const int N = 600005, mo = 924844033, g = 5;
int n, sz[N], rev[N];
LL a[N], b[N], f[N];
vector<int> to[N];

void dfs(int x, int f){
	sz[x] = 1;
	for (int i = 0; i < to[x].size(); ++i){
		int y = to[x][i];
		if (y == f) continue;
		dfs(y, x);
		sz[x] += sz[y];
		--a[sz[y]];
		--a[n - sz[y]];
	}
}

LL pwr(LL a, LL b){
	LL res = 1;
	for (; b; b >>= 1, (a *= a) %= mo)
		if (b & 1) (res *= a) %= mo;
	return res; 
}

LL inv(LL x){
	return pwr(x, mo - 2);
}

void ntt(LL *a, int n, int d = 1){
	REP(i, 0, n - 1) if (i > rev[i]) swap(a[i], a[rev[i]]);
	for (int m = 2; m <= n; m <<= 1){
		LL wn = pwr(g, d * (mo - 1) / m + mo - 1);
		for (int i = 0; i < n; i += m){
			LL w = 1;
			for (int j = i; j < i + m / 2; ++j){
				LL u = a[j], v = w * a[j + m / 2] % mo;
				a[j] = (u + v) % mo;
				a[j + m / 2] = (u - v) % mo;
				(w *= wn) %= mo;
			}
		}
	}
	if (d == -1){
		LL t = inv(n);
		REP(i, 0, n - 1) (a[i] *= t) %= mo;
	}
}

int main(){
	n = read();
	REP(i, 2, n){
		int u = read(), v = read();
		to[u].push_back(v);
		to[v].push_back(u);
	}
	dfs(1, 0); a[n] = n; f[0] = 1;
	REP(i, 1, n) f[i] = f[i - 1] * i % mo;
	REP(i, 0, n) a[i] = a[i] * f[i] % mo;
	REP(i, 0, n) b[i] = inv(f[i]);
	REP(i, 0, n / 2) swap(a[i], a[n - i]);
	int len;
	for (len = 1; len < 2 * (n + 1); len <<= 1);
	REP(i, 1, len - 1)
		if (i & 1) rev[i] = (rev[i >> 1] >> 1) ^ (len >> 1);
		else rev[i] = (rev[i >> 1] >> 1);
	ntt(a, len); ntt(b, len);
	REP(i, 0, len - 1) (a[i] *= b[i]) %= mo;
	ntt(a, len, -1);
	PER(i, n - 1, 0){
		LL ans = a[i] * inv(f[n - i]) % mo;
		printf("%lld\n", (ans + mo) % mo);
	}
	return 0;
}

Measured memory_bytes: 48384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;
 
void solve(){
    int k;
    cin >> k;

    ll cur = 7;
    for(int i = 1; i <= 1e7; ++i) {
        if(cur % k == 0){
            cout << i;
            return;
        }
        cur = (cur * 10 + 7) % k;
    }
    cout << "-1";
}
 
int main(){
    // speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

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

using namespace std;

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

	int n;
	cin >> n;
	vector<vector<int>> a(n, vector<int>(n - 1));
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n - 1; ++j) {
			cin >> a[i][j];
			--a[i][j];
		}
	}
	vector<int> q[2];
	int cur = 0;
	for (int i = 0; i < n; ++i) {
		if (a[a[i][0]][0] == i) {
			q[cur].push_back(i);
		}
	}
	int ans = 0;
	vector<int> cnt(n);
	while (q[cur].size()) {
		++ans;
		q[cur ^ 1].clear();
		set<int> s;
		for (int x : q[cur]) {
			++cnt[x];
			if (cnt[x] < n - 1) {
				int y = a[x][cnt[x]];
				if (cnt[y] < n - 1 and a[y][cnt[y]] == x) {
					s.insert(x);
					s.insert(y);
				}
			}
		}
		for (int x : s) {
			q[cur ^ 1].push_back(x);
		}
		cur ^= 1;
	}
	for (int i = 0; i < n; ++i) {
		if (cnt[i] != n - 1) {
			ans = -1;
		}
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 1; i < (n); i++)
using namespace std;
using ll = long long;

vector<pair<ll, ll> > prime_factorize(ll N) {
    vector<pair<ll, ll> > res;
    for (ll a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        ll ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
	int n; cin >> n;
	ll cnt = 0;
	REP(c, n) {
		const auto &pf = prime_factorize(n - c);
		ll res = 1;
		for (auto p : pf)
			res *= p.second + 1;
		cnt += res;
	}
	cout << cnt << '\n';
	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
string ch[101];
int main()
{   int n,l;
    cin>>n>>l;
    for(int i=1;i<=n;i++)  
	cin>>ch[i];
	sort(ch,ch+n+1);
	for(int i=1;i<=n;i++)
	cout<<ch[i];
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[3];
	cin>>a[1]>>a[2]>>a[3];
	sort(a+1,a+4);
	if(a[1]==a[2]) cout<<a[3];
	else cout<<a[1];
	cout<<endl;
	return 0;
 } 

Measured memory_bytes: 256
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] P = new int[n];
            for (int i = 0; i < n; i++)
            {
                P[i]= int.Parse(Console.ReadLine());
            }
            Array.Sort(P);
            int sum = 0;
            for (int i = 0; i < n; i++)
            {
                if (i == n - 1) P[i] /= 2;
                sum += P[i];
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 27380
/*
氏名：鈴木丈人
学籍番号：190441067
概要：3つの整数a,b,cを読み込み、それらがa<b<cの条件を満たすならば"Yes"を、満たさないならば"No"を出力するプログラム
*/
#include<stdio.h>
int main(void)
{
	int a;
	int b;
	int c;

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

	/*a<b<c*/
	if ((a < b) && (a < c) && (b < c))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

int main(){
  int n;
  cin>>n;
  set<ll> s;
  decltype(s)::iterator it;
  for(int i=0;i<n;i++){
    ll tmp;
    cin>>tmp;
    it=s.find(tmp);
    if(it==s.end()) s.insert(tmp);
    else s.erase(tmp);
  }
  cout<<s.size()<<endl;
  return 0;
}


Measured memory_bytes: 4864
#include<stdio.h>
int main()
{
   int a,b,c,p=0;
   scanf("%d%d%d",&a,&b,&c);
   if(a<b&&a<c)
   {
    if(b<c)p=b-a+c-b;
    else p=c-a+b-c;
   }
   else if(b<a&&b<c)
   {
    if(a<c)p=a-b+c-a;
    else p=c-b+a-c;
   }
   else if(c<b&&c<a)
   {
    if(a<b)p=a-c+b-a;
    else p=b-c+a-b;
   }
   else if(a==b)p=c-a;
   else if(b==c)p=a-b;
   else if(c==a)p=b-a;
   else p=0;

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




   return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define va first
#define vb second
#define lb lower_bound
#define ub upper_bound
#define pp push_back
#define ep emplace_back
#define all(v) (v).begin(),(v).end()
#define szz(v) ((int)(v).size())
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
using ll = long long;
using lf = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int n;

void solve0(){
    cout << n * n / 4 << '\n';
    vector<int> A, B;
    for(int i = 1; i + i <= n; i += 2){
        A.pp(i); A.pp(n+1-i);
        B.pp(i+1); B.pp(n-i);
    }
    for(int a : A){
        for(int b : B) cout << a << ' ' << b << '\n';
    }
}
void solve1(){
    cout << (n-1) * (n-1) / 2 << '\n';
    for(int i = 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            if(j != n - i) cout << i << ' ' << j << '\n';
        }
    }
}
void solve2(){
    cout << n * (n-2) / 2 << '\n';
    for(int i = 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            if(j != n+1-i) cout << i << ' ' << j << '\n';
        }
    }
}
void solve3(){
    cout << (n-1) * (n+1) / 4 << '\n';
    vector<int> A, B;
    int k = (n+1)/4;
    for(int i = 1; i < k; i++) A.pp(i), A.pp(n+1-i);
    for(int i = k + 1; i + i < n; i++) B.pp(i), B.pp(n+1-i);
    A.pp(k); A.pp((n+1)/2); B.pp(n+1-k);
    for(int a : A){
        for(int b : B) cout << a << ' ' << b << '\n';
    }
}
int main(){
    fio;
    cin >> n;
    switch(n % 4){
    case 0:
        solve0();
        break;
    case 1:
        solve1();
        break;
    case 2:
        solve2();
        break;
    case 3:
        solve3();
        break;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

int a, b, c, d, e, f;
bool water[33] = {1}, sugar[3030] = {1};

int main() {
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
	for (int i = a; i <= f/100; i++)
		if (i < b) water[i] = water[i-a];
		else water[i] = water[i-a] || water[i-b];
	for (int i = c; i <= f; i++)
		if (i < d) sugar[i] = sugar[i-c];
		else sugar[i] = sugar[i-c] || sugar[i-d];
	int sw = 0, s = 0;
	double dst = -1.0;
	for (int i = a; i <= f/100; i++)
		if (water[i]) {
			int j = std::min( i*e, f-i*100 );
			while (j && !sugar[j]) j--;
			double t = (double)j/i;
			if (t > dst) {
				dst = t;
				sw = i*100 + j;
				s = j;
			}
		}
	printf("%d %d\n",sw,s);
	return 0;
}

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


int main(void)
{
    
    ll n,p;
    string s;
    cin>>n>>p;
    cin>>s;
    ll dp[n+1];
    dp[0]=1;
    dp[1]=10;
    ll ans;
    for(int i =2;i<=n;i++)
     dp[i] = ((dp[i-1]%p)*(10%p))%p;
     if(p==2 || p ==5){
         ans = 0;
    for(int i =0;i<n;i++)
    {
        if((s[i]-'0')%p==0)
        ans+=(i+1);
    }
    cout<<ans<<endl;
    return 0;
     }
     ans=0;
     ll cou[p];
     for(int i=0;i<p;i++)cou[i]=0;
     cou[0]=1;
     ll cur = 0;ll val;
     for(int i =0 ;i<n;i++)
     {
         cur=((cur%p)*(10%p))%p;
         cur+=(s[i]-'0');
         cur=cur%p;
         val = ((cur%p)*dp[n-1-i])%p;
         cou[val]++;
     }
     for(int i =0;i<p;i++)
     ans+=(cou[i]*(cou[i]-1))/2;
     cout<<ans<<endl;
}

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

int main(void)
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		if(c >= 5 && d >= 2)
		{
			int g = (a*c + b*d)*0.8;
			cout << g << endl;
		}
		else
		{
			{
				int f;
				int e = a*c + b*d;
				if (c > 5)
				{
					f = (a * 6 + b * 2)*0.8;
				}
				else if (d > 2)
				{
					f = (a * 5 + b * d)*0.8;
				}
				else
				{
					f = (a * 5 + b * 2)*0.8;
				}
				if (e > f)
				{
					cout << f << endl;
				}
				else
				{
					cout << e << endl;
				}
			}
		}
	}
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define int long long
using namespace std;
vector<pair<int,int>> arr(105);
vector<vector<int>> dp(105,vector<int>(100005,-1));
int fill(int n,int w)
{
	if(n==0 || w <= 0)
		return 0;
	if(dp[n][w] != -1)
		return dp[n][w];
	return dp[n][w] = max((arr[n].first <= w)*(arr[n].second+fill(n-1,w-arr[n].first)),fill(n-1,w));
}
int32_t main()
{
	int n,w;
	cin >> n >> w;
	for(int i=1;i<=n;i++)
	{
		cin >> arr[i].first >> arr[i].second;
	}
	cout << fill(n,w) << endl;
}

Measured memory_bytes: 83328