akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<math.h>
#include <stdio.h>
#include<vector>
#include<deque>
#include<stdlib.h>
#include <algorithm>
#include<set>
#include<map>
#include <limits>
#include<iomanip>
#include<string>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
#define d_5 100000
#define d9_7 1000000007
//木構造グラフ
struct edge{
  struct treev* to;
  ll length;
};
struct treev{
  int num;
  vector<edge> nexts;
  ll len[3];//状態数的なアレ
};
struct input{
  int u;
  int v;
  ll w;
};
ll minlen;
  int s,t;
vector<treev*> vs;
treev* createtreenode(int num){
  treev* newt=new treev;
  if(newt==NULL){
    cout << "memory error" << endl;
    while(1){
      num=1;//メモリエラー対策
    }
  }
  newt->num=num;
  newt->nexts={};
  newt->len[0]=-1;
  newt->len[1]=-1;
  newt->len[2]=-1;
  //cout << "fff" << endl;
  return newt;
}
void insertree(ll len,int Va,int Vb){//結ぶ頂点を
  vs[Va]->nexts.push_back({vs[Vb],len});
  //vs[Vb]->nexts.push_back({vs[Va],len});
  return;
}
deque<pair<treev*,ll>> opera;
void search(){
  /*cout<<"begin"<<endl;;
  for(auto itr=opera.begin();itr!=opera.end();itr++){
    cout<<(*itr).first->num +1<<" "<<(*itr).second<<endl;
  }
  cout<<"end"<<endl;*/
  if(opera.empty()==true||minlen!=llMAX/10){
    //cout<<"found "<<minlen<<endl;
    return;
  }
  treev* root =(opera.front()).first;
  ll depth = (opera.front()).second;
  opera.pop_front();
  /*if(minlen<=d_5*50 && minlen*3+3<=depth){
  //cout<<"test3 "<<root->num+1<<" "<<depth<<endl;
    return;
  }*/
  
  //cout<<"test "<<root->num+1<<" "<<depth<<endl;
  if(root->num==t&&depth%3==0){
  //cout<<"test2 "<<root->num+1<<" "<<depth<<endl;
    minlen=min(minlen,depth/3);
    return;
  }
  if(root->len[depth%3]!=-1){
    if(root->len[depth%3]<=depth){
  //cout<<"test4 "<<root->num+1<<" "<<root->len[depth%3]<<" "<<depth<<endl;
  search();
      
      return;
    }
  }
  root->len[depth%3]=depth;
  //cout << "eee" << endl;
  //ここにやりたい処理を書く
  for(auto i:root->nexts){
    /*if(pre==i.to){
      continue;
    }*/
    /*if(minlen*3<=(root->len)[depth%3]){
      //cout<<"test1 "<< minlen << " " << root->num+1<<" "<<depth<<" "<<(root->len)[0]<<" "<<(root->len)[1]<<" "<<(root->len)[2]<<endl;
      return;
    }*/
      opera.push_back({i.to,depth+1});
  }
  //cout<<i.to->num+1<<" "<<root->num +1<<endl;;
  if(opera.empty()==false){
    search();
  }
  return;
}
 
  
int main(void){
  //今回は有向グラフ
  int m,n;
  cin>>n>>m;
  int u,v;
  minlen=llMAX/10;
  rep(i,n){
    vs.push_back(createtreenode(i));
  }
  rep(i,m){
    cin>>u>>v;
    u--;v--;
    insertree(1,u,v);
  }
  cin>>s>>t;
  s--;t--;
  opera.push_back({vs[s],0});
  search();
  if(minlen==llMAX/10){
    cout<<-1<<endl;
    return 0;
  }
  cout<<minlen<<endl;
  return 0;
}

Measured memory_bytes: 24436
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() (rand() >> 3)*rand()
#define scan(X) do{while((X=getchar())<'0'); for(X-='0'; '0'<=(_=getchar()); X=(X<<3)+(X<<1)+_-'0');}while(0)
char _;
#define pi 3.14159265358979323846

ll x, y;
int main(){
    cin >> x >> y;
    if (x%y==0) cout << -1;
    else if (y==1) cout << x;
    else cout << x*(y-1);
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

N = int(input())

data = []

for i in range(N):
    price = input().split()
    data.append(price) 

total = 0

for i in range(N):
    if data[i][1] == "JPY":
        total += int(data[i][0])
    elif data[i][1] == "BTC":
        total += 380000 * float(data[i][0])

print(total)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  string S;
  cin>>N>>K>>S;
  if(S.at(K-1)=='A')
    S.at(K-1)='a';
  else if(S.at(K-1)=='B')
    S.at(K-1)='b';
  else
    S.at(K-1)='c';
  cout<<S<<endl;
  }

Measured memory_bytes: 256
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<ll,ll>&a,const pair<ll,ll>&b)
{
    return (a.second<b.second);
}
const int N=1e6+5;
int prime[N];
int vis[N+5];
int cnt[N],k=0;
void seive()
{
    prime[k++]=2;
    for(int i=3;i<N;i+=2)
    {
        if(!vis[i])
        {
            prime[k++]=i;
              for(int j=3*i;j<=N;j+=2*i)
            vis[j]=1;
        }

    }

}
int main()
{
    ios;
    seive();
    int n;
    cin>>n;
    int ar[n];
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
    }
    for(int i=0;i<n;i++)
    {
        int a=ar[i];
        if(ar[i]==1)
        {
            cnt[1]=1;
        }

        else
        {
            for(int k1=0;prime[k1]*prime[k1]<=a&&k1<k;k1++)
            {
                if(a%prime[k1]==0)
                {
                    while(a%prime[k1]==0)
                    {
                        a/=prime[k1];
                    }
                    cnt[prime[k1]]++;
                }
            }
            if(a!=1)
                cnt[a]++;
        }
    }
    int mx=*max_element(cnt,cnt+N);
    if(mx==1)
        cout<<"pairwise coprime"<<endl;
    else if(mx<n)
         cout<<"setwise coprime"<<endl;
    else
        cout<<"not coprime"<<endl;



}




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

int main() {
	int n;
	while (scanf("%d%*c", &n), n) {
		map<string, int>mp;
		rep(i, n) {
			string buf; getline(cin, buf);
			stringstream ss(buf);
			string s;
			while (getline(ss, s, ' '))mp[s]++;
		}
		vector<P>v;
		char c; cin >> c;
		for (auto p : mp) {
			if (p.first[0] == c)
				v.push_back({ p.second,p.first });
		}
		if (v.empty())printf("NA");
		sort(v.begin(), v.end(), [](P a, P b) {
			if (a.first == b.first)return a.second < b.second;
			return a.first > b.first;
		});
		rep(i, min(5, (int)v.size())) {
			cout << (!i ? "" : " ") << v[i].second;
		}
		cout << endl;
	}
}

Measured memory_bytes: 3352
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int oo =1e18;
const int MOD = 1e9 + 7;
const int Nmax = 1005;

int gt[Nmax];
int inv[Nmax];
int dp[Nmax][Nmax];
int n,a,b,c,d;

int power(int n, int k)
{
    if (k == 0) return 1;
    int tmp = power(n, k / 2);
    tmp = tmp * tmp % MOD;
    if (k % 2) return tmp * n % MOD;
    return tmp;
}

void init()
{
    gt[0] = 1;
    for (int i = 1; i <= 1000; i++)
    {
        gt[i] = gt[i - 1] * i;
        if (gt[i] > MOD) gt[i] %= MOD;
    }
    inv[0] = 1;
    for (int i = 1; i <= 1000; i++)
    {
        inv[i] = power(gt[i], MOD - 2);
    }
}

signed main()
{
    //freopen("file.inp","r",stdin);
    init();
    cin >> n >> a >> b >> c >> d;
    dp[a - 1][0] = 1;
    for (int i = a; i <= b; i++)
    for (int j = 0; j <= n; j++)
    {
        dp[i][j] += dp[i - 1][j];
        for (int k = c; k <= d; k++)
        {
            if (i * k > j) break;
            int res = gt[j] * power(inv[i], k) % MOD * inv[j - k * i] % MOD * inv[k] % MOD;
            dp[i][j] += dp[i - 1][j - i * k] * res % MOD;
            if (dp[i][j] > MOD) dp[i][j] %= MOD;
        }
    }
    cout << dp[b][n];
    return 0;
}


Measured memory_bytes: 8064
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include "bitset"
#include "cmath"
#include "list"
#include "complex"
#include <cassert>
#include "deque"
#include "numeric"
#include <cstdio>

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++) 
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
//#define mp make_pair
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
#define endl '\n'
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;
#define int long long
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

const int sze = 3e5 + 50, oo = 1e18 + 500, mod = 1e9 + 7;
const double eps = 1e-9, PI = 2 * acos(0.0);
vi vertices[sze];
vc visit(sze, false);
vc used(sze, false);
vi arr(sze, 0);
int n, m, k;
int A, B;
int cnt = 0;

vi dp(sze, oo);

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

	cin >> n;
	vi h(n);

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

	dp[0] = 0;
	for (int i = 0; i < n; i++)
	{
		if (i + 1 < n)
		{
			mini(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
		}

		if (i + 2 < n)
		{
			mini(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
		}
	}

	cout << dp[n - 1];
	return 0;
}

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

int main(){
	int S,h,m,s;
	cin >> S;
	h = S/3600;
	m=(S-3600*h)/60;
	s=S-3600*h-60*m;
	cout << h << ":" << m << ":" << s <<endl;
	return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int main() {
	int n;
	long long a[100000];

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

	sort(a, a + n); //昇順にソート

	long long p = a[n - 1];
	long long r = 0;

	if (p % 2 == 0) {
		long long p2 = a[n - 1] / 2;
		for (int i = 0; i<n - 1; i++) {
			if (abs(r - p2) > abs(a[i] - p2)) {
				r = a[i];
			}
		}
	}
	else {
		double p2 = (double)a[n - 1] / 2;
		for (int i = 0; i<n - 1; i++) {
			if (abs((double)r - p2) > abs((double)a[i] - p2)) {
				r = a[i];
			}
		}
	}

	cout << p << " " << r;

	return 0;
}

Measured memory_bytes: 1024
def run(x):
    '''

    '''


    # sum = 0
    # while x > 0:
    #     sum += x%10
    #     x = int(x/10)

    # print('Yes' if sum % 9 == 0 else 'No')
    print('Yes' if x % 9 == 0 else 'No')


if __name__ == '__main__':
    x = int(input())
    run(x)

Measured memory_bytes: 9220
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int A = sc.nextInt();

		if(X < A) {
			System.out.println(0);
		}else {
			System.out.println(10);
		}
	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <string>

using namespace std;
int main(){
	string S;
	cin >> S;
	if(S.size()%2==1){
		cout << "No\n";
		return 0;
	}
	for (int i = 0; i < S.size()/2; ++i)
	{
		if(S[i*2] != 'h'  || S[i*2+1] != 'i'){
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
}

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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0);

signed main () {
  cin.tie(0);
  cout << setprecision(10);
  int n; cin >> n;
  if(n == 1) {
    cout << "Hello World" << endl;
    return 0;
  }
  int a, b; cin >> a >> b;
  int ans = a + b;


  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			(3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
template<class T> void chmax(T &a, const T &b){if(a<b)a=b;}
template<class T> void chmin(T &a, const T &b){if(a>b)a=b;}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	double a,b;
	cin>>a>>b;
	fcout(10);
	cout<<a/b<<endl;
	
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
typedef pair<int,int> P;
const int MAX_N=2e5;
int N;
P X[MAX_N];
int ans[MAX_N];
int main(){
	cin>>N;
	REP(i,N){
		int x;
		cin>>x;
		X[i]=P(x,i);
	}
	sort(X,X+N);
	REP(i,N){
		if (i<N/2){
			ans[X[i].second]=X[N/2].first;
		}else{
			ans[X[i].second]=X[N/2-1].first;
		}
	}
	REP(i,N){
		cout<<ans[i]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 4480
a = gets.chomp.split.map(&:to_i)
b,ans = [],[]
a[0].times{b << gets.chomp.split.map(&:to_i)}
b.delete_if{|b_1,b_2| b_2>a[1]}.map{|b_1,b_2|ans << b_1}
puts ans.size != 0 ? ans.min : "TLE"

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

string s, t;
int a, b, c;
int main(){
  cin >> s >> t;
  bool flag = true;
  rep(i, s.size()){
    if(s.at(i) != t.at(i)) flag = false;
  }
  if(flag) cout << "Yes" <<endl;
  else cout << "No" <<endl;
}

Measured memory_bytes: 3632
//In the name of Allah :)
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1e5 + 10;
int val[MAXN];
set <int> adj[MAXN];

int main(){
	ios_base::sync_with_stdio(NULL);cin.tie(nullptr);cout.tie(nullptr);
        int n , m , u , v;
        cin >> n >> m;
        for(int i = 0 ; i < n ; i++){
                cin >> val[i];
        }
        for(int i = 0 ; i < m ; i++){
                cin >> u >> v;
                adj[u-1].insert(val[v-1]);
                adj[v-1].insert(val[u-1]);

        }
        int ans = 0;
        for(int i = 0 ; i < n ; i++){
                if(adj[i].size() == 0){
                        ans++;
                        continue;
                }
                if(*adj[i].rbegin() < val[i]) ans++;
        }
        cout << ans << '\n'; 
        
}


Measured memory_bytes: 18056
using System;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            double input = double.Parse(Console.ReadLine());
            double area = input * input * Math.PI;
            double length = (input * 2) * Math.PI;
            Console.WriteLine(area + " " + length);
        }
    }
}

Measured memory_bytes: 9136
# カウントと踏破フラグをもっておくと二度目の踏破でループの長さが分かりそう

n, k = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))
count_arr = [0] * n
count = 0

now = 0
loop_length = -1
while True:
    if count == k:
        print(now + 1)
        exit()
    if count_arr[now] != 0:
        loop_length = count - count_arr[now] + 1
        break
    count += 1
    count_arr[now] = count
    now = a[now]

# 真の残り回数
rest = (k - count) % loop_length

# 既にゴールしてると見る場合
if rest == 0:
    print(now + 1)
    exit()

while rest > 0:
    rest -= 1
    if rest == 0:
        break
    now = a[now]
print(a[now] + 1)
# 727202214173249352

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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    for (int &x : a) cin >> x;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        bool ok = 1;
        for (int j = 0; j < i; j++) {
            ok &= (a[j] <= a[i]);
        }
        ans += ok;
    }
    cout << ans << '\n';
    return 0;
}


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

using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;

int main(){
    int N, sum = 0;
    int L[110];

    cin >> N;
    rep(i, N) cin >> L[i];

    sort(L, L + N);
    rep(i, N - 1){
        sum += L[i];
    }

    if(L[N - 1] < sum){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N (100009)
#define ll long long
using namespace std;
ll n,q,x,a[N],c,A[N],f[N];
int main()
{
	cin>>n>>q;
	a[++c]=n;
	for (ll i=1; i<=q; ++i)
	{
		cin>>x;
		while (c && x<=a[c]) --c;
		a[++c]=x;
	}
	f[c]=1;
	for (ll i=c; i; --i)
	{
		ll k=a[i];
		while (k>a[1])
		{
			ll t=lower_bound(a+1,a+c+1,k)-a-1;
			f[t]+=f[i]*(k/a[t]);
			k%=a[t];
		}
		A[k]+=f[i];
	}
	for (ll i=n; i; --i) A[i]+=A[i+1];
	for (ll i=1; i<=n; ++i) cout<<A[i]<<endl;
}

Measured memory_bytes: 4096
/* ****revpro**** */
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl	   '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii	    map<ll,ll>
using namespace std;

#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define N  100005
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;  
#define ordered_set tree<double, null_type,less<double>, rb_tree_tag,tree_order_statistics_node_update> 
void solve()
{
	ll n,k;
	cin>>n>>k;
	ll a[n+1];
	rep(i,1,n+1) cin>>a[i];
	vi v;
	ll vis[n+1]={0};
	ll cur=1;
	while(!vis[cur]){
		v.pb(cur);
		vis[cur]=1;
		cur=a[cur];
	}	
	ll idx;
	rep(i,0,sz(v)) if(v[i]==cur) {
		idx=i;
		break;
	}
	k++;
	ll len=sz(v)-idx;
	if(k<=idx) cout<<v[k-1];
	else {
		k-=idx+1;
		k%=len;
		cout<<v[idx+k]<<endl;
	}
}
signed main()
{
	
		/***********************************/
    unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
    mt19937_64 generator (seed);

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
		
	}
	TIME
	return 0;
}

Measured memory_bytes: 8488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll n, ans, mul[10000005];

int main() {
	fastio; cin >> n;
	FOR(i, 1, n) {
		for (ll j = i; j <= n; j += i) mul[j]++;
		ans += mul[i] * i;
	}
	cout << ans;
}


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

#define int long long
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;
#define rep(i,a,n) for(int i=a; i<n; i++)
#define endl "\n"
#define E "\n"
#define show(arr) REP(i,arr.size()){cout<<arr[i]<<" ";}
const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;
const int MAX = 1e18;

#define N 5010

int sum(int x){
    int s=0;
    while(x>0){
        s+=x%10;
        x/=10;
    }
    return s;
}

void solve()
{
    int n,s=0;
    cin>>n;
    vi a(3*n,0);
    REP(i,3*n) cin>>a[i];
    sort(all(a));
    for (int i=3*n-2;i>=n;i-=2) s+=a[i];
    cout<<s;
}

signed main()
{
    int t=1;
    //cin>>t;
    WL(t)solve();

    return 0;
}




Measured memory_bytes: 5612
from collections import Counter
n = int(input())
list_N = list(map(int, input().split()))
list_L = []
list_R = []
for i in range(n):
    if i % 2 == 0:
        list_L.append(list_N[i])
    else:
        list_R.append(list_N[i])

list_L_V = Counter(list_L)
list_R_V = Counter(list_R)

list_L_V = list_L_V.items()
list_R_V = list_R_V.items()

list_L_V = sorted(list_L_V, key=lambda x:x[1], reverse=True)
list_R_V = sorted(list_R_V, key=lambda x:x[1], reverse=True)

list_L_V.append((0, 0))
list_R_V.append((0, 0))

ans = 0
if list_L_V[0][0] != list_R_V[0][0]:
    ans += n - list_L_V[0][1] - list_R_V[0][1]
else:
    ans += min(n - list_L_V[1][1] - list_R_V[0][1], n - list_L_V[0][1] - list_R_V[1][1])

print(ans)

Measured memory_bytes: 20700
from itertools import *
f=lambda:map(int,input().split())
g=lambda:[0]+[*accumulate(f())]
n,m,k=f()
A,B=g(),g()
c,j=0,m
for i,a in enumerate(A):
  while j and a+B[j]>k: j-=1
  if a+B[j]<=k: c=max(c,i+j)
print(c)

Measured memory_bytes: 48368
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (a) - 1; (i) >= (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
const ll inf = 1e9;

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

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

int main(){
    ll n,c;
    cin >> n >> c;
    ll d[c][c],g[n][n],cnt[3][c];
    rep0(i, 3)rep0(j, c)cnt[i][j] = 0;
    rep0(i, c)rep0(j, c)cin >> d[i][j];
    rep0(i, n)rep0(j, n){
        cin >> g[i][j];
        --g[i][j];
        ++cnt[(i + j + 2) % 3][g[i][j]];
    }
    ll ans = inf;
    rep0(i, c)rep0(j, c){
        if(i == j)continue;
        rep0(k, c){
            if(j == k || i == k)continue;
            ll cnt1 = 0;
            rep0(l, c)cnt1 += d[l][i] * cnt[0][l];
            rep0(l, c)cnt1 += d[l][j] * cnt[1][l];
            rep0(l, c)cnt1 += d[l][k] * cnt[2][l];
            ans = min(ans,cnt1);
        }
    }
    pf(ans);
    return 0;
}


Measured memory_bytes: 2176
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

res = 0
for i in range(N):
  res += B[A[i]-1]
  if i != 0:
    if A[i] == A[i-1] + 1:
      res += C[A[i-1]-1]
print(res)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
  	public static int verticalSide;
  	public static int holizonticalSide;
  
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int sx = sc.nextInt();
		int sy = sc.nextInt();
		int tx = sc.nextInt();
      	int ty = sc.nextInt();
      
      	// 答えをここに入れていくよ
      	List<String> ansList = new ArrayList<>(); 
 
      	// 縦の辺の長さ
      	verticalSide = ty - sy;
      	// 横の辺の長さ
      	holizonticalSide = tx - sx;
      
      	// 1往復目＿行き
      	shortest(ansList, "R", "U");
      
      	// 1往復目＿帰り
      	ansList.add("R");
      	verticalMove(ansList, "D");
      	ansList.add("D");
      	ansList.add("L");
      	holizonticalMove(ansList, "L");
      	ansList.add("U");
      
      	// 2往復目＿行き
      	ansList.add("L");
      	verticalMove(ansList, "U");
      	ansList.add("U");
      	ansList.add("R");
      	holizonticalMove(ansList, "R");
      	ansList.add("D");
      
      	// 2往復目＿帰り
      	shortest(ansList, "L", "D");
      
      	// Listを文字列連結する
      	String ans = String.join("", ansList);
      
      	// 出力
		System.out.println(ans);
	}
      
    // 最短で行く場合の道のり
   	private static void shortest(List<String> ansList, String horizonticalChar, String verticalChar){
    	// 長方形の横の辺上を移動する
		holizonticalMove(ansList, horizonticalChar);
        // 長方形の縦の辺上を移動する
       	verticalMove(ansList, verticalChar);
    }
      
    // 長方形の横の辺上を移動する
    private static void holizonticalMove(List<String> ansList, String horizonticalChar){
        for(int i = 0; i < holizonticalSide ; i++){
        	ansList.add(horizonticalChar);
       	}
  	}
      
  	// 長方形の縦の辺上を移動する
   	private static void verticalMove(List<String> ansList, String verticalChar){
    	for(int i = 0; i < verticalSide ; i++){
       		ansList.add(verticalChar);
     	}
  	}
 
      	
      	
 
}

Measured memory_bytes: 24020
#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;
 
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
 
template < typename T > using index_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)


const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;

int main() 
{

    fast();
      

    ll n;
    cin>>n;
    ll c=0;
    f(i,1,n+1)
    {
        str s=to_string(i);
        if(s.size()%2==1)
        {
            c++;
        }
    }    
    cout<<c;
    







  


    
    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define umap unordered_map<int, int>
#define F first
#define S second
#define pii pair<int, int>
#define endl "\n"
using namespace std;

int min_cost(int *a, int n, int *dp, int k){

	if(n==0) return 0;

	if(dp[n]!=-1) return dp[n];
	int ans = INT_MAX;
	for(int i=1; i<=k; i++) {

		if(n - k>=0) {
			ans = min(ans, min_cost(a, n - i, dp, k) + abs(a[n] - a[n - i]));
		}
		else{
			return abs(a[n] - a[0]);
		}
	}

	return dp[n] = ans;
}

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	// int t; cin >> t; while(t--)
	{
		int n, k;
		cin >> n >> k;
		int a[n + 1];
		for(int i=0; i<n; i++) cin >> a[i];

		int dp[100005];
		memset(dp, -1, sizeof(dp));

		cout << min_cost(a, n - 1, dp, k) << endl;
		// for(int i=0; i<n; i++) {
		// 	cout << dp[i] << " ";
		// }
		// cout << endl;

	}

	return 0;
}

Measured memory_bytes: 10368
#include <stdio.h>
#include <math.h>
int main(void){
    int a=0;
    int b=0;
    double avg=0;
    double ans=0;
    scanf("%d %d",&a,&b);
    avg = ((double)a + (double)b) / 2;
    ans = ceil(avg);
    printf("%d\n",(int)ans);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  int n=s.size();
  char p='a';int count;int flag=0;
  for(int i=0;i<26;i++){
    count=0;
    for(int j=0;j<n;j++)if(s.at(j)==p)count++;
    if(count%2==1){flag++;break;}
    p++;
  }
  if(flag!=0)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

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


using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 998244353;


int main() {

	string s;
	cin >> s;

	int k;
	cin >> k;
	if (s.size() == 1) {
		if (k == 1) {
			cout << s << endl;
		}
		else cout << 0 << endl;
		return 0;
	}


	VVLL dp(s.size(), VLL(k + 2, 0));
	VVLL b(s.size(), VLL(k + 2, false));

	dp[0][1] = (int)(s[0] - '0');
	dp[0][0] = 1;

	REP(i, s.size())dp[i][0] = 1;
	b[0][1] = true;



	REP(i, s.size() - 1) {
		dp[i][0] = 1;
		dp[i + 1][0] = 1;
		int num = (int)(s[i + 1] - '0');

		if (num == 0) {

			REP(j, k+1) {
				if (!b[i][j]) {
					dp[i + 1][j] += dp[i][j];
					dp[i + 1][j + 1] += dp[i][j] * 9 + num;
				}
				else {
					b[i + 1][j] = true;
					dp[i + 1][j] += dp[i][j];
					dp[i + 1][j + 1] += (dp[i][j] - 1) * 9;
				}
			}
		}
		else {
			REP(j, k+1) {
				if (!b[i][j]) {
					dp[i + 1][j] += dp[i][j];
					dp[i + 1][j + 1] += dp[i][j] * 9;
				}
				else {
					b[i + 1][j + 1] = true;
					dp[i + 1][j] += dp[i][j];
					dp[i + 1][j + 1] += (dp[i][j] - 1) * 9 + num;
				}
			}
		}
	}

	cout << dp[s.size()-1][k] << endl;

	
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int num;				// 参加人数
		long k;						// 初期持ち点
		long[] points = new long[100000];	// 各参加者の持ち点
		int question;			// 問題数

		// 入力の受け取り
		num = scan.nextInt();
		k = scan.nextLong();
		question = scan.nextInt();
		k -= question;		// 実質的な初期持ち点 ここに正解数を足し、1以上なら勝ち抜けと考える

		// 参加者全員の持ち点を初期化
		for(int i = 0; i < num; i++) {
			points[i] = k;
		}

		// 正解者リストを受け取り、点数計算を行う
		for(int i = 0; i < question; i++) {
			points[scan.nextInt() - 1] += 1;
		}

		// 結果を表示する
		for(int i = 0; i < num; i++) {
			if(points[i] >= 1) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}

	}
}


Measured memory_bytes: 58756
#include <stdio.h>

void printarray(int array[],int n){
	int i;
	for(i=0;i<n;++i){
		if(i)printf(" ");
		printf("%d",array[i]);
	}
	printf("\n");
}

int main(void){
	int n,i,j,key;
	int array[100];
	scanf("%d",&n);
	
	for(i=0;i<n;++i)
		scanf("%d",&array[i]);
		
	printarray(array,n);
	for(i=1;i<n;++i){
		key = array[i];
		j=i-1;
		while(j>=0&&array[j]>key){
			array[j+1] = array[j];
			j--;
		}
		array[j+1] = key;
		printarray(array,n);
	}
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
long long x,y,a,b;
int main()
{
	cin>>x>>y;
	if(x%y==0)cout<<-1<<endl;
	else 
	{
		cout<<x<<endl;
	}
	return 0;
 } 

Measured memory_bytes: 256
h,w=map(int,input().split())
ans=10**5
for _ in range(2):
    for i in range(1,h):
        th=(h-i)//2
        m1=max(i*w,th*w,(h-i-th)*w)-min(i*w,th*w,(h-i-th)*w)
        tw=w//2
        m2=max(i*w,(h-i)*tw,(h-i)*(w-tw))-min(i*w,(h-i)*tw,(h-i)*(w-tw))
        ans=min(ans,m1,m2)
    h,w=w,h
print(ans)

Measured memory_bytes: 3064
#line 1 "/workspaces/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "main.cpp"

constexpr int m = 26;

// d日目までのスコアを計算する
ll calc_ans(const int d, const vi &ans, const vector<vl> &s, const vl &c) {
  ll ret = 0LL;
  vi last(m, 0);
  REP(i, d) {
    ret += s[i][ans[i]];
    last[ans[i]] = i + 1;
    REP(j, m) { ret -= c[j] * (i + 1 - last[j]); }
  }
  return ret;
}

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

  int d;
  cin >> d;

  vl c(m);
  REP(i, m) { cin >> c[i]; }

  vector<vl> s(d, vl(m, 0));
  REP(i, d) {
    REP(j, m) { cin >> s[i][j]; }
  }

  vi ans(d);
  REP(i, d) {
    cin >> ans[i];
    ans[i]--;
  }
  REP(i, d) { cout << calc_ans(i + 1, ans, s, c) << endl; }
  return 0;
}


Measured memory_bytes: 3704
#include<stdio.h>

int main(){
    int i,j,x,n,m,a[101][101],b[101],c[101];
    char ch;
    
    for(i=0;i<101;i++){
        b[i]=0;
        c[i]=0;
        for(j=0;j<101;j++){
            a[i][j]=0;
        }
    }
    
    scanf("%d %d",&n,&m);
    
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(i=0;i<m;i++){
        scanf("%d",&c[i]);
        
    }
    for(i=0;i<n;i++){
        x=0;
        for(j=0;j<m;j++)
            x+=a[i][j]*c[j];
            printf("%d\n",x);
        
    }
    return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>

int main(){
    int a, b, t, r;
    scanf("%d %d %d", &a, &b, &t);
    while(true){
        if(t >= a){
            r += b;
            t -= a;
        }else{
            break;
        }
    }
    printf("%d\n", r);
}


Measured memory_bytes: 128
s=input()
t=input()
ans=0
s1=s
ans=0
flag=1
for i in t:
    if i not in s1:
        flag=0
if flag==0:
    print(-1)
else:
    for i in t:
        if i in s1:
            ans+=s1.index(i)+1
            s1=s1[s1.index(i)+1:]
        else:
            ans = ((ans+len(s)-1)//len(s))*len(s) 
            ans+=s.index(i)+1   
            s1=s[s.index(i)+1:]
    print(ans)

Measured memory_bytes: 3572
#include <iostream>
#include <queue>
#include <vector>
#include <string>

int main()
{
    int N;
    std::vector<int>B;
    std::cin >> N;
    B.resize(N);
    for (int i = 0; i < N; i++)
    {
        std::cin >> B[i];
    }

    std::vector<bool> checked;
    checked.resize(N);
    std::string ans;
    for (int i = 0; i < N; i++)
    {
        int cnt = 0;
        int index = -1;
        for(int j =0;j<N;j++)
        {
            if(checked[j])
            {
                continue;
            }
            cnt++;
            if (cnt == B[j])index = j;
        }

        if(index == -1)
        {
            std::cout << "-1" << std::endl;
            return 0;
        }
        else
        {
            ans = std::to_string(B[index]) + "\n" + ans;
        }
        checked[index] = true;
    }
    std::cout << ans << std::endl;

}

Measured memory_bytes: 256
N = int(input())+1
# M=1
# A=[5,4,2,1]
 
cnt = 0
cnt1 = 0
 
# for i in range(N):
#     cnt = cnt + A[i]
#
# for i in range(N):
#     if A[i] / cnt > 1 / 4 / M:
#         cnt1 = cnt1 + 1
 
sum=0
for i in range(N):
    if (i % 3) != 0 and (i % 5) != 0:
        sum = sum + i
        # print(i,sum)
 
# a1 = N % 10
# a2 = ((N-a1*10) % 100)/10
# a3 = ((N-a1*100-a2*10))/100
 
print(sum)

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

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

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

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

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

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

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

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


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




int main() {
	ll N;
	cin >> N;
	
	vector<vector<ll>> g(N + 1);
	repn(i,N-1){
		ll a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);

	}

	vector<ll> dis1(N + 1, -1);

	queue<ll> q;
	dis1[1] = 0;
	q.push(1);

	while (!q.empty()) {
		ll v = q.front();
		q.pop();
		for (ll w : g[v]) {
			if (dis1[w] != -1) { continue; }
			dis1[w] = dis1[v] + 1;
			q.push(w);
		}
	}

	vector<ll> disN(N + 1, -1);

	disN[N] = 0;
	q.push(N);

	while (!q.empty()) {
		ll v = q.front();
		q.pop();
		for (ll w : g[v]) {
			if (disN[w] != -1) { continue; }
			disN[w] = disN[v] + 1;
			q.push(w);
		}
	}

	ll s = 0;
	ll f = 0;
	repn(i, N) {
		if (dis1[i] > disN[i]) { s++; }
		else { f++; }
		//cout << dis1[i] << disN[i] << endl;
	}

	if (f > s) { cout << "Fennec"; }
	else { cout << "Snuke"; }
	

	system("PAUSE");
}






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

double dis(vector<double> X, vector<double> Y, double p)
{
    double sum = 0;
    for (int i=0; i<X.size(); i++)
    {
        sum += pow(abs(X.at(i) - Y.at(i)), p);
    }
    return pow(sum, 1/p);
}


int main()
{
    int n;
    cin >> n;
    vector<double> X(n);
    vector<double> Y(n);
    for (int i=0; i<n; i++)
    {
        cin >> X.at(i);
    }
    for (int i=0; i<n; i++)
    {
        cin >> Y.at(i);
    }
    for (int i=1; i<=3; i++)
    {
        cout << fixed << setprecision(15) <<dis(X, Y, i) << endl;
    }
    double dis_inf=-1;
    for (int i=0; i<n; i++)
    {
        dis_inf = max(dis_inf, abs(X.at(i) - Y.at(i)));
    }
    cout << fixed << setprecision(15) <<dis_inf << endl;
}


Measured memory_bytes: 3448
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int N,M;
  cin>>N>>M;
  vector<pair<int,int>> e(M);
  for (int i(0);i<M;i++){
    cin>>e[i].second>>e[i].first;
  }
  sort(e.begin(),e.end());
  int ans(0),tmp(0);
  for (int i(0);i<M;i++){
    //cout << tmp << endl;
    if (e[i].second >= tmp){
      tmp = e[i].first;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1024
// Problem : D - Grid Repainting
// Contest : AtCoder - AtCoder Beginner Contest 088
// URL : https://atcoder.jp/contests/abc088/tasks/abc088_d
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 51; //check the limits, dummy
 int dx[]={-1,1,0,0},dy[]={0,0,-1,1};
int H,W;
int v[MX][MX],vis[MX][MX],len[MX][MX];

inline bool isV(int x,int y)
{
	if(x>=0 && x<H && y>=0 && y<W && !v[x][y])
		return true;
	return false;
}
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	cin>>H>>W;
	int cnt=0;
	F0R(x,H)
	{
		string str;
		cin>>str;
		F0R(y,W)
		{
			v[x][y]=str[y]=='.'?0:1,vis[x][y]=0;
			if(str[y]=='#')
				cnt++;
		}
	}
	queue<pi> st;
	st.push({0,0});
	len[0][0]=1;
	vis[0][0]=1;
	while(sz(st)!=0)
	{
		pi S=st.front();
		if(S.f==H-1 && S.s==W-1)
		{
			cout<<H*W-len[H-1][W-1]-cnt<<nl;
			return 0;
		}
		// vis[S.f][S.s]=1;
		st.pop();
		F0R(x,4)
		{
			if(isV(S.f+dx[x],S.s+dy[x]) && !vis[S.f+dx[x]][S.s+dy[x]])
			{
				vis[S.f+dx[x]][S.s+dy[x]]=1;
				st.push({S.f+dx[x],S.s+dy[x]});
				len[S.f+dx[x]][S.s+dy[x]]=1+len[S.f][S.s];
			}
		}
	}
	cout<<-1<<nl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3644
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let s: u64 = read();
    let x;
    let y;
    if s == 1000000000000000000 {
        x = 1000000000;
        y = 0;
    } else {
        x = (s / 1000000000) + 1;
        y = x * 1000000000 - s;
    }

    println!("{} {} 1 1000000000 0 0", x, y);
}


Measured memory_bytes: 4352
/* by Natsu Kinmoe */
#include <bits/stdc++.h>
using namespace std;
#define SZ(x)               ((int)(x).size())
#define all(x)              (x).begin(), (x).end()
#define loop(i, n)          for(int i = 0; i < (n); i++)
#define cont(i, n)          for(int i = 1; i <= (n); i++)
#define circ(i, a, b)       for(int i = (a); i <= (b); i++)
#define range(i, a, b, c)   for(int i = (a); ((c) > 0 ? i <= (b) : i >= (b)); i += (c))
#define foreach(it, v)      for(__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define y0          y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1          y1II11II11III11I1III11II111IIII1II1I1
#define pub         push_back
#define pob         pop_back
#define mak         make_pair
typedef long long   ll;
typedef long double lf;
const int   Inf = 0x3f3f3f3f;
const ll    INF = 0x3f3f3f3f3f3f3f3fll;
/* Source code starts here */

ll a, b, c, d;

int main() {
	cin >> a >> b >> c >> d;
	cout << max(max(a * c, a * d), max(b * c, b * d)) << endl;
	return 0;
}


Measured memory_bytes: 3628
n,m = map(int,input().split())
s = list(map(int,input().split()))
t = list(map(int,input().split()))
mod = 10**9 + 7
dp = [[1]*(m+1) for _ in range(n+1)]
for i in range(n):
  for j in range(m):
    dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j] - dp[i][j]*(s[i] != t[j])) % mod
print(dp[n][m])

Measured memory_bytes: 72540
#include<bits/stdc++.h>
#define tmp(x) std::cout<<"& "<<(x)<<" &\n"
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
typedef long long ll;
#define  pii pair<int,int>
#define  pll pair<ll,ll>
#define  vi vector<int>


using namespace std;
const int maxn=2e5+100;
int n,k;
ll a[maxn];

int main(){
//	freopen("in.txt","r",stdin);
//    ios::sync_with_stdio(false);
//    cin.tie(0);
    deque<int>aa;
    scanf("%d%d",&n,&k);
    rep(i,1,n){
        scanf("%d",&a[i]);
    }
    rep(i,1,k)aa.push_back(a[i]);
    rep(i,k+1,n){
        int t=aa.front();
        if (a[i]>t)printf("Yes\n");
        else printf("No\n");
        aa.pop_front();
        aa.push_back(a[i]);
    }





    return 0;
}

Measured memory_bytes: 6068
//
//AtCoder Beginner Contest 129
//A - Airplane
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int p, q, r;
    cin >> p >> q >> r;
    int ans = 999;
    ans = min(ans, p+q);
    ans = min(ans, q+r);
    ans = min(ans, r+p);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
main = getContents >>= mapM_ (putStrLn . national_budget) . reverse . fin [] . tail . lines
fin acc [] = acc
fin acc (x:y:xys) = fin ([x,y]:acc) xys

national_budget [x,y]
 | (length x > 80) || (length y > 80) = "overflow"
 | (length $ show (read x + read y)) > 80 = "overflow"
 | otherwise = show (read x + read y)

Measured memory_bytes: 4296