akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

func main() {
	var x int
	fmt.Scan(&x)
	prime := x
	for !isPrime(prime) {
		prime++
	}
	fmt.Println(prime)
}

func isPrime(x int) bool {
	if x <= 1 {
		return false
	}
	for i := 2; i*i <= x; i++ {
		if x%i == 0 {
			return false
		}
	}
	return true
}


Measured memory_bytes: 512
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>

#define INF 100000000
#define ll long long

using namespace std;
int n, a;
int x[10] = {};
int main() {
	int min = 0;
	int max = 0;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		if (a >= 3200) {
			x[8]++;
		}
		else if (a >= 2800) {
			x[7]++;
		}
		else if (a >= 2400) {
			x[6]++;
		}
		else if (a >= 2000) {
			x[5]++;
		}
		else if (a >= 1600) {
			x[4]++;
		}
		else if (a >= 1200) {
			x[3]++;
		}
		else if (a >= 800) {
			x[2]++;
		}
		else if (a >= 400) {
			x[1]++;
		}
		else if(a >= 1){
			x[0]++;
		}
	}

	if (x[8] == n) {
		cout << 1 << " " << n << endl;
		return 0;
	}

	for (int i = 0; i < 8; i++)
	{
		if (x[i] != 0) {
			min++;
		}
	}
	max = min;
	for (int i = 0; i < x[8]; i++)
	{
			max++;
	}

	printf("%d %d\n", min, max);
	return 0;
}

Measured memory_bytes: 256
N,X,Y=map(int, input().split())
dislist = [0]*N
midXY = (X+Y)//2
def caldis(i,l):
    return min((l-i),(abs(X-i)+1+abs(Y-l)))
for i in range(1,N):
    for l in range(i+1,N+1):
        dislist[caldis(i,l)] += 1
for i in dislist[1:]:
    print(i)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define sz(x) ((int)x.size())
#define pb push_back
#define ii pair<int,int>
#define iii pair<ii,int>
#define ppb pop_back
#define st first
#define nd second
#define ll long long
#define N 500005
#define inf 2000000005
#define MOD 1000000007
#define LOG 14
#define EPS 0.000000001
using namespace std;

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);

	int l, r, d;
	cin >> l >> r >> d;
	int ans = 0;
	for(int i = l; i <= r; i++) {
		ans += (i % d == 0);
	}
	cout << ans;

}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define IL inline
#define RG register
using namespace std;

const int N=3e5+3;

int n,m,a[N],b[N],ans[2];

IL int gi() {
	int x=0,p=1;char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') p=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
	return x*p;
}

IL int check(int val) {
	RG int i,fl=1;
	for(i=1;i<=n;++i) b[i]=a[i]>=val;
	for(i=2;i<=n;++i) fl&=b[i]^b[i-1];
	if(fl) return b[1];
	ans[0]=ans[1]=n;
	for(i=2;i<=n;++i) 
		if(b[i]==b[i-1])
			ans[b[i]]=min(ans[b[i]],abs(m-i));
	for(i=n-1;i;--i)
		if(b[i]==b[i+1])
			ans[b[i]]=min(ans[b[i]],abs(m-i));
	return ans[1]<ans[0];
}

int main()
{
	RG int i,l,r,mid;
	m=gi(),n=(m<<1)-1,l=1,r=n;
	for(i=1;i<=n;++i) a[i]=gi();
	while(l<r) {
		mid=l+r+1>>1;
		if(check(mid)) l=mid;
		else r=mid-1;
	}
	printf("%d\n",r);
	return 0;
}
//Median Pyramid Hard


Measured memory_bytes: 1792
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
3
abcbdab
bdcaba
abc
abc
abc
bc

output:
4
3
2

"""
import sys


def lcs(A, B):
    m, n = len(A), len(B)
    count_list = [[0] * (n + 1) for _ in range(m + 1)]

    for i in range(1, m + 1):
        for j in range(1, n + 1):
            if A[i - 1] == B[j - 1]:
                count_list[i][j] = count_list[i - 1][j - 1] + 1
            elif count_list[i - 1][j] >= count_list[i][j - 1]:
                count_list[i][j] = count_list[i - 1][j]
            else:
                count_list[i][j] = count_list[i][j - 1]

    return count_list[m][n]


def lcs_better(X, Y):
    costs = [0]
    for c in Y:
        for i in range(len(costs) - 1, -1, -1):
            tmp = X.find(c, costs[i])
            if tmp + 1:
                if i + 1 < len(costs):
                    costs[i + 1] = min(costs[i + 1], tmp + 1)
                else:
                    costs.append(tmp + 1)
    return len(costs) - 1


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    pair_num = int(_input[0])

    word_list = _input[1:]
    # assert len(word_list) == 2 * pair_num
    for k in range(0, len(word_list), 2):
        print(lcs_better(word_list[k].strip(), word_list[k + 1].strip()))

Measured memory_bytes: 7708
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

typedef map<string,vector<int> > P;

int main()
{
    P p;
    string str;
    int t = 0;
    while (cin >> str >> t)
        p[str].push_back(t);
    P::iterator it;
    for (it = p.begin(); it != p.end(); it++) {
        sort(it->second.begin(), it->second.end());
        cout << it->first  << endl << it->second[0];
        for (int j = 1; j < it->second.size(); j++)
            cout << " " << it->second[j];
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1244
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

#include<string>
    
using namespace std;

int main() {
    string s, t;
    cin >> s;
    cin >> t;
    cout <<t + s <<endl;
}

Measured memory_bytes: 256
# python3.4.2用
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')
def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N = iin()
A = []
B = []
for _ in range(N):
    a,b=imn()
    A.append(a)
    B.append(b)
cnt = 0
for i in range(N-1,-1,-1):
    if A[i] % B[i] != 0:
        if B[i] >= A[i]:
            cnt += B[i]-A[i]
        else:
            cnt += B[i]-(A[i]%B[i])
    if i > 0:
        A[i-1] += cnt
print(cnt)



Measured memory_bytes: 17128
#include <bits/stdc++.h>
using namespace std;
int main() 
{
  int H, W;
  cin >> H >> W ;

  string board[50];
  
  const int dx[8] = {1, 0,-1, 0, 1,-1,-1, 1};
  const int dy[8] = {0, 1, 0,-1, 1, 1,-1,-1};

  for (int i=0; i < H; i++) cin >> board[i];
  
  for (int i=0; i < H; i++) {
   for (int j=0; j < W; j++) {
     if (board[i][j]=='.') {
       int cnt =0;
       for (int k=0;k<8;k++) {
         int x = i + dx[k];
         int y = j + dy[k];
         if (x >=0 && x < H && y >=0 && y < W && board[x][y]=='#') cnt++;
       }
       board[i][j]='0'+cnt;
     }
   }
  }
  for (int i=0; i < H; i++) cout << board[i] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string subsequence(string s,string t)
{
  int l1=s.length();
  int l2=t.length();
  int dp[l1+1][l2+1];
  for(int i=0;i<=l1;i++)
  {
    for(int j=0;j<=l2;j++)
    {
      if(i==0 || j==0)
        dp[i][j]=0;
      else if(s[i-1]==t[j-1])
        dp[i][j]=dp[i-1][j-1]+1;
      else
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    }
  }
  int i=l1,j=l2;
  string lcs;
  while(i>0 && j>0)
  {
    if(s[i-1]==t[j-1])
    {
      lcs=s[i-1]+lcs;
      i--;
      j--;
    }
    else if(dp[i-1][j]>dp[i][j-1])
      i--;
    else
      j--;
  }
    return lcs;
}
int main()
{
  string s,t;
  cin>>s;
  cin>>t;
  cout<<subsequence(s,t);
  return 0;
}

Measured memory_bytes: 35456
/*
 * 	Roses are red
 * 		Violets are blue
 * 			I cried
 * 				And so did you
 */
// #pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifndef rd
#define endl '\n'
#endif
#ifdef rd
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=2e18;
const int infi=1e9;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag,
		tree_order_statistics_node_update> oset;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
auto clk=clock();
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int harmonic(int n) {

}
void solve() {
	int n;
	cin>>n;
	int sum=0;
	int i;
	for(i=1; i<=n; ) {
		int v=n/i;
		int nv=n/v+1;
		int te=(n-v)/v;
		if((n-v)%v==0&&te>v)
			sum+=te;
		i=nv;
	}
	cout<<sum<<endl;
}
signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cout<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;

class Main {
	
	public static int setNum (String str) {
		
		if (str.equals("A")) {
			return 0;
		} else if (str.equals("B")) {
			return 1;
		} else {
			return 2;
		}
		
	}
	
	public static void main(String[] args) throws IOException {

		BufferedReader br =
			new BufferedReader(new InputStreamReader(System.in));

//		ArrayList<String> ans = new ArrayList<String>();
		
		boolean[] cup = {true,false,false};
		
		while (true) {

			String s = br.readLine();
			if (s == null) break;
			
			StringTokenizer st = new StringTokenizer(s,",");
			int from = setNum(st.nextToken());
			int to = setNum(st.nextToken());
			boolean temp;
			
			temp = cup[to];
			cup[to] = cup[from];
			cup[from] = temp;
			
		}
		
		for (int i = 0; i < cup.length; i++) {
			if (cup[i]) {
				
				switch (i) {
					case 0 : System.out.println("A"); break;
					case 1 : System.out.println("B"); break;
					case 2 : System.out.println("C"); break;
				}
				
				break;
			}
		}
		
		
//		for (String p : ans) {
//			System.out.println(p);
//		}
	}

}

Measured memory_bytes: 9340
def exec():
    s = input()
    a,b,c = 0,0,0
    for ch in s :
        if ch == 'a':
            a += 1
        elif ch == 'b':
            b += 1
        elif ch == 'c':
            c += 1
    if a == 1 and b == 1 and c == 1:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
  exec()


Measured memory_bytes: 3060
import scala.io.StdIn.{readLine,readInt}
import scala.language.postfixOps

object Main {
  var cnt:Long = 0
  val l = new Array[Int](100002)
  val r = new Array[Int](100002)

  def merge(a:Array[Int],left:Int,mid:Int,right:Int) = {
    val n1 = mid-left
    val n2 = right-mid
    Array.copy(a,left,l,0,n1)
    l(n1) = Int.MaxValue
    Array.copy(a,mid,r,0,n2)
    r(n2) = Int.MaxValue
    var i=0
    var j=0
    for(k<-left until right) {
      if(l(i)<=r(j)){
        a(k) = l(i)
        i += 1
      } else  {
        a(k)=r(j)
        cnt = cnt+(n1-i).toLong
        j += 1
      }
    }
  }

  def scan(h:Int,l:List[IndexedSeq[(Int,Int)]]):List[IndexedSeq[(Int,Int)]] =
    if(h<=0) l
    else scan(h-1,(for(i<-l.head;j<-List((i._1,(i._2+i._1)/2),((i._2+i._1)/2,i._2))) yield j)::l)

  def getSortIndex(n:Int):Iterator[IndexedSeq[(Int,Int)]] = {
    var w = n
    var h = 0
    while(w>1) {
      h += 1; w /= 2
    }
    scan(h-1,List(IndexedSeq((0,n/2),(n/2,n)))).to[Iterator]
  }

  def main(args:Array[String]) = {
    val n = readInt
    val a = readLine.split(" ").map(_.toInt)
    val l = getSortIndex(n)
    for(e2<-l) {
      for(e<-e2) {
        val mid = (e._2+e._1)/2
        if(e._2-e._1>1)
          merge(a,e._1,mid,e._2)
      }
    }
    merge(a,0,n/2,n)
    println(cnt)
  }
}

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

using namespace std;
const int maxN=5e5+100;

 int n,k;
vector<int> ans;
int a[maxN];
bool mark[maxN];

void alg()
{
  if(k<=n)
    {
      a[n]=k;
      a[n+1]=k-1;
      a[n+2]=k+1;
      a[n-1]=k+2;
    }
  else
    {
      a[n]=k;
      a[n+1]=k+1;
      a[n+2]=k-1;
      a[n-1]=k-2;
    }
  for(int i=n-1;i<=n+2;i++)
    mark[a[i]]=true;
  for(int i=1;i<=2*n-1;i++)
    if(!mark[i])
      ans.push_back(i);
  int cnt=0;
  for(int i=1;i<=n-2;i++)
    a[i]=ans[cnt++];
  for(int i=n+3;i<=2*n-1;i++)
    a[i]=ans[cnt++];
}
int main()
{

  cin>>n>>k;

  if(n==1)
    {
      if(k==1){
	cout<<"Yes"<<endl;
	cout<<1<<endl;}
      
      else
	cout<<"No"<<endl;
    }
  else if(n==2)
    {
      if(k==2){
	cout<<"Yes"<<endl;
	cout<<"1\n2\n3\n";}
      else
	cout<<"No"<<endl;
    }
  else if(k==1 || k==2*n-1)
    cout<<"No"<<endl;
  else
    {
      cout<<"Yes"<<endl;
      
      alg();
      for(int i=1;i<=2*n-1;i++)
	cout<<a[i]<<"\n";
    }

  return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define s(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
int main(){
  int N,K;
  cin>>N;
  int ans =0;
  rep(i,N+1){
    int count = 0;
    int a  = i+1;
    if(a%2==0)continue;
    for(int j =1;j<N+1;j++){
      if(a%j==0)count++;
    }
    if(count==8)ans++;
  }
  cout<<ans<<endl;;
  
}

Measured memory_bytes: 256
import sys

import numba as nb
import numpy as np

input = sys.stdin.readline


@nb.njit("i8(i8[:],i8)", cache=True)
def binary_search(a, key):
    """Meguru type binary search"""
    ok = -1
    ng = len(a)

    def is_ok(a, key, idx):
        if a[idx] < key:
            return True
        else:
            return False

    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(a, key, mid):
            ok = mid
        else:
            ng = mid

    return ok


@nb.njit("i8(i8,i8[:])", cache=True)
def solve(N, L):
    L.sort()
    ans = 0
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            x = binary_search(L, L[a] + L[b])
            ans += (x - b)
    return ans


def main():
    N = int(input())
    L = np.array(input().split(), dtype=np.int64)

    ans = solve(N, L)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 106164
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
    #include "lib/dump.hpp"
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

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

    vector<int> used(n);
    vector<vector<int>> ans;
    auto dfs = [&](const auto& dfs, vi x, int i, int m) -> void {
        rep(c, min(m+2, n)){
            vi y(x);
            y.pb(c);
            if (i==n-1){
                ans.pb(y);
            }
            else{
                dfs(dfs, y, i+1, max(c, m));
            }
        }
    };
    dfs(dfs, vi(), 0, -1);
    dump(ans);

    rep(i, sz(ans)){
        string res;
        rep(j, n){
            res += ans[i][j] + 'a';
        }
        cout << res << endl;
    }

    return 0;
}


Measured memory_bytes: 15280
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long n, p = 0, q = 0, k = 1;
    cin >> n;
    long long a[n];
    for (long long i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    reverse(a, a + n);
    for (long long i = 1; i < n; i++)
    {
        if (a[i] == a[i - 1]) k++;
        else k = 1;
        if (p == 0)
        {
            if (k > 1) 
            {
                p = a[i];
                k -= 2;
            }
        }
        else
        {
            if (k > 1) 
            {
                q = a[i];
                break;
            }
        }
    }
    cout << p * q;
}

Measured memory_bytes: 4376
import java.util.Scanner;

public class Main{
    public static void main(String[]args){
        Scanner scan = new Scanner(System.in);
        int a,b;
         a=scan.nextInt();b=scan.nextInt();
        double c = (double) a/b;
        System.out.printf("%d %d %f\n",a/b,a%b,c); 
    }
}


Measured memory_bytes: 26380
package main

import (
	"fmt"
)

func main() {
	var a, b int
	var op string

	for {
		fmt.Scan(&a, &op, &b)
		if op == "?" {
			break
		}

		switch op {
		case "+":
			fmt.Println(a + b)
		case "-":
			fmt.Println(a - b)
		case "*":
			fmt.Println(a * b)
		case "/":
			fmt.Println(a / b)
		}
	}
}



Measured memory_bytes: 1132
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
typedef long double LD;
#define LP(i, a, b) for (int i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (int i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-8
#define INF 1e9
#define LINF 1e18

int N;
int const MaxSize = 100 + 10;

int res[MaxSize][MaxSize][2];

int good(int a, int b, int aT) {
	if (res[a][b][aT] != -1) {
		return res[a][b][aT];
	}

	//cout << a << " " << b << "  " << aT << " " << res[a][b][aT] << endl;

	res[a][b][aT] = -2;

	int aWin = 0;
	if (aT) {

		if (a > 1) {
			aWin = good(a - 1, b, !aT);
		}

		if (a + 1 < b && aWin < 1) {
			aWin = good(a + 1, b, !aT);
		}

	} else {

		int bWin = 0;
		if (b < N) {
			bWin = !good(a, b + 1, !aT);
		}

		if (b - 1 > a && bWin < 1) {
			bWin = !good(a, b - 1, !aT);
		}

		aWin = !bWin;
	}

	res[a][b][aT] = aWin;

	//cout << a << " " << b << "  " << aT << " " << res[a][b][aT] << endl;
	return aWin;
}

int main() {

	ios_base::sync_with_stdio(false);
	//freopen("/Users/george/A_1.in", "r", stdin);
	int A, B;
	cin >> N >> A >> B;

	if ((B - A) % 2){
		cout << "Borys";
	}else{
		cout << "Alice";
	}

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
//#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

signed main(){
  int n,a,b;cin>>n>>a>>b;
  cout << min(a,b) << " " << max(a+b-n,0) << endl;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

ll rem(ll n, ll m, bool f)
{
    if(f) return (n % m + m) % m;
    else return (n % m - m) % m;
}

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

    bool f = true;
    ll d = 1;
    string S;
    if(N == 0) S = "0";
    while(N != 0) {
        ll r = rem(N, abs(-2*d), d>0);
        N -= r;
        S += '0' + (r / d);
        d *= -2;
    }
    REV(S);
    PR(S);

    return 0;
}

/*



*/

Measured memory_bytes: 3576
#include <stdio.h>

int Search(int n,int s[],int k){
	int r,l,mid;
	r = n;
	l = 0;
	while(l < r){
		mid = (r + l)/2;
		if(s[mid] < k){
			l = mid + 1;
		}else if(s[mid] > k){
			r = mid;
		}else{
			return 1;
		}
	}
	return 0;
}

int main(void){
	int n,q,i,j,s[100000],key;
	int res = 0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&s[i]);
	}
	scanf("%d",&q);
	for(j=0;j<q;j++){
		scanf("%d",&key);
		if(Search(n,s,key))res++;
	}
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 2128
if __name__ == '__main__':

	n = int(input())
	m = int(n//2)

	end = n - 1
	for x in range(2,int(n**0.5)+1):
		if n % x == 0:
			y = n // x
			end = min(x+y-2,end)

	print(end)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll a[3005];
ll dp[3002][3002][2];
ll func(ll i,ll j,int b)
{
	ll d;
	//cout<<i<<" "<<j<<" "<<sum_x<<" "<<sum_y<<endl;
	if(i<1||j<1||i>j)
		return 0;
	if(dp[i][j][b]!=-1)
		return dp[i][j][b];
	if(b)
		dp[i][j][b]=max(func(i,j-1,0)+a[j],func(i+1,j,0)+a[i]);
	else
		dp[i][j][b]=min(func(i,j-1,1)-a[j],func(i+1,j,1)-a[i]);
	return dp[i][j][b];
}
int main()
{
	ll i,n,j;
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>a[i];
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
			dp[i][j][0]=dp[i][j][1]=-1;
	}
	cout<<func(1,n,1)<<endl;
}


Measured memory_bytes: 141184
#include<stdio.h>
int main()
{
	int n,i,count=0;
	scanf("%d",&n);
	for(i=1;i<=9;i++)
	{
		if(n%i==0 && (n/i<=9 && n/i>=1))
		{
		printf("Yes");
			count=1;
		break;
		}
	}
	if(count==0)
	printf("No");
return 0;
}

Measured memory_bytes: 128
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    std::vector<int64_t> P;

    for (size_t i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        P.push_back(t-1);
    }

    std::vector<int64_t> A;
    std::vector<int64_t> B;

    for (size_t i = 0; i < N; ++i) {
        A.push_back(i*N + 1);
        B.push_back((N-1-i)*N + 1);
    }

    for (int64_t i = 0; i < N; ++i) {
        A[P[i]] += i;
    }

    for (auto a: A) {
        std::cout << a << " ";
    }
    std::cout << std::endl;

    for (auto b: B) {
        std::cout << b << " ";
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 1316
#include <iostream>
#define eps 0.0000001
using namespace std;
int p,q,a,n,ans;
double pq;
void  saiki(double sum,int x,int kai,int start){
  if(-eps<=(sum-pq)&&(sum-pq)<=eps)ans++;
  if(kai>=n||x>=a||sum>pq+eps)return;
  for(int i=start;i*x<=a;i++) saiki(sum+1.0/i,x*i,kai+1,i);
}

int main() {
  while(1){
    cin>>p>>q>>a>>n;
    if(!p&&!q&&!a&&!n)break;
    pq=1.0*p/q;
    ans=0;
    saiki(0,1,0,1);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
while 1:
	n,m=map(int,raw_input().split())
	if n==0:break
	h={i:0 for i in range(m)}
	for i in range(n):
		a=map(int,raw_input().split())
		for j in range(m):
			h[j]+=a[j]
	ans=[k[0]+1 for k in sorted(h.items(),key=lambda x:x[1],reverse=True)]
	print " ".join(map(str,ans))

Measured memory_bytes: 4256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------
#include <iostream>
#include <bitset>
#include <algorithm>        // sort()
#include <vector>           // for vectors
#include <map>              // for ordered map
#include <unordered_map>
#include <list>             // for list
#include <iomanip>          // for setprecision()
#include <cmath>            // for pow(), sqrt(), log(), log10(), ....
#include <cstring>          // for memset()
#include <unordered_set>    // for unordered_set
#include <climits>          // for INT_MAX & INT_MIN
#include <set>              // for ordered set

#define C ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll;
#define INF INT_MAX
#define NINF INT_MIN
#define MOD 1000000007
const double pi=acos(-1); // value of pi


bool isVowel(char ch) {
    if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u') {
        return 1;
    }
    return 0;
}

bool compare(pair<ll, ll> a, pair<ll, ll> b) {
    return a.second<b.second;
}


bool isPrime(ll n) {
    for(ll i=3; i*i<=n; i+=2) {
        if(n%i==0) {
            return false;
        }
    }
    return true;
}

ll binary_exp(ll x, ll n, ll mod)
{
    if (n == 0) {
        return 1;
    } else if (n == 1) {
        return x % mod;
    } else {
        ll temp = binary_exp(x, n / 2, mod);
        temp = (temp * temp) % mod;

        if (n % 2 == 0) {
            return temp;
        } else {
            return ((x % mod) * temp) % mod;
        }
    }
}

map<string, ll> m;
// map<ll, ll> m;

int main() {
    C
//     freopen("input.txt","r",stdin);
// 	freopen("output.txt","w",stdout);
    int t=1;
    // cin >> t;
    while(t--) {
        ll n;
        cin >> n;
        string x;
        string arr[4]={"AC", "WA", "TLE", "RE"};
        for(ll i=0; i<n; i++) {
            cin >> x;
            m[x]++;
        }
        for(ll i=0; i<4; i++) {
            cout << arr[i] << " x " << m[arr[i]] << endl;
        }
    }
}


Measured memory_bytes: 3188
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int n, d;
	int x[10][10];

	cin >> n >> d;
	rep(i,n) {
		rep(j, d)cin >> x[i][j];
	}


	int ans = 0;
	rep(j, n)rep(i, j) {
		int s = 0;
		rep(k, d)s += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);

		int sq = sqrt(s) + 0.001;
		if (sq * sq == s)ans++;
	}
	cout << ans << endl;


	return 0;
}

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

    typedef long long int ll;
    #define pb         push_back
    #define mp         make_pair
    #define F          first
    #define S          second
    #define fl(i,a,b)  for(ll i=a;i<b;i++)
    #define pll        pair<ll,ll>
    #define pii        pair<int,int>
    #define all(v)     v.begin(),v.end()
    #define M 1000000007
    #define tr(v, it) for(auto it = v.begin(); it != v.end(); it++)
    using namespace std;


   int n,m;
   char graph[1005][1005];
   bool visited[1005][1005];
   ll dp[1005][1005];

    ll dfs(int i,int j)
    {
        if(i==n-1 && j==m-1)
        {
            return 1;
        }
        if(i>=n || j>=m)
            return 0;
        if(!visited[i][j] && graph[i][j]=='.')
        {
            visited[i][j]=true;
            dp[i][j]= ((dfs(i+1,j)%M)+(dfs(i,j+1)%M))%M;
        }


       return dp[i][j];
    }


    int main()
    {

        ios_base::sync_with_stdio(false);
    	cin.tie(NULL);


         cin>>n>>m;

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

            for(int j=0; j<m; j++)
                {
                    cin>>graph[i][j];
                }
         }


         memset(dp,0,sizeof(dp));
         memset(visited,false,sizeof(visited));


        cout<<(dfs(0,0)%M);

       return 0;
    }


Measured memory_bytes: 13628
while 1 :
    h,w=map(int,input().split())
    if h==0 and w==0 : break
    token=0
    for i in range(h):
        out=""
        if token==1: out="."
        out+="#."*((w-token)//2)+"#"*((w-token)%2)
        token+=1
        token%=2
        print(out)
    print("")
    


Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste

// #include "UnionFind.hpp"
// #include "power.hpp"


signed main() {
    int A, B;
    cin >> A >> B;
    if (A <= 5) {
        cout << 0 << endl;
    } else if (A <= 12) {
        cout << B / 2 << endl;
    } else {
        cout << B << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int d[]=new int[6];
        for(int i=0;i<6;i++){
            d[i]=scan.nextInt();
        }
        Dice dice =new Dice(d[0],d[1],d[2],d[3],d[4],d[5]);

        int q=scan.nextInt();

        for(int i=0;i<q;i++){
            int TOP=scan.nextInt();
            int FRONT=scan.nextInt();

            dice.settop(TOP);
            dice.setfront(FRONT);
            System.out.println(dice.right);
        }

    }
}

class Dice{
    int top,bottom,left,right,front,back;

    Dice(int a, int b,int c,int d,int e,int f){
        top=a;
        front=b;
        right=c;
        left=d;
        back=e;
        bottom=f;
    }
    void settop(int a){
        if(a==right)turnW();
        else if(a==left)turnE();
        else if(a==back)turnS();
        else if(a==front)turnN();
        else if(a==bottom){
            turnN();
            turnN();
        }
    }
    void setfront(int a){
        if(a==right)turnL();
        else if(a==left)turnR();
        else if(a==back){
            turnL();
            turnL();
        }
    }
    void turnN(){
        int tmp=top;
        top=front;
        front=bottom;
        bottom=back;
        back=tmp;
    }
    void turnS(){
        int tmp=top;
        top=back;
        back=bottom;
        bottom=front;
        front=tmp;
    }
    void turnW(){
        int tmp=top;
        top=right;
        right=bottom;
        bottom=left;
        left=tmp;
    }
    void turnE(){
        int tmp=top;
        top=left;
        left=bottom;
        bottom=right;
        right=tmp;
    }
    void turnL(){
        int tmp=front;
        front=right;
        right=back;
        back=left;
        left=tmp;
    }
    void turnR(){
        int tmp=front;
        front=left;
        left=back;
        back=right;
        right=tmp;
    }
}



Measured memory_bytes: 26384
#include<stdio.h>
#define min(a, b) ( a < b? (a) : (b) )
typedef long long ll;
int main(){
  ll N, K;
  scanf("%lld%lld",&N, &K);
  N = N%K;
  N = min(N, K-N);
  printf("%lld",N);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60; const ll mod=1e9+7; const int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------
vector<int> v[27];
int cur[27];

int main(){
	string s,t; cin >> s >> t;
	map<char, int> mp;
	FOR(i,0,s.size()-1){
		v[s[i]-int('a')].push_back(i);
	}
	FOR(i,0,26) cur[i] = -1;
	bool ok = true;
	ll ans = 0;
	int idx = 0;
	int prev = -1;
	while(idx <= t.size()-1){
		int now = int(t[idx]) - int('a');
		auto ptr = upper_bound(ALL(v[now]), max(cur[now], prev));
		//cout << *ptr << ' ';
		if(ptr == v[now].end()){
			if(v[now].size() == 0){
				ok = false;
				break;
			}else{
				FOR(i,0,26) cur[i] = -1;
				//cur[now] = -1;
				ans += s.size(); 
				//cout << "YES" << ' ';
				ptr = upper_bound(ALL(v[now]), cur[now]);
				//cout << *ptr << ' ';
				if(idx == t.size()-1){
					ans += *ptr+1; 
				}
			}
		}else{
			if(idx == t.size()-1) ans += *ptr+1;
			cur[now] = *ptr;
			
		}
		prev = *ptr;
		idx++;
	}
	cout << (ok?ans:-1)<< endl;
    return 0;
}


Measured memory_bytes: 1216
n = int(input())

color = [0] * 8
pro = 0
for ai in map(int, input().split()):
    if 1 <= ai <= 399:
        color[0] = 1
    elif 400 <= ai <= 799:
        color[1] = 1
    elif 800 <= ai <= 1199:
        color[2] = 1
    elif 1200 <= ai <= 1599:
        color[3] = 1
    elif 1600 <= ai <= 1999:
        color[4] = 1
    elif 2000 <= ai <= 2399:
        color[5] = 1
    elif 2400 <= ai <= 2799:
        color[6] = 1
    elif 2800 <= ai <= 3199:
        color[7] = 1
    else:
        pro += 1

colSum = sum(color)
if colSum == 0 and pro > 0:
    print(1, pro)
else:
    print(colSum, colSum + pro)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair <int,int>
#define ull unsigned long long
#define mp make_pair
#define s second
#define f first                                          
#define _ ios_base::sync_with_stdio(false);cin.tie(0);

using namespace std;

const int MAXN = (int)(2e5)+2;
const int MOD = (int)(1e9)+7;


int main() {
	_
	
	ll x,y;
	cin >> x >> y;
	ll ans = 0;
	while (x <= y) {
	 	ans++;
	 	x *= 2;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int count = K;
    for(int i=1;i<N;i++){
      count = count*(K-1);
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 23252
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>

int main(){
	int ans;
	std::string s;
	int num;
	int delta;
	int minDelta=999;

	std::cin>>s;

	for(int i=0; i< s.size()-2; i++){
		num=0;
		num+= (s[i]-'0')*100;
		num+= (s[i+1]-'0')*10;
		num+= (s[i+2]-'0');

		minDelta= std::min(minDelta, std::abs(753-num));
	}

	std::cout<<minDelta<<std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int i=0,n=0,n2;
  char s[100001];
  scanf("%s",s);
  n2=strlen(s);
  for(i=0;i<n2;i++){
    if(s[i]=='0')
      if(s[i+1]=='0'){
        s[i+1]='1';
        n++;
      }
    if(s[i]=='1')
      if(s[i+1]=='1'){
        n++;
        s[i+1]='0';
  }
  }
  printf("%d",n);
  return 0; 
}

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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  
  int n;
  cin >> n;
  int a = ceil(n/1.08);
  if(floor(a*1.08)==n){
    cout << a << endl;
  }else{
    cout << ":(" << endl;
  }
  return 0;
}

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

int merge_sort(int left,int right){
  if(left+1<right){
    int mid=(left+right) >> 1;
    return (merge_sort(left,mid)+merge_sort(mid,right)+right-left);
  }
  else{
    return (0);
  }
}


int main(){
  int x,n,S[500000];
  cin >> n;
  for(int i=0;i<n;i++) cin >> S[i];
  sort(S,S+n);

  x=merge_sort(0,n);

  for(int i=0;i<n;i++){
    if(i) cout << " ";
    cout << S[i];
  }
  cout << endl;
  cout << x << endl;
  return 0;
}




Measured memory_bytes: 5060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
int main(){
    //Seiranchan!
    int a,b;
    string s;
    cin >> a>> b>>s;
    bool flg= true;
    for(int i=0;i<(a+b);i++){
        if(i==a){
            if(s[i]!='-'){
                flg = false;
            }
        }else{
            if(s[i]=='-'){
                flg = false;
            }
        }
    }

    if(flg){
        cout <<"Yes" <<endl;
    }else{
        cout <<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

class UnionFind {
private:
	vector<lint> data;
public:
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }

	UnionFind(lint size) : data(size, -1) { }
	bool is_same(int x, int y) { return root(x) == root(y); }
	int size(lint x) { return -data[root(x)]; }

	void unify(lint x, lint y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
};

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	lint N, K, L;
	cin >> N >> K >> L;

	vector<pair<lint,lint>> road(K), line(L);
	for (int i = 0; i < K; i++) cin >> road[i].first >> road[i].second;
	for (int i = 0; i < L; i++) cin >> line[i].first >> line[i].second;

	UnionFind UFroad(N), UFline(N);
	for (const auto &elem : road) UFroad.unify(elem.first - 1, elem.second - 1);
  	for (const auto &elem : line) UFline.unify(elem.first - 1, elem.second - 1);

  	map<pair<int,int>,int> roots;
	for (int i = 0; i < N; i++) roots[make_pair(UFroad.root(i),UFline.root(i))]++;
	for (int i = 0; i < N; i++) cout << roots[make_pair(UFroad.root(i),UFline.root(i))] << " ";

	return 0;
}


Measured memory_bytes: 18048
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        if (n == 1) {
            System.out.println("Hello World");
        } else {
            int a = sc.nextInt();
            int b = sc.nextInt();

            System.out.println(a + b);
        }
    }
}


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

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

  vector<int> tails(n);
  for (int i = 0; i < n; i++) {
    cin >> tails[i];
  }

  sort(tails.begin(), tails.end());
  reverse(tails.begin(), tails.end());

  int sum = 0;
  for (int i = 0; i < k; i++) {
    sum += tails[i];
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<cstdlib>
#include<ctime>
using namespace std;
typedef long long ll;
int main() {
	string s;
	cin >> s;
	for (int i = 0; i <= s.size() - 2; i++) {
		if (s[i] == 'A'&&s[i+1] == 'C') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
class main
{
    static void Main(string[] args)
    {
        while (true)
        {
            string s = Console.ReadLine();
            if (s != null)
            {
                    string[] t = s.Split(' ');
                    int a = int.Parse(t[0]);
                    int b = int.Parse(t[1]);
                    int c = a + b;

                    Console.WriteLine(c.ToString().Length);
            }
            if (s == null)
            {
                break;
            }
        }
        //Console.ReadKey();
    }
}

Measured memory_bytes: 5632
h,w = map(int,input().split())

ans = []
ans.append("#"*(w+2))
for i in range(h):
  s = input()
  tmp = "#"
  tmp += s
  tmp += "#"
  ans.append(tmp)
  

ans.append("#"*(w+2))
for i in ans:
  print(i)

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

#define FOR(i, a, b)  for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << "\n"
#define _ << " _ " <<
#define ll long long

using namespace std;

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

int main() {
  ios_base::sync_with_stdio(false);

  int n, ma = 0, gc = 0, k;
  cin >> n >> k;
  REP(i, n) {
    int x;
    cin >> x;
    ma = max(ma, x);
    gc = gcd(x, gc);
  }
  if (ma < k) {
    cout << "IMPOSSIBLE\n";
    return 0;
  }

  if (k % gc) {
    cout << "IMPOSSIBLE\n";
    return 0;
  }

  cout << "POSSIBLE\n";

  return 0;
}


Measured memory_bytes: 256
#  Changing a Character
N, K = map(int,input().split())
S = str(input())

S2 = ''

for i in range(len(S)):
    if i == K-1:
        S2 = S2 + S[K-1].replace('A', 'a').replace('B', 'b').replace('C', 'c')
    else:
        S2 = S2 + S[i]

print(S2)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>


using namespace std;

int min(int a, int b) { return(a < b) ? a : b; }

class Solution
{
public:
	int minDistance(const string &word1, const string &word2)
	{
		const size_t m = word1.size() + 1;
		const size_t n = word2.size() + 1;

		vector<vector<int> > k(m, vector<int>(n));

		for (size_t i = 0; i < m; ++i)
			k[i][0] = i;

		for (size_t j = 0; j < n; ++j)
			k[0][j] = j;

		for (size_t i = 1; i < m; ++i)
		{
			for (size_t j = 1; j < n; ++j)
			{
				if (word1[i - 1] == word2[j - 1])
					k[i][j] = k[i - 1][j - 1];
				else
					k[i][j] = min(k[i - 1][j - 1], min(k[i - 1][j], k[i][j - 1])) + 1;
			}
		}
		return k[m - 1][n - 1];
	}
};

int main() {
	string a, b;
	cin >> a >> b;
	Solution A;
	cout << A.minDistance(a, b) << endl;
}

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

string solve2(int N, string s, int a, int b) {
  vector<bool> dp(N+1);
  dp[0] = a;
  dp[1] = b;
  rep(i, 1, N) {
    if(dp[i]) { // オオカミ
      if(s[i] == 'o') dp[i+1] = dp[i-1]^1;
      else dp[i+1] = dp[i-1];
    } else { // ヒツジ
      if(s[i] == 'x') dp[i+1] = dp[i-1]^1;
      else dp[i+1] = dp[i-1];
    }
  }
  int v = 0;
  if(a) {
    if(s[0] == 'o') v = b^1;
    else v = b;
  } else {
    if(s[0] == 'o') v = b;
    else v = b^1;
  }
  string ret = "";
  if(dp[0] == dp[N] && v == dp[N-1]) {
    rep(i, 0, N) {
      ret += dp[i] ? 'W' : 'S';
    }
    return ret;
  } else {
    return "-1";
  }
}

string solve() {
  int N;
  string s;
  cin >> N >> s;
  string ret = "-1";
  rep(i, 0, 2) rep(j, 0, 2) {
    ret = solve2(N, s, i, j);
    if(ret != "-1") return ret;
  }
  return ret;
}

int main() {
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 768
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AStillTBD solver = new AStillTBD();
        solver.solve(1, in, out);
        out.close();
    }

    static class AStillTBD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s[] = in.next().split("/");
            int yy = Integer.parseInt(s[0]), mm = Integer.parseInt(s[1]), d = Integer.parseInt(s[2]);
            if (yy > 2019) {
                out.println("TBD");
                return;
            }
            if (yy == 2019 && mm > 4) {
                out.println("TBD");
                return;
            }
            if (yy == 2019 && mm == 4 && d > 30) {
                out.println("TBD");
                return;
            }
            out.println("Heisei");
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21460