akhauriyash/Code-Regression huggingface dataset:
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()

p = list(map(int, input().split()))

if not(x in p):
    print(x)
    exit()

p_max = max(p)
p_min = min(p)

ans_max = -1
for i in range(x + 1, p_max + 2):
    if not(i in p):
        ans_max = i
        break
    ans_max = p_max + 1

ans_min = 101
for i in range(x - 1, p_min - 2, -1):
    if not(i in p):
        ans_min = i
        break
    ans_min = p_min - 1

if abs(x - ans_max) < abs(x - ans_min):
    print(ans_max)
else:
    print(ans_min)



Measured memory_bytes: 9212
fn get_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (n, m) = {
        let nm = get_line()
            .split_whitespace()
            .map(|e| e.parse().unwrap())
            .collect::<Vec<u64>>();
        (nm[0], nm[1])
    };

    let total = get_line()
        .split_whitespace()
        .map(|n| n.parse::<u64>().unwrap())
        .fold(0, |sum, x| sum + x);

    if n < total {
        println!("-1");
    } else {
        println!("{}", n - total);
    }
}


Measured memory_bytes: 2152
import Data.Char

main = do
  [a, b] <- map read . words <$> getLine
  s <- getLine
  if solve a b s
    then putStrLn "Yes"
    else putStrLn "No"


solve a b s = all isDigit (take a s) && all isDigit (drop (a + 1) s) && s !! a == '-'


Measured memory_bytes: 508
#include<stdio.h>

int main(void){
    int H,W;
    int i,j,k;
    
    for(k=1;k<1000;k++){
        scanf("%d %d",&H,&W);
        if(H!=0||W!=0){
            for(i=1;i<=W;i++){
                printf("#");
            }
            printf("\n");
            for(j=2;j<H;j++){
                printf("#");
                for(i=2;i<W;i++){
                    printf(".");
                }
                printf("#\n");
            }
            if(H>=2){
                for(i=1;i<=W;i++){
                    printf("#");
                }
            }
            printf("\n\n");
        }
    }
    
    return 0;
}



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

int main() {
  //cout << "文字列" << endl;で文字列を出力できる
  //cin >> 変数 で入力を受け取ることができる
  int R,G;
  cin >> R;
  cin >> G;
  int a;
  a = 2*G-R;
  cout << a << endl;
}

Measured memory_bytes: 256
s = input()
k = int(input())
if len(set(s)) == 1:
    print((len(s)*k)//2)
else:
    l_list = []
    check = s[0]
    cnt = 1
    for i in s[1:]:
        if check == i:
            cnt += 1
        else:
            l_list.append(cnt)
            check = i
            cnt = 1
    l_list.append(cnt)
    ans = 0
    if s[0] == s[-1]:
        for i, l in enumerate(l_list):
            if 0 < i < len(l_list)-1:
                ans += (l//2)*k
            else:
                ans += l//2
        ans += ((l_list[0]+l_list[-1])//2)*(k-1)
    else:
        for l in l_list:
            ans += (l//2)*k
    print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG arc/arc071/c.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    int cnt[51][26];
    string alp = "abcdefghijklmnopqrstuvwxyz";
    int n;
    cin >> n;
    rep(i, n){
        rep(j, 26){
            cnt[i][j] = 0;
        }
    }

    rep(i, n){
        string s;
        cin >> s;
        rep(j, s.length()){
            cnt[i][s[j] - 'a']++;
        }
    }

    int com[26];
    rep(j, 26){
        int m = 5000;
        rep(i, n){
            if(m > cnt[i][j]) m = cnt[i][j];
        }
        com[j] = m;
    }

    rep(i, 26){
        rep(j, com[i]){
            cout << alp[i];
        }
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, K = map(int,input().split())
P = list(map(int,input().split()))
count = 0
first = 1
def init(init_val,n):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2])

def segfunc(x,y):
    return max([x,y])

def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])

def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#####単位元######
ide_ele = 0

#num:n以上の最小の2のべき乗
num =2**(N-1).bit_length()
seg=[ide_ele]*2*num

def init2(init_val,n):
    #set_val
    for i in range(n):
        seg2[i+num-1]=init_val[i]
    #built
    for i in range(num-2,-1,-1) :
        seg2[i]=segfunc2(seg2[2*i+1],seg2[2*i+2])

def segfunc2(x,y):
    return min([x,y])

def update2(k,x):
    k += num-1
    seg2[k] = x
    while k:
        k = (k-1)//2
        seg2[k] = segfunc2(seg2[k*2+1],seg2[k*2+2])

def query2(p,q):
    if q<=p:
        return ide_ele2
    p += num-1
    q += num-2
    res=ide_ele2
    while q-p>1:
        if p&1 == 0:
            res = segfunc2(res,seg2[p])
        if q&1 == 1:
            res = segfunc2(res,seg2[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc2(res,seg2[p])
    else:
        res = segfunc2(segfunc2(res,seg2[p]),seg2[q])
    return res

#####単位元######
ide_ele2 = 10**9

#num:n以上の最小の2のべき乗
num =2**(N-1).bit_length()
seg2=[ide_ele2]*2*num

l = [0]*(N-1)
for i in range(len(l)):
    if P[i]>=P[i+1]:
        l[i] = 1
l2 = [0]*(N-K+1)
tmp = sum(l[0:K-1])
for i in range(N-K+1):
    if tmp==0:
        l2[i]=1
    if i != N-K:
        tmp += (l[i+K-1]-l[i])
init(P,N)
init2(P,N)
for i in range(N-K+1):
    if l2[i]==1:
        if first == 1:
            count += 1
            first = 0
        continue
    elif  (P[i-1] < query2(i,i+K-1)) and (P[i+K-1] > query(i,i+K-1)) and (i!=0):
        continue
    else:
        count += 1
print(count)


Measured memory_bytes: 98124
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stack>
#include<vector>
#include<cmath>
#include<string>
#include<queue>
#include<map>
#include<cstring>
#include<sstream>
#include<vector>
#include<algorithm>
#include<functional>
#include<set>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<time.h>
typedef long long ll;
using namespace std;

int gcd(int a, int b) {
	//cout << "a: " << a << "b: " << b << endl;
	return b ? gcd(b, a%b) : a;
}
int main() {
	//freopen("run.in", "r", stdin);
	//freopen("run.out", "w", stdout);

	int m, n;
	while (cin >> n>>m) {
		cout << gcd(m, n) << endl;
	}

	return 0;

}

Measured memory_bytes: 3116
#include <bits/stdc++.h> 
using namespace std; 
  
void precisionCompute(int x, int y, int n) 
{ 
    // Base cases 
    if (y == 0) { 
        cout << "Infinite" << endl; 
        return; 
    } 
    if (x == 0) { 
        cout << 0 << endl; 
        return; 
    } 
    if (n <= 0) { 
        // Since n <= 0, don't compute after 
        // the decimal 
        cout << x / y << endl; 
        return; 
    } 
  
    // Handling negative numbers 
    if (((x > 0) && (y < 0)) || ((x < 0) && (y > 0))) { 
        cout << "-"; 
        x = x > 0 ? x : -x; 
        y = y > 0 ? y : -y; 
    } 
  
    // Integral division 
    int d = x / y; 
  
    // Now one by print digits after dot 
    // using school division method. 
    for (int i = 0; i <= n; i++) { 
        cout << d; 
        x = x - (y * d); 
        if (x == 0) 
            break; 
        x = x * 10; 
        d = x / y; 
        if (i == 0) 
            cout << "."; 
    } 
}
int main() 
{ 
    int a;
    cin>>a;
    int x=a-ceil(a/2);
    int  y = a, n = 9; 
    precisionCompute(x, y, n); 
    return 0; 
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,N) for(auto i=0; i<N; ++i)
#define ALL(x) x.begin(), x.end()
using namespace std;
using ll=long long;
signed main()
{
	ll N,M; cin >> N >> M;
	vector< vector< ll > > children(N+1);
	FOR(i,M) {
		ll a, b;		cin >> a >> b;
		children[a].push_back(b);
		children[b].push_back(a);
	}
	vector<ll> PERM(N); iota(ALL(PERM), 1);
	ll ans = 0;
	do {
		bool ok = true;
		if (PERM[0] != 1) continue;
		FOR(i, N-1) { auto v = PERM[i]; auto nextv = PERM[i+1];
			if( find(ALL(children[v]),  nextv) == children[v].end()) {
				ok = false; break;
			}
		}
		if (ok) ans += 1;
	} while (next_permutation(ALL(PERM))) ;
	
	cout << ans << endl;
	return 0;
}

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

namespace WelcomeAtcordet
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            int ans = int.MaxValue;
            for (long i = 1; i * i <= N; i++)
            {
                if (N % i == 0)
                {
                    long A = i;
                    long B = N / i;

                    int digit = Math.Max((A.ToString()).Length, (B.ToString()).Length);
                    if (digit < ans)
                    {
                        ans = digit;
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int A,B;
    cin >> A >> B;
    cout << A * B << endl;
}



Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
using P=pair<int,int>;
int main() {
    int n,k;cin>>n>>k;
    int result;
    if((n-1)%(k-1)==0) result=(n-1)/(k-1);
    else result=((n-1)/(k-1))+1;
    cout<<result<<endl;
}

Measured memory_bytes: 256
n = int(input())
ans = [0,0,0,0]

for i in range(n):
  tmp = input()
  if tmp == "AC":
    ans[0] += 1
  elif tmp == "WA":
    ans[1] += 1
  elif tmp == "TLE":
    ans[2] += 1
  else:
    ans[3] += 1
    
print("AC x",ans[0])
print("WA x",ans[1])
print("TLE x",ans[2])
print("RE x",ans[3])

Measured memory_bytes: 69872
var a,b,c,i,j,k,x,cnt:Longint;
begin
read(a,b,c,x);
for i:=0 to a do
	for j:=0 to b do
		for k:=0 to c do
			if i*500+j*100+k*50=x then cnt:=cnt+1;
write(cnt)
end.


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
  	int	h1;
  	int	m1;
  	int	h2;
  	int	m2;
  	int	k;
  	int	s;
  	int	e;
  	int	d;
  
  	scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
  
  	s = h1 * 60 + m1;
  	e = h2 * 60 + m2;
  	d = e - s;
  	
    printf("%d", d - k);
  	return (0);
}
      
  	

Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
using namespace std;
long long MOD = 1e9 + 7;

long long N;
vector<long long> comp;
vector<vector<long long>>DP;

int main() {
	cin >> N;
	comp.resize(N);
	string S;
	cin >> S;
	for (long long n = 1; n <= N - 1; n++) {
		if (S[n-1] == '>')comp[n] = 1;
		else comp[n] = -1;
	}
	DP.resize(N + 1,vector<long long>(N+1,0));
	for (long long n = 1; n <= N; n++)DP[1][n] = 1;
	for (long long n = 2; n <= N; n++) {
		if (comp[n - 1] == 1) {
			DP[n][n] = 0;
			for (long long j = n - 1; j >= 1; j--) {
				DP[n][j] = (DP[n - 1][j] + DP[n][j + 1]) % MOD;
			}
		}
		else {
			DP[n][1] = 0;
			for (long long j = 1; j <= N; j++) {
				DP[n][j] = (DP[n][j - 1] + DP[n - 1][j - 1]) % MOD;
			}
		}
	}
	long long ans = 0;
	for (long long n = 1; n <= N; n++) {
		ans = (ans + DP[N][n]) % MOD;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main(void){
  int h, n, a;

  cin >> h >> n;
  int s = 0;

  for (int i = 0; i < n; i++){
    cin >> a;
    s += a;
  }


  if (h <= s)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())
three = 0
six = 0
same = 0
for a in range(1,K+1):
  for b in range(a, K+1):
    for c in range(b, K+1):
      if(a != b and b != c and a != c):
        six += gcd(a,b,c)
      elif(a == b and b == c and c == a):
        same += a
      else:
        three += gcd(a,b,c)

print(six * 6 + three * 3 + same) 

Measured memory_bytes: 9636
import java.util.Scanner;

public class Main {
	private static Main instance = new Main();
	
	private Scanner scanner = new Scanner(System.in);
	
	public static void main(String[] args) {
		instance.solve();
	}
	
	private void solve() {
		int answer = 1;
		int a = scanner.nextInt();
		
		int b = scanner.nextInt();
		if(a != b) answer++;
		
		int c = scanner.nextInt();
		if(c != a && c != b) answer++;
		
		System.out.printf("%d", answer);
	}
}


Measured memory_bytes: 9812
S=input()
s=len(S)
K=int(input())
A=[]
for i in range(s):
  A.append(S[i])
for i in range(s-1):
  A.append(S[i:i+2])
for i in range(s-2):
  A.append(S[i:i+3])
for i in range(s-3):
  A.append(S[i:i+4])
for i in range(s-4):
  A.append(S[i:i+5])
B=sorted(set(A))
print(B[K-1])

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

#define Fast            ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define fWrite          freopen ("out.txt","w",stdout);
#define TC              int t;cin >> t;FOR(tc,1,t)
#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define all(a)          a.begin(),a.end()
#define MEM(a,x)        memset(a,x,sizeof(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)

int main()
{
    double r;
    cin >> r;
    cout << fixed << setprecision(5) << 3.14159265358*2.0*r;
}


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

bool isok(string &s, int i){
  if(s.size() == i) return true;
  bool ans = false;
  if(s.substr(i,7) == "dreamer") ans = (isok(s,i+7)||ans);
  if(s.substr(i,5) == "dream") ans = (isok(s,i+5)||ans);
  if(s.substr(i,6) == "eraser") ans = (isok(s,i+6)||ans);
  if(s.substr(i,5) == "erase") ans = (isok(s,i+5)||ans);
  if(ans) return true;
  else return false;
}

int main(){
  string s;
  cin >> s;
  if(isok(s,0)) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 2048
#include <iostream>

using namespace std;

int main() {
	int a = 0;
	int b = 0;
	int c = 0;
	cin >> a >> b >> c;
	if ((a >= b) || (b >= c)) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
}


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

int main() {
  int n;
  cin >> n;
  int close = 1001, far = -1;
  rep(i,n){
    int a;
    cin >> a;
    close = min(close, a);
    far = max(far, a);
  }
  int ans = far - close;

  cout<<ans<<endl;
  return 0;
}


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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 

	int n , m;
	cin >> n >> m;
	
	vector<vi> a(n , vi(m));
	rep(i , n){
		rep(j , m){
			cin >> a[i][j];
			--a[i][j];
		}
	}

	
	vi used(m , 1);
	
	int ans = INF;
	
	rep(k , m){
		vi fr(m , 0);
		rep(i , n){
			rep(j , m){
				if(used[a[i][j]]){
					++fr[a[i][j]];
					break;
				}
			}
		}
		int mxi = 0 , mxv = fr[0];
		repi(i , m - 1){
			if(mxv < fr[i]){
				mxv = fr[i];
				mxi = i;
			}
		}
		ans = min(ans , mxv);
	//	cout << ans << nl;
		used[mxi] = 0;
	}
	cout << ans;

	return 0;
}

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

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define Ft first
#define Sd second
using ll = long long;
using pii = pair<int, int>;
constexpr ll MAX = 1e6+5;
constexpr ll INF = 2134567890;
constexpr ll MOD = 998244353;

ll fpow(ll b, ll a, ll MOD = MOD) {
    b %= MOD;
    ll r = 1;
    for(; a; b=b*b%MOD, a>>=1)
        a&1 && (r = r*b%MOD);
    return r;
}

signed main() {
    FAST;

    string s;
	cin >> s;
  	Fr(i, 0, s.size()) cout << 'x';
  	cout << endl;

}


Measured memory_bytes: 256
from itertools import combinations_with_replacement
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,m,q=INTM()
    aq=[]
    for i in range(q):
        aq.append(LIST())
    number = [int(i+1) for i in range(m)]
    
    ans=0
    for i in combinations_with_replacement(number,n):
        temp=0
        for k in aq:
            if i[k[1]-1]-i[k[0]-1]==k[2]:
                temp+=k[3]
        ans=max(ans,temp)
    print(ans)
    
if __name__ == '__main__':
    do()

Measured memory_bytes: 9148
#include<cstdio>
#include<algorithm>
using namespace std;
int D[201000][4], n;
char p[201000];
bool Same(int a, int b, int c) {
	int i;
	for (i = 0; i < c; i++) {
		if (p[a] != p[b])return false;
		a--, b--;
	}
	return true;
}
int main() {
	scanf("%s", p + 1);
	int i, j, k;
	for (i = 1; p[i]; i++);
	n = i - 1;
	for (i = 0; i <= n; i++)for (j = 0; j < 4; j++)D[i][j] = -1e9;
	D[0][0] = 0;
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= 3 && j<=i; j++) {
			int t = i - j;
			for (k = 0; k <= 3; k++) {
				if (k > t)continue;
				if (j == k && Same(i, t, j))continue;
				D[i][j] = max(D[i][j], D[t][k] + 1);
			}
		}
	}
	int res = 0;
	for (i = 0; i <= 3; i++)res = max(res, D[n][i]);
	printf("%d\n", res);
}

Measured memory_bytes: 3456
#include <iostream>
#include <set>
#include <cstring>
using namespace std;

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

int H, W;
ll ans[10];
set<P> st;

void calc(int a, int b) {
  int ssi = max(a - 2, 1);
  int ssj = max(b - 2, 1);
  int ggi = min(a, H - 2);
  int ggj = min(b, W - 2);
  for (int si = ssi; si <= ggi; si++) {
    for (int sj = ssj; sj <= ggj; sj++) {
      int cnt = 0;
      for (int i = si; i < si + 3; i++) {
	for (int j = sj; j < sj + 3; j++) {
	  if (st.find(P(i, j)) != st.end()) {
	    cnt++;
	  }
	}
      }
      ans[cnt - 1]--;
      ans[cnt]++;
    }
  }
}

int main() {
  int N;

  while (cin >> H >> W >> N) {
    st.clear();
    memset(ans, 0, sizeof(ans));
    ans[0] = ((ll)H - 2) * ((ll)W - 2);
    for (int i = 0; i < N; i++) {
      int a, b;
      cin >> a >> b;
      st.insert(P(a, b));
      calc(a, b);
    }
    for (int i = 0; i < 10; i++) {
      cout << ans[i] << endl;
    }
  }
}


Measured memory_bytes: 4992
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for C - ID
	var N, M int
	fmt.Scan(&N, &M)

	var P, Y int
	ans := make(map[int]int, M)
	year := make([]int, M)
	year1 := make([]int, M)

	city := make([]int, M)
	sc.Split(bufio.ScanWords)
	for i := 0; i < M; i++ {
		P = nextInt()
		Y = nextInt()
		ans[Y] = P
		year[i] = Y
		year1[i] = Y
		city[i] = P
	}

	ans1 := make(map[int]int, M)
	temp := make(map[int]int, M)
	sort.Sort(sort.IntSlice(year))
	for i := 0; i < M; i++ {
		temp[ans[year[i]]]++

		//fmt.Println(year[i], ans[year[i]], temp[ans[year[i]]])
		ans1[year[i]] = temp[ans[year[i]]]
	}

	for i := 0; i < M; i++ {
		fmt.Printf("%06d%06d\n", city[i], ans1[year1[i]])
	}
}


Measured memory_bytes: 14680
s = input()

def dfs(i, f, sum):
    if i == 3:
        if sum == 7:
            print(f + "=7")
            exit()
    else:
        dfs(i + 1, f + "+" + s[i + 1], sum + int(s[i + 1]))
        dfs(i + 1, f + "-" + s[i + 1], sum - int(s[i + 1]))


dfs(0, s[0], int(s[0]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    string ans = "Yay!";
    if (e-a>k) ans = ":(";
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		BigDecimal X = new BigDecimal(sc.next());
		BigDecimal Y = new BigDecimal("100");
		BigDecimal y = new BigDecimal("1.01");
		int count = 0;
		while (Y.compareTo(X) == -1) {
			Y = Y.multiply(y).setScale(0, RoundingMode.DOWN);
			count++;
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 36488
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include<limits.h>
#include<algorithm>


#define MOD 1000000007

using namespace std;

long long int modpow(long long int a, long long int n) {
	if (n == 0)return 1;
	if (n == 1)return (a % MOD);

	long long int hanbun = n / 2;
	long long int amari = n % 2;

	long long int ans = (a * a) % MOD;
	ans = modpow(ans, hanbun);

	if (amari == 1)ans *= a;

	ans %= MOD;

	return ans;

}

long long int gcd(long long int a, long long int b) {
	if (a < b) {
		long long int tmp = a;
		a = b;
		b = tmp;
	}

	long long int amari = a % b;

	if (amari == 0)return b;

	return gcd(b, amari);
}

long long int lcm(long long int a, long long int b) {
	long long int ans = (a * b) % MOD;
	long long int wari = modpow(gcd(a, b), MOD - 2);
	ans = (ans * wari) % MOD;
	return ans;
}

long long int factElement[10000] = { 0 };

long long int factrial(int n) {

	if (factElement[n] != 0)return factElement[n];

	if (n == 0) {
		factElement[0] = 1;
		return factElement[n];
	}

	long long int ans = n * factrial(n - 1);
	factElement[n] = ans;
	return factElement[n];

}





int main()
{

	int n;
	cin >> n;

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

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

	for (int i = 0; i < n - 1; i++) {
		if (a[i] == a[i + 1]) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;






	return 0;



}



Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        
        int ans = 0;
        int x = 1;
        for(int i = 0; i < n; i++){
            int a = Integer.parseInt(sc.next());
            if(a == x){
                x++;
            }else{
                ans++;
            }
        }
        if(x == 1) ans = -1;
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 48932
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }






int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	vector<int> b(100001);
	rep(i,n){
		if(a.at(i) > 100000) continue;
		b.at(a.at(i))++;
	}
	int ans = n;
	rep(i,100001) if(b.at(i) >= i) ans -= i;
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main() {
    vector<int> A(3);
    for (int i = 0; i < 3; i++) cin >> A[i];
    sort(A.begin(), A.end());

    int sum = 0;
    for (int i = 0; i < 2; i++) {
        sum += A[i];
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3632
import heapq

def main():
    X, Y, Z, K = map(int,input().split())
    A = [int(o) for o in input().split()]
    B = [int(o) for o in input().split()]
    C = [int(o) for o in input().split()]
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)
    A_size = len(A)
    B_size = len(B)
    C_size = len(C)
    heap = []
    heapq.heappush(heap,(-(A[0]+B[0]+C[0]),0,0,0))
    for i in range(K):
        val,a,b,c = heapq.heappop(heap)
        if a < (A_size-1) and (-(A[a+1]+B[b]+C[c]),a+1,b,c) not in heap:
            heapq.heappush(heap,(-(A[a+1]+B[b]+C[c]),a+1,b,c))
        if b < (B_size-1) and (-(A[a]+B[b+1]+C[c]),a,b+1,c) not in heap:
            heapq.heappush(heap,(-(A[a]+B[b+1]+C[c]),a,b+1,c))
        if c < (C_size-1) and (-(A[a]+B[b]+C[c+1]),a,b,c+1) not in heap:
            heapq.heappush(heap,(-(A[a]+B[b]+C[c+1]),a,b,c+1))
        print(-val)
if __name__ == "__main__" :
    main()

Measured memory_bytes: 3828
#include<iostream>
using namespace std;
typedef unsigned long long int ll;
const ll maxim=1e18L;
int main()
{
    ll n;
    cin>>n;
    ll a[n];
    bool zero=false;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i] == 0)
            zero=true;
    }
    if(zero)
    {
        cout<<0<<endl;
        return 0;
    }
    ll product = a[0];
    bool possible=true;
    for(int i=1;i<n;i++)
    {
        if(product > maxim / a[i])
        {
            possible = false;
            break;
        }
        product = product * a[i];
    }
    if(possible)
        cout<<product<<endl;
    else
        cout<<-1<<endl;
}


Measured memory_bytes: 4432
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = ns()
n = len(s)+1
a = [0]*n

c = 0
for i in range(n-1):
    if s[i] == '<':
        c+=1
        a[i+1] = c
    else:
        c = 0

c = 0
for j in range(1,n):
    if s[-j] == '>':
        c+=1
        a[-j-1] = max(a[-j-1],c)
    else:
        c = 0

print(sum(a))

Measured memory_bytes: 23372
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    string s;
    cin >> s;
    ll n = s.size();

    string ans = "";
    rep(i, n) {
        if(s[i] == '0') {
            ans = ans + "0";
        }
        else if(s[i] == '1') {
            ans = ans + "1";
        }
        else if(s[i] == 'B') {
            if(ans != "") {
                ans.pop_back();
            }
        }
    }

    out(ans);
    re0;
}

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

int main() {
  long long a;
  double b;
  cin >> a >> b;
  ll lb = 100 * b + 0.5;
  a *= lb;
  a /= 100;
  cout << a << endl;
  return 0;
}


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

const int maxN=410;
const int maxM=101000;

int n,m;
int P1[maxM],P2[maxM],Mark[maxN];
bitset<maxN> B[maxN];

int main(){
    scanf("%d%d",&n,&m);for (int i=1;i<=m;i++) scanf("%d%d",&P1[i],&P2[i]);
    for (int i=1;i<=n;i++){
	B[i][i]=1;
	for (int j=m;j>=1;j--)
	    if (B[i][P1[j]]&&B[i][P2[j]]){
		Mark[i]=1;break;
	    }
	    else if (B[i][P1[j]]||B[i][P2[j]]) B[i][P1[j]]=B[i][P2[j]]=1;
    }
    int Ans=0;
    for (int i=1;i<=n;i++) for (int j=i+1;j<=n;j++) if (!Mark[i]&&!Mark[j]&&!(B[i]&B[j]).any()) ++Ans;
    printf("%d\n",Ans);return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include<stdio.h>
#include<cstring>
using namespace std;

int main()
{
    int A,B,C,X,Y;
    while(cin>>A){
            int money=0;
        cin>>B>>C>>X>>Y;
        if((A+B)/2.0>C){
            if((A>2*C||B>2*C)){if(A<B){if(B>2*C){
                money=money+C*2*Y;
                X=X-Y;
                Y=0;
            }if(A>2*C&&X>0){
                money=money+C*2*X;
                Y=Y-X;
                X=0;
            }else if(X>0){money=money+X*A;X=0;}}else{if(A>2*C){
                money=money+C*2*X;
                Y=Y-X;
                X=0;
            }if(B>2*C&&Y>0){
                money=money+C*2*Y;
                X=X-Y;
                Y=0;
            }else if(Y>0){money=money+Y*B;Y=0;}}}else{
            int t=(X>Y?Y:X);
            money=money+2*t*C+(X-t)*A+(Y-t)*B;
            }
        }else{
            money=money+A*X+B*Y;
        }
        cout<<money<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;

int main() {
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
	
	ll n;
	cin >> n;
	vector<ll> arr(n,0);
	ll txor = 0;
	for(ll i=0;i<n;i++){
		cin >> arr[i];
		txor^=arr[i];
	}
	//cout << txor << endl;
	for(ll i=0;i<n;i++){
		cout << (arr[i]^txor) << " ";
	}

    

    return 0;
}


Measured memory_bytes: 4836
{
  type Print = void | string | number | string[] | number[];
  const outs: Print[] = [];
  const _io = (i = 0) => {
    // eslint-disable-next-line @typescript-eslint/no-var-requires
    const str = require("fs").readFileSync("/dev/stdin", "utf8");
    const lines = str.trim().split("\n");
    const s = () => lines[i++] || "";
    const n = () => Number(s());

    const mn = (v: string[]) => v.map(Number);
    const sp = (v: string) => v.split(" ");

    const ss = () => sp(s());
    const nn = () => mn(ss());
    const nls = () => mn(lines.slice(i));
    const nnls = () => lines.slice(i).map((v: string) => mn(sp(v)));

    return { lines, s, n, ss, nn, nls, nnls };
  };
  const main = (): Print => {
    const r = _io();
    const [s] = r.ss();
    // 以下入れ替え
    return getMultipleOne(Number(s));
  };
  /**
   * get how many times as one circle area
   *
   * @param radius - The circle area
   * @returns how many times as one circle area
   *
   */
  const getMultipleOne = (radius: number): number => {
    return (radius * radius) / 1;
  };

  outs.push(main());

  console.log(
    outs
      .map((line) => (typeof line === "object" ? line.join(" ") : String(line)))
      .join("\n")
  );
}


Measured memory_bytes: 29648
#include<bits/stdc++.h>
using namespace std;
long long n,ans=0;
int main()
{
	cin>>n;
	for(long long i=1;;i++)
	{
		long long a=i*i;
		if(a>=n)
		break;
		if(n%i==0&&(n/i-1)>i)
		ans+=n/i-1;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for y in range(0, H):
        for x in range(0, W):
            if x == 0 or x == W - 1 or y == 0 or y == H - 1:
                print('#', end = '')
            else:
                print('.', end = '')
        print('')
    print('')



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

#define rep(i, n) for(int (i) = 0; i < (n); ++(i))

using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
  int A, B, C, D;
  std::cin >> A >> B >> C >> D;

  while(A > 0 && C > 0) {
    C -= B;
    if(C <= 0) {
      std::cout << "Yes" << '\n';
      return 0;
    }
    A -= D;
    if(A <= 0) {
      std::cout << "No" << '\n';
      return 0;
    }
  }
}


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

#define loop(i,a,b) for(ll i=a; i<b; i++)
#define rloop(i,a,b) for(ll i=a; i>b; i--)
#define all(var) var.begin(), var.end()
#define eloop(var) for(auto elem : var)
#define debug(x) cerr<<#x<<" ----> "<<x<<endl;
#define PB push_back
#define MP make_pair
#define tt ll TT; cin>>TT; while(TT--)
#define F first
#define S second
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define INF 0x7fffffff
#define LINF 2000000000000000007
#define MOD 1000000007
#define MAX 100005
typedef long long ll;
typedef long double ld;

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

    //tt
    {
        ll a,b;
        cin>>a>>b;
        string s = "", t= "";
        loop(i,0,a)
            s += '0'+b;
        loop(i,0,b)
            t += '0'+a;
        if(s<t)
            cout<<s<<'\n';
        else
            cout<<t<<'\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int a[10]; //答えが入る
    int i,j;
    int n;
    int c;
    int m;
    int flag=0;
    
    for(i=0;i<10;i++){
        a[i]=0;
    }
    
    scanf("%d",&n);
    
    a[0]=n;
    
    for(i=n-1;i>1;i--){
        c=0;
        for(j=0;j<10;j++){
            a[j]=a[j]*i+c;
            c=a[j]/100;
            a[j]=a[j]%100;
        }
    }
    
    for(i=9;i>=0;i--){
        if(a[i]!=0){
            m=i;
            break;
        }
    }
    
    for(i=m;i>=0;i--){
        if(i!=m && a[i]<10){
            printf("0%d",a[i]);
        }else{
            printf("%d",a[i]);
        }
    }
    
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
#define pb push_back
typedef long long ll;
const ll INF = 1LL << 60;

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    ll abs_max_ind;
    ll abs_max_val = 0;
    rep(i,n){
        if(abs(a[i])>=abs_max_val){
            abs_max_val = abs(a[i]);
            abs_max_ind = i;
        }
    }
    
    vector<pair<ll,ll>> ans;
    rep(i,n){
        if(i != abs_max_ind){
            a[i] += a[abs_max_ind];
            ans.pb(make_pair(abs_max_ind,i));
        }
    }
    if(a[abs_max_ind]>=0){
        rep(i,n-1){
            a[i+1] += a[i];
            ans.pb(make_pair(i,i+1));
        }
    }
    else{
        repr(i,n-1,0){
            a[i-1] += a[i];
            ans.pb(make_pair(i,i-1));
        }
    }

    cout << ans.size() << endl;
    rep(i,ans.size()){
        cout << ans[i].first+1<< " " << ans[i].second+1 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;
lli dp[51][51][2501];

int main(void)
{
	int N, A; cin >> N >> A;
	vector<int> x(N); rep(i, 0, N)cin >> x[i];
	dp[0][0][0] = 1;

	rep(i, 0, N) {
		rep(j, 0, N) {
			rep(k, 0, 2500) {
				dp[i + 1][j][k] += dp[i][j][k];
				dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
			}
		}
	}

	lli ans = 0;
	rep(i, 1, N + 1)ans += dp[N][i][i*A];
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 50048
#include <stdio.h>
#include <cassert>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <functional>
using namespace std;

int main(void){


    int n;
    int m;
    scanf("%d",&n);
    scanf("%d",&m);
    long fib[n+1];
    fib[0]=1;
    fib[1]=1;
    for(int i=1;i<n+1;i++){
        fib[i+1]=(fib[i]+fib[i-1])%1000000007;
    }
    if(m>=1){
        int a[m];
        for(int i=0;i<m;i++){
            scanf("%d",&a[i]);
        }
        int min=100000;
        for(int i=1;i<m;i++){
            if(min>=a[i]-a[i-1]){
                min=a[i]-a[i-1];
            }
        }
        if(min<=1){
            printf("%d",0);
        }else{
            long ans=fib[a[0]-1];
            for(int i=1;i<m;i++){
                ans=ans*fib[a[i]-a[i-1]-2]%1000000007;
            }
            ans=ans*fib[n-a[m-1]-1]%1000000007;
            printf("%ld",ans);
        }
    }else{
        printf("%ld",fib[n]);
    }
    return 0;
}

Measured memory_bytes: 1280
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  s=chomp(readline())
  println(all(x->'a'<=x<='z',s) && length(s)==6 && s[3]==s[4] && s[5]==s[6] ? "Yes" : "No")
end
main()
if isdefined(Base, :mystdin);close(mystdin);end

Measured memory_bytes: 155332
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define INF 1000000007
#define SEP " "

int     main()
{
	int n, x, y;
	cin >> n >> x >> y;
	vector<int> c(n, 0);
	for (int i = 1; i < n; i++) {
		vector<int> dp(n+1, INF);
		queue<int> q;
		q.push(i);
		dp[i] = 0;
		while (!q.empty())
		{
			int f = q.front();
			q.pop();
			if (f-1 >= 1 && dp[f-1] == INF)
			{
				dp[f-1] = dp[f]+1;
				q.push(f-1);
				if (f-1 > i)
					c[dp[f-1]]++;
			}
			if (f+1 <= n && dp[f+1] == INF)
			{
				dp[f+1] = dp[f]+1;
				q.push(f+1);
				if (f+1 > i)
					c[dp[f+1]]++;
			}
			if (f == x && dp[y] == INF)
			{
				dp[y] = dp[f]+1;
				q.push(y);
				if (y > i)
					c[dp[y]]++;
			}
			if (f == y && dp[x] == INF)
			{
				dp[x] = dp[f]+1;
				q.push(x);
				if (x > i)
					c[dp[x]]++;
			}

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


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

    

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var n, a int
	fmt.Scan(&n)
	m := make(map[int]int)
	keys := []int{1}
	for i := 2; i <= n; i++ {
		fmt.Scan(&a)
		m[a]++
		keys = append(keys, i)
	}
	for _, key := range keys {
		fmt.Println(m[key])
	}
}

Measured memory_bytes: 17664
#include <cstdio>
#include <algorithm>
using namespace std;
int n,d,x,a;

int main()
{
    int i,j;
    //freopen("date.in","r",stdin);
    scanf("%d %d %d",&n,&d,&x);
    for (i=1;i<=n;i++) {
        scanf("%d",&a);
        x+=(d-1)/a+1;
    }
    printf("%d",x);
    return 0;
}


Measured memory_bytes: 128
E = 10**-10

def cp(a, b):
    c = [a[1]*b[2] - a[2]*b[1],
        a[2]*b[0] - a[0]*b[2],
        a[0]*b[1] - a[1]*b[0]]
    return c

while True:
    try:
        x1,y1,x2,y2,x3,y3,xp,yp = [float(i) for i in input().split()]
        ax = x3-x1
        ay = y3-y1
        bx = x1-x2
        by = y1-y2
        cx = x2-x3
        cy = y2-y3
        pax = xp-x1
        pay = yp-y1
        pbx = xp-x2
        pby = yp-y2
        pcx = xp-x3
        pcy = yp-y3
        ca = [bx,by,0]
        ab = [cx,cy,0]
        bc = [ax,ay,0]
        pa = [pax,pay,0]
        pb = [pbx,pby,0]
        pc = [pcx,pcy,0]
        cp1 = cp(ca,pa)[2]
        cp2 = cp(ab,pb)[2]
        cp3 = cp(bc,pc)[2]
        if abs(cp1 - abs(cp1)) < E:
            sig1 = 1
        elif abs(cp1 + abs(cp1)) < E:
            sig1 = -1
        if abs(cp2 - abs(cp2)) < E:
            sig2 = 1
        elif abs(cp2 + abs(cp2)) < E:
            sig2 = -1
        if abs(cp3 - abs(cp3)) < E:
            sig3 = 1
        elif abs(cp3 + abs(cp3)) < E:
            sig3 = -1
        if abs(sig1 + sig2 + sig3) == 3:
            print('YES')
        else:
            print('NO')
    except EOFError:
        break




Measured memory_bytes: 5632
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Data.Char
import Data.List

main = do
    n <- readLn :: IO Int
    xs <- VU.fromList . sort . VU.toList .  (VU.zipWith (-) (VU.fromList [1..n])) . VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    let y = xs VU.! (n `quot` 2)
    print $ VU.foldl' (\a x -> a + (abs $ x-y)) 0 xs

Measured memory_bytes: 31100
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        final String SPACE = " ";

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

        String inputData[] = br.readLine().split(SPACE);
        final int a = Integer.parseInt(inputData[0]);
        final int b = Integer.parseInt(inputData[1]);
        final int c = Integer.parseInt(inputData[2]);
        int cnt = 0;

        for (int i = 0; a + i <= b; i++) {
            if (c % (a + i) == 0) {
                cnt++;
            }
        }

        System.out.println(cnt);

    }
}

Measured memory_bytes: 17092
#include <cstdio>

int main()
{
    int A,B,C,K;
    int out;

    // input
    scanf("%d %d %d %d", &A, &B, &C, &K);

    // process
    if ( A > K ) {
        out = K;
    } else if ( A + B > K ) {
        out = A;
    } else {
        out = A - ( K - ( A + B ) );
    }

    // output
    printf( "%d\n", out );

    return 0;
}


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

int main(){
    int n;
    string w;
    priority_queue<int> s;
    while(cin>>w && w!="end"){
        if(w=="insert"){
            cin>>n;
            s.push(n);
        }
        else{
            n=s.top();
            s.pop();
            cout<<n<<endl;
        }
    }
}


Measured memory_bytes: 7020
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

const int N = 1e5 + 7;
const int INF = 1e9;

int used[N];

namespace DSU {
    int p[N];
    int rank[N];

    int get(int v) {
        if (p[v] != v) {
            p[v] = get(p[v]);
        }
        return p[v];
    }

    void merge(int a, int b) {
        a = get(a);
        b = get(b);
        assert(a != b);
        if (rank[a] < rank[b]) swap(a, b);
        p[b] = a;
        if (rank[a] == rank[b]) rank[a]++;
    }

    void init() {
        for (int i = 0; i < N; i++) {
            p[i] = i;
        }
    }
}

struct Edge {
    int u, v, ind;

    Edge() {}

    Edge(int u_, int v_, int ind_) {
        u = u_;
        v = v_;
        ind = ind_;
    }
};

int d[N];
int cl[N];
int ans[2 * N];

void run(int cd, vector<Edge> in, vector<Edge> out) {
    // cerr << "run " << cd << endl;
    for (auto t : out) {
        if (used[t.v]) continue;
        if (!used[t.u]) continue;
        cl[t.v] = cl[t.u];
        ans[t.ind] = d[t.v] - d[t.u];
        used[t.v] = 1;
    }
    for (auto t : in) {
        if (DSU::get(t.u) != DSU::get(t.v)) {
            if (used[t.u] && used[t.v]) continue;
            if (!used[t.u] && !used[t.v]) {
                cl[t.u] = 0;
                cl[t.v] = 1;
            } else if (!used[t.u]) {
                cl[t.u] = 1 ^ cl[t.v];
            } else {
                cl[t.v] = 1 ^ cl[t.u];
            }
            ans[t.ind] = cd;
            DSU::merge(t.u, t.v);
            used[t.u] = 1;
            used[t.v] = 1;
        }
    }

}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    DSU::init();

    int n, m;
    cin >> n >> m;
    map<int, vector<int>> ind;
    for (int i = 0; i < n; i++) {
        cin >> d[i];
        ind[d[i]].push_back(i);
    }
    map<int, vector<Edge>> in;
    map<int, vector<Edge>> out;
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        assert(u != v);
        if (d[u] > d[v]) swap(u, v);
        if (d[u] == d[v]) {
            in[d[u]].push_back(Edge(u, v, i));
        }  else {
            out[d[v]].push_back(Edge(u, v, i));
        }
    }
    fill(ans, ans + m, INF);
    fill(cl, cl + N, -1);
    for (auto t : ind) {
        run(t.first, in[t.first], out[t.first]);
    }
    for (int i = 0; i < n; i++) {
        if (!used[i]) {
            cout << -1 << endl;
            exit(0);
        }
    }
    for (int i = 0; i < n; i++) {
        cout << (cl[i] ? 'B' : 'W');
    }
    cout << endl;
    for (int i = 0; i < m; i++) {
        cout << ans[i] << '\n';
    }
}   


Measured memory_bytes: 33616