akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using i64 = long long;


int main() {
    std::vector<int> c { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
    int n, m;
    scanf("%d%d", &n, &m);
    std::vector<int> v;
    std::vector<int> dp(n + 11, -1);
    std::set<int> s;
    for (int i = 0; i < m; i++) {
        int d;
        scanf("%d", &d);
        v.push_back(d);
        s.insert(c[d]);
        dp[c[d]] = 1;
    }
    std::sort(v.begin(), v.end(), std::greater<>());
    dp[0] = 0;

    for (int i = 0; i < n - 1; i++) {
        if (!dp[i]) continue;
        for (const auto el : s) {
            dp[i + el] = std::max(dp[i + el], dp[i] + 1);
        }
    }

    while (n) {
        for (const auto d : v) {
            if (n - c[d] >= 0 && dp[n] - dp[n - c[d]] == 1) {
                printf("%c", '0' + d);
                n -= c[d];
                break;
            }
        }
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 256
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();
        int order[] = {a,b,c,d,e};
      	Integer time[] = new Integer[order.length];
      	int total = 0;
     
      	for(int i = 0; i < order.length; ++i){
        	time[i] = order[i]%10;
          	order[i] = order[i]-time[i];
        }
      	
      	for(int i = 0; i < time.length; ++i){
          int amari=0;
          	if(time[i]!=0){
          		amari = 10-time[i];
            }
          	total = total+order[i]+time[i]+amari;
        }
      	Arrays.sort(time);
      
      	if(time[0]!=0){
      		total = total - (10-time[0]);
          	 //調理時間出力
      		System.out.println(total);
         }else if(time[1]!=0){
          	total = total - (10-time[1]);
          	System.out.println(total);
         }else if(time[2]!=0){
          	total = total - (10-time[2]);
          	System.out.println(total);
         }else if(time[3]!=0){
          	total = total - (10-time[3]);
          	System.out.println(total);
         }else if(time[4]!=0){
          	total = total - (10-time[4]);
          	System.out.println(total);
         }else if(time[4]==0){
          	System.out.println(total);
        }
      
    }
}

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

using namespace std;

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

    int N;
    cin >> N;

    int x = N*100/108;

    while(x*108/100<N) x++;

    if(x*108/100==N) cout << x;
    else cout << ":(";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int r,g,b;
	cin >> r >> g >> b;
	int score = r * 100 + g * 10 + b;
	if(score % 4 == 0)cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import copy

N=int(input())
P=[list(map(int,input().split()))+[i] for i in range(N)]
Q=copy.deepcopy(P)

#UnionFind

Group=[i for i in range(N)]#グループ分け.Group[i]=jのときiとjは同じグループ

def find(x):#find(a)=find(b)のとき同じグループ
    while Group[x] != x:
        x=Group[x]
    return x

def Union(x,y):  # xとyが同じグループになるよう更新
    if find(x) != find(y):
        Group[find(y)]=Group[find(x)]=min(find(y),find(x))

P.sort(key=lambda x:x[0])

for i in range(1,N):
    if P[i][0]==P[i-1][0]:
        Union(P[i][2],P[i-1][2])


P.sort(key=lambda x:x[1])

for i in range(1,N):
    if P[i][1]==P[i-1][1]:
        Union(P[i][2],P[i-1][2])

#print([find(i) for i in range(N)])
#F=[find(i) for i in range(N)]
#S=set(F)

B=[[] for i in range(N)]

for i in range(N):
    B[find(i)].append(i)

ANS=0
for BEL in B:
    X=[]
    Y=[]
    for b in BEL:
        X.append(Q[b][0])
        Y.append(Q[b][1])

    #print(BEL,X,Y)
    ANS+=len(set(X))*len(set(Y))-len(BEL)
print(ANS)
        


Measured memory_bytes: 125404
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
#include <memory>
#include <time.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-9;
const double PI  = acos(-1.0);

const ll M=1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;
int main(){
	int n,w;
	cin>>n>>w;
	vi f(n);
	REP(i,n){
		cin>>f[i];
	}
	sort(ALL(f));
	vvl dp(n,vl(w+1));
	if(f[n-1]<=w){
		dp[n-1][f[n-1]]=1;
	}
	dp[n-1][0]=1;
	for(int i=n-2;i>=0;i--){
		REP(j,w+1){
			if(j-f[i]>=0&&j-f[i]<=w){
				dp[i][j]+=dp[i+1][j-f[i]];
			}
			dp[i][j]+=dp[i+1][j];
			dp[i][j]%=M;
		}
	}
	ll ans=0;
	REP(i,n+1){
		ll cnt=0;
		int weight=0;
		REP(j,i){
			weight+=f[j];
		}
		if(i<n){
			FOR(j,w-f[i]+1,w-(i==0?0:f[i-1])+1){
				if(j-weight>=0&&j-weight<=w){
					cnt+=dp[i][j-weight];
					cnt%=M;
				}
			}
		}else{
			cnt=w-f[i-1]-weight>=0;
		}
		ans+=cnt;
		ans%=M;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 16844
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

struct Heap {
	Heap *l, *r;
	int val;
	int pos;
	Heap(int val, int pos) : val(val), pos(pos){
		l = r = (Heap *)0;
	}
};

Heap *root;

Heap *meld(Heap *a, Heap *b)
{
	if (!a) return (b);
	if (!b) return (a);
	
	if (a->val > b->val) swap(a, b);
	a->r = meld(a->r, b);
	swap(a->l, a->r);
	
	return (a);
}

void push(Heap x)
{
	Heap *p = new Heap(x);
	
	root = meld(root, p);
}

Heap top()
{
	return (*root);
}

void pop()
{
	Heap *p = root;
	
	root = meld(root->r, root->l);
	delete p;
}

int reqLevel[2][500 * 500 + 1];
int map[512][512];
bool visited[512][512];
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};

int main()
{
	int R;
	
	while (scanf("%d", &R) && R){
		
		for (int t = 0; t < 2; t++){
			int W, H, Sx, Sy;
			scanf("%d %d %d %d", &W, &H, &Sx, &Sy);
			
			for (int i = 1; i <= R; i++){
				reqLevel[t][i] = 1000000000;
			}
			
			for (int i = 0; i < H; i++){
				for (int j = 0; j < W; j++){
					scanf("%d", &map[i][j]);
				}
			}
			
			memset(visited, 0, sizeof(visited));
			--Sy; --Sx;
			push(Heap(map[Sy][Sx], Sy * 1000 + Sx));
			int req = 0;
			int num = 0;
			while (root){
				Heap x = top();
				pop();
				
				if (visited[x.pos / 1000][x.pos % 1000]) continue;
				visited[x.pos / 1000][x.pos % 1000] = true;
				
				req = max(req, x.val);
				reqLevel[t][++num] = req;
				
				for (int i = 0; i < 4; i++){
					int ny = x.pos / 1000 + dy[i], nx = x.pos % 1000 + dx[i];
					if (0 <= ny && ny < H && 0 <= nx && nx < W){
						push(Heap(map[ny][nx], ny * 1000 + nx));
					}
				}
			}
		}
		
		int ans = 2000000000;
		
		for (int i = 0; i <= R; i++){
			ans = min(ans, reqLevel[0][i] + reqLevel[1][R - i]);
		}
		
		printf("%d\n", ans);
	}
	
	return (0);
}

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

#define N 100

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

int dist(int x1, int y1, int x2, int y2) {
	return pow2(x2-x1)+pow2(y2-y1);
}

#define S "Safe"
#define D "Danger"

int main() {
	int n, m;
	int wx[N], wy[N], r[N];
	bool safe;
	int tx, ty, sx, sy;
	while(cin >> n && n) {
		rep(i, n) {
			cin >> wx[i] >> wy[i] >> r[i];
			r[i] *= r[i];
		}
		cin >> m;
		rep(i, m) {
			cin >> tx >> ty >> sx >> sy;
			int dx = sx - tx, dy = sy - ty;
			safe = false;
			rep(j, n) {
				bool isin_t = dist(tx, ty, wx[j], wy[j])<=r[j];
				bool isin_s = dist(sx, sy, wx[j], wy[j])<=r[j];
				if( isin_t ^ isin_s ) {
					safe = true;
					break;
				}
				int t1 = -( dx*(tx-wx[j]) + dy*(ty-wy[j]) ), t0 = pow2(dx) + pow2(dy);
				if(!isin_s && !isin_t && 0<=t1 && t1<=t0 && pow2( dx*(ty-wy[j]) - dy*(tx-wx[j]) ) <= t0*r[j]) {
					safe = true;
					break;
				}
			}
			cout << (safe ? S : D) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    import os, zlib, base64
    open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c${TYO>cuR480@qAH2g<SksD5J4|Tok8~W85Fi=^lxC{7Uq74hU0=X{&(AMTO53&2Xd%xxXSJz7>bCE!gI2XS<-(vOg8X%LXU;vhylGT3lX}ZdrAE@IQs{2RE9GR(EkmL<t_%ZNs1oq^`kGMW(1(Ga6!i>F7X}`H7r5y^)s+#F<9Kdtv{BTL6HF9?=_=i%VE`DDGzbO~GDv*+Uh77|Wh7Au1V>|0yp(l`$OpW=ry#82-wQ%&5*=L<I3nkS91mLMeyjnxoC_Mo3uVbQ@U1`8@2@<^5lK3Aat{slZ0e;f-VC71YKCFZGT@9(su?&&4({63n|X#@)0TYNZqu@}piynS!l;c`8{%8;w6tA`FP1qj<+5Xskk~=E1`badh}FFHdOq<Z@*POwP?JBF$%S|<lLNOc5Aw%s(BC5>_v-Un{8mi7T;8d_YO*KO;Xw>(82E=B9iEFXbHIzhll}vB`qr2")))
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Measured memory_bytes: 9804
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

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

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

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

void debug(VS &board){
	int h = board.size();
	rep(i,h){
		cout<<board.at(i)<<endl;
	}
	return;
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

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

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	int s,w;
	cin>>s>>w;
	if(s<=w){
		cout<<"unsafe"<<endl;
	}else{
		cout<<"safe"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3632
input = gets.split("\s")
m = input[0].to_i
d = input[1].to_i
result = 0

m.times do |month|
  d.times do |day|
    day1 = (day+1) % 10
    day10 = (day+1) / 10
    if(day1 > 1 && day10 > 1)
      if(day1 * day10 == month+1)
        result += 1
      end
    end
  end
end

puts result


Measured memory_bytes: 1788
N, T = map(int, input().split())
ct = [tuple(map(int, input().split())) for _ in range(N)]
min_cost = 10**9 + 7
for c, t in ct:
    if t <= T:
        min_cost = min(min_cost, c)
print("TLE" if min_cost == 10**9 + 7 else min_cost)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll a, b, c, d, e, f;
bool poss[4000];
bool poss2[4000];
pair<ld, pair<ll, ll> > ans;
int main()
{
	scanf("%lld%lld%lld%lld%lld%lld", &a, &b, &c, &d, &e, &f);
	for (ll i = 0; i < 30; i++)
	{
		for (ll j = 0; j < 30; j++)
		{
			if (a*100*i + b*100*j <= f)
			{
				poss[a*100*i + b*100*j] = true;
			}
		}
	}
	for (ll i = 0; i < 3000; i++)
	{
		for (ll j = 0; j < 3000; j++)
		{
			if (c*i + d*j <= f)
			{
				poss2[c*i + d*j] = true;
			}
		}
	}
	for (ll i = 1; i <= f; i++)
	{
		if (poss[i])
		{
			for (ll j = 0; j <= (((ld)i)/100)*e; j++)
			{
				if (poss2[j] && i+j <= f)
				{	
					ans = max(ans, make_pair((ld)j/(i+j), make_pair(i, j)));
				}
			}
		}
	}
	printf("%lld %lld\n", ans.second.first+ans.second.second, ans.second.second);
}

Measured memory_bytes: 256
#include<stdio.h>

void call(int);

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

  call(n);
  return 0;
}

void call(int n){
  int i;
  int x;

  for(i = 1; i <= n; i++){
    x = i;
    if(x % 3 == 0){
      printf(" %d", i);
    }
    else if(x % 10 == 3){
      printf(" %d", i);
    }
    else {
      while(x != 0){
	if(x % 10 == 3){
	  printf(" %d", i);
	  break;
	}
	x /= 10;
      }
    }
  }

  printf("\n");
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
unsigned long long n;
int main(){
	cin>>n;
	if (n%2==1)
		cout<<0<<endl;
	else{
		if (0<=n&&n<10)
			cout<<0<<endl;
		else{
			unsigned long long num=0;
			num+=n/10;
			n/=10;
			while(n>0){
				n=n/5;
				num+=n;
			}
			cout<<num<<endl;
		}
	}
	return 0;
}

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

int main(){
    int n;
    cin >> n;
	vector<char> s(n);
    rep(i,n) cin>>s[i];
    int ans=0;
    rep(i,n){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=20,INF=1<<28;

int dis[MAX][MAX],N;

void floyd(){
    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
            }
        }
    }
}

int main(){

    int E;cin>>N>>E;
    vector<int> cnt(N);
    
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            dis[i][j]=INF;
            if(i==j) dis[i][j]=0;
        }
    }
    int sum=0;
    for(int i=0;i<E;i++){
        int a,b,c;cin>>a>>b>>c;
        sum+=c;
        dis[a][b]=min(dis[a][b],c);
        dis[b][a]=min(dis[b][a],c);
        cnt[a]++;
        cnt[b]++;
    }
    
    floyd();
    
    vector<int> S;
    
    for(int i=0;i<N;i++){
        if(cnt[i]%2==1) S.push_back(i);
    }
    
    if(S.size()==0) cout<<sum<<endl;
    else{
        int M=S.size();
        int dp[(1<<M)];
        for(int i=0;i<(1<<M);i++){
            dp[i]=INF;
        }
        dp[0]=0;
        for(int i=0;i<(1<<M);i++){
            for(int j=0;j<M;j++){
                if(i&(1<<j)) continue;
                for(int k=0;k<M;k++){
                    if(i&(1<<k)) continue;
                    if(j==k) continue;
                    dp[i|(1<<j)|(1<<k)]=min(dp[i]+dis[S[j]][S[k]],dp[i|(1<<j)|(1<<k)]);
                }
            }
        }
        
        cout<<sum+dp[(1<<M)-1]<<endl;
        
    }
    
}




Measured memory_bytes: 3204
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    if N%2 ==0:
        print(N)
    else:
        print(N*2)
        
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include<stdio.h>

int main(void){
    double a,b,c,d,e,f,x,y;
    while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f) != EOF){
        if(a < 0){
            a = a * -1;
            b = b * -1;
            c = c * -1;
        }
        if(d < 0){
            d = d * -1;
            e = e * -1;
            f = f * -1;
        }
        if(!(a == 0 || d == 0)){
            b = b * d / a;
            c = c * d / a;
            a = d;
            e = e - b;
            f = f - c;
            y = f / e;
            e = e + b;
            f = f + c;
            x = (f - e * y) / d;
        }
        else if(a == 0){
            y = c / b;
            x = (f - e * y) / d;
        }
        else{
            y = f / e;
            x = (c - b * y) / a;
        }
        printf("%.3lf %.3lf\n",x,y);
    }
    return 0;
}

Measured memory_bytes: 652
#include<bits/stdc++.h>
#define rep(i,start,lim) for(lld i=start;i<lim;i++)
#define repd(i,start,lim) for(lld i=start;i>=lim;i--)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld ",x)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define br printf("\n")
#define sz(a) lld((a).size())
#define YES printf("YES\n")
#define NO printf("NO\n")
#define all(c) (c).begin(),(c).end()
#define INF         1011111111
#define LLINF       1000111000111000111LL
#define EPS         (double)1e-10
#define MOD         1000000007
#define PI          3.14159265358979323
using namespace std;
typedef long double ldb;
typedef long long lld;
lld powm(lld base,lld exp,lld mod=MOD) {lld ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
lld ctl(char x,char an='a') {return (lld)(x-an);}
char ltc(lld x,char an='a') {return (char)(x+an);}
#define bit(x,j) ((x>>j)&1)
typedef vector<lld> vlld;
typedef pair<lld,lld> plld;
typedef map<lld,lld> mlld;
typedef set<lld> slld;
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mxm(a,b) a = max(a,b)
#define mnm(a,b) a = min(a,b)
#define endl '\n'
#define fre freopen("1.in","r",stdin); freopen("1.out","w",stdout);
#define N 1000005
int main()
{
    //sync;
    lld n,ans = 0, x;
    cin>>n;
    while(n--) {
        cin>>x;
        while(x%2==0) ans++,x/=2;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // setprecision
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;
const double long PI = acos(-1);

vector<ll> is = {7, 5, 3};

ll dfs(ll s, ll N) {
  if (s > N) return 0;
  ll ret = (s > 0);
  for (auto i=is.begin();i!=is.end();i++){
    int flag = 0;
    for (ll a=s;a!=0;a/=10) {
      if (a % 10 == *i) flag = 1;
    }
    if (flag == 0) ret = 0;
  }
  for (auto i=is.begin();i!=is.end();i++){
    ret += dfs(s * 10 + *i, N);
  }
  return ret;
}

void solve() {
  ll N, counter;
  cin >> N;

  cout << dfs(0, N) << endl;
}

int main(void) {
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	private class Node {
		int id, parent=-1, left=-1, right=-1, sibling=-1, depth, height=-1;
		public Node(int id) {
			this.id = id;
		}
		public String toString() {
			StringBuilder sb = new StringBuilder();
			sb.append("node " + id + ": ");
			sb.append("parent = " + parent + ", ");
			sb.append("sibling = " + sibling + ", ");
			sb.append("degree = " + getDegree() + ", ");
			sb.append("depth = " + depth + ", ");
			sb.append("height = " + height + ", ");
			if (parent == -1) {
				sb.append("root");
			} else if (getDegree() == 0) {
				sb.append("leaf");
			} else {
				sb.append("internal node");
			}
			return sb.toString();
		}
		private int getDegree() {
			int degree = 0;
			if (left != -1) degree++;
			if (right != -1) degree++;
			return degree;
		}
	}
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		Node[] nodes = new Node[n];
		for (int i = 0; i < n; i++) {
			StringTokenizer st = new StringTokenizer(reader.readLine());
			int id = Integer.parseInt(st.nextToken());
			int left = Integer.parseInt(st.nextToken());
			int right = Integer.parseInt(st.nextToken());
			if (nodes[id] == null) {
				nodes[id] = new Node(id);
			}
			nodes[id].left = left;
			nodes[id].right = right;
			if (left != -1 && nodes[left] == null) {
				nodes[left] = new Node(left);
			}
			if (right != -1 && nodes[right] == null) {
				nodes[right] = new Node(right);
			}
			if (left != -1) {
				nodes[left].sibling = right;
				nodes[left].parent = id;
			}
			if (right != -1) {
				nodes[right].sibling = left;
				nodes[right].parent = id;
			}
		}
		reader.close();
		
		int rootId = -1;
		for (int i = 0; i < n; i++) {
			if (nodes[i].parent == -1) {
				rootId = nodes[i].id;
				break;
			}
		}
		
		setDepth(nodes, rootId);
		setHeight(nodes, rootId);
		
		for (int i = 0; i < n; i++) {
			System.out.println(nodes[i]);
		}
	}
	
	private void setDepth(Node[] nodes, int id) {
		if (nodes[id].left != -1) {
			nodes[nodes[id].left].depth = nodes[id].depth + 1;
			setDepth(nodes, nodes[id].left);
		}
		if (nodes[id].right != -1) {
			nodes[nodes[id].right].depth = nodes[id].depth + 1;
			setDepth(nodes, nodes[id].right);
		}
	}
	
	private void setHeight(Node[] nodes, int id) {
		if (nodes[id].right != -1) {
			setHeight(nodes, nodes[id].right);
		}		
		if (nodes[id].left != -1) {
			setHeight(nodes, nodes[id].left);
		}
		if (nodes[id].getDegree() == 0) {
			nodes[id].height = 0;
		}
		if (nodes[id].left != -1) {
			nodes[id].height = Math.max(nodes[id].height, nodes[nodes[id].left].height + 1);
		}
		if (nodes[id].right != -1) {
			nodes[id].height = Math.max(nodes[id].height, nodes[nodes[id].right].height + 1);
		}
	}
}



Measured memory_bytes: 24276
nb = int(input())
l = list(map(int,input().split()))
d = dict()
m = 0
for i in l:
   if i in d:
      d[i] += 1
   else:
      d[i] = 1
for k in d:
   if d[k] < k:
      m += d[k]
   else:
      m += d[k] - k
print(m)


Measured memory_bytes: 18168
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

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

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n;
  cin>>n;
  char field[300][300]={};
  int result=0;
  for(int r=0;r<n;r++){
    for(int c=0;c<n;c++){
      cin>>field[r][c];
    }
  }

  for(int axis_begin_row=0;axis_begin_row<n;axis_begin_row++){
    bool isok=true;
    for(int r=0;r<n;r++){
      for(int c=0;c<n;c++){
        int r_left=(r+axis_begin_row>=n)?r+axis_begin_row-n:r+axis_begin_row;
        int c_right=(c+axis_begin_row>=n)?c+axis_begin_row-n:c+axis_begin_row;
        if(field[r_left][c]!=field[c_right][r]){
          isok=false;
          break;
        }
      }
      if(!isok) break;
    }
    if(isok){
      result+=n;
    }
  }
  cout<<result<<endl;

  return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  set<int> st;
  REP(i, K) st.insert(min(A + i, B));
  REP(i, K) st.insert(max(B - i, A));
  for (auto a : st) cout << a << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import deque
n,m=map(int,input().split())
print('Yes')
root=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    root[a-1].append(b-1)
    root[b-1].append(a-1)
q=deque([0])
check=[0]*n
while q:
    e=q.popleft()
    for i in root[e]:
        if check[i]:
            continue
        check[i]=e+1
        q.append(i)
for i in range(1,n):
    print(check[i])

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

typedef long double     ld;
typedef long long       ll;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;

const int inf = 0x3f3f3f3f;
const ll  INF = 0x3f3f3f3f3f3f3f3f;

#define FOR(i, b, e)    for(int i=b; i<=e; i++)
#define FORD(i, b, e)   for(int i=b; i>=e; i--)
#define SIZE(x)         ((int)(x).size())
#define pb              push_back
#define st              first
#define nd              second
#define all(a)          begin(a), end(a)
#define watch(x)        cerr << (#x) << " is " << (x) << '\n';

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

    int a; string s;
    cin>>a>>s;

    if(a>=3200){
        cout<<s;
    }
    else{
        cout<<"red";
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,a[700][700],la,cnt;
struct PP{int a,b,c,d;}an[250007];
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>m;for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)cin>>a[i][j];
	for(int i=1;i<=n;i++){
		if(i&1){
			for(int j=1;j<=m;j++){
				if(la){
					if(j==1){
						an[++cnt].a=i-1;
						an[cnt].b=1;
						an[cnt].c=i;
						an[cnt].d=1;
					}
					else{
						an[++cnt].a=i;
						an[cnt].b=j-1;
						an[cnt].c=i;
						an[cnt].d=j;
					}
				}
				if(a[i][j]&1){
					la^=1;
				}
			}
		}
		else{
			for(int j=m;j>=1;j--){
				if(la){
					if(j==m){
						an[++cnt].a=i-1;
						an[cnt].b=m;
						an[cnt].c=i;
						an[cnt].d=m;
					}
					else{
						an[++cnt].a=i;
						an[cnt].b=j+1;
						an[cnt].c=i;
						an[cnt].d=j;
					}
				}
				if(a[i][j]&1){
					la^=1;
				}
			}
		}
	}
	cout<<cnt<<endl;
	for(int i=1;i<=cnt;i++){
		cout<<an[i].a<<' '<<an[i].b<<' '<<an[i].c<<' '<<an[i].d<<endl;
	}
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair < int , int > pii;
#define mpr make_pair
#define FS first
#define SC second
#define PB push_back
template < typename T > void UMAX(T &a,T b){a=(a>b?a:b);}
template < typename T > void UMIN(T &a,T b){a=(a<b?a:b);}
LL readint(){
	char c=getchar();
	LL ret=0ll;
	bool neg=0;
	while(!(c>='0' && c<='9')){
		if(c=='-') neg=1;
		c=getchar();
	}
	while(c>='0' && c<='9'){
		ret=ret*10ll+(LL)(c-'0');
		c=getchar();
	}
	return neg?-ret:ret;
}
void putint(LL v){
	if(v<0){
		putchar('-');
		v=-v;
	}
	if(!v){
		putchar('0');
		return;
	}
	if(v>=10ll) putint(v/10ll);
	putchar('0'+(v%10ll));
}
int n,x[200005],y[200005],p[200005],ptr;
namespace DSU{
	int fa[200005],cnt[200005];
	void init(){
		int i;
		for(i=0;i<200005;++i) fa[i]=i,cnt[i]=0;
	}
	int anc(int x){
		return fa[x]==x?x:fa[x]=anc(fa[x]);
	}
	void unite(int x,int y){
		fa[anc(x)]=anc(y);
	}
}
namespace BIT{
	vector < int > a[200005];
	void init(){
		int i;
		for(i=0;i<200005;++i) a[i].clear();
	}
	void add(int p,int v){
		++p;
		while(p<=n){
			a[p].push_back(v);
			p+=p&-p;
		}
	}
	void ext(int p,int v){
		++p;
		while(p){
			if(!a[p].empty()){
				int i;
				for(i=1;i<(int)a[p].size();++i)
					DSU::unite(a[p][0],a[p][i]);
				DSU::unite(a[p][0],v);
				a[p].resize(1);
			}
			p-=p&-p;
		}
	}
}
bool cmpx(int a,int b){
	return x[a]<x[b];
}
int res[200005];
int main(){
	int i,j,k;
	n=readint();
	for(i=0;i<n;++i) x[i]=readint()-1,y[i]=readint()-1,p[i]=i;
	sort(p,p+n,cmpx);
	DSU::init();
	BIT::init();
	for(i=0;i<n;++i){
		BIT::ext(y[p[i]],p[i]);
		BIT::add(y[p[i]],p[i]);
	}
	BIT::init();
	for(i=n-1;i>=0;--i){
		BIT::ext(n-1-y[p[i]],p[i]);
		BIT::add(n-1-y[p[i]],p[i]);
	}
	for(i=0;i<n;++i) ++DSU::cnt[DSU::anc(i)];
	for(i=0;i<n;++i) printf("%d\n",DSU::cnt[DSU::anc(i)]);
	return 0;
}


Measured memory_bytes: 23544
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<vector<int> > nodes(n);
  vector<pair<int, int> > edge(n-1);
  map<pair<int,int>, int> mp;
  map<pair<int, int>, int> used;
  vector<int> cl(n-1);
  for(int i = 0; i < n-1; i++){
    int a, b;
    cin >> a >> b;
    a--;b--;
    int c = max(a,b);
    a = min(a,b);
    b = c;
    edge[i] = {a,b};
    nodes[a].push_back(b);
    nodes[b].push_back(a);
    mp[{a,b}] = i;
    used[{a,b}] = 0;
  }
  int maxi = 0;
  for(int i = 0; i < n; i++){
    maxi = max(maxi, (int)nodes[i].size());
  }
  cout << maxi << endl;
  for(int i = 0; i < n; i++){
    int col = 0;
    for(int j = 0; j < nodes[i].size(); j++){
      if(used[{min(i, nodes[i][j]), max(i, nodes[i][j])}]){
        // cout << i << ' ' << j << ' ' << cl[mp[{min(i, nodes[i][j]), max(i, nodes[i][j])}]] << endl;
        col = cl[mp[{min(i, nodes[i][j]), max(i, nodes[i][j])}]];
      }
    }
    for(int j = 0; j < nodes[i].size(); j++){
      if(!used[{min(i, nodes[i][j]), max(i, nodes[i][j])}]){
        col = col%maxi+1;
        // cout << col << endl;
        used[{min(i, nodes[i][j]), max(i, nodes[i][j])}] = 1;
        cl[mp[{min(i, nodes[i][j]), max(i, nodes[i][j])}]] = col;
      }
    }
  }
  for(int i = 0; i < n-1; i++){
    cout << cl[i] << endl;
  }
}


Measured memory_bytes: 19712
#include<bits/stdc++.h>
using namespace std;
int sum1,sum2;
int main() {
    int n;
    cin >> n;
    int v[n],c[n];
    for(int i=0;i<n;i++) {
        cin >> v[i];
    }

    for(int i=0;i<n;i++) {
        cin >> c[i];
    }

    for(int i=0;i<n;i++) {
        if(v[i]>c[i]) sum1 += v[i]-c[i];
    }

    cout << sum1;

}


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

int main(void) {
	char s[200]={}, p[200]={};
	scanf("%s", s);
	scanf("%s", p);
	int m=2*strlen(s);
	char cir[400]={};
	int i, j;
	int k=0;
	for (i=0; i<m/2; i++)
	{
		cir[i]=s[i];
	}
	for (i=m/2; i<m; i++)
	{
		cir[i]=s[i-m/2];
	}
	int n=strlen(p);
	char sub[200]={};
	for (i=0; i<=m-n; i++)
	{
		for (j=i; j<i+n; j++)
		{
			sub[j-i]=cir[j];
		}
		if (strcmp(sub, p)==0)
		{
			k=1;
		}
	}
	if (k==1)
	{
		printf("Yes\n");
	}else printf("No\n");
	return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
#include<string>
#include<map>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define vii         vector<pair<ll,ll> >
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define rep1(i,a,b) for(ll i=a;i<= b;i++)
#define PI          3.14159
#define MAX         100000001
#define fast_io      ios_base::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
#define scan(var)    scanf("%lld",&var)
#define print(var)   printf("%lld\n", var);
#define BLOCK 317
#define double       long double
#define mod          998244353
using namespace std;
ll dp[100001];
ll arr[100001];
ll n,k;
ll solvedp(ll index, ll n)
{
  if(index >= n)
  {
    return INT_MAX;
  }
  if(index == n - 1)
  {
    return 0;
  }
  if(dp[index] != -1)
  {
    return dp[index];
  }
  ll ans = abs(arr[index] - arr[index + 1]) + solvedp(index + 1,n);
  for(int i = 2 ; i <= k; i++)
  {
    ans = min(ans,abs(arr[index] - arr[index + i]) + solvedp(index + i,n));
  }
  dp[index] = ans;
  return dp[index];
}
int main()
{
  fast_io
  cin >> n >> k;
  memset(dp,-1,sizeof(dp));
  rep(i,0,n)
  {
    cin >> arr[i];
  }
  cout << solvedp(0,n);
  return 0;
}



Measured memory_bytes: 6528
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,flag = 0;
	cin>>n;
	int f=0;
	for(int i = 0 ;i <= 25;i++){
		for(int j = 0 ;j <= 15;j++){
			if((i*4+j*7) == n){
				flag = 1;
				break;
			}
		}
		if(flag) 
		   break;
	}
	if(flag) 
		cout<<"Yes"<<endl;
	else 
		cout<<"No"<<endl;
	return 0;
}


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

using namespace std;

#define int long long
int const maxn = 2e5 + 5;
int a[maxn], pref[maxn];

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k, ans = 0;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 1; i <= n; ++i) pref[i] = pref[i - 1] + a[i];
    for (int i = k; i <= n; ++i) {
        ans = max(ans, pref[i] - pref[i - k]);
    }
    ans += k;
    if (ans % 2 == 0) {
        cout << ans / 2 << ".";
        for (int j = 0; j <= 7; ++j) cout << "0";
    }
    else {
        cout << ans / 2 << ".5";
        cout << "0000000";
    }
    return 0;
}



Measured memory_bytes: 3328
// B. 

#include <sstream>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;

static const LL MOD = 1000000007;

struct modll {
	long long x;
	modll() { }
	modll(long long _x) : x(_x) { }
	operator int() const { return (int)x; }
	modll operator+(const modll &r) { return (x + r.x) % MOD; }
	modll operator+=(const modll &r) { return x = (x + r.x) % MOD; }
	modll operator-(const modll &r) { return (x + MOD - r.x) % MOD; }
	modll operator-=(const modll &r) { return x = (x + MOD - r.x) % MOD; }
	modll operator*(const modll &r) { return (x * r.x) % MOD; }
	modll operator*(int r) { return (x * r) % MOD; }
	modll operator*=(const modll &r) { return x = (x * r.x) % MOD; }
	static modll modinv(int a) { return modpow(a, MOD - 2); }
	static modll modpow(int a, int b) {
		modll x = a, r = 1;
		for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
		return r;
	}
};

int main(int argc, char *argv[])
{
	int n;
	cin >> n;
	vector<LL> a(n);
	vector<modll> inv(n + 1), sum(n + 1, 0LL);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	modll x = 1;
	for (int i = 1; i <= n; ++i) {
		x *= i;
	}
	for (int i = 1; i <= n; ++i) {
		inv[i] = modll::modinv(i) * x;
		sum[i] = sum[i - 1] + inv[i];
	}
	modll ans = 0;
	for (int i = 0; i < n; ++i) {
		modll y = sum[i + 1] + sum[n - i] - sum[1];
		y *= a[i];
		ans += y;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2560
#!/usr/bin/ruby
# -*- coding: utf-8 -*-

w = []
10.times do
  w.push gets.to_i
end
y = []
10.times do
  y.push gets.to_i
end

w.sort!
y.sort!

printf "%d %d\n", w[9] + w[8] + w[7], y[9] + y[8] + y[7]
                 

Measured memory_bytes: 6100
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] h = new int[n];
        for(int i=0;i<n;i++){
            h[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        int max = 0;
        int res = 0;
        for(int i=0;i<n;i++){
            if(h[i] >= max){
                res++;
            }
            max = Math.max(max,h[i]);
        }
        System.out.println(res);
    }

}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N, X, ans = 0;
ll f(ll a, ll b)
{
	if (!a) return -b;
	if (!b) return -a;
	if (a < b) return f(a, b % a) + b / a * a * 2ll;
	else return f(a % b, b) + a / b * b * 2ll;
}

int main()
{
	cin >> N >> X;
	cout << f(X, N - X) + N << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

int N;
vector<vector<int>> G;
map<pair<int,int>,int> mp;
int ma = 0;

void dfs(int n, int pre, int col){
    for(auto nv : G[n]){
        if(nv == pre) continue;
        col++;
        col %= ma;
        int a = n, b = nv;
        if(a > b) swap(a,b);
        mp[{a,b}] = col;
        dfs(nv, n, col);
        //cout << pre << endl;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    G.resize(N);
    vector<int> a(N-1),b(N-1);
    REP(i,N-1){
        cin >> a[i] >> b[i];
        --a[i], --b[i];
        if(a[i] > b[i]) swap(a[i], b[i]);
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    int idx = 0;
    REP(i,N){
        if(chmax(ma, (int)G[i].size())) idx = i;
    }

    dfs(idx, -1, 0);
    cout << ma << endl;
    REP(i,N-1) cout << mp[{a[i], b[i]}] + 1 << endl;
}

Measured memory_bytes: 14976
#include<bits/stdc++.h>
using namespace std;
#define MAXN	2005
#define P	1000000007
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int dp[MAXN][MAXN], sum[MAXN][MAXN];
int main() {
	int n, k;
	read(n), read(k);
	dp[1][n - k] = 1;
	for (int i = 1; i <= n - k - 1; i++)
		dp[1][n - k] = dp[1][n - k] * 2 % P;
	sum[1][0] = dp[1][0];
	for (int i = 1; i <= n; i++)
		sum[1][i] = (sum[1][i - 1] + dp[1][i]) % P;
	for (int i = 2; i <= n; i++)
	for (int j = 0; j <= n; j++) {
		dp[i][j] = sum[i - 1][j + 1];
		if (j == 0) sum[i][j] = dp[i][j];
		else sum[i][j] = (sum[i][j - 1] + dp[i][j]) % P;
	}
	cout << dp[n][0] << endl;
	return 0;
}

Measured memory_bytes: 31744
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}




int main(){
  string s;
  cin >> s;
  for(int left=0;left<s.size();left++){
    for(int right=left;right<s.size();right++){
      string t=s.substr(0,left)+s.substr(right);
      if(t=="keyence"){
        cout<<"YES"<<endl;
        return 0;
      }
    }
  }
  cout <<"NO"<<endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>

constexpr double Deg = 180 / 3.1415926535897932;

int main() {
	double a, b, x;
	std::cin >> a >> b >> x;
	
	std::cout << std::setprecision(10);
	if (b * a * a < 2 * x)
		std::cout << std::atan2(2 * (b - x / a / a), a) * Deg << std::endl;
	else
		std::cout << std::atan2(b, 2 * x / b / a) * Deg << std::endl;
}

Measured memory_bytes: 256
'use strict'

const main = (input) => {
    const N = parseInt(input)
    let ans = 0
    for(let i = 0; ; i++){
        let pow = Math.pow(i, 2)
        if(pow > N) break
        ans = pow
    }
    console.log(ans)
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7372
H,W,N = map(int,input().split())
count = []
L = 0
for i in range(N):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    for i in range(max(0,a-2),min(a+1,H-2)):
        for j in range(max(0,b-2),min(b+1,W-2)):
            count.append((i,j))
            L += 1
count.sort()
ans = [0]*10
tmp = 1
for i in range(L-1):
    if count[i] == count[i+1]:
        tmp += 1
    else:
        ans[tmp] += 1
        tmp = 1
if L>=1:
  ans[tmp] += 1
ans[0] = (H-2)*(W-2)-sum(ans)
for i in range(10):
    print(ans[i])

Measured memory_bytes: 109000
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;

string s;
int cnt[130];
int used[130];
int tot;
vector<int> pos[130];
int a[210000];

int t[210000];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> s;
    int n = s.size();
    
    for (int i = 0; i < n; i++) cnt[s[i]]++;
    
    int odd = 0;
    for (int i = 'a'; i <= 'z'; i++) if (cnt[i] % 2 == 1) odd++;
    if (odd > 1) {
        cout << -1 << endl;
        return 0;
    }

    for (int i = 0; i < n; i++) {
        pos[s[i]].push_back(i);
    }

    for (int i = 0; i < n; i++) {
        if (used[s[i]] + 1 > pos[s[i]].size()) continue;
        else if (used[s[i]] + 1 == pos[s[i]].size() ) {
            a[i] = n / 2;
            used[s[i]]++;
        }
        else {
            a[i] = tot;
            a[pos[s[i]].back()] = n - 1 - tot;
            tot++;
            pos[s[i]].pop_back();
            used[s[i]]++;
        }
    }

    long long ans = 0;
    for (int i = 0; i < n; i++) {
        int ad = i;
        for (int x = a[i]+1; x > 0; x -= x&-x) ad -= t[x];
        ans += ad;
        for (int x = a[i]+1; x <= 200100; x += x&-x) t[x]++;
    }

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

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

typedef pair<int,int> P;

int main(){
  int n,a,b,cnt;
  char c;
  int inv[10010];
  vector<P> v[10010];
  map<int,int> m;

  bool first = true;

  while(cin >> n,n){
    v[0].clear();
    v[0].push_back(P(0,1000000001));
    inv[0] = -1;
    m.clear();
    m[0] = 0;
    cnt = 1;
    
    while(n--){
      cin >> c;
      if(c == 'W'){
	cin >> a >> b;
	int tmp = m[a] = cnt;
	v[tmp].clear();
	inv[cnt] = a;
	cnt++;
	while(b){
	  if(b<v[0][0].second){
	    v[tmp].push_back(P(v[0][0].first,b));
	    v[0][0].first += b;
	    v[0][0].second -= b;
	    b = 0;
	  }else{
	    v[tmp].push_back(v[0][0]);
	    b -= v[0][0].second;
	    v[0].erase(v[0].begin());
	  }
	} 
      }else if(c == 'D'){
	cin >> a;
	int tmp = m[a];
	for(int i=0;i<(int)v[tmp].size();i++)v[0].push_back(v[tmp][i]);
	sort(v[0].begin(),v[0].end());
	v[tmp].clear();
      }else{
	cin >> a;
	bool f = true;;
	for(int i=0;i<cnt;i++){
	  for(int j=0;j<(int)v[i].size();j++){
	    if(v[i][j].first<= a && a<v[i][j].first+v[i][j].second){
	      cout << inv[i] << endl;
	      f = false;
	      break;
	    }
	  }

	  if(!f)break;
	}
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 20000
X, N = list(map(int, input().split()))

if N == 0:
  print(X)
else:
  num_list = list(map(int, input().split()))
  sub_list = [x-X for x in num_list]
  
  for i in range(100):
    if -i not in sub_list:
      print(X - i)
      break
    elif i not in sub_list:
      print(X + i)
      break

Measured memory_bytes: 9184
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define SZ(X) ((int64_t)((X).size()))
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
#define doublemax (std::numeric_limits<double>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
//const double EPS = 1e-9;
//const double PI = acos(-1.0);




signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,T;
    cin>>N>>T;
    vector<int>t(N);
    rep(i,N)cin>>t[i];
    int ans = T;
    REP(i,1,N){
        ans+=min(T,t[i]-t[i-1]);
    }
    cout<<ans<<endl;
    
    
    return 0;
}




Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>
#include <cctype>
#include <ctype.h>

#define INF 100000000

using namespace std;

int main()
{
    string s;
    cin >> s;
    int ans = -1, tmp = 0;
    bool flag = true;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T')
        {
            while (flag)
            {
                if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T')
                    tmp++;
                else
                    flag = false;
                i++;
            }
            i--;
            ans = max(ans, tmp);
            tmp = 0;
            flag = true;
        }
        ans = max(ans, tmp);
        tmp = 0;
        flag = true;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char x[100005], y[100005];
int main(){
	scanf(" %s", x);
	int s = 0;
	for(int i = 0; x[i]; i ++ ) s = i;

	int ans = 0;
	for(int i = 0, j = s; x[i]; i ++, j -- ){
		//printf(" %c ? %c \n", x[i], x[j]);
		if ( i >= j ) break;
		if ( x[i] == x[j] ) continue;
		if ( x[i] == 'x' or x[j] == 'x' ) {
			if ( x[i] == 'x' ) j ++;
			else i --;
			ans ++;
		}
		else {
			puts("-1");
			return 0;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 384
/*▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ЗАПУСКАЕМ▒▀██████▄
░███▀▒▒▒▒▒ДЯДЮ▒▒▒▒▒▒▀█████
░▐██▒▒▒▒▒БОГДАНА▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄█████████████  █▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐*/
#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <math.h>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define DEBUG
#define fi first
#define se second
#define pqueue priority_queue
#define pb(x) push_back(x)
// #define endl '\n'
#define all(x) x.begin(), x.end()
#define int long long
#define mk(a, b) make_pair(a, b)

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vector<ll> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;
// typedef tuple<ll, ll, ll> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector< vector<ll> > vvi;
typedef vector<char> vc;
 
const ll INF = 1e9 + 228;
const ll INFLL = 1e18;
const ll MOD = 1e9 + 7;
// const ll MAXN = 3e5;
const ld eps = 1;
const ld eps2 = 1e-9;
const ll MOD2 = 998244353;
const ll dosz = 5e5;
const ll SZ = (1<<18);
const ld PI = atan2l(0, -1);

void fast_io(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	#ifdef DEBUG
//		freopen("a.in", "r", stdin);
	#endif
}
void solve(){
	string a, b;
	cin >> a >> b;
	if(b.substr(0, a.size()) == a){
		cout << "Yes" << endl;
	} else{
		cout << "No" << endl;
	}
}

signed main(){
	fast_io();
	int q = 1;
//	cin >> q;
	while(q--){
		solve();
	}

}


Measured memory_bytes: 3680
using System;
class Program
{    static void Main(String[] args){
  
    string[] str = Console.ReadLine().Split(' ');
    int a = int.Parse(str[0]);
    if (a%2==1){

        Console.WriteLine(a/2*(a/2+1));

    }else {
        Console.WriteLine(a/2*a/2);
        }   
    }   
}

Measured memory_bytes: 13140