akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int h,w;
		while(true){
			h=sc.nextInt();
			w=sc.nextInt();
			if(h!=0&&w!=0){
				for(int i=0;i<h;i++){
					for(int j=0;j<w;j++){
						if(i==0||i==h-1||j==0||j==w-1){
							System.out.printf("#");
						}
						else{
							System.out.printf(".");
						}
					}
					System.out.println();
				}
				System.out.println();
			}
			else{
				break;
			}
		}
	}
}


Measured memory_bytes: 56508
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld  double
#define ff first
#define ss second
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
ll mod =   1e9 +7  ;
//const ll inf  = 1e9 + 10 ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
void solve(){
    ll x ;
    cin >> x ;
    if(x>=30){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }

}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1 ;
   // cin >> t ;
    while(t--){
        solve( );
    }
}



Measured memory_bytes: 3632
X,N = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
if(N==0):
    print(X)
    exit()


min = 101


for i in range(101,-1,-1):
    # print("i",abs(X-i),"min",min)
    if(not (i in p) and abs(i-X) <=abs(X-min)):
        min = i
        # print("IN *******i=",i,min)


print(min)


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

signed main() {
  string S;
  cin >> S;
  
  string T = "ACGT";
  
  int ans = 0;
  int now = 0;
  for( int i = 0; i < S.size(); i++ ){
    bool fg = false;
    for( int j = 0; j < 4; j++ ){
      if( S.at(i) == T.at(j) ) fg = true;
    }
    if( fg ) now++;
    else{
      ans = max(ans, now);
      now = 0;
    }
  }
  ans = max(ans, now);
  cout << ans << endl;

}


Measured memory_bytes: 256
using System;

namespace ConsoleApp17
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = 0;
            int a, b, c;
            string[] str = Console.ReadLine().Split(' ');
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);
            c = int.Parse(str[2]);
            for(int n = a; n <= b; n++)
            {
                if (c % n == 0)
                {
                    count = count + 1;
                }
            }
            Console.WriteLine("{0}",count);
        }
    }
}

Measured memory_bytes: 9224
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
   string a, b, c;
   cin >> a >> b >> c;
   if (a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0])
   {
      cout << "YES" << endl;
   }
   else
   {
      cout << "NO" << endl;
   }
   return 0;
}


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


int main() {
    int n, tmp;
    int sum = 0;

    cin >> n;
    tmp = n;

    while (tmp > 0) {
        sum += tmp % 10;
        tmp = tmp / 10;
    }

    if (n%sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

bool isPalindromicNumber(int n) {
    if ((n / 10000) != (n % 10)) {
        return false;
    }

    n /= 10;
    n -= (n / 1000) * 1000;

    return ((n / 100) == (n % 10));
}

int main() {
    int a, b;
    cin >> a >> b;

    int ans = 0;
    for (int i = a; i <= b; i++) {
        if (isPalindromicNumber(i)) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <utility>
using namespace std;
using ll = long long int; 

unsigned gcd(unsigned a, unsigned b) {
	if (a < b) gcd(b, a);
	unsigned r;
	while ((r = a%b)) {
		a = b;
		b = r;
	}
	return b;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	ll N, M;
	cin >> N >> M;
	string A, B;
	cin >> A >> B;
	ll g = gcd(N, M);
	for (ll i = 0; i < g; i++) {
		if (A[N / g*i] != B[M / g*i]) {
			cout << -1; return 0;
		}
	}
	cout << N / g*M;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
int main()
{
    int h,w,n;
    char s[8][8];
    int c=0,ans=0;
    scanf("%d %d %d",&h,&w,&n);
    for(int t=0;t<h;t++)
    {
        scanf("%s",s[t]);
    }
    for(int i=0;i<pow(2,h);i++)//所有可能项目
       for(int j=0;j<pow(2,w);j++)
       {
           c=0;
           for(int k=0;k<h;k++)
              {
                  if(i&(1<<k)) continue;//排除掉已经被清理项
                  for(int l=0;l<w;l++)
                  {
                      if(j&(1<<l)) continue;
                      if(s[k][l]=='#') c++;
                  }
                  
              }
              if(c==n) ans++;
       }
       printf("%d",ans);
       return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define ZERO(a) memset(a,0,sizeof(a))

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll n,k;
  cin>>n>>k;
  vpl t(n);
  REP(i,n)cin>>t[i].SE>>t[i].FI;

  sort(ALL(t), greater<pll>());
  vll picked(n+1), remind, tail;

  ll sum=0;
  ll kind=0;
  REP(i,n){
    if(i<k){
      sum+=t[i].FI;
      if(picked[t[i].SE]==0){
        picked[t[i].SE]=1;
        kind++;
      }
      else
        tail.push_back(t[i].FI);
    }
    else{
      if(picked[t[i].SE]==0){
        remind.push_back(t[i].FI);
        picked[t[i].SE]=1;
      }
    }
  }

  sort(ALL(tail));
  sort(ALL(remind), greater<ll>());
  ll ans = sum+kind*kind;
  ll m=min(tail.size(), remind.size());
  REP1(i,m)tail[i]+=tail[i-1];
  REP1(i,m)remind[i]+=remind[i-1];

  REP(i,m)
    ans = max(ans,sum-tail[i]+remind[i]+(kind+1+i)*(kind+1+i));

  cout<<ans<<endl;

}



Measured memory_bytes: 3392
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,d=map(int, readline().rstrip().split())
    dd = d * d
    ans=0
    for i in range(n):
        x,y=map(int, readline().rstrip().split())
        xy=x*x+y*y
        if xy<=dd:
            ans+=1
    print(ans)
    #arr=list(map(int, readline().rstrip().split()))
    #n=int(readline())
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16140
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>

using namespace std;

int main(){
	int n, m;
	cin >> n >> m;

	int l=1, r=n;
	for(int i=0; i<m; i++){
		int l0, r0;
		cin >> l0 >> r0;
		l=max(l, l0);
		r=min(r, r0);
	}

	if(l<=r) cout << r-l+1 << endl;
	else cout << 0 << endl;

	return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int 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)1E16;
#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 fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

int main(){
    ll n;cin>>n;
    ll ans=1;
    ll a[n];
    rep(i,0,n-1){
        cin>>a[i];
    }
    rep(i,1,n-1){
        if(a[i]<=a[i-1]){
            ans++;
        }
    }
    cout<<ans<<endl<<n<<endl;
    
    
    
    return 0;
}



Measured memory_bytes: 3884
#include <bits/stdc++.h>
using namespace std;
 
  int main() {
  int N;
  cin >> N;
  vector <char> str(N);
 
  for (int i = 0; i < N; i++) {
    cin >> str.at(i);
    }
 
  string answer = "Three";
  for (int i = 0; i < N; i++) {
    if (str.at(i) == 'Y') {
      answer = "Four";
      break;
    }
  }
 
  cout << answer << endl;
}
  
  

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdio.h>
using namespace std;

int main(){
    int a, b, c, x;
    cin>>a>>b>>c>>x;
    int i, j, k;
    int ans = 0;
    for(i=0; i<=a; i++){
        for(j=0; j<=b; j++){
            for(k=0; k<=c; k++){
                if(500*i+100*j+50*k==x){
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e;
  string s,ss,sss;
  cin>>a>>b>>c;
  cout<<min(a+b,min(b+c,c+a))<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N;

int main()
{
    while (cin >> N)
    {
        if (N == 0)
            return 0;
        int left = 0, right = 0, high = 0, low = 0, x = 0, y = 0;
        vector<pair<int, int>> v;
        for (int i = 0; i < N - 1; i++)
        {
            int n, d;
            cin >> n >> d;
            v.emplace_back(n, d);
        }

        vector<pair<int, int>> point(N);
        point[0] = {0, 0};
        for (int i = 0; i + 1 < N; i++)
        {
            int dx = 0, dy = 0, d = v[i].second;
            if (d == 0)
                dx--;
            else if (d == 1)
                dy--;
            else if (d == 2)
                dx++;
            else if (d == 3)
                dy++;
            point[i + 1] = {point[v[i].first].first + dx, point[v[i].first].second + dy};
        }

        for (int i = 0; i < N; i++)
        {
            left = min(left, point[i].first);
            right = max(right, point[i].first);
            low = min(low, point[i].second);
            high = max(high, point[i].second);
        }

        cout << (right - left + 1) << " " << (high - low + 1) << endl;
    }
}


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

int main() {
  int N;
  cin >> N;
  vector <int> a(101);
  
  for(int i=0;i<N;i++){
       int b;
       cin >>b;
       a.at(b)=1;
  }
  int r;
  for(int i=0;i<101;i++){
    r+=a.at(i);
  }  
  cout << r;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int i,j,b[50],p,n,pp;

  while(1)
    {
      scanf("%d%d",&n,&p);
      if(n==0 && p==0) break;
      pp=p;
      j=0;
      for(i=0;i<=n-1;i++)
         {
	    b[i]=0;
	 }
      while(1)
	{
	  if(p!=0)
	    {
	      b[j]++;
	      p--;
	    }
	  else
	    {
	      p+=b[j];
	      b[j]=0;
	    }
	  if(b[j]==pp) break;
	  j++;
	  j%=n;
	}
      printf("%d\n",j);
    }
  return 0;
}

Measured memory_bytes: 600
N, x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a_sort =sorted(a)
cou = 0
for i in range(N):
    if x >= a_sort[i]:
        x -= a_sort[i]
        cou += 1
if x > 0 and cou == N:
    print(cou-1)
else:
    print(cou)

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

import numpy as np
nmx = input().split(" ")
n = int(nmx[0])
m = int(nmx[1])
x = int(nmx[2])
a = []
c = []
total = []
pattern = [[0] * n]

for i in range(pow(2, n) - 1):
  pattern.append([pattern[i][j] for j in range(n)])
  for j in range(n):
    if pattern[i+1][j] == 0:
      pattern[i+1][j] = 1
      break
    else:
      pattern[i+1][j] = 0

r = 0

for i in range(n):
  text = input().split(" ")
  c.append(int(text[0]))
  a.append([int(text[i]) for i in range(1, m + 1)])

a = np.array(a)

for i in range(pow(2, n) - 1, -1,  -1):
  array = a.T @ pattern[i]
  if not(all(v >= x for v in array)):
    pattern = np.delete(pattern, i, 0)


total = [np.dot(np.array(c), p) for p in pattern]
# print(pattern)
# print(total)

if len(total) > 0:
  print(min(total))
else:
  print(-1)

Measured memory_bytes: 28516
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    string s;
    int N;
    cin >> N;
    vi a(N);
    rep(i, 0, N) {
        cin >> a[i];
    }
    int count = 0;
    int j = 1;

    rep(i, 0, N) {
            if (a[i] == j) {
                ++j;
            } else {
                ++count;
            }
    }
    
    if (j == 1) {
        cout << -1 << endl;
    } else {
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
import sys

input = sys.stdin.readline


def main():
    N = int(input())

    dp = [0] * (10 ** 5 + 1)
    dp[1] = 1

    x = [1]
    x.extend([6 ** x for x in range(1, 8)])
    x.extend([9 ** x for x in range(1, 6)])


    for i in range(2, 10 ** 5 + 1):
        tmp = []
        for v in x:
            if i >= v:
                tmp.append(dp[i - v] + 1)

        dp[i] = min(tmp)

    print(dp[N])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define nl cout<<"\n"
#define db(x) cout<<x<<" "
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define fk(a,b) for(int k=a;k<b;k++)
#define F first
#define S second
#define UM unordered_map<int,int>
#define MP map<int,int>
void fun(){
	ll n;	cin>>n;
	vector<ll> a(n+1);
	fi(1,n+1){
		for(int j=i;j<=n;j=j+i)
			a[j]+=1;
	}
	ll ans=0;
	fi(1,n+1)	ans+=i*a[i];
	cout<<ans<<"\n";
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
	// cin>>t;
	while(t--){
		fun();
	}
}

Measured memory_bytes: 81316
import java.util.*;

class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        int count = 1;

        //AとBの大公約数を求める
        long gcdAB = Main.gcd(A, B);
        double sqrtGcd = Math.sqrt(gcdAB);

        for(long i = 2 ; i <= sqrtGcd; i++){
            if(gcdAB % i == 0) count++;
            while(gcdAB % i == 0){
                gcdAB /= i;
            }
        }
        if(gcdAB > 1) count++;

        System.out.println(count);

    }

    //gcd  = greateset common divisor
    public static long gcd(long A, long B){
        if(B == 0) return A;
        else return gcd(B, A % B);
    }




}







Measured memory_bytes: 23764
//#include "pch.h" 
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <time.h>
#include <iomanip>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define double long double
#define int long long
#define low lower_bound
#define upp upper_bound
#define mod (int)(1e9 + 7)
#define inf (int)1e16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define P pair<int,int>
using namespace std;
int h, w, cnt = 0;
char s[55][55];
int d[55][55];
int a[4] = { 0,1,0,-1 }, b[4] = { 1,0,-1,0 };
int bfs() {
	queue<P>que;
	rep(i, h) rep(j, w) d[i][j] = inf;
	que.push(P(0, 0));
	d[0][0] = 0;
	while (que.size()) {
		P p = que.front(); que.pop();
		if (p.first == h - 1 && p.second == w - 1) break;
		rep(i, 4) {
			int ny = p.first + a[i], nx = p.second + b[i];
			if (0 <= nx && nx < w && 0 <= ny && ny < h&&s[ny][nx] != '#'&&d[ny][nx] == inf) {
				que.push(P(ny, nx));
				d[ny][nx] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[h - 1][w - 1];
}
signed main() {
	cin >> h >> w;
	rep(i, h) {
		rep(j, w) {
			cin >> s[i][j];
			if (s[i][j] == '.') cnt++;
		}
	}
	int dis = bfs();
	if (dis == inf) {
		cout << -1 << endl;
	}
	else {
		cout << cnt - dis - 1 << endl;
	}
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

#[allow(unused_macros)]
macro_rules! vec_md {
    ( $ init : expr ; $ ( $ dim : expr ) ;* ) => { vec_md ! ( $ ( $ dim ) ;* => $ init ) };
    ( $ head : expr ; $ ( $ tail : expr ) ;* => $ init : expr ) => { vec ! [ vec_md ! ( $ ( $ tail ) ;* => $ init ) ; $ head ] };
    ( $ head : expr => $ init : expr ) => { vec ! [ $ init ; $ head ] };
}

#[allow(unused_macros)]
macro_rules! chmax {
    ( $ x : expr , $ y : expr ) => { if $ x < $ y { $ x = $ y ; true } else { false } };
}

fn main() {
    input! {
        n: usize,
        abc: [[u64; 3]; n]
    }

    let mut dp = vec_md![0u64;n+1;3];
    for i in 0..n {
        for j in 0..3 {
            for k in 0..3 {
                if j != k {
                    chmax!(dp[i+1][k], dp[i][j] + abc[i][k]);
                }
            }
        }
    }
    println!("{}",
        std::cmp::max(dp[n][0], std::cmp::max(dp[n][1], dp[n][2]))
    );
}

Measured memory_bytes: 18684
from collections import defaultdict
import sys
sys.setrecursionlimit(10**7)

N = int(input())
ab = [tuple(map(int, input().split())) for _ in range(N - 1)]

G = defaultdict(list)

v = [-1 for _ in range(N - 1)]

for i, (a, b) in enumerate(ab):
    G[a].append((b, i))
    G[b].append((a, i))

def check(p, trg, pc):
    # print(p, trg, pc)
    c = 0
    for next_, vi in G[trg]:
        if next_ != p:
            if c == pc:
                c += 1
            check(trg, next_, c)
            v[vi] = c
            c += 1

check(0, 1, -1)
print(len(set(v)))
for c in v:
    print(c + 1)

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

using namespace std;

const int MAX_N = 200 + 5;

int n, L[MAX_N], ans;

int main() {
    scanf("%d", &n);
    n <<= 1;
    for (int i = 1; i <= n; ++i) scanf("%d", L + i);
    sort(L + 1, L + n + 1);
    for (int i = 1; i <= n; i += 2) ans += L[i];
    printf("%d\n", ans);
    return 0;
}

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

int main(){
    int n,m; cin >> n >> m;
    int cnt = 0;
    vector<int> score(m,0);
    for(int i = 0; i < n; i++){
        int k; cin >> k;
        for(int j = 0; j < k; j++){
            int x; cin >> x;
            score[x-1]++;
            }
    }
    for(int l = 0; l < m; l++){
        if(score[l] == n) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<vector>
using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  //白いマスのみからなる行または列が存在する間、次の操作を繰り返し行います
  //操作: 白いマスのみからなる行または列をひとつ任意に選び、その行または列を取り除いて空白を詰める。
  vector<string> c(h);
  for(int i=0;i<h;i++){
    cin>>c[i];
  }

  vector<bool>row(h,false);//falseで初期化
  vector<bool>col(w,false);//falseで初期化
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(c[i][j]=='#'){
        row[i]=true;
        col[j]=true;
      }
    }
  }
  for(int i=0;i<h;i++){
    if(row[i]){
      for(int j=0;j<w;j++){
        if(col[j]){
          cout<<c[i][j];
        }
      }
    }
    cout<<endl;
  }
}


Measured memory_bytes: 256
#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, M;
  cin >> N >> M;

  vector<bool> AC(N, false);
  vector<int> WA(N, 0);
  rep(i, M) {
    int p;
    string s;
    cin >> p >> s;
    p--;

    if (AC.at(p)) continue;
    if (s == "AC") {
      AC.at(p) = true;
    } else {
      WA.at(p)++;
    }
  }

  int numA = 0;
  int numW = 0;
  rep(i, N) {
    if (AC.at(i)) {
      numA++;
      numW += WA.at(i);
    }
  }
  cout << numA << " " << numW << endl;
  return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
from sys import stdin
import numpy as np
# import sys
# sys.setrecursionlimit(10**4)

s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()


MOD = 998244353

N = d_in()
total = 3 ** N - (2**N - 2) * 3 - 3

a_list = []
for _ in range(N):
    a_list.append(d_in())
sum_a = sum(a_list)

# 1要素目: i番目の整数までを考慮
# 2要素目: [both>0, (緑or青)>0, both==0]
# 3要素目: 最大の色(赤とする)の和, sum_aの半分まで
dp = np.zeros((N+1, 3, 1 + (sum_a+1)//2), dtype=int)
dp[0, 2, 0] = 1

for i in range(1, N+1):
    a = a_list[i-1]

    # 赤に入れる
    dp[i, :, a:] += dp[i-1, :, :-a]
    dp[i, :, -1] += dp[i-1, :, -a:].sum(axis=1)

    # 緑or青に入れる
    dp[i, 0, :] += (dp[i-1, 0, :] + dp[i-1, 1, :]) * 2
    dp[i, 1, :] += dp[i-1, 1, :]
    dp[i, 1, :] += dp[i-1, 2, :]

    dp[i, :, :] %= MOD

print((total - dp[-1, 0, -1] * 3) % MOD)


Measured memory_bytes: 328724
n, m, _ = map(int, input().split())
exem = list(range(n))
i = 0

for a in map(int, input().split()):
    is_odd = a & 1
    i += -a if a & 1 else a
    i %= n
    exem.pop(i)
    n -= 1

for q in map(int, input().split()):
    print(int(q in exem))

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

int main() {
  string s,ans;
  cin >> s;
  ans = "Yes";
  
  for(int i = 0;i < s.size();i++){
    if(i%2 == 0){
      if(s.at(i) == 'L'){
        ans = "No";
        break;
      }
    }else{
      if(s.at(i) == 'R'){
        ans = "No";
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
int main() {
	int N, M;
	ll S = 0;
	cin >> N >> M;
	vector<ll> a(N);
	vector<pair<ll, ll>> d(M);
	rep(i, 0, N)cin >> a[i];
	rep(i, 0, M)scanf("%lld%lld", &d[i].second, &d[i].first);
	sort(all(a));
	sort(all(d));
	reverse(all(d));
	auto it = a.begin();
	rep(i, 0, M) {
		ll x = min((ll)(lower_bound(it, a.end(), d[i].first) - it), d[i].second);
		S += (ll)d[i].first * x;
		it += x;
		if (it == a.end())break;
	}
	rep(i, it - a.begin(), N) {
		S += a[i];
	}
	printf("%lld\n", S);
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;

int main() {

	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 1; j < n; j++) {
			int arr[256] = { 0 }, sum = 0;

			for (int k = i; k < j; k++) {
				arr[(int)s[k]]++;
			}
			for (int k = j; k < n; k++) {
				if (arr[(int)s[k]] > 0) {
					sum++;
					arr[(int)s[k]] = 0;
				}
			}
			ans = max(ans, sum);

		}
	}

	printf("%d\n", ans);
}



Measured memory_bytes: 3676
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

typedef struct{
    int t;
    int x;
    int y;
}data;

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

    //A[0]~A[N-1]に格納する
    data* A;
    NEW(A,N+1);
    A[0].t=0;
    A[0].x=0;
    A[0].y=0;
    for(int i=1;i<=N;i++){
        scanf("%d%d%d",&A[i].t, &A[i].x, &A[i].y);
    }

    int flg;
    for(int i=1;i<=N;i++){
        int distance = abs(A[i].x-A[i-1].x)+abs(A[i].y-A[i-1].y);
        int time = A[i].t-A[i-1].t;

        if(distance>time) flg=0;
        else if((time-distance)%2==1) flg=0;
        else flg=1;

        if(!flg){
            printf("No\n");
            return 0;
        }
    }

    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pf(n) printf("%d\n",n)
#define pff(a,b) printf("%d  %d\n",a,b);
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

int main() {
	int n, T;
	cin >> n >> T;
	int ans = 1001001;
	rep(i, n) {
		int c, t;
		cin >> c >> t;
		if (t <= T and c<ans) {
			ans = c;
		}
	}
	if (ans == 1001001) {
		cout << "TLE\n";
		return 0;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3588
from collections import deque
N, M = map(int, input().split())
INF = 1001001001
dist = [[INF for _ in range(3)] for _ in range(N)]

# 有向グラフG
G = [[] for _ in range(N)]
for i in range(M):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    G[u].append(v)

S, T = map(int, input().split())
S -= 1
T -= 1

# BFS
q = deque()
q.append((S, 0))
dist[S][0] = 0

while q:
    v, l = q.popleft()
    for u in G[v]:
        nl = (l + 1) % 3
        if dist[u][nl] == INF:
            dist[u][nl] = dist[v][l] + 1
            q.append((u, nl))

ans = dist[T][0]
if ans == INF:
    ans = -1
else:
    ans //= 3
print(ans)


Measured memory_bytes: 39624
#include <bits/stdc++.h>
 
const int N = 505;
typedef std::pair<std::pair<int, int>, std::pair<int, int> > P;
 
int n, m, i, j, k, h, w;       
std::vector<P> ans;  
int a[N][N];
 
int main() {
  scanf("%d %d", &h, &w);
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      scanf("%d", a[i] + j);
    }
  }
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j < w; j++) {
      if (a[i][j] & 1) {
        a[i][j]--;
        a[i][j + 1]++;
        ans.push_back(std::make_pair(std::make_pair(i, j), std::make_pair(i, j + 1)));
      }
    }
  }
  for (int i = 1; i < h; i++) {
    if (a[i][w] & 1) {
      a[i][w]--;    
      a[i + 1][w]++;
      ans.push_back(std::make_pair(std::make_pair(i, w), std::make_pair(i + 1, w)));
    }
  }
  printf("%d\n", ans.size());
  for (P v : ans) {
    printf("%d %d %d %d\n", v.first.first, v.first.second, v.second.first, v.second.second);
  }
  return 0;    
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> toshi(n + 1, 0);//添え字は都市番号,値は他都市に向けられた道路の数
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    toshi[a]++;
    toshi[b]++;
  }
  for (int i = 1; i <= n; i++) cout << toshi[i] <<endl;
}

Measured memory_bytes: 3592
program atc
integer i,j,count
character(3) c
read *, c
count=700
if (c(1:1)=="o" ) then
  count=count+100
end if
if (c(2:2)=="o" ) then
  count=count+100
end if
if (c(3:3)=="o" ) then
  count=count+100
end if
print *, count
end program atc

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;
void set(long long N, vector<long long>& par) {
	for (long long i = 0; i < N; i++) par[i] = -1;
}

long long root(long long x, vector<long long>& par) {
	if (par[x] < 0) return x;
	return par[x] = root(par[x], par);
}

void unite(long long x, long long y, vector<long long>& par) {
	long long rx = root(x, par);
	long long ry = root(y, par);
	if (rx == ry) return;
	par[ry] += par[rx];
	par[rx] = ry;
}
bool same(long long x, long long y, vector<long long>& par) {
	long long rx = root(x, par);
	long long ry = root(y, par);
	return rx == ry;
}
long long size(long long x, vector<long long>& par) {
	return -par[root(x, par)];
}

int main() {
	long long N, M;
	cin >> N >> M;
	vector<pair<long long, long long>> E(M);
	for (long long i = 0; i < M; i++) cin >> E[i].first >> E[i].second;
	vector<long long> Ans(M);
	vector<long long> par(N);
	set(N, par);
	Ans[M - 1] = N * (N - 1) / 2;
	for (long long i = M - 1; i >= 1; i--) {
		long long a = E[i].first, b = E[i].second;
		Ans[i - 1] = Ans[i];
		if (!same(a - 1, b - 1, par)) {
			Ans[i - 1] -= size(a - 1, par) * size(b - 1, par);
			unite(a - 1, b - 1, par);
		}
	}
	for (long long a : Ans) cout << a << endl;
}


Measured memory_bytes: 6368
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  double a,b;
  cin>>a>>b;
  printf("%f\n",a*b/(a+b));
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
using namespace std;

bool is_good(int n)
{
    bool frag = true;
    int next = n / 10;
    int keta = n % 10;
    while (next != 0)
    {
        if (keta != next % 10)
        {
            frag = false;
            break;
            cout << n <<" in not good" << endl;
        }
        keta = next % 10;
        next = next / 10;
    }
    return frag;
}

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

    while (true)
    {
        if(is_good(n))
        {
            cout << n << endl;
            break;
        }
        n++;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main()
{
    int a;
    while(scanf("%d",&a)!=EOF)
    {
        if(a<=3)
            printf("%d\n",a);
        else
        {
            int f=0,maxn;
            for(int i=a;i>=1;i--)
            {
                for(int j=2;j<=sqrt(i+1);j++)
                {
                    int b=i;
                    while(b)
                    {
                        if(b%j==0)
                            b=b/j;
                        else
                        {
                            f=0;
                            break;
                        }
                        if(b==1)
                        {
                            f=1;
                            maxn=i;
                            break;
                        }
                    }
                    if(f==1)
                        break;
                }
                if(f==1)
                    break;
            }
            printf("%d\n",maxn);
        }

    }
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(),(x).end()
#define pushb(x) push_back(x)
#define popb() pop_back()
#define makep make_pair
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv);
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v);
template<typename T> ll gcd(T a,T b);
template<typename T> ll lcm(T a,T b);
int main(){
    string s;cin>>s;
    rep(i,3){
        if(s[i]==s[i+1]){
            cout<<"Bad"<<endl;
            return 0;
        }
    }
    cout<<"Good"<<endl;
    return 0;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
    int len = vv.size();
    for (int i = 0; i < len; ++i) {
        s << vv[i] << endl;
    }
    return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len - 1) s << ' ';
    }
    return s;
}
template<typename T> ll gcd(T a,T b){
    if(b==0){
        return a;
    }
    return gcd(b,a%b);
}
template<typename T> ll lcm(T a,T b){
    return a*b/gcd(a,b);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <set>
#include <string>
#include <iomanip>
using namespace std;

int main(){
    long long n,a,b,c,d,e;
    cin >> n >> a >> b >> c >> d >> e;
    long long x = min({a,b,c,d,e});
    cout << 4 + ( n+x-1)/x << endl;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    ll ans = 0;

    if (N%2 == 0) {
        ll tmp = 10;
        ans += N/tmp;
        while (N >= tmp) {
            tmp *= 5;
            ans += N/tmp;
        }
    }

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

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N,K = map(int,S().split())
p = LI()
p = sorted(p)

ans = 0
for i in range(K):
    ans += p[i]

print(ans)

Measured memory_bytes: 62496
import java.util.Scanner;

class Main{

	public static void main(String[] args) {




		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		int[] data = new int[N];

		for(int i = 0;i < N; i++){
			data[i] = scan.nextInt();
		}

		long[] ansdata = new long[N];

		for(int i = 0;i <= N-K; i++){
			ansdata[i] = Math.min(Math.abs(data[i]) + Math.abs(data[i]-data[i+K-1]),Math.abs(data[i+K-1]) + Math.abs(data[i]-data[i+K-1]))  ;


		}
		long min = Integer.MAX_VALUE;
		for(int i= 0;i <= N-K;i++){
			min = Math.min(min, ansdata[i]);
		}
		
		
			System.out.println(min);
		



	}


}


Measured memory_bytes: 50116
use proconio::input;

const MOD: usize = 1_000_000_007;

fn main() {
  input! {
    n: usize,
    ai: [usize;n]
  }
  
  let mut sum = 0;
  for i in 0..=60 {
    let mut count = 0;
    for v in ai.iter() {
      if *v >> i & 1 == 1 {
        count += 1;
      }
    }
    let mut s_sum = count * (n - count) % MOD;
    
    for ii in 0..i {
      s_sum = s_sum * 2 % MOD;
    }
    sum = s_sum + sum % MOD;
  }
  println!("{}", sum);
}

Measured memory_bytes: 9828
N, M = map(int, input().split())
a = [0]*N
b = [0]*N
pena = 0
for i in range(M):
    p, s = input().split()
    if s == 'WA' and a[int(p)-1] == 0:
        b[int(p)-1] += 1
    if s == 'AC' and a[int(p)-1] == 0:
        a[int(p)-1] = 1
        pena += b[int(p)-1]
print(sum(a),pena)

Measured memory_bytes: 4596
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  int N;
  cin >> N;
  vector<int64_t> A(N);
  rep(i, N) { cin >> A[i]; }
  if (A[0] != 0) {
    cout << -1 << endl;
    return 0;
  }

  int64_t answer = 0;
  for (int i = N - 1; i > 0; --i) {
    if (A[i - 1] >= A[i]) {
      answer += A[i];
    } else if (A[i] - A[i - 1] >= 2) {
      cout << -1 << endl;
      return 0;
    } else {
      ++answer;
    }
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 4820
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++) 
#define all(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
	string S;
	cin >> S;
	string s = "Sunny";
	string c = "Cloudy";
	string r = "Rainy";
	if(S == s){
		cout << c << endl;
	} else if(S == c){
		cout << r << endl;
	} else {
		cout << s << endl;
	}
}

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

using namespace std;

int main() {
    int n,k;
    long double sum, ans;
    ans = 0.0;
    cin >> n >> k;
    for (int i=1; i<=n; i++) {
        long double tmp = 1.0/n;
        sum = i;
        while( sum < k ) {
            sum *=2.0;
            tmp /=2.0;
        }
        ans += tmp;
    }
    // cout << ans << endl;
    printf("%.14Lf\n", ans);
}


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

using namespace std;
using ll = long long;

int const N = 100 * 1000 + 16;

int n;
bool done;
int c[N];
vector<int> g[N];
vector<int> nodes;

void dfs(int u, int p) {
  if(done)
    return;
  nodes.emplace_back(u);

  if(u == n) {
    done = true;
    return;
  }

  for(int v : g[u])
    if(not done && v != p)
      dfs(v, u);

  if(not done)
    nodes.pop_back();
}

int cnt;
void dfs_color(int u, int p) {
  cnt++;
  for(int v : g[u])
    if(v != p && not c[v])
      dfs_color(v, u);
}

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

  cin >> n;
  for(int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    g[u].emplace_back(v);
    g[v].emplace_back(u);
  }

  dfs(1, 0);
  for(int l = 0, r = nodes.size()-1; l <= r; l++, r--)
    c[nodes[l]] = 1;

  dfs_color(n, 0);

  int f = n-cnt;
  int s = n-f;
  cout << (f > s ? "Fennec" : "Snuke") << endl;
}

Measured memory_bytes: 11384
void main() {
    int n = readln.chomp.to!int;
    int[] a = readln.split.to!(int[]);
    int diff;
    a.sort!"a > b";
    foreach (i, x; a) {
        diff += (-1) ^^ i * x;
    }
    diff.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

int main() {
 long long int n;cin>>n;long long int a[5];//cout<<"unko"<<endl;
  for(int i=0;i<5;i++){
    cin>>a[i];//cout<<a[i]<<endl;
  }
  sort(a,a+5);

 if(n%a[0]!=0)cout<<n/a[0]+5<<endl;
  else cout<<n/a[0]+4<<endl;
  
  
  
  
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
int C[202020];
ll V[202020];
vector<ll> cand[202020];
int id[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N) {
		cin>>C[i]>>V[i];
		C[i]--;
		cand[C[i]].push_back(V[i]*2);
	}
	
	multiset<pair<ll,int>> P,Q,R,S,T;
	vector<vector<ll>> ev;
	FOR(i,K) {;
		sort(ALL(cand[i]));
		cand[i][cand[i].size()-2]=cand[i][cand[i].size()-1]=(cand[i][cand[i].size()-1]+cand[i][cand[i].size()-2])/2;
		reverse(ALL(cand[i]));
		S.insert({cand[i][0]+cand[i][1],i});
		if(cand[i].size()>=3) T.insert({cand[i][0]+cand[i][1]+cand[i][2],i});
		FOR(j,cand[i].size()) ev.push_back({-cand[i][j],i,j});
	}
	
	sort(ALL(ev));
	ll cur=0;
	FOR(i,N) {
		auto e=ev[i];
		x=e[1];
		
		if(e[2]==0) {
			ll ret=-2;
			if(Q.size()) ret=max(ret,cur+Q.rbegin()->first);
			if(P.size()&&S.size()) ret=max(ret,cur-P.begin()->first+S.rbegin()->first);
			if(R.size()&&T.size()) ret=max(ret,cur-R.begin()->first+T.rbegin()->first);
			cout<<ret/2<<endl;
		}
		else {
			
			if(e[2]==1) {
				cur-=2*e[0];
				S.erase({cand[x][0]+cand[x][1],x});
				if(cand[x].size()>=3) T.erase({cand[x][0]+cand[x][1]+cand[x][2],x});
				R.insert({cand[x][0]+cand[x][1],x});
				id[x]=2;
				if(id[x]<cand[x].size()) Q.insert({cand[x][id[x]],x});
			}
			else {
				cur-=e[0];
				if(id[x]==2) R.erase({cand[x][0]+cand[x][1],x});
				else P.erase({cand[x][id[x]-1],x});
				Q.erase({cand[x][id[x]],x});
				P.insert({cand[x][id[x]],x});
				id[x]++;
				if(id[x]<cand[x].size()) Q.insert({cand[x][id[x]],x});
			}
			cout<<cur/2<<endl;
		}
		
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main(){
	string S, T;
  	cin >> S;
  	cin >> T;
  	T.pop_back();
  	if (S.compare(T) == 0) cout << "Yes\n";
  	else cout << "No\n";
  	return 0;
}

Measured memory_bytes: 3628
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)
ll n;
ll dummy[2][5001][2];//!j???i???????????????????????´j???????°??????????
ll a[10000];
const ll INF = 0xffffffffff;

int main()
{
	cin>>n;
	rep1(i,n-1) cin>>a[i];
	fill(dummy[0][0],dummy[1][5001],INF);
	ll (*dp1)[2]=dummy[0];
	ll (*dp2)[2]=dummy[1];
	dp1[0][0]=0;
	dp1[0][1]=0;
	rep(i,n-1){
		rep(j,n/2+1) rep(k,2) dp2[j][k]=INF;
		rep(j,min(n/2,i)+1){
			rep(k,2){
				dp2[j][k]=min(dp2[j][k],dp1[j][k]); //k????????????
				if(i+1-j<=(n/2)) dp2[i+1-j][!k]=min(dp2[i+1-j][!k],dp1[j][k]+a[i+1]); //!k????????????
			}
		}
		swap(dp1,dp2);
	}
	cout<<min(dp1[n/2][0],dp2[n/2][1])<<endl;
}

Measured memory_bytes: 3364
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;

//Power with MOD: O(logp)
template<typename T>
T mod_pow(T a, int p)
{
	if (p == 0)return 1;
	else if (p == 1)return a;
	else if (p % 2 == 0)
	{
		ll h = mod_pow(a, p / 2);
		return h * h % MOD;
	}
	else return (mod_pow(a, p - 1) * a) % MOD;
}

//Combination using factorial: O(n)
struct comb_fact
{
	int N;
	vector<ll> fact, fact_inv;
	comb_fact(int n):N(n)
	{
		fact = vector<ll>(N+1,1);
		fact_inv = vector<ll>(N+1,1);
		rep(i, n)
		{
			fact[i+1] = (fact[i]*ll(i+1)) % MOD;
			fact_inv[i+1]=(fact_inv[i]*mod_pow(ll(i+1),MOD-2)) % MOD;
		}
	};

	ll comb(ll n, ll m)
	{
		return (((fact[n]*fact_inv[m]) % MOD) * fact_inv[n-m]) % MOD;
	}
};

void solve()
{	
	ll n,k; cin >> n>>k;
	ll e_max=min(n-1,k);
	ll ans=0;
	comb_fact cf(n);
	rep(i,e_max+1)
	{
		ll tmp = (cf.comb(n,i)*cf.comb(n-1,i))%MOD;
		ans+=tmp;
		ans%=MOD;
	}
	cout << ans << endl;
	return;
}

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


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<n; i++)
template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) cin >> a[i];

    int cur = 0;
    REP(i, N)
        if(a[i] == cur+1) cur++;
    if(cur == 0) cout << -1 << endl;
    else cout << N - cur << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>

#define fr(i,a,b) for(register long long i=a;i<=b;i++)
#define cabs(a) ((a)<0?-(a):(a))

long long n,a[100010],b[100010],c[100010],sum;

inline long long v_in(){
	char ch=getchar();long long sum=0,f=1;
	while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') sum=(sum<<3)+(sum<<1)+(ch^48),ch=getchar();
	return sum*f;
}

int main(){
	n=v_in();
	fr(i,1,n) a[i]=v_in();
	a[0]=a[n+1]=0;
	fr(i,1,n+1) b[i]=cabs(a[i]-a[i-1]),sum+=b[i];
	fr(i,2,n+1) c[i]=cabs(a[i]-a[i-2]);
	fr(i,1,n) printf("%lld\n",sum-b[i]-b[i+1]+c[i+1]);
	return 0;
}

Measured memory_bytes: 3456