akhauriyash/Code-Regression huggingface dataset:
import java.awt.Point;
import java.io.IOException;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int M = scanner.nextInt();
			if (M == 0)
				break;
			Point[] xym = new Point[M];
			for (int i = 0; i < M; i++) {
				xym[i] = new Point(scanner.nextInt(), scanner.nextInt());
			}
			int N = scanner.nextInt();
			HashSet<Point> ps = new HashSet<Point>();
			for (int i = 0; i < N; i++) {
				ps.add(new Point(scanner.nextInt(), scanner.nextInt()));
			}
			loop: for (Point p : ps) {
				int dx = p.x - xym[0].x;
				int dy = p.y - xym[0].y;
				for (Point m : xym) {
					int nx = m.x + dx;
					int ny = m.y + dy;
					if (!ps.contains(new Point(nx, ny))) {
						continue loop;
					}
				}
				System.out.println(dx + " " + dy);
				break;
			}
		}
	}
}

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

long long f(long long x) {
        if (x % 4 == 0) return x;
        if (x % 4 == 1) return x ^ (x - 1);
        if (x % 4 == 2) return x ^ 1;
        if (x % 4 == 3) return 0;
        assert(false);
}

int main() {
        long long a, b;
        scanf("%lld%lld", &a, &b);
        printf("%lld\n", f(b) ^ (a == 0 ? 0 : f(a - 1)));
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	int n,k;
  cin >> n >> k;
  vector<char> s(n);
  rep(i,n) cin >> s[i];

  int x = s[k-1] - 'A';
  s[k-1] = 'a' + x;
  rep(i,n) cout << s[i];
  cout << endl;

  return 0;
}


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

int main()
{
    string s;
    while(cin >> s)
    {
        int len = s.size();
        int ioi = 0,joi = 0;
        rep(i,len-2)
        {
            if(s.substr(i,3) == "JOI")joi++;
            if(s.substr(i,3) == "IOI")ioi++;
        }
        cout << joi << endl;
        cout << ioi << endl;
    }
    return 0;
}

Measured memory_bytes: 0
N = int(input())

dic = {}
word = ""

for i in range(N):
    word = input()
    if word in dic:
        dic[word] += 1
    else:
        dic[word] = 1

M = int(input())

for i in range(M):
    word = input()
    if word in dic:
        dic[word] -= 1
    else:
        dic[word] = -1

li = list(dic.values())

s = max(li)

if s > 0:
    print(s)
else:
    print(0)


Measured memory_bytes: 3064
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

######################################################

N=intput()
for h,n in product(range(1,3501),repeat=2):
    if 4*h*n-N*(h+n)==0:
        continue
    w=N*h*n//(4*h*n-N*(h+n))
    if 0<w<=3500 and (4*h*n-N*(h+n))*w==N*h*n:
        print(h,n,w)
        exit()

Measured memory_bytes: 74472
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;
use std::cmp::max;

fn main() {
    input! {
        N: usize,
        K: i64,
        mut Ps: [usize; N],
        Cs: [i64; N],
    }

    // Psの値は1以上なので、0オリジンにする
    for i in 0..N {
        Ps[i] -= 1;
    }

    // ループがある。
    // O(N)で開始点ごとの1周の周期とポイントを調べて、
    // 次に、O(N)で各点スタートのときの点を調べて最大のものを調べる?

    // periods[i] : iを開始点とした時の周期
    let mut periods: Vec<i64> = vec![0i64; N];

    // points[i] : iを開始点とした時の1周期で得られるポイント
    let mut points: Vec<i64> = vec![0i64; N];

    // 周期とポイントを調べる
    for i in 0..N {
        // もう確認済みならばスキップ (後述)
        if periods[i] != 0 {
            continue;
        }


        // whileでうまく回すために、あらかじめ1ムーブしておく
        let mut current = Ps[i];
        let mut period = 1;
        let mut point = Cs[current];

        // マスとマスjが同じループの中にあるならば、periods[i]==points[j]が成り立つ (periodsも同様)
        // よって、通ったマスを記憶しておくことで、ループ回数を減らすことができる
        let mut paths: Vec<usize> = Vec::new();
        paths.push(i);
        paths.push(current);

        while current != i {
            current = Ps[current];
            period += 1;
            point += Cs[current];
        }

        for p in paths.iter() {
            periods[*p] = period;
            points[*p] = point;
        }
    }

    for i in 0..N {
        dbg!(periods[i]);
        dbg!(points[i]);
    }

    let mut ans = std::i64::MIN;
    // 実際に巡ってみよう
    for i in 0..N {
        // まず1回は進むのがルール
        let mut current = Ps[i];
        let mut point: i64 = Cs[current];
        ans = max(ans, point);
        let mut rest = K - 1;

        // まず、周期でざっとやる
        // ただし、損するならやらない
        if points[current] > 0 {
            let cnt: i64 = rest / periods[current];
            point += points[current] * cnt;
            ans = max(ans, point);
            rest -= periods[current] * cnt;
        } else {
            // 1周したら損するので、1周以下を見ればよい
            rest = periods[current];
        }

        // 1歩ずつ進んで、点を更新していく
        // いつでもやめられるので、最高点をマークし続ければOK
        // restは5000で割った余りになっているので、5000 * 5000のオーダーとなる。
        // ギリギリ間に合うかな?
        for _k in 0..rest {
            current = Ps[current];
            point += Cs[current];
            ans = max(ans, point);
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2424
from itertools import permutations

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

perm = permutations(list(range(2, n+1)), n - 1)

ans = 0
for p in perm:
    flag = True
    for i in range(n-1):
        if i == 0:
            if not [1, p[i]] in ab:
                flag = False
                break
        else:
            if not ([p[i-1], p[i]] in ab or [p[i], p[i-1]] in ab):
                flag = False
                break
    if flag: ans += 1
print(ans)



Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int a[] = new int[n];
        int p[] = {0, 0};
        
        for (int i = 0; i < n; i++)
            a[i] = Integer.parseInt(sc.next());
        Arrays.sort(a);
        
        for (int i = n - 1; i >= 0; i--)
            if ((n - 1) % 2 == i % 2)
                p[0] += a[i];
            else
                p[1] += a[i];
        
        System.out.println(p[0] - p[1]);
    }
}

Measured memory_bytes: 23764
n=gets.to_i
A=gets.split.map &:to_i
B=gets.split.map &:to_i
t=0
n.times{|i|
m=[A[i],B[i]].min
t+=m
A[i]-=m
B[i]-=m
m=[A[i+1],B[i]].min
t+=m
A[i+1]-=m
B[i]-=m
}
p t

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

using namespace std;

const int inf = 0x3f3f3f3f;
const int N = 10414;
const int M = 40414;

struct Edge{
	int u, v, d, c;
	int next;
}edge[M];

int cnt, head[N];
int vis[N], dis[N], cost[N];
int op, tp, link[18014];

void add_edge(int u, int v, int d, int c);
void spfa(int n);

int main(){
	int n, m, i, u, v, d, c;
	while(~scanf("%d %d", &n, &m) && (n || m)){
		cnt = 0;
		memset(head, -1, sizeof(head));
		for(i = 0; i < m; i++){
			scanf("%d %d %d %d", &u, &v, &d, &c);
			add_edge(u, v, d, c);
			add_edge(v, u, d, c);
		}
		spfa(n);
	}
	return 0;
}
void add_edge(int u, int v, int d, int c){
	edge[cnt].u = u;
	edge[cnt].v = v;
	edge[cnt].d = d;
	edge[cnt].c = c;
	edge[cnt].next = head[u];
	head[u] = cnt++;
	return;
}
void spfa(int n){
	int i, u, v, d, c, sum;
	memset(vis, 0, sizeof(vis));
	memset(dis, inf, sizeof(dis));
	memset(cost, inf, sizeof(cost));
	op = tp = 0;
	vis[1] = 1, dis[1] = 0, cost[1] = 0;
	link[tp++] = 1;
	while(op < tp){
		u = link[op++];
		vis[u] = 0;
		for(i = head[u]; ~i; i = edge[i].next){
			v = edge[i].v, d = edge[i].d, c = edge[i].c;

			if(dis[v] > dis[u] + d || (dis[v] == dis[u] + d && cost[v] > c)){
				dis[v] = dis[u] + d;
				cost[v] = c;
				if(!vis[v]){
					vis[v] = 1;
					link[tp++] = v;
				}
			}
		}
	}
	sum = 0;
	for(i = 1; i <= n; i++){
		sum += cost[i];
	}
	printf("%d\n", sum);
	return;
}



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

int main(){
	int n,m,a[100],b[100],min[3],asum,bsum,sa;
	while(true){
		cin>>n>>m;
		if(n==0 && m==0){
			break;
		}
		min[0]=1000000000;
		min[1]=-1;
		min[2]=-1;
		asum=0;
		bsum=0;
		for(int i=0;i<n;i++){
			cin>>a[i];
			asum += a[i];
		}
		for(int i=0;i<m;i++){
			cin>>b[i];
			bsum += b[i];
		}
		sa=asum-bsum;
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				if((a[i]-b[j])*2==sa && min[0]>a[i]+b[j]){
					min[0]=a[i]+b[j];
					min[1]=a[i];
					min[2]=b[j];
				}
			}
		}
		if(min[0]>1000000){
			cout<<"-1"<<endl;
		}
		else{
			cout<<min[1]<<' '<<min[2]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
using System;
using System.Linq;
class x{static void Main(){
	for(int a,b;;){
		String[] _=Console.ReadLine().Split();
		a=int.Parse(_[0]);
		b=int.Parse(_[1]);
		if(a==0)break;
		Console.WriteLine(Enumerable.Range(0,a/2+1).Select(i=>Math.Abs(b-Math.Sqrt(i*i+(a-i)*(a-i)))).Min());
	}
}}

Measured memory_bytes: 9432
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int Count = 0;
		for(int i = 0; i<N; i++) {
			if(sc.nextInt() >= K) {
				Count++;
			}
		}
		System.out.println(Count);
	}
}

Measured memory_bytes: 47524
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
typedef struct edge { int f, t, c; } edge;
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
int bellman_ford(int st, int en, int n, vector<edge> &es);
int bellman_ford(int st, int en, int n, vector<edge> &es)
{
    vi d(n, INF);
    d[st] = 0;
    Rep(i, n) {
        bool update = false;
        rep(i, es.size()) {
            edge e = es[i];
            if (d[e.f] != INF && d[e.t] > d[e.f] + e.c) {
                d[e.t] = d[e.f] + e.c;
                update = true;
            }
        }
        if (!update) {
 //   rep(i, n) cout << d[i] << endl;
            return d[en];
        }
    }
//    cout << "ok" << endl;
    int bef = d[en];
    Rep(i, n) {
        bool update = false;
        rep(i, es.size()) {
            edge e = es[i];
            if (d[e.f] != INF && d[e.t] > d[e.f] + e.c) {
                d[e.t] = d[e.f] + e.c;
                update = true;
            }
        }
        if (!update) {
            return d[en];
        }
    }
    if (bef == d[en]) {
        return bef;
    } else {
        return INF;
    }
}


bool find_negative_loop(int n, vector<edge> &es);
bool find_negative_loop(int n, vector<edge> &es)
{
    vi d(n, 0);

    rep(i, n) {
        rep(j, es.size()) {
            edge e = es[j];
            if (d[e.t] > d[e.f] + e.c) {
                d[e.t] = d[e.f] + e.c;
                if (i == n - 1) return true;
            }
        }
    }
    return false;
}
 
 
signed main()
{
    int2(n, m);
    vector<edge> es(m);
 
    rep(i, m) {
        cin >> es[i].f >> es[i].t >> es[i].c;
        es[i].f--;
        es[i].t--;
        es[i].c *= -1;
    }

    int ret = bellman_ford(0, n-1, n, es);
    if (ret == INF) {
        cout << "inf" << endl;
    } else {
        cout << -ret << endl;
    }
 
    return 0;
}



Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

void solve(){
    ll N; cin >> N;
    bool ok = false;
    ll L = -1;
    for(ll a = 1; a <= N+10; a++){
        if(a*(a+1)==2*N){
            ok = true;
            L = a;
            break;
        }
    }
    if(!ok){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
        cout << L+1 << endl;
        vector<vector<ll>> Ans(L+1,vector<ll>(L));
        ll key = 1;
        for(int i = 0; i < L;i++){
            for(int j = 0; j < L;j++){
                if(Ans[i][j]!=0) continue;
                
                for(int k = 0; j+k < L;k++){
                    Ans[i][j+k] = key;
                    Ans[i+k+1][j] = key;
                    key++;
                }
                break;
            }
        }
        
        for(int i = 0; i <= L;i++){
            cout << L << " " << Ans[i] << endl;
        }
    }
    
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve();
    return 0;
}


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

int main(){
    string s;
    int x,y,f0=0;
    cin >> s >> x >> y;
    vector<int> dx(0),dy(0);
    bool isx=1;
    for(int i = 0;i < s.size();i ++){
        int cx=0,cy=0;
        if(!i){
            while(i<s.size()&&s[i]=='F'){
                f0 ++;
                i ++;
            }
        }
        while(i<s.size()&&s[i]=='F'){
            if(isx) cx ++;
            else cy ++;
            i ++;
        }
        if(i<s.size()&&s[i]=='T') isx = !isx;
        if(cx) dx.push_back(cx);
        if(cy) dy.push_back(cy);
    }
    bool dpx[16001][4000],dpy[16001][4000];
    fill(dpx[0],dpx[16001],false);
    fill(dpy[0],dpy[16001],false);
    dpx[8000+f0][0] = true;dpy[8000][0] = true;
    for(int i = 1;i <= dx.size();i ++){
        for(int j = 0;j <= 16000;j ++){
            bool b1 = false,b2 = false;
            if(j-dx[i-1]>=0) b1 = dpx[j-dx[i-1]][i-1];
            if(j+dx[i-1]<=16000) b2 = dpx[j+dx[i-1]][i-1];
            dpx[j][i] = b1|b2;
        }
    }
    for(int i = 1;i <= dy.size();i ++){
        for(int j = 0;j <= 16000;j ++){
            bool b1 = false,b2 = false;
            if(j-dy[i-1]>=0) b1 = dpy[j-dy[i-1]][i-1];
            if(j+dy[i-1]<=16000) b2 = dpy[j+dy[i-1]][i-1];
            dpy[j][i] = b1|b2;
        }
    }
    bool judge;
    if(dx.size()&&dy.size())judge=dpx[8000+x][dx.size()]&dpy[8000+y][dy.size()];
    else if(!dx.size()&&dy.size()) judge = (x==f0)&&dpy[8000+y][dy.size()];
    else if(dx.size()&&!dy.size()) judge = dpx[8000+x][dx.size()]&&!y;
    else judge = (x==f0)&&!y;
    if(judge) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 125312
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
string S, T;
int main() {
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'C' && T.size() == 0)T += 'C';
		if (S[i] == 'F' && T.size() == 1)T += 'F';
	}
	if (T.size() == 2)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int a,b,c,mx;
    cin >> a >> b;
    mx=a+b;
    mx=max(mx,a-b);
    mx=max(mx,a*b);
    cout << mx;
}


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

using namespace std;

#define INF 1e9

int N, A, B, C;
vector<int> L;

int rec(int i, int a, int b, int c) {
    if (i == N) {
        if (!a || !b || !c) return INF;
        return abs(a - A) + abs(b - B) + abs(c - C);
    }

    int res = rec(i+1, a,b,c);

    res = min(res, rec(i+1, a+L[i], b, c) + (a ? 10:0));
    res = min(res, rec(i+1, a, b+L[i], c) + (b ? 10:0));
    res = min(res, rec(i+1, a, b, c+L[i]) + (c ? 10:0));

    return res;
}
    

int main() {
    cin >> N >> A >> B >> C;
    L.resize(N);
    for (int i = 0; i < N; i++) cin >> L[i];

    cout << rec(0,0,0,0) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
main()
{

  double a[100];
  int x=0, y;
  char s1[] = "light fly"; 
  char s2[] = "fly";
  char s3[] = "bantam";
  char s4[] = "feather";
  char s5[] = "light";
  char s6[] = "light welter";
  char s7[] = "welter";
  char s8[] = "light middle";
  char s9[] = "middle";
  char s10[] = "light heavy";
  char s11[] = "heavy";

  while( scanf("%lf", &a[x]) != EOF){
    x++;
  }

  for(y = 0; y < x; y++){

    if(a[y] <= 48)
      puts(s1);

    else if(48 < a[y] && a[y] <= 51)
      puts(s2);

    else if(51 < a[y] && a[y] <= 54)
      puts(s3);
    
    else if(54 < a[y] && a[y] <= 57)
      puts(s4);
    
    else if(57 < a[y] && a[y] <= 60)
      puts(s5);

    else if(60 < a[y] && a[y] <= 64)
      puts(s6);

    else if(64 < a[y] && a[y] <= 69)
      puts(s7);

    else if(69 < a[y] && a[y] <= 75)
      puts(s8);

    else if(75 < a[y] && a[y] <= 81)
      puts(s9);

    else if(81 < a[y] && a[y] <= 91)
      puts(s10);

    else
      puts(s11);

  }

  return 0;
}

Measured memory_bytes: 0
S=str(input())
a = S[0:1]
b = S[1:2]
c = S[2:3]
d = S[3:4]
if a==b and b==c and c==d and a==d:
    print('No')
elif a==b:
    if c==d:
        print('Yes')
    else:
        print('No')
elif a==c:
    if b==d:
        print('Yes')
    else:
        print('No')    
elif a==d:
    if b==c:
        print('Yes')
    else:
        print('No')
else:
    print('No')
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
string s[3];
int n[3];
int ok[3][3][8080];
int okpos[3][3];
bool check(int i,int j,int p)
{
	if(ok[i][j][p]!=-1)return ok[i][j][p];
	for(int q=0;q<n[j];q++)
	{
		if(p+q>=n[i])break;
		if(s[i][p+q]!='?'&&s[j][q]!='?'&&s[i][p+q]!=s[j][q])return ok[i][j][p]=0;
	}
	return ok[i][j][p]=1;
}
int main()
{
	memset(ok,-1,sizeof(ok));
	for(int i=0;i<3;i++)
	{
		cin>>s[i];
		n[i]=s[i].length();
	}
	int ans=n[0]+n[1]+n[2];
	for(int fst=0;fst<3;fst++)
	{
		for(int snd=0;snd<3;snd++)
		{
			if(fst==snd)continue;
			
			for(int mchpos=0;mchpos<=n[fst];mchpos++)
			{
				if(!check(fst,snd,mchpos))continue;
				//fst [0,n[fst])
				//snd [mchpos,mchpos+n[snd])
				int trd=0;
				while(trd==fst||trd==snd)trd++;
				for(int mchpos2=mchpos;mchpos2<=max(n[fst],mchpos+n[snd]);mchpos2++)
				{
					if(check(fst,trd,mchpos2)&&check(snd,trd,mchpos2-mchpos))
					{
						ans=min(ans,max(max(n[fst],mchpos+n[snd]),mchpos2+n[trd]));
					}
				}
			}
			
			
		}
	}
	cout<<ans;
	return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  pair<int,int> p[100007];
  rep(i,n) cin >> p[i].first >> p[i].second;

  sort(p,p+n);

  priority_queue<int> q;

  int index =0;

  int ans =0;

  for(int j=m-1;j>=0;j--){
     while(index<n && p[index].first+j<=m) {
         q.push(p[index].second);
         index++;
     }
     if(!q.empty()){
         ans += q.top();
         q.pop();
     }

  }
  cout << ans << endl;


  
}

Measured memory_bytes: 1660
#include <stdio.h>
int main(void)
{
	int x, y;

	while (1) {
		scanf("%d", &x);
		scanf("%d", &y);

		if (x == 0 && y == 0) break;

		if (x < y)
			printf("%d %d\n", x, y);
		else
			printf("%d %d\n", y, x);
	}

	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int n=5;
    int a[n];
    for(int i=0; i<n; i++) {
        cin>>a[i];
        if(a[i]==0) cout<<i+1<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt();
	    
	    int count = 1;
	    int max = sc.nextInt();
	    
	    for (int i=1; i<N; i++){
	    	int temp = sc.nextInt();
	    	
	    	if (temp>=max){
	    		count++;
	    		max=temp;
	    	}
	    }
	    System.out.println(count);
		sc.close();
	}

}

Measured memory_bytes: 23124
n = input()
N = int(n)
P = []
counter = 0
input_string = input()
P = input_string.split()

for i in range(int(N)):
    for j in range(N):
        if N == int(P[i]):
            counter = counter + 1
            if N != 1:
                N = N - 1
                break
            else: 
                break
        elif N < int(P[i]):
            break
        else:
            if N != 1:
                N = N - 1   

print(counter)

Measured memory_bytes: 20848
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  string s;
  cin >> s;
  int n = s.size();
  if(s[n-1]!='s')s+='s';
  else s+="es";
  cout << s << endl;
}

Measured memory_bytes: 3608
n=int(input())
A=[int(input()) for i in range(n)]

l=0
cnt=0

for i in range(n):
  if A[i]==0:
    cnt+=(sum(A[l:i]))//2
    l=i+1
  elif i==n-1:
    cnt+=(sum(A[l:n+1]))//2
print(cnt)

Measured memory_bytes: 7840
import sys

input = sys.stdin.readline


def main():
    count = [0, 0, 0, 0]
    for _ in range(3):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        count[a] += 1
        count[b] += 1

    if count.count(1) == 2 and count.count(2) == 2:
        ans = "YES"
    else:
        ans = "NO"

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9088
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int count = 0;
    int number;

    for (int i=0; i < N; i++) {
      number = sc.nextInt();

      while (number%2 == 0) {
        count++;
        number = number / 2;
      }
    }

    System.out.println(count);
  }
}


Measured memory_bytes: 34168
#include<stdio.h>

int main(){
  int h, w;
  int i, j;
  
  while(1){
    scanf("%d %d", &h, &w);
    if(h == 0 && w == 0) break;

    for(i = 0; i < h; i++){
      for(j = 0; j < w; j++){
	if((i + j) % 2 == 0){
	  printf("#");
	}
	else {
	  printf(".");
	}
      }
      printf("\n");
    }
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2052
from bisect import bisect_left, bisect_right
n = int(input())
l = list(map(int, input().split()))
l.sort()
# print(l)

ans = 0
for i in range(n):
    for j in range(i+1, n):
        idx1 = bisect_right(l, abs(l[i] - l[j]))
        idx2 = bisect_left(l, l[i] + l[j])
        ansi = idx2 - idx1
        if abs(l[i] - l[j]) < l[i]:
            ansi -= 1
        if abs(l[i] - l[j]) < l[j]:
            ansi -= 1
        ans += ansi
        # print(l[i], l[j], idx1, idx2)

ans //= 3
print(ans)


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

int main(){
  int a, b;
  cin >> a >> b;
  cout << max({a+b, a-b, a*b}) << endl;
}

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

int main() {
    string str;
    getline(cin, str);
    for (int i = 0; i < str.length(); i++) {
        if ((str[i] >= 65) && (str[i] <= 90)) {
            str[i] += 32; 
        }else if ((str[i] >= 97) && (str[i] <= 122)) {
            str[i] -= 32; 
        }
    }
    cout<<str<<endl;
    return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}
int main()
{
	int n;
	cin >> n;
	ll lc = 1;
	for(int i = 0 ; i < n ; i++){
		ll t;
		cin >> t;
		lc = lcm(lc , t);
	}
	cout << lc << endl;
	return 0;
} 




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int Maxn = 1e5 + 5;
int n;
int main()
{
	int cnt = 0,a;
	cin >> n;
	for (int i = 1; i <= n; i++)
		{
    scanf("%d",&a);
		    if (a== cnt + 1)
			cnt++;
		}
	if (!cnt)
		puts("-1");
	else
		cout << n - cnt << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cctype>
using namespace std;
template <class code>inline code read(const code &a)
{
    code x=0;short w=0;char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) {x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
    return w?-x:x;
}
const int mod=1e9+7;
int pd[100005],a[100005];
void work(int x){
    if(x%2==0)
        for(int i=1;i<=x;i+=2){
            a[i]=i;
            a[i+1]=a[i];
        }
    else
        for(int i=2;i<=x;i+=2){
            a[i]=i;
            a[i+1]=a[i];
        }
	return;
}
int main()
{
    int n,k=1;
    scanf("%d",&n);
    work(n);
    for(int i=1;i<=n;i++)pd[i]=read(pd[i]);
    sort(pd+1,pd+1+n);
    for(int i=1;i<=n;i++)
        if(a[i]!=pd[i]){
            puts("0");
            return 0; 
        }
    long long ans=1;
    n/=2;
    while(n--)ans=ans*2%mod;
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 896
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n, k;
  cin >> n >> k;
  double ans = 0;
  for(int i = 1; i <= n; i++) {
    double t = 1;
    int tmp = i;
    while(tmp < k) {
      tmp *= 2;
      t /= 2;
    }
    ans += t;
  }
  cout << fixed << setprecision(12) << ans / n << endl;
  return 0;
}


Measured memory_bytes: 256
def aminch(dp, pot, dp_1, pot_1): # Absolute MINimum CHanging
	return min(dp, abs(pot-pot_1)+dp_1)

N = int(input())
h = tuple(map(int, input().split()))
dp = [float("INF")]*N
dp[0], dp[1] = 0, abs(h[0]-h[1])

for i in range(2, N):
	dp[i] = aminch(dp[i], h[i], dp[i-1], h[i-1])
	dp[i] = aminch(dp[i], h[i], dp[i-2], h[i-2])

print(dp[-1])

Measured memory_bytes: 20640
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        while True:
            n, p = map(int, raw_input().split())
            if n == 0 and p == 0:
                break
            r = [0 for i in range(n)]
            turn = 0
            while True:
                if p > 0:
                    r[turn % n] += 1
                    p -= 1
                    if p == 0 and r.count(0) == n - 1:
                        break
                else:
                    p = r[turn % n]
                    r[turn % n] = 0
                turn += 1
                # print r
            print turn % n
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

Measured memory_bytes: 4648
N, x = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
if A[0] > x:
    ans += A[0] - x
    A[0] = x

for i in range(N-1):
    if A[i] + A[i+1] > x:
        ans += A[i] + A[i+1] - x
        A[i+1] -= A[i] + A[i+1] - x

print(ans)

Measured memory_bytes: 63984
import math

a, b = map(int, input().split())

a_min = math.ceil(a / 0.08)
a_max = math.ceil((a + 1) / 0.08)

b_min = math.ceil(b / 0.10)
b_max = math.ceil((b + 1) / 0.10)

ans = -1

for i in range(a_min,a_max):
  if i >= b_min and i < b_max:
    ans = i
    break

print(ans)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>

#include <iomanip>

#include <algorithm>

#include <vector>

#include <stack>

#include <queue>

#include <cmath>

#include <set>

#include <map>

#include <string>

#include <numeric>

#include <cstdio>

#include <cstdlib>

using namespace std;


const int INF = 10000000;

typedef pair<int, int> P;
typedef long long ll;
#define PB push_back

//char maze[100][101];

ll n, m;

int sx, sy;

int gx, gy;

int qqq;

//各座標までの最短距離

int d[100][100];


//移動方向のベクトル

int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

int ans = 0;
pair<int, int> red[101], blue[101];
//ll a[200000], b[20000];

//ユークリッドの互除法
ll gcd(ll x, ll y) {
	if (x < y) swap(x, y);
	if (y == 0) return x;
	return gcd(y, x%y);
}

//エラトステネスの篩 prime(n)[k]で1~nまで探索して(k+1)番目の素数を出力
vector<int> prime(int n) {
	vector<int> erst;
	for (int i = 0; i < n; ++i) erst.PB(i);
	erst[0] = erst[1] = NULL;
	auto dmax = sqrt(n);

	for (int dx = 2; dx < dmax; ++dx) {
		if (erst[dx] == NULL) continue;
		for (int i = dx * 2; i < n; i += dx) erst[i] = NULL;
	}

	vector<int> erstlist;
	for (auto i : erst) if (i) erstlist.PB(i);

	return erstlist;
}

ll v_find(std::vector<ll> vec, ll number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

ll BIG = 10000000000;

ll POW(ll a, ll b) {
	if (b == 0) return 1;
	return (a*POW(a, b - 1)) % BIG;
}

int Kaijou(int a) {
	if (a < 2) return 1;
	return a * Kaijou(a - 1);
}


ll aa[51];

int main() {
	int n;
	cin >> n;
	int a[100000] = { 0 };
	int da[100000] = { 0 };
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		da[a[i]]++;
		if (a[i] != 0) da[a[i] - 1]++;
		if (a[i] != 99999) da[a[i] + 1]++;
	}
	int maxid = -1,M=0;
	for (int i = 0; i < 100000; ++i) {
		if (M < da[i]) {
			M = da[i];
			maxid = i;
		}
	}
	
	cout << M << endl;


	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, d;
  cin >> n >> d;
  ll e = 2 * d + 1;
  cout << (n + e - 1) / e << endl;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int ans = -1;
		int num = 7;

		for (int i = 1; i <= k; i++) {
			if (num % k == 0) {
				ans = i;
				break;
			}

			num = (((10 % k) * (num % k)) % k + 7 % k) % k;
		}

		System.out.println(ans);

		sc.close();
	}

}

Measured memory_bytes: 35700
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
#define PI 3.14159265359
#define MOD 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

int main(){

    int n; cin >> n;
    deque<int> que;
    int a;

    rep(i,n){
        cin >>a;
        if(a == 0){
            int b,c; cin >> b >> c;
            if(b == 0){
                que.push_front(c);
            }
            else que.push_back(c);
        }
        else if(a == 2){
            int b; cin >> b;
            if(b == 0){
                que.pop_front();
            }
            else que.pop_back();
        }
        else{
            int b; cin >> b;
            cout << que.at(b) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4576
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#include<string>
#include<stdlib.h>
#include<stdio.h>

typedef long long ll;
using namespace std;
const ll x=1000000007;
int mod(ll a){
	return a%x;
}
int main(){
	ll n,a,b;
	cin>>n;
	for(int i=pow(n,0.5);i>=1;i--){
		if(n%i==0){
			a=i;
			b=n/i;
			break;
		}
	}
	cout<<(a-1)+(b-1);
}

Measured memory_bytes: 4028
#include<bits/stdc++.h>
using namespace std;
int psum[300005];
int k_psum[300005];
int arr[300005];

int main(){
	int n,k;
	string s;
	cin>>n>>k>>s;
	char curr = s[0];
	int counter = 0;
	vector<int>ret;
	for(int i=0; s[i]; i++){
		if(s[i]==curr) counter++;
		else{
			if(curr=='0') ret.push_back(counter*-1);
			else ret.push_back(counter);
			curr = s[i];
			counter = 1;
		}
	}
	if(curr=='0') ret.push_back(counter*-1);
	else ret.push_back(counter);
	n=ret.size();
	for(int i=0; i<ret.size(); i++) arr[i+1] = ret[i];
	for(int i=1; i<=n; i++){
		if(arr[i]<0) k_psum[i]++;
		k_psum[i]+=k_psum[i-1];
	}
	k_psum[n+1] = 1000000;
	for(int i=1; i<=n; i++){
		psum[i] = abs(arr[i]);
		psum[i]+=psum[i-1];
	}
	psum[n+1] = psum[n];
	int maxget=0;
	for(int i=1; i<=n; i++){
		int direction = k_psum[i-1]+k;
		int index = (upper_bound(k_psum,k_psum+n+2,direction)-k_psum);
		maxget = max(maxget,psum[index-1]-psum[i-1]);
	}
	cout<<maxget;
}

Measured memory_bytes: 5056
use std::io::*;
const MOD: u64 = 1_000_000_007;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let s: &str = itr.next().unwrap();

    let mut dp: Vec<Vec<u64>> = vec![vec![0; 5050]; 5050];
    dp[0][0] = 1;
    for i in 0..n {
        for j in 0..n + 1 {
            dp[i + 1][j + 1] += dp[i][j];
            dp[i + 1][j + 1] %= MOD;
            if j > 0 {
                dp[i + 1][j - 1] += dp[i][j] * 2;
                dp[i + 1][j - 1] %= MOD;
            }
            if j == 0 {
                dp[i + 1][j] += dp[i][j];
                dp[i + 1][j] %= MOD;
            }
        }
    }
    println!("{}", dp[n][s.len()]);
}


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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a+b > c+d) {
        cout << "Left" << endl;
    } else if (a+b == c+d) {
        cout << "Balanced" << endl;
    } else {
        cout << "Right" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, AB):
    g = defaultdict(set)

    for a, b in AB:
        g[a].add(b)
        g[b].add(a)

    def dfs(s):
        stack = [s]
        done = {s: 0}

        while stack:
            u = stack.pop()
            for v in g[u]:
                if v not in done:
                    done[v] = done[u] + 1
                    stack.append(v)
        l = (-0, 0)
        for k, v in done.items():
            if l[1] < v:
                l = (k, v)
        return l

    v, _ = dfs(1)
    _, l = dfs(v)
    return 'First' if l % 3 != 1 else 'Second'


def main():
    N = read_int()
    AB = [read_int_n() for _ in range(N-1)]
    print(slv(N, AB))


if __name__ == '__main__':
    main()


Measured memory_bytes: 173476
#include "bits/stdc++.h"
using namespace std;

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

int lcm(int x, int y) {
	return x * y / gcd(x, y);
}

int main() {
	int N,M;
	cin >> N >>M;
	vector<int>X(M);
	for (int n = 0;n<M;++n) {
		cin >> X[n];
	}
	sort(X.begin(),X.end());	
	vector<int>Y(M-1);
	for (int n = 0; n < M-1; ++n) {
		Y[n]=X[n+1]-X[n];
	}
	sort(Y.begin(), Y.end(), greater<int>());
	int res = X.back() - X[0];
	for (int n = 0;n<min(N-1,M - 1);++n) {
		res -= Y[n];
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3968
d,g=map(int,input().split())
l=[list(map(int,input().split()))for _ in range(d)]
for i in range(d):
    s=l[i][0]*100*-~i
    l[i].append(s+l[i][1])
    l[i].append(s)
a=10**18
for i in range(1<<d):
    s=t=k=0
    for j in range(d):
        if (i>>j)&1:
            s+=l[j][2]
            t+=l[j][0]
        else:
            k=j
    if s+l[k][3]<g:continue
    if s<g:
        t+=-(-(g-s)//(100*-~k))
    a=min(a,t)
print(a)

Measured memory_bytes: 40816
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#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 CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef int64_t LL;
typedef uint64_t ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
template<class T, class... U> void DEBUG(const T &head, const U &... tail) { 
#ifdef HOME
    _W('#'); _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...);
#endif
}
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int n;R(n);
    W(48-n);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
#define SELECTOR(_1, _2, _3, SELECT, ...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__, _rep1, _rep0)(__VA_ARGS__)
#define _rep0(i, n) for (ll i = 0; i < n; ++i)
#define _rep1(i, k, n) for (ll i = k; i < n; ++i)

void solve(){
  // main coding
  int n,m; cin>>n>>m;
  int INF=1<<15;
  vector<vector<int>> dist(n,vector<int>(n,INF)); // adjacency matrix
  vector<vector<int>> E(n); // adjacency list
  rep(_,m) {
    int a,b; cin>>a>>b;
    --a; --b; // 0-indexed
    dist[a][b]=1;
    E[a].push_back(b);
  }
  // Warshall-Floyd
  rep(k,n) rep(i,n) rep(j,n) {
    dist[i][j]=min(dist[i][k]+dist[k][j],dist[i][j]);
  }
  // loop detection
  int len=n+1,v;
  rep(i,n) {
    if(dist[i][i]<len) {
      v=i;
      len=dist[i][i];
    }
  }
  if(len==n+1) {
    cout<<-1<<"\n";
    return;
  }
  const int vm=v;
  vector<int> ans;
  while(len){
    ans.push_back(v);
    --len;
    rep(i,n) if(dist[v][i]==1 && dist[i][vm]==len){
      v=i;
      break;
    }
  }
  cout<<ans.size()<<"\n";
  for(int v:ans) cout<<v+1<<"\n";
}

int main(){
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  solve();
  return 0;
}


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

int main(){
  int i=0,j=0,n=0,sum=0;
  int c[500],s[500],f[500];
  cin >> n;
  for(i=0;i<n-1;i++){
    cin >> c[i] >> s[i] >> f[i];
  }
  c[n-1] = 0;
  s[n-1] = 0;
  f[n-1] = 1;
  for(j=0;j<n;j++){
    sum = c[j] + s[j];
    for(i=j+1;i<n;i++){
      if(sum - s[i] >= 0 && (sum-s[i])%f[i] == 0){
        sum = sum + c[i];
      }
      else if(sum - s[i] >= 0 && (sum-s[i])%f[i] != 0){
        sum = sum + c[i] + (f[i]-(sum-s[i])%f[i]);
      }
      else if(sum - s[i] < 0){
        sum = c[i] + s[i];
      }
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
typedef long long ll;
typedef long double la;
#define pb push_back()
using namespace std;

int main(){
  int n;
  double c;
  double ans=0;
  cin >> n;
  double a[n];
  vector<int> b;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    c = 1/a[i];
    ans += c;
  }
  cout << 1/ans << endl;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{

int n;
int a[10101];
cin>>n;
for(int i=0;i<n;i++)
    cin>>a[i];

int ans=0;
for(int i=0;i<n;i++)
    while(a[i]%2==0) {
                      a[i]/=2;
                      ans++;
                     }
cout<<ans;

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int s = a+b+c;
  int m = max({a,b,c});
  if(s % 2 != m % 2){
    ++m;
  }
  cout << (m*3-s) / 2 << endl;
}

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

using namespace std;
int main(void){
    int n;
    cin >> n;
    
    vector<int> a(n+1);
    vector<int> b(n);
    
    for (int i = 0; i < n+1; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    
    long long ans = 0;
    
    for (int i = 0; i < n; i++){
        
        int temp = min(a[i], b[i]);
        a[i] -= temp;
        b[i] -= temp;
        ans += temp;
        
        temp = min(a[i+1], b[i]);
        a[i+1] -= temp;
        ans += temp;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024