akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define sqr(a) (a)*(a)

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    vector< string > v(n);
    for(auto &el : v){
        cin >> el;
    }
    sort(v.begin(), v.end());
    int mv = 1;
    int nv = 1;
    for(int i = 1; i < n; ++i){
        if(!v[i].compare(v[i-1])){
            nv++;
        }else{
            mv = max(mv, nv);
            nv = 1;
        }
    }
    mv = max(mv, nv);
    nv = 1;
    for(int i = 1; i < n; ++i){
        if(!v[i].compare(v[i-1])){
            nv++;
        }else{
            if(nv == mv){
                cout << v[i-1] << endl;
            }
            nv = 1;
        }
    }
    if(nv == mv){
        cout << v[n-1] << endl;
    }
}

Measured memory_bytes: 12928
#include <iostream>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

    int l = n / 2;
    int A[100000];
    REP(i, 100000) A[i] = 0;
    int B[100000];
    REP(i, 100000) B[i] = 0;
    int buf;
    
    REP(i, l) {
        cin >> buf;
        A[buf]++;
        cin >> buf;
        B[buf]++;
    }

    int am = 0;
    int amv = 0;
    int am2 = 0;
    int amv2 = 0;
    REP(i, 100000) {
        if (A[i] > amv) {
            amv2 = amv;
            am2 = am;
            amv = A[i];
            am = i;
        }
        else if (A[i] > amv2) {
            amv2 = A[i];
            am2 = i;
        }
    }

    int bm = 0;
    int bmv = 0;
    int bm2 = 0;
    int bmv2 = 0;
    REP(i, 100000) {
        if (B[i] > bmv) {
            bmv2 = bmv;
            bm2 = bm;
            bmv = B[i];
            bm = i;
        }
        else if (B[i] > bmv2) {
            bmv2 = B[i];
            bm2 = i;
        }
    }

    if (am != bm) {
        cout << n - amv - bmv << endl;
    }
    else if ((amv + bmv2) < (amv2 + bmv)) {
        cout << n - amv2 - bmv << endl;
    }
    else {
        cout << n - amv - bmv2 << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
n,k = map(int,input().split())
s = input()

conti = 0

if n == 1:
    print(0)
else:
    for i in range(n-1):
        if s[i] == s[i+1]:
            conti += 1
        
    count = min(n-1, conti+2*k)
    print(count)

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


int main(){
    int h,w; cin >> h >> w;
    vector<string> s(h); rep(i,h) cin >> s[i];
    bool visited[h][w]; rep(i,h) rep(j,w) visited[i][j] = false;
    queue<tuple<int,int,int>> q;
    rep(i,h) rep(j,w){
        if(s[i][j] == '#'){
            q.emplace(i,j,0);
            visited[i][j] = true;
        }
    }
    int dx[] = {0, 1, 0, -1}, dy[] = {-1, 0, 1, 0};
    int ans;
    while(!q.empty()){
        tuple<int,int,int> now = q.front();
        visited[get<0>(now)][get<1>(now)] = true;
        ans = get<2>(now);
        q.pop();
        rep(i,4){
            int ny = get<0>(now) + dy[i], nx = get<1>(now) + dx[i];
            if(nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
            if(visited[ny][nx]) continue;
            q.emplace(ny,nx,ans+1);
            visited[ny][nx] = true;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 14352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s[2] == s[3] and s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc120_d
{
  class Program
  {
    static void Main(string[] args)
    {
      var n = ConsoleInput.ReadAsInt();
      var m = ConsoleInput.ReadAsInt();
      var a = new int[m];
      var b = new int[m];

      for (var i = 0; i < m; i++)
      {
        a[i] = ConsoleInput.ReadAsInt() - 1;
        b[i] = ConsoleInput.ReadAsInt() - 1;
      }

      var uf = new UnionFind(n);

      var ans = Enumerable.Repeat((long)n * (n - 1) / 2, m).ToArray();

      for (var i = m - 1; i >= 1; i--)
      {
        if (uf.Root(a[i]) != uf.Root(b[i]))
        {
          ans[i - 1] = ans[i] - (long)uf.Size(a[i]) * uf.Size(b[i]);
          uf.Unite(a[i], b[i]);
        }
        else
        {
          ans[i - 1] = ans[i];
        }
      }

      for (var i = 0; i < m; i++)
      {
        Console.WriteLine(ans[i]);
      }
    }
  }

  class UnionFind
  {
    private readonly int[] parent;

    public UnionFind(int n)
    {
      this.parent = Enumerable.Repeat(-1, n).ToArray();
    }

    public int Root(int a)
    {
      if (this.parent[a] < 0)
      {
        return a;
      }
      else
      {
        return this.parent[a] = this.Root(parent[a]);
      }
    }

    public int Size(int a)
    {
      return -parent[this.Root(a)];
    }

    public bool Unite(int a, int b)
    {
      a = this.Root(a);
      b = this.Root(b);

      if (a == b)
      {
        return false;
      }
      else
      {
        if (this.Size(a) < this.Size(b))
        {
          var tmp = a;
          a = b;
          b = tmp;
        }

        this.parent[a] += this.parent[b];
        parent[b] = a;

        return true;
      }
    }
  }

  class ConsoleInput
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadAsInt() => int.Parse(Read());
    public static long ReadAsLong() => long.Parse(Read());
    public static double ReadAsDouble() => double.Parse(Read());

    public static string[] ReadAsStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadAsIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadAsInt();
      }

      return array;
    }

    public static long[] ReadAsLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadAsLong();
      }

      return array;
    }
    public static double[] ReadAsDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadAsDouble();
      }

      return array;
    }
  }
}

Measured memory_bytes: 22984
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using ull=unsigned long long int;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
 while(1){
   ll n,m;
   cin>>n>>m;
   if(n==0)return 0;
   V<bool> infect(n,false);
   infect[0]=true;
   V<pair<int,P>> dat(m);
   for(int i=0;i<m;i++){
     ll t,s,d;
     cin>>t>>s>>d;
     s--;d--;
     dat[i]={t,P(s,d)};
   }
   sort(all(dat));
   for(int i=0;i<m;i++){
     infect[dat[i].se.se]=infect[dat[i].se.fi]|infect[dat[i].se.se];
   }
   int ans=0;
   for(int i=0;i<n;i++)if(infect[i])ans++;
   cout<<ans<<"\n";
 }
}


Measured memory_bytes: 3856
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	n <- readLn
	print $ length $
		filter ( ( == 3 ) . length . group . sort ) $
		filter ( ( <= n ) . ( read :: String -> Integer ) ) $
		tail $ concat $ take 11 $ iterate f [ "" ]

f ss = do
	s <- ss
	c <- "753"
	return $ reverse $ c : reverse s

Measured memory_bytes: 11388
require 'prime'
p = Prime.each(1299709).to_a

def bs(n,a)
    mid = a[(a.size)/2]
    if n == mid
        return 0
    elsif a[a.size/2 - 1] < n && n < mid
        return mid - a[a.size/2 - 1]
    elsif n < mid
        bs(n,a[0...(a.size/2)])
    else
        bs(n,a[(a.size/2)...a.size])
    end
end

loop do
    k = gets.to_i
    break if k == 0
    puts bs(k,p)
end

Measured memory_bytes: 7476
import numpy as np
n,s=map(int, input().split( ))
*a,=map(int, input().split( ))
l=min(s+1,3001)
dp=np.zeros(l,dtype = int)
dp[0]=1
mod=998244353
ans=0
cnt=0
for ai in a:
    #dp2=dp.copy()
    dp2=dp[:-ai].copy()
    dp*=2
    dp[ai:]+=dp2#[:-ai]
    #ans+=dp[s]*pow(2,n-cnt,mod)
    #dp=dp2
    #ans%=mod
    dp%=mod
print(dp[s])

Measured memory_bytes: 27524
#include <iostream>
#include <cstdio>
#define int long long
using namespace std;
const int N = 405;
const int mod = 998244353;
int n, a[N], b[N], f[N][N][N], Sa, Sb, fac[N], inv[N], A[N][N];
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
int ksm(int x, int y)
{
	int res = 1;
	for(; y; y >>= 1, x = x * x % mod)
		if(y & 1) res = res * x % mod;
	return res;
}
signed main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read();
	for(int i = 1; i <= n; i ++) a[i] = read(), b[i] = read(), Sa += a[i], Sb += b[i];
	f[0][0][0] = -1; fac[0] = 1;
	for(int i = 1; i <= Sb; i ++) fac[i] = fac[i - 1] * i % mod;
	inv[Sb] = ksm(fac[Sb], mod - 2);
	for(int i = Sb - 1; i >= 0; i --) inv[i] = inv[i + 1] * (i + 1) % mod;
	for(int i = 1; i <= n; i ++) for(int j = 0; j <= Sb; j ++) A[i][j] = ((j == 0) ? 1 : (A[i][j - 1] * a[i] % mod));
	for(int i = 1; i <= n; i ++)
		for(int j = 0; j <= Sa; j ++)
			for(int k = 0; k <= Sb; k ++)
			{
				f[i][j][k] = f[i - 1][j][k];
				for(int l = 0; l < b[i]; l ++) if(j >= a[i] && k >= l) f[i][j][k] = (f[i][j][k] - f[i - 1][j - a[i]][k - l] * A[i][l] % mod * inv[l] % mod + mod) % mod;
			}
	int ans = 0;
	for(int i = 0; i <= Sa; i ++) for(int j = 0; j <= Sb; j ++) ans = (ans + f[n][i][j] * Sa % mod * fac[j] % mod * ksm(ksm(i, mod - 2), j + 1) % mod) % mod;
	printf("%lld\n", ans);
	fclose(stdin);
	fclose(stdout);
	return 0;
}


Measured memory_bytes: 515584
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
# def LIST(): return list(map(str, input().split()))
# def LIST(): return list(input())

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
h = LIST()
dp = [INF] * (N+1)
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2, N):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))

print(dp[N-1])























# N = INT()
# h = LIST()
# dp = [INF] * N
# dp[0] = 0
# dp[1] = abs(h[1] - h[0])
# # for i in range(2, N):
# #     a = abs(dp[i-2] + abs(h[i] - h[i-2]))
# #     b = abs(dp[i-1] + abs(h[i] - h[i-1]))
# #     dp[i] = min(a, b)
# # print(dp[-1])

# for i in range(2, N):
#     a = dp[i-2] + abs(h[i] - h[i-2])
#     b = dp[i-1] + abs(h[i] - h[i-1])
#     dp[i] = min(a, b)
# print(dp[-1])



Measured memory_bytes: 16276
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
  ll n, k; cin >> n >> k;
  vector<ll> num(100001,0);
  for(int i = 0; i < n; i++){
    ll a, b; cin >> a >> b;
    num[a] += b;
  }
  for(int i = 1; i < 100001; i++){
    k -= num[i];
    if(k <= 0){
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 4028
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>

#include <numeric>

#include <map>

#include <deque>

#include <cassert>

#include <memory>

using namespace std;

typedef long long LL;

int na, nb, m;
int a[123456], b[123456], c[123456], x[123456], y[123456];

int mina = 0x3f3f3f3f, minb  = 0x3f3f3f3f;

int main() {
    cin >> na >> nb >> m;
    for (int i = 1; i <= na; ++i) {
        scanf("%d", &a[i]);
        mina = min(mina, a[i]);
    }
    for (int i = 1; i <= nb; ++i) {
        scanf("%d", &b[i]);
        minb = min(minb, b[i]);
    }

    int ans = mina + minb;
    for (int i = 1; i <= m; ++i) {
        int xx, yy, cc;
        scanf("%d%d%d", &xx, &yy, &cc);
        ans = min(ans, a[xx]+b[yy]-cc);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().split()))

A = np.array(A, dtype=int)
ans = (A - 1).sum()

print(ans)


Measured memory_bytes: 13384
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;
#define ll long long int
int main()
{
    ll n,a,b;
    cin>>n>>a>>b;
    if(n%(a+b)<=a)cout<<(n/(a+b))*a+n%(a+b);
    else cout<<(n/(a+b))*a+a;
    
    
    
    
    
    
    
    
}


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

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

    if (b > d)
        cout << "1";
    else
        cout << "0";
    cout << endl;

    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define LoopMAX 20

int main() {
  int N;
  cin >> N;
  
  vector<int> Hi;
   
  rep(i,N){
    int tmpHi = 0;
    cin >> tmpHi;
    Hi.push_back(tmpHi);
  }
  
  int ans = 0;
  
  rep(i,N){
    int tmp_ans = 0;
    int tmp_ans_max = N - i;
    
    for(int j = i;j < N - 1;j++){
      if(ans >= tmp_ans_max) break;
      if(Hi.at(j) >= Hi.at(j + 1)){
        tmp_ans++;
      }else{
        break;
      } 
    }
    ans = max(ans,tmp_ans);
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k;
    int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin >> k;
    cout << a[k-1];
    return 0;
}

Measured memory_bytes: 256
/*
As you do not know the path of the wind,
or how the body is formed in a mother's womb,
so you cannot understand the work of God,
the Maker of all things.
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;

#define SZ(x) ((int)x.size())

const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
int n, m, k, d[805][805], a[805][805];
char s[805];
ii start;

int min4(int u, int v, int p, int q) { return min(min(u, v), min(p, q)); }
bool valid(int x, int y) { return x >= 1 && x <= n && y >= 1 && y <= m; }

int main() {
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 1; i <= n; ++i) {
		scanf("%s", s + 1);
		for (int j = 1; j <= m; ++j) {
			a[i][j] = s[j] == '#';
			if (s[j] == 'S') start = ii(i, j);
		}
	}
	memset(d, -1, sizeof(d));
	int res = (int)1e9+7;
	queue<ii> q;
	q.push(ii(start.first, start.second)), d[start.first][start.second] = 0;
	while (SZ(q)) {
		int u = q.front().first, v = q.front().second;
		q.pop();
		int tmp = min4(u - 1, v - 1, n - u, m - v);
		res = min(res, tmp / k + (tmp % k != 0) + 1);
		if (d[u][v] == k) continue;
		for (int i = 0; i < 4; ++i) {
			int x = u + dx[i], y = v + dy[i];
			if (!valid(x, y) || d[x][y] != -1 || a[x][y]) continue;
			d[x][y] = d[u][v] + 1;
			q.push(ii(x, y));
		}
	}
	printf("%d", res);
	return 0;
}


Measured memory_bytes: 5376
/*  -*- coding: utf-8 -*-
 *
 * 1626.cc: Skyscraper MinatoHarukas
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

/*
  b = a*n+n(n-1)/2
  a>=1 -> b > n(n-1)/2 -> 2b > n(n-1)
 */

int main() {
  for (int b; scanf("%d", &b) == 1 && b > 0;) {
    int b2 = b * 2;

    int n = 1;
    while (n * (n + 1) < b2) n++;
    //printf("maxn=%d\n", n);

    for (; n > 1; n--) {
      int m = b - n * (n - 1) / 2;
      if (m % n == 0) break;
    }
    //printf("n=%d\n", n);

    int a = (b - n * (n - 1) / 2) / n;
    printf("%d %d\n", a, n);
  }
  return 0;
}



Measured memory_bytes: 3132
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

int main() {
   int N, tmp;
   cin >> N;
   map<int, int> log;
   for (int i = 0; i < N; i++) {
      cin >> tmp;
      log[tmp]++;
   }
   int ans = 0;
   for (map<int, int>::iterator it = log.begin(); it != log.end(); ++it) {
      int num = it->first;
      int cnt = it->second;
      if (num <= cnt) ans += cnt - num;
      else ans += cnt;
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using ll = long long;
using namespace std;

const ll linf = 1e18;

int main()
{
    int a, b, q; cin >> a >> b >> q;
    vector<ll> s(a+2); s[0] = -linf; s[a+1] = linf;
    for (int i = 1; i <= a; i++) cin >> s[i];
    vector<ll> t(b+2); t[0] = -linf; t[b+1] = linf;
    for (int i = 1; i <= b; i++) cin >> t[i];
    
    for (int i = 0; i < q; i++) {
        ll x; cin >> x;
        auto its = lower_bound(s.begin(), s.end(), x);
        auto itt = lower_bound(t.begin(), t.end(), x);

        ll s1 = *its - x;
        ll s2 = *(its - 1) - x;
        ll t1 = *itt - x;
        ll t2 = *(itt - 1) - x;

        ll dist1 = min(abs(s1), abs(t1)) + abs(t1 - s1);
        ll dist2 = min(abs(s1), abs(t2)) + abs(t2 - s1);
        ll dist3 = min(abs(s2), abs(t1)) + abs(t1 - s2);
        ll dist4 = min(abs(s2), abs(t2)) + abs(t2 - s2);

        cout << min({dist1, dist2, dist3, dist4}) << endl;
    }
    return 0;
}

Measured memory_bytes: 2944
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;

int main(){
	int n = 0;
	for(int i = 1; i <= 3; i++){
		int a;
		scanf("%d", &a);
		n = n * 10 + a;
	}
	if(n % 4 == 0) printf("YES\n");
	else printf("NO\n");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
const int MX = 1000 + 10, MD = 1e9 + 7;
long long n, m, a[MX], ans, tmp, x;
bool mark[MX];
int main(){
    ios::sync_with_stdio(0) ; cin.tie(0) ;
    cin >> n >> m >> x;
    for(int i = 0; i < m; i++){
        cin >> a[i];
        mark[a[i]] = 1;
    }
    for(int i = 1; i < x; i++){
        if(mark[i] == 1){
            tmp++;
        }
    }
    for(int i = x + 1; i <= n; i++){
        if(mark[i] == 1){
            ans++;
        }
    }
    ans = min(ans,tmp);
    cout << ans;


}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
	string s;
	cin>>s;
	bool ok=false;
	for(int i=0;i<s.size()-1;i++){
		if(s[i]=='A'&&s[i+1]=='C')ok=true;
	}
	if(ok)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long int;
 
#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define MOD 1000000007 //10^9+7
//#define MOD 1
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
const int MAX = 1000;
 
ll table[MAX][MAX];
 
// テーブルを作る前処理
void COMinit() {
    table[0][0] = table[0][1] = 1;
    FOR(i, 1, MAX-1){
      FOR(j, 0, i+1){
        if(j==0) table[i][j] = 1;
        else if(j == i+1) table[i][j] = 1;
        else table[i][j] = table[i-1][j-1]+table[i-1][j];
      }
    }
}
 
// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return table[n-1][k];
}

void sosuu(ll n, vector<ll> &v){

  vector<ll> num(n, 0);

  FOR(i, 1, sqrt(n)){
    if(num[i]==0){
      FOR(j, 0, n/i){
        num[i+(j*i)] = 1;
      }
    }
  }
  REP(i, n){
    if(num[i]==0) v.push_back(i+1);
  }
}

ll SORT(int n, vector<pair<ll, ll>> &v, int start){
  sort(v.begin()+start, v.end());
  return v[n-1].first;
}

int ans = 0;

int main(void){
  string s;
  cin>>s;

  for(int i=0;i<s.size()-1;i++){
    if(s[i]=='A' && s[i+1]=='C'){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
  

}

Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools, os
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)
def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('- {} -> {}'.format(name, val), file=sys.stderr)
            return None
"""
書き換えたあとの最大公約数の最大値を求める
書き換える値の最適解は、最小値を最大値に書き換えること
例えば、1,6,3があるとき、1を3に書き換えることで最大公約数が3になる
しかし、7 6 8の場合、最小の6ではなく7を書き換えることが最適となる
結局全部の数について書き換えたときの最大値を求めるしか無いか
そうするとO(N**2)になってしまう
全体の最大公約数はgcd(gcd(gcd(1,2), 3),4)
1つ書き換えるは、消すと同義
逆でやる？
全部のgcdを求めて、そこから途中結果を保存しておく
7 6 8 なら
None 1 1と
None 2 1
Noneと2なので2

"""
def main(N, A):
    tmp = A[0]
    tmp_list = [A[-1], A[0]]

    for i in range(N-1):
        tmp = fractions.gcd(tmp, A[i+1])
        tmp_list.append(tmp)

    tmp = A[-1]
    reversed_tmp_list = [A[0], A[-1]]
    for i in range(N-1):
        tmp = fractions.gcd(tmp, A[-(i+2)])
        reversed_tmp_list.append(tmp)

    debug(tmp_list, locals())
    debug(reversed_tmp_list, locals())

    answers = []
    for i in range(N):
        #  if i == 0:
        #      answers.append(reversed_tmp_list[-(i+2)])
        #      continue
        #  if i == N - 2:
        #      answers.append(tmp_list[i])
            #  continue
        tmp = fractions.gcd(tmp_list[i], reversed_tmp_list[-(i+2)])
        answers.append(tmp)
    debug(answers, locals())
    return max(answers)


if __name__ == "__main__":
    if 'LOCAL' in os.environ:
        values = [
                [
                    4,
                    [2, 4, 6, 8],
                    2
                    ],
                [
                    2,
                    [100000, 100000],
                    100000
                    ],
                [
                    3,
                    [12, 6, 12],
                    12
                    ],
                [2, [1, 1000000], 1000000],
                [2, [1, 1], 1],

                [8, list(map(int, '746130 1385670 4849845 881790 3233230 1939938 570570 510510'.split())), 19]
                ]
        for i in values:
            print('A', i[1])
            res = main(i[0], i[1])
            print('res: {res}, exp: {exp}'.format(res=res, exp=i[2]))
            assert res == i[2]
    else:
        N = _I()
        A = LI()
        print(main(N, A))


Measured memory_bytes: 124648
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(a, n) rep(hoge, n) printf("%d%c", a[hoge], hoge == n - 1? '\n' : ' ');
#define all(a) (a).begin(), (a).end()
#define ln(a) cout << (a) << endl

using namespace std;
using P = pair<int, int>;
using ll = long long;

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

signed main() {
    int n;
    cin >> n;
    int* a = new int[n];
    rep(i, n) cin >> a[i];
    int ans = 0;
    rep(i, n) {
        if(a[i] == ans + 1) ans++;
    }
    if(ans) ln(n - ans);
    else ln(-1);
}


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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 200007 , __ = _<<1;

int to[__],ne[__],he[_]={0},ecnt=1;
inline void adde(int a,int b){to[++ecnt]=b,ne[ecnt]=he[a],he[a]=ecnt;}
inline void addde(int a,int b){adde(a,b),adde(b,a);}

int n,fa[_]={0},dep[_]={0},mxdep;

void dfs(int x,int ff)
{
	fa[x]=ff,dep[x]=dep[ff]+1;
	if(dep[x]>dep[mxdep])mxdep=x;
	for(int i=he[x];i;i=ne[i])if(to[i]!=ff)dfs(to[i],x);
}

int main()
{
	n=ty();
	for(int i=1,a,b;i<n;i++)a=ty(),b=ty(),addde(a,b);
	
	mxdep=1,dfs(1,0),dfs(mxdep,0);
	puts(dep[mxdep]%3==2?"Second":"First");

	return 0;
}


Measured memory_bytes: 12032
#include <iostream>
using namespace std;
int n,m;
long long dp[100009];
int a;
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++)dp[i]=-1;
    dp[0]=1;
    for(int i=0;i<m;i++){
        cin>>a;
        dp[a]=0;
    }
    if(dp[1]!=0)dp[1]=1;
    for(int i=2;i<=n;i++){
        if(dp[i]==0)continue;
        dp[i]=(dp[i-1]+dp[i-2])%1000000007;
    }
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 1024
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#include <math.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
using namespace std;



int main() {
    double L, ans;
    cin >> L;
    ans = pow(L / 3, 3);

    cout << setprecision(10) << ans << endl;
    
   
    return 0;
}


Measured memory_bytes: 384
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Sun Apr  8 19:35:01 2018
//
package main

import (
	"fmt"
)

var Q, H, S, D int
var N int

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	fmt.Scan(&Q, &H, &S, &D)
	fmt.Scan(&N)

	num := N / 2
	cost := num * min(8*Q, min(4*H, min(2*S, D)))
	num = N % 2
	cost += num * min(4*Q, min(2*H, S))

	fmt.Println(cost)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int x_max=0, x_min=1, y_max=2, y_min=3; // type
// 時刻t(double)以降[type]=at+bになるというクエリ
struct affine{int a, b;};
struct query{double t; int type; affine func;};
bool cmp(const query &a, const query &b){
    return a.t < b.t;
}

int N;
#define MAX_N 100001
char d[MAX_N];

vector<query> vec;
// 最小値なら入力と出力を-1倍すればいい
void search(int type, vector<int> x, char inc, char dec){
    int mm = (type+1) % 2;
    if(mm == 0) mm--;
    int high=INT_MIN, low=INT_MIN, mid=INT_MIN; // t=0 の座標
    for (int i = 0; i < N; ++i) {
        if(d[i] == inc){
            low = max(low, x[i]*mm);
        } else if(d[i] == dec){
            high = max(high, x[i]*mm);
        } else{
            mid = max(mid, x[i]*mm);
        }
    }

    if(high == INT_MIN && mid == INT_MIN){
        vec.push_back({INT_MIN, type, {mm, low*mm}});
        return;
    }
    if(high == INT_MIN && low == INT_MIN){
        vec.push_back({INT_MIN, type, {0, mid*mm}});
        return;
    }
    if(mid == INT_MIN && low == INT_MIN) {
        vec.push_back({INT_MIN, type, {-mm, high*mm}});
        return;
    }

    // 以下 INT_MIN は1個以下
    double t1 = high;
    t1 -= mid;
    double t2 = mid; 
    t2 -= low;
    if(high == INT_MIN){
        vec.push_back({INT_MIN, type, {0, mid*mm}});
        vec.push_back({t2, type, {mm, low*mm}});
        return;
    }
    vec.push_back({INT_MIN, type, {-mm, high*mm}});
    if (low == INT_MIN) {
        vec.push_back({t1, type, {0, mid*mm}});
    } else if (t1 < t2 && mid != INT_MIN) {
        vec.push_back({t1, type, {0, mid*mm}});
        vec.push_back({t2, type, {mm, low*mm}});
    } else {
        vec.push_back({(t1+t2)/2, type, {mm, low*mm}});
    }
}

int main() {
    cin >> N;
    vector<int>x(N);
    vector<int>y(N);
    for (int i = 0; i < N; ++i) {
      cin >> x[i] >> y[i] >> d[i];
    }

    search(x_max, x, 'R', 'L');
    search(x_min, x, 'L', 'R');
    search(y_max, y, 'U', 'D');
    search(y_min, y, 'D', 'U');

    sort(vec.begin(), vec.end(), cmp);
    double ans;
    affine x_max_af, x_min_af, y_max_af, y_min_af;
    int flag = 0;
    for (int i = 0; i < vec.size(); ++i) {
        double t = vec[i].t;
        if(t >= 0 && flag == 0){ // t=0のとき
            flag = 1;
            ans = (x_max_af.b - x_min_af.b);
            ans *= (y_max_af.b - y_min_af.b);
        }
        if(vec[i].type == x_max) x_max_af = vec[i].func;
        if(vec[i].type == x_min) x_min_af = vec[i].func;
        if(vec[i].type == y_max) y_max_af = vec[i].func;
        if(vec[i].type == y_min) y_min_af = vec[i].func;
        if(t >= 0){
            double x_t = t * (x_max_af.a - x_min_af.a) + (x_max_af.b - x_min_af.b);
            double y_t = t * (y_max_af.a - y_min_af.a) + (y_max_af.b - y_min_af.b);
            ans = min(ans, x_t * y_t);
        }
    }
    if(vec.back().t < 0){
        ans = (x_max_af.b - x_min_af.b);
        ans *= (y_max_af.b - y_min_af.b);
    }

    cout << setprecision(20) << ans;
    return 0;
}

Measured memory_bytes: 1536
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main()
{
	double n,x;
	int t;
	cin>>n>>x>>t;
	int num = ceil((double)(n/x));
	//cout<<num<<endl;
	cout<<num*t<<endl;
	return 0;
}



Measured memory_bytes: 3256
N, K=map(int, input().split())
import math
ans=0
for i in range(N):
    if i+1>=K:
        ans+=1/N
    else:
        req=math.ceil(K/(i+1))
        dice=math.ceil(math.log2(req))
        ans+=(0.5**dice)*(1/N)
print(ans)

Measured memory_bytes: 3060
import java.lang.Math

fun isPrime(n: Int) : Boolean {
  val max = Math.sqrt(n.toDouble()).toInt() + 1
  for (x in 2 until max) {
    if (n % x == 0) {
      return false
    }
  }
  return true
}

fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  var a = mutableListOf<Int>()
  for (x in 0 until n) {
    a.add(readLine()!!.toInt())
  }

  var cnt = 0
  for (i in a) {
    if (isPrime(i)) {
      cnt += 1
    }
  }
  println(cnt)
}


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


int main(){

  vector<long> c1, c2;
  long cm1 = 0; long cm2 = 0;
  int m1 = 0;
  int m2 = 0;
  int n;
  cin >> n;
  if (n == 3){
    printf("2 5 63\n");
    return 0;
  }
  for (int i = 2; i <= 30000; i++){
    if (i % 2 == 0){
      c1.push_back(i);
      cm1 += i;
      m1++;
      continue;
    } else if (i % 3 == 0) {
      c2.push_back(i);
      cm2 += i;
      m2++;
    }
  }

  int t = m1 + m2 - n;

  int q = min(t / 2, (m2-2)/2);
  for (int i = 0; i < q; i++){
    c2.pop_back();
    c2.pop_back();
    t -= 2;
  }


  q = t / 3;
  for (int i = 0; i < q; i++){
    c1.pop_back();
    c1.pop_back();
    c1.pop_back();
    t -= 3;
  }

  if (t == 1){
    c1.pop_back();
  }
  if (t == 2){
    int u = c1.back();
    c1.pop_back();
    c1.pop_back();
    c1.pop_back();
    c1.push_back(u);
  }


  for (int i = 0; i < c1.size(); i++){
    printf("%ld ", c1[i]);
  }
  for (int i = 0; i < c2.size()-1; i++){
    printf("%ld ", c2[i]);
  }
  printf("%ld\n", c2.back());


  return 0;
}

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    
    cin >> N;
    if (N < 10)
    {
        cout << N << endl;
    }
    else if (N < 100)
    {
        cout << 9 << endl;
    }
    else if (N >= 100 && N < 1000)
    {
        cout << 9 + (N-100+1) << endl;
    }
    else if (N >= 1000 && N < 10000)
    {
        cout << 9 + 900 << endl;
    }
    else if (N >= 10000 && N < 100000)
    {
        cout << 9 + + 900 + (N-10000+1) << endl;
    }
    else if (N == 100000)
    {
        cout << 9 + + 900 + 90000 << endl;
    }
    
    return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()


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

  string S;
  cin>>S;
  S.erase(S.begin()+S.size()-8,S.end());
  cout<<S<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

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(){
	cin.tie(0);
	ios::sync_with_stdio(false);

    int n;
    cin >> n;
    double rsl = 0.0;

    rep(i, 0, n) {
        double x;
        string u;
        cin >> x >> u;
        if(u == "JPY") rsl += x;
        else {
            rsl += x * 380000.0;
        }
    }
    cout << setprecision(10) << rsl << endl;
}


Measured memory_bytes: 256
// Pratiyush Mishra(pratiush7)
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define repab(i,a,b) for(ll i=a;i<=b;i++)
#define ull unsigned long long int
#define ll long long int
#define LL_MAX 9223372036854775807
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define vl vector<ll>
#define bs(v,x) binary_search(v.begin(),v.end(),x)
#define popf pop_front
#define p() cout<<'\n'
#define p0(x) cout<<x<<" "
#define p1(x) cout<<x<<'\n'
#define p2(x,y) cout<<x<<" "<<y<<'\n'
#define p3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define pr1(x) cout<<fixed<<setprecision(15)<<x<<'\n'
#define mod 1000000007
#define mod1 998244353
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define get(n) ll n;cin>>n
#define getvec(v,n) vector<ll> v(n);for(ll i=0;i<n;i++) cin>>v[i];
#define getstr(s) string s;cin>>s
#define all(x) x.begin(),x.end()
#define countBits(x) __builtin_popcount (x)
using namespace std;

int main(){
  fio;
  char c;
  cin>>c;
  c++;
  p1(c);
  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 a = sc.nextInt();
		int b = sc.nextInt();

		boolean ans = true;
		if (a % 2 == 0) {
			ans = false;
		}
		if (b % 2 == 0) {
			ans = false;
		}
		if (ans) {
			System.out.println("Odd");
		} else {
			System.out.println("Even");
		}
	}
}


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

#define CIN1(a) long long a;cin >> a;
#define CIN2(a,b) long long a,b;cin >> a >> b;
#define CIN3(a,b,c) long long a,b,c;cin >> a >> b >> c;
#define rep(i,n) for(int i=0,i##_len=(n); i<i##_len; ++i)

int main(){
    CIN2(n,T)
    vector<int> v;
    rep(i,n){
        CIN2(c,t)
        if(t<=T) v.push_back(c);
    }
    if(!v.size()) cout << "TLE" << endl;
    else cout << *min_element(v.begin(),v.end()) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 100005;

class Edge {
public:
  int nxt, to;
} e[MAX_N << 1];

int head[MAX_N], cnt;
void addedge(int u, int v) {
  e[++cnt] = (Edge){head[u], v}, head[u] = cnt;
  e[++cnt] = (Edge){head[v], u}, head[v] = cnt;
}

int N, fa[MAX_N], sz[MAX_N], dep[MAX_N];

void dfs(int u, int v) {
  dep[u] = dep[v] + 1, fa[u] = v, sz[u] = 1;
  for (int i = head[u]; i; i = e[i].nxt)
    if (e[i].to != v)
      dfs(e[i].to, u), sz[u] += sz[e[i].to];
}

int main() {
  
  scanf("%d", &N);
  for (int i = 1, u, v; i < N; ++i) {
    scanf("%d%d", &u, &v);
    addedge(u, v);
  }

  dfs(1, 0);

  int d = (dep[N] + 1) / 2 + 1, u = N;
  
  while (dep[u] != d) u = fa[u];

  int sz1 = sz[u], sz2 = N - sz1;

  if (sz1 >= sz2) puts("Snuke");
  else puts("Fennec");
  
  return 0;
}


Measured memory_bytes: 7936
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main(){
        string s;
        int i,idxR,idxL,cnt=1;
        cin >> s;
        vector<int> v(s.length());
        for(i=1;i<s.length();++i){
                ++cnt;
                if(s[i-1]=='R'&&s[i]=='L'){
                        idxR = i-1;
                        idxL = i;
                        v.at(i-1) += cnt/2;
                        v.at(i) += cnt - cnt/2;
                        cnt = 0;
                }
                else if(s[i-1]=='L'&&s[i]=='R'){
                        --cnt;
                        v.at(idxL) += cnt/2;
                        v.at(idxR) += cnt - cnt/2;
                        cnt = 1;
                }
        }
        if(cnt>0){
                v.at(idxL) += cnt/2;
                v.at(idxR) += cnt - cnt/2;
        }
        for(i=0;i<v.size();++i) cout << v.at(i) << " ";
        cout << endl;
        return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;
  ll minae = min({a, b, c, d, e});

  ll ans = ceil(((double)n/(double)minae)+4.0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;
#define LL long long
#define mp make_pair
#define fr first
#define sc second
#define pb push_back
#define lc (x<<1)
#define rc ((x<<1)|1)
const int N=2005;
const LL inf=100000000000000ll;
LL a[N],f[N][N],minf1[N],maxf2[N];
int n;
LL wabs(LL x){if (x<0) x=-x;return x;}
/*LL dfs(int x,int y,int t){
    if (f[x][y][t]!=-1) return f[x][y][t];
    LL ans;int i;
    if (!t){
        if (y==n) {f[x][y][t]=wabs(a[x]-a[y]);return f[x][y][t];}
        ans=0;
        for (i=y+1;i<=n;i++) ans=max(ans,dfs(i,y,t^1));
        f[x][y][t]=ans;
    } else{
        if (x==n) {f[x][y][t]=wabs(a[x]-a[y]);return f[x][y][t];}
        ans=inf;
        for (i=x+1;i<=n;i++) ans=min(ans,dfs(x,i,t^1));
        f[x][y][t]=ans;
    }
    return f[x][y][t];
}*/
int main(){
  //  freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    int i,j;
    scanf("%d%lld%lld",&n,&a[1],&a[2]);n+=2;
    for (i=3;i<=n;i++) scanf("%lld",&a[i]);
  //  for (i=1;i<=n;i++) for (j=1;j<=n;j++) f[i][j][0]=f[i][j][1]=-1;
  //  for (i=1;i<=n;i++) cout<<a[i]<<" ";
  //  puts("");
    for (i=1;i<=n;i++) minf1[i]=maxf2[i]=wabs(a[i]-a[n]);
    for (i=n;i>=1;i--) for (j=n;j>=1;j--){
        if (i==j) continue;
        if (i<j){
            if (j==n) f[i][j]=wabs(a[i]-a[j]);
             else f[i][j]=maxf2[j];
            minf1[i]=min(minf1[i],f[i][j]);
        } else{
            if (i==n) f[i][j]=wabs(a[i]-a[j]);
             else f[i][j]=minf1[i];
            maxf2[j]=max(maxf2[j],f[i][j]);
        }
    }

    cout<<f[1][2]<<endl;

    return 0;
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
using PL = pair<ll , ll> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
#define mod 1000000007
vector<int> mx = {0, 1, 0, -1} ;
vector<int> my = {1, 0, -1, 0} ;

int main(){
    int h, w;
    cin >> h >> w ;
    vector<string> g (h);
    vector<vector<int>> list (h, vector<int> (w, -1)) ;
    rep(i, h) cin >> g[i] ;
    int bk = 0 ;
    rep(i, h){
        rep(j ,w){
            if(g[i][j] == '#'){
                bk++ ;
            }
        }
    }
    queue<P> que ;
    que.push(P(0, 0)) ;
    list[0][0] = 0 ;
    while(!que.empty()){
        P p = que.front() ;
        que.pop() ;
        int x = p.first ;
        int y = p.second ;
        int cost = list[x][y] ;
        if(x == h - 1 && y == w - 1) break ;
        rep(v, 4){
            int nx = x + mx[v] ;
            int ny = y + my[v] ;
            if(nx < 0 || ny < 0 || nx >= h || ny >= w) continue ;
            if(list[nx][ny] >= 0) continue ;
            if(g[nx][ny] == '#') continue ; 
            list[nx][ny] = cost + 1 ;
            que.push(P(nx, ny)) ;
        }
    }  
    if(list[h - 1][w - 1] == -1) {
        cout << -1 << endl ;
        return 0 ;
    }
    int t = list[h - 1][w - 1] - 1;
    cout << h*w - t - bk - 2 << endl ;
} 

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
//sum
using namespace std;

int main() {
    string ans = "";
    string s1;
    int i;
    cin >> s1;
    for (i=0;s1.size()>i;i++) {
        if ((s1[i] == 'B') && (!ans.empty())) {
            ans.pop_back();
        } else if (s1[i] == '0') {
            ans += "0";
        } else if (s1[i] == '1') {
            ans += "1";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <stack>
#include <unordered_map>
#define lld long long int
#define dbg1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define dbg2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define dbg3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	lld n;
	cin >> n;
	if(n&1)
	{
		cout << 0 ;
		return 0;
	}
	lld ans=0;
	lld a = 5;
	while((n/(2*a))>0)
	{
		ans+=(n/(2*a));
		a*=5;
	}
	cout << ans;
}

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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  int a[11]={};
  rep(i,3)
  {
    int tmp=in();
    if(tmp==5) a[5]++;
    if(tmp==7) a[7]++;
  }
  if(a[5]==2&&a[7]==1) print("YES");
  else print("NO");

  return 0;
}

Measured memory_bytes: 256