akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>

int main(){
  std::string s;
  std::cin >> s;
  int i,n = s.size();
  for(i = 0; i != n; i++)
    if(s[i] == '9')
      break;
  if(i == n)
    std::cout << "No" << std::endl;
  else
    std::cout << "Yes" << std::endl;
  return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<ll, ll>;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
struct edge {
  ll to, cost;
};

int main() {
  int X, Y, A, B, C; cin >> X >> Y >> A >> B >> C;
  vector<ll> p(A), q(B), r(C);
  REP(i, A) cin >> p[i];
  REP(i, B) cin >> q[i];
  REP(i, C) cin >> r[i];
  sort(all(p), greater<ll>()); sort(all(q), greater<ll>()); sort(all(r), greater<ll>());
  vector<ll> res;
  REP(i, X) res.push_back(p[i]);
  REP(i, Y) res.push_back(q[i]);
  REP(i, C) res.push_back(r[i]);
  sort(all(res), greater<ll>());
  ll ans = 0;
  for(int i = 0; i < (X + Y); ++i) {
    ans += res[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 9748
/**
 *    Creator :  bizarre
 *    Date : 3/2020
 *    Problem Number : 388
**/
#include <bits/stdc++.h>
using namespace std;
#define bizarre     ios_base::sync_with_stdio( false ), cin.tie( nullptr ), cout.tie( nullptr );
/*
const int inf = 2e9, mod = 1e9 + 7,N=1e6+5;
long long fact[N], inv[N];
vector<int> prime_Numbers;
int primes[1000005];
void prime(int n)
{
    primes[1]=primes[0]=0;
    for(int i=2; i<=n; i++)
        primes[i]=true;
    for(int i=2; i<=n; i++)
    {
        if(primes[i]==true)
        {
            prime_Numbers.push_back(i);
            for(int j=i+i; j<=n; j+=i)
                primes[j]=false;
        }
    }
    for(int i=2; i<=n; i++)
        primes[i]+=primes[i-1];
}

void move1step(long long& a, long long& b, long long q)
{
    long long c= a-q*b;
    a=b;
    b=c;
}
long long egcd(long long r0,long long r1,long long& x0,long long& y0)
{
    long long x1=0,y1=1;
    x0=1;
    y0=0;
    while(r1)
    {
        long long q=r0/r1;
        move1step(r0,r1,q);
        move1step(x0,x1,q);
        move1step(y0,y1,q);
    }
    return r0;
}
bool  solve (long long a, long long b, long long c,long long&x, long long& y)
{
    long long g=egcd(a,b,x,y);
    int m=c/g;
    x*=m;
    y*=m;
    return c%g==0;
}
int npr(long long n, long long r)
{
    return (fact[n] * inv[n - r]) % mod;
}

int gcd(int a, int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
int ncr(long long n, long long r)
{
    return (((fact[n] * inv[n - r]) % mod) * inv[r]) % mod;
}
void pre(long long n)
{
    fact[0] = 1;
    inv[0] = 1;
    for (long long i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}
*/
map<long long,long long>mp;
const long long mod=1e9+7;
long long fp(long long base, long long exp)
{
    if (exp == 0)
        return 1;
    long long ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}
void PrimeFactorization(int n)
{
    for(int i=2;i*i<=n;i++)
    {
        int c=0;
        if(n%i==0)
        {
            while(n%i==0)
            {
                n/=i;
                c++;
            }
            if(c)
                mp[i]=max(mp[i],(long long)c);
        }
    }
    if(n)
        mp[n]=max(mp[n],1ll);
}

int main()
{
    long long n;
    cin>>n;
    vector<long long>v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
        PrimeFactorization(v[i]);
    }
    long long lcm=1;
    for(auto it:mp)
    {
        lcm*=fp(it.first,it.second);
        lcm%=mod;
    }
    long long ans=0;
    for(int i=0;i<n;i++)
    {
        ans+=lcm*fp(v[i],mod-2)%mod;
        ans%=mod;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    new Main();
  }
  public Main(){
    Scanner sc = new Scanner(System.in);
    while(true){
      int w = sc.nextInt();
      int h = sc.nextInt();
      if(h==0 && w==0)break;
      int[][] dp = new int[h][w];
      dp[0][0] = 1;
      int n = sc.nextInt();
      while(n-->0){
        int x = sc.nextInt();
        int y = sc.nextInt();
        dp[y-1][x-1] = -1;
      }
      for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
          if(dp[i][j]==-1)continue;
          if(i>0 && dp[i-1][j]!=-1) dp[i][j] += dp[i-1][j];
          if(j>0 && dp[i][j-1]!=-1) dp[i][j] += dp[i][j-1];
        }
      }
      System.out.println(dp[h-1][w-1]);
    }
  }
}

Measured memory_bytes: 25980
N = int(input())
A = list(map(int, input().split()))

money = 1000
kabu = 0
for i in range(N-1):
    if A[i+1] > A[i]:
        kabu += money // A[i]
        money %= A[i]
    else:
        money += kabu * A[i]
        kabu = 0
money += kabu * A[-1]
kabu = 0
print(money)

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

vector<int> vazio,total;
vector<vector<int>> adj;
vector<vector<int>> resposta; 

int main(){
		int n,x,y;
		cin >> n >> x >> y;
		int totalPares=n*n-1;
		totalPares-=n;;
		for (int i = 0; i <= n; ++i)
		{
			resposta.push_back(vazio);
			total.push_back(0);
			for (int j = 0; j <= n; ++j)
			{
				resposta[i].push_back(-1);
			}
			adj.push_back(vazio);
		}
		for (int i = 1; i < n; ++i)
		{
			adj[i].push_back(i+1);
			adj[i+1].push_back(i);
		}
		adj[x].push_back(y);
		adj[y].push_back(x);
		for (int i = 1; i <= n; ++i)
		{
			queue<int> bfs;
			bfs.push(i);
			bfs.push(0);
			while(!bfs.empty()){
				int atual=bfs.front();
				bfs.pop();
				int distancia=bfs.front();
				bfs.pop();
				for (int j = 0; j < adj[atual].size(); ++j)
				{
					if(resposta[i][adj[atual][j]]==-1){
						resposta[i][adj[atual][j]]=distancia+1;
						if(adj[atual][j]>i){
							total[distancia+1]+=1;
						}
						bfs.push(adj[atual][j]);
						bfs.push(distancia+1);
					}
				}
			}
		}
		for (int i = 1; i < n; ++i)
		{
			cout << total[i] << endl;
		}
}


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

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }


int ans=1000000000;
int main(){
    string s;
    string t;
    cin>>s;
    for(int i=0;i<8;i++){
        t="";
        for(int j=i;j<i+3;j++){
            t+=s[j];
        }
        int p=toInt(t);
        ans=min(ans,abs(p-753));
    }

    
    cout<<ans<<endl;
}

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


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

	queue<int64_t> lun;
	for (int64_t i = 1; i <= 9; i++) {
		lun.push(i);
	}

	int cnt = 1;
	int64_t ans = 0;
	while (cnt <= k) {
		ans = lun.front();
		int64_t amari = ans % 10;
		if (amari != 0) {
			lun.push(ans * 10 + amari - 1);
		}
		lun.push(ans * 10 + amari);
		if (ans % 10 != 9) {
			lun.push(ans * 10 + amari + 1);
		}
		lun.pop();
		cnt++;
	}

	cout << ans << endl;

}



Measured memory_bytes: 1792
import copy

def bubble_sort(a):
    ba = copy.copy(a)
    flag = True
    for i in range(0, n):
        if not flag:
            break
        flag = False
        for j in range(n-1, 0, -1):
            if int(ba[j][1]) < int(ba[j-1][1]):
                ba[j], ba[j-1] = ba[j-1], ba[j]
                flag = True

    return ba

def selection_sort(a):
    sa = copy.copy(a)
    for i in range(n):
        flag = False
        minj = i
        for j in range(i, n):
            if int(sa[j][1]) < int(sa[minj][1]):
                minj = j
                flag = True
        if flag:
            sa[i], sa[minj] = sa[minj], sa[i]

    return sa

def is_stable(ba, sa):
    for b, s in zip(ba, sa):
        if b != s:
            return 'Not stable'
    return 'Stable'


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

ba = bubble_sort(a)
print(' '.join(map(str, ba)))
print('Stable')

sa = selection_sort(a)
print(' '.join(map(str, sa)))
print(is_stable(ba, sa))



Measured memory_bytes: 6344
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int a[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n ;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+n+1,greater<int>());
    int p;
    for(int i=1;i<=n;i++)
    {
        if(a[i]>=i)
            p=i;
        else break;
    }
    int q;
    for(int i=1;i<=n;i++)
    {
        if(a[i]>=p)
            q=i;
    }
    if(((a[p]-p+1)&1)&&((q-p+1)&1))
    {
        printf("Second");
    }
    else puts("First");

}


Measured memory_bytes: 640
s = input()
OPE_CNT = 3
ANS = 7

def solve(sum, cnt, ope_s):
    if cnt == OPE_CNT:
        if sum == ANS:
            print(ope_s + '=7')
            return True
        else:
            return False
    if solve(sum + int(s[cnt + 1]), cnt + 1, ope_s + '+' + s[cnt + 1]):
        return True
    if solve(sum - int(s[cnt + 1]), cnt + 1, ope_s + '-' + s[cnt + 1]):
        return True
    return False

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


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define sz(x) (int)x.size()
using namespace std;

const int MXN = (int)1e7 + 7;

typedef long long llong;

int n, lp[MXN];
llong ans;

void comp(){
  for(int i = 2; i <= 1e7; i++){
    if(!lp[i]){
      for(int j = i; j <= 1e7; j += i){
        lp[j] = i;
      }
    }
  }
}

int div(int n){
  int ans = 1;
  while(n > 1){
    int x = lp[n], cnt = 1;
    while(n % x == 0){
      n /= x;
      cnt++;
    }
    ans *= cnt;
  }
  return ans;
}

int main(){
  ios_base::sync_with_stdio(0);
  comp();
  cin >> n;
  for(int i = 1; i <= n; i++){
    ans += (i * 1LL) * (div(i) * 1LL);
  }
  cout << ans;
	return 0;
}


Measured memory_bytes: 42708
var input = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/g);
var k = input[0].split(/\s/g)[1];
var l = input[1].split(/\s/g).map(function(s){return s - 0;}).sort(function(a,b){return (parseInt(a) > parseInt(b)) ? 1 : -1;});
console.log(l.slice(l.length - k).reduce(function(s, a){return s + a;}));

Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>

int main(){
    int n;
    while(cin >> n,n){
        
        // ?????????????????????????????±
        priority_queue<pii,vector<pii>,greater<pii>> pq;
        
        // ?????\??????????????????????´???????????????????
        map<int,vector<pii>> mp;
        
        // ??????????????????????????????->?????\??????
        map<int,int> endtoi;
        
        pq.push(make_pair(0, 1000000000));
        
        for(int i=0;i<n;i++){
            char c;cin >> c;
            if(c == 'W'){
                int i,s;
                cin >> i >> s;
                while(s > 0){
                    pii x = pq.top();
                    pq.pop();
                    if(s <= x.second - x.first){
                        pq.push(make_pair(x.first + s, x.second));
                        mp[i].push_back(make_pair(x.first, x.first + s));
                        endtoi[x.first + s] = i;
                        s = 0;
                    } else {
                        s -= x.second - x.first;
                        mp[i].push_back(make_pair(x.first, x.second));
                        endtoi[x.second] = i;
                    }
                }
            }
            if(c == 'D'){
                int i;
                cin >> i;
                for(int unsigned j = 0; j < mp[i].size(); j++){
                    pq.push(make_pair(mp[i][j].first,mp[i][j].second));
                    endtoi.erase(mp[i][j].second);
                }
                mp.erase(i);
            }
            // ?????°???
            if(c == 'R'){
                int p;
                cin >> p;
                auto it = endtoi.upper_bound(p);
                if(it == endtoi.end()){
                    cout << -1 << endl;
                    continue;
                }
                int i = it->second;
                
                bool isInRange = false;
                for(int unsigned j = 0;j<mp[i].size();j++){
                	if(mp[i][j].first <= p && p <= mp[i][j].second){
                		isInRange = true;
                	}
                }
                if(isInRange){
                    cout << i << endl;
                } else {
                    cout << -1 << endl;
                }
            }
        }
        cout << endl;
    }
	return 0;
}

Measured memory_bytes: 3288
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int H, W, N;
  cin >> H >> W >> N;
  
  vector<int> A(N);
  for( int i = 0; i < N; i++ ) cin >> A.at(i);
  
  int color = 1;
  vector<vector<int>> C(H, vector<int>(W));
  for( int i = 0; i < H; i++ ){
    for( int j = 0; j < W; j++ ){
      if( i % 2 == 0 ){ //→
        C.at(i).at(j) = color;
        A.at(color-1)--;
      }else{ //←
        C.at(i).at(W-1-j) = color;
        A.at(color-1)--;
      }
      if( A.at(color-1) == 0 ) color++;
    }
  }
  
  
  for( int i = 0; i < H; i++ ){
    for( int j = 0; j < W; j++ ) cout << C.at(i).at(j) << " ";
    cout << endl;
  }
        
    
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b, sum;
    cin >> a >> b;
    for (int i=0; i<2; i++){
        if (a>b){
            sum += a;
            a--;
        }
        else {
            sum += b;
            b--;
        }
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	@SuppressWarnings("unchecked")
	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			int k = scanner.nextInt();
			if ((n | k) == 0)
				break;
			List<Edge>[] lists = new ArrayList[n];
			for (int i = 0; i < n; i++)
				lists[i] = new ArrayList<Edge>();
			while (k-- > 0) {
				int a = scanner.nextInt();
				if (a == 1) {
					int b = scanner.nextInt() - 1;
					int c = scanner.nextInt() - 1;
					int d = scanner.nextInt();
					lists[b].add(new Edge(c, d));
					lists[c].add(new Edge(b, d));
				} else {
					int s = scanner.nextInt() - 1;
					int g = scanner.nextInt() - 1;
					PriorityQueue<Edge> pq = new PriorityQueue<Edge>();
					pq.offer(new Edge(s, 0));
					int ans = -1;
					int[] cost = new int[n];
					Arrays.fill(cost, 1 << 30);
					cost[s] = 0;

					while (!pq.isEmpty()) {
						Edge edge = pq.poll();
						if (edge.to == g) {
							ans = edge.cost;
							break;
						}
						for (Edge e : lists[edge.to]) {
							if (cost[e.to] < e.cost + edge.cost)
								continue;
							cost[e.to] = e.cost + edge.cost;
							pq.offer(new Edge(e.to, e.cost + edge.cost));
						}
					}
					System.out.println(ans);
				}
			}
		}
	}

	class Edge implements Comparable<Edge> {
		@Override
		public String toString() {
			return "Edge [to=" + to + ", cost=" + cost + "]";
		}

		public Edge(int to, int cost) {
			super();
			this.to = to;
			this.cost = cost;
		}

		int to, cost;

		@Override
		public int compareTo(Edge o) {
			return this.cost - o.cost;
		}

	}
}

Measured memory_bytes: 62524
#include<iostream>
#include<math.h>
#include<vector>
using namespace std;


int main(void){
  int n;
  vector<int> v(10000);
  int flg=0;
  int count=0;
  cin >> n;
for(int k = 0;k<n;k++)
 {
      cin >> v[k];
    for(int j= 2;j<=sqrt(v[k])+2;j++){
	  if(v[k]%j==0&&v[k]!=j)
	    {
	      flg=1;
	    }
    }
	  if(flg==0)
	    {
	      count=count+1;
	    }
  flg=0;
 }
  cout << count << endl;
  return 0;
}



Measured memory_bytes: 3124
n = int(input())
for i in range(1,100):
    if 26**i<n:
        n -= 26**i
    else:        
        break

alpha = [chr(i) for i in range(97, 97+26)]

lis = []
n-=1
for j in range(i-1,-1, -1):
    a = n//(26**j)
    lis.append(alpha[a])
    n = n%(26**j)

print("".join(lis))

Measured memory_bytes: 9220
N = input()
S = [raw_input() for _ in range(2)]

T = [[[0]*3 for i in range(3)] for j in range(N)]

for i in range(3):
  for j in range(3):
    if S[0][0]==S[1][0] and i==j or S[0][0]!=S[1][0] and i!=j:
      T[0][i][j] += 1

for i in range(1, N):
  for p0 in range(3):
    for p1 in range(3):
      for c0 in range(3):
        for c1 in range(3):
          if ((S[0][i-1]==S[0][i] and p0==c0 or S[0][i-1]!=S[0][i] and p0!=c0) and
              (S[1][i-1]==S[1][i] and p1==c1 or S[1][i-1]!=S[1][i] and p1!=c1) and
              (S[0][i]==S[1][i] and c0==c1 or S[0][i]!=S[1][i] and c0!=c1)):
            T[i][c0][c1] += T[i-1][p0][p1]
            T[i][c0][c1] %= 1000000007
ans = 0
for i in range(3):
  for j in range(3):
    ans += T[-1][i][j]
    ans %= 1000000007
print ans


Measured memory_bytes: 2696
#include<iostream>
#include<vector>
#include<functional>
#include<queue>
#include<map>
#include<algorithm>
#include<string>

using namespace std;

int main(void){

    string str, r_str;
    cin >> str;

    int count = 0;

    for(int i = 0;i < str.length();i++){
        if(str[i] != str[str.length()-1-i]) count++;
    }

    cout << count/2 << endl;


    return 0;
}

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

using namespace std;

// Prioridade
typedef long long   ll;
typedef pair<ll,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(int i = a; i < (b); i++)
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (((a)*(b))/__gcd((a), (b)))

// fim da Prioridade
int dp[100010];
int h[100200];
int n;
int k;
int solve(int i){
	if(i == n-1){
		return 0;
	}
	if(i >= n)
		return INF;
	if(dp[i] != -1){
		return dp[i];
	}
	int ans = INF;
	REP(j,1,k+1){
		ans = min(ans,abs(h[i] - h[i+j]) + solve(i+j));
	}
	return dp[i] = ans;
}
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin >> n;
	cin >> k;
	memset(dp,-1,sizeof dp);
	REP(i,0,n){
		cin >> h[i];
	}
	cout << solve(0) << endl;
	return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define vpi vector<ppi>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/

int main()
{
	fast


		
	ld a,b;
	cin>>a>>b;	

	cout<<ceil((b-1)/(a-1));










	return 0;
}

Measured memory_bytes: 256
import * as fs from 'fs';

namespace AtCoder.abc113 {

    class Program {
        /**
         * in
         *  81 58
         * out
         *  110
         */
        main(inp: string): void {
            const [x, y]: number[] = inp.split(' ').map(x => parseInt(x, 10));
            console.log(x+y/2);

        }
    }

    const prg = new Program();
    prg.main(fs.readFileSync('/dev/stdin', 'utf8').trim());
}




Measured memory_bytes: 7500
use std::collections::VecDeque;
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let ab: Vec<_> = (0..n - 1)
        .map(|_| (read::<usize>() - 1, read::<usize>() - 1))
        .collect();

    let mut graph: Vec<Vec<usize>> = vec![vec![]; n];
    for (a, b) in ab {
        graph[a].push(b);
        graph[b].push(a);
    }

    let (w, b) = calc_dist(0, n, &graph)
        .iter()
        .zip(calc_dist(n - 1, n, &graph))
        .fold(
            (0, 0),
            |(w, b), (x, y)| if *x <= y { (w + 1, b) } else { (w, b + 1) },
        );

    println!("{}", if w > b { "Fennec" } else { "Snuke" });
}

fn calc_dist(start: usize, n: usize, graph: &Vec<Vec<usize>>) -> Vec<usize> {
    let mut queue = VecDeque::new();
    let mut dist = vec![std::usize::MAX; n];

    dist[start] = 0;
    queue.push_back(start);

    while let Some(v) = queue.pop_front() {
        for &next in &graph[v] {
            if dist[next] <= dist[v] {
                continue;
            }
            dist[next] = dist[v] + 1;
            queue.push_back(next);
        }
    }
    dist
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 14588
n=int(input())
x=sum=0
while True:
    r1 = 10**x
    r2 = 10**(x+1)
    if n < r1:
        break
    if r1 <= n < r2:
        sum += n - r1 + 1
        break
    else:
        sum += r2 - r1
    x += 2
print(sum)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		 
        Scanner scan = new Scanner(System.in);
 
        while (true) {
            String str = scan.nextLine();
            if (str.equals("0")) break;
            int sum = 0;
            char[] box = str.toCharArray();
            for (int i = 0; i < box.length; i++)
                sum += box[i] - '0';
            System.out.println(sum);
        }
 
    }
}

Measured memory_bytes: 17476
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    int dif = b - a;
    int sum = 0;
    for(int i = 1; i <= dif; i++){
        sum += i;
    }
    cout << sum - b << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7



int main() {
	
	int N;
	double A[1000];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%lf", &A[i]);
	}

	double ans = 0;
	for (int i = 0; i < N; i++) {
		ans += 1.0 / A[i];
	}



	printf("%f", 1.0 / ans);




}






Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int h[N];
  for (int i = 0; i < N; i++)
    cin >> h[i];
  int ans = 0;
  int active = 0;
  for (int i = 0; i < N; i++)
  {
    if (active < h[i])
    {
      ans += h[i] - active;
    }
    active = h[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int Inf = 1e9+7;
const int Mod = 1e9+7;

string path = "";

int main ()
{
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int dx = x2-x1;
	int dy = y2-y1;
	for (int i = 1; i <= dy; i ++) {
		cout << 'U';
	}
	for (int i = 1; i <= dx; i++) {
		cout << 'R';
	}
	for (int i = 1; i <= dy; i++) {
		cout << 'D';
	}
	for (int i = 1; i <= dx+1; i++) {
		cout << 'L';
	}
	for (int i = 1; i <= dy+1; i++) {
		cout << 'U';
	}
	for (int i = 1; i<= dx+1; i++) {
		cout << 'R';
	}
	cout <<'D' << 'R';
	for (int i = 1; i <= dy+1; i++) {
		cout << 'D';
	}
	for (int i = 1; i <= dx+1; i++) {
		cout << 'L';
	}
	cout << 'U' << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int sx, sy, tx, ty;
 
int main() {
//    std::ios::sync_with_stdio(false);
    while( scanf( "%d%d%d%d", &sx, &sy, &tx, &ty ) != EOF ) {
        string ans;
        for( int i = 0; i < ty-sy; ++i ) {
            ans += 'U';
        }
        for( int i = 0; i < tx-sx; ++i ) {
            ans += 'R';
        }
        for( int i = 0; i < ty-sy; ++i ) {
            ans += 'D';
        }
        for( int i = 0; i < tx-sx; ++i ) {
            ans += 'L';
        }
        ans += 'L';
        for( int i = 0; i < ty-sy+1; ++i ) {
            ans += 'U';
        }
        for( int i = 0; i < tx-sx+1; ++i ) {
            ans += 'R';
        }
        ans += 'D';
        ans += 'R';
        for( int i = 0; i < ty-sy+1; ++i ) {
            ans += 'D';
        }
        for( int i = 0; i < tx-sx+1; ++i ) {
            ans += 'L';
        }
        ans += 'U';
        cout<<ans<<endl;
    }
 
    
    
}

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

signed main() {
  int a, b;
  cin >> a >> b;
  if(a<b) {
    for(int i=0; i<b; i++) cout << a;
    puts("");
  }
  else {
    for(int i=0; i<a; i++) cout << b;
    puts("");
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>

#define MAX_V	(100)

int main(int argc, char const *argv[])
{
	int E[MAX_V][MAX_V], V;

	while (scanf("%d", &V), V){
		int used[MAX_V] = {0};
		int m;
		int count, min_c, min_v;
		int lantern;
		int i, j;
		
		// init
		for (i = 0; i < V; i++){
			for (j = 0; j < V; j++){
				E[i][j] = INT_MAX;
			}
		}

		scanf("%d", &m);
		for (i = 0; i < m; i++){
			int from, to, cost;
			scanf("%d,%d,%d", &from, &to, &cost);
			E[from][to] = E[to][from] = cost / 100 - 1;
		}

		used[0] = 1;
		count = 1;
		lantern = 0;

		while (count < V){
			min_v = INT_MAX;
			for (i = 0; i < V; i++){
				if (!used[i]) continue;
				for (j = 0; j < V; j++){
					if (used[j]) continue;
					if (min_v > E[i][j]){
						min_v = E[i][j];
						min_c = j;
					}
				}
			}
			lantern += min_v;
			used[min_c] = 1;
			count++;
		}
		printf("%d\n", lantern);
	}
	return (0);
}

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

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

    cout << fixed;
    cout << a / b << ' ' << a % b << ' ' << setprecision(6) << (double)a / (double)b << endl;
}



Measured memory_bytes: 3284
def calculate1():
    change = B - A
    if change % 1000 == 0:
        one_thousand_count = change / 1000
        print_result(one_thousand_count)
    else:
        one_thousand_count = change / 1000
        remainder = change - one_thousand_count * 1000
        calculate2(remainder, one_thousand_count)
        
def calculate2(remainder, one_thousand_count):
    if remainder % 500 == 0:
        five_hundred_count = remainder / 500
        print_result(one_thousand_count, five_hundred_count)
    else:
        five_hundred_count = remainder / 500
        remainder = remainder - five_hundred_count * 500
        calculate3(remainder, one_thousand_count, five_hundred_count)
        
def calculate3(remainder, one_thousand_count, five_hundred_count):
        one_hundred_count = remainder / 100
        print_result(one_thousand_count, five_hundred_count, one_hundred_count)
        
def print_result(one_thousand_count=0, five_hundred_count=0, one_hundred_count=0):
    print '%s %s %s' % (one_hundred_count, five_hundred_count, one_thousand_count)

while True:
    A, B = map(int, raw_input().split())
    if A == 0 and B == 0: break
    calculate1()

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

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

if n%2:
    for i in range(n-1,-1,-2):
        print(data[i],end=" ")
    for i in range(1,n-1,2):
        print(data[i],end=" ")
    print("")
else:
    for i in range(n-1,-1,-2):
        print(data[i],end=" ")
    for i in range(0,n-1,2):
        print(data[i],end=" ")
    print("")


Measured memory_bytes: 26180
// AOJ 1214: Walking Ant
// 2017.10.15

#include <stdio.h>
#include <string.h>

typedef struct { int r, c, t, hp; } Q;
Q q[700]; int top, end;
char map[10][10];
char mk[10][10][7];

int mv[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};

int main()
{
	int w, h, i, a, r, c, t, hp, r2, c2, sr, sc, gr, gc, ans;

	while (scanf("%d%d", &w, &h) && w > 0) {
		memset(mk, 0, sizeof(mk));
		for (r = 0; r < h; r++) for (c = 0; c < w; c++) {
			scanf("%d", &a);
			map[r][c] = a;
			if (a == 2) sr = r, sc = c, map[r][c] = 1;
			else if (a == 3) gr = r, gc = c;
		}
		q[0].r = sr, q[0].c = sc, q[0].t = 0, q[0].hp = 6;
		top = 0, end = 1, mk[sr][sc][6] = 1;
		ans = -1;
		while (top < end) {
			r = q[top].r, c = q[top].c, t = q[top].t, hp = q[top++].hp;
			if (r == gr && c == gc) { ans = t; break; }
			if (hp <= 1) continue;
			for (i = 0; i < 4; i++) {
				r2 = r + mv[i][0], c2 = c + mv[i][1];
				if (r2 < 0 || r2 >= h || c2 < 0 || c2 >= w || map[r2][c2] == 0) continue;
				if (mk[r2][c2][hp-1]) continue;
				mk[r2][c2][hp-1] = 1;

				q[end].r = r2, q[end].c = c2, q[end].t = t+1;
				q[end].hp = (map[r2][c2] == 4) ? 6 : hp-1;
				end++;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1692
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a[100];
	cin>>a;
	int c=0;
	for(int i=0;i<strlen(a);i++)
	{
		if((i+1)%2==1){
		if(a[i]=='R' || a[i]=='U' || a[i]=='D')
			c+=1;
	
	}
	
	if((i+1)%2==0)
	{
	if(a[i]=='L' || a[i]=='U' || a[i]=='D')
	c+=1;

}
}
if(c==strlen(a))
	cout<<"Yes";
else
cout<<"No";
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.bigint;

struct UFTree(T)
{
    struct Node
    {
        T parent;
        T rank = 1;
    }

    ///
    this(T n)
    {
        nodes.length = n;
        sizes.length = n;
        foreach (i, ref node; nodes) {
            node = Node(i.to!T);
            sizes[i] = 1;
        }
    }

    ///
    bool unite(T a, T b)
    {
        a = root(a);
        b = root(b);

        if (a == b) return false;

        if (nodes[a].rank < nodes[b].rank) {
            sizes[nodes[a].parent] += sizes[nodes[b].parent];
            nodes[b].parent = nodes[a].parent;
        } else {
            sizes[nodes[b].parent] += sizes[nodes[a].parent];
            nodes[a].parent = nodes[b].parent;
            if (nodes[a].rank == nodes[b].rank) nodes[a].rank += 1;
        }

        return true;
    }

    ///
    bool is_same(T a, T b)
    {
        return root(a) == root(b);
    }

    ///
    T size(T i)
    {
        return sizes[root(i)];
    }

private:
    Node[] nodes;
    T[] sizes;

    T root(T i)
    {
        if (nodes[i].parent == i) return i;

        return nodes[i].parent = root(nodes[i].parent);
    }
}

///
UFTree!T uftree(T)(T n)
{
    return UFTree!T(n);
}

alias AB = Tuple!(int, "a", int, "b");

void main()
{
    auto N = readln.chomp.to!int;
    auto ab = new AB[](N);
    auto as = new int[](N);
    foreach (i, a; readln.split.to!(int[])) {
        ab[i].a = a;
        as[i] = a;
    }
    foreach (i, b; readln.split.to!(int[])) ab[i].b = b;
    sort!"a.b < b.b"(ab);
    sort(as);
    foreach (i; 0..N) {
        if (as[i] > ab[i].b) {
            writeln("No");
            return;
        }
    }
    AB[] xas, yas;
    xas.length = N;
    yas.length = N;
    foreach (i; 0..N) {
        xas[i] = AB(i, ab[i].a);
        yas[i] = AB(i, ab[i].a);
    }
    sort!"a.b < b.b"(yas);
    auto uft = uftree(N);
    foreach (i; 0..N) {
        uft.unite(xas[i].a, yas[i].a);
    }
    if (uft.size(0) != N) {
        writeln("Yes");
        return;
    }
    foreach (i; 0..N-1) {
        if (as[i+1] <= ab[i].b) {
            writeln("Yes");
            return;
        }
    }
    writeln("No");
}

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

using namespace std;

int main() {
    unsigned long long a, b, m;
    cin >> a >> b >> m;
    vector<unsigned long long> refrigerators(a);
    vector<unsigned long long> microwaves(b);
    for (unsigned long long i = 0; i < a; ++i) cin >> refrigerators[i];
    for (unsigned long long i = 0; i < b; ++i) cin >> microwaves[i];
    unsigned long long min_price = *min_element(refrigerators.begin(), refrigerators.end()) + *min_element(microwaves.begin(), microwaves.end());
    for (unsigned long long i = 0; i < m; ++i) {
        unsigned long long x, y, c;
        cin >> x >> y >> c;
        unsigned long long price = refrigerators[x - 1] + microwaves[y - 1] - c;
        if (price < min_price) min_price = price;
    }
    cout << min_price << endl;
    return EXIT_SUCCESS;
}

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

//ACのカウント関数
vector<int> ac(int N, string S){
    int cnt=0;
    vector<int> T(N-1);
    for(int i = 0; i < N-1; i++){
        if(S[i] == 'A' && S[i+1] == 'C'){
            cnt++;
        }
        T[i] = cnt;
    }
    return T;
}

int main(){
    int N, Q;
    string S;
    cin >> N >> Q >> S;
    vector<int> T(N-1);
    T = ac(N, S);
    vector<int> l(Q),r(Q);
    for(int i = 0; i < Q; i++){
        cin >> l[i] >> r[i];
    }
    for(int i = 0; i < Q; i++){
        cout << (T[r[i]-2] - T[l[i]-2]) << endl;
    }
}

Measured memory_bytes: 2296
#include <iostream>
using namespace std;
#define rep(i,n) for(int i = 0; i < n ; i++)
int n, memo[52];
void init(){
  rep(i,10)rep(j,10)rep(k,10)rep(l,10)memo[i+j+k+l]++;
}
int main(){
  init();
  while(cin >> n){
    cout << memo[n] << endl;
  }
  return 0;
}

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

int n, m, a[1010], b[1010], ans[1010], mx;

int main()
{
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < m; i++)
        cin >> b[i];
    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (a[j] <= b[i])
            {
                ans[j + 1]++;
                mx = max(mx, ans[j + 1]);
                break;
            }
        }
    }
    for (int i = 0; i <= 1000; i++)
    {
        if (ans[i] == mx)
        {
            cout << i << endl;
            return 0;
        }
    }
}



Measured memory_bytes: 3112
#include <cstdio>
#include <math.h>
#include <utility>

using namespace std;

int main ()
{
  int n;
  int first[3][10];
  int second[3][10];
  int third[3][10];
  int fourth[3][10];
  int b, f, r, v;

  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 10; j++) {
      first[i][j] = 0;
      second[i][j] = 0;
      third[i][j] = 0;
      fourth[i][j] = 0;
    }
  }


  scanf("%d", &n);

  for (int i = 1; i <= n; i++) {
    scanf("%d %d %d %d", &b, &f, &r, &v);
    if (b == 1){
      first[f - 1][r - 1] += v;
    } else if (b == 2) {
      second[f - 1][r - 1] += v;
    } else if (b == 3) {
      third[f - 1][r - 1] += v;
    } else if (b == 4) {
      fourth[f - 1][r - 1] += v;
    }
  }

  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 10; j++) {
      printf(" %d", first[i][j]);
    }
    printf("\n");
  }
  printf("####################\n");

  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 10; j++) {
      printf(" %d", second[i][j]);
    }
    printf("\n");
  }
  printf("####################\n");

  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 10; j++) {
      printf(" %d", third[i][j]);
    }
    printf("\n");
  }
  printf("####################\n");

  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 10; j++) {
      printf(" %d", fourth[i][j]);
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 2704
#!/usr/bin/env python3
import sys
import collections as cl


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()
    A = LI()
    count = [0] * (N + 1)

    for a in A:
        count[a] += 1

    total = 0

    for idx in range(N+1):
        total += count[idx] * (count[idx] - 1) / 2
    for a in A:
        a_count = count[a]
        print(int(total - (a_count * (a_count - 1) /
                           2) + ((a_count - 1)*(a_count - 2)/2)))


main()


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

int main() {
	int a, b, c, d, e, f, mixedAns = 0, sugarAns = 0;
	cin >> a >> b >> c >> d >> e >> f;
	double cnc = -1;

	for (int ai = 0; ai <= f; ai += 100 * a) {
		for (int bi = 0; ai + bi <= f; bi += 100 * b) {
			int water = ai + bi; if (water == 0)continue;

			for (int ci = 0; water + ci <= f; ci += c) {
				for (int di = 0; water + ci + di <= f; di += d) {
					int sugar = ci + di;
					double nowCnc = 100.0 * sugar / (water + sugar);
					int limitSugar = water / 100 * e;
					if (sugar <= limitSugar && nowCnc > cnc) {
						cnc = nowCnc;
						mixedAns = water + sugar; sugarAns = sugar;
					}
				}
			}
		}
	}
	cout << mixedAns << ' ' << sugarAns << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef PRAGMA
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif
#define fst first
#define snd second
#define fore(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define bs binary_search
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int) (n).size())
#define MAXI ((ll)1e16)
#define MINI ((ll)-1e16)
using namespace std;
typedef long long ll;  
     
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b,a%b); } 
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }          
ll n,res,aux;
ll a[3001];
ll dp[3001][3001][2];
ll solve(int l, int r, int k){
	if(l>r)return 0;
	if(dp[l][r][k]!=-1)return dp[l][r][k];
	if(!k)dp[l][r][k]=max(a[l]+solve(l+1,r,(k+1)%2),a[r]+solve(l,r-1,(k+1)%2));
	else dp[l][r][k]=min(solve(l+1,r,(k+1)%2)-a[l],solve(l,r-1,(k+1)%2)-a[r]);
	return dp[l][r][k];
}
int main(){FIN;
	cin >> n;
	fore(i,0,n){
		cin >> a[i];
	}
	memset(dp,-1,sizeof(dp));
	cout << solve(0,n-1,0);
	
}

Measured memory_bytes: 141184
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <list>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cstdio>


using namespace std;
const int mod = 1000000007;

int main(){
    int h, w, k;
    cin >> h >> w >> k;

    vector<vector<int> > dp(h + 1, vector<int> (w, 0));
    dp[0][0] = 1;

    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            for(int x = 0; x < (1 << (w - 1)); ++x){
                /*
                to exclude the pattern where two line next set
                */
                bool isOK = true;
                for(int l = 0; l < w - 2; ++l){
                    if((x & (1 << l)) && (x & (1 << (l + 1)))) isOK = false;
                }

                if(isOK){
                    if((j >= 1) && (x & (1 << (j - 1)))){
                        dp[i + 1][j - 1] += dp[i][j];
                        dp[i + 1][j - 1] %= mod;
                    }else if((j <= (w - 2)) && (x & (1 << j))){
                        dp[i + 1][j + 1] += dp[i][j];
                        dp[i + 1][j + 1] %= mod;
                    }else{
                        dp[i + 1][j] += dp[i][j];
                        dp[i + 1][j] %= mod;
                    }
                }

            }
        }
    }
    cout << dp[h][k - 1] << endl;

    return 0;
}

Measured memory_bytes: 256
let () =
  let n = read_int () in
  let tbl = Hashtbl.create 2000000 in
  for i=1 to n do
    begin match Scanf.scanf "%s %s\n" (fun a b -> a,b) with
        "insert",word -> Hashtbl.add tbl word 0
      | _,word ->
        Printf.printf "%s\n"
          (if Hashtbl.mem tbl word then "yes" else "no")
    end
  done

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

int main(){
	int N, K; cin>>N>>K;
	vector<int> P(N), C(N);
	rep(i, N) cin>>P[i], P[i]--;
	rep(i, N) cin>>C[i];

	ll score = -1e18;
	rep(st, N){
		ll lap_sc = 0;
		int lap_cn = 0;
		int nx = st;
		while(true){
			lap_cn++;
			lap_sc += C[nx];
			if(st == (nx = P[nx])) break;
		}
		lap_sc = max(0LL, lap_sc);

		ll sum_sc = 0;
		rep(k_cn, K){
			sum_sc += C[nx];
			score = max(score, sum_sc + lap_sc * ((K - (k_cn + 1)) / lap_cn));
			if(st == (nx = P[nx])) break;
		}
	}
	cout<< score <<endl;
}


Measured memory_bytes: 3672
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
          int N =sc.nextInt();
          int n[] = new int[N];
      
      for(int i=0; i<N; i++){
      n[i]= sc.nextInt();
      }
      
      Arrays.sort(n);
      
      for(int i=0; i<N; i++){
      System.out.println(n[N/2]-n[N/2-1]);
        break;
    }
}
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    ll s = accumulate(A.begin(), A.end(), 0LL);
    ll cnt = 0;
    rep(i, N) {
        if (A[i] >= s / (4.0 * M)) cnt++;
    }
    // print(cnt);
    if (cnt >= M) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }
}

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


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

template<typename T>
static inline void chmax(T& ref, const T value) {
	if (ref < value) ref = value;
}

const ll mod = 1000000007;

constexpr ll m = 1e9 + 7;

class modint {
	using u64 = std::int_fast64_t;

public:
	u64 a;
	modint(const u64 x = 0) noexcept : a(x% m) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= m) {
			a -= m;
		}
		return *this;
	}
	modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += m;
		}
		a -= rhs.a;
		return *this;
	}
	modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % m;
		return *this;
	}
};

ostream& operator<<(ostream& stream, const modint& data) {
	stream << data.a;
	return stream;
}

ll n;
vector<vector<int>> g;
vector<vector<modint>> dp;

modint dfs(int current, int parent, bool black) {
	if (dp[current][black].a >= 0) return dp[current][black];
	modint ans = 1;
	for (auto c : g[current]) {
		if (c == parent) continue;
		modint nc = dfs(c, current, false);
		if (!black) {
			nc += dfs(c, current, true);
		}
		ans *= nc;
	}
	dp[current][black] = ans;
	return ans;
}

int main() {
	cin >> n;
	g.resize(n);
	dp.resize(n, vector<modint>(2, -1));
	rep(i, n-1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	modint ans = dfs(0, -1, false);
	ans += dfs(0, -1, true);
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 22356
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	string a, b;
	cin >> a >> b;

	int n = stoi(a + b);
	for(int i = 1; i * i <= n; i++){
		if(i * i == n){
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 N, M;
  cin >> N >> M;
  vector<i64> H(N);
  for (i64 i = 0; i < N; i++)
    cin >> H[i];
  vector<i64> edge[N];
  for (i64 i = 0; i < M; i++)
  {
    i64 A, B;
    cin >> A >> B;
    A--;
    B--;
    edge[A].push_back(B);
    edge[B].push_back(A);
  }
  i64 ans = 0;
  for (i64 i = 0; i < N; i++)
  {
    bool ok = true;
    for (i64 j : edge[i])
      if (H[i] <= H[j])
        ok = false;
    if (ok)
      ans++;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	int n, k;
	string s;
	cin >> n >> k;
	cin >> s;
	Vec<int> st(1);
	for (int i = 1; i < s.size(); i++) {
		if (s[i - 1] != s[i]) {
			st.push_back(i);
		}
	}
	for (int i = 0; i < 4 * k; i++) {
		st.push_back(n);
	}
	int ans = 0;
	for (int i = 0; st[i] < n; i++) {
		if (s[st[i]] == '0') {
			ans = max(ans, st[i + 2 * k] - st[i]);
		}
		else {
			ans = max(ans, st[i + 2 * k + 1] - st[i]);
		}
	}
	cout << ans << "\n";
}

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


Measured memory_bytes: 2500
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


void solve(vll&ans, vll&ab, vll&c, int k)
{
	for(ll mab:ab)
	{
		for(ll mc:c)
		{
			ll v=-(mab+mc);
			if(v>=ans[k-1]) break;

			auto it=lower_bound(ans.begin(), ans.end(), v);
			ans.insert(it, v);
			ans.pop_back();
		}
	}
}


int main(void)
{
	int x, y, z, k;
	while(scanf("%d%d%d%d", &x, &y, &z, &k)==4)
	{
		vll a(x), b(y), c(z);
		vll ab, ans(k);

		ab.reserve(x*y);
		for(int i=0;i<x;i++) scanf("%lld", &a[i]);
		for(int i=0;i<y;i++) scanf("%lld", &b[i]);
		for(int i=0;i<z;i++) scanf("%lld", &c[i]);
		for(ll ma:a)
		{
			for(ll mb:b)
			{
				ab.push_back(ma+mb);
			}
		}
		sort(ab.rbegin(), ab.rend());
		sort(c.rbegin(), c.rend());

		solve(ans, ab, c, k);
		for(int i=0;i<k;i++)
		{
			printf("%lld\n", -ans[i]);
		}
	}
	return 0;
}


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

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    for(int i = 0; i <= 100; ++i) {
        if(a * i - i + 1 >= b) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3640