akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;


int N,M;
vector<int>s;
vector<int>c;

bool OK(string str_digit){
        if(str_digit.size()!=N)return false;
        for(int j=0;j<M;j++)if(str_digit[s[j]-1]!=(char)(c[j]+'0'))return false;
        return true;
}

string solve(){
    for(int i=0;i<=999;i++){
        stringstream iss;iss<<i;
        string str_digit=iss.str();
        if(OK(str_digit))return str_digit;
    }
    return "-1";
}

int main() {
    cin >> N >> M;
    s.resize(M);c.resize(M);
    for(int i=0;i<M;i++)cin>>s[i]>>c[i];
    cout<<solve();
    return 0;
}

Measured memory_bytes: 3648
k = int(input()) - 1
def onesearch(last):
    if last < 0:
        return [9, 1]
    elif last == 0:
        return [2, 0]
    elif last == 9:
        return [2, 8]
    else:
        return [3, last - 1]
memo = {}
def search(i, last, rest):
    # print('search', (i, last, rest))
    if i == 0:
        n, base = onesearch(last)
        if rest < n:
            return (n, base + rest)
        else:
            return (n, -1)
    if (i, last) in memo:
        n, ret = memo[(i, last)]
        if ret >= 0:
            return (n, ret)
    n = 0
    if last < 0:
        for j in range(1, 10):
            n1, ret = search(i - 1, j, rest)
            if ret >= 0:
                return (n1, j * 10 ** i + ret)
            n += n1
            rest -= n1
        memo[(i, last)] = (n, -1)
        return (n, -1)
    for j in range(max(0, last - 1), min(10, last + 2)):
        n1, ret = search(i - 1, j, rest)
        if ret >= 0:
            return (n1, j * 10 ** i + ret)
        n += n1
        rest -= n1
    memo[(i, last)] = (n, -1)
    return (n, -1)
def sub(k):
    for i in range(20):
        n, ret = search(i, -1, k)
        if ret >= 0:
            return ret
        k -= n

print(sub(k))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    vector<string> v(3);
    for (int i = 0; i < 3; i++) { cin >> v[i]; }
    for (int i = 0; i < 3; i++) { cout << v[i][i]; }
    cout << '\n';
}


Measured memory_bytes: 256
import { readFileSync } from 'fs'
import { reverse } from 'dns'
import { start } from 'repl'
 
let lines: string[] = [];
const reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
 
reader.on('line', function (line: string) {
    lines.push(line);
});
reader.on('close', function () {
    /* let [n, d] = lines[0].split(' ').map( _ => parseInt(_)) */
    let a = lines[0]

    if('a' <= a && a <= 'z') {
        console.log('a')
    } else {
        console.log('A')
    }


});

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long n;
    cin >> n;
    long long cnt = 1, ans = 0;
    for(long long i = 0LL; i < n; i++){
        long long a;
        cin >> a;
        if(a != cnt) ans++;
        else cnt++;
    }
    if(ans == n) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, T;
int A[3010], B[3010];
pair<ll, int> dp[3010][3010];
//---------------------------------------------------------------------------------------------------
pair<ll, int> max(pair<ll, int> a, pair<ll, int> b) {
	if (a.first + a.second == b.first + b.second) {
		if (a.first > b.first) return a;
		return b;
	}

	if (a.first + a.second > b.first + b.second) return a;
	return b;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> T;
	rep(i, 0, N) cin >> A[i] >> B[i];

	rep(i, 0, N + 1) rep(t, 0, T + 1) dp[i][t] = { -infl, 0 };
	dp[0][0] = { 0, 0 };

	rep(i, 0, N) rep(t, 0, T + 1) if(0 <= dp[i][t].first) {
		dp[i + 1][t] = max(dp[i + 1][t], { dp[i][t].first, max(dp[i][t].second, B[i]) });
		if (t + A[i] <= T) {
			dp[i + 1][t + A[i]] = max(dp[i + 1][t + A[i]], {
				dp[i][t].first + B[i],
				dp[i][t].second
				});
		}
	}

	ll ans = 0;
	rep(t, 0, T) chmax(ans, dp[N][t].first + dp[N][t].second);
	chmax(ans, dp[N][T].first);
	cout << ans << endl;
}







Measured memory_bytes: 141568
#include<iostream>

using namespace std;

// 長方形の判定：三平方の定理を使用する。
// ひし形の判定：二つの辺の長さが等しいこと
// 正方形の場合：ひし形、長方形の特殊なケースなので両方にカウント

int main() {
	int a, b, c;
	int r_count = 0; // 長方形の数
	int l_count = 0; // ひし形の数
	// 
	while (true) {
		cin >> a;
		cin.ignore();
		cin >> b;
		cin.ignore();
		cin >> c;
		if (cin.eof()) {
			break;
		}
		// 長方形判定
		if (a * a + b * b == c * c) {
			++r_count;
		}
		// ひし形判定
		if (a == b) {
			++l_count;
		}
	}
	cout << r_count << endl;
	cout << l_count << endl;

	return 0;
}

Measured memory_bytes: 1160
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    A = list(map(int, input().split()))
    colors = [0] * 8
    over = 0

    for a in A:
        if a < 3200:
            colors[a // 400] += 1
        else:
            over += 1

    result = sum(color > 0 for color in colors)

    if result:
        print(result, result + over)
    else:
        print(1, over)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
typedef long long ll; 
const ll mod = 1e9+7;
#define fo(i, n) for (int i = 0; i < n; i++)
#define sc(n) scanf("%d", &n) 
using namespace std;

int n;

void solve() {
    cin >> n;
    printf("%.18f", 2*3.14159265389793238*n);
}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3252
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <random>
#include <ctime>
#include <sstream>
#include <numeric>
#include <queue>
using namespace std;

int main(){
    int64_t x ;
    cin >> x ;
    int64_t ans = 0 ;
    ans += x /11 ;
    ans *= 2 ;
    if (x % 11 > 6)
    {
        ans += 2 ;
    }else if (x % 11 > 0)
    {
        ans += 1 ;
    }
    
    cout << ans << endl ;
    
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc079/tasks/abc079_c

import sys
import itertools as it
import operator

if __name__ == "__main__":
    xs = [int(c) for c in input().strip()]
    ops = it.product([-1, 1], repeat=3)
    res = next(op for op in ops if 7 == (xs[0] + sum(map(operator.mul, xs[1:], op))))
    symbols = ["+" if i == 1 else "-" for i in res]
    iterable = filter(
        lambda x: x is not None,
        it.chain.from_iterable(
            it.zip_longest(map(str, xs), symbols)
        )
    )
    res = "".join(iterable) + "=7"
    print(res)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define ll long long
//不要再爆long long了！！！！！！！！不要再爆long long了！！！！！！！ 
bool sf[200010]={0};//R1W0
int main()
{
	int n;
	string s;
	cin>>n;
	cin>>s;
	for(int i=0;i<n;i++)
	{
		sf[i]=(s[i]=='R');
	}
	int cnt=0;
	int loc1=0,loc2=n-1;
	while(1)
	{
		while(sf[loc1]==1)
		{
			if(loc1<n-1)loc1++;
			else goto loop;
		}
		while(sf[loc2]==0)
		{
			if(loc2>0)loc2--;
			else goto loop;
		}
		if(loc1<loc2)sf[loc1]=1,sf[loc2]=0,cnt++;
		else goto loop;
	}
	loop:;
	printf("%d\n",cnt);
	return 0;
}

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

int main(void){
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  string c(w, '.');
  for(int i = 0; i < h; i++) cin >> s[i];
  vector<bool> hh(h, true);
  vector<bool> ww(w, true);
  for(int i = 0; i < h; i++){
    if(s[i] == c) hh[i] = false;
  }
  for(int i = 0; i < w; i++){
    bool flag = true;
    for(int j = 0; j < h; j++){
      if(s[j][i] == '#') flag = false;
    }
    if(flag) ww[i] = false;
  }
  for(int i = 0; i < h; i++){
    if(hh[i]){
      for(int j = 0; j < w; j++){
	if(ww[j]) cout << s[i][j];
      }
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
import numpy as np

# 店の数を入力する
N = int(input())
# 店の営業時間の情報を入力する
F = np.zeros((N, 10), dtype = int)
for i in range(N):
    F_i = list(map(int, input().split()))
    F[i] = [val for j, val in enumerate(F_i)]
# 各店と同時に営業したときの利益を入力する
P = np.zeros((N, 11), dtype = int)
for i in range(N):
    P[i] = list(map(int, input().split()))
# joisinoの開店パターン行列を作成する
matrix_pattern = np.zeros((2**10 - 1, 10), dtype = int)
for x in range(10):
    for y in range(0, 2**(10 - x), 2):
        matrix_pattern[(2**x * y):(2**x * (y + 1)), x] = 1
# 開店パターンごとの利益を格納するリストを作成する
list_profit = []
# joisinoの開店パターンごとに利益を計算
for pattern in matrix_pattern:
    # joisinoの店の利益を初期化する
    profit = 0
    # 店ごとに繰り返す
    for i in range(N):
        # 同時に営業している時間帯の個数（c_i）を計算する
        c_i = sum(F[i] * pattern)
        # joisinoの店の利益を更新する
        profit += P[i, c_i]
    list_profit.append(profit)
# 利益の最大値を出力する
print(max(list_profit))

Measured memory_bytes: 21060
#include <bits/stdc++.h>
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
int main(){
  int x,y,a,b,c; cin >>x >>y >>a >>b >>c; ll ans=0;
  vector<int>p(a); vector<int>q(b); vector<int>r(x+y+c);
  for(int i=0; i<a; i++) cin >>p[i];
  sort(p.rbegin(),p.rend());
  for(int i=0; i<x; i++) r[i]=p[i];
  for(int i=0; i<b; i++) cin >>q[i];
  sort(q.rbegin(),q.rend());
  for(int i=0; i<y; i++) r[x+i]=q[i];
  for(int i=0; i<c; i++) cin >>r[x+y+i];
  sort(r.rbegin(),r.rend());
  for(int i=0; i<x+y; i++) ans+=r[i];
  cout <<ans;
return 0;}

Measured memory_bytes: 2176
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Clue = Tuple!(long, "x", long, "y", long, "h");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long a, b;
    scan(a, b);
    // 面倒なので総当り,最大でも消費税は100であることからxは10000以下
    foreach (i; iota(10_000))
    {
        auto s = floor((i + 1) * 0.08);
        auto t = floor((i + 1) * 0.10);
        if (s == a && t == b)
        {
            writeln(i + 1);
            return;
        }
    }
    writeln(-1);
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll N, M;
ll A[100005];
ll S[100005];

ll solve(ll n, ll x) {
    ll ok = -1, ng = N;
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if (n + A[mid] >= x)
            ok = mid;
        else
            ng = mid;
    }
    return ok;
}

bool check(ll x) {
    ll cnt = 0;
    REP(i, N) {
        cnt += solve(A[i], x) + 1;
    }
    return cnt <= M;
}

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

    cin >> N >> M;
    REP(i, N) {
        cin >> A[i];
    }
    sort(A, A + N, greater<ll>());

    ll mx = INF, ng = 1;
    while (abs(mx - ng) > 1) {
        ll mid = (mx + ng) / 2;
        if (check(mid))
            mx = mid;
        else
            ng = mid;
    }

    memset(S, 0, sizeof(S));
    REP(i, N) {
        S[i] += A[i];
        S[i + 1] += S[i];
    }

    ll ans = 0;
    ll cnt = 0;
    REP(i, N) {
        ll index = solve(A[i], mx);
        if (index < 0)
            continue;
        ans += A[i] * (index + 1) + S[index];
        cnt += index + 1;
    }
    cout << ans + (M - cnt) * (mx - 1) << endl;

    return 0;
}

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

    return divisors


N = int(input())
d1 = make_divisors(N)
d2 = make_divisors(N - 1)

ans = len(d2) - 1
for n in d1:
    if n == 1:
        continue
    n2 = N
    while n2 % n == 0:
        n2 //= n
    if n2 % n == 1:
        if n not in d2:
            ans += 1

print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	int n, m;
	cin >> n >> m;
	vl a(n);
	rep(i,0,n) {
		cin >> a[i];
	}
	vector<vi> adj(n);
	rep(i,0,m) {
		int x,y;
		cin >> x >> y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	vi id(n, -1);
	int cnt = 0;
	rep(i,0,n) {
		if(id[i] != -1) continue;
		id[i] = cnt++;
		queue<int> q;
		q.push(i);
		while(!q.empty()) {
			int u = q.front();
			q.pop();
			for(auto v : adj[u]) {
				if(id[v] == -1) {
					id[v] = id[u];
					q.push(v);
				}
			}
		}
	}
	if(cnt == 1) {
		cout << 0 << '\n';
		return 0;
	}
	vector<vl> b(cnt);
	rep(i,0,n) {
		b[id[i]].pb(a[i]);
	}
	if((cnt-1)*2 > n) {
		cout << "Impossible" << '\n';
	} else {
		ll ret = 0;
		vl cand;
		rep(i,0,cnt) {
			sort(all(b[i]));
			ret += b[i][0];
			rep(j,1,sz(b[i])) {
				cand.pb(b[i][j]);
			}
		}
		sort(all(cand));
		int k = (cnt-1)*2-cnt;
		rep(i,0,k) {
			ret += cand[i];
		}
		cout << ret << '\n';
	}
	return 0;
}


Measured memory_bytes: 9600
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    map<int, bool> m;
    for (int i = 0; i < K; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int x;
            cin >> x;
            m[x] = true;
        }
    }
    int count = 0;
    for (int i = 1; i <= N; i++) {
        if (m[i] == false) {
            count++;
        }
    }
    
    cout << count;
    return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;

#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	int q; cin >> q;
	int a = 0;
	rep(i, 0, q) {
		char c;
		int p, n; cin >> p >> c >> n;
		if (c == '(')a += n;
		else a -= n;
		if (a == 0)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3064
from heapq import heappop, heappush

def inpl(): return list(map(int, input().split()))

N, M, s, t = inpl()
Gs = [[] for _ in range(N+1)]
Gt = [[] for _ in range(N+1)]

for i in range(M):
    u, v, a, b = inpl()
    Gs[u].append([v, a])
    Gs[v].append([u, a])
    Gt[u].append([v, b])
    Gt[v].append([u, b])

S = [10**15]*(N+1)
T = [10**15]*(N+1)
S[s] = 0
T[t] = 0

Q = []
heappush(Q, [0, s])

while Q:
    pc, p = heappop(Q)
    if pc > S[p]:
        continue
    for q, dc in Gs[p]:
        if S[q] > pc + dc:
            S[q] = pc + dc
            heappush(Q, [S[q], q])

Q = []
heappush(Q, [0, t])

while Q:
    pc, p = heappop(Q)
    if pc > T[p]:
        continue
    for q, dc in Gt[p]:
        if T[q] > pc + dc:
            T[q] = pc + dc
            heappush(Q, [T[q], q])

tmp = 0
X = 10**15
ans = [0 for _ in range(N)]
for i in range(N, 0, -1):
    t = X - T[i] - S[i]
    tmp = max(tmp, t)
    ans[i-1] = tmp*1

print(*ans, sep="\n")

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

int main(){
    int x,y;
    while(1){
        cin>>x>>y;
        if(x==0 && y==0){
            break;
        }
        if(y>x){
            cout<<x<<" "<<y<<endl;
        }
        else{
            cout<<y<<" "<<x<<endl;
        }
    }
}


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

using namespace std;

int arr[301];

int main()
{
    int n,k,result=0;
    cin>>n;

    for(int i=1 ; i<=n ; i++)
    {
        cin>>k;
        if(i%2 != 0 && k%2 != 0 )
            result++;
    }

    cout<<result;





    return 0;
}


Measured memory_bytes: 3564
// 20:50 -
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
  int n;
  int t[100005][5];
  bool flg = true;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> t[i][0] >> t[i][1] >> t[i][2];
    if(t[i][1] + t[i][2] > t[i][0] || (t[i][1]+t[i][2]) % 2 != t[i][0] % 2) flg = false;
  }

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

  return 0;
}


Measured memory_bytes: 2176
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int a[200001]={}, b[200001]={};
    string s;
    int n;
    cin>>n;
    cin>>s;
    for(int i=0; i<n; i++){
        if(s[i]=='#') a[i+1]=a[i]+1;
        else a[i+1]=a[i];
    }
    b[n]=0;
    for(int i=n-1; i>=0; i--){
        if(s[i]=='.') b[i]=b[i+1]+1;
        else b[i]=b[i+1];
    }
    int ans=n;
    for(int i=0; i<=n; i++){
        ans=min(ans, a[i]+b[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    int d[n];
    for (int i = 0; i < n; i++) cin >> d[i];
    sort(d, d+n);
    cout << d[n / 2] - d[n / 2 - 1] << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std ;
int main (){
 int a ,b ,c ,d;
  cin >>a>>b>>c;
  d+=a+b+c;
  if(d>=22){
    cout<<"bust"<<endl;
    return 0;
  }
  else if (d<22){
   cout<<"win"<<endl;
    return 0 ;
  }
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int ans=100010005;
  rep(i,n){
    int sum_1=0;
    int sum_2=0;
    rep(j,i){
      sum_1 += a[j];
    }
    for (int k=i; k <n; k++){
      sum_2 += a[k];
    }
    ans = min(ans, abs(sum_1 - sum_2));
    //cout << sum_1 << sum_2 << endl;
  }
  cout << ans << endl;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A, B;
  cin >> A >> B;
  for (int p = 0; p < 10000; p++) {
    if (static_cast<int>(p * 0.08) == A && static_cast<int>(p * 0.10) == B) {
      cout << p << '\n';
      return 0;
    }
  }
  cout << -1 << '\n';
  return 0;
}


Measured memory_bytes: 256
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	ll N; cin >> N;
	vector<ll> A(N);
	rep(i, N) cin >> A[i];
	ll ma = 0;
	ll idx = 0;
	rep(i, N) {
		if(ma < A[i]){
			ma = A[i];
			idx = i;
		}
	}
	ll mar = 0;

	ll ansma = ma;
	ll ansmar = 0;
	rep(i, N){
		if(idx == i) continue;
		if(mar < min(ma - A[i], A[i])){
			mar = min(ma- A[i], A[i]);
			ansmar = A[i];
		}
	}

	cout << ansma << " " << ansmar << endl;
	return 0;
}


Measured memory_bytes: 1024
<?php
$fp = fopen('php://stdin', 'r');
$week = fgets($fp);
$debt = 100000;
for ($i=0; $i<$week; $i++) {
  $debt *= 1.05; 
  $debt = (int)$debt;
//  echo $debt.PHP_EOL;
//  echo substr($debt, -3, 3).PHP_EOL;
  if (substr($debt, -3, 3) != 0) {
    $debt = (int)($debt / 1000) * 1000 + 1000;
  }
}
echo $debt.PHP_EOL;

Measured memory_bytes: 6580
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 200000000;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

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

    ll s;
    cin >> s;
    set<ll> as;
    as.insert(s);
    int m = 1000000;
    FOR(i, 2, m) {
        if (s % 2 == 0) {
            s /= 2;
        } else {
            s = 3 * s + 1;
        }
        if (as.find(s) != as.end()) {
            cout << i << endl;
            return 0;
        }
        as.insert(s);
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c;
  in3(a, b, c);
  if(b - a == c - b)
    out("YES");
  else
    out("NO");
  memi;
}

Measured memory_bytes: 256
#pragma GCC optimize(3)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <algorithm>
#define mp make_pair
#define Debug(...) fprintf(stdout, __VA_ARGS__)

using namespace std;

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

const int MAXN = 6e2 + 7;
const int MOD = 1e9 + 7;

template<typename T> inline T read() {
	T res = 0, flag = 1; char in = getchar();
	while(!isdigit(in)) { if(in == '-') flag = -1; in = getchar(); }
	while(isdigit(in)) { res = (res << 1) + (res << 3) + in - '0'; in = getchar(); }
	return res * flag;
}

template<typename T> inline void chkmax(T &a, T b) { if(a < b) a = b; }
template<typename T> inline void chkmin(T &a, T b) { if(a > b) a = b; }

inline void Add(int &x, int y) { x += y; if(x >= MOD) x -= MOD; }

int n, k, ans;
int dp[MAXN][MAXN];
int cnt[MAXN][MAXN];
int p[MAXN], g[MAXN];

int dfs(int l, int r) {

	if((r - l + 1) & 1) return dp[l][r] = 0;
	if(dp[l][r] >= 0) return dp[l][r];
	if(cnt[l][r] & 1) return dp[l][r] = 0;

	int Max = r, Min = l; 
	for(int i = l; i <= r; ++i) {
		if(p[i]) {
			chkmin(Min, p[i]);
			chkmax(Max, p[i]);
		}
	}
	if(Min < l || Max > r) return dp[l][r] = 0;

	int &res = dp[l][r]; res = 0;
	Max = p[l];
	for(int k = l + 1; k < r; ++k) {
		chkmax(Max, p[k]);
		if((k - l + 1) & 1) continue;
		if(Max > k) continue;
		Add(res, (LL) dfs(l, k) * g[cnt[k + 1][r]] % MOD);
	}
	res = (g[cnt[l][r]] - res + MOD) % MOD;

	return res;
}

inline void init() {
	n = read<int>() << 1; k = read<int>();
	for(int i = 1; i <= k; ++i) {
		int a = read<int>();
		int b = read<int>();
		p[a] = b; p[b] = a;
	}

	for(int i = 1; i <= n; ++i) {
		for(int j = i; j <= n; ++j) {
			cnt[i][j] = cnt[i][j - 1] + (p[j] == 0);
//			printf("[%d, %d] = %d\n", i, j, cnt[i][j]);
		}
	}
	g[0] = 1;
	for(int i = 2; i < MAXN; i += 2)
		g[i] = (LL) g[i - 2] * (i - 1) % MOD;
}

inline void solve() {
	memset(dp, -1, sizeof dp);
	dfs(1, n);
	for(int i = 1; i <= n; ++i) {
		for(int j = i; j <= n; ++j) {
			if(dfs(i, j) > 0) Add(ans, (LL) dfs(i, j) * g[cnt[1][i - 1] + cnt[j + 1][n]] % MOD);
//			printf("[%d, %d] = %2.d | coef %d | ct %lld\n", i, j, dfs(i, j), cnt[j + 1][n], (LL) dfs(i, j) * g[cnt[1][i - 1] + cnt[j + 1][n]] % MOD);
		}
	}
	printf("%d\n", (ans + MOD) % MOD);
}

int main() {

	init();
	solve();

	return 0;
}



Measured memory_bytes: 3072
#include <stdio.h>

typedef struct node_t {
	int val;
	struct node_t *next;
} node;

node* new_node(int val) {
	static int it = 0;
	static node pool[200000];
	pool[it] = (node) { val, NULL };
	return &pool[it++];
}

node* st[1000];
node* en[1000];

int main(void)
{
	int n, q, com, t, x;
	node *tmp;
	scanf("%d%d", &n, &q);
	while (q--) {
		scanf("%d%d", &com, &t);
		if (com == 0) {
			scanf("%d", &x);
			tmp = new_node(x);
			if (!st[t]) st[t] = en[t] = tmp;
			else en[t]->next = tmp, en[t] = tmp;
		}
		else if (com == 1) {
			if (st[t]) printf("%d\n", st[t]->val);
		}
		else {
			if (st[t]) st[t] = st[t]->next;
		}
	}
	return 0;
}



Measured memory_bytes: 4820
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

ll a, b, c, d;

ll num_of_mul(ll n) {//a以上b以下でnで割り切れるものの数
  return b/n - (a+n-1)/n + 1;
}

int main() {
  cin >> a >> b >> c >> d;
  ll lcm = c*d/__gcd(c, d);
  ll ng = num_of_mul(c) + num_of_mul(d) - num_of_mul(lcm);
  cout << b-a+1 - ng << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int N, M, C;
    scanf("%d %d %d", &N, &M, &C);
    int B[M];
    int A[N][M];

    for (int i = 0; i < M; i++) {
        scanf("%d", &B[i]);
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            scanf("%d", &A[i][j]);
        }
    }

    int count = 0;
    for (int i = 0; i < N; i++) {
        int score = 0;
        for (int j = 0; j < M; j++) {
            score += A[i][j] * B[j];
        }
        if (score + C > 0) {
            count++;
        }
    }
    printf("%d\n", count);
}


Measured memory_bytes: 128
import java.util.Scanner;


public class Main{

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int[] array = new int[n+1];
		array[0] = 1;
		array[1] = 1;
		for(int i=0 ; i<(n-1) ; i++) {
			array[i+2] = array[i+1] + array[i];
		}
		System.out.println(array[n]);
	}

}

Measured memory_bytes: 17164
#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>;

int main() {
  int K, N, i; cin >> K >> N;
  vector<int> a(N), dis(N);
  rep (i, N)
    cin >> a.at(i);

  rep (i, N-1) {
    dis.at(i) = a.at(i+1) - a.at(i);
  }
  dis.at(N-1) = K-a.at(N-1) + a.at(0);

  int sum = 0;
  sum = accumulate(dis.begin(), dis.end(), sum);
  sort(dis.begin(), dis.end(), greater<int>());

  cout << K - dis.at(0) << endl;
  return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define Fst first
#define Snd second
#define RG register
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int UI;
typedef unsigned long long ULL;
template<typename T> inline void read(T& x) {
	char c = getchar();
	bool f = false;
	for (x = 0; !isdigit(c); c = getchar()) {
		if (c == '-') {
			f = true;
		}
	}
	for (; isdigit(c); c = getchar()) {
		x = x * 10 + c - '0';
	}
	if (f) {
		x = -x;
	}
}
template<typename T, typename... U> inline void read(T& x, U& ... y) {
	read(x), read(y...);
}
int n;
int A[250010],X[510],ID[510],cnt[510];
bool cmp(int a,int b) {
  return X[a]<X[b];
}
//#define rua
int main() {
//	ios::sync_with_stdio(false);
#ifdef rua
	freopen("GG.in","r",stdin);
#endif
//  freopen("data.in","r",stdin);
//  freopen("data.out","w",stdout);
  read(n);
  for(int i=1;i<=n;++i) read(X[i]),A[X[i]]=i,ID[i]=i,cnt[i]=1;
  sort(ID+1,ID+n+1,cmp);
  for(int i=1;i<=n*n;++i) {
    if(A[i]) continue;
    for(int j=1;j<=n;++j) {
      int t=ID[j];
      if(cnt[t]!=t) {
        A[i]=t,++cnt[t];
        break;
      }
    }
  }
  for(int i=n*n;i;--i) {
    if(A[i]) continue;
    for(int j=n;j;--j) {
      int t=ID[j];
      if(cnt[t]!=n) {
        A[i]=t,++cnt[t];
        break;
      }
    }
  }
  for(int i=1;i<=n;++i) {
    int t=0;
    for(int j=1;j<=X[i];++j) {
      if(A[j]==i) ++t;
    }
    if(t!=i) return puts("No"),0;
  }
  puts("Yes");
  for(int i=1;i<=n*n;++i) printf("%d ",A[i]);
  return 0;
}


Measured memory_bytes: 2176
#include<cstdio>
int min(int a,int b) {return a>b?b:a;}
int a[200304],f[203040];
int main()
{
	int n,now=1,ans=0x7f7f7f7f;
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",&a[i]);
	for (int i=1;i<=n;++i)
		f[a[i]]=f[a[i]-1]+1;
	for (int i=1;i<=n;++i) ans=min(ans,n-f[i]);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair<ll, ll> pll;


ll a,b;
int main()
{
        cin >> a >> b;
        ll yo = (a + b);
        if(yo%2 == 1) {
                cout << "IMPOSSIBLE\n";
        }else {
                cout << yo/2 << endl;
        }
        return 0;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
long long dijk[21][21][1 << 11] = {};
int visited[21][21][1 << 11] = {};
int main() {
	while (true) {
		int w, h;
		cin >> w >> h;
		if (w == 0) return 0;
		int grid[20][20] = {};
		int now_cnt = 1;
		REP(i, 21) {
			REP(q, 21) {
				REP(j, 1 << 11) {
					dijk[i][q][j] = LONG_INF;
					visited[i][q][j] = 0;
				}
			}
		}
		priority_queue<tuple<long long, int, int, int>> next;
		REP(i, h) {
			string s;
			cin >> s;
			REP(q, s.length()) {
				if (s[q] == 'o') {
					dijk[i][q][0] = 0;
					next.push(make_tuple(-0, i, q, 0));
				}
				else if (s[q] == 'x') {
					grid[i][q] = -1;
				}
				else if (s[q] == '*') {
					grid[i][q] = now_cnt;
					now_cnt++;
				}
			}
		}
		while (next.empty() == false) {
			tuple<long long, int, int, int> now = next.top();
			next.pop();
			int now_x = get<1>(now);
			int now_y = get<2>(now);
			int now_cleaned = get<3>(now);
			if (visited[now_x][now_y][now_cleaned] == 1) continue;
			visited[now_x][now_y][now_cleaned] = 1;
			int xe[4] = { 1,-1,0,0 };
			int ye[4] = { 0,0,1,-1 };
			REP(q, 4) {
				int next_x = xe[q] + now_x;
				int next_y = ye[q] + now_y;
				if (next_x >= 0 && next_x < h && next_y >= 0 && next_y < w) {
					if (grid[next_x][next_y] == -1) continue;
					int next_taken = now_cleaned;
					if (grid[next_x][next_y] != 0) {
						next_taken |= (1 << (grid[next_x][next_y] - 1));
					}
					int next_cost = -get<0>(now) + 1;
					if (dijk[next_x][next_y][next_taken] > next_cost) {
						dijk[next_x][next_y][next_taken] = next_cost;
						next.push(make_tuple(-next_cost, next_x, next_y, next_taken));
					}
				}
			}
		}
		now_cnt--;
		long long ans = LONG_INF;
		REP(i, h) {
			REP(q, w) {
				ans = min(ans, dijk[i][q][(1 << now_cnt) - 1]);
			}
		}
		if (ans == LONG_INF) {
			cout << -1 << endl;
		}
		else {
			cout << ans << endl;
		}
	}
}


Measured memory_bytes: 13920
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define MAX 100005
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  string s;
  cin>>s;
  s.erase(--s.end());
  int k=s.size();
  rep(i,k){
    int len=s.size();
    if(len%2==1)s.erase(--s.end());
    else{
      rep(i,len){
        if(s[i]!=s[i+len/2]){
          s.erase(--s.end());
          break;
        }
        if(i==len/2-1){
          cout<<s.size()<<endl;
          return 0;
        }
      }
    }
  }


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    string S;
    cin >> S;
    string t;
    for(auto c:S)if(c != 'x')t.push_back(c);
    rep(i,0,t.size()/2){
        if(t[i] != t[t.size()-i-1]){
            cout << -1 << endl;
            return 0;
        }
    } 
    vector<int> cnt(t.size()+1);
    for(int i = 0,c = 0;i < S.size();i++){
        if(S[i] == 'x')cnt[c]++;
        else c++;
    }
    int ans = 0;
    rep(i,0,cnt.size()/2){
        ans += abs(cnt[i] - cnt[cnt.size()-i-1]);
    }
    cout << ans << endl;
}

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

using namespace std;

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

    vector<int> memo(N, 0);
    for (int i = 0; i < N; i++) {
      if (S[i] == 'W') {
        memo[i+1] = memo[i] + 1;
      } else {
        memo[i+1] = memo[i];
      }
    }

    int ans = N;
    for (int i = 0; i < N; i++) ans = min(ans, memo[i] + (N - (i+1)) - (memo[N] - memo[i+1]));
    cout << ans << endl;
}


Measured memory_bytes: 1796
#include<stdio.h>
int main(void){
  int N,c=0;
  scanf("%d",&N);
  char S[N];
  scanf("%s",S);
  for(int i=0;i<N-2;i++){
   if(S[i]=='A')if(S[i+1]=='B')if(S[i+2]=='C')c++;
  }
  printf("%d",c);
  return 0;
}

Measured memory_bytes: 2156
#include<stdio.h>

int main(){
    char S[102];
    int i=0,flg = 0;
    scanf("%s",S);
    while(S[i] != '\0'){
        if((i+1) % 2 != 0){
            if(S[i] != 'R' && S[i] != 'U' && S[i] != 'D' ){
                flg++;
                break;
            }
        }else{
            if(S[i] != 'L' && S[i] != 'U' && S[i] != 'D' ){
                flg++;
                break;
            }
        }
        i++;
    }
    if(flg == 0){
            printf("Yes");
        }else{
            printf("No");
        }

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int H, W, i, j;
	
	do {
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0)
			break;
		
		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++)
				putchar('#');
			putchar('\n');
		}
		putchar('\n');
	} while (1);
	
	return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
//typedef vector<vector<ll> > Graph;
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 = 1e18;

//テンプレート
//辺の構築
template< typename T = int >
struct Edge {
  int from, to;
  T cost;
  int idx;

  Edge() = default;

  Edge(int from, int to, T cost = 1, int idx = -1) : from(from), to(to), cost(cost), idx(idx) {}

  operator int() const { return to; }
};

template< typename T = int >
struct Graph {
  vector< vector< Edge< T > > > g;
  int es;

  Graph() = default;

  explicit Graph(int n) : g(n), es(0) {}

  size_t size() const {
    return g.size();
  }

  void add_directed_edge(int from, int to, T cost = 1) {
    g[from].emplace_back(from, to, cost, es++);
  }

  void add_edge(int from, int to, T cost = 1) {
    g[from].emplace_back(from, to, cost, es);
    g[to].emplace_back(to, from, cost, es++);
  }

  void read(int M, int padding = -1, bool weighted = false, bool directed = false) {
    for(int i = 0; i < M; i++) {
      int a, b;
      cin >> a >> b;
      a += padding;
      b += padding;
      T c = T(1);
      if(weighted) cin >> c;
      if(directed) add_directed_edge(a, b, c);
      else add_edge(a, b, c);
    }
  }
};

/**
 * @brief BFS(幅優先探索)
 */
template< typename T >
vector< T > bfs(const Graph< T > &g, int s) {
  T max_cost = 0, beet = 0;
  for(auto &es : g.g) {
    for(auto &e : es) max_cost = max(max_cost, e.cost);
  }
  ++max_cost;
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(g.size(), INF);
  vector< queue< int > > ques(max_cost + 1);
  dist[s] = 0;
  ques[0].emplace(s);
  for(T cost = 0; cost <= beet; cost++) {
    auto &que = ques[cost % max_cost];
    while(!que.empty()) {
      int idx = que.front();
      que.pop();
      if(dist[idx] < cost) continue;
      for(auto &e : g.g[idx]) {
        auto next_cost = cost + e.cost;
        if(dist[e.to] <= next_cost) continue;;
        dist[e.to] = next_cost;
        beet = max(beet, dist[e.to]);
        ques[dist[e.to] % max_cost].emplace(e.to);
      }
    }
  }
  return dist;
}


int main(){
    int n,u,v;
    cin >> n >> u >> v;
    u--;v--;
    Graph<int> g(n);
    g.read(n-1,-1,false,false);
    auto dista = bfs(g,v);
    auto distt = bfs(g,u);
    int M = 0;
    rep(i,n){
        if(dista[i]>distt[i])chmax(M,dista[i]);
    }
    cout << M-1 << endl;
    return 0;
}

Measured memory_bytes: 8704
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
//---------------------------------------------------------------------------------------------------
typedef pair<int,int> P;

int main(void){
    // Your code here!
    int n,r; cin >> n >> r;
    if (n >= 10) cout << r << endl;
    else cout << r + 100*(10-n) << endl;
}


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

int main() {
  int N;
  cin>>N;
  vector<int> b(N);
  for(int j=1;j<=N;j++){
    cin>>b[j];
  }
  int next=1,c=0;
  for(int i=0;i<N;i++){
    next = b[next];
    c++;
    if(next==2){
      cout<<c<<endl;
      return 0;
    }
  }
cout<<-1<<endl;
}


Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
int main() {
    int h,a;
    cin >> h >> a;
    int ans = 0;
    while(true){
        h -= a;
        ans++;
        if(h <= 0) break;
    }
    dunk(ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

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

	int n, m;
	scanf("%d%d", &n, &m);
	vector<vi> s(m);
	for (int i = 0; i < m; i++) {
		int k;
		scanf("%d", &k);
		s[i].resize(k);
		for (int j = 0; j < k; j++) {
			scanf("%d", &s[i][j]);
			--s[i][j];
		}
	}
	vi p(m);
	for (int i = 0; i < m; i++) scanf("%d", &p[i]);

	int ans = 0;
	for (int mask = 0; mask < (1 << n); mask++) {
		int i;
		for (i = 0; i < m; i++) {
			int on = 0;
			for (int x : s[i]) if (mask & (1<<x)) ++on;
			//printf("%d %d %d\n", mask, i, on);
			if ((on & 1) != p[i]) break;
		}
		if (i == m) ans++;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
#define INF 1e9
#define INFL 1e12
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
int main()
{
    double a1, b1, a2, b2;
    cin >> a1 >> b1 >> a2 >> b2;

    double slope, intercept;
    bool slopeinf=false;
    if(a1==a2) slopeinf = true;
    else if(b1==b2) slope = 0;
    else slope = (b1-b2) / (a1-a2);
    intercept = b1 - (slope*a1);

    double dist, sl_inv, x, y, xx, yy;
    double ansx, ansy;
    
    int n; cin >> n;
    rep(i, n){
        cin >> x >> y;
        dist = abs(slope*x - y + intercept) / sqrt(slope*slope + 1);
        if(slopeinf){
            yy = y;
            if(a1<x) xx = a1;
            else xx = a1;
        }else{
            xx = (slope*slope*a1 - slope*b1 + x + slope*y) / (slope*slope+1);
            if(slope==0) yy = 0;
            else yy = (x - xx) / slope + y;
        }
        xx = 2*xx - x; yy = 2*yy - y;
        printf("%.12lf %.12lf\n", xx, yy);
    }
    return 0;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
const ll MOD = 1000000007;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ll N;
    cin>>N;
    
    map<ll,ll> m;
    
    REP(i,N){
        ll t;cin>>t;
        if(m.count(t)==0)m[t]=1;else m[t]++;
        t++;
        if(m.count(t)==0)m[t]=1;else m[t]++;
        t--;t--;
        if(m.count(t)==0)m[t]=1;else m[t]++;
    }
    ll ans=0,ii=0;
    for(const auto t:m){
        if(ans<t.second){
            ans=t.second;
            ii=t.first;
        }
    }
    cout<<ans;
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 6144
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = long.Parse(Console.ReadLine());
        var a = long.Parse(Console.ReadLine());
        var b = long.Parse(Console.ReadLine());
        var c = long.Parse(Console.ReadLine());
        var d = long.Parse(Console.ReadLine());
        var e = long.Parse(Console.ReadLine());

        var min = Math.Min(Math.Min(Math.Min(Math.Min(
            a,
            b),
            c),
            d),
            e);

        var ans = ceil(n, min) + 4;
        Console.WriteLine(ans);
    }

    static long ceil(long a, long b)
    {
        return (a + b - 1) / b;
    }
}


Measured memory_bytes: 11092