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

int main(void)
{
    int D,N;
    cin >> D >> N;
    if(D == 0){
        if(N==100){
            cout << 101 << endl;
        }else{
            cout << N << endl;
        }
    }else if(D == 1){
        if(N==100){
            cout << 10100 << endl;
        }else{
            cout << N*100 << endl;
        }
    }else if(D == 2){
        if(N==100){
            cout << 1010000 << endl;
        }else{
            cout << N*10000 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n,a[2][20],ans=1e9;
int main(){
	scanf("%d", &n);
	rep(o,2) rep(i,n) scanf("%d", a[o]+i);
	rep(bt,1<<n){
		int rev[40] = {}, c[] = {-2,-1};
		bool ok = true;
		vector<int> v[51];
		rep(i,n) v[a[bt>>i&1][i]].push_back(i);
		rep(i,51){
			for(int t: v[i]) rev[c[abs(c[1]-t)%2 == (bt>>t)%2]+=2] = t+1;
			if(abs(c[0]-c[1])>1) ok = false;
		}
		if(ok){
			constexpr int sz = 32;
			int sm = 0;
			vector<int> dat(sz+1);
			rep(i,n){
				for(int j=rev[i]; j; j-=j&-j) sm+=dat[j];
				for(int j=rev[i]; j<=sz; j+=j&-j) dat[j]++;
			}
			sm = n*(n-1)/2 - sm;
			ans = min(ans,sm);
		}
	}
	printf("%d\n",ans == (int)1e9 ? -1 : ans);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cassert>
#define FILL(a, n, x) memset((a), (x), sizeof ((a)[0]) * (n))
#define FILLA(a, x) memset((a), (x), sizeof (a))
#define COPY(a, n, b) memcpy((b), (a), sizeof ((a)[0]) * (n))
#define COPYA(a, b) memcpy((b), (a), sizeof (a))
using namespace std;

typedef pair<int, int> pii;
typedef long long li;
typedef unsigned long long lu;
const int inf = ~0U >> 2;
const li infl = ~0LLU >> 2;

template <class T> inline void Min(T &x, T y) { if (y < x) x = y; }
template <class T> inline void Max(T &x, T y) { if (y > x) x = y; }

// const int mod = 1e9 + 7;
// inline int Add(int x) { return x >= mod ? x - mod : x; }
// inline void Add(int &x, int y) { x += y; if (x >= mod) x -= mod; }
// inline int Sub(int x) { return x < 0 ? x + mod : x; }
// inline void Sub(int &x, int y) { x -= y; if (x < 0) x += mod; }
// inline int Mul(int x, int y) { return (int)((li)x * y % mod); }
// inline int Mul(int x, int y, int z) { return Mul(x, Mul(y, z)); }
// int Pow(int x, int y) { int z = 1;
//   for (; y; y >>= 1, x = Mul(x, x)) { if (y & 1) z = Mul(z, x); } return z; }
// inline int Inv(int x) { return Pow(x, mod - 2); }
// inline int Fix(li x) { x %= mod; if (x < 0) x += mod; return (int)x; }
// inline int Fix(int x) { x %= mod; if (x < 0) x += mod; return x; }

// ----------------------------------------

const int maxn = 2e5;

int n, lim;
int st[maxn], top;
int L[maxn], R[maxn];
li ans;

li Ways(int l, int r) {
  li sum = 0, tot = 0;
  for (int i = r - 1; i >= l + lim - 1; --i) {
    sum += R[i];
    tot += (li)L[i - lim + 1] * sum;
  }
  for (int i = l; i < r; ++i) {
    tot += (li)L[i] * R[i];
  }
  return tot;
}

void Merge(void) {
  int val = st[top - 1];
  int begin = top - 1;
  while (begin > 0 && st[begin - 1] == st[begin]) {
    --begin;
  }
  int end = top;
  ans += Ways(begin, end);

  if (end - begin < lim) {
    top = begin;
    while (top > 0) Merge();
    return;
  }
  int len = (end - begin) / lim;

  static int cntP[maxn + 1], cntS[maxn + 1];
  FILL(cntP, len + 1, 0);
  FILL(cntS, len + 1, 0);
  for (int i = begin; i < end; ++i) {
    int c = i - begin + 1;
    if (c >= lim) {
      cntP[c / lim] += R[i];
    }
    c = end - i;
    if (c >= lim) {
      cntS[c / lim] += L[i];
    }
  }
  top = begin + len;
  for (int i = 0; i < len; ++i) {
    st[begin + i] = val + 1;
    L[begin + i] = cntS[len - i];
    R[begin + i] = cntP[i + 1];
  }

  ans -= Ways(begin, top);
}

int main(void) {
  scanf("%d%d", &n, &lim);
  top = 0;
  ans = 0;
  for (int i = 0; i < n; ++i) {
    int now;
    scanf("%d", &now);
    while (top > 0 && st[top - 1] < now) {
      Merge();
    }
    L[top] = R[top] = 1;
    st[top++] = now;
  }
  while (top > 0) {
    Merge();
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 2432
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>





using namespace std;
int main() {
	
	
	bool f[6] = {};
	int t[6 ]= {};
	
	for (int i = 0; i < 5; i++)cin >> t[i];

	int ans = 0;
	int p = 0;
	int a = 0;
	while (p < 5) {
		for (int i = 0; i < 5; i++) {
			if (t[i] % 10 == a && !f[i]) {
				ans += t[i];
p++;
				if(p<5&&a)ans += 10 - t[i] % 10;
				f[i] = 1;
			//	cout << ans << endl;
			
			}
			

		}if (a)a--;
			else a = 9;
	}
	cout << ans << endl;


	return 0;
}

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

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

    vector<long long> A(n-1);
    for(int i=0; i<n-1; i++){
        cin >> A.at(i);
    }

    vector<long long> B(n,0);

    for(int i=0; i<n-1; i++){
        B.at(A.at(i)-1)++;
    }

    for(int i=0; i<n; i++){
        cout << B.at(i) << endl;
    }

    
}

Measured memory_bytes: 6428
#include <bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    for(int i=1;i<1000;i++) {
        if(((a%b)*i)%b==c) {
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e12+1);
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	int c=0;
	while(-1){
		int a,b;cin>>a>>b;
		if(a+b==0){RE;}
		if(b<a){swap(a,b);}
		cout<<a<<" "<<b<<endl;
	}
	RE;
}


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

int main() {
  ll n, k;
  cin >> n >> k;

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

  sort(h.begin(), h.end());
  for (ll i = 0; i < min(k, n); i++) {
    h.pop_back();
  }
  
  ll ans = 0;
  for (auto hi : h) {
    ans += hi;
  }

  cout << ans << endl;
}


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

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

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

int alice =0, bob=0;

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



if (N%2 != 0){
for ( int i = 0; i < N ; i++){
  if (i == 0 || i%2 ==0) alice += a.at(i);
  else bob += a.at(i);
}}
else {
for ( int i = 0; i < N ; i++){
  if (i == 0 || i%2 ==0) bob += a.at(i);
  else alice+= a.at(i);
}}

cout << alice - bob << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (int)(n); i++
using namespace std;

int main() {
	int q,a,c;
	string b;
	map<string,int> s;
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin>>a>>b;
		if (a == 0) {
			cin >> c;
			if (s.count(b)) {
				s[b] = c;
			}
			else {
				s.insert(make_pair(b, c));
			}
		}
		else if (a == 1) {
			if (s.count(b)) {
				cout << s[b] << endl;
			}
			else {
				cout << 0 << endl;
			}
		}
		else {
			s.erase(b);
		}
	}
}




Measured memory_bytes: 27720
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;
u64 over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int k, t;
  cin >> k >> t;
  int n[t];
  for (int i = 0; i < t; ++i) cin >> n[i];
  for (int i = 0; i < t; ++i) {
    int other = k-n[i];
    if (n[i] > other+1) {
      cout << n[i] - other - 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    
    long long ans = 0;
    for(int i = 0; i <= N; i++){
        if(i % 3==0 || i % 5==0) continue;
        else ans += i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3652
N,M,S=map(int,input().split())
from heapq import heappop,heappush 

inf = float('inf')
cost=[[] for _ in range(N)]
exc=[]


for _ in range(M):
    u,v,a,b=map(int,input().split())
    u,v=u-1,v-1
    cost[u].append((v,a,b))
    cost[v].append((u,a,b))
for _ in range(N):
    c,d=map(int,input().split())
    exc.append((c,d))

di=[inf]*2451*N
if S>2450:
    S=2450
di[S]=0
hq=[(0,S)] #時間,都市名*2451+銀貨

while hq:
    t,v=heappop(hq)
    u=v//2451 #都市名
    s=v%2451 #所持金

    for x,a,b in cost[u]:
        if s>=a:
            v_new=x*2451+s-a
            t_new=t+b
            if t_new<di[v_new]:
                di[v_new]=t_new
                heappush(hq,(t_new,v_new))
    
    c,d=exc[u]
    if s+c>2450:
        c=2450-s
    v_new=v+c
    t_new=t+d
    if t_new<di[v_new]:
        di[v_new]=t_new
        heappush(hq,(t_new,v_new))

for i in range(1,N):
    m=di[i*2451]
    for j in range(1,2451):
        m=min(m,di[i*2451+j])
    print(m)

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

#ifdef SG
	#include <debug.h>
#else
	template<typename T> struct outputer;
	struct outputable {};
	#define PRINT(...)
	#define OUTPUT(...)
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
	#define fbegin(...)
	#define fend
	#define pbegin(...)
	#define pend
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb emplace_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef int64_t ll;
typedef uint64_t ull;
typedef uint32_t ui;
typedef uint16_t us;
typedef uint8_t uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

struct Input {
	int n, m;
	
	bool read () {
		return !!(cin >> n >> m);
	}

	void init (const Input &input) {
		*this = input;
	}
};

struct Data: Input {
	ll ans;
	
	void write () {
		cout << ans << endl;
	}
};


namespace Main {
	
	struct Solution: Data {
		void rec (const ve<pll> &v) {
			if (sz(v) == 3) {
				ll mn = ll(n) * ll(m);
				ll mx = 0;
				forn (i, 3) {
					umn(mn, v[i].fs * v[i].sc);
					umx(mx, v[i].fs * v[i].sc);
				}
				umn(ans, mx - mn);
				return;
			}
			forn (i, sz(v)) {
				forn (t, 2) {				
					forn (j, -100, 100) {
						ll x = (t ? v[i].sc : v[i].fs) / (4 - sz(v)) + j;
						ve<pll> w;
						forn (k, sz(v)) {
							if (k != i) {
								w.pb(v[k]);
							}
						}
						w.pb(t ? mp(v[i].fs, x) : mp(x, v[i].sc));
						w.pb(t ? mp(v[i].fs, v[i].sc - x) : mp(v[i].fs - x, v[i].sc));
						rec(w);
					}
				}
			}
		}
		
		void solve () {
			ans = ll(n) * ll(m);
			rec(ve<pll>(1, pll(n, m)));
		}
		
		void clear () {
			*this = Solution();
		}
	};
}


Main::Solution sol;

int main () {
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);

	#ifdef SG
		freopen((problemname + ".in").c_str(), "r", stdin);
//		freopen((problemname + ".out").c_str(), "w", stdout);
		while (sol.read()) {
			sol.solve();
			sol.write();
			sol.clear();
		}
	#else
		sol.read();
		sol.solve();
		sol.write();
	#endif
	
	/*
	int t;
	cin >> t;
	forn (i, t) {
		sol.read();
		sol.solve();
		sol.write();
		sol.clear();
	}
	*/
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1001;
constexpr double PI = 3.14159265358979323846;


struct Unionfind{
    vector<int> parents;
    int n;
    Unionfind(int n):n(n),parents(n,-1){ }

    int find(int x){
        if(parents[x] < 0) return x;
        else return parents[x] = find(parents[x]);
    }

    void unite(int x,int y){
        x = find(x);
        y = find(y);

        if(x==y) return;
        if(parents[x] > parents[y]) swap(x,y);
        parents[x] += parents[y];
        parents[y] = x;
    }  

   int size(int x){
       return -parents[find(x)];
   }

   bool same(int x,int y){
       return find(x) == find(y);
   }

   vector<int> members(int x){
       int root = find(x);
       vector<int> member;
       for(int i=0;i<n;i++){
           if(find(i)==root){
               member.push_back(i);
           }
       }
      return member;
  }

  int group_cnt(){
      int c = 0;
      rep(i,n){
          if(parents[i] < 0) ++c;
      }
      return c;
  }
};

int main(){
    int v,d;
    while(cin >> v >> d){
        vector<int> fib(v+2);
        fib[0] = fib[1] = 1;
        for(int i=2;i<v+2;i++){
            fib[i] = (fib[i-1] + fib[i-2])%MOD;
        }

        Unionfind uf(v);

        for(int i=2;i<v+2;i++){
            for(int j=i+1;j<v+2;j++){
                if(abs(fib[i]-fib[j])<d) uf.unite(i-2,j-2);
            }
        }

        cout << uf.group_cnt() << endl;
    }
    return 0;
}


Measured memory_bytes: 3004
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n;

	ll min=1e18;

	cin>>n;

	vll a(n), sum(n+1);

	rep(i, n) cin>>a[i];

	sum[0]=0;

	rep(i, n){
		sum[i+1]=sum[i]+a[i];
	}
	repr(i, 1, n){
		if(llabs(sum[n]-sum[i]*2)<min) min=labs(sum[n]-sum[i]*2);
	}
	cout<<min<<endl;
}

Measured memory_bytes: 3328
h, w = gets.split.map(&:to_i)
ss = h.times.map { gets.chomp }

ans = Array.new(h) { Array.new(w, 0) }

h.times do |i|
  w.times do |j|
    if ss[i][j] == "#"
      ans[i][j] = ss[i][j]
      next
    end

    l = j - 1 < 0 ? j : j - 1
    r = j + 1 > w ? j : j + 1

    if i - 1 >= 0
      ans[i][j] += ss[i - 1][l..r].count("#")
    end

    ans[i][j] += ss[i][l..r].count("#")

    if i + 1 <= h - 1
      ans[i][j] += ss[i + 1][l..r].count("#")
    end
  end

  puts ans[i].join
end


Measured memory_bytes: 2044
from math import gcd
from functools import reduce


def facs(n):
    """試し割り法における割る数を生成する。"""
    yield 2
    for x in range(3, n, 2):
        yield x


def main():
    input()  # N
    array = [int(x) for x in input().split()]
    MAX_A = 10 ** 6 + 1
    histogram = [0] * MAX_A
    for x in array:
        histogram[x] += 1

    for divider in facs(MAX_A):
        count = sum(histogram[divider::divider])
        if count > 1:
            break
    else:
        return 'pairwise coprime'

    gcd_total = reduce(gcd, array)
    if gcd_total == 1:
        return 'setwise coprime'
    else:
        return 'not coprime'


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 133152
from datetime import datetime, timedelta

def main():
    s = input()
    d = datetime.strptime(s, '%Y/%m/%d')
    if d < datetime(2019, 4, 30) + timedelta(days=1):
        print('Heisei')
    else:
        print('TBD')

if __name__ == "__main__":
    main()

Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};


int n,m;
const int n_max=7e2+7;
set<int> g[n_max];


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

  
  cin >> n >> m;    
  UnionFind uf(n);

  rep(i,m){
    int a,b;
    cin >> a >> b;
    --a;--b;
    g[a].insert(b);
    g[b].insert(a);
    uf.unite(a,b);
  }
  vector<int> clus;
  rep(i,n){
    if(uf.find(i)==i){
      clus.pb(uf.size(i));
    }
  }
  if(clus.size()>2){
    cout << -1 << endl;
    return 0;
  }
  if(clus.size()==2){
    int sum = clus[0]*(clus[0]-1)/2 + clus[1]*(clus[1]-1)/2;
    if(sum==m){
      cout << m << endl;
    }
    else cout << -1 << endl;
    return 0;
  }
  vector<int> color(n,-1);
  vector<pair<int,int> > group;
  int pre_z,pre_o;
  pre_z=pre_o=0;
  rep(k,n){
    if(color[k]>=0) continue;
    if(g[k].size()==n-1) continue;
    color[k]=0;
    queue<int> que;
    que.push(k);
    while(!que.empty()){
      int v=que.front();que.pop();
      int c=color[v];
      rep(j,n){
	if(j==v) continue;
	if(g[v].count(j)==0){
	  if(color[v]==color[j]){
            cout << -1 << endl;
            return 0;
          }
	  if(color[j]==-1){
	    que.push(j);
	    color[j]=((1-c)%2);
	  }
	}
      }
    }
    int z,o;
    z=o=0;
    rep(i,n){
      if(color[i]==0) z++;
      else if(color[i]==1) o++;
    }
    group.pb(mp(z-pre_z,o-pre_o));
    pre_z=z;pre_o=o;
  }
  int rest=0;
  rep(i,n){
    if(g[i].size()==n-1) rest++;
  }  
  vector<bool> dp(n-rest+10, false);
  rep(i,group.size()){
    vector<bool> ndp(n-rest+10, false);
    int fi=group[i].first;
    int	sec=group[i].second;
    //    cout << "culster a b  "<< fi << " " <<sec << endl;
    if(i==0) ndp[fi]=ndp[sec]=true;
    rep(j,n-rest+10){
      if(j+fi<n-rest+10) ndp[j+fi] = (dp[j] | ndp[j+fi]);
      if(j+sec<n-rest+10) ndp[j+sec] = (dp[j] | ndp[j+sec]);
    }
    rep(j,n-rest+10){
      dp[j]=ndp[j];
    }    
  }
  int ze,on;
  ze=0;
  rep(i,n-rest+10){
    if(dp[i]){
      //      cout << i << endl;
      int mid = (n-rest)/2;
      if(abs(mid - ze) > abs(mid - i)){
	ze=i;
      }
    }
  }
  on = n-rest-ze;
  //  cout << ze << " " << on << endl;
  while(rest>0){
    if(ze>on) on++;
    else ze++;
    rest--;
  }
  int ans = on*(on-1)/2+ze*(ze-1)/2;
  cout << ans << endl;
  
  return 0;
    

}


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

using namespace std;

#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mmp make_pair
#define st first
#define nd second
#define rd third
#define ll long long
#define pii pair <int, int>
#define tri pair <pii, int>
#define itr pair <int, pii>
#define PQ priority_queue
#define all(v) (v).begin(), (v).end()
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, n) for (int (i) = (a); (i) < (int)(n); i++)
#define FORN(i, a, n) for (int (i) = (a); (i) > (int)(n); i--)
#define Rep(i, n) for (int (i) = 0; (i) <= (int)(n); i++)
#define For(i, a, n) for (int (i) = (a); (i) <= (int)(n); i++)
#define Forn(i, a, n) for (int (i) = (a); (i) >= (int)(n); i--)
#define FORD(i, n) for (int (i) = (int)(n) - 1; i>= 0; i--)
#define rep(i, n) for (int (i) = 1; (i) <= (int)(n); i++)
#define EACH(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define DEBUG(x) cout << #x << " = " << (x) << endl;
#define PR(a, n) {cout << #a << " = "; FOR(_, 1, n) cout << a[_] << ' '; puts(""); }
#define PRO(a, n) { cout << #a << " = "; REP(_, n) cout << a[_] << ' '; puts(""); }
#define pi 3.1415926535897932384626433832795028841971
//#define LOCAL

const int INF = 1 << 30;
const int N = 1005;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

inline ll read()
{
	ll x = 0; int f = 1, c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
	return x * f;
}

int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	
	printf("%d\n", (read() + 1) / 2); 
	
	return 0;
}


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

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 x,a,b;
    cin >> x >> a >> b;
    x=max(x-a,0);
    cout << x%b << endl;
}

Measured memory_bytes: 256
n = int(input())
p = [int(i) for i in input().split()]
sum = 0
for i in range(n-2):
    if ((p[i+2] < p[i+1]) & (p[i+1] < p[i])) | ((p[i] < p[i+1]) & (p[i+1] < p[i+2])):
        sum = sum+1
print(sum)

Measured memory_bytes: 3060
n,m=map(int,input().split())
if n%2==1:
    x=[f"{i+1} {n-i}" for i in range(m)]
    print(" ".join(x))
else:
    x=[f"{i+1} {n-i}" if i<m/2 else f"{i+1} {n-i-1}" for i in range(m)]
    print(" ".join(x))

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  if (a+b > c+d) {
    cout << "Left" << endl;
  }
  else if (a+b == c+d) {
    cout << "Balanced" << endl;
  }
  else {
    cout <<"Right" << endl;
  }
}


Measured memory_bytes: 3592
#include<iostream>
#include<cmath>
#include<cstdio>
#define LL long long
using namespace std;
LL p[200010];
LL cabs(LL x)
{
    if (x>0) return x;
    return -x;
}
int main()
{
    int n,i;
    LL x;
    cin>>n;
    for (i=1;i<=n;i++)
    {
        cin>>x;
        p[i]=p[i-1]+x;
    }
    LL ans=cabs(p[n]-2*p[1]);
    for (i=2;i<=n-1;i++)
        ans=min(ans,cabs(p[n]-p[i]-p[i]));
    cout<<ans<<endl;
}


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

const int mod = 1e9 + 7;
int N;
ll K;

struct matrix {
	int n;
	vector<vector<ll>> mat;
	
	matrix(int m, int p) {
		n = m;
		mat.resize(n, vector<ll> (m, 0));
		if (p == 1) {
			for (int i = 0; i < m; i++) {
				mat[i][i] = 1;
			}
		}
	}
	int order() {
		return n;
	}
	matrix multiply(const matrix& b) {
		matrix c = matrix(n, 0);
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				for (int k = 0; k < n; k++) {
					c.mat[i][j] = (c.mat[i][j] + mat[i][k] * b.mat[k][j]) % mod;
				}
			}
		}
		return c;
	}
	matrix expo(ll k) {
		matrix exp = matrix(n, 1);
		while (k > 0) {
			if (k & 1) {
				exp = exp.multiply(*this);
			}
			*this = multiply(*this);
			k = k >> 1;
		}
		return exp;
	}
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> N >> K;
	matrix g = matrix(N, 0);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> g.mat[i][j];
		}
	}
	matrix res = g.expo(K);
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			ans = (ans + res.mat[i][j]) % mod;
		}
	}
	cout << ans;
	
	return 0;
}


Measured memory_bytes: 3716
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

a,b = input().split()

ccc = ""

for i in range(n*2):
    if i % 2 == 0:
        ccc += a[i//2]
    else:
        ccc += b[i//2]
print(ccc)







Measured memory_bytes: 38256
import java.util.Scanner;



public class Main {

	private static Scanner sc;

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int N = sc.nextInt();

		int[][] map = new int[W][H];

		for (int i = 0; i < W; i++) {
			for (int j = 0; j < H; j++) {
				map[i][j] = 0;
			}
		}

		for (int i = 0; i < N; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			int a = sc.nextInt();

			switch (a) {
			// ai=1 のときは長方形の x<xi をみたす領域
			case 1:
				for (int j = 0; j < x; j++) {
					for (int k = 0; k < H; k++) {
						map[j][k] = 1;
					}
				}
				break;
			// ai=2 のときは長方形の x>xi をみたす領域
			case 2:
				for (int j = x; j < W; j++) {
					for (int k = 0; k < H; k++) {
						map[j][k] = 1;
					}
				}
				break;

			// ai=3 のときは長方形の y<yi をみたす領域
			case 3:
				for (int j = 0; j < W; j++) {
					for (int k = 0; k < y; k++) {
						map[j][k] = 1;
					}
				}
				break;

			// ai=4 のときは長方形の y>yi をみたす領域
			case 4:
				for (int j = 0; j < W; j++) {
					for (int k = y; k < H; k++) {
						map[j][k] = 1;
					}
				}

				break;

			}

		}
//		for (int i = 0; i < H; i++) {
//			for (int j = 0; j < W; j++) {
//				System.out.print(map[j][i]);
//				if (j == W - 1) {
//					System.out.print("\n");
//				}
//			}
//		}

		int ans = 0;

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (map[j][i] == 0) {
					ans++;
				}
			}
		}
		
		System.out.println(ans);
	}

}


Measured memory_bytes: 12168
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<stdio.h>
using namespace std;
typedef long long ll;
ll mod = 998244353;




int main(){
	string S;
	cin>>S;
	string A;
	for(int i = S.size() - 1 ; i >= 0; i--){
		A.insert(A.begin(), S[i]);
		if(A == "eraser"){
			A.clear();
		}if(A == "dreamer"){
			A.clear();
		}if(A == "dream"){
			A.clear();
		}if(A == "erase"){
			A.clear();
		}
	}
	if(!A.empty()){
		cout<<"NO"<<endl;
	}else{
		cout<<"YES"<<endl;
	}
	return 0;
}


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

int main() {
    int N; cin >> N;
    string s; cin >> s;
    int Q; cin >> Q;
    vector<multiset<int> > A(30);
    rep(i, N){
        int x = s[i] - 'a';
        A[x].insert(i);
    }
    rep(k, Q){
        int w; cin >> w;
        if(w == 1){
            int i; cin >> i;
            i--;
            char c; cin >> c;
            int x = c - 'a';
            char now = s[i];
            int xnow = now - 'a';
            A[xnow].erase(i);
            A[x].insert(i);
            s[i] = c;
        } else {
            int l, r; cin >> l >> r;
            l--; r--;
            int ans = 0;
            rep(i, 30){
                if(!A[i].empty()){
                    auto itr = A[i].lower_bound(l);
                    if(itr == A[i].end())continue;
                    int x = *itr;
                    if(x <= r)ans++;
                }
            }
            cout << ans << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 27244
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int aa = 0;
		int bb = 0;
		for( int i=10; i<=1009; i++ ){
			if( i/10==B ){
				bb = i;
				break;
			}
		}
		for( int i=bb/10*10; i<=bb/10*10+9; i++  ){
			if( i*8/100==A ){
				System.out.println(i);
				break;
			}
			if( i==bb/10*10+9 ){
				System.out.println(-1);
			}
		}
	}
}


Measured memory_bytes: 23380
#include<bits/stdc++.h>
#define int long long
#define p pair<int, int>
#define endl '\n'

using namespace std;

vector<vector<int>> sequences(int n, int m){
    if (n == 1){
        vector<vector<int>> now;
        for (int q = 1; q <= m; q++){
            now.push_back({q});
        }
        return now;
    }
    vector<vector<int>> now = sequences(n-1, m), now1;
    for (auto &q: now){
        for (int q1 = q.back(); q1 <= m; q1++){
            now1.push_back(q);
            now1.back().push_back(q1);
        }
    }
    return now1;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, m, k;
    cin >> n >> m >> k;
    vector<pair<p, p>> a(k);
    for (int q = 0; q < k; q++){
        cin >> a[q].first.first >> a[q].first.second >> a[q].second.first >> a[q].second.second;
        a[q].first.first--, a[q].first.second--;
    }
    vector<vector<int>> ans = sequences(n, m);
    int answer = 0;
    for (auto &q: ans){
        int sum1 = 0;
        for (auto &q1: a){
            if (q[q1.first.second]-q[q1.first.first] == q1.second.first){
                sum1 += q1.second.second;
            }
        }
        answer = max(answer, sum1);
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 27888
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,k,h[234567],a=0;
    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>h[i];
    sort(h,h+n);
    for(int i=0;i<(n-k);i++){
        
        a+=h[i];
    }cout<<a<<endl;
}


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

int main(){
    string S[3];
    vector<int> index(3,0);
    for(int i = 0; i < 3; i++) cin >> S[i];
    int who = 0;
    while(1){
        if(index[who] == S[who].size()){
            cout << (char)('A' + who) << endl;
            return 0;
        }

        index[who]++;
        who = S[who][index[who] - 1] - 'a';
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    string Sa,Sb,Sc;
    cin >> Sa >> Sb >> Sc;
    char q='a';
    char ans;
    while(true){
        if(q=='a'){
            if(Sa.size()==0) {
                ans='A';
                break;
            }
            q=Sa.at(0);
            Sa=Sa.substr(1);
            
        }
        if(q=='b'){
            if(Sb.size()==0) {
                ans='B';
                break;
            }
            q=Sb.at(0);
            Sb=Sb.substr(1);
            
        }
        if(q=='c'){
            if(Sc.size()==0) {
                ans='C';
                break;
            }
            q=Sc.at(0);
            Sc=Sc.substr(1);
            
        }
    }
    cout << ans << endl;



}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i, n-1) {
    cin >> a[i] >> b[i];
    --a[i], --b[i];
  }
  priority_queue<int> pque;
  rep(i, n) {
    int c;
    cin >> c;
    pque.push(c);
  }
  vector<vector<int>> to(n);
  rep(i, n) {
    to[a[i]].push_back(b[i]);
    to[b[i]].push_back(a[i]);
  }
  vector<int> node(n);
  node[0] = pque.top();
  pque.pop();
  queue<int> que;
  que.push(0);
  while (!que.empty()) {
    int now = que.front();
    que.pop();
    for (auto next : to[now]) {
      if (!node[next]) {
        node[next] = pque.top();
        pque.pop();
        que.push(next);
      }
    }
  }
  int ans = 0;
  rep(i, n-1)
    ans += min(node[a[i]], node[b[i]]);
  cout << ans << endl;
  rep(i, n)
    printf("%d%c", node[i], i==n-1?'\n':' ');
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  bool flag = false;
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if (i*j == n) {
        flag = true;
      }
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int P, Q, R;
	cin >> P >> Q >> R;
	
	int answer = 0;
	// A B C
	answer = P + Q;
	// A C B
	answer = min(R + Q, answer);
	// B A C
	answer = min(P + R, answer);
	
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 256
from collections import deque

def read_input():
    n, m = map(int, input().split())

    edges = []
    for i in range(m):
        a, b = map(int, input().split())
        edges.append((a, b))

    return n, m, edges


def check_graph(n, edges):
    nodes = list(range(1, n + 1))
    nodes.sort()

    trans = {i: [] for i in nodes}
    for e in edges:
        trans[e[0]].append(e[1])
        trans[e[1]].append(e[0])

    node_q = deque()
    node_q.appendleft(nodes[0])
    searched = []
    while len(node_q) > 0:
        curr = node_q.popleft()
        searched.append(curr)
        target = trans[curr]

        for t in target:
            if t not in searched:
                node_q.appendleft(t)

        searched = list(set(searched))
        searched.sort()

    if searched == nodes:
        return True
    else:
        return False


def submit():
    n, m, edges = read_input()

    count = 0
    for t in range(m):
        test = [e for i, e in enumerate(edges) if i != t]
        if check_graph(n, test):
            count += 1

    print(m - count)

if __name__ == '__main__':
    submit()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e9

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

string s;
int ans;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> s;
	int n = s.size();
	for(int i = 1; i < n; i++){
		if(s[i]!=s[i-1]){
			ans++;
		}
	}
	cout << ans;
	return 0;
}


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

int main(){
  long long A, B, K;
  cin >> A >> B >> K;
  if(A >= K) cout << A-K << " " << B << endl;
  else if(A+B >= K) cout << 0 << " " << A+B - K << endl;
  else cout << 0 << " " << 0 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
    	Scanner input = new Scanner(System.in);
    	int[] a = new int[4];
    	int[] b = new int[4];
    	while(input.hasNext()){
        	boolean[] used = new boolean[4];
			for(int i = 0 ; i < 4 ; i++){
				a[i] = input.nextInt();
			}
			for(int i = 0 ; i < 4 ; i++){
				b[i] = input.nextInt();
			}
			int hit = 0;
			int blow = 0;
			for(int i = 0 ; i < 4 ; i++){
				if(a[i] == b[i])hit++;
			}
			
			for(int i = 0 ; i < 4 ; i++){
				for(int j = 0 ; j < 4 ; j++){
					if(!used[j] && a[i] == b[j]){
						used[j] = true;
						blow++;
						break;
					}
				}
			}
			blow -= hit;
			System.out.println(hit+" "+blow);
    	}
    }
}

Measured memory_bytes: 18304
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	int n,k,x,y;
	cin >> n>>k>>x>>y;
	if(n<=k){cout<<n*x<<endl;}
	else{
		cout<<k*x+(n-k)*y<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin>>s;
    if(s[0]==s[2])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int,int> P;
 
int main(){
  int n; cin >> n;
  vector<int> vec(n);
  rep(i, n) cin >> vec.at(i);
  if (n % 2 != 0) {
    cout << 0 << endl;
    return 0;
  }
  sort(all(vec));
  cout << vec.at(n/2) - vec.at(n/2-1) << endl;
}


Measured memory_bytes: 768
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
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 chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	int pn = 0;
	if (*ci == '-') {
		pn = 1;
		ci++;
	}
	//ll tmp = *(ll*)ci;
	//int dig = ((tmp & ma0) ^ ma0) ? 68 - __builtin_ctzll((tmp & ma0) ^ ma0) : 0;
	//tmp = tmp << dig & ma1;
	//tmp = tmp * 10 + (tmp >> 8) & ma2;
	//tmp = tmp * 100 + (tmp >> 16) & ma3;
	//tmp = tmp * 10000 + (tmp >> 32) & ma4;
	//ci += (64 - dig >> 3);
	int tmp = 0;
	while ((ct = *ci++) >= '0') tmp = tmp * 10 + ct - '0';
	if (pn) tmp = -tmp;
	return tmp;
}

ll A[200001];
void pakuri_sort(int N, ll A[]) {
	const int b = 8;
	ll tmp[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int N = getint();
	rep1(i, N) {
		A[i] = getint() + A[i - 1];
	}

	pakuri_sort(N + 1, A);

	ll kotae = 0;
	ll mae = 1e18;
	int kazu = 0;
	rep(i, N + 1) {
		if (mae != A[i]) {
			mae = A[i];
			kazu = 0;
		}
		kotae += kazu++;
	}

	printf("%lld\n", kotae);

	Would you please return 0;
}

Measured memory_bytes: 6312
import math
a,b,c,x,y=map(int,input().split())
cost=float('inf')
if 2*c>=a+b:
    cost=a*x+b*y
else:
    least=min(x*2,y*2)
    most=max(x*2,y*2)
    r=least
    while r<=most:
        p=max(0,math.ceil(x-r/2))
        q=max(0,math.ceil(y-r/2))
        tmp=a*p+b*q+c*r
        cost=min(cost,tmp)
        r+=1
print(cost)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] t = new int[n];
        int[] x = new int[n];
        int[] y = new int[n];
        for (int i = 0; i < n; i++) {
            t[i] = Integer.parseInt(sc.next());
            x[i] = Integer.parseInt(sc.next());
            y[i] = Integer.parseInt(sc.next());
        }

        // 主処理
        boolean judge = true;
        for (int i = 0; i < n && judge; i++) {

            int pointSum = Math.abs(x[i]) + Math.abs(y[i]);

            if (t[i] < pointSum) {
                judge = false;

            } else if (pointSum < t[i]) {

                if (t[i] % 2 == 0 && pointSum % 2 == 1) {
                    judge = false;

                } else if (t[i] % 2 == 1 && pointSum % 2 == 0) {
                    judge = false;
                }
            }
        }

        String result = judge ? "Yes" : "No";

        // 出力
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 62512
/**
 *      purpose : 「みんなのプロコン 2019」A
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, k; cin >> n >> k;
    if (n & 1){
        if (k <= n / 2 + 1) print("YES");
        else print("NO");
    }
    else {
        if (k <= n / 2) print("YES");
        else print("NO");
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int INF = 2e6;
ll MOD = 1e9 + 7;
 
int main(){
    int n,m; cin >> n >> m;
    vector<vector<int>> g(n);
    rep(i,m){
        int a,b; cin >> a >> b;
        a--; b--;
        g[a].pb(b);
        g[b].pb(a);
    }

    queue<int> que;
    que.push(0);
    vector<bool> vis(n,false);
    vis[0] = true;
    vector<int> dist(n);
    vector<int> ans(n);
    
    while(que.size()){
        int p = que.front();
        que.pop();
        for(auto i : g[p]){
            if(!vis[i]){
                vis[i] = true;
                dist[i] = dist[p] + 1;
                que.push(i);
                ans[i] = p + 1;
            }
        }
    }
    for(int i = 1;i < n;i++){
        if(dist[i] == 0){
            cout << "No" << endl;
            return 0;       
        }
    }
    cout << "Yes" << endl;
    for(int i = 1;i < n;i++){
        cout << ans[i] << endl;
    }
    
}

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

using namespace std;

typedef long long llint;

const int MAXN = 100005;

int n, sol;
int a[MAXN];

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++) {
        sol += a[a[i]] == i;
    }
    cout << sol / 2;
    return 0;
}


Measured memory_bytes: 4008
N, Q = map(int, input().split())
es = [[] for i in range(N)]
value = [0]*N

for i in range(N-1):
  a, b = map(int, input().split())
  es[a-1] += [b-1]
  es[b-1] += [a-1]

for i in range(Q):
  p, x = map(int, input().split())
  value[p-1] += x

stuck = [0]
log = [1]*N
log[0] = 0

while stuck:
  e = stuck.pop()
  for f in es[e]:
    if log[f]:
      log[f] = 0
      value[f] += value[e]
      stuck += [f]

ans = [str(v) for v in value]
print(' '.join(ans))

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

const int MAXN=100+10;
char s[MAXN];

int main( )
{
	scanf( "%s", s+1 );
	bool b1=0, b2=0;
	for ( int i=1; s[i]!=0; i++ )
	{
		if ( s[i]=='C' )
			b1=1;
		if ( b1 && s[i]=='F' )
			b2=1;
	}
	printf( "%s\n", b2?"Yes":"No" );
	return 0;
}


Measured memory_bytes: 128