akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define reset(x, y) memset(x, y, sizeof(x))
#define BUG(x) cerr << #x << " = " << (x) << endl
#define BUGP(x) cout << #x << " = " << (x)._1 << ", " << (x)._2 << endl
using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const int dr[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dc[] = {0, -1, 0, 1, -1, 1, -1, 1};
// Head

const int N = 112345;

vector<int> G[N];
int n, a, b;
int dep[N], maxm[N], fa[N];

void dfs(int u, int pa, int d) {
    dep[u] = d;
    fa[u] = pa;
    maxm[u] = 0;

    for (int v : G[u]) {
        if (v == pa) continue;
        dfs(v, u, d + 1);
        maxm[u] = max(maxm[u], maxm[v] + 1);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> a >> b;
    for (int i = 0; i < n - 1; ++i) {
        int x, y;
        cin >> x >> y;
        G[x].pb(y), G[y].pb(x);
    }

    dfs(b, 0, 1);

    int dis = dep[a] - 1;
    int cur = a;

    for (int i = 0; i < (dis - 1) / 2; ++i) cur = fa[cur];
    if (dis & 1) cout << maxm[cur] + dis / 2 << '\n';
    else cout << maxm[cur] + (dis - 1) / 2 + 1 << '\n';
    return 0;
}

Measured memory_bytes: 13696
#include<bits/stdc++.h>
typedef long long ll;
#define pair<int,int> P
#define sc(N) scanf("%lld",&N);
using namespace std;
int N;
ll A[100005];
int main()
{
    sc(N);
    ll mi=0;
    for(int i=0;i<N;i++){
        sc(A[i]);
    }
    if(N==1){puts("Yes");return 0;}
    for(int i=0;i<N-1;i++){
        if(max(A[i]-1,mi)>A[i+1]){

            puts("No");return 0;
        }
        else mi=max(A[i]-1,mi);
    }
    puts("Yes");

}


Measured memory_bytes: 1024
n = gets.chomp.to_i
hash = Hash.new
n.times do
    str = gets.chomp
    if hash[str]
        hash[str] += 1
    else
        hash[str] = 1
    end
end
m = gets.chomp.to_i
m.times do
    str = gets.chomp
    if hash[str]
        hash[str] -= 1
    else
        hash[str] = -1
    end
end
puts [hash.sort{|a, b| b[1]<=>a[1]}[0][1], 0].max

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

using namespace std;

int main()
{
    int N, ans = 0;
    vector<int> h(100);
    cin >> N;
    for(int i = 0; i < N; ++i) cin >> h[i];
    for(int l = 0; l < N; ++l) {
        while(h[l] > 0) {
            int r;
            for(r = l; r < N; ++r) {
                if(h[r] == 0) break;
            }
            for(int i = l; i < r; ++i) h[i]--;
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
l=[]
for i in range(m):
  l.append(int(input()))
l=set(l)
L=[0 for i in range(n+1)]
L[0]=1
if 1 in l:
  L[1]=0
else:
  L[1]=1
for i in range(2,n+1):
  if i in l:
    L[i]=0
  else:
    L[i]=L[i-1]+L[i-2]
    L[i]%=(10**9+7)
print(L[n])

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

typedef long long ll;
typedef long double ld;

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

    int A, B, C;
    cin >> A >> B >> C;

    for(int i = 1; i < 10000; i++) {
        if(A * i % B == C) {
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;
}

Measured memory_bytes: 256
import math

A, B, C, D = map(int, input().split())

T_kougeki = C / B     # 高橋くんが攻撃して、青木くんの体力が0になるまでの回数
A_kougeki = A / D     # 青木くんが攻撃して、高橋くんの体力0になるまでの回数

if math.ceil(T_kougeki) <= math.ceil(A_kougeki):   #切り上げた値で少ない方、同数なら先行の高橋くんの勝ち
    print('Yes')

else:
    print('No')

Measured memory_bytes: 9164
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
	
 	    Scanner scanner = new Scanner(System.in);
 	    String S = scanner.next();
 	    int ans = 0;
 	    
 	    for(int i=0; i<4; i++) {
 	    	if(S.substring(i,i+1).equals("+")) {
 	    		ans++;
 	    	}else {
 	    		ans--;
 	    	}
 	    }
 	    System.out.println(ans);
 	    
 	    
	}

}


Measured memory_bytes: 21972
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
	int a = scan.nextInt();
	int b = scan.nextInt();
	if (a+b<10) {		
		System.out.println(a+b);
	}
	else {
		System.out.println("error");
	}
	}
}


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

int main(){
    string s;
    cin >> s;
    if(s[0] == s[s.size()-1]){
        if(s.size()&1)  cout << "Second" << endl;
        else    cout << "First" << endl;
    }else{
        if(s.size()&1)  cout << "First" << endl;
        else    cout << "Second" << endl;
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    if(a[0]!=0){
        cout<<-1<<endl;
        return 0;
    }
    ll res=0;
    reverse(a.begin(),a.end());
    ll maxi=0;
    rep(i,n){
        if(a[i]<maxi){
            cout<<-1<<endl;
            return 0;
        }
        if(chmax(maxi,a[i]))res+=a[i];
        maxi--;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 4840
#include<stdio.h>
int main()
{
    int r,c,i,j;
    scanf("%d%d",&r,&c);
    int a[r+1][c+1];
    for(i=0; i<r; i++)
    {
        for(j=0; j<c; j++)
        {
            scanf("%d",&a[i][j]);
        }
    }
    ///printf("\n");



    int sum=0;
    for(i=0; i<r; i++)
    {
        for(j=0; j<c; j++)
        {
            sum=sum+a[i][j];


        }
        for(j=c; j<=c; j++)
        {
            a[i][j]=sum;

        }

        sum=0;
    }




    int sum2=0;
    for(j=0; j<c+1; j++)
    {
        for(i=0; i<r; i++)
        {
            sum2=sum2+a[i][j];
        }
        for(i=r;i<=r;i++)
        {   a[i][j]=sum2;

        }

        sum2=0;
    }


   for(i=0;i<r+1;i++)
   {
       for(j=0;j<c+1;j++)
       { if(j==c)printf("%d",a[i][j]);
           else {printf("%d ",a[i][j]);}
       }
       printf("\n");
   }




    return 0;
}



Measured memory_bytes: 2052
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main() {
	vector<int> a(4);
	for(int i=0;i<4;i++){
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	vector<int> b={1,4,7,9};
	if(a==b){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int f=0;
  for(int i=0;i<s.length()-1;i++)
  {
    if(s[i]==s[i+1])
               {
                 f=1;
                 break;
               }
}
if(f==1)
    cout<<"Bad";
else
    cout<<"Good";
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int i, a, b, c, n;
    cin >> a >> b >> c;
    n = 0;
    for(i=a; i<=b; i++)
    {
        if(c % i == 0)
            n++;
    }
    cout << n << endl;
    
}


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

int main() {
 ll l,r;  ll ans=2019;
 cin >> l >> r;
 if(r-l>=673){
   cout << 0 << endl;
   return 0;
 }
 else{
   for(ll i=l;i<=r;i++){
     for(ll j=l+1;j<=r;j++){
       if(i>=j)continue;
       ll d=(i*j)%2019;
       ans=min(d,ans);
     }
   }
   cout << ans << endl;
 }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
int n,ans[200010],m[2][200010],all[2];
string x;
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n>>x;
    ans[0]=0;
    for(int i=1;i<=n;i++){
        ans[i]=ans[i%__builtin_popcount(i)]+1;
    }
    int popcnt=count(all(x),'1');
    if(popcnt==0){
        cout<<1<<endl;
        return 0;
    }
    if(popcnt==1){
        rep(i,n){
            if(x[i]=='0'){
                if(x[n-1]=='1'||i==n-1){
                    cout<<2<<endl;
                }
                else cout<<1<<endl;
            }
            else{
                cout<<0<<endl;
            }
        }
        return 0;
    }
    m[0][n-1]=1;
    for(int i=n-2;i>=0;i--){
        m[0][i]=m[0][i+1]*2%(popcnt-1);
    }
    m[1][n-1]=1;
    for(int i=n-2;i>=0;i--){
        m[1][i]=m[1][i+1]*2%(popcnt+1);
    }
    rep(i,n){
        if(x[i]=='1'){
            all[0]+=m[0][i];
            all[0]%=(popcnt-1);
        }
    }
    rep(i,n){
        if(x[i]=='1'){
            all[1]+=m[1][i];
            all[1]%=(popcnt+1);
        }
    }
    rep(i,n){
        if(x[i]=='0'){
            cout<<ans[(all[1]+m[1][i])%(popcnt+1)]+1<<endl;
        }
        else{

            cout<<ans[(all[0]-m[0][i]+(popcnt-1))%(popcnt-1)]+1<<endl;
        }
    }
    return 0;
}


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

int main(){
   char c[10001];
   int m,e,j;
   int n;
   
   while(1){
      cin >> n;
      if(n==0) break;
      for(int i=0; i<n; i++){
         cin >> m >> e >> j;
         if(m==100||e==100||j==100) c[i]='A';
         else if(m+e>=180) c[i]='A';
         else if(m+e+j>=240) c[i]='A';
         else if(m+e+j>=210) c[i]='B';
         else if(m+e+j>=150&&m>=80) c[i]='B';
         else if(m+e+j>=150&&e>=80) c[i]='B';
         else c[i]='C';
      }
      for(int i=0; i<n; i++) cout << c[i] << endl;
   }
   return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> a(n), b(m);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    for (int i = 0; i < m; i++) {
        cin >> b.at(i);
    }

    for (int top = 0; top <= n - m; top++) {
        for (int left = 0; left <= n - m; left++) {
            bool ok = true;
            for (int i = 0; i < m; i++) {
                for (int j = 0; j < m; j++) {
                    if (a.at(i + top).at(j + left) != b.at(i).at(j)) {
                        ok = false;
                        break;
                    }
                }
                if (!ok) break;
            }
            if (ok) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

int main(void){
    ll n;
    cin >> n;
    cout << n*(n-1)/2 << endl;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

void main() {
    while (true) {
        int n;
        scan(n);

        if (n == 0) return;

        auto map = new int[][](21, 21);

        foreach (i ; 0 .. n) {
            int xi, yi;
            scan(xi, yi);
            map[xi][yi]++;
        }

        int m;
        scan(m);

        int hsk;
        int px = 10, py = 10;

        foreach (i ; 0 .. m) {
            char di;
            int li;
            scan(di, li);

            foreach (j ; 0 .. li) {
                if (di == 'N') {
                    py++;
                }
                else if (di == 'S') {
                    py--;
                }
                else if (di == 'E') {
                    px++;
                }
                else {
                    px--;
                }

                hsk += map[px][py];
                map[px][py] = 0;
            }
            
        }

        debug {
            writeln(hsk);
        }

        writeln(hsk == n ? "Yes" : "No");
    }
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 3152
#include <iostream>
using namespace std;
int main(){
int n,t,a[3]={0};
cin>>n;
for(int i=0;i<n;i++){
cin>>t;
a[t%2==0?t%4==0?2:1:0]++;
}
if((a[1] && a[0] <= a[2]) || (!a[1] && a[0] <= a[2] +1))
cout<<"Yes"; else cout<<"No";
cout<<endl;
return 0;
}

Measured memory_bytes: 256
n = int(input())
l = []
for i in range(n):
    x,y = input().split()
    y = int(y)
    l.append([i+1,x,y])

l.sort(key=lambda x: (x[1],(x[2]*-1)))

for i in range(n):
    print(l[i][0])




Measured memory_bytes: 9100
// 2020-09-22 18:30:01
// clang-format off
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

// clang-format on
const int MX = 100010;
vector<int> G[MX];
int p[MX], c[MX];
void answer() {
  int n, m;
  cin >> n >> m;
  rep(i, n) {
    cin >> p[i];
    p[i]--;
  }
  rep(i, m) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  memset(c, -1, sizeof c);
  int w = 0;
  rep(i, n) if (c[i] == -1) {
    queue<int> que;
    que.push(i);
    c[i] = w;
    while (!que.empty()) {
      int u = que.front();
      que.pop();
      for (int v : G[u])
        if (c[v] == -1) {
          que.push(v);
          c[v] = w;
        }
    }
    w++;
  }
  int ans = 0;
  rep(i, n) ans += (c[i] >= 0 && c[i] == c[p[i]]);
  cout << ans << '\n';
}

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

Measured memory_bytes: 9780
#include <stdio.h>

int main()
{
	int i,k;
	int a,b;
	while(1){
		scanf("%d %d", &a, &b);
		if(a==0&&b==0){
			break;
		}
		else if(a<=300&&b<=300){
			for(i=0; i<a; i++){
				for(k=0; k<b; k++){
					if(i%2==0){
						if(k%2==0){
							printf("#");
						}
						else{
							printf(".");
						}
					}
					else{
						if(k%2==0){
							printf(".");
						}
						else{
							printf("#");
						}
					}
				}
				printf("\n");
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 572
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#

"""
AGC028 C
"""

from operator import itemgetter

n = int(input())
abli = []
for i in range(n):
    a, b = map(int, input().split())
    abli.append((a, i, 0))
    abli.append((b, i, 1))

abli.sort(key=itemgetter(0))
tmpans0 = sum(map(itemgetter(0), abli[:n]))
aiset = set([i for x, i, aorb in abli[:n] if not aorb])
biset = set([i for x, i, aorb in abli[:n] if aorb])
flag = bool(set.intersection(aiset, biset))


y, j, arob2 = abli[n]
z, k, arob3 = abli[n+1]

if flag:
    tmpans = tmpans0
else:
    min1 = y-max([x for x, i, aorb in abli[:n] if j != i])
    min2 = z-max([x for x, i, aorb in abli[:n] if j == i])
    tmpans = tmpans0 + min(min1, min2)

leftsum = sum([aa for aa, i, aorb in abli if not aorb])
rightsum = sum([bb for bb, i, aorb in abli if aorb])

print(min(leftsum, rightsum, tmpans))


Measured memory_bytes: 36164
count = Hash.new

('a'..'z').each do |key|
  count[key] = 0
end

while s = gets
  s = s.chomp.downcase.chars
  s.each do |s_i|
    if 'a' <= s_i && s_i <= 'z'
      count[s_i] += 1
    end
  end
end


('a'..'z').each do |key|
  puts "#{key} : #{count[key]}"
end



Measured memory_bytes: 6868
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)

string S;

signed main(){
	cin>>S;
	int ans=0,ans2=0;
	int mode=0;
	REP(i,S.size()){
		if(i%2==0&&S[i]=='0'){
			ans++;
		}
		else if(i%2==1&&S[i]=='1'){
			ans++;
		}
	}
	REP(i,S.size()){
		if(i%2==0&&S[i]=='1'){
			ans2++;
		}
		else if(i%2==1&&S[i]=='0'){
			ans2++;
		}
	}
	cout<<min(ans,ans2)<<endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#define llint long long
#define inf 1e18

using namespace std;

struct edge{
	llint to, cap, rev;
	edge(llint a, llint b, llint c){
		to = a, cap = b, rev = c;
	}
};

int n, m;
int a[105][105], b[105][105], c[105][105];
vector<int> vec[105][105];

vector<edge> G[255];
int S, T;
llint level[255], iter[255];

void bfs(llint s)
{
	for(int i = 0; i <= T; i++) level[i] = inf;
	level[s] = 0;
	
	queue<int> Q;
	Q.push(s);
	while(Q.size()){
		int v = Q.front();
		Q.pop();
		for(int i = 0; i < G[v].size(); i++){
			int u = G[v][i].to;
			if(G[v][i].cap <= 0 || level[u] < inf) continue;
			level[u] = level[v] + 1;
			Q.push(u);
		}
	}
}

llint dfs(int v, llint f)
{
	if(v == T) return f;
	
	llint ret;
	for(int i = iter[v]; i < G[v].size(); i++){
		if(level[v] >= level[G[v][i].to] || G[v][i].cap <= 0) continue;
		ret = dfs(G[v][i].to, min(f, G[v][i].cap));
		if(ret > 0){
			G[v][i].cap -= ret;
			G[G[v][i].to][G[v][i].rev].cap += ret;
			return ret;
		}
	}
	return 0;
}

void add_edge(int s, int t, llint cap)
{
	G[s].push_back(edge(t, cap, G[t].size()));
	G[t].push_back(edge(s, 0, G[s].size()-1));
}

int main(void)
{
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> a[i][j];
			a[i][j]--;
			vec[i][a[i][j]/m].push_back(a[i][j]);
		}
	}
	
	S = 2*n, T = 2*n+1;
	for(int z = 0; z < m; z++){
		
		for(int i = 0; i <= T; i++) G[i].clear();
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(vec[i][j].size() > 0) add_edge(j, n+i, 1);
			}
		}
		for(int i = 0; i < n; i++) add_edge(S, i, 1), add_edge(n+i, T, 1);
		
		llint ans = 0, flow;
		while(1){
			bfs(S);
			if(level[T] >= inf) break;
			for(int i = 0; i <= T; i++) iter[i] = 0;
			while(1){
				flow = dfs(S, inf);
				if(flow <= 0) break;
				ans += flow;
			}
		}
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < G[i].size(); j++){
				int v = G[i][j].to;
				if(G[i][j].cap > 0 || v < n || v >= 2*n) continue;
				v -= n;
				b[v][z] = vec[v][i].back(), vec[v][i].pop_back();
			}
		}
	}
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cout << b[i][j]+1 << " ";
		}
		cout << endl;
	}
	
	for(int j = 0; j < m; j++){
		vector<int> vec;
		for(int i = 0; i < n; i++) vec.push_back(b[i][j]);
		sort(vec.begin(), vec.end());
		for(int i = 0; i < n; i++) c[i][j] = vec[i];
	}
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cout << c[i][j]+1 << " ";
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1664
from collections import Counter

n = int(input())
a = list(map(int, input().split()))

c = Counter(a)
m = max(a)

flag = True

if m%2 == 0:
    for i in range(1,m+1):
        if i<m//2:
            if c[i]!=0:
                flag = False
                break
        elif i==m//2:
            if c[i]!=1:
                flag = False
                break
        else:
            if c[i]<2:
                flag = False
                break
else:
    for i in range(1,m+1):
        if i<=m//2:
            if c[i]!=0:
                flag = False
                break
        elif i==m//2+1:
            if c[i]!=2:
                flag = False
                break
        else:
            if c[i]<2:
                flag = False
                break

print('Possible' if flag else 'Impossible')

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


int main(){
    ll n;   cin >> n;
    bool ans=false;
    for(ll i=1; i<=n; i++){
        if(int(i*1.08)!=n) continue;
        cout << i << endl;
        ans = true;
    }
    if(!ans)
        cout << ":(" << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 
long long int N,M,K,res=0,A,B;
string S;

int main()
{
    cout << fixed << setprecision(18);
    cin>>K;
    N=100;
    for(long long int i = 1; i < 10000; i++){
        N=N+N/100;
        if(N>=K){cout<<i<<endl;return 0;}
    }
    
}

Measured memory_bytes: 3624
//Vol0 0017
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main()
{
	char s[128];
	int i,j,k;
	int c;
	while((gets(s))!=NULL){
		c=1;
		for(i=0;i<26;i++){
			for(j=0;j<strlen(s);j++){
				if(isalpha(s[j])){
					if(s[j]=='z'){
						s[j]='a';
					}else{
						s[j]++;
					}
				}
			}
			for(k=0;k<strlen(s)-1;k++){
				if((s[k]=='t')&&(s[k+1]=='h')){
					if(c){
						c=0;
						printf("%s\n",s);
					}
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 524
#include <iostream>
// #include <vector>
// #include <algorithm>
// #include <cmath>
// #include <math.h>
using namespace std;

int sum(int N){
    int s = 0;
    while(N > 0){
        s += N % 10;
        N /= 10;
    }
    return s;
}

int main(){
    int N;
    cin >> N;
    if (N % sum(N) == 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

INF = 10**20
def main():
    N = int(input())
    A = list(map(int,input().split()))

    seen = set()
    dup = set()
    ng = 0
    B = []

    for a in A:
        if not a in seen:
            B.append(a)
            seen.add(a)
        else:
            dup.add(a)


    out = set()
    mx = max(B)
    for b in B:
        c = 2
        while c * b <= mx:
            out.add(c * b)
            c += 1

    for a in A:
        if a in out or a in dup: ng += 1


    print(N-ng)






if __name__ == "__main__":
  main()


Measured memory_bytes: 218200
#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 q,n,x;
    cin>>q;
    bitset<64>a;
    REP(i,q){
        cin>>n;
    switch (n){
        case 0:
            cin>>x;
            cout<<a.test(x)<<endl;
        break;
        case 1:
            cin>>x;
            a.set(x);
        break;
        case 2:
            cin>>x;
            a.reset(x);
        break;
        case 3:
            cin>>x;
            a.flip(x);
        break;
        case 4:
            cout<<a.all()<<endl;
        break;
        case 5:
            cout<<a.any()<<endl;
        break;
        case 6:
            cout<<a.none()<<endl;
        break;
        case 7:
            cout<<a.count()<<endl;
        break;
        case 8:
            cout<<a.to_ullong()<<endl;
        break;
    }
    }
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define MOD 100000007

using namespace std;

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


int main() {
  int a, b;
  cin >> a >> b;
  if ((( a + b ) % 3) && (a % 3) && (b % 3))
    cout << "Impossible\n";
  else cout << "Possible\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int p[1007],c[1007],n,m;
long long f[10007],g[10007],ans,no;
queue<int>Q;
int main(){
	ios::sync_with_stdio(false);cin>>n>>m;ans=1007;
	for(int i=1;i<=n;i++)cin>>p[i]>>c[i];Q.push(0);
	while(!Q.empty()){
		int x=Q.front();Q.pop();
		for(int i=0;i<n;i++){
			if(x&(1<<i))continue;
			if(f[x]+p[i+1]*(i+1)*100+c[i+1]<m){
				Q.push(x|(1<<i));f[x|(1<<i)]=f[x]+p[i+1]*(i+1)*100+c[i+1];
				g[x|(1<<i)]=g[x]+p[i+1];
			}
			else {
				if(f[x]+p[i+1]*(i+1)*100<m)ans=min(ans,p[i+1]+g[x]);
				else {
					if((m-f[x])%(100*(i+1)))no=(m-f[x])/(100*(i+1))+1;else no=(m-f[x])/(100*(i+1));
					no+=g[x];ans=min(ans,no);
				}
			}
		}
	}
	cout<<ans<<endl;return 0;
}

Measured memory_bytes: 15140
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
input = sys.stdin.readline
INF = float("inf")


# 1-indexed
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]

    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1

    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]


# 処理内容
def main():
    N, M = map(int, input().split())

    T = UnionFind(N)
    for _ in range(M):
        a, b = map(int, input().split())
        T.Unite(a, b)
    
    ans = 0
    used = [False] * N
    for i in range(1,N+1):
        r = T.Find_Root(i) - 1
        if used[r] == False:
            used[r] = True
            ans += 1
    
    print(ans - 1)




if __name__ == '__main__':
    main()

Measured memory_bytes: 79168
import java.util.Scanner;
import java.util.Arrays;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        String[] str = new String[H];
        for(int i = 0;i < H;i++){
            str[i] = sc.next();
        }
        char[][] s = new char[H][W];
        for(int i = 0;i < H;i++){
            s[i] = str[i].toCharArray();
        }
        int[][] num = new int[H][W];
        int[] dx = {0,0,-1,1};
        int[] dy = {1,-1,0,0};
        for(int i = 0;i < H;i++){
            for(int j = 0;j < W;j++){
                if(s[i][j] == '.'){
                    continue;
                }
                boolean can = false;
                if(s[i][j] == '#'){
                    for(int k = 0;k < 4;k++){
                        int ni = i + dy[k];
                        int nj = j + dx[k];
                        if(nj < 0 || nj >= W){
                            continue;
                        }
                        if(ni < 0 || ni >= H){
                            continue;
                        }
                        if(s[ni][nj] == '#'){
                            can = true;
                        }
                    }
                }
                if(!can){
                    System.out.println("No");
                    return;
                }
            }
        }
        System.out.println("Yes");
    }
}


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

#define llint long long int
#define P (1000000000 + 7)

using namespace std;

int main(){
    string S;

    cin >> S;

    vector<vector<llint>> count(S.length(), vector<llint>(13, 0));

    if(S[S.length() - 1] == '?'){
        for(int i = 0; i < 10; i ++){
            count[S.length() - 1][i] = 1;
        }
    }else{
        count[S.length() - 1][S[S.length() - 1] - '0'] = 1;
    }
    vector<int> pow10(S.length());

    pow10[S.length() - 1] = 1;

    for(int i = S.length() - 2; i >= 0; i --){
        pow10[i] = (pow10[i + 1] * 10) % 13;
    }
    for(int i = S.length() - 2; i >= 0; i --){
        if(S[i] == '?'){
            for(int j = 0; j < 10; j ++){
                int d = (j * pow10[i]) % 13;

                for(int k = 0; k < 13; k ++){
                    count[i][(k + d) % 13] += count[i + 1][k];
                    count[i][(k + d) % 13] %= P;
                }
            }
        }else{
            int d = ((S[i] - '0') * pow10[i]) % 13;

            for(int j = 0; j < 13; j ++){
                count[i][(j + d) % 13] += count[i + 1][j];
                count[i][(j + d) % 13] %= P;
            }
        }
    }
    cout << count[0][5] << endl;
}

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

ll mod = 1000000007;

ll kai(ll x){
    if (x == 0) return 1;
    ll a = kai(x/2);
    a *= a;
    a = a % mod;
    if (x % 2 == 1) a *= 2;
    a = a % mod;
    return a;
}

ll kain(ll A, ll n){
    if (n == 0) return 1;
    ll a = kain(A, n / 2);
    a *= a;
    a = a % mod;
    if (n % 2 == 1) a *= A;
    a = a % mod;
    return a;
}

int main() {
    ll n, a, b; cin >> n >> a >> b;

    //2^n -1 mod を求める
    ll X = kai(n);

    //nCa mod を求める

    ll aa = 1;
    for (int i = 1; i <= a; i++){
        aa *= i;
        aa = aa % mod;
    }
    ll bb = 1;
    for (int i = 1; i <= b; i++){
        bb *= i;
        bb = bb % mod;
    }
    ll nna = 1;
    for (int i = 0; i < a ; i++){
        nna *= n - i;
        nna = nna % mod;
    }
    ll nnb = 1;
    for (int i = 0; i < b ; i++){
        nnb *= n - i;
        nnb = nnb % mod;
    }
    
    ll A = (nna * kain(aa, mod-2)) % mod;
    ll B = (nnb * kain(bb, mod-2)) % mod;

    ll ans = X - 1 - A - B;
    while(ans < 0){
        ans += mod;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

vint dx = {1,0};
vint dy = {0,1};

int h, w;
vector<string> field;

bool dfs(int x, int y, vector<string> field) {
    field[y][x] = '.';
    if (x == w-1 && y == h-1) {
        bool ok = true;
        rep(i,h)rep(j,w) if (field[i][j] == '#') ok = false;
        return ok;
    }
    bool res = false;
    rep(i,2) {
        int n_x = x + dx[i];
        int n_y = y + dy[i];
        if (n_x < w && n_y < h && field[n_y][n_x] == '#') {
            res |= dfs(n_x,n_y,field);
        }
    }
    return res;
}

int main() {
    cin >> h >> w;
    field.resize(h);
    rep(i,h) cin >> field[i];
    if (dfs(0,0,field)) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}

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

/**
 * @docs input_vector.md
 */
template <typename T>
std::vector<T> input_vector(int N){
  std::vector<T> ret(N);
  for(int i = 0; i < N; ++i) std::cin >> ret[i];
  return ret;
}

template <typename T>
std::vector<std::vector<T>> input_vector(int N, int M){
  std::vector<std::vector<T>> ret(N);
  for(int i = 0; i < N; ++i) ret[i] = input_vector<T>(M);
  return ret;
}


#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...)
#endif

namespace solver{
  constexpr int CONTEST = 26;
  
  int score(int D, std::vector<int> c, std::vector<std::vector<int>> s, std::vector<int> t){
    for(auto &x : t) x--;
    
    int ret = 0;
    std::vector<int> last(CONTEST, -1);

    for(int i = 0; i < D; ++i){
      ret += s[i][t[i]];
      last[t[i]] = i;

      for(int j = 0; j < CONTEST; ++j){
        ret -= c[j] * (i - last[j]);
      }

      std::cout << ret << "\n";
    }

    return ret;
  }
  
  void solve(){
    int D; std::cin >> D;
    auto c = input_vector<int>(CONTEST);
    auto s = input_vector<int>(D, CONTEST);
    auto t = input_vector<int>(D);

    score(D, c, s, t);
  }
}

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


Measured memory_bytes: 3696
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        long K = in.l();
        int[] A = new int[N];
        Arrays.setAll(A, i -> in.i() - 1);
        int ans = solve(N, K, A);
        out.println(ans);
    }

    static  int solve(int N, long K, int[] A) {
        int[] tel = new int[N + 1];
        int[] path = new int[N];
        path[0] = 1;
        int i = 1;
        int v = 0;
        while (true) {
            tel[i] = v = A[v];
            if (path[v] > 0) {
                break;
            }
            path[v] = ++i;
        }
        int pref = path[v] - 1;
        int loop = i - path[v] + 1;
        int ans = tel[(int)(Math.max(0, K - pref) % loop + Math.min(K, pref))] + 1;
        return ans;
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = read(cbuf, 0, cbuf.length);
            } catch (IOException e) {}
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (c != ' ' && c != '\n' && c != '\r') {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (true) {
            char c = next();
            if (c != ' ' && c != '\n' && c != '\r') {
                back();
                break;
            }
        }
    }

    char[] s(final int N) {
        skip();
        char[] s = new char[N];
        for (int i = 0; i < s.length; i++) {
            s[i] = next();
        }
        return s;
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 39020
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int n = b - a - 1;
		System.out.println(n * (n + 1) / 2 - a);
	}
}


Measured memory_bytes: 22740
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  int key;
  struct node *next;
  struct node *prev;
};

typedef struct node Node;

Node *nil;

Node* ListSearch(int key);
void init();
void printList();
void deleteNode(Node *t);
void deleteFirst();
void deleteLast();
void deletekey(int key);
void insert(int key);

int main(){
  int key,n,i,np=0,nd=0;
  int size=0;
  char c[20];

  scanf("%d",&n);
  init();
  for(i=0;i<n;i++){
    scanf("%s%d",c,&key);
    if(c[0]=='i'){
      insert(key);
      np++;
      size++;
    }
    else if(c[0]=='d'){
      if(strlen(c)>6){
	if(c[6]=='F') deleteFirst();
	else if(c[6]=='L') deleteLast();
      }
      else{
	deletekey(key);
	nd++;
      }
      size--;
    }
  }

  printList();
  
  return 0;
}

Node* ListSearch(int key){
  Node *cur;
  cur=nil->next;
  while(cur!=nil && cur->key != key){
    cur=cur->next;
  }
  return cur;
}

void init(){
  nil=(Node *)malloc(sizeof(Node));
  nil->next=nil;
  nil->prev=nil;
}

void printList(){
  Node *cur;
  cur=nil->next;
  int isf=0;
  while(1){
    if(cur==nil) break;
    if(isf++>0) printf(" ");
    printf("%d",cur->key);
    cur=cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t){
  if(t==nil) return;
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}


void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
 deleteNode(nil->prev);
}

void deletekey(int key){
deleteNode(ListSearch(key));
}

void insert(int key){
  Node *x;
  x=malloc(sizeof(struct node));
  x->key=key;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	ll S; cin >> S;
	ll y = ceil((double)S / 1e9);
	ll x = (ll)(y * 1e9) - S;
	cout << "0 0 1000000000 1 " << x << " " << y << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int n, q, k;
vector<pii> edge[100005];
int dist[100005];

int dfs(int v) {

    for(auto&&i:edge[v]) {
        int u = i.second;
        if(dist[u]==-1) {
            dist[u] = dist[v] + i.first;
            dfs(u);
        }
    }
}

signed main() {

    int a, b, c;

    cin >> n;
    for(int i = 0; i < n-1; i++) {
        cin >> a >> b >> c;
        edge[a].bash(pii(c,b));
        edge[b].bash(pii(c,a));
    }

    cin >> q >> k;
    
    memset(dist,-1,sizeof(dist));
    dist[k] = 0;
    dfs(k);

    for(int i = 0; i < q; i++) {
        cin >> a >> b;
        cout << dist[a] + dist[b] << endl;
    }

        

  
    return 0;
}



Measured memory_bytes: 12800
# coding: utf-8

n = input()
ss = [raw_input() for _ in xrange(n)]

ws = {}
for s in ss:
    if s not in ws:
        ws[s] = 1
    else:
        ws[s] += 1

m = max(ws[k] for k in ws)
for x in sorted(k for k in ws if ws[k] == m):
    print x



Measured memory_bytes: 32272
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    if((b- a) & 1){
    	cout << "Borys" << endl;
    }else{
    	cout << "Alice" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
ans = []
while N > 0:
    if N%26 == 0:
        ans.append(26)
        N //= 26
        N -= 1
    else:
        ans.append(N%26)
        N //= 26
print("".join([chr(ord('a') + x-1) for x in reversed(ans)]))


Measured memory_bytes: 9068
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>


/* 
*    coder :: ATUL_PANDEY_2608
*        >>> INDIA <<<
*/
using namespace std;
using namespace __gnu_pbds;

// #define  part ..
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end() 
long long  mod = 1000000007;
//#define maxx 200006
#define ll long long 
#define quick    ios_base::sync_with_stdio(NULL),cin.tie(0);
#define listll vector< long long > 
#define listi vector< int> 
#define pii   pair<int , int> 
#define pll pair<long long , long long > 
#define minheap priority_queue<long long , vector< long long >, greater<long long > >
#define rep(i,a,b) for(int i=a;i<b;i++)
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


template < class T > using oset = tree< T , null_type, less  < T  > , rb_tree_tag , tree_order_statistics_node_update > ;


// end of #define 

// define globals ...
const int maxx = 2e5+26;

//write function from here ...








int Main(){

string s;
cin>>s;
cout<<s.substr(0,3);






return 0;

}

















int main(){
 quick;
int t =1; 
//cin>>t;
while(t-- )
 Main();

 return 0;


}


Measured memory_bytes: 3588