akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

#define max(a, b) ((a) < (b) ? (b) : (a))

int main(){
  int Q;
  scanf("%d", &Q);
  
  while(Q--){
    long long A, B;
    scanf("%lld%lld", &A, &B);
    
    long long num = 0;
    
    long long ng = max(A, B);
    long long ok = 0;
    while(ng - ok > 1){
      long long mid = (ok + ng) / 2;
      if(mid < (A * B - 1) / mid) ok = mid;
      else ng = mid;
    }
    
    num += 2 * ok;
    if(ok >= A || ok >= B) num--;
    if(ok + 1 != A && ok + 1 != B && (ok + 1) * (ok + 1) < A * B) num++;
    
    printf("%lld\n", num);
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29

int main(){
	int n, k, h[100100], dp[100100];
	cin >> n >> k;
	rep(i, n) dp[i] = INF;
	dp[0] = 0;
	rep(i, n) cin >> h[i];
	rep(i, n) {
		for(int j = 1; j <= k; j++) {
			if (i >= j) dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
		}
	}
	cout << dp[n - 1] << endl;
}



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

using namespace std;

int main() {
    int count = 0;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < s.size(); j++) {
            if (s[i] == s[j]) {
                count++;
            }
        }
        if (count >= 2) break;
        count = 0;
    }

    if (count >= 2)cout << "no" << endl;
    else cout << "yes" << endl;

    return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn.readLine

object Main extends App {
  val Array(h, w) = readLine.split(" ").map(_.toLong)

  def calc(h: Long, w: Long): Long = {
    1L.to(h / 2).map({ i =>
      val s1 = i * w

      val l = h - i
      val s2 = l / 2 * w
      val s3 = (l - l / 2) * w

      val s4 = w / 2 * l
      val s5 = (w - w / 2) * l

      val min1 = Seq(s1, s2, s3).min
      val max1 = Seq(s1, s2, s3).max

      val min2 = Seq(s1, s4, s5).min
      val max2 = Seq(s1, s4, s5).max

      math.min(max1 - min1, max2 - min2)
    }).min
  }

  println(math.min(calc(h, w), calc(w, h)))

}

Measured memory_bytes: 77160
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    int n;
    cin >> n;
    V<ll> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    ll ans = 0;
    rep(i, 30) {
        V<ll> A(n);
        ll t = 1 << i;
        rep(j, n) A[j] = a[j] & 2 * t - 1;
        sort(ALL(A));
        ll cnt = 0;
        rep(j, n) {
            ll B = b[j] & 2 * t - 1;
            cnt += lower_bound(ALL(A), 2 * t - B) - lower_bound(ALL(A), t - B);
            cnt +=
                lower_bound(ALL(A), 4 * t - B) - lower_bound(ALL(A), 3 * t - B);
        }
        ans += (cnt & 1) << i;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
a,b,c,d,e,f = map(int, input().split())

x = []
y = []

k=0
i = 0
j = 0

#print(a,b,c,d,e,f)

while( 100*a*i + 100*b*j <= f ):
  while( 100*a*i + 100*b*j <= f):
    x.append(100*a*i + 100*b*j)
    j +=1
  j = 0
  i +=1
  
i = 0
j = 0
while( c*i + d*j <= f ):
  while( c*i + d*j <= f):
    y.append(c*i + d*j)
    j +=1
  j = 0
  i +=1
      
    
x = list(set(x))
y = list(set(y))

x.remove(0)
#y.remove(0)
#print( x )
#print( y )

noudo = 0
reg_i = 0
reg_j = 0

for i in range(len(x)):
  for j in range(len(y)):
    tmp_noudo = 100 * y[j] / (x[i] + y[j])
    if  tmp_noudo <= 100 * e / (100 + e) and (x[i] + y[j]) <= f:
      if noudo < tmp_noudo:
        noudo = tmp_noudo
        reg_i = i
        reg_j = j
        

print( x[reg_i]+y[reg_j] , y[reg_j] )

Measured memory_bytes: 12476
#include <bits/stdc++.h>
using namespace std;
int MAX = 2500;
int main(){
  int N, A;
  cin >> N >> A;
  vector<int> x(N);
  for (int i = 0; i < N; i++){
    cin >> x[i];
    x[i] -= A;
  }
  vector<int> neg, pos;
  int zero = 0;
  for (int i = 0; i < N; i++){
    if (x[i] < 0){
      neg.push_back(-x[i]);
    } else if (x[i] > 0){
      pos.push_back(x[i]);
    } else {
      zero++;
    }
  }
  vector<int> dpN(MAX, 0);
  dpN[0] = 1;
  for (int i = 0; i < neg.size(); i++){
    for (int j = MAX - 1; j >= neg[i]; j--){
      dpN[j] += dpN[j - neg[i]];
    }
  }
  vector<int> dpP(MAX, 0);
  dpP[0] = 1;
  for (int i = 0; i < pos.size(); i++){
    for (int j = MAX - 1; j >= pos[i]; j--){
      dpP[j] += dpP[j - pos[i]];
    }
  }
  long long M = (long long) 1 << zero;
  long long ans = 0;
  for (int i = 0; i < MAX; i++){
    ans += (long long) dpN[i] * dpP[i];
  }
  ans *= M;
  ans--;
  cout << ans << endl;
}

Measured memory_bytes: 256
// Problem : C - Connect Cities
// Contest : AtCoder - ACL Beginner Contest
// URL : https://atcoder.jp/contests/abl/tasks/abl_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Delete the dynamically allocated memory

#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define pb              push_back
#define pr              pair<long long,long long>
#define mp(a,b)         make_pair(a,b)
#define vr              vector<long long>
#define mod1            1000000007
#define mod2            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define fill(a,b)       memset(a, b, sizeof(a))
#define mk(arr,n,type)  type *arr=new type[n];
#define ll              long long
#define ld	            long double
#define w(x)            int x; cin>>x; while(x--)

void print(vr* edges,ll n,ll s,bool* visited){
	visited[s]=true;
	for(ll i=0;i<edges[s].size();i++){
		if(!visited[edges[s][i]]){
			print(edges,n,edges[s][i],visited);
		}	
	}
	return;
}

void DFS(vr* edges,ll n){
	mk(visited,n,bool)
	for(ll i=0;i<n;i++){
		visited[i]=false;
	}
	ll cnt=0;
	for(ll i=0;i<n;i++){
		if(!visited[i]){
			print(edges,n,i,visited);
			cnt++;
		}
	}
	cout<<cnt-1<<"\n";
	delete[] visited;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,m;
	cin>>n>>m;
	mk(edges,n,vr)
	for(ll i=0;i<m;i++){
		ll f,s;
		cin>>f>>s;
		edges[f-1].pb(s-1);
		edges[s-1].pb(f-1);
	}
	DFS(edges,n);
	delete[] edges;
	return 0;
	} 
	
	
	
	
	
	
	



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

int main()
{  
    int n;
    cin>>n;
    set<int>s;
    REP(i,n)
    {
        int x,y;
        cin>>x>>y;
        if(x==0){s.insert(y);cout<<s.size()<<endl;}
        if(x==1)
        {
            if(s.find(y)==s.end())cout<<0<<endl;
            else cout<<1<<endl;
        }
    }
}



Measured memory_bytes: 12364
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <algorithm>

using   namespace std;

const long long int MOD = 1000000007;
const long long int INF = 100000000;
long long int N,M;
long long int C[30];
long long int dp[21][100000];

int DP(int n,int v)
{
	if(n<0||v<0) return INF;

	if(dp[n][v]!=-1) return dp[n][v];
	return dp[n][v] = min(DP(n-1,v),DP(n,v-C[n])+1);
}

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

		for(int i = 0; i < M; i++){
			cin>>C[i];
		}

    memset(dp,-1,sizeof(dp));

		for(int i = 0; i < 21; i++){
			dp[i][0]=0;
		}
    cout << DP(M - 1,N) << endl;

		return 0;
}



Measured memory_bytes: 19564
s = input()
q = int(input())

from collections import deque

flip = False
deq = deque(s)

for _ in range(q):
    query = input().split(' ')
    if len(query)==1:
        flip = not flip
    else:
        f,c = int(query[1])-1,query[2]
        if flip ^ f:
            deq.append(c)
        else:
            deq.appendleft(c)

if flip:
    deq.reverse()

res =""
for c in deq:
    res+=c

print(res)


Measured memory_bytes: 6880
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args)throws Exception {
    	InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);

        while(true){
        	String[] input = br.readLine().split(" ");
        	int H = Integer.parseInt(input[0]);
        	int W = Integer.parseInt(input[1]);
        	if(H == 0 && W == 0){
        		break;
        	}
        	for(int x = 0 ; x < H ; x++){
        		for(int y = 0; y < W ; y++){
        			if(x > 0 && H - 1 > x && y > 0 && W - 1 > y ){
        				System.out.print(".");
        			}else{
        				System.out.print("#");
        			}
        		}
        		System.out.println();
        	}
        	System.out.println();
        }
    }
}

Measured memory_bytes: 31708
/*
ID: computerbox --> Huseyn Hajiyev
LANG: C++
TASK: target_mode_on
*/
#include <bits/stdc++.h>
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define _CRT_SECURE_NO_WARNINGS
//#include <boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
#define FAST_READ ios_base::sync_with_stdio(0);cin.tie(0);
#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define COUT(n, a) cout<< fixed << setprecision(a) << n<<endl
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";
#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl
#define DTIME(ccc) __begin = clock(); ccc; cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<endl;
#define MAXN 2000

using namespace std;

ll a,b;

int main(){
FAST_READ;
cin>>a>>b;
cout<<a*b-a-(b-1)<<endl;







return 0;
} 


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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

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

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

bool hantei(vector<ll> &a,vector<ll> &f,ll k,ll score){
	ll n = a.size();
	ll cnt=0;
	rep(i,n){
		cnt += max(0LL,a[i]-(score)/f[i]);
	}

	return cnt<=k;
}

int main()
{
	ll n,k;
	cin>>n>>k;
	vector<ll> a(n),f(n);
	rep(i,n)cin>>a[i];
	rep(i,n)cin>>f[i];

	if(accumulate(all(a),0LL)<=k){
		cout<<0<<endl;
		return 0;
	}

	sort(all(a));
	sort(all(f));
	reverse(all(f));

	ll low=0,high=1e12;

	while(low+1<high){
		ll mid=(low+high)/2;
		if(hantei(a,f,k,mid)){
			high=mid;
		}else{
			low=mid;
		}
	}

	cout<<(hantei(a,f,k,low)?low:high)<<endl;

	return 0;
}

Measured memory_bytes: 3328
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
from functools import lru_cache
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# slist = "abcdefghijklmnopqrstuvwxyz"
N = int(input())

@lru_cache(maxsize=1000)
def lucas_number(n) -> int:
    if n<0:
        return -1
    if n==0:
        return 2
    elif n==1:
        return 1
    else:
        return lucas_number(n-1)+ lucas_number(n-2)

ans = lucas_number(N)

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 3684
from math import modf
N, D=map(int,input().split())
lis = []
for i in range(N):
   li = list(map(int,input().split()))	
   lis.append(li)
res = 0
ans = 0
for i in range (N):
   for j in range(i+1,N):
      for k in range(D):
         a = lis[i][k]-lis[j][k]
         res += a ** 2
      b = res ** 0.5
      decimal, integer = modf(b)
      if (decimal == 0):
         ans += 1
      res = 0
print(ans)

Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func main() {
	var r int
	fmt.Scan(&r)

	if r < 1200 {
		fmt.Println("ABC")
	} else if r < 2800 {
		fmt.Println("ARC")
	} else {
		fmt.Println("AGC")
	}
}

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

int n,d[1000000],ans;

string s[100000],s1;

bool b;

int main(){
   cin >> n;
   for(int i = 0; i < n; i++){
       cin >> s[i] >> d[i];
   }
   cin >> s1;
   for(int i = 0; i < n; i++){
       if(b == true){
        ans += d[i];
       } else if(s[i] == s1) b = true;
   }
   cout << ans;
}


Measured memory_bytes: 1024
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

def check(d1,d2):
    end = int(d2**(1/4))
    for A in range(end+1):
        B = A - d1
        test = A**4 + A**3*B + A**2*B**2 + A*B**3 + B**4
        if test == d2:
            return True, A, B
    return False, 0, 0
    

X = int(input())
div = make_divisors(X)
#print(div)

for d in div:
    f, A, B = check(d, X//d)
    if f:
        print(A, B)
        break

Measured memory_bytes: 9412
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datN, datY) = readLine.split(" ").map(_.toInt)

    for (x <- 0 to datN; y <- 0 to (datN - x)) {
      val z = datN - x - y
      val sum = x * 1000 + y * 5000 + z * 10000
      if (sum == datY) {
        println(z + " " + y + " " + x)
        return
      }
    }
    println("-1 -1 -1")
  }
}


Measured memory_bytes: 27196
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, a[maxn];
bool calc()
{
	int odd = 0;
	bool one = 0;
	for(int i = 1; i <= n; ++i) 
	{
		if(a[i] == 1) one = 1;
		if(a[i] & 1) ++odd;
	}
	if(odd > 1 || one) return !(odd & 1);
	int d = 0;
	for(int i = 1; i <= n; ++i) 
	{
		if(a[i] & 1) --a[i];
		d = __gcd(d, a[i]);
	}
	for(int i = 1; i <= n; ++i) a[i] /= d;
	return !calc();
}
int main()
{
	scanf("%d", &n);
	if(!(n & 1))
	{ 
		bool cnt = 0;
		for(int i = 1; i <= n; ++i)
		{
			scanf("%d", &a[i]);
			if(!(a[i] & 1)) cnt ^= 1;
		}
		if(cnt) puts("First");
		else puts("Second");
	}
	else
	{
		for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
		if(calc()) puts("First");
		else puts("Second");
	}
	return 0;
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = INF + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 1000 * 1000 + 13;

int n, h, d;

bool read () {
	if (scanf("%d%d%d", &n, &h, &d) != 3)
		return false;
	return true;
}

int add(int a, int b){
	a += b;
	if (a >= MOD)
		a -= MOD;
	if (a < 0)
		a += MOD;
	return a;
}

int mul(int a, int b){
	return (a * li(b)) % MOD;
}

int dp[N];
int pr[N];

int get(int l, int r){
	return add(pr[r + 1], -pr[l]);
}

int fact[N];
int prfact[N];

void solve() {
	fact[0] = 1;
	prfact[1] = 0;
	fore(i, 1, N - 1){
		fact[i] = mul(fact[i - 1], i);
		prfact[i + 1] = add(prfact[i], fact[i]);
	}
	dp[0] = fact[n];
	pr[1] = dp[0];
	fore(i, 1, h + 1){
		dp[i] = mul(prfact[n + 1], get(max(0, i - d), i - 1));
		pr[i + 1] = add(pr[i], dp[i]);
	}
	printf("%d\n", get(h - d, h - 1));
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
	
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

#ifdef _DEBUG
	while(read()) {	
#else
	if (read()){
#endif
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

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

namespace AtCoderABC115
{
    class Program
    {
        public static void Main(string[] args)
        {
            int D = int.Parse(Console.ReadLine());
            Console.WriteLine(
                (D == 25)? "Christmas":
                (D == 24)? "Christmas Eve":
                (D == 23)? "Christmas Eve Eve":
                "Christmas Eve Eve Eve"
            );
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

string S, T;

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

  cin >> S >> T;

  int ans = 0;
  for (int i = 0; i < len(S); ++i) {
    if (S[i] == T[i]) ++ans;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <tr1/unordered_map>
#include <cmath>
#include <algorithm>

using namespace std;

typedef long long LL;

const int MAXN = 1e05 + 10;
const int MAXM = 2200 + 10;

int N;
LL a[MAXN], newa[MAXN]= {0};

int prime[MAXM]= {0}, pcnt = 0;
bool visit[MAXM]= {false};
const int MAX = 2200;
void sieve () {
	for (int i = 2; i <= MAX; i ++) {
		if (visit[i]) continue;
		prime[++ pcnt] = i;
		for (int j = i << 1; j <= MAX; j += i)
			visit[j] = true;
	}
}

tr1::unordered_map<LL, int> mapp, ccnt;
int ind = 0;
inline LL power (LL x, int p) {
	LL cnt = 1;
	for (int j = 1; j <= p; j ++)
		cnt *= x;
	return cnt;
}
pair<LL, LL> save[MAXN];
int solve () {
	int ans = 0;
	save[++ ind] = make_pair (1, 0);
	mapp[0] = mapp[1] = 1;
	for (int i = 1; i <= N; i ++) {
		LL p = a[i];
		LL cnt = 1, ano = 1;
		for (int j = 1; j <= pcnt; j ++)
			if (! (p % prime[j])) {
				int times = 0;
				while (! (p % prime[j]))
					p /= prime[j], times ++;
				times %= 3;
				if (times > 0)
					ano *= power (prime[j], 3 - times);
				cnt *= power (prime[j], times);
			}
		// cout << "orin: " << a[i] << " and " << cnt << ' ' << ano << ' ' << p << endl;
		if (a[i] != 1 && cnt == 1 && p == 1) {
			ccnt[0] ++;
			continue;
		}
		ccnt[cnt * p] ++, newa[i] = cnt * p;
		if (mapp[cnt * p]) continue;
		if (p > 1) {
			LL sqr = sqrt (p);
			if (sqr * sqr == p) {
				// cout << "Suc: " << a[i] << endl;
				save[++ ind] = make_pair (cnt * p, ano * sqr);
				mapp[cnt * p] = mapp[ano * sqr] = ind;
			}
		}
		else {
			save[++ ind] = make_pair (cnt, ano);
			mapp[cnt] = mapp[ano] = ind;
		}
	}
	ccnt[0] = min (ccnt[0], 1), ccnt[1] = min (ccnt[1], 1);
	/*for (int i = 1; i <= ind; i ++) {
		cout << save[i].first << ' ' << save[i].second << ' ';
		cout << "and " << ccnt[save[i].first] << ' ' << ccnt[save[i].second] << endl;
	}*/
	for (int i = 1; i <= ind; i ++)
		ans += max (ccnt[save[i].first], ccnt[save[i].second]);
	/*for (int i = 1; i <= N; i ++)
		cout << newa[i] << ' ';
	puts ("");*/
	for (int i = 1; i <= N; i ++)
		if (! mapp[newa[i]])
			ans ++;
	return ans;
}

template<typename T>
T getnum () {
	T num = T ();
	char ch = getchar ();

	while (! isdigit (ch))
		ch = getchar ();
	while (isdigit (ch))
		num = (num << 3) + (num << 1) + ch - '0', ch = getchar ();

	return num;
}

int main () {
	N = getnum<int> ();
	for (int i = 1; i <= N; i ++)
		a[i] = getnum<LL> ();
	sieve ();
	int ans = solve ();
	cout << ans << endl;

	return 0;
}

/*
8
1
2
3
4
5
6
7
8
*/

/*
6
2
4
8
16
32
64
*/

/*
10
1
10
100
1000000007
10000000000
1000000009
999999999
999
999
999
*/

/*
10
1
10
100
2368593037
38192375
218391929
572421321
2
16
32
*/

Measured memory_bytes: 15596
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	if(n<105){
		cout<<0;
	}else if(n==105){
		cout<<1;
	}else{
		int n8=0;
		for(int i=107;i<=n;i+=2){
//			cout<<i<<endl;
			int f=0;
			for(int j=1;j<=n;j++){
				if(i/j*j==i){
					f++;
				}
			}
			if(f==8){
				n8++;
			}
		}
		cout<<n8+1;
	}
	return 0;
}

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

void solve(int n,int k){
    unsigned long long int ans=1,a,b;
    double mul=(double)k/(k-1);
    for(int i=0;i<n-1;i++){
        a=ans/(k-1);
        b=ans%(k-1);
        b*=k;
        if(b%(k-1))b=b/(k-1)+1;
        else b=b/(k-1);
        ans=a*k+b;
    }
    cout<<ans-1<<endl;
}
int main(void){
    int a,b;
    while(cin>>a>>b){
        solve(a,b);
    }
    
}

Measured memory_bytes: 3100
#include <stdio.h>

int main (){
  int a,b;
  int c[15];
  scanf("%d%d", &a, &b);

  if (a>b){
    for (int i = 0; i < a; i++){
      c[i]=b;
      printf("%d", c[i]);
    }
  }
  else {
    for (int i = 0; i < b; i++){
      c[i]=a;
      printf("%d", c[i]);
    }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

int main(){
    char s[201],p[101],q[101];

    cin >> s >> p;
    strcpy(q,s);
    strcat(s,q);

    if(strstr(s,p)==NULL){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;}

    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

string s;
vector<string> vs;
int cnt[26] = {};

void dfs(string t, int lev) {
  if (lev == (int)s.size()) {
    vs.emplace_back(t);
    return;
  }
  int pos = s[lev] - 'a';
  if (s[lev] == 'a' || cnt[pos]) {
    cnt[pos]++;
    dfs(t + s[lev], lev + 1);
    cnt[pos]--;
  }
  if (s[lev] < 'z' && !cnt[pos + 1]) {
    cnt[pos + 1]++;
    dfs(t + char(s[lev] + 1), lev + 1);
    cnt[pos + 1]--;
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  while (cin >> s, s != "#") {
    vs.clear();
    dfs("", 0);
    cout << vs.size() << endl;
    if ((int)vs.size() <= 10) {
      for (string v : vs) {
        cout << v << endl;
      }
    } else {
      sort(vs.begin(), vs.end());
      for (int i = 0; i < 5; i++) {
        cout << vs[i] << endl;
      }
      for (int i = 4; i >= 0; i--) {
        cout << vs[vs.size() - 1 - i] << endl;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 4400
package main
import(
  "fmt"
  "bufio"
  "os"
  "strconv"
)
var sc=bufio.NewScanner(os.Stdin)
func nextInt() int64{
  sc.Scan()
  i, e :=strconv.ParseInt(sc.Text(), 10, 64)
  if e!=nil{
    panic(e)
  }
  return i
}
func max(a *int64, b int64)bool{
  if *a<b{
    *a=b 
    return true
  }
  return false
}
func main(){
  var i, sum int64
  dp:=make([][]int64, 110)
  sc.Split(bufio.ScanWords)
  n:=nextInt()
  w:=nextInt()
  a:=make([]int64, 110)
  b:=make([]int64, 110)
  for i=0;i<n;i++{
    a[i]=nextInt()
    b[i]=nextInt()
  }
  for i=0;i<110;i++{
    dp[i]=make([]int64, 100100)
  }
  for i=0;i<n;i++{
    for sum=0;sum<=w;sum++{
      if sum-a[i]>=0{
        max(&dp[i+1][sum], dp[i][sum-a[i]]+b[i])
      }
      max(&dp[i+1][sum], dp[i][sum])
    }
  }
  fmt.Println(dp[n][w])
}

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

class Program
{
    //A, C, G, T が存在し、A と T、C と G がそ

    static void Main(string[] args)
    {
        var conv = new Dictionary<string, string>()
        {
            ["A"] = "T",
            ["T"] = "A",
            ["C"] = "G",
            ["G"] = "C",
        };


        var aa = Console.ReadLine();
        Console.WriteLine(conv[aa]);
    }
}


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

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

	int tmp = N;
	int S = 0;

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

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

Measured memory_bytes: 256
class DisjointSet:
    def __init__(self, size):
        self.rank = []
        self.parent = []
        for i in range(size):
            self.makeSet(i)

    def makeSet(self, x):
        self.parent.append(x)
        self.rank.append(0)

    def isSame(self, x, y):
        return self.findSet(x) == self.findSet(y)

    def unite(self, x, y):
        self.link(self.findSet(x), self.findSet(y))

    def link(self, x, y):
        if self.rank[x] > self.rank[y]:
            self.parent[y] = x
        else:
            self.parent[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def findSet(self, x):
        # Recursively invoke findSet() until it reaches to the parent (root)
        if x != self.parent[x]:
            self.parent[x] = self.findSet(self.parent[x])
        return self.parent[x]


import sys
# sys.stdin = open('input.txt')

n, q = map(int, input().split())
disjointSet = DisjointSet(n)

for i in range(q):
    com, x, y = map(int, input().split())
    if com == 0:
        disjointSet.unite(x, y)
    else:
        if disjointSet.isSame(x, y):
            print(1)
        else:
            print(0)


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

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int t = 0;
    for (char c : S) if (c == '.') t++;
    int ans = t; 
    for (char c : S) {
        if (c == '.') t--;
        if (c == '#') t++;
        ans = min(ans, t);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    private static Scanner sc;
    private static int N;

    public static void main(String[] args) {

        sc = new Scanner(System.in);
        N = sc.nextInt();

        System.out.println(solve() ? "YES" : "NO");

    }

    private static boolean solve() {
        Set<Long> set = new HashSet<>();

        for (int i = 0; i < N; i++) {
            if (!set.add(sc.nextLong())) {
                return false;
            }
        }
        return true;
    }

}


Measured memory_bytes: 101296
from collections import Counter
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
c = Counter(A)
diff = len(c.keys()) - K
if diff<=0:
    print(0)
else:
    c_s = sorted(c.items(), key=lambda x: x[1])
    cnt=0
    for _, value in c_s:
        cnt += value
        diff -= 1
        if diff==0:
            break
    print(cnt)
        



Measured memory_bytes: 39320
n = int(raw_input())
nums = map(int, raw_input().split(' '))
nums.sort()
r = 0


for c in range(2, n):
	a,b = 0, c - 1

	for a in range(c - 1):
		lo,hi = a+1, c-1
		while(lo < hi):
			med = (lo + hi) / 2
			if nums[a] + nums[med] > nums[c]:
				hi = med
			else:
				lo = med + 1
		
		r += (c - lo) if (nums[a] + nums[lo] > nums[c]) else (0)
print r

Measured memory_bytes: 33128
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::cmp::{min, max};
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn gcd(mut a: i32, mut b: i32) -> i32 {
    while b != 0 {
        let r = a % b;
        a = b; b = r;
    }
    a
}
fn lcm(x: i32, y: i32)->i32{
    return x /gcd(x, y) * y;
}
fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
   input!{
       n: i32, d: i32,
   } 
   let r = 2 * d + 1;
   let ans = if n%r == 0 {n/r}else{n/r + 1};
   println!("{}", ans);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

Measured memory_bytes: 8572
//Md Fahad
// CSE 18

#include<bits/stdc++.h>

using  namespace  std;

#define PI              acos(-1.0)
#define lcm(a,b)        (a * (b / __gcd(a,b)))
#define en '\n'

#define READ_IN freopen("Input.txt","r",stdin);
#define READ_OUT freopen("Output.txt","w",stdout);
#define Infi                0x3f3f3f3f

const int fx[] = {+1,-1,+0,+0};                         // 4 X directions
const int fy[] = {+0,+0,+1,-1};                         // 4 Y directions
const int fx8[] = {+0,+0,+1,-1,-1,+1,-1,+1};            // King X Moves
const int fy8[] = {-1,+1,+0,+0,+1,+1,-1,-1};            // King Y Moves
const int kx[] = {-2, -2, -1, -1,  1,  1,  2,  2};      // Knight X Moves
const int ky[] = {-1,  1, -2,  2, -2,  2, -1,  1};      // Knight Y Moves



int  Set    (int N,int pos) {return N=N | (1<<pos);}    /// turn a bit on
int  reset  (int N,int pos) {return N= N & ~(1<<pos);}  /// turn a bit off
bool check  (int N,int pos) {return (bool)(N & (1<<pos));} /// check, if a bit is on or not

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define trace(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define trace(x...)
#endif

typedef long long int           ll;
typedef unsigned long long int  llu;


int main(void)
{
   //READ_IN;
    //READ_OUT;
    int n;
    cin >> n;

    vector<string> a;

    for(int i=0;i<n;i++){

        string x; cin >> x;
        a.push_back(x);

    }
    map<string,int> mm;

    for(int i=0;i<n;i++){
        mm[a[i]]++;
    }

    int maxe=0;

    for(auto it:mm){

        maxe = max(maxe,it.second);
    }
    vector<string> ans;
    for(auto it:mm){

        if(it.second==maxe){
                ans.push_back(it.first);
        }
    }
    sort(ans.begin(),ans.end());

    for(int i=0;i<ans.size();i++){
        cout << ans[i] << endl;
    }



    return 0;
}



Measured memory_bytes: 28528
#include<iostream>
using namespace std;
int main (void)
{
  int a,b,c,d,aa,bb;
  cin>>a>>b>>c>>d;
  aa=a/d;
  bb=c/b;
 // cout<<aa<<" "<<bb<<endl;
  if(a%d!=0){aa++;}
  if(c%b!=0){bb++;}
  if(aa>=bb){cout<<"Yes";}
  else cout<<"No";

}

Measured memory_bytes: 3580
// hackerearth incom
        #include <bits/stdc++.h>

        using namespace std;

        typedef long long ll;
        const ll N = 5e5+5;
        const ll MOD = 1000000007;
        #define all(x) x.begin(),x.end()
        #define pii pair<ll,ll>
        #define pis pair<ll,string>
        #define F first
        #define S second
        #define LCM(a,b) ((a*b)/__gcd(a,b))
        #define inf 1e15
        #define test ll cse;cin>>cse;for(ll _i=1;_i<=cse;_i++)
        #define PI 3.14159265
        #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
        const double EPS = 1E-9;
        typedef vector<vector<double>> matrix;
        typedef vector<int> vi;


int main(){

    fast;
    int n;
    ll ar[N];
    ll dp[N];
    memset(ar, 0, sizeof ar);
    memset(dp, 0, sizeof dp);

    cin >> n;
    for(int i = 1; i <= n; i++) cin >> ar[i];
    for(int i = 1; i <= n; i++) dp[i] = (dp[i-1] + ar[i]) % MOD;

    ll ans = 0;

    for(int i = 1; i <= n; i++) {
        ll A = (dp[n] - dp[i] + MOD) % MOD;
        ll B = (ar[i]) % MOD;

        ans = (ans % MOD + (A*B) % MOD) % MOD;
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 11456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MOD = 1e9 + 7;
const int INF = 2e9;
#define pb push_back
#define mp make_pair
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
    int l, r, ans = INF;
    cin >> l >> r;
    if(l%2019==0 || r%2019==0){
        ans = 0;
    } 
    else{
        for (int i = l/2019; i < (r/2019)+1; i++){
            if(l<i*2019 && i*2019<r){
                ans = 0;
                break;
            }
        }
    }
    if(ans == INF){
        for (int i = l; i < r; i++){
            for (int j = l + 1; j <= r; j++){
                ans = min(ans, ((i % 2019) * (j % 2019)) % 2019);
            }
        }
    }
    cout << ans << endl;
}

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

int main() {

    int n;
    cin >> n;
    vector<int> v(n);
    int sum = 0;

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

    sort(v.begin(), v.end());

    auto isCorrect = [&](int a, int b, int c) {
        return v[c] < v[a] + v[b];
    };

    for(int i = 0; i < n - 2; ++i) {
        for(int j = i + 1; j < n - 1; ++j) {

            if(j == n - 2) {
                sum += isCorrect(i, j, n - 1);
                break;
            }

            int left = j + 1;
            int right = n;
            int mid;
            while(right - left > 1) {
                mid = (left + right) / 2;
                
                if(isCorrect(i, j, mid)) 
                    left = mid;
                else
                    right = mid;
               //  cout << left << " " << right << endl;
            }
            
            if(isCorrect(i, j, left))
                sum += left - j;

/*
            cout << i << ":" << j << " : " << left << endl;
            cout << "left = " << left << ", " << "right = " << right << endl;
            cout << v[i] << "+" << v[j] << " = " << v[i] + v[j] << " : " << v[left] << endl;
            cout << endl;
*/

        }

    }
    
    cout << sum << endl;

    return 0;

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int a,b;
	cin>>a>>b;
	puts(a!=2&&b!=2?"Yes":"No");
}


Measured memory_bytes: 256
#include <stdio.h>

#define N 100

int main() {
	int n;
	double ans;

	scanf("%d", &n);
	ans = 0;
	while (n--) {
		int a;

		scanf("%d", &a);
		ans += (double) 1 / a;
	}
	printf("%f\n", 1 / ans);
	return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		HashMap<Integer, Integer> map = new HashMap<>();
		map.put(0, 1);
		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum += sc.nextInt();
			sum %= m;
			Integer x = map.get(sum);
			if (x == null) {
				x = 0;
			}
			map.put(sum, x + 1);
		}
		long count = 0;
		for (int x : map.values()) {
			count += (long)x * (long)(x - 1) / (long)2;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 61208
import java.util.Scanner;
class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int ans=0;
        String day=sc.next();
        String[]week={"SUN","MON","TUE","WED","THU","FRI","SAT"};
        for(int i=week.length-1;i>0;i--){
            if(day.equals(week[i])){;break;}
            else{ans++;}
        }
        System.out.println(ans+1);
    }
}

Measured memory_bytes: 21844
import java.io.InputStreamReader;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		try(Scanner scan = new Scanner(new InputStreamReader(System.in))){
			String line = scan.nextLine();
			
			int n = 0;
			int s = 0;
			int w = 0;
			int e = 0;
			
			for(char c : line.toCharArray()){
				switch(c){
				case 'N':
					n = 1;
					break;
				case 'S':
					s = 1;
					break;
				case 'W':
					w = 1;
					break;
				case 'E':
					e = 1;
					break;
				}
			}
			
			if(n - s == 0 && w - e == 0){
				System.out.print("Yes");
			}else{
				System.out.print("No");				
			}
		}
	}
}


Measured memory_bytes: 8660
import sys
from collections import deque

input = sys.stdin.readline

N = int(input())

graph = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

check = [0] * (N + 1)
que1 = deque() #fennecのキュー
que2 = deque() #sunukeのキュー

que1.append(1)
que2.append(N)

check[1] = 1
check[N] = 1

fennec = 0
snuke = 0

flag = True

while flag:
    flag = False

    tmp_lst = []
    while len(que1) != 0:
        flag = True
        tmp = que1.popleft()
        for next_ in graph[tmp]:
            if check[next_] == 0:
                tmp_lst.append(next_)
                fennec += 1
                check[next_] = 1
    for i in tmp_lst:
        que1.append(i)
    
    tmp_lst = []
    while len(que2) != 0:
        flag = True
        tmp = que2.popleft()
        for next_ in graph[tmp]:
            if check[next_] == 0:
                tmp_lst.append(next_)
                snuke += 1
                check[next_] = 1
    for i in tmp_lst:
        que2.append(i)

if fennec > snuke:
    print ('Fennec')
else:
    print ('Snuke')

Measured memory_bytes: 22232
import math

n,k = map(int, input().split())

def main(i):
  blue = int(math.factorial(k-1) // (math.factorial(i-1) * math.factorial(k-i)))
  red = int(math.factorial(n-k+1) // (math.factorial(n-k+1-i) * math.factorial(i)))
  print((blue*red) % (10**9 + 7))

for i in range(1, k+1):
  if i > n-k+1:
    print('0')
  else:
   main(i)


Measured memory_bytes: 9232
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int n=s.length();
    if(s[0]==s[n-1])
    {
        if(n%2)
            cout<<"Second\n";
        else
            cout<<"First";
    }
    else
    {
        if(n%2)
            cout<<"First\n";
        else
            cout<<"Second\n";
    }
    
    return 0;   
}




 
 
    

Measured memory_bytes: 512
import * as fs from 'fs';

export class Reader {
    lines: string[];
    currentLine: number;

    constructor() {
        this.lines = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        this.currentLine = 0;
    }

    readLine(): string {
        return this.lines[this.currentLine++];
    }

    readInt(): number {
        return Number(this.readLine());
    }

    readInts(): number[] {
        return this.readLine().split(" ").map(Number);
    }
}

let reader: Reader = new Reader();
let N = reader.readInt();
let A: number[] = reader.readInts();
let B: number[] = new Array(N).fill(0);
let count = 0;

for(let i=N-1; i>=0; i--) {
	let S = 0;
	for(let j=2*i+1; j<N; j+=i+1) {
		S += B[j];
	}
	if (S%2 == A[i]%2) {
		B[i] = 0;
	} else {
		B[i] = 1;
		count += 1;
	}
}
console.log(count);
for(let i=0; i<N; i++) {
	if (B[i] == 1) {
		console.log(i+1);
	}
}


Measured memory_bytes: 50516
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}
fn main() {
   input! {
      n: usize,
      m: usize,
      xy: [(usize, usize); m]
   }
   let mut to = vec![vec![]; n];
   let mut d = vec![0; n];
   for (x, y) in xy {
      to[x - 1].push(y - 1);
   }
   let mut ans = 0;
   for v in 0..n {
      if d[v] == 0 {
         dfs(v, &mut d, &to);
         ans = std::cmp::max(ans, d[v]);
      }
   }
   println!("{}", ans);
}

fn dfs(v: usize, d: &mut Vec<usize>, to: &Vec<Vec<usize>>) {
   let mut x = 0;
   for &u in to[v].iter() {
      if d[u] == 0 {
         dfs(u, d, to);
      }
      x = std::cmp::max(x, d[u] + 1);
   }
   d[v] = x;
}


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

int main() {
	int a[3]; for(int i = 0 ; i < 3 ; ++ i) cin >> a[i];
	sort(a, a + 3);
	cout << (a[2] * 10 + a[1] + a[0]) << endl;
}

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}


inline int addmod(int x ,int y){return (x%mod + y%mod)%mod;}
inline int submod(int x ,int y){return (x%mod - y%mod + mod)%mod;}
inline int mulmod(int x ,int y){return (x%mod *1LL* y%mod)%mod;}
inline int nextSubMask(int i , int mask) {return (i-1)&mask;} /// returns next smallest submask

void we_r_done(){cout<<"NO"; exit(0);}

void debug(bool ok , string mssg)
{
    if(ok)return;
    cout<<mssg;
    exit(0);
}

int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    ///FastIO;

    lli x,y , d;

    cin>>x>>y;

    d = abs(x-y);

    if(d%3 == 0 && d/3) cout<<"Alice";
    else if(d<=1)cout<<"Brown";
    else cout<<"Alice";

    return 0;

}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?


Measured memory_bytes: 384