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

int main(){
    int N,M;
    cin >> N >> M;
    int H[N + 1];
    vector<int> hp(N);
    for (int i = 1; i<=N; i++) cin >> H[i];
    for (int i = 0; i<M; i++) {
        int a, b;
        cin >> a >> b;
        hp[a] = max(hp[a], H[b]);
        hp[b] = max(hp[b], H[a]);
    }

    int res = 0;
    for (int i = 1; i<=N; i++) {
        if(hp[i] < H[i]) res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4056
#include <cstdio>
#include <cstring>

void merge(const int al, const int bl, int a[], int b[], int result[]) {
    if (al == 0) {
        memcpy(result,b,sizeof(int) * (size_t)bl);
    } else if (bl == 0) {
        memcpy(result,a,sizeof(int) * (size_t)al);
    } else if (a[0] > b[0]) {
        result[0] = a[0];
        merge(al-1,bl,a+1,b,result+1);
    } else {
        result[0] = b[0];
        merge(al,bl-1,a,b+1,result+1);
    }
}

void mergesort(int l, int result[]) {
    if (l > 1) {
        int al=l/2, bl=l-al;
        int a[al], b[bl];
        memcpy(a,result,sizeof(int) * (size_t)al);
        memcpy(b,result+l/2,sizeof(int) * (size_t)bl);
        mergesort(al,a);
        mergesort(bl,b);
        merge(al,bl,a,b,result);
    }
}
int main() {
    int N, i;
    scanf("%d",&N);
    int a[N];
    for (i=0; i<N; i++) {
        scanf("%d",&a[i]);
    }
    mergesort(N,a);
    int m=1,dif=0;
    for (i = 0; i<N; i++) {
        dif += m*a[i];
        m = -m;
    }
    printf("%d\n",dif);
}

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

int n;
std::set<char> vowel {'a', 'i', 'u', 'e', 'o'};
std::vector< std::vector<char> > code(50, std::vector<char>(50));
int main() {
    int i, j, k, l, maxl;
    std::string s;
    while(std::cin >> n, n != 0) {
        maxl = 0;
        for(i = 0; i < n; ++i) {
            std::cin >> s;
            code[i].clear();
            l = s.length();
            for(j = 0; j < l; ++j) {
                if(j == 0 || vowel.count(s[j - 1]) > 0) {
                    code[i].push_back(s[j]);
                }
            }
            maxl = std::max(maxl, (int)code[i].size());
        }

        std::set< std::string > used;
        k = 0;

        int ans = -1;
        while(++k <= maxl) {
            used.clear();

            for(i = 0; i < n; ++i) {
                s = std::string(code[i].begin(), code[i].begin() + std::min(k, (int)code[i].size()));
                used.insert(s);
            }
            if(used.size() == n) {
                ans = k;
                break;
            }
        }
        std::cout << ans << std::endl;
    }
}


Measured memory_bytes: 3184
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		String str =new Scanner(System.in).nextLine();
		String[] str1 = str.split("");
		String[] str2 = new String[str1.length];
		for (int i = str1.length - 1; i >= 0; i--) {
			str2[str1.length - i - 1] = str1[i];
		}
		String str3 ="";
		for (int i = 0; i < str2.length; i++) {
			str3=str3+str2[i];
		}
		System.out.println(str3);
	}

}

Measured memory_bytes: 26152
#include<iostream>
#include<algorithm>
#include<vector>

const int MAX_N = 15, INF = 1 << 24;
const double EPS = 1e-10;
int ns[16], d[16], cost[16][16], w[16], weight[1<<MAX_N];
int n, next[1<<MAX_N][16];
double dp[1<<MAX_N][16];

double rec(int S, int v){
	if(dp[S][v] > -EPS){
		return dp[S][v];
	}

	if(S == (1 << n) - 1){
		return 0;
	}

	double min_res = INF;
	for(int i=0;i<n;i++){
		if(!(S >> i & 1)){
			double res = (70.0 + weight[S]) * cost[v][i] / 2000.0 + rec(S | (1 << i), i);
			if(res < min_res + EPS){
				min_res = res;
				next[S][v] = i;
			}
		}
	}

	return dp[S][v] = min_res;
}

int main(){
	std::cin >> n;

	for(int i=0;i<n;i++){
		std::cin >> ns[i] >> d[i] >> w[i];
	}

	for(int i=0;i<(1<<n);i++){
		for(int j=0;j<n;j++){
			if(i >> j & 1){
				weight[i] += w[j];
			}
		}
		weight[i] *= 20;
		std::fill(dp[i], dp[i]+16, -1);
	}

	for(int i=0;i<n;i++){
		cost[n][i] = cost[i][n] = 0;
		for(int j=i+1;j<n;j++){
			cost[i][j] = cost[j][i] = abs(d[i]-d[j]);
		}
	}

	rec(0, n);

	std::vector<int> route;
	int S = 0, u = n;
	while(S != (1 << n) - 1){
		int v = next[S][u];
		S |= (1 << v);
		u = v;
		route.push_back(ns[u]);
	}

	std::cout << route[0];
	for(int i=1;i<route.size();i++){
		std::cout << " " << route[i];
	}
	std::cout << std::endl;
}

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

//Class.
vector<int> list[2000];
int N, M, E;
int match[2000];
bool used[2000];
int x[2000], y[2000];

bool DFS(int V) {
	used[V] = true;
	for (int i = 0; i < list[V].size(); i++) {
		int u = list[V][i]; int w = match[u];
		if (w < 0 || !used[w] && DFS(w)) {
			match[V] = u;
			match[u] = V;
			return true;
		}
	}
	return false;
}

int supermatching() {
	int r = 0;
	memset(match, -1, sizeof(match));
	for (int j = 0; j < N + M; j++) {
		if (match[j] < 0) {
			memset(used, 0, sizeof(used));
			if (DFS(j)) { r++; }
		}
	}
	return r;
}

//main.
int main() {
	while (true) {
		for (int i = 0; i < 2000; i++) { list[i].clear(); }
		cin >> N >> M; if (!N) { break; }
		for (int i = 0; i < N; i++) {
			cin >> x[i];
		}
		for (int i = 0; i < M; i++) {
			cin >> y[i];
		}
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < M; j++) {
				if (__gcd(x[i], y[j]) != 1) {
					list[i].push_back(j + N);
				}
			}
		}
		cout << supermatching() << endl;
	}
	return 0;
}

Measured memory_bytes: 4132
N, *C = $<.read.split.map(&:to_i)

s, i, b, g, h = 1, -1, 0, Hash.new(0), Hash.new(0)
until (i+=1) == N
	next if b == c = C[i]
	h[c] += s = ((s -= g[c]) + (g[c] = h[c])) % 1000000007
	b = c
end
p s


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

using LL = long long;
using LD = long double;
 
LL mod = 1e9+7;

int main()
{
	LL k;
	cin >> k;
	LL sum = 0;
	for (LL i = 0; i < k; ++i) {
		for (LL j = 0; j < k; ++j) {
			for (LL kk = 0; kk < k; ++kk) {
				sum += __gcd(i+1, __gcd(j+1, kk+1));
			}
		}
	}
	cout << sum << "\n";
}

Measured memory_bytes: 3620
n,m = map(int,raw_input().split())
a = []
b = []

for i in range(n):
  a.append(map(int, raw_input().split()))
for i in range(m):
  b.append(input())
for i in range(n):
  ans = 0
  for j in range(m):
    ans += a[i][j]*b[j]
  print ans

Measured memory_bytes: 6620
main = print . solve . map read . words =<< getContents

solve :: [Int] -> Int
solve [n,k] = solve' n k 1

solve' 0 _ x = x
solve' n k x
    | x < k = solve' (n-1) k (x*2)
    | otherwise = solve' (n-1) k (x+k)


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	ll N, A[5];
	cin >> N >> A[0] >> A[1] >> A[2] >> A[3] >> A[4];;

	ll B = *min_element(A, A + 5);
	ll C = (N + B - 1) / B;

	co(C + 4);

	Would you please return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cstdlib>
#define f first
#define s second
using namespace std;
typedef pair <string,int> P;
map <string,P> mp;
 
string find(string x){
  if(mp[x].f!=x) mp[x] = mp[find(mp[x].f)];
  return mp[x].f;
}
 
void unite(string x,string y){
  x=find(x);
  y=find(y);
  if(x==y) return;
  if(mp[x].s<mp[y].s)swap(x,y);
  mp[x].f=y;
}
 
int main() {
  int n,m,a;
  cin >> n;
  string str,str2;
  for(int i=0;i<n;i++) {
    cin >> str >> a;
    mp[str].f = str;
    mp[str].s = a;
  } 
  cin >> m;
  for(int i=0;i<m;i++){
    cin >> str >> str2;
    unite(str,str2);
  }     
  int ans = 0;
  map<string,P> :: iterator it;
  for(it=mp.begin();it!=mp.end();it++) ans += mp[find(it->f)].s;
  cout << ans <<endl;
  return 0;
}

Measured memory_bytes: 1788
n,m,x=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
a.sort()
one=0
while a:
    check=a.pop()
    if check>x:
        one+=1
    else:
        a.append(check)
        break
two=len(a)

print(min(one,two))

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<stack>
using namespace std;
int n,m,De[2020202][2];
char S[2020202];
bool Out[2020202];
vector <int> Vec[202020];
stack <int> St;
int main(){
	scanf("%d %d",&n,&m);
	scanf("%s",S+1);
	for (int i=1;i<=m;i++){
		int x,y; scanf("%d %d",&x,&y);
		De[x][S[y]-'A']++; De[y][S[x]-'A']++;
		Vec[x].push_back(y);
		Vec[y].push_back(x);
	}
	for (int i=1;i<=n;i++) if (!De[i][0]||!De[i][1])
		St.push(i),Out[i]=1;;
	while (!St.empty()){
		int x=St.top(); St.pop(); 
		for (int i=0;i<Vec[x].size();i++){
			int y=Vec[x][i];
			if (Out[y]) continue;
			De[y][S[x]-'A']--;
			if (!De[y][0]||!De[y][1]){
				Out[y]=1; St.push(y);
			}
		}
	}
	for (int i=1;i<=n;i++) if (!Out[i]){
		cout<<"Yes"; return 0;
	}
	cout<<"No";
}

Measured memory_bytes: 16256
// Shift-JIS（シフトジス）

#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    long long ans = 4 + ceil(double(N) / double((min({A, B, C, D, E}))));
    cout << ans << endl;
}

Measured memory_bytes: 256
a = list(map(int, input().split()))

b = [a[0]-a[2], a[1]-a[3]]
c = [b[1]+a[2], -b[0]+a[3]]

d = [a[2]-c[0], a[3]-c[1]]
e = [d[1]+c[0], -d[0]+c[1]]

ans = []
ans.append(c[0])
ans.append(c[1])
ans.append(e[0])
ans.append(e[1])

L = [str(a) for a in ans]
L = ' '.join(L)
print(L)

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

int main(){

	int k,a,b;
	cin>>k;
	cin>>a;
	cin>>b;
	int x,y;
	x=a/k;
	y=b/k;
	if (a%k==0){
		cout<<"OK"<<endl;

	}
	else if(b%k==0){
		cout<<"OK"<<endl;
	}

	else if(x!=y){
		cout<<"OK"<<endl;
	}else{
		cout<<"NG"<<endl;
	}

}

Measured memory_bytes: 3624
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
# print(N, A)
max1_a = -1
max1_i = -1
max2_a = -1
max2_i = -1

for i in range(N):
    a = A[i]
    if a >= max1_a:
        max1_a = a
        max1_i = i

for i in range(N):
    if i == max1_i:
        continue
    a = A[i]
    if a >= max2_a:
        max2_a = a
        max2_i = i

for i in range(N):
    if i == max1_i:
        print(max2_a)
    else:
        print(max1_a)


Measured memory_bytes: 69336
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int maxb = 20;
int x[maxn], r[maxn][maxb];
int n, L;
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", &x[i]);
	scanf("%d", &L); 
	int j = n;
	r[n][0] = n + 1;
	for(int i = n - 1; i; --i)
	{
		while(x[j] - x[i] > L) --j;
		r[i][0] = j;
	}
	for(int j = 1; j < maxb; ++j) 
		for(int i = 1; i <= n; ++i)
			r[i][j] = r[i][j - 1] == n + 1 ? n + 1 : r[r[i][j - 1]][j - 1];
	int q;
	scanf("%d", &q);
	while(q--)
	{
		int u, v, ans = 0;
		scanf("%d%d", &u, &v);
		if(u > v) swap(u, v);
	 	for(int j = maxb - 1; ~j; --j)
	 		if(r[u][j] <= v)
	 		{
	 			u = r[u][j];
	 			ans += 1 << j;
	 		}
	 	if(u < v) ++ans;
	 	printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 12040
n =int(input())
s = input().split()
cnt=[0,0,0,0]
for i in range(n):
    if s[i]=='G':cnt[0]+=1
    elif s[i]=='W':cnt[1]+=1
    elif s[i]=='Y':cnt[2]+=1
    else: cnt[3]+=1
print("Three" if min(cnt)==0 else "Four")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define endl "\n"
    #define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n,k;
    ll func(ll cost[],ll h[]){
      cost[1]=0;
      cost[2]=abs(h[1]-h[2]);
      for(ll i=3;i<=k+1;i++){
        ll temp=cost[i-1]+abs(h[i]-h[i-1]);
        for(ll j=2;j<i;j++){
          temp=min(temp,cost[i-j]+abs(h[i]-h[i-j]));
        }
        cost[i]=temp;
      }
      for(ll i=k+2;i<=n;i++){
        ll temp=cost[i-1]+abs(h[i]-h[i-1]);
        for(ll j=2;j<=k;j++){
          temp=min(temp,cost[i-j]+abs(h[i]-h[i-j]));
        }
        cost[i]=temp;
      }  
      return cost[n];
    }
    int32_t main(){
      IOS;
      cin>>n>>k;
      ll h[n+1];
      if(k>n){
        k=n;
      }
      for(int i=1;i<=n;i++){
      	cin>>h[i];
      }
      ll cost[n+1];
      ll costn=func(cost,h);
      cout<<costn;
      return 0;
    }

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

#define ll long long int
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define sz(a) int((a).size())
#define mod 1000000007
#define inf LLONG_MAX
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
template <typename T>
inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }

template <typename T>
inline void seethis(vector<T>vect)
{
    for(T x:vect)
        cout<<x<<" ";
    cout<<"\n";
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
//LCM
int lcm(int a, int b) {  return a * (b / gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

//Tree
/* const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];*/

//ModPower
ll modpower(ll a,ll b,ll c)
{
  ll res=1;
  while(b)
  {
    if(b&1LL)
      res=(res*a)%c;
    a=(a*a)%c;
    b>>=1;
  }
  return res;
}
#define ep 0.000001
int main()
{
  FASTIO;
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  double d,t,s;
   cin>>d>>t>>s;

   double time = d/s;

   if((time-t)>ep)
    cout<<"No\n";
  else
    cout<<"Yes\n";
  
  return 0;
}

Measured memory_bytes: 3704
#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (x, ) = input!(u64);

    match x {
        400..=599 => println!("8"),
        600..=799 => println!("7"),
        800..=999 => println!("6"),
        1000..=1199 => println!("5"),
        1200..=1399 => println!("4"),
        1400..=1599 => println!("3"),
        1600..=1799 => println!("2"),
        1800..=1999 => println!("1"),
        _ => {},
    }
}

fn main() {
    solve();
}


Measured memory_bytes: 2140
n = int( input( ) )
dic = {}
output = []
for i in range( n ):
	cmd, word = input( ).split( " " )
	if "insert" == cmd:
		dic[ word ] = True
	elif "find" == cmd:
		if not dic.get( word ):
			output.append( "no" )
		else:
			output.append( "yes" )

print( "\n".join( output ) )

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int N;
    cin >> N;
    vector<int> a(N),ans(N);
    for (int i = 0; i < N; i++){
        cin >> a[i];
    }

    //if (N % 2 == 0){
        for (int i = 0; i < N; i++){
            if (i % 2 == 0){
                ans[i/2] = a[N-i-1];
            } else {
                ans[N-1-i/2] = a[N-i-1];
                //ans[(N-i+2-1)/2 + 1] = a[N-i-1];
            }
        }
    //} else {
    /*
        for (int i = 0; i < N; i++){
            if (i % 2 == 0){
            */

    for (int i = 0; i < N; i++){
        cout << ans[i] << ' ';
    }


            


    return 0;
}


Measured memory_bytes: 3712
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_D
{
    class D090
    {
        static void Main(string[] args)
        {
            int[] h = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();
            int N = h[0], K = h[1];

            long counter = 0;
            for (int i = K + 1; i <= N; i++)
            {
                int turn = N / i;
                long q = (long)turn * (i - K);
                int m = N % i;
                int d = K == 0 ? 0 : K - 1;
                int p = m - d; 
                if(p>0) q += p;
                counter += q;
            }
            Console.WriteLine(counter);
        }

    }
}


Measured memory_bytes: 13396
n = int(input())
b_num = n // 1.08
b_num_1 = b_num + 1
if int(b_num * 1.08) == n:
    print(int(b_num))
elif int(b_num_1 * 1.08) == n:
    print(int(b_num_1))
else:
    print(':(')

Measured memory_bytes: 3060
#include <stdio.h>

int bi(int b){
  int i=0;
  while(b%2==0){
    b >>= 1;
    i++;
  }
  return i;
}

int main(void) {
  int N;
  int i;
  int a;
  int total=0;

  //  fgets(line, 9999, stdin);
  scanf("%d", &N);

  for(i=0;i<N;i++){
    scanf("%d", &a);
    total += bi(a);
  }

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


Measured memory_bytes: 128
from collections import defaultdict
import sys
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    return int(input())


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


N, M = inpl()
hh = inpl()

lines = [[] for _ in range(N)]

for _ in range(M):
    A, B = inpl()
    A -= 1
    B -= 1
    lines[A].append(B)
    lines[B].append(A)

ans = 0

for s in range(N):
    sh = hh[s]

    for t in lines[s]:
        th = hh[t]
        if sh > th:
            continue
        else:
            break
    else:
        ans += 1

print(ans)


Measured memory_bytes: 30012
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		private const int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			//System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start();
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int x = vs[0];
			int y = vs[1];
			int z = vs[2];
			Console.WriteLine($"{z} {x} {y}");



			Console.Out.Flush();
			//System.Diagnostics.Debug.WriteLine(stopwatch.Elapsed);
		}
	}
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    string s, t; std::cin >> s >> t;
    int ans = 1e9;
    rep (i, s.size()-t.size()+1) {
        int cnt = 0;
        rep (j, t.size()) {
            cnt += (t[j] != s[j+i]);
        }
        chmin(ans, cnt);
    }
    std::cout << ans << "\n";
}


Measured memory_bytes: 3656
#include <iostream>
#include <map>
#include <cstdlib>
using namespace std;


int main()
{
    int n;
    cin >> n;
    
    std::map<std::pair<int,int>, int> m1, m2;
    int ans = 0;
    for(int i=1; i<=n; i++) {
        std::string str = std::to_string(i);
        int begin = str[0] - '0';
        int end = i%10;
        m1[std::make_pair(begin, end)]++;
    }
    std::map<std::pair<int,int>, int>::iterator itr;
    /*
    itr = m1.begin();
    while(itr != m1.end()){
        cout << itr->first.first << "," << itr->first.second << " " << itr->second << endl;
        ++itr;
    }
    */
    for(int i=1; i<=n; i++) {
        std::string str = std::to_string(i);
        int begin = str[0] - '0';
        int end = i%10;
        std::pair<int,int> p = std::make_pair(end, begin);
        //cout << end << "," << begin << endl;
        //cout << m1[p] << endl;
        itr = m1.find(p);
        if(itr != m1.end()){
            ans += itr->second;
        }
    }
    cout << ans << endl; 
    return 0;
}

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

#define ll long long
#define pb push_back
#define F first
#define S second

int inf =1e9+10;
const int N=1e5+10;
int n , a[N] , k;
int mem[N];

int dp(int i)
{
    if (i == n)
        return 0;
        if (i > n)
            return inf;
    int p = inf;
    int &ret = mem[i];
    if (ret != -1)
        return ret;
    for(int j = 1;j<=k;j++)
    {p = min(p , abs(a[i] - a[i+j]) + dp(i+j));
    //cout<<i<<" "<<p<<"\n";
    }

    return ret = p;
}

int main()
{
#ifdef Mohammad
 freopen("input.in","r",stdin);
#endif
     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
     cin >> n>>k ;
     for (int i =1;i<=n;i++)
        cin >> a[i];
        memset(mem , -1 , sizeof mem);
        cout<<dp(1);
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

int main()
{
  string S, T;
  cin >> S >> T;

  ll ans = 0;
  for (ll i = 0; i < 3; i++)
  {
    if (S.at(i) == T.at(i))
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import itertools
import math
import sys

n, k = map(int, input().split())
h = [int(input()) for i in range(n)]
h.sort()
ans = 10 ** 9
for i in range(n):
    if i + k - 1 >= n:
        break
    ans = min(ans, h[i + k - 1] - h[i])
print(ans)


Measured memory_bytes: 7532
#C - Energy Drink Collector
n,m = map(int,input().split())
ab = []
for i in range(n):
    ab.append(list(map(int, input().split())))
abSorted = sorted(ab)
sumB = 0
sumMoney = 0
i = 0
while sumB + abSorted[i][1] < m:
    sumB += abSorted[i][1]
    sumMoney += abSorted[i][0] * abSorted[i][1]
    i += 1
sumMoney += abSorted[i][0] * (m - sumB)
print(sumMoney)

Measured memory_bytes: 61528
import sys 
import collections
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N,P = map(int,readline().split())
S = list(map(int,readline().rstrip().decode()))

def solve_2(S):
    cnt = sum(i for i,x in enumerate(S,1) if x % 2 == 0)
    return cnt
def solve_5(S):
    cnt = sum(i for i,x in enumerate(S,1) if x % 5 == 0)
    return cnt
def solve(S):
    if P == 2:
        return solve_2(S)
    if P == 5:
        return solve_5(S)
    mod_cnt = [0]*(len(S))
    power = 1
    S = S[::-1]
    for i in range(len(S)):
        power *= 10
        power %= P
        mod_cnt[i] = (mod_cnt[i-1] + S[i] * power) % P
    c = collections.Counter(mod_cnt)
    cnt = sum( n*(n-1)//2 for n in c.values()) + c[0]
    return cnt

print(solve(S))

Measured memory_bytes: 20588
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <complex>
//定数
#define MOD 1000000007
//マクロ
#define rep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))

#define vsort(v) sort((v).begin(), (v).end());

typedef unsigned long long int ull;
typedef long long lint;

using namespace std;




int main(){
    string S, T;
    int count=0;


    //入力
    cin >> S >> T;
    rep(i, 3) if(S[i] == T[i]) count++;
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.lang.*;

public class Main {
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String[] s = br.readLine().split(" ", 0);
        int n = Integer.parseInt(s[0]);
        int q = Integer.parseInt(s[1]);
        
        Queue[] queues = new Queue[n];
        for (int i = 0; i < n; i++) {
            queues[i] = new Queue();
        }
        
        String[] l;
        String command;
        int t, x;
        for (int i = 0; i < q; i++) {
            l = br.readLine().split(" ", 0);
            command = l[0];
            t = Integer.parseInt(l[1]);
            switch (command) {
                case "0":
                    x = Integer.parseInt(l[2]);
                    queues[t].enqueue(x);
                    break;
                case "1":
                    queues[t].front();
                    break;
                case "2":
                    queues[t].dequeue();
                    break;
            }
        }
    }
}

class Queue {
    ArrayList<Integer> a;
    
    Queue() {
        a = new ArrayList<Integer>();
    }
    
    void enqueue(int x) {
        a.add(x);
    }
    
    void front() {
        int size = a.size();
        if (size != 0) {
            System.out.println(a.get(0));
        }
    }
    
    void dequeue() {
        int size = a.size();
        if (size != 0) {
            a.remove(0);
        }
    }
}

    



Measured memory_bytes: 67544
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]
lenA = len(A)
minA = min(A)
BC.sort(reverse = True, key = lambda x:x[1])

i = 0
cnt = 0
while cnt < lenA and i < M:
  A.extend([BC[i][1] for _ in range(BC[i][0])])
  cnt += BC[i][0]
  i += 1
A.sort(reverse = True)
l = A[0:lenA]

print(sum(l))

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

long long lcm(long long a,long long b){
    long long x=a*b;
    long long r=b%a;
    while(r!=0){
        b=a;
        a=r;
        r=b%a;
    }
    return x/a;
}

long long antiDiv(long long n,long long c,long long d){
    return n-(n/c)-(n/d)+(n/lcm(c,d));
}

int main(){
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    long long ans;
    ans=antiDiv(b,c,d)-antiDiv(a-1,c,d);
    cout<<ans<<endl;
}

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

int main() {
   int W, H, N;
  cin >> W >> H >> N;
  
  vector<vector<int>> data(H, vector<int>(W, 0));
  
  vector<int> x(N);
  vector<int> y(N);
  vector<int> a(N);
  for(int i = 0; i < N; i++) {
    cin >> x.at(i) >> y.at(i) >> a.at(i);
  }
  
  for(int i = 0; i < N; i++) {
    if(a.at(i) == 1) {
      for(int j = 0; j < x.at(i); j++) {
      for(int k = 0; k < H; k++) {
        data.at(k).at(j) = 1;
      }
      }
    }
    if(a.at(i) == 2) {
      for(int j = x.at(i); j < W; j++) {
      for(int k = 0; k < H; k++) {
        data.at(k).at(j) = 1;
      }
      }
    }
     if(a.at(i) == 3) {
      for(int j = 0; j < W; j++) {
      for(int k = H - y.at(i); k < H; k++) {
        data.at(k).at(j) = 1;
      }
      }
    }
  if(a.at(i) == 4) {
      for(int j = 0; j < W; j++) {
      for(int k = 0; k < H - y.at(i); k++) {
        data.at(k).at(j) = 1;
      }
      }
    }
  }
  
  int count = 0;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if (data.at(i).at(j) == 0) {
        count++;
      }
    }
  }
  cout << count << endl;
  
  
  
  return 0;
  
    
}
    

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

int main() {
  int H,W;
  cin >> H >> W;
  vector<string> vec(50);
  vector<int> dx ={-1,-1,-1,0,0,1,1,1};
  vector<int> dy ={-1,0,1,-1,1,-1,0,1};
  for(int i=0;i<H;i++) cin >> vec.at(i);


  
 for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      int count = 0;
      for(int k=0;k<8;k++){        
        if(vec.at(i).at(j) == '#') continue;
        if(j+dx.at(k) < 0 || j+dx.at(k) > W-1) continue;
        if(i+dy.at(k) < 0 || i+dy.at(k) > H-1) continue;
        if(vec.at(i+dy.at(k)).at(j+dx.at(k)) == '#') count++;
      }
      if(vec.at(i).at(j) == '#'){
        cout << "#";
      }else{
        cout << count;
      }
    }
   cout << endl;
 }
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define pi pair<int, int>
#define mk make_pair
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N=1e3+10;
char s[N];
int n;
int main()
{
	cin>>s+1;
	n=strlen(s+1);
    int l=1,r=(n-1)/2,flag=1;
    for(int i=l,j=r;i<=j;++i,--j) if(s[i]!=s[j]) flag=0;

    l=(n+3)/2,r=n;
    for(int i=l,j=r;i<=j;++i,--j) if(s[i]!=s[j]) flag=0;
    l=1,r=n;
    for(int i=l,j=r;i<=j;++i,--j) if(s[i]!=s[j]) flag=0;
    if(flag) puts("Yes");
    else puts("No");

}


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

int main(){
    double a;
    while(cin>>a){
        double s=a;
        for(int i=2; i<=10; i++){
            if(i%2==0){
                a*=2;
            } else {
                a/=3;
            }
            s+=a;
        }
        printf("%.10f\n",s);
    }
}

Measured memory_bytes: 1224
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b;
    scanf("%d",&a);
    scanf("%d",&b);


    if(a>b && b!=1||a==1 && b!=a)
        printf("Alice");
        else if(b>a && a!=1 || b==1 && a!=b)
            printf("Bob");
        else
        printf("Draw");
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
    public static void main(String[] args) throws java.io.IOException{
        Scanner scan = new Scanner(System.in);
        
        while(true){
        	int n=scan.nextInt();
        	if(n==0)break;
        	HashMap<String,String> hash =new HashMap<String,String>();
        	
        	for(int i=0;i<n;i++)hash.put(scan.next(),scan.next());
        	int m=scan.nextInt();
        	
        	for(int i=0;i<m;i++){
        		String in =scan.next();
        		
        		if(hash.containsKey(in))
        			System.out.print(hash.get(in));
        		else System.out.print(in);
        	}
        	System.out.println();
        }
    }
}

Measured memory_bytes: 12000
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int A;
int B;


int main(){
	
	cin>>A>>B;
	
	if( A == 2 ) A = 2;
	else if( A == 4 || A == 6 || A == 9 || A == 11 ){
		A = 4;
	}
	else{
		A = 0;
	}
	
	if( B == 2 ) B = 2;
	else if( B == 4 || B == 6 || B == 9 || B == 11 ){
		B = 4;
	}
	else{
		B = 0;
	}
	
	if( A == B )puts("Yes");
	else{	puts("No");}
	
	
	return 0;

}

Measured memory_bytes: 256
#!/usr/bin/env python3
n = int(input())
a = list(map(int, input().split()))
a.sort()
idx = 0
tmp = a[0]
for i in range(1, n):
    if tmp * 2 < a[i]:
        idx = i  # ここで併合できなくなり、i 以上しか無理になる
    tmp += a[i]
print(n - idx)



Measured memory_bytes: 14404
#include<bits/stdc++.h>
using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;

int a[5];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 

    int t=1,te=0;
    // cin>>t;
    while(t--){
        for(int i=0;i<3;++i)cin>>a[i];

        sort(a,a+3);

        printf("%d\n", a[0]+a[1]);


        //printf("Case %d: ",++te);
    }
    return 0;
}

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

using namespace std;


int main()
{
	int n; cin >> n;
	int a[n],b[n],c[n];
	for(int i = 0;i < n; i++){
		cin >> a[i] >> b[i] >> c[i];
	}
	int dp[n+1][3];
	for(int i = 0; i < 3; i++) dp[0][i] = 0;
	for(int i = 1; i <= n; i++){
		dp[i][0] = max(dp[i-1][1], dp[i-1][2])+a[i-1];
		dp[i][1] = max(dp[i-1][0], dp[i-1][2])+b[i-1];
		dp[i][2] = max(dp[i-1][0], dp[i-1][1])+c[i-1];
	}
	int ans = 0;
	for(int x : dp[n]) ans = max(ans, x);
	cout << ans;
}


Measured memory_bytes: 5940
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn main() {
   input! {
      n: usize,
      m: usize,
      ab: [(usize, usize); m]
   }
   let mut to = vec![vec![]; n];
   for &(a, b) in ab.iter() {
      to[a - 1].push(b - 1);
      to[b - 1].push(a - 1);
   }

   let mut visit = vec![false; n];
   let ans = dfs(0, &mut visit, &to);
   println!("{}", ans);
}

fn dfs(v: usize, visit: &mut Vec<bool>, to: &Vec<Vec<usize>>) -> usize {
   visit[v] = true;
   let mut x = if visit.iter().all(|&x| x) { 1 } else { 0 };
   for &u in to[v].iter() {
      if visit[u] {
         continue;
      }
      x += dfs(u, visit, to);
   }
   visit[v] = false;
   x
}


Measured memory_bytes: 4352
from collections import Counter
n = int(input())
arr = list(map(int, input().split()))

c = Counter(arr)

def co(n):
    return n*(n-1)//2

ans = {}
tot = 0
for k,v in c.items():
    ans[k] = co(v)
    tot += ans[k]

for it in arr:
    a = tot - ans[it] + co(c[it]-1)
    print(a)


Measured memory_bytes: 32156
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
int main()
{
	int num, mok;
	scanf("%d%d", &num, &mok);
	vector<pii>v;
	vector<ll>x, y;
	for (int i = 0; i < num; i++)
	{
		int za, zb;
		scanf("%d%d", &za, &zb);
		v.push_back(make_pair(za, zb));
		x.push_back(za), y.push_back(zb);
	}
	sort(v.begin(), v.end());
	ll mini = 8000000000000000000LL;
	for (int i = 0; i < num; i++)
	{
		for (int j = 0; j < num; j++)
		{
			for (int k = 0; k < num; k++)
			{
				ll lx = x[i], ly = y[j], uy = y[k];
				int cnt = 0;
				for (int l = 0; l < num; l++)
				{
					if (lx <= v[l].first&&ly <= v[l].second&&v[l].second <= uy)cnt++;
					if (cnt == mok)mini = min(mini, (v[l].first - lx)*(uy - ly));
				}
			}
		}
	}
	printf("%lld\n", mini);
}

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

    int main()
    {
        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int n; cin >> n;
        vector<int>v(n); 
        for (int& i : v) cin >> i;
        vector<int>res(n);
        int p1 = 0, p2 = n - 1;
        bool ok = 1;
        for (int i = n - 1; i >= 0; --i) {
            if(ok)
            res[p1++] = v[i];
            else
            res[p2--] = v[i];
            ok = !ok;
        }
        for (int i : res) cout << i << " ";
            return 0; 
    }

Measured memory_bytes: 3712
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


vpll edge[MAX];
ll color[MAX];

void dfs(ll cur, ll pre, ll col) {
  color[cur] = col;
  rep(i, edge[cur].size()) {
    ll to = edge[cur][i].first;
    if (to == pre) continue;
    if (edge[cur][i].second % 2) dfs(to, cur, col ^ 1LL);
    else dfs(to, cur, col);
  }
}


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

  
  cin >> n;
  rep(i, n - 1) {
    ll u, v, w;
    cin >> u >> v >> w;
    edge[u].pb(pll(v, w));
    edge[v].pb(pll(u, w));
  }
  dfs(1, -1, 0);
  FOR(i, 1, n + 1) cout << color[i] << endl;




  return 0;
}

Measured memory_bytes: 14592
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iostream>
#include <stack>
#include <tuple>
#include <map>
#include <cassert>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<ll> ds(n);
    for(int i = 0; i < n; ++i){
        cin >> ds.at(i);
    }
    sort(ds.begin(), ds.end());
    ll index = ds.size() / 2;
    cout << (ds.at(index) - ds.at(index - 1)) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int K, T; cin >> K >> T;
    vector<int> A(T); for (auto &a : A) cin >> a;
    int M = *max_element(begin(A), end(A));
    cout << max(0, (M-K/2)*2-1-K%2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Y;
    cin >> N >> Y;
    Y /= 1000;
    rep(i, N+1) {
        rep(j, N+1-i) {
            int money = i * 10 + j * 5 + (N-i-j);
            if (money == Y) {
                cout << i << " " << j <<  " " << N-i-j << endl;
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }


int main() {
    int aa, bb;
    cin >> aa >> bb;
    cout << aa*bb << endl;
}

Measured memory_bytes: 3632
MOD = 10**9+7
fac = [1, 1]

def prepare(n, mod):
    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)


def modcmb(n, r, mod):
    if n < 0 or r < 0 or r > n:
        return 0

    return fac[n] * pow(fac[r], mod-2, mod) * pow(fac[n-r], mod-2, mod) % mod


def f(r, c):
    return modcmb(r+c, r, MOD)


def g(x, y):
    return ((y+2) * modcmb(x+y+2, x, MOD) - (x+1)) * pow(x+1, MOD-2, MOD)


def main():
    prepare(2*10**6+10, MOD)
    r1,c1,r2,c2 = map(int, input().split())

    ans = g(r2, c2) - g(r1-1, c2) - g(r2, c1-1) + g(r1-1, c1-1)
    ans %= MOD

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 118124
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        v: [usize; n]
    }
    let m = *v.iter().clone().max().unwrap();
    if v.iter().map(|x| *x).sum::<usize>() - m > m {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
bool has3(int x){
    while(x){
        if(x%10==3)return true;
        x/=10;
    }
    return false;
}

void call(int n){
    for(int x=1; x<=n; x++){
        if(x%3==0||has3(x)){
          cout << " " << x;  
        }
    }
    cout << endl;
}


int main(){
    int n;
    cin>>n;
    call(n);
    
    return 0;
}    


Measured memory_bytes: 3092
#include<stdio.h>

int main(void){
  long long int X;
  long long int money;
  int cnt;
  
  scanf("%lld",&X);
  
  money = 100;
  cnt = 0;
  while(money<X){
    money += money/100;
    cnt++;
  }
  
  printf("%d",cnt);
  return 0;
}

Measured memory_bytes: 1728
w,h,n = map(int,input().split())
a_1 = [0]
a_2 = [0]
a_3 = [0]
a_4 = [0]
for i in range(n):
  x,y,a = map(int,input().split())
  if a == 1:
    a_1.append(x)
  if a==2:
    a_2.append(w-x)
  if a==3:
    a_3.append(y)
  if a==4:
    a_4.append(h -y)
if w - (max(a_1) + max(a_2))<=0:
  print(0)
elif h - (max(a_3) + max(a_4))<=0:
  print(0)
else:
  print((w - (max(a_1) + max(a_2))) * (h - (max(a_3) + max(a_4))))

Measured memory_bytes: 3064
n, a, b, c, d = map(int, input().split())
diff_ab = abs(b-a)
diff_cd = d - c
mod = c + d
mod_ab = diff_ab % mod
MAX = d * (n-1)
MAX_mod = MAX % mod
MIN_mod = (c * (n-1)) % mod
if MAX >= diff_ab:
    if diff_cd * (n-1) + 1 >= mod:
        print("YES")
    else:
        if MAX_mod >= MIN_mod:
            if MIN_mod <= mod_ab <= MAX_mod:
                print("YES")
            else:
                print("NO")
        else:
            if mod_ab >= MIN_mod or mod_ab <= MAX_mod:
                print("YES")
            else:
                print("NO")

else:
    print("NO")


Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<ll> x(n), y(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i];
  }
  ll sm = 0;
  ll cur = 0;
  ll res = 0;
  for (ll p = -1; p <= 1; ++p) {
    for (ll q = -1; q <= 1; ++q) {
      if (p == 0 || q == 0) continue;
      sm = p * x[0] + q * y[0];
      for (int i = 1; i < n; ++i) {
        cur = p * x[i] + q * y[i];
        res = max(res, cur - sm);
        sm = min(sm, cur);
      }
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 6416
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define printdbl(a) printf("%lf\n", a)
#define printYes() printf("Yes\n")
#define printNo() printf("No\n")
#define scanll(a) scanf("%lld", &a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scan4Int(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
typedef long long ll;
const int INF = 1001001001;
using namespace std;
void swap(int *a, int *b) {
    int tmp = *a;
    *a = *b;
    *b = tmp;
    return;
}
int gdc(int a, int b) {
    int r;
    if (a < b)
        swap(&a, &b);
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main() {
    int k,n,max = 0;
    scan2Int(k,n);
    int house[n];
    rep(i, n) cin >> house[i];
    rep(i, n - 1)
        max = max > house[i+1] - house[i] ? max : house[i+1] - house[i];
    max = max > house[0] + k - house[n-1] ? max : house[0] + k - house[n-1];
    printInt(k - max);
    return 0;
}

Measured memory_bytes: 4560