akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
#define MX 1000000007
int main()
{
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  int ar[200001],n;
  cin>>n;
  rep(i,n){
      cin>>ar[i];
  }
  lli ans=0;
  lli till=0;
  rep(i,n){
      ans=(ans+(till*ar[i])%MX)%MX;
      till=(till+ar[i])%MX;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4380
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
	
		Scanner scan = new Scanner(System.in);
		int count = 0;
		String s =scan.next();
		
		char[] charArray1; // 配列型の変数を宣言して、
            charArray1 = new char[3]; // 配列の実体をnewして紐付けて、
            charArray1[0] =s.charAt(0); // インデックスへ数字を代入する
            charArray1[1] =s.charAt(1);
            charArray1[2] =s.charAt(2);
            
        if(charArray1[0]=='1') {
            	
            count++;
        
        }
        
        if(charArray1[1]=='1') {
            	
            count++;
        
        }
        
        if(charArray1[2]=='1') {
            	
            count++;
        
        }
        System.out.println(count);
        

	}
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
const int64 INF = 1LL << 58;

int N, A[200000];
int64 sum[200000];

bool Find(const int& pos, const int64& size){
  int hoge = distance( sum, lower_bound( sum + pos + 1, sum + N + pos + 1, sum[pos] + size));
  if(hoge == N + pos + 1) return false;
  int fuga = distance( sum, lower_bound( sum + hoge + 1, sum + N + pos + 1, sum[hoge] + size));
  if(fuga == N + pos + 1) return false;
  int foo = distance( sum, lower_bound( sum + fuga + 1, sum + N + pos + 1, sum[fuga] + size));
  return(foo != N + pos + 1);
}


bool calc(int64 size){ //size: 1個あたりの大きさ
  for(int pos = 0; pos < N; pos++){
    if(Find(pos, size)) return true;
  }
  return false;
}

int main(){

  scanf("%d", &N);
  for(int i = 0; i < N; i++){
    scanf("%d", A + i);
    A[N + i] = A[i];
  }

  sum[0] = A[0];
  for(int i = 1; i < 2 * N; i++){
    sum[i] = sum[i - 1] + A[i];
  }

  int64 low = 0, high = INF;
  while(high != low){
    int64 mid = (low + high + 1) >> 1;
    if(calc(mid)) low = mid; else high = mid - 1;
  }
  printf("%lld\n", low);
}

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

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

	string s;
	cin >> s;

	bool d = false;

	if (s.length() >= 6)
		if (s[2] == s[3] && s[4] == s[5])
			d = true;

	if (d)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}



Measured memory_bytes: 256
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());

    long[] A = new long[N+1];
    for (int i = 0; i <= N; i++) {
      A[i] = Integer.parseInt(sc.next());
    }

    long[] B = new long[N];
    for (int i = 0; i < N; i++) {
      B[i] = Integer.parseInt(sc.next());
    }

    long kill = 0;
    for (int i = B.length-1; i >= 0; i--) {
      kill += kill(A, B, i+1, i);
      kill += kill(A, B, i, i);
    }

    System.out.println(kill);
  }

  private static long kill(long[] A, long[] B, int ai, int bi) {
    long cnt = 0;
    long origin = A[ai];
    A[ai] = Math.max(0, A[ai]-B[bi]);      
    cnt = Math.max(0, origin-A[ai]);
    B[bi] = Math.max(0, B[bi] - cnt);    
    return cnt;
  }
}

Measured memory_bytes: 50540
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll a[110],b[110];
ll dp[110][110000];
int main(){
    ll n,w;
    cin>>n>>w;
    rep(i,0,n)cin>>a[i]>>b[i];
    rep(i,0,n+1){
        rep(j,0,100100)dp[i][j]=1e11;
    }
    dp[0][0]=0;
    rep(i,0,n){
        rep(j,0,100100){
            if(j-b[i]>=0)dp[i+1][j]=min(dp[i+1][j],dp[i][j-b[i]]+a[i]);
            dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
        }
    }
    ll ans;
    rep(i,0,100100)if(dp[n][i]<=w)ans=i;
    cout<<ans;
}


Measured memory_bytes: 88192
group1 = [1,3,5,7,8,10,12]
group2 = [4,6,9,11]

x, y = gets.split.map(&:to_i)

if group1.include?(x) && group1.include?(y) || group2.include?(x) && group2.include?(y)
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 1788
from collections import defaultdict
import sys
N=int(input())
A=[int(i) for i in input().split() ]
dd=defaultdict(int)
for a in A:
    dd[a]+=1
L=[]
for j in dd.values():
    L.append(j-1)
if len(L)==1 or len(L)==2:
    print(1)
    sys.exit()
if sum(L)%2==1:
    print(len(L)-1)
    sys.exit()
if sum(L)%2==0:
    print(len(L))
    sys.exit()

Measured memory_bytes: 63976
#include <bits/stdc++.h>
using namespace std;
#define finish(x) reutrn cout << x << endl, 0;
#define ll long long

int n, x, k, dp[100001][2];
vector <int> a;

int solve(int k, int cur){
    int &ret = dp[k][cur];
    if(ret != -1) return ret;
    if(k < a[0]) return cur ^ 1;
    for(int i = 0 ; i < n ; i++){
        if(k < a[i]) continue;
        if(solve(k - a[i], cur ^ 1) == cur)
            return ret = cur;
    }
    return ret = (cur ^ 1);
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    memset(dp, -1, sizeof dp);
    cin >> n >> k;
    for(int i = 0 ; i < n && cin >> x ; i++)
        a.push_back(x);
    if(solve(k, 0) == 0) cout << "First" << endl;
    else cout << "Second" << endl;
}


Measured memory_bytes: 5760
N = int(input())
l = len(str(N))
d = [0,9,0,900,0,90000]
res = 0
for i in range(l):
  res += d[i]
if l == 1:
  res += N
if l == 3:
  res += (N - 99)
if l == 5:
  res += (N - 9999)
print(res)

Measured memory_bytes: 61712
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
int main()
{
	char s[105];
	int l,k;
	cin>>s;
	l=strlen(s);
	cin>>k;
	for(int i=0;i<l;i++)
	{
		if(k>0)
		{
			long long sum=s[i]-48;
			k=k-pow(sum,5E15);	
		}
		if(k<=0)
		{
			cout<<s[i];
			break;
		}
	}
	return 0;	
		
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl "\n"
#define MOD 1000000007
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))

int main()
{	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	
		ll n,k;
		cin>>n>>k;
		if(k==1)
			cout<<"0";
		else cout<<(n-k);
	return 0;
}

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

int main(){
	int n;
	while(1){
		int sum, result;
		cin >> n;
		if(n == 0){
			break;
		}
		vector<int> score;
		for(int i = 0; i < n; i++){
			int s;
			cin >> s;
			score.push_back(s);
		}
		sort(score.begin(), score.end());
		sum = accumulate(score.begin(), score.end(), 0);
		result = (sum - score[0] - score[n-1]) / (n-2);
		cout << result << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
const int inf=1e18;
inline int in(){int x;scanf("%lld",&x);return x;}
#define x first
#define y second
int32_t main()
{	
	int n=in();
	vector<vector<pair<int,int>>> g(n);
	int u,v,w;
	for(int i=1;i<n;i++)
	{
		u=in();v=in();w=in();
		u--;v--;
		g[u].push_back({v,w});
		g[v].push_back({u,w});
	}
	
	int Q=in();int K=in();K--;
	
	queue<int> q;
	q.push(K);
	vector<int> dis(n,inf);
	dis[K]=0;
	while(!q.empty())
	{
		u=q.front();
		q.pop();
		for(auto v:g[u])
		{
			if(dis[v.x]!=inf)continue;
			dis[v.x]=min(dis[v.x],dis[u]+v.y);
			q.push(v.x);
		}
	}
	while(Q--)
	{
		u=in();v=in();
		cout<<dis[u-1]+dis[v-1]<<"\n";
	}
	
	
}

Measured memory_bytes: 11924
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>

using namespace std;

#define ll long long
int main(){
   
   int A,B;
   cin>>A>>B;
   cout<<max(A+B,max(A-B,A*B))<<endl;
   
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, N, a, b) for(int i = a; i < N; i += b)

int main(){
	string A, B;
	// int64_t A, B;
	cin >> A >> B;
	// cout << A << endl;
	// cout << B << endl;
	if (A.size() == B.size()){
		if (A > B) cout << "GREATER" << endl;
		else if (A < B) cout << "LESS" << endl;
		else cout << "EQUAL" << endl;
	}
	else {
		if (A.size() > B.size()) cout << "GREATER" << endl;
		else cout << "LESS" << endl;
	}
}

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

int main(){
        int a,b,c;
        cin >> a >> b >> c;
        if(c>=a && c<=b)
                cout << "Yes";
        else
                cout << "No";

        //cout << y << endl;
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define Nmax 105
#define Wmax 100005
using namespace std;

ll n, W, dp[3][Wmax], v[Nmax], w[Nmax];

int main()
{
    cin >> n >> W;

    for (int i = 1; i <= n; ++i) {
        cin >> w[i] >> v[i];
    }

    for (int noOfItems = 1; noOfItems <= n; ++noOfItems) {
        ll step = 1;
        if (!(noOfItems & 1)) {
            step = -1;
        }

        ll ln = (noOfItems % 2) ? 1 : 2;
        for (int weight = 1; weight <= W; ++weight) {
            dp[ln][weight] = dp[ln + step][weight];
            if (weight - w[noOfItems] >= 0) {
                dp[ln][weight] = max(dp[ln + step][weight], dp[ln + step][weight - w[noOfItems]] + v[noOfItems]);
            }
            //cout << ln << " " << weight << " " << dp[ln][weight] << "\n";
        }
    }

    if (n % 2) {
        cout << dp[1][W];
        return 0;
    }
    cout << dp[2][W];

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long A,B,C,D,H,K,L,M,N,T,W,X,Y;
  string S;
  cin >> N >> X >> Y;
  vector<long long> vec(N,0);
  
  A=0;
  
  for (long long i=1;i<N;i++) {
  
    for (long long j=i+1;j<N+1;j++) {
	
	  if (i<X && j<Y) {
	  
	    A=min(j-i,Y-j+1+X-i);
		vec.at(A-1)++;
	  
	  }
	  else if (i>=X && j<Y) {A=min(j-i,Y-j+1+i-X);vec.at(A-1)++;}
	  else if (i<X && j>=Y) {A=min(j-i,j-Y+1+X-i);vec.at(A-1)++;}
	  else {A=min(j-i,j-Y+1+i-X);vec.at(A-1)++;}
	  
	  //cout << A << endl;
      
	}
  
  }
  
  for (long long i=0;i<N-1;i++) {cout << vec.at(i) << endl;}
  
  
}

Measured memory_bytes: 256
s = input()
moji = len(s)
if moji % 2 == 0:
    moji = int(moji/2)
else:
    moji = int((moji-1)/2)

answer = 0
for i in range(moji):
    if s[i] != s[len(s)-1-i]:
        answer += 1
print(answer)

Measured memory_bytes: 61744
#include <bits/stdc++.h>
#define nl endl
#define dbg(a) cout << #a << "=" << a << endl
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define md 1000000007

using namespace std;

int solve()
{
    ll n;
    cin>>n;
    vector<long long> v(n);
    
    for(auto &it:v) cin>>it;
    ll ct=0, mx=v[0];
    for(int i=1;i<n;i++)
    {
        ct+=max(0LL, mx-v[i]);
        mx=max(mx, v[i]);
        // dbg(ct);
        // dbg(mx);
    }
    cout<<ct<<endl;

    return 0;
}

int main()
{
    fast;
    solve();
    return 0;
}

Measured memory_bytes: 4728
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <utility>
#include <unordered_set>

using namespace std;

template <typename T>
void print_vec(const vector<T> &v) {
  int n = v.size();
  for (int i = 0; i < n; ++i) {
    if (i > 0) cout << ' ';
    cout << v[i];
  }
  cout << '\n';
}

int main() {
  int k;
  cin >> k;
  int prev = 0;
  vector<bool> exist(k, false);
  int t = 1;
  int ans = -1;
  for (;;) {
    prev = prev * 10 + 7;
    if (prev % k == 0) {
      ans = t;
      break;
    }
    prev %= k;
    if (exist[prev]) {
      break;
    } else {
      exist[prev] = true;
    }
    ++t;
  }
  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3712
#include<stdio.h>

int main(void){
  int r,D,x,xn,i;
  scanf("%d %d %d",&r,&D,&x);
  for(i=1;i<=10;i++){
    xn=r*x-D;
    x=xn;
    printf("%d\n",xn);
  }
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main (void)
{
  int i;
  int n;
  scanf("%d",&n);
  
  double x=0,xx=0;
  char u[n];
  
  for(i=0;i<n;i++){
   scanf("%lf %s",&x,&u);
    
   if(u[0]=='J')
     xx=xx+x;
   else
     xx=xx+(x*380000.0);
  
  }
  
  printf("%.4f",xx);
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int a[7]={64,32,16,8,4,2,1};
  int n;cin>>n;
  rep(i,7){
    if(a[i]<=n){cout<<a[i]<<endl;return 0;}
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

class Point{
	int x;
	int y;
	int z;
	Point(int a,int b,int c){
		this.x = a;
		this.y = b;
		this.z = c;
	}
}
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		//int[] A = new int[N];
		Queue<Integer> queue = new PriorityQueue<Integer>();

		for(int i = 0 ; i < N ; i++){
			//A[i] = sc.nextInt();
			queue.add(sc.nextInt());
		}

		sc.close();
		int count = 0;
		int prev = queue.poll();
		long sum = prev;

		while(!queue.isEmpty()){
			int p = queue.poll();
			if(prev != p){
				if((long)Math.pow(prev, 2) - sum < 0){
					count += (sum - Math.pow(prev, 2))/prev;
				}
				else if((long)Math.pow(prev, 2) - sum > 0){
					count += sum/prev;
				}
				sum = p;
			}
			else{
				sum += p;
			}
			prev = p;

			//System.out.println(count);
		}
		//System.out.println(sum);
		//System.out.println(prev);
		//System.out.println(count);
		if((long)Math.pow(prev, 2) - sum < 0){
			count += (sum - (long)Math.pow(prev, 2))/prev;
		}
		else if((long)Math.pow(prev, 2) - sum > 0){
			count += sum/prev;
		}

		System.out.println(count);
	}
}

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

int main()
{
  int a, b, c, d, value, value2, i;
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  scanf("%d", &d);

  value = a;
  value2 = c;
  for(i = 0; i < 200; i++){
    if(i % 2 == 0){
      value2 -= b;
      if(value2 <= 0){
        printf("Yes\n");
        break;
      }
    }
    else{
      value -= d;
      if(value <= 0){
        printf("No\n");
        break;
      }
    }
  }


  return 0;
  }


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

int	main()
{
	int	N, Q;
	string	S;
	cin >> N >> Q >> S;
	vector<int>	cnt_vec(N + 1, 0);
	for (int i = 2; i <= N; ++i)
	{
		cnt_vec.at(i) = cnt_vec.at(i - 1);
		if (S.substr(i - 2, 2) == "AC")
			++cnt_vec.at(i);
	}
	int	l, r;
	for (int i = 0; i < Q; ++i) {
		cin >> l >> r;
		if (l >= 2 && S.substr(l - 2, 2) == "AC")
			cout << cnt_vec.at(r) - cnt_vec.at(l) << endl;
		else
			cout << cnt_vec.at(r) - cnt_vec.at(l - 1) << endl;
	}
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    bool p = 1;
    for (int i = 0; i < s.size(); i++){
        if((i + 1) & 1){
            if (s[i] == 'L')
                p = 0;
        }
        else if (s[i] == 'R')
            p = 0;
    }
    puts(p ? "Yes" : "No");
    return 0;
}


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

using namespace std;

const int MOD = 1000000007;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  vector<vector<int>> graph(N);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    graph[a].emplace_back(b);
    graph[b].emplace_back(a);
  }
  vector<bool> used(N, false);
  vector<int> color(N, 0);
  used[0] = true;
  color[0] = K;
  queue<int> que;
  que.push(0);
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    int c = u == 0 ? K - 1 : K - 2;
    for (int v : graph[u]) {
      if (used[v]) continue;
      color[v] = c--;
      used[v] = true;
      que.push(v);
    }
  }
  int res = 1;
  for (int i = 0; i < N; i++) {
    res = 1LL * res * color[i] % MOD;
  }
  cout << res << '\n';
  return 0;
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >=0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;
#define INF 1e9

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



int main(){
  int n;
  cin >> n;
  vector<int> a(n+1), sum(n+1,0);
  ll ans1=0, ans2=0;
  FOR(i, 1, n+1){
    cin >> a[i];
  }
  
  FOR(i, 1, n+1){
    if(i%2){
      if(sum[i-1]+a[i] <= 0){
        ans1 += 1 -(sum[i-1]+a[i]);
        sum[i] = 1;
      }
      else{
        sum[i] = sum[i-1]+a[i];
      }
    }
    else{
      if(sum[i-1]+a[i] >= 0){
        ans1 += (sum[i-1]+a[i])+1;
        sum[i] = -1;
      }
      else{
        sum[i] = sum[i-1]+a[i];
      }
    }
  }
  FOR(i, 1, n+1){
    if(!(i%2)){
      if(sum[i-1]+a[i] <= 0){
        ans2 += 1 -(sum[i-1]+a[i]);
        sum[i] = 1;
      }
      else{
        sum[i] = sum[i-1]+a[i];
      }
    }
    else{
      if(sum[i-1]+a[i] >= 0){
        ans2 += (sum[i-1]+a[i])+1;
        sum[i] = -1;
      }
      else{
        sum[i] = sum[i-1]+a[i];
      }
    }
  }

  cout << min(ans1, ans2);

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
//#include <unordered_map>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
//ll mod=1000000007;
//ll mod=67280421310721;
ll mod=998244353;
ll INF=1e18;
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
//			re%=mod;
		}
		a=(a*a);
//		a%=mod;
		b>>=1;
	}
	return re;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
//	cin>>test;
	while(test--)
	{
		ll x,a,b;
		cin>>x;
		FOR(i,-200,200)
		{
			a=i;
			a=po(a,5);
			FOR(j,-200,200)
			{
				b=j;
				b=po(b,5);
				if((a-b)==x)
				{
					cout<<i<<' '<<j;
					return 0;
				}
			}
		}
	}
	return 0;
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int64_t gcd(int64_t x, int64_t y) {
  if (x == 0) {
    return y;
  }

  return gcd(y % x, x);
}

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

  int64_t ans = 0;
  for (auto a : irange(1L, k + 1)) {
    for (auto b : irange(1L, k + 1)) {
      int64_t t = gcd(a, b);
      for (auto c : irange(1L, k + 1)) {
        ans += gcd(t, c);
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3620
//複雑な分数は、同じくらいに分けて分割して行う

#include<bits/stdc++.h>

using namespace std;


signed main(){
    
    int N;
    double ans = 0.0, A;
    cin >> N;
    for(int i = 1; i <= N; ++i){
        cin >> A;
        ans += 1.0 / A;
    }
    ans = 1.0/ans;
    cout << setprecision(16) << ans << endl;
    //出力する不動係数を固定する
 }


Measured memory_bytes: 256
n,k=map(int,input().split())
l=list(map(int,input().split()))
ans=1e20
for i in range(n-k+1):
  r=i+k-1
  p1=abs(l[i])+abs(l[r]-l[i]);p2=abs(l[r])+abs(l[i]-l[r])
  ans=min(ans,p1,p2)
print(ans)

Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char a1,b1,c1,d1;
    cin>>a1>>b1>>c1>>d1;
    int a,b,c,d,ans;
    a=a1-'0';b=b1-'0';c=c1-'0';d=d1-'0';
    if(a+b+c+d==7)
    {
        cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7\n";
        exit(0);
    }
    if(a+b+c-d==7)
    {
        cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7\n";
        exit(0);
    }
    if(a+b-c+d==7)
    {
        cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7\n";
        exit(0);
    }
    if(a-b+c+d==7)
    {
        cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7\n";
        exit(0);
    }
    if(a-b+c-d==7)
    {
        cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7\n";
        exit(0);
    }
    if(a+b-c-d==7)
    {
        cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7\n";
        exit(0);
    }
    if(a-b-c+d==7)
    {
        cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7\n";
        exit(0);
    }
    if(a-b-c-d==7)
    {
        cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7\n";
        exit(0);
    }
    return 0;                     
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<ll>res(n+2);
  rep(i,n+2){
    ll k=0;
    ll ti=i;
    while(ti>0){
      k++;
      ti/=10;
    }
    if(k%2)res[i]++;
  }
  rep(i,n+1){
    res[i+1]+=res[i];
  }
  cout<<res[n]<<endl;

  return 0;

}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<cctype>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N,a,b,c;
    cin >> N;
    a=0;
    b=0;
    c=0;
    ll i;
    ll t,m;
    ll ans=1;
    for(i=0;i<N;i++){
        cin >> t;
        m=1;
        if(a==t){
            if(b==a)m++;
            if(c==a)m++;
            a++;
        }else if(b==t){
            if(c==b)m++;
            b++;
        }else if(c==t){
            c++;
        }else m=0;
        ans=ans*m%1000000007;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int n;
    while(cin >> n, n){
        vector<int> a(n);
        for(int i = 0; i < n; i++)cin >> a[i];
        sort(a.begin(),a.end());
        int ans = 1e9;
        for(int i = 0; i < n-1; i++){
            ans = min(ans, a[i+1]-a[i]);
        }
        cout << ans << endl;
    }
}



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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

const int INF = 0x3f3f3f3f;
const ll  LINF = 0x3f3f3f3f3f3f3f3fLL;
const int maxn = 45+10;
const int mod = 1e9+7;

using namespace std;

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

    int n,x,s=0;

    cin >> n >> x;

    vi v(n);

    for(int &d:v){
    	cin >> d;
    	s+=d;
    }

    sort(all(v));

    x-=s;

    cout << (n + (x/v[0])) << endl;

    return 0;
}



Measured memory_bytes: 3572
n = int(input())
lines = [input() for x in range(n)]

order_lines = dict()
sum = 0
for i,line in enumerate(lines):
    sort_characters = "".join(sorted(line))
    if sort_characters not in order_lines:
        order_lines[sort_characters] = []
    else:
        sum += len(order_lines[sort_characters])
    order_lines[sort_characters].append(i)
print(sum)


Measured memory_bytes: 37324
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int A[MAX_N];

void solve() {
	cin >> N;
	rep(i, 0, N) {
		int a; cin >> a; a--;
		A[a] = i;
	}
	multiset<int> S;
	multiset<int> rS;

	S.insert(N);
	S.insert(N);
	S.insert(A[N - 1]);

	rS.insert(1);
	rS.insert(1);
	rS.insert(-A[N - 1]);

	ll res = 0;
	rer(i, N - 1, 0) {
		int idx = A[i];
		auto it = S.lower_bound(idx);
		auto pit = it;
		it++;
		auto rit = rS.lower_bound(-idx);
		auto rpit = rit;
		rit++;

		ll tmp = 0;
		tmp += (*it - *pit) * (idx + (*rpit));
		tmp += (*rit - *rpit) * ((*pit) - idx);
		// debug(*it, *pit, -(*rit), -(*rpit), tmp);
		tmp *= (i + 1);
		res += tmp;
		S.insert(idx);
		rS.insert(-idx);
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n; cin >> n;
  vi a(n);
  map<ll,ll> m;
  
  rep(i, n) {
    cin >> a[i];
    ++m[a[i]];
  }

  ll ans = 0;

  for (auto e : m) ans += e.se * (e.se-1) / 2;

  rep(i, n) {
    --m[a[i]];
    
    cout << ans - m[a[i]] << endl;

    ++m[a[i]];
  }

}


Measured memory_bytes: 11916
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const long long N = 3e6 + 17;
ll a[N], b[N], cnt, ans, lnt, n, m, r1, r0, l1, l0, sum, mx, h, c[N], t[N], mn = N, x, y, k;
pair<ll,ll>pr[N];
vector<ll>v,v2;
map<ll,ll>mp;
bool used[N];
char ch[N];
ll prime[N] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> x >> y >> n >> k;
    cout << min(x + n, min(x + k , min(y + n, y + k)));
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9
#define MOD 1e9+7
#define fastio ios_base::sync_with_stdio(0),cin.tie(0)
#define debug(x) cout << x << endl

int main(){
	int h,w;
	cin >> h >> w;
	string grid[60];
	string tmbh="";
	for (int i=0;i<=w+1;i++){
		tmbh=tmbh+'.';
	}
	grid[0]=tmbh;
	grid[h+1]=tmbh;
	for (int i=1;i<=h;i++){
		string a;
		cin >> a;
		a='.'+a+'.';
		grid[i]=a;
	}
	bool bisa=true;
	for (int i=1;i<=h;i++){
		for (int j=1;j<=w;j++){
			bool ini=true;
			if (grid[i][j]=='#'){
				ini=false;
				if (grid[i][j+1]=='#'){
					ini = true;
				}
				if (grid[i][j-1]=='#'){
					ini = true;
				}
				if (grid[i+1][j]=='#'){
					ini = true;
				}
				if (grid[i-1][j]=='#'){
					ini = true;
				}
			}
			if (!ini){
				bisa=false;
				break;
			}
		}
	}
	if (bisa){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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

using int64 = long long;

int64 f(int64 b, int64 n) {
  if (b < 2)
    return -1;
  int64 ret = 0;
  while (n) {
    ret += n % b;
    n /= b;
  }
  return ret;
}

int64 Solve(int64 n, int64 s) {
  if (n < s)
    return -1;
  if (n == s)
    return n + 1;

  const int64 sq = sqrt(n);
  for (int64 b = 2; b <= sq; ++b) {
    if (f(b, n) == s)
      return b;
  }

  int64 r = n + 1;
  for (int64 p = 1; p <= sq; ++p) {
    int64 b = (n - s) / p + 1;
    if (s == f(b, n) && b < r)
      r = b;
  }

  if (r <= n)
    return r;
  return -1;
}

int main() {
  int64 n, s;
  cin >> n >> s;
  cout << Solve(n, s) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define u128 __int128
#define pb push_back

#define N 100010
#define MOD 1000000007

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

	int k, x;
	cin >> k >> x;
	for(int i = max(x - k + 1, -1000000); i <= min(x + k - 1, 1000000); ++i)
		cout << i << " ";
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

#define FOR(i,k,n) for(int (i) = (k); (i) < (n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x,y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
template<class T> using vv=vector<vector<T>>;
typedef deque<int> di;
typedef deque<deque<int>> ddi;

int main() {
    while(1) {
        int n;
        cin >> n;
        if(n==0) {
            break;
        }
        int dp[30];
        dp[0] = 1;
        dp[1] = 2;
        dp[2] = 4;
        FOR(i,3,n) {
            dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
        }
        if(dp[n-1] % 3650 == 0) { 
            cout << dp[n-1] /3650 << endl;
        } else {
            cout << dp[n-1] /3650 + 1 << endl;
        }
         
    }
	return 0;
}

Measured memory_bytes: 3084
#include<stdio.h>
    int main(){
            int num[3],i,tmp,add=0,x=0;
            scanf("%d %d %d",&num[0],&num[1],&num[2]);
            for(i=0;i<2;i++)
            {
                    if(x==2) break;
                    if(num[i] < num[i+1]){
                            tmp = num[i];
                            num[i] = num[i+1];
                            num[i+1] = tmp;
                    }
                    if(i==1){
                            i=-1;
                            x++;
                    }
            }
            while(1){                                                                          
                    if(num[0]==num[1] && num[1]==num[2] && num[2]==num[0])
                    {
                                break;
                    }
                    if((num[0]-num[1])%2 == 0 && num[0]!=num[1]){
                            add+=(num[0]-num[1])/2;
                            num[1]=num[0];
                    }else{
                            num[1]++;
                            num[2]++;
                            add++;
                            continue;
                    }
                    if((num[0]-num[2])%2 == 0){
                            add+=(num[0]-num[2])/2;
                            num[2]=num[0];
                    }else{
                            if(num[0]==num[1]){
                                    num[0]++;
                                    num[1]++;
                                    add++;
                            }else{
                                    num[1]++;
                                    num[2]++;
                                    add++;
                            }
                    }
            }
            printf("%d\n",add);
            return 0;
    }

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int inf=1<<30;
struct st{int p,b,c;};
bool operator<(st a,st b){
	return a.c>b.c;
}
unordered_map<int,vector<int> >e[100001];
unordered_map<int,int>d[100001];
vector<int> g[100001]; 
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int p,q,c;
		cin>>q>>p>>c;p--;q--;
		e[p][c].push_back(q);
		e[q][c].push_back(p);
		g[p].push_back(c);
		g[q].push_back(c);
	}
	st f;
	f.p=0;f.b=0;f.c=0;
	priority_queue<st> pq;
	d[0][0]=0;pq.push(f);
	while(!pq.empty()){
		st p=pq.top();pq.pop();
		//cout<<p.p<<" "<<p.b<<" "<<p.c<<endl;
		if(d[p.p][p.b]!=p.c)continue;
		if(d[p.p].find(0)==d[p.p].end()||d[p.p][0]>p.c){
			d[p.p][0]=p.c;
			f.b=0;
			f.p=p.p;f.c=p.c;
			pq.push(f);
		} 
		if(p.b==0){
			for(int v:g[p.p]){
				if(d[p.p].find(v)==d[p.p].end() || d[p.p][v]>p.c+1){
					d[p.p][v]=p.c+1;
					f.p=p.p;f.b=v;f.c=p.c+1;
					pq.push(f);
				}
			}
			continue;
		}
		for(int v:e[p.p][p.b]){
			if(d[v].find(p.b)==d[v].end()||d[v][p.b]>p.c){
				d[v][p.b]=p.c;
				f.p=v;f.b=p.b;f.c=p.c;
				pq.push(f);
			}
		}
	}
	int mi=inf;
	for(auto p:d[n-1])mi=min(mi,p.second);
	if(mi==inf)puts("-1");
	else cout<<mi<<endl;
	return 0;
}

Measured memory_bytes: 79764
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        boolean playing = true;
        int player = 0; //A
        int countA = 0, countB = 0, countC = 0;
        
        char A[] = scan.nextLine().toCharArray();
        char B[] = scan.nextLine().toCharArray();
        char C[] = scan.nextLine().toCharArray();
       
        while(playing) {
            switch(player) {
                case 0:
                    try {
                    switch(A[countA]) {
                        case 'a':
                            player = 0;
                            break;
                        case 'b':
                            player = 1;
                            break;
                        case 'c':
                            player = 2;
                            break;
                        
                    }
                    } catch(ArrayIndexOutOfBoundsException ex) {
                        System.out.println("A");
                        return;
                    }
                    countA += 1;
                    break;
                case 1:
                    try {
                    switch(B[countB]) {
                        case 'a':
                            player = 0;
                            break;
                        case 'b':
                            player = 1;
                            break;
                        case 'c':
                            player = 2;
                            break;
                            default :
                            System.out.println("B");
                            playing = false;
                            break;
                    }
                    } catch(ArrayIndexOutOfBoundsException ex) {
                        System.out.println("B");
                        return;
                    }
                    countB += 1;
                    break;
                case 2:
                    try {
                    switch(C[countC]) {
                        case 'a':
                            player = 0;
                            break;
                        case 'b':
                            player = 1;
                            break;
                        case 'c':
                            player = 2;
                            break;
                            default :
                            System.out.println("C");
                            playing = false;
                            break;
                    }
                    } catch(ArrayIndexOutOfBoundsException ex) {
                        System.out.println("C");
                        return;
                    }
                    countC += 1;
                    break;
            }
        }
        
    }
}

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

vector<int> G[100100];
vector<bool> seen(100100);
int dist[100100];
void bfs(int start){
	queue<pair<int,int>> Q;
	Q.push(pair<int,int>(start,0));
	while(!Q.empty()){
		int cur = Q.front().first;
		int tako = Q.front().second;
		Q.pop();
		if(seen[cur]) {
			continue;
		}
		seen[cur] = true;
		dist[cur] = tako;
		for(int i = 0 ; i < G[cur].size() ; i ++){
			int to = G[cur][i] ;
			Q.push(pair<int,int>(to,dist[cur]+1));
		}
	}
}
int main()
{
	int n;
	cin >> n;
	rep(i,n-1){
		int a , b ;
		cin >> a >> b ;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	//グラフが出来た。0からBFSで何個取れるかとn-1からBFSで何個取れるか
	rep(i,100100) dist[i] = 0 ;
	rep(i,100100) seen[i] = false;
	bfs(1);
	vector<int> dist_fene(n+1);
	for(int i = 1 ; i <= n ; i++){
		dist_fene[i] = dist[i];
	}
	//for(int i = 0 ; i <= n ; i++){
	//	cout <<"dist["<<i<<"]= " << dist[i] << endl;
	//}

	rep(i,100100) dist[i] = 0 ;
	rep(i,100100) seen[i] = false;
	bfs(n);
	vector<int> dist_sunu(n+1);
	for(int i = 1 ; i <= n ; i++){
		dist_sunu[i] = dist[i];
	}
	//for(int i = 0 ; i <= n ; i++){
	//	cout <<"dist["<<i<<"]= " << dist[i] << endl;
	//}
	int fene = 0 ;
	int sunu = 0;
	for(int i = 1 ; i <= n ; i++){
		if(dist_fene[i] <= dist_sunu[i]) fene++;
		else sunu ++;
	}
	debug(fene);
	debug(sunu);
	if(fene > sunu){
		cout << "Fennec" << endl;
	} else {
		cout << "Snuke"<<endl;
	}



}


Measured memory_bytes: 7112
#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>;

//エラストテネスの篩

bool flag[1000001];  //その数を見たかどうか/falseなら素数
int exist[1000001];

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    bool pairwise = true;
    bool setwise = true;

    rep(i, 1000001) flag[i] = false;
    rep(i, 1000001) exist[i] = 0;
    rep(i, N)++ exist[A[i]];

    for (int i = 2; i < 1000001; ++i) {
        int cnt = 0;
        cnt += exist[i];
        if (!flag[i]) {
            for (int j = i * 2; j < 1000001; j += i) {
                flag[j] = true;
                cnt += exist[j];
            }
        }
        if (cnt > 1) pairwise = false;
        if (cnt == N) setwise = false;
    }
    if (pairwise) {
        cout << "pairwise coprime" << endl;
    } else if (setwise) {
        cout << "setwise coprime" << endl;
    } else
        cout << "not coprime" << endl;
}


Measured memory_bytes: 11912
#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;
  string s;
  cin >> s;
  int ans = 0;
  rep(i, n)
  {
    if (s[i] == 'A')
    {
      if ("ABC" == s.substr(i, 3))
      {
        ans++;
        i += 2;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {

	vector<int> n(4, 0);
	for (int i = 0; i < n.size(); i++) {
		cin >> n[i];
	}
	sort(n.begin(), n.end());

	auto ok = (n[0] == 1 && n[1] == 4 && n[2] == 7 && n[3] == 9);

	cout << (ok ? "YES" : "NO") << endl;
	return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    string S, T; cin >> S >> T;
    ll ans = 0;
    rep(i, S.size()){
        if (S[i] != T[i]){ans++;}
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3772
lst = [int(i) for i in input().split()]
a = int(input())

n = []
if a == 1:
  for i in range(3):
    n.append([i])
if a == 2:
  for i in range(3):
    for j in range(3):
      n.append([i, j])
if a == 3:
  for i in range(3):
    for j in range(3):
      for k in range(3):
        n.append([i, j, k])
if a == 4:
  for i in range(3):
    for j in range(3):
      for k in range(3):
        for l in range(3):
          n.append([i, j, k, l])
if a == 5:
  for i in range(3):
    for j in range(3):
      for k in range(3):
        for l in range(3):
          for m in range(3):
            n.append([i, j, k, l, m])
if a == 6:
  for i in range(3):
    for j in range(3):
      for k in range(3):
        for l in range(3):
          for m in range(3):
            for o in range(3):
              n.append([i, j, k, l, m, o])
if a == 7:
  for i in range(3):
    for j in range(3):
      for k in range(3):
        for l in range(3):
          for m in range(3):
            for o in range(3):
              for p in range(3):
                n.append([i, j, k, l, m, o, p])
flag = False
for i in range(len(n)):
  #print(n[i])
  for index in n[i]:
    lst[index] *= 2
    #print(lst)
    if (lst[0] < lst[1]) and (lst[1] < lst[2]):
      flag = True
      break
  if flag:
    break
  for index in n[i]:
    lst[index] = int(lst[index] / 2)
if flag:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
//#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main(){fastio
    dd a,b;cin>>a>>b;
    ll ans=a*b;
    cout<<ans<<endl;
    
    return 0;
}





Measured memory_bytes: 3744