akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
int x[200020], y[200020]; 
int main() {
	int n;
	cin >> n;
	int a,b;
	rep(i,n) {
		cin >> a >> b;
		x[i] = a+b;
		y[i] = a-b;
	}

	int X = *max_element(x,x+n) - *min_element(x,x+n);
	int Y = *max_element(y,y+n) - *min_element(y,y+n);

	cout << max(X,Y) << endl;
	return 0;
}

Measured memory_bytes: 5228
#include <iostream>
#include <string>
using namespace std;
int main(){
    int a,b,c,x=3;
    cin >> a >> b >> c;
    if(a==b){x--;}
    if(a==c){x--;}
    if(b==c){x--;}
    if(x==0){x=1;}
    cout << x << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int main() {
  int n;
  scanf("%d", &n);
  printf("%d\n", (n*n+n)/2);
}


Measured memory_bytes: 256
#include<stdio.h>

int linearSearch(int*, int, int);

int main() {
  int i, sl, tl, arrayS[10000], arrayT[500], result=0;

  scanf("%d", &sl);
  for(i=0 ; i<sl ; i++) { scanf("%d", &arrayS[i]); }

  scanf("%d", &tl);
  for(i=0 ; i<tl ; i++) { scanf("%d", &arrayT[i]); }

  for(i=0 ; i<tl ; i++) {
    if(linearSearch(arrayS, sl, arrayT[i])) { result++; }
  }
  
  printf("%d\n", result);
  return 0;
}

int linearSearch(int* array, int l, int key) {
  int i;

  for(i=0 ; i < l; i++){
    if(array[i] == key) { return 1; }
  }
  
  return 0;
}



Measured memory_bytes: 2124
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
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 functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

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


def main():
    N = INT()
    T = [INT() for _ in range(N)]

    lcm_base = lambda x, y: (x * y) // gcd(x, y)
    lcm = lambda *numbers: reduce(lcm_base, numbers, 1)
    print(lcm(*T))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9976
import collections
n = int(input())
S = [list(input()) for i in range(n)]
Sc = [collections.Counter(i) for i in S]


if n == 1:
    S[0].sort()
    ans = "".join(S[0])
    print(ans)
else:
    counter = Sc[0] & Sc[1]
    for i in range(2, len(Sc)):
        counter = counter & Sc[i]

    Sclist = list(counter.elements())
    Sclist.sort()
    ans = "".join(Sclist)

    print(ans)


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

int main() {
  int n,x,cnt=1;
  cin>>n>>x;

  vector<int> l(n+1),d(n+2);
  l[0] = 0;
  d[0] = 0;
  d[1] = 0;
  for (int i = 1; i <= n; i++) cin >> l[i];

  for (int i = 2; i <= n+1; i++) {
    d[i] = d[i-1] + l[i-1];
    if (d[i] <= x) cnt++;
  }

  cout << cnt << endl;
  return 0;
  

}

Measured memory_bytes: 3588
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
int main() {
	int sum = 0;
	vector<int>as(4), bs(2);
	for (int i = 0; i < 4; ++i) {
		cin >> as[i];
		sum += as[i];
	}
	cin >> bs[0] >> bs[1];
	sum += bs[0] + bs[1];
	sum -= *min_element(as.begin(), as.end()) + *min_element(bs.begin(), bs.end());
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define forinc(i,a,b) for(int i=a;i<=b;++i)
#define fordec(i,a,b) for(int i=a;i>=b;--i)
#define fi first
#define se second
#define pii pair<int,int>
#define gg exit(0)

int h,w,k;
int a[20][1010],x[20];
int s[20][1010],ret=INT_MAX;
int get(int i,int j,int u,int v)
{
    return max(0ll,s[u][v]-s[u][j-1]-s[i-1][v]+s[i-1][j-1]);
}
void ktra(){
  //  if(x[1]==1&&x[2]==1){
    int cnt=0;
    vector<int> tmp;
    tmp.push_back(0);
    forinc(i,1,h-1) if(x[i]==1) {tmp.push_back(i);cnt++;}
    tmp.push_back(h);
    int cur=1;
    int pos=1;
    while(pos<=w){
            bool ok=0;
            for(int j=0;j<tmp.size()-1;++j){
                    //cout<<tmp[j]<<"\n";
                if(get(tmp[j]+1,cur,tmp[j+1],pos)>k){
                      //  cout<<tmp[j]<<" "<<cur<<" "<<tmp[j+1]<<" "<<pos<<"\n";
                        ok=1;break;}
            }
            if(pos==1&&ok==1) {cnt=INT_MAX;break;}
            if(!ok) pos++;
            else{
                    //cout<<pos<<" "<<cur<<"\n";
                //   cout<<pos<<" "<<cnt<<"\n";
                cnt++;
                cur=pos;
            }
    }
 //   cout<<cnt;
    ret=min(ret,cnt);
  //  }
  //if(cnt==3) cout<<x[1]<<" "<<x[2]<<"\n";

}

void duyet(int i){
    if(i==h) ktra();
    else
    {
        forinc(t,0,1){
            x[i]=t;
            duyet(i+1);
        }
    }
}
main()
{
    //freopen("test.inp","r",stdin);
   ios_base::sync_with_stdio(false);
   cin>>h>>w>>k;
   forinc(i,1,h) forinc(j,1,w)
   {
       char ch;cin>>ch;
       a[i][j]=(ch-'0');
   }
    forinc(i,1,h) forinc(j,1,w) s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+a[i][j];

    duyet(1);
    cout<<ret;
}


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

int main()
{
    int N;
    cin >> N;
    int AC = 0, WA = 0, TLE = 0, RE = 0;
    while (N--)
    {
        string S;
        cin >> S;
        if (S == "AC")
            AC++;
        else if (S == "WA")
            WA++;
        else if (S == "TLE")
            TLE++;
        else
            RE++;
    }
    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};



int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	while(1){
		int n;
		cin>>n;
		if(n==0) break;
		map<char,int> mp;
		vvi a(n);
		int id=0;
		for(int i=0;i<n;i++){
			string s;
			cin>>s;
			int m=s.size();
			for(int j=0;j<m;j++){
				if(mp.find(s[j])==mp.end()){
					mp[s[j]]=id;
					id++;
				}
				a[i].push_back(mp[s[j]]);
			}
			reverse(a[i].begin(),a[i].end());
		}
		vi b(10);
		for(int i=0;i<10;i++) b[i]=i;
		int res=0;
		do{
			int sum=0;
			for(int i=0;i<n;i++){
				int tmp=0,t=1;
				if(a[i].size()>1&&b[a[i].back()]==0) break;
				for(auto j:a[i]){
					tmp+=t*b[j];
					t*=10;
				}
				if(i==n-1&&sum==tmp) res++;
//				if(i==n-1&&sum==tmp) cout<<sum<<' '<<tmp<<endl;
				sum+=tmp;
			}
		}while(next_permutation(b.begin(),b.end()));
		for(int i=0;i<10-id;i++) res/=i+1;
		cout<<res<<endl;
	}
}


Measured memory_bytes: 3120
#include <iostream>
using namespace std;
#define M 2000000
int A[M + 1],n;

void maxHeapify(int i){
  int l,r,largest;

  l = i * 2;
  r = i * 2 + 1;

  if(l <= n && A[l] > A[i]) largest = l;
  else largest = i;
  if(r <= n && A[r] > A[largest]) largest = r;

  if(largest != i){
    swap(A[i],A[largest]);
    maxHeapify(largest);
  }
}
int main(){

  cin >> n;
  for(int i = 1;i <= n;i++){
    cin >> A[i];
  }
  for(int i = n / 2;i >= 1;i--) maxHeapify(i);

  for(int i = 1;i <= n;i++){
    cout << " ";
    cout << A[i];
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 4964
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S, ans="Yes";
  cin >> S;
  REP(i,S.size()){
    if(i%2==0) {
      if(S[i]=='L') ans="No";
    }
    else if(i%2==1) {
      if(S[i]=='R') ans="No";
    }
  }
  cout << ans << endl;
}

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

int a[100000][3];

signed main(){

  int n,m; cin >> n >> m;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 3; j++){
      cin >> a[i][j];
    }
  }

  int ans = 0;
  vector<int> vec(n,0);
  for(int i = 0; i < (1 << 3); i++){
    for(int j = 0; j < n; j++){
      for(int k = 0; k < 3; k++){
        vec[j] += ((i >> k & 1) ? 1 : -1)*a[j][k];
      }
    }
    sort(vec.rbegin(),vec.rend());
    int res = 0;
    for(int j = 0; j < m; j++){
      res += vec[j];
    }
    ans = max(ans,res);
    fill(vec.begin(),vec.end(),0);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int H,W,i,j;
	for(;;){
		cin>>H>>W;
		if(H==0&&W==0){
		break;
		}
	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
			cout<<"#";
		}
		cout<<endl;
	}
	cout<<endl;
	}
return 0;
}


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

#define MAX 1010
#define INF 200000000

vector<int> g[MAX];
int custo[MAX];
int M,N;
int potencias[14];
int dp[MAX][100000];

bool check(int mask){
	bool ans=true;
	for (int i=0; i<N; i++){
		if ((potencias[i]&mask)==0) ans=false;
	}
	
	return ans;
}

int solve(int m, int mask){
	if (m==M){
		if (check(mask)) return 0;
		else return INF;
	}
	
	if (dp[m][mask]!=-1) return dp[m][mask];
	
	int new_mask=mask;
	
	for (int i=0; i<g[m].size(); i++){
		new_mask|=potencias[g[m][i]];
	}
	
	dp[m][mask]=min(solve(m+1,new_mask)+custo[m],solve(m+1,mask));
	
	return dp[m][mask];

}




int main(){
	potencias[0]=1;
	for (int i=1; i<14; i++) potencias[i]=potencias[i-1]*2;
	
	memset(dp, -1, sizeof(dp));

	cin>>N>>M;
	
	for (int i=0; i<M; i++){
		int a,b;
		cin>>a>>b;
		custo[i]=a;
		for (int j=0; j<b; j++){
			int k;
			cin>>k;
			k--;
			g[i].push_back(k);
		}
	}
	
	if (solve(0,0)>=INF) cout<<-1<<endl;
	else cout<<solve(0,0)<<endl;
	
	


}


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

A = sorted(list(map(int, input().split())))
'''
INF = 10**6

ind = INF
for i in range(len(A)):
    if A[i]>=0:
        ind = i
        break
    else:
        A[i] *= -1

if ind == INF:
    ind = N

if ind %2 == 0:
    print(sum(A))
elif ind==N:
    print(sum(A)-2*A[ind-1])
else:
    print(sum(A)-2*min(A[ind], A[ind-1]))
'''
start = 0
end = N-1

while end != start:
    if A[(start+end)//2] >= 0:
        end = (start+end)//2
    elif end-start==1:
        start = (start+end)//2+1
    else:
        start = (start+end)//2

if start==N-1 and A[N-1]<0:
    start=N

if start%2==0:
    print(sum(A[:start])*(-1) + sum(A[start:]))
elif start==N:
    print(sum(A[:start])*(-1) + sum(A[start:]) + 2*A[N-1])
else:
    print(sum(A[:start])*(-1) + sum(A[start:]) - 2*min(A[start], (-1)*A[start-1]))

Measured memory_bytes: 64624
n,ma,mb = map(int,input().split())
l = []
sum_a = 0
sum_b = 0
for _ in range(n):
    a,b,c = map(int,input().split())
    sum_a += a
    sum_b += b
    l.append([a,b,c])

INF = 10**10
dp = list( list([INF for i in range(450)] for i in range(450)) for i in range(45))
dp[0][0][0] = 0
for i in range(n):
    for s in range(sum_a+1):
        for k in range(sum_b+1):
            a,b,c = l[i]
            dp[i+1][s][k] = min(dp[i][s][k], dp[i+1][s][k],dp[i][s-a][k-b]+c)

ans = 10**10
k = 1
while ma*k < 450 and mb*k < 450 :
    ans = min(ans, dp[n][ma*k][mb*k])
    k += 1
if ans != 10**10:
  print(ans)
else:
  print(-1)


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

#define ll long long
#define pb push_back
#define eb emplace_back
//#define st first
#define sc second

using namespace std;

const ll mod = 1e9 + 7;
const int e = 2*1e5 + 69;
const int base = 311;

// dung inverse module de tinh nCk
// beginer 78
// mbeginer
// cach tao hoan vi tu n so : n*(n+1)/2;

//vector<pair<ll,ll>>adj[e];
//vector<ll>adj[e];

/*ll Pow(ll n, ll dem)
{
    if(dem == 0) return 1;
    if(dem == 1) return n ;
    ll t = Pow(n, dem/2);
    if(dem % 2 == 0) return (t*t);
    else return ((t * t) * n);
}*/

/*ll C(ll k, ll n)
{
    if(k == 0) return 1;
    if(n < k) return 0;
    return (gt[n]%mod * (igt[k]%mod * igt[n-k]%mod)%mod)%mod;
}*/

ll n, m, k;
ll h[e];

int main()
{
    ll maxx = 0;
    ll minn = 1e18;
    cin >> n >> m >> k;
    ll pos = 1e18, pos1 = 1e18;
    for(int i=1; i<=n; i++) cin >> h[i];
    if(n == 1)
        cout << abs(h[1]  - k);
    else cout << max(abs(h[n] - k), abs(h[n-1] - h[n]));
}
/*

*/


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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> x(N);
  int S = 0;
  for(int i=0;i<N;i++){
    cin >> x[i];
    if(x[i] <= K/2){
      S += x[i]*2;
    }
    else{
      S += (K - x[i])*2;
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 256
#include <cstdio>

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

  for (int i = 0; i < N; ++i) {
    int A;
    scanf("%d", &A);
    for (int j = 1; j <= D; j += A)
      ++X;
  }
  printf("%d\n", X);
}

Measured memory_bytes: 256
import math
from collections import deque
from collections import defaultdict

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

ans = 0
a,b = readInts()

for i in range(a,b+1):
	s = str(i)
	if s[:2]==s[-1:-3:-1]:
		ans+=1

print(ans)

Measured memory_bytes: 3444
#include <iostream>
#include <string.h>

using namespace std;

int main(){
	string batter;
	int n;

	cin >> n; 

	for(int i = 0; i < n; i++){
		int runner = 0 , num = 0 , out = 0;	
		while(1){
			cin >> batter;

			if(batter == "HIT"){
				runner++;
				if(runner == 4){
					runner--;
					num++;
				}
			}else if(batter == "HOMERUN"){
				num++;
				num += runner;
				runner = 0;
			}else if(batter == "OUT"){
					out++;
					if(out == 3){
						runner = 0;
						break;
					}
				}
			}
		cout << num << endl;
	}
	return 0;
}

Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i, s, e) for (int i = (s); i <= (e); i++)
int n;
int k;
int l;


struct UnionFind
{
	vector<int> par_;
	vector<int> rank_;

	void init(int size)
	{
		par_.resize(size, 0);
		rank_.resize(size, 0);
		for (int i = 0; i < size; i++)
		{
			par_[i] = i;
			rank_[i] = 0;
		}
	}
	int root(int x)
	{
		return par_[x] == x ? x : par_[x] = root(par_[x]);
	}

	bool unite(int x, int y)
	{
		x = root(x);
		y = root(y);
		if (x == y)
			return true;

		if (rank_[x] < rank_[y])
		{
			par_[x] = y;
		}
		else
		{
			par_[y] = x;
			if (rank_[x] == rank_[y])
				rank_[x]++;
		}
		return false;
	}
	bool same(int x, int y)
	{
		return root(x) == root(y);
	}
};

int main()
{

	cin >> n >> k >> l;

	UnionFind road,train;
	road.init(n);
	train.init(n);

	rep(i, 1, k)
	{
		int p, q;
		cin >> p >> q;
		p--;q--;
		road.unite(p,q);
	}
	rep(i, 1, l)
	{
		int p, q;
		cin >> p >> q;
		p--;q--;
		train.unite(p,q);
	}

	typedef pair<int,int> P;
	typedef pair<P,int> P2;
	vector<P2> vec;

	rep(i,0,n - 1)
	{
		road.root(i);
		train.root(i);
	}

	rep(i,0,n-1)
	{
		vec.push_back(P2(P(road.par_[i],train.par_[i]),i));
	}

	sort(vec.begin(),vec.end());
	vector<int> memo;
	vector<int> cou(n,0);

	int c = 1;
	memo.push_back(vec[0].second);

	rep(i,1,n - 1)
	{
		if(vec[i - 1].first.first == vec[i].first.first && vec[i - 1].first.second == vec[i].first.second)
		{
			c++;
		}
		else
		{
			for(int m : memo)
			{
				cou[m] = c;
			}
			c = 1;
			memo.resize(0);
		}
		memo.push_back(vec[i].second);
	}

	for(int m : memo)
	{
		cou[m] += c;
	}
	c = 1;
	for(int ans : cou)
	{
		cout << ans << endl;
	}
	return 0;


}


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

int main() {
  int a,b;
  cin>>a>>b;
  int m=max(a,b);
  if (a==b) {
    cout << 2*a << endl;
  }
  else {
    cout << 2*m-1 << endl;
  }
}


Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		int N = int.Parse(str);
		int min = 999999;
		int count = 0;
		int ac = 0;
		while(N >= ac * 6){
			int an = ac * 6;
			int a = 6;
			count = 0;
			while(a >= 6){
				while(an >= a * 6){
					a *= 6;
				}
				while(an >= a){
					an -= a;
					count += 1;
				}
				a /= 6;
			}
			an = N - ac * 6;
			int b = 9;
			while(b >= 9){
				while(an >= b * 9){
					b *= 9;
				}
				while(an >= b){
					an -= b;
					count += 1;
				}
				b /= 9;
			}
			count += an;
			min = Math.Min(count,min);
			ac += 1;
		}
		Console.WriteLine(min);
	}
}

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

using namespace std;
#define LL long long
LL s[6];
int main()
{
    LL n,ans;
    while(cin>>n)
    {
        for(int i=0;i<5;i++)
            cin>>s[i];
        sort(s,s+5);
        if(n%s[0]==0)
            ans=4+n/s[0];
        else
            ans=5+n/s[0];
        cout<<ans<<endl;
    }

    return 0;
}


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

const int mod = (int)1e9+7;

ll a[2001];

ll rec(int n) {
    if (a[n] != 0) return a[n];
    if (n == 0) return a[n] = 1;
    if (n == 1 or n == 2) return a[n] = 0;
    ll s = 0;
    rep(i, n-2) {
        s += rec(i);
        s %= mod;
    }
    return a[n] = s;
}

int main() {
    int n;
    cin >> n;
    memset(a, 0, sizeof(a));
    cout << rec(n) << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <set>
#include <algorithm>

using namespace std;

int solve(string cars);

int main(){
	int n;
	string word;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> word;
		cout << solve(word) << endl;
	}
}

int solve(string cars){
	set<string> s;
	int n = cars.size();
	for (int i = 1; i < n; i++){
		string a = cars.substr(0, i);
		string b = cars.substr(i);
		s.insert(a + b);
		s.insert(b + a);
		reverse(b.begin(), b.end());
		s.insert(a + b);
		s.insert(b + a);
		reverse(a.begin(), a.end());
		s.insert(a + b);
		s.insert(b + a);
		reverse(b.begin(), b.end());
		s.insert(a + b);
		s.insert(b + a);
	}
	return s.size();
}

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

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> v(N);
  
  string str;
  for (int i = 0; i < N; i++) {
    cin >> str;
    v.at(i) = str;
  }
  
  sort(v.begin(), v.end());
  
  for (int i = 0; i < N; i++) {
    cout << v.at(i);
    if (i == (N - 1)) {
      cout << endl;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
bool isPrime[400010];

void init(){
  fill(isPrime,isPrime+400010,true);
  isPrime[0] = isPrime[1] = false;
  for(int i = 2;i*i < 400010;i++){
    if(isPrime[i]){
      for(int j = i*2;j < 400010; j += i){
        isPrime[j] = false;
      }
    }
  }
}

int main(){
  init();
  while(true){
    int n;
    cin >> n;
    if(n == 0)break;
    int cnt = 0;
    for(int i = n+1;i <= n*2;i++){
      if(isPrime[i])cnt++;
    }
    cout << cnt << endl;
  }
}

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    string ans = "Yes";
    while(1){
        c-=b;
        if(c<=0) break;
        a-=d;
        if(a<=0) {
            ans = "No";
            break;
        }

    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef complex<double> P; //Point
typedef pair<P,P> L; //Line, Segment

const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);

namespace std {
  bool operator < (const P& a, const P& b){
    return fabs(real(a)-real(b)) < EPS ? imag(a) < imag(b) : real(a) < real(b);
  }
}
double dot(P a, P b){ return real(conj(a)*b); }
double cross(P a, P b){ return imag(conj(a)*b); }
int ccw(P a, P b, P c){
  b -= a;
  c -= a;
  if(cross(b,c) > EPS) return 1;   // ????????????(b-a)????????´???????????????(c-a)????????¨?????????
  if(cross(b,c) < -EPS) return -1; // ????????????(b-a)????????´???????????????(c-a)????????¨?????????
  if(dot(b,c) < -EPS) return 2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}

double area(vector<P> v){
  double sum = 0.0;
  int n = v.size();
  for(int i=0;i<n;i++) sum += (real(v[i]) - real(v[(i+1)%n])) * (imag(v[i]) + imag(v[(i+1)%n]));
  return fabs(sum) / 2;
};

P crossPoint(L l, L m){
  double A = cross(l.second - l.first, m.second - m.first);
  double B = cross(l.second - l.first, l.second - m.first);
  if(fabs(A) < EPS && fabs(B) < EPS) return m.first;
  else if(fabs(A) >= EPS) return m.first + B / A * (m.second - m.first);
}

vector<P> convex_cut(vector<P> G, L l){
  vector<P> ans;
  for(int i=0;i<G.size();i++){
    P A = G[i];
    P B = G[(i+1)%G.size()];
    if(ccw(l.first, l.second, A) != -1) ans.push_back(A);
    if(ccw(l.first, l.second, A) * ccw(l.first, l.second, B) < 0)
      ans.push_back(crossPoint(L(A,B), l));
  }
  return ans;
}

int n,m;
vector<P> mp;
double calc(int idx,vector<P>g){
  for(int i=0;i<m;i++){
    if(i==idx)continue;
    P t=mp[idx]-mp[i];
    P a=P(abs(t)/2,1)*t/abs(t)+mp[i];
    P b=P(abs(t)/2,-1)*t/abs(t)+mp[i];
    if(ccw(a,b,mp[idx])<0)swap(a,b);
    g=convex_cut(g,L(a,b));
  }
  return area(g);
}

int main(){
  while(1){
  cin>>n>>m;
  if(!n&&!m)break;
  vector<P> pl(n);
  mp.resize(m);
  for(int i=0,x,y;i<n;i++)cin>>x>>y,pl[i]=P(x,y);
  for(int i=0,x,y;i<m;i++)cin>>x>>y,mp[i]=P(x,y);
  for(int i=0;i<m;i++)printf("%.10f\n",calc(i,pl));
  }
  return 0;

}

Measured memory_bytes: 3088
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,a;
    int max = -1000000;
    int min = 1000000;
    long long sum = 0;
    
    cin >>n;
    
    for(int i = 0; i < n; i++){
        cin >> a;
        sum = sum + a;
        if(max < a){
            max = a;
        }
       if(min > a){
           min = a; 
       }
    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}




Measured memory_bytes: 3104
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll n, k, d;

	cin >> n >> k;

	ll ans = n;
	set<ll> s;

	REP(i, k) {
		cin >> d;
		s.insert(d);
	}

	ll now;
	bool flag;

	while (true) {
		now = ans;
		flag = true;
		
		while (now > 0) {
			if (s.count(now % 10)) {
				ans++;
				flag = false;
				break;
			}
			else {
				now /= 10;
			}
		}

		if (flag) {
			break;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
 
signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  int s,w;
  cin >> s >> w;
  if(w >= s){
    cout << "unsafe" << endl;
  } 
  else{
    cout << "safe" << endl;
  }

  return 0;
}

Measured memory_bytes: 3644
import copy
N = int(input())
p = [int(i) for i in input().split()]
_p = p.copy()

a = []
for i in range(len(p)-1):
	if p[i]>=p[i+1]:
		a.append(i)
if len(a)==2:
	c = p[a[0]]
	d = p[a[1]+1]
	_p[a[0]]=d
	_p[a[1]+1]=c
	p.sort()
	if _p==p:
		print("YES")
	else:
		print("NO")
elif len(a)==0:
	print("YES")
else:
	print("NO")

Measured memory_bytes: 3444
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("trapv")
#pragma GCC target("sse4")

#include <bits/stdc++.h>
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n"
#define int long long
#define mod 1000000007
#define PI acos(-1)

void solve() {
	int n;
	cin >> n;
	vector<int> arr(n);
	for(auto &ele : arr)
		cin >> ele;
	int ans = 0;
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {
			for(int k = j + 1; k < n; k++) {
				vector<int> temp = {arr[i], arr[j], arr[k]};
				sort(temp.begin(), temp.end());
				if(arr[i] != arr[j] && arr[j] != arr[k] && arr[i] != arr[k] && temp[0] + temp[1] > temp[2]) {
					ans++;
				} 
			}
		}
	}
	cout << ans;
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	int tc = 1;
	// cin >> tc;
	while(tc--) {
	    solve();
	}
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	int N,A;
	cin >> N >> A;
	int L=A;
	int R=A+N-1;
	int eat;
	if(R<=0)eat=R;
	else if(L>=0)eat=L;
	else eat = 0;
	int ans=(R+L)*(R-L+1)/2 -eat;
	cout << ans << endl;
}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll l, r;
  cin >> l >> r;
  
  if(r - l >= 2019){
    cout << 0 << '\n';
    return 0;
  }
  
  ll ans = 2020;
  for(ll i = l; i < r; i++){
    for(ll j = i + 1; j <= r; j++){
      ans = min(ans, (i * j) % 2019);
    }
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
using namespace std;
const int inf = 2147483647;
int n, q, tp, v1, v2, v3, seg[262156], lazy[262156];
void push(int k) {
	if(lazy[k] != -inf) {
		seg[k * 2] = lazy[k * 2] = lazy[k];
		seg[k * 2 + 1] = lazy[k * 2 + 1] = lazy[k];
		lazy[k] = -inf;
	}
}
void update(int a, int b, int x, int k, int l, int r) {
	if (a <= l && r <= b) {
		seg[k] = lazy[k] = x;
		return;
	}
	if (r <= a || b <= l) return;
	push(k);
	update(a, b, x, k * 2, l, (l + r) >> 1);
	update(a, b, x, k * 2 + 1, (l + r) >> 1, r);
	seg[k] = min(seg[k * 2], seg[k * 2 + 1]);
}
int query(int a, int b, int k, int l, int r) {
	if (a <= l && r <= b) return seg[k];
	if (r <= a || b <= l) return inf;
	push(k);
	int lc = query(a, b, k * 2, l, (l + r) >> 1);
	int rc = query(a, b, k * 2 + 1, (l + r) >> 1, r);
	return min(lc, rc);
}
int main() {
	fill(seg, seg + 262156, inf);
	fill(lazy, lazy + 262156, inf);
	scanf("%d %d", &n, &q);
	while (q--) {
		scanf("%d", &tp);
		if (tp == 0) {
			scanf("%d %d %d", &v1, &v2, &v3); v2++;
			update(v1, v2, v3, 1, 0, 131072);
		}
		else {
			scanf("%d %d", &v1, &v2); v2++;
			int ret = query(v1, v2, 1, 0, 131072);
			printf("%d\n", ret);
		}
	}
	return 0;
}

Measured memory_bytes: 4796
#include <stdio.h>

int main(){
        int X,A,B;
        scanf("%d %d %d",&X,&A,&B);
        if((A-B)>=0){
                printf("delicious");
                goto fin;
        }
        if((A-B+X)>=0){
                printf("safe");
                goto fin;
        }
        printf("dangerous");
fin:        return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

#define N 100

int main() {
	static char cc[N][N + 1], s[N], aa[N], bb[N];
	int n, m, i, j, k, good;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++)
		scanf("%s", cc[i]);
	for (i = 0; i < n; i++) {
		good = 1;
		for (j = 0; j < m; j++)
			if (cc[i][j] != '.') {
				good = 0;
				break;
			}
		aa[i] = good;
	}
	for (j = 0; j < m; j++) {
		good = 1;
		for (i = 0; i < n; i++)
			if (cc[i][j] != '.') {
				good = 0;
				break;
			}
		bb[j] = good;
	}
	for (i = 0; i < n; i++)
		if (!aa[i]) {
			k = 0;
			for (j = 0; j < m; j++)
				if (!bb[j])
					s[k++] = cc[i][j];
			s[k] = '\0';
			printf("%s\n", s);
		}
	return 0;
}


Measured memory_bytes: 128
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

use std::cmp;

fn main() {
    let (n, z, w) = get!(usize, i32, i32);
    let aa = get!(String).split_whitespace().map(|a| a.parse::<i32>().unwrap()).rev().collect::<Vec<_>>();

    let mut dp = vec![vec![-1; n+1]; 2];

    for i in 0..n+1 {
        let (x, y) = if i == n { (z, w) } else { (aa[i], aa[i]) };
        dp[0][i] = (aa[0] - y).abs();
        dp[1][i] = (aa[0] - x).abs();
        for j in 1..i {
            dp[0][i] = cmp::max(dp[0][i], dp[1][j]);
            dp[1][i] = cmp::min(dp[1][i], dp[0][j]);
        }
    }

    println!("{}", dp[0][n]);
}

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

using namespace std;

int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    long long a;

    cin >> a;

    long long b;

    cin >> b;

    if(a>=1 and a<=9 and b>=1 and b<=9) {

        cout << a*b << '\n';

    } else {

        cout << -1 << '\n';

    }

    return 0;

}



Measured memory_bytes: 3612
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;
const double PI=3.14159265358979323846;

int main() {
    long long N, M;
    cin >> N >> M;

    vector<pair<long long, long long>> ab(N);
    for (int i = 0; i < N; i++) {
        cin >> ab[i].first >> ab[i].second;
    }

    sort(ab.begin(), ab.end(), [](const pair<int, int>& left, const pair<int, int>& right) {
        return left.first < right.first;
    });

    long long cost = 0;
    long long lastM = M;
    int index = 0;
    while (lastM > 0) {
        // cout << ab[index].first << ", " << ab[index].second << endl;
        cost += ab[index].first * min(ab[index].second, lastM);
        lastM -= ab[index].second;
        index++;
    }

    cout << cost << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
	long long int n,i,temp,max;
	temp=0;
	max=0;
	cin>>n;
	for (i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	for(i=0;i<n-1;i++)
	{
		if (arr[i]>=arr[i+1])
		{
			temp++;
		}
		else
		{
			max=fmax(temp,max);
			temp=0;
		}
	}
	max=fmax(max,temp);
	cout<<max<<endl;
}

Measured memory_bytes: 1024
a= input()
b = len(a)
if a!=a[::-1]:
  print("No")
elif a[:(b-1)//2]!=a[:(b-1)//2][::-1]:
  print("No")
elif a[(b+1)//2:]!=a[(b+1)//2:][::-1]:
  print("No")
else:
  print("Yes")


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
    int n;
    int b,f,r,v;
    cin >> n;
    int count[4][3][10]={{{}}};
    for(int i=0;i<n;i++){
        cin >> b >> f >> r >> v;
        count[b-1][f-1][r-1]+=v;
    }
    
    for(int j=0;j<4;j++){
        for(int k=0;k<3;k++){
            for(int l=0;l<10;l++){
                cout <<" ";
                cout << count[j][k][l];
            }cout << endl;
        }
        if (j!=3)cout << "####################" <<endl;
    }
}


Measured memory_bytes: 3088
import std.stdio, std.conv, std.string;
import std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

int DEBUG_LEVEL = 0;
void print()(){ writeln(""); }
void print(T, A ...)(T t, lazy A a){ write(t), print(a); }
void print(int level, T, A ...)(T t, lazy A a){ if(level <= DEBUG_LEVEL) print(t, a); }

void main(string[] args){
	if(args.length > 1 && args[1] == "-debug"){
		if(args.length > 2 && args[2].isNumeric) DEBUG_LEVEL = args[2].to!int;
		else DEBUG_LEVEL = 1;
	}
	
	// ----------------------------------------
	
	int n = read.to!int;
	Node[] nodes;
	foreach(i; 0 .. n) nodes ~= new Node(i);
	
	foreach(i; 0 .. n - 1){
		long a = read.to!long - 1;
		long b = read.to!long - 1;
		nodes[a].nodes ~= nodes[b];
		nodes[b].nodes ~= nodes[a];
	}
	
	print!1("nodes:", nodes);
	
	// 直径の両端を求める
	foreach(nd; nodes) nd.isVisited = 0;
	Node p = nodes[uniform(0, n)].furthest;
	foreach(nd; nodes) nd.isVisited = 0;
	Node q = p.furthest;
	print!1("p:", p, " q:", q);
	
	// pからqまでの距離(直径)
	foreach(nd; nodes) nd.isVisited = 0;
	p.setp(0);
	int d = q.dp;
	
	string ans;
	if((d - 1) % 3 == 0) ans = "Second";
	else ans = "First";
	
	ans.writeln;
}
/*

「葉をすべて削除」
「指定した1つの葉以外のすべての葉を削除」
という行動ができる。

直径がどう変わるか？
・直径は1減る（直径に寄与している葉を指定したとき）
・直径は2減る（その他を指定したとき）

※直径が1のときは直径に寄与している葉しかないので後手勝ち

直径が0のときは先手勝ち

ニムをする。(直径-1)を0にしたらよいゲーム。
(直径-1)を3で割った余りに注目し、余りが0なら後手勝ち。それ以外は先手勝ち。

*/

class Node{
	long id;
	int dp, dq, d;
	bool isVisited;
	Node[] nodes;
	this(long id){
		this.id = id;
	}
	Node furthest(){ // O(n) // isVisitedをクリアしてから呼ぶこと
		Node res = this;
		Node[] q = [this];
		int iq = 0;
		this.isVisited = 1;
		while(iq < q.length){
			foreach(nd; q[iq].nodes) if(! nd.isVisited) nd.isVisited = 1, q ~= nd;
			iq ++;
		}
		return q[$ - 1];
	}
	void setp(int d){
		this.isVisited = 1;
		this.dp = d;
		foreach(nd; nodes) if(! nd.isVisited) nd.setp(d + 1);
	}
	void setq(int d){
		this.isVisited = 1;
		this.dq = d;
		foreach(nd; nodes) if(! nd.isVisited) nd.setq(d + 1);
	}
	
	override string toString(){
		return id.to!string ~ "(" ~ dp.to!string ~ " " ~ dq.to!string ~ " " ~ d.to!string ~ ")" ~ nodes.map!(x => x.id.to!string).join(" ");
	}
}


Measured memory_bytes: 49532
import sys
from collections import deque
import heapq

def solve():
    input = sys.stdin.readline
    N, M, P = map(int, input().split())
    graph = [None for i in range(M)]
    for i in range(M):
        a, b, c = map(int, input().split())
        graph[i] = (a - 1, b - 1, P - c)

    gain = [10 ** 20 for i in range(N)]
    gain[0] = 0
    
    for i in range(N):
        update = False
        for efrom, eto, ecost in graph:
            if gain[efrom] < 10 ** 20 and gain[eto] > gain[efrom] + ecost:
                gain[eto] = gain[efrom] + ecost
                update = True
        if not update:
            print(max(-gain[N-1], 0))
            break
    else:
        possible_min = gain[N-1]
        for i in range(N):
            for efrom, eto, ecost in graph:
                if gain[efrom] < 10 ** 20 and gain[eto] > gain[efrom] + ecost:
                    gain[eto] = gain[efrom] + ecost

        if gain[N-1] == possible_min: print(max(-gain[N-1], 0))
        else: print(-1)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 46300
import std.stdio,
       std.array,
       std.conv,
       std.algorithm;

void main() {
  string s;
  while((s=readln()).length != 0) {
    string[] input = split(s);
    int pos = 1;
    int carry = 0;
    int lena = to!int(input[0].length);
    int lenb = to!int(input[1].length);
    while(true) {
      int a = lena<pos ? 0 : to!int(input[0][lena-pos]-'0');
      int b = lenb<pos ? 0 : to!int(input[1][lenb-pos]-'0');
      int res = a + b + carry;
      carry = res<10 ? 0 : 1;
      if(input[0].length <= pos && input[1].length <= pos) {
        if(carry) pos++;
        break;
      }
      pos++;
    }
    writeln(pos);
  }
}

Measured memory_bytes: 2404
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

using Pos = pair<int, int>; // h, w の順

int table[310][310];

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  string buf;

  vector<Pos> berries;

  int k = 1;
  for(int h = 1; h <= H; ++h) {
    cin >> buf;
    for(int i = 0; i < buf.size(); ++i) {
      int w = i + 1;
      if(buf[i] == '.') {
        table[h][w] = -1;
      } else {
        table[h][w] = k;
        berries.push_back(Pos(h, w));
        k++;
      }
    }
  }

  for(int i = 0; i < berries.size(); ++i) {
    auto bpos = berries[i];
    int no    = table[bpos.first][bpos.second];
    for(int l = bpos.second - 1; l > 0; --l) {
      if(table[bpos.first][l] != -1) {
        break;
      }
      table[bpos.first][l] = no;
    }
    for(int r = bpos.second + 1; r <= W; ++r) {
      if(table[bpos.first][r] != -1) {
        break;
      }
      table[bpos.first][r] = no;
    }
  }

  for(int h = 1; h <= H; ++h) {
    if(table[h][1] == -1) {
      // 高さhの列はいちごが置かれていなかった
      int limit = h;
      if(h < H) {
        for(int h2 = h; h2 <= H; ++h2) {
          if(table[h2][1] != -1) {
            limit = h2;
            break;
          }
        }
      } else {
        for(int h2 = h; h2 > 0; --h2) {
          if(table[h2][1] != -1) {
            limit = h2;
            break;
          }
        }
      }

      if(limit > h) {
        for(int h3 = limit - 1; h3 >= h; --h3) {
          for(int w = 1; w <= W; ++w) {
            table[h3][w] = table[h3 + 1][w];
          }
        }
      } else {

        for(int h3 = limit + 1; h3 <= h; ++h3) {
          for(int w = 1; w <= W; ++w) {
            table[h3][w] = table[h3 - 1][w];
          }
        }
      }
    }
  }

  for(int h = 1; h <= H; ++h) {
    for(int w = 1; w <= W; ++w) {
      if(w == W) {
        cout << table[h][w];
      } else {
        cout << table[h][w] << " ";
      }
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1912
#include<stdio.h>

int main(void){
    char c[3][4];
    int i;
    for(i=0;i<3;i++){
        scanf("%s",c[i]);
    }
    printf("%c%c%c\n",c[0][0],c[1][1],c[2][2]);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  string s;
  cin >> s;
  vector<int> v(4);
  rep(i,s.size()) {
    if (s[i] == 'N') v[0]++;
    else if (s[i] == 'S') v[1]++;
    else if (s[i] == 'E') v[2]++;
    else v[3]++;
  }
  bool b = true;
  rep(i,4) {
    if (!v[i]) b = false;
  }
  if (v[0] && v[1] && !v[2] && !v[3]) b = true;
  if (!v[0] && !v[1] && v[2] && v[3]) b = true;
  cout << (b? "Yes": "No") << endl;
}

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

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define LL long long
using namespace std ;
void Read ( LL &x, char c = getchar(), bool f = 0 ) {
	for ( x = 0 ; !isdigit(c) ; c = getchar() ) if (c == '-') f = 1 ;
	for ( ; isdigit(c) ; c = getchar() ) x = 10*x + c - '0' ;
}
const int modd = 1e9+7, maxn = 8005, base = 2001, N = 4002, maxN = 2e5+5 ;
LL f[4005][4005], ans = 0, n, m, a[maxN], b[maxN] ;
LL fac[8005], inv[8005] ;
LL Qpow ( LL a, LL b ) {
	LL rec = 1 ;
	for ( ; b ; b >>= 1, (a *= a) %= modd )
		if (b&1) (rec *= a) %= modd ;
	return rec ;
}
void init() {
	LL i ;
	fac[0] = 1 ;
	for ( i = 1 ; i <= 8000 ; i ++ ) fac[i] = fac[i - 1]*i%modd ;
	inv[8000] = Qpow(fac[8000], modd-2) ;
	for ( i = 8000 ; i ; i -- ) inv[i - 1] = inv[i]*i%modd ;
}
LL gn ;
LL C ( LL a, LL b ) {
	LL rec = fac[a] ;
	(rec *= Qpow(fac[b], modd-2)) %= modd ;
	(rec *= Qpow(fac[a-b], modd-2)) %= modd ;
	return rec ;
}
int main() {
	LL i, j, k ;
	init() ;
	Read(n) ;
	for ( i = 1 ; i <= n ; i ++ ) {
		Read(a[i]) ; Read(b[i]) ;
		++f[base-a[i]][base-b[i]] ;
		ans = (ans - C((a[i]+b[i])<<1,a[i]<<1) + modd)%modd ;	
	}
	for ( i = 1 ; i <= N ; i ++ )
		for ( j = 1 ; j <= N ; j ++ )
			(f[i][j] += (f[i - 1][j]+f[i][j - 1])%modd)%=modd ;
	for ( i = 1 ; i <= n ; i ++ ) (ans += f[base+a[i]][base+b[i]]) %= modd ;
	(ans *= Qpow(2, modd-2)) %= modd ;	
	printf ( "%lld\n", ans ) ;
	return 0 ;
}

Measured memory_bytes: 128768
MOD = 998244353

def beki(x, n):
  if n == 0:
    return 1
  if n % 2 == 0:
    return beki(x * x % MOD, n // 2) % MOD
  else:
    return x * beki(x, n - 1) % MOD


N = int(input())
Orig = list(map(int, input().split()))
D = sorted(Orig)

ans = 1
cnt = 1
precnt = 1

if Orig[0] != 0:
    ans = 0
if N >= 2 and D[1] == 0:
    ans = 0

for i in range(N-1):
    if D[i] == D[i+1]:
        cnt += 1

    elif D[i] + 1 != D[i+1]:
        ans = 0
        break

    else:
        ans *= beki(precnt, cnt)
        ans %= MOD
        precnt = cnt
        cnt = 1
        if (i == N-1):
            break
else:
    ans *= beki(precnt, cnt)
    ans %= MOD

print(ans)



Measured memory_bytes: 14004
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define rev(r) reverse(r.begin(),r.end())
#define SORT(ar) sort(ar.begin(), ar.end())
#define sz(x) (int)(x).size()
#define len(x) (int)x.length()
#define in(a) scanf("%d",&a)
#define pr(x) printf("%d ",x)
#define endl '\n'
#define read(v,n) for(int h=0;h<n;h++) cin>>v[h];
#define fo(i,a,b) for(i=a;i<b;i++)
#define fi(i,a,b) for(i=a;i>=b;i--)
#define mo 1000000007
#define N 300007
ll dp[101][100001];

int main()
{
    ll n,W,i,j,ans=0;
    cin>>n>>W;
    ll w[n+1],v[n+1];
    fo(i,1,n+1) cin>>w[i]>>v[i];
    fo(i,1,n+1)
    {
        fo(j,1,100001)
        {
            if(v[i]>j) dp[i][j]=dp[i-1][j];
            else if(j==v[i]){
                dp[i][j]=w[i];
                if(dp[i-1][j]>0) dp[i][j]=min(dp[i][j],dp[i-1][j]);
            }
            else {
                if(dp[i-1][j]>0 && dp[i-1][j-v[i]]>0) dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
                else if(dp[i-1][j-v[i]]>0) dp[i][j]=dp[i-1][j-v[i]]+w[i];
                else dp[i][j]=dp[i-1][j];
            }
            if(dp[i][j]>0 && dp[i][j]<=W) ans=max(ans,j);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 78336
using System;
using System.Linq;

public static class Program
{
    static int n;
    public static void Main(string[] args)
    {
      n = int.Parse(Console.ReadLine());
      int[] S = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
      int q = int.Parse(Console.ReadLine());
      int[] T = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

      int count = 0;
      for(int i = 0; i < q; i++)
      {
        if(Count(S, T[i]))
        {
          count++;
        }
      }

      Console.WriteLine(count);
    }

    public static bool Count(int[] S, int target)
    {
      int l = 0;
      int r = n;

      while(l < r)
      {
        int mid = (l + r) / 2;
        if(S[mid] < target)
        {
          l = mid + 1;
        }
        else if(target < S[mid])
        {
          r = mid;
        }
        else
        {
          return true;
        }
      }

      return false;
    }
}



Measured memory_bytes: 22872