akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#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 dfs(int n,vector<vector<int>> &v,vector<bool> &visited,vector<int> &count)
{
    visited[n] = true;
    count[n] = 0;
    int maxi = 0;
    forn(i,0,v[n].sze)
    {
        if(!visited[v[n][i]])
        {
            maxi = max(maxi,1+dfs(v[n][i],v,visited,count));
        }
        else
        {
            maxi = max(maxi,1+count[v[n][i]]);
        }
    }

    count[n] += maxi;
    return count[n];
}


int main()
{
    fast


        
    int n,m;
    cin>>n>>m;

    vector<vector<int>> v(n);

    int a,b;
    forn(i,0,m)
    {
        cin>>a>>b;
        v[a-1].pb(b-1);
    }

    vector<bool> visited(n,false);
    vector<int> count(n,-1);
    forn(i,0,n)
    {
        if(!visited[i])
        {
            dfs(i,v,visited,count);
        }
    }


    int ans = 0;

    forn(i,0,n)
    {
        // cout<<count[i]<<" ";
        ans = max(ans,count[i]);
    }

    // cout<<endl;
    cout<<ans;



    return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define int long long
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
        int N; cin>>N;
        vint a(N),b(N);
        REP(i,N) cin>>a[i]>>b[i];

        vint dp(N);
        dp[0]=1;
        REP(i,N-1){
                int A=(a[i]*dp[i]+a[i+1]-1)/a[i+1];
                int B=(b[i]*dp[i]+b[i+1]-1)/b[i+1];
                dp[i+1]=max(A,B);
        }
        cout<<(a[N-1]+b[N-1])*dp[N-1]<<endl;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();

        int count = 0, oCount = 0;
        foreach (var c in s)
        {
            if (c == 'o') oCount++;
            count++;
        }

        if (count <= 7) Console.WriteLine("YES");
        else if (15 - count >= 8 - oCount) Console.WriteLine("YES");
        else Console.WriteLine("NO");
    }
}

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

// global variables
#define debug(x) cout << #x << ": " << x << endl
typedef long long ll;
const int M = 1e9 + 7;
const int INF = 1e9;

// typedef
typedef pair<ll, int> P;
// sort by P.first (asd)
bool comPair(const P &firstElof, const P &secondElof) {
    return firstElof.first < secondElof.first;
}

// moving 4-direction
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int n, m;
    string s;
    vector<int> ans;
    vector<string> blue, red;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s;
        blue.push_back(s);
    }
    cin >> m;
    for (int i = 0; i < m; i++) {
        cin >> s;
        red.push_back(s);
    }
    for (int i = 0; i < n; i++) {
        int res = 0;
        for (int j = i; j < n; j++) {
            if (blue[i] == blue[j]) res++;
        }
        for (int k = 0; k < m; k++) {
            if (blue[i] == red[k]) res--;
        }
        ans.push_back(res);
    }
    sort(ans.begin(), ans.end(), greater<int>());
    cout << max(0, ans[0]) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	long int x, y; cin >> x >> y;
	long int n = x;
	int count = 0;
	for(int i=1;i<=100;i++){
		while(n<=y){
			n = n*2;
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
    //入力を受け取る
    string S;
    cin >> S;

  if (S == "SUN") {
    cout << 7 << endl;
  }
  else if (S == "MON") {
    cout << 6 << endl;
  }
  else if (S == "TUE") {
    cout << 5 << endl;
  }
  else if (S == "WED") {
    cout << 4 << endl;
  }
  else if (S == "THU") {
    cout << 3 << endl;
  }
  else if (S == "FRI") {
    cout << 2 << endl;
  }
  else if (S == "SAT") {
    cout << 1 << endl;
  }
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <math.h>
#include <algorithm>

const long long MOD = 1000000007;

using namespace std;




int main(void) {

    long long i, j;
    long long n, m;
    long long sum = 0;
    long long maisu = 0;
    long long temp, temp_b;
    long long min, max;
    string s1, s2;
    long long a, b, c, k;
    long long mod = 2019;
    vector<long long> t;
    vector<long long> dp;

    cin >> a >> b >> c >> k;

    // a
    if (k - a > 0) {
        sum += a;
        k -= a;
    }else {
        sum += k;
        cout << sum << endl;
        return 0;
    }

    // b
    if (k - b > 0) {
        k -= b;
    }else {
        cout << sum << endl;
        return 0;
    }

    // c
    sum -= k;
    cout << sum << endl;
    

    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

struct Data{
	char com;
	int idx;
	int len;
};

int main(){
	int n;
	while(cin >> n,n){
		vector<Data> d(n);
		vector<int> r;

		rep(i,n){
			char c;
			cin >> c;

			int a, b = -1;
			if(c == 'W'){
				cin >> a >> b;
			}else{
				cin >> a;
			}

			d[i] = Data{c,a,b};
			if(c == 'R') r.emplace_back(i);
		}

		rep(i,r.size()){
			int cnt = 0;
			int p = -1;
			int idx = d[r[i]].idx + 1;
			map<int,int> ma;
			rep(j,r[i]){
				//cout << cnt << ' ' << p << endl;
				if(d[j].com == 'W'){
					int add = min(idx - cnt, d[j].len);
					ma[d[j].idx] = add;

					if(p == -1 and cnt + add == idx){
						p = d[j].idx;
					}

					cnt += add;
				}else if(d[j].com == 'D'){
					if(p == d[j].idx) p = -1;
					cnt -= ma[d[j].idx];
				}
			}
			cout << p << endl;
		}
		cout << endl;
	}
}



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

int main(){
      int S[32]= {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
      int K; cin >> K;
      cout << S[K-1] << endl;
}


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

int main() {
int N,A[110] ;
    cin >> N ;
  for (int i=0; i<N; i++){
   cin >> A[i];
  }
   
  string ans= "APPROVED" ;
  
  for (int i=0;i<N;i++){
   if (A[i]%2==0&&A[i]%3!=0&&A[i]%5!=0 )
     ans= "DENIED";
  }
  
    cout << ans << endl;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
probabilities = [[] for _ in range(N)]

def GetCounts(number):
    cnt = 0
    quotient = K/number
    while(quotient>1):
        quotient /= 2
        cnt += 1
    return cnt

for i in range(N):
    probabilities[i] = (1/N)* pow(0.5,GetCounts(i+1))
print(sum(probabilities))

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

int main(){
  long a[100000] = {};
  long absmin = -1; 
  long n = 0;
  long i = 0;
  long long abstotal=0;
  long minuscnt=0;
  scanf("%ld",&n);
  for(i=0;i<n;i++){
    scanf("%ld",&a[i]);
    if(a[i]<0){
      minuscnt++;
    }
    if(absmin == -1 || absmin > labs(a[i])){
      absmin = labs(a[i]);
    }
    abstotal += labs(a[i]);
  }
  if(minuscnt % 2 == 0){
    printf("%lld",abstotal);
  }else{
    printf("%lld",abstotal-2*absmin);
  }
  return 0;
}
  
  
    

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

int main()
{
	int d, n;
	ll num;
	cin >> d >> n;

	switch (d) {
		case 0:
			num = 1;
			break;
		case 1:
			num = 100;
			break;
		case 2:
			num = 10000;
			break;
	}
	if (n == 0)
		cout << num;
	else if (n == 100)
		cout << (n + 1) * num;
	else
		cout << num * n;
}

Measured memory_bytes: 256
#import re
import sys
#input = sys.stdin.readline
#import heapq
#import bisect
#from collections import deque
#import math

def main():
    s, t = input().split()
    a, b = map(int,input().split())
    u = input()
    if s == u:
        print(a-1, b)
    else:
        print(a, b-1)


    
if __name__ == '__main__':
    main()


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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<double, double> pd;
typedef pair<int, int> pi; typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;  typedef pair<ll, pi> plp;
typedef pair<int, pi> pip; typedef tuple<int, int, int> ti;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 55;

char S[MAX_N];
int main() {
	scanf("%s", S);
	int N = strlen(S);
	for(int i=0; i<N-8; i++) printf("%c", S[i]); puts("");
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    string a[] = {"KIHBR","KIHBRA","KIHBAR","KIHBARA","KIHABR","KIHABRA","KIHABAR","KIHABARA","AKIHBR","AKIHBRA","AKIHBAR","AKIHBARA","AKIHABR","AKIHABRA","AKIHABAR","AKIHABARA"};
    string s;
    cin >> s;
    for(int i = 0;i < 16;i++)
    {
        if(s == a[i])
        {
            cout << "YES\n";
            return 0;
        }
    }
    cout << "NO\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
using namespace std;

int main()
{
    int N;
    int ans;
    cin >> N;
    if (N > 1000)
    {
        if (N % 1000 == 0)
        {
            cout << N %1000 <<endl;
        }
        else
        {

            ans = 1000 * (floor(N / 1000) + 1) - N;
            cout << ans << endl;
        }
    }
    else
        cout << 1000 - N << endl;
    return 0;
}

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

vector<pair<int, int>> factorize(int n){
    vector<pair<int, int>> res;
    for(int i=2; i* i < n; i++){
        if(n % i != 0)continue;
        pair<int, int> z = {i, 0};
        while(n % i == 0){
            z.second++;
            n /= i;
        }
        res.push_back(z);
    }
    if(n != 1)res.push_back({n, 1});
    return res;
}

int num_factor(int n){
    vector<pair<int, int>> res = factorize(n);
    int ans = 1;
    for(auto it: res){
        ans *= (it.second + 1);
    }
    return ans;
}

int main(){
    int n; cin >> n;
    int ans = 0;
    for(int i=1; i<=n; i++){
        //ans += /num_factor(i);
        if (num_factor(i) == 8 && i % 2 != 0){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;

int main(){
    int N, R;
    cin >> N >> R;
    if (N >= 10) {
        cout << R << endl;
    } else {
        cout << 100 * (10 - N) + R<< endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

int ans[100005] = {0,};

void f(vector<set<int>> &out,vector<set<int>> &in,vector<int> &deg,int point){
    queue<int> q;
    q.push(point);
    while(!q.empty()){
        int p = q.front();
        q.pop();

        for(auto itr = out[p].begin(); itr != out[p].end();++itr){
            
            if(deg[*itr] == 1){
                ans[(*itr)-1] = p;
                q.push(*itr);
            }else{
                deg[*itr]--;
                in[*itr].erase(p);
            }
        }
    }
}


int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n-1+m), b(n-1+m);
    vector<set<int>> in(n+1), out(n+1);
    for(int i = 0; i < n-1+m; i++){
        cin >> a[i] >> b[i];
        out[a[i]].insert(b[i]);
        in[b[i]].insert(a[i]);
    }
    vector<int> deg(n+1,0);
    int p;
    for(int i = 1; i <= n; i++){
        deg[i] = in[i].size();
        if(deg[i]==0){p = i;}
    }
    f(out,in,deg,p);
    for(int i = 0; i < n; i++){
        cout << ans[i] << endl;
    }

}


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

//typedef long long ll;

int main(){
    vector<vector<int>> c(3,vector<int>(3));

    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>c.at(i).at(j);
        }
    }
    int memory=0;

    vector<int> H1 (3);
    for(int i=0;i<3;i++){
        H1.at(i)=c.at(0).at(i)-c.at(1).at(i);
    }
    for(int i=0;i<2;i++){
        if(H1.at(i)!=H1.at(i+1)){
            memory=1;
            break;
        }
    }
    if(memory==0){
        vector<int> H2 (3);
        for(int i=0;i<3;i++){
            H2.at(i)=c.at(1).at(i)-c.at(2).at(i);
        }
        for(int i=0;i<2;i++){
            if(H2.at(i)!=H2.at(i+1)){
                memory=1;
                break;
            }
        }
    }
    if(memory==0){
        vector<int> V1 (3);
        for(int i=0;i<3;i++){
            V1.at(i)=c.at(i).at(0)-c.at(i).at(1);
        }
        for(int i=0;i<2;i++){
            if(V1.at(i)!=V1.at(i+1)){
                memory=1;
                break;
            }
        }
    }
    if(memory==0){
        vector<int> V2 (3);
        for(int i=0;i<3;i++){
            V2.at(i)=c.at(i).at(1)-c.at(i).at(2);
        }
        for(int i=0;i<2;i++){
            if(V2.at(i)!=V2.at(i+1)){
                memory=1;
                break;
            }
        }
    }

    if(memory==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

constexpr int INF = (1 << 29);

int main()
{
    int N, M;
    cin >> N >> M;
    string d;
    vector<int> sumL(N + 2), sumR(N + 2);
    for (int i = 0; i < M; i++) {
        cin >> d;
        for (int i = 1; i <= N; i++) {
            sumL[i] += (d[i - 1] == 'E');
        }

        for (int i = N; i >= 1; i--) {
            sumR[i - 1] += (d[i - 1] == 'W');
        }        
    }

    for (int i = 1; i <= N; i++) {
        sumL[i] += sumL[i - 1];
    }

    for (int i = N; i >= 1; i--) {
        sumR[i - 1] += sumR[i];
    }
    
    int mini = INF, num = -1;
    for (int i = 0; i <= N; i++) {
        if (sumL[i] + sumR[i] < mini) {
            mini = sumL[i] + sumR[i];
            num = i;
        }
    }
    cout << num << " " << num + 1 << endl;
    return 0;
}

Measured memory_bytes: 3324
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector
//#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int a,b,c;
	cin>>a>>b>>c;
	int x=max(a,b);
	x=max(x,c);
	int s=0;
	s+=3*x-a-b-c;
	if(s%2==0){
		cout<<s/2<<endl;
	}else{
		cout<<s/2+2<<endl;
	}



return 0;
}





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

int p[18][100000], v[100000], d[100000];
vector<int>E[100000];
int lca(int u, int v) {
	if (d[u] > d[v])swap(u, v);
	rep(i, 18) {
		if ((d[v] - d[u]) >> i & 1)v = p[i][v];
	}
	if (u == v)return u;
	for (int i = 17; i >= 0; i--) {
		if (p[i][u] != p[i][v]) {
			u = p[i][u]; v = p[i][v];
		}
	}
	return p[0][u];
}
int main() {
	int n; scanf("%d", &n);
	p[0][0] = -1;
	for (int i = 1; i < n; i++) {
		scanf("%d", &p[0][i]); p[0][i]--;
		E[p[0][i]].push_back(i);
	}
	int c = 0;
	queue<int>que;
	memset(d, -1, sizeof(d));
	d[0] = 0; que.push(0);
	while (!que.empty()) {
		int p = que.front(); que.pop();
		v[c++] = p;
		for (int v : E[p]) {
			if (d[v] == -1) {
				d[v] = d[p] + 1; que.push(v);
			}
		}
	}
	for (int i = 1; i < 18; i++) {
		rep(j, n) {
			if (p[i - 1][j] == -1)p[i][j] = -1;
			else p[i][j] = p[i - 1][p[i - 1][j]];
		}
	}
	long long sum = 0;
	rep(i, n - 1) {
		int u = lca(v[i], v[i + 1]);
		sum += d[v[i]] - d[u] + d[v[i + 1]] - d[u];
	}
	printf("%lld\n", sum);
}

Measured memory_bytes: 16548
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.insert(0,"X")
B.insert(0,"X")
C.insert(0,"X")
stf_c = 0
j = 100
for i in range(1,N+1):
	if A[i] == j+1:
		stf_c += (B[A[i]]+C[j])
		j = A[i]
	else:
		stf_c += B[A[i]]
		j = A[i]
print(stf_c)

Measured memory_bytes: 3064
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int A[3];
	int K;
	rep(i, 0, 3)
	{
		cin >> A[i];
	}
	cin >> K;
	sort(A, A + 3);
	cout << A[0] + A[1] + A[2] * (int)pow(2, K) << endl;

	return 0;
}

Measured memory_bytes: 256
import Data.List
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import qualified Data.IntMap as IM
import Data.Ord

type Map = IM.IntMap Int

readIntsLine :: IO [Int]
readIntsLine = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

countUp :: Int -> Int -> Map -> Map
countUp = IM.insertWithKey f
  where f _ new old = old + new

solve :: [(Int, Int)] -> Int
solve [] = 0
solve [(l1, c1)] = if c1 >= 4 then l1 ^ 2 else 0
solve [(l1, c1), (l2, c2)] = if c1 >= 4 then l1 ^ 2 else l1 * l2

main :: IO ()
main = do
  getLine
  as <- readIntsLine
  let res = take 2 . filter ((>=2) . snd) . sortOn (Down . fst) . IM.toList $ foldl (\m a -> countUp a 1 m) IM.empty as
  print $ solve res

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

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

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

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long X, Y;
    scan(X, Y);
    long n = X;
    long cnt;
    while (n <= Y)
    {
        cnt++;
        n <<= 1;
    }
    writeln(cnt);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	int n, h, w;
	cin >> n >> h >> w;
	cout << (n - h + 1) * (n - w + 1) << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, int b, int _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }




void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
    
    int T;
    // cin >> T;
    T = 1;
    
    while (T--) {
        solve();
    }
}


// https://atcoder.jp/contests/dp/submissions/3944283
int n;
ll c;
vector<ll> a, dp;

// Convex Hull Trick
ll A(int j) { return -2 * a[j]; }
ll B(int j) { return dp[j] + a[j] * a[j]; }
ll C(int i) { return c + a[i] * a[i]; }
ll f(int j, int x) { return A(j) * x + B(j); }
using pll = pair<ll, ll>;
struct CHT {
    deque<int> d;
    ll get(int x) {
        while (sz(d) >= 2) {
            ll a = f(d[0], x);
            ll b = f(d[1], x);
            if (a <= b) break;
            d.pop_front();
        }
        return f(d[0], x);
    }
    void add(pll x, int x2) {
        while (sz(d) >= 2) {
            pll y = pll(A(d[sz(d) - 1]), B(d[sz(d) - 1]));
            pll z = pll(A(d[sz(d) - 2]), B(d[sz(d) - 2]));
            
            ll a1 = y.F, b1 = y.S, a2 = z.F, b2 = z.S, a3 = x.F, b3 = x.S;
            if ((b3 - b1) * (a2 - a1) >= (a1 - a3) * (b1 - b2)) break;
            d.pop_back();
        }
        d.push_back(x2);
    }
};



void solve() {
    cin >> n >> c;
    
    a.resize(n);
    cin >> a;
    dp.resize(n);
    dp[0] = 0;
    
    CHT d;
    d.add(pll(A(0), B(0)), 0);
    
    rep3(i, 1, n) {
        dp[i] = d.get(a[i]) + C(i);
        d.add(pll(A(i), B(i)), i);
    }
    cout << dp[n - 1] << endl;
}


Measured memory_bytes: 3968
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <set>
#define INF 1000000001
#define N 5003
using namespace std;
typedef pair<int,int> P;
int Bynary_Search(int,int,int,int);
int n,m,xsz,ysz,d[N][N],ans;
int pxy[2][N],x[N],y[N],x1,y1,x2,y2;
set<int> sx,sy;
P in[N];

int main(){
  cin>>n>>m;
  for(int i=0;i<n;i++) cin>>x[i]>>y[i],sx.insert(x[i]),sy.insert(y[i]);
  int k=1;
  for(set<int>::iterator it=sx.begin();it!=sx.end();it++,k++) pxy[0][k]=*it;
  k=1;
  for(set<int>::iterator it=sy.begin();it!=sy.end();it++,k++) pxy[1][k]=*it;
  xsz=sx.size();
  ysz=sy.size();
  pxy[0][0]=pxy[1][0]=-INF;
  pxy[0][xsz+1]=pxy[1][ysz+1]=INF;
  for(int i=0;i<n;i++){
    int rx=Bynary_Search(x[i],0,xsz,0);
    int ry=Bynary_Search(y[i],1,ysz,0);
    d[ry][rx]++;
  }
  for(int i=0;i<ysz+1;i++)
    for(int j=1;j<xsz+1;j++) d[i][j]=d[i][j]+d[i][j-1];
  for(int i=0;i<xsz+1;i++)
    for(int j=1;j<ysz+1;j++) d[j][i]=d[j][i]+d[j-1][i];
  for(int i=0;i<m;i++){
    scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
    int xb=Bynary_Search(x1,0,xsz,0),yb=Bynary_Search(y1,1,ysz,0);
    int xe=Bynary_Search(x2,0,xsz,1),ye=Bynary_Search(y2,1,ysz,1);
    ans=d[ye][xe];
    if(yb) ans-=d[yb-1][xe];
    if(xb) ans-=d[ye][xb-1];
    if(xb&&yb) ans+=d[yb-1][xb-1];
    if(xb>xe||yb>ye) ans=0;
    printf("%d\n",ans);
  }
  return 0;
}

int Bynary_Search(int s,int index,int sz,int c){
  int l=0,r=sz+2,m;
  while(l+1<r){
    m=(l+r)/2;
    if(s>=pxy[index][m]) l=m;
    else r=m;
  }
  if(c) return l;
  if(s==pxy[index][l]) return l;
  else return l+1;
}

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

int main() {
	
	string s;
	cin >> s;
	deque <char> a;
	bool parity=0;
	int q;
	cin >> q;
	for(auto i : s) a.push_front(i);
	for(int i=0; i<q; i++){
		int t;
		cin >> t;
		if(t==1) parity ^=1;
		if(t==2){
			int f;
			char c;
			cin >> f >> c;
			if(f==1 ^ parity) a.push_back(c);
			else a.push_front(c);
		}
	}
	if(parity) for(auto i=a.begin(); i!=a.end(); i++) cout << *i;
	else for(auto i=a.rbegin(); i!=a.rend(); i++) cout << *i;
	cout << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#define ll long long
using namespace std;

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

	string s;
	if (n != 0) {
		while (n != 1) {
			if (n % (-2) == 0) {
				s = "0" + s;
				n = n / (-2);
			}
			else {
				n = (n - 1) / (-2);
				s = "1" + s;
			}
		}
		s = "1" + s;
	}else{
		s = "0";
	}

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
from collections import deque

n, k = list(map(int, input().split()))
hl = sorted([int(input()) for _ in range(n)])

hq = deque() 
dif = float("inf")
for i in range(n) :
    hmax = hl[i]
    hq.append(hmax)
    if len(hq) == k :
        hmin = hq.popleft()
        dif = min(dif, hmax - hmin)

print(dif)

Measured memory_bytes: 8612
#include <iostream>
#include <list>

using namespace std;

string peticion;
list<int> lista;
int N,dato;

int main(){
string peticion;
list<int> lista;
int N,dato;

    cin >> N;
    for(int i = 0; i < N; i++)
    {
        cin >> peticion;
        if(peticion == "insert") //Inserta un elemento a la lista, hasta el frente.
        {
            cin >> dato;
            lista.push_front(dato);
        }
        else if(peticion == "delete") //Elimina un elemento de la lista.
        {
            cin >> dato;
            for(list<int>::iterator it = lista.begin(); it != lista.end(); it++) //Un for doble para ir recorriendo la lista doblemente ligada.
                if(*it == dato) //Si el el iterador es igual al valor ingresado este será eliminado.
                {
                    lista.erase(it);
                    break;
                }
        }
        else if(peticion == "deleteFirst") //ELiminar el primer elemento de la lista.
            lista.pop_front();
        else if(peticion == "deleteLast")   //Eliminar el ultimo elemento de la lista.
            lista.pop_back();
    }
    int i = 0;
    for(list<int>::iterator it = lista.begin(); it != lista.end(); it++) //Recorrido de la lista para imprimir los valores.
    {
        if(i++)
            cout<<" ";
        cout<<*it;
    }
    puts("");
    return 0;
}



Measured memory_bytes: 34412
import Control.Monad
import Control.Applicative

solve :: [String] -> [String]
solve [] = []
solve (line:lines) =
    let [a,op,b] = words line in
    case (go (read a) op (read b)) of
    Just x -> show x : solve lines
    Nothing -> []
    where
    go :: Int -> String -> Int -> Maybe Int
    go a "+" b = Just $ a + b
    go a "-" b = Just $ a - b
    go a "*" b = Just $ a * b
    go a "/" b = Just $ a `div` b
    go _ _ _ = Nothing

main = 
    mapM_ putStrLn =<< solve <$> lines <$> getContents

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

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 5e5 + 123;
const int M = 1e6 + 123;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

string s;

bool ok(int l, int r){
    string a = "", b = "";
    for (int i = l; i <= r; i++){
        a += s[i];
        b += s[i];
    }

    //cout << a << endl;
    reverse(all(a));
    return a == b;
}

void solve(){

    cin >> s;
    int n = sz(s);
    if (ok(0, n-1) && ok(0, (n-1)/2-1) && ok((n+3)/2-1, n-1)){
        cout << "Yes";
        return;
    }
    cout << "No";
}

int main(){
    #ifdef KAZAKH
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,x,y;
  cin>>n>>x>>y;
  int mat[n][n];
  vector<int> ans(n,0);
  for(int i=1;i<n;i++)
  {
    for(int j=i+1;j<=n;j++)
    {
      int d=min(j-i,abs(x-i)+1+abs(y-j));
      mat[i][j]=d;
      ans[mat[i][j]]++;
    }
 }
 for(int i=1;i<n;i++)
    cout<<ans[i]<<"\n";
  return 0;
}
                

Measured memory_bytes: 15744
def listint():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

a,b,c = listint()
poor = False
if a == b:
    if a != c:
        poor = True
if a == c:
    if a != b:
        poor = True
if b == c:
    if a != b:
        poor = True
if poor == True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>

int main()
{
  using namespace std;
  // int a = 1, b = 2;
  // cout << a << " " << b << endl;
  // swap(a, b);
  // cout << a << " " << b << endl;
  int X, Y, Z;
  cin >> X >> Y >> Z;
  swap(X, Y);
  swap(X, Z);
  cout << X << " " << Y << " " << Z << endl;

  return 0;
}

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

k0=k1=k2=0
for ai in a:
    if ai%4==0:
        k2+=1
    elif ai%2==0:
        k1+=1
    else:
        k0+=1

if k1==0:
    f=k2*2+1>=N
else:
    f=k2*2+k1>=N

print('Yes' if f else 'No')

Measured memory_bytes: 62576
/*
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
typedef mp::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n;i>0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;


int main()
{
    set<int> a;
    
    rep(i,3) {int z;cin>>z;a.insert(z);}

    cout<<a.size()<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int xa[] = new int[n];
		int ya[] = new int[m];
		for(int i = 0; i < n; i++){
			xa[i] = sc.nextInt();
		}
		for(int i = 0; i < m; i++){
			ya[i] = sc.nextInt();
		}
		boolean ans = false;
		for(int i = x+1; i <= y; i++){
			boolean flag = false;
			for(int j = 0; j < n; j++){
				if(xa[j] >= i){
					flag = true;
				}
			}
			for(int j = 0; j < m; j++){
				if(ya[j] < i) flag = true;
			}
			if(flag == false){
				ans = true;
				break;
			}
		}
		if(ans){
			System.out.print("No War");
		}else{
			System.out.print("War");
		}
	}
}


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

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++){
        s[i]=s[i]+n;
        if(s[i]>90)
        s[i]=abs(s[i]-90)+64;
        cout<<s[i];
    }
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, M = [int(x) for x in input().split()]
    H = [int(x) for x in input().split()]
    AB = [[int(x) for x in input().split()] for _ in range(M)]

    ROAD = [[] for j in range(N + 1)]
    for a, b in AB:
        ROAD[a].append(b)
        ROAD[b].append(a)

    ans = 0
    for i in range(1, N + 1):
        for n in ROAD[i]:
            if H[i - 1] <= H[n - 1]:
                break
        else:
            ans += 1

    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 39592
#include<iostream>
#include<time.h>
#include<stdlib.h>
#include<string>

using namespace std;

int main(){
    
    int n = 0;
    cin >> n;
    string b; cin >> b;
    int l = b.length();
    for(int i = 0; i < l; i++){
        for(int j = 0; j < n; j++){
            b[i] += 1;
            if(b[i] == 'Z' + 1) b[i] = 'A';
        }
    }
    cout << b;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

struct Info{
	char name[21];
	double seed_price,before_leaf,after_leaf,num,sell_price,count,rate;
};

//???????????????????????????3,left?????????????????´??????1,right?????????????????¨??????2
int strCmp2(char* left,char* right){
	int i;

	for(i=0;left[i] != '\0' && right[i] != '\0'; i++){
		if(left[i] != right[i]){
			if(left[i] < right[i])return 1;
			else{
				return 2;
			}
		}
	}
	if(left[i] == '\0')return 1;
	else{
		return 2;
	}
}

void func(int N){
	Info info[N];
	double A,B,C,D,E,sum,total_time;

	for(int loop = 0; loop < N; loop++){
		scanf("%s %lf %lf %lf %lf %lf %lf %lf %lf %lf",info[loop].name,&info[loop].seed_price,&A,&B,&C,&D,&E,&info[loop].num,&info[loop].sell_price,&info[loop].count);
		info[loop].before_leaf = A+B+C;
		info[loop].after_leaf = D+E;

		sum = 0;
		total_time = info[loop].before_leaf;
		for(int i = 0; i < info[loop].count; i++){
			total_time += info[loop].after_leaf;
			sum += info[loop].sell_price*info[loop].num;
		}
		sum -= info[loop].seed_price;
		info[loop].rate = sum/total_time;
	}

	for(int i = 1; i <= N-1; i++){
		for(int k = N-1; k >= i; k--){
			if(info[k].rate > info[k-1].rate)swap(info[k],info[k-1]);
			else if(info[k].rate == info[k-1].rate && strCmp2(info[k].name,info[k-1].name) == 1)swap(info[k],info[k-1]);
		}
	}

	for(int i = 0; i < N; i++)printf("%s\n",info[i].name);
	printf("#\n");

}

int main(){
	int N;

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func(N);
	}

}

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

int main() {
  string S;
  cin >> S;
  if(S == "Sunny") cout << "Cloudy" << endl;
  if(S == "Cloudy") cout << "Rainy" << endl;
  if(S == "Rainy") cout << "Sunny" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
ll n,a[100010];
int main(){
  cin>>n;
  lol(i,n){
    cin>>a[i];
  }
  ll mini=2,maxi=2;
  for(int i=n-1;i>=0;i--){
    
    ll x=(mini-1)/a[i]+1;
    x*=a[i];
    mini=x;
    
    ll y=maxi/a[i];
    y*=a[i];
    maxi=y+a[i]-1;
    
    if(mini>maxi){
      cout<<"-1"<<endl;
      return 0;
    }
  }
  cout<<mini<<" "<<maxi<<endl;
  return 0;
}


Measured memory_bytes: 1024
# include<iostream>

using namespace std;
int main(){
	int a = 0;
	int b = 0;
	int c = 0;
	cin >> a >> b >> c;
	if (a < b && b < c){ cout << a << " " << b << " " << c << endl; }
	if (b < a && a < c){ cout << b << " " << a << " " << c << endl; }
	if (c < a && a < b){ cout << c << " " << a << " " << b << endl; }
	if (a < c && c < b){ cout << a << " " << c << " " << b << endl; }
	if (b < c && c < a){ cout << b << " " << c << " " << a << endl; }
	if (c < b && b < a){ cout << c << " " << b << " " << a << endl; }
	if (a == b && b < c){ cout << a << " " << b << " " << c << endl; }
	if (b == c && c < a){ cout << b << " " << c << " " << a << endl; }
	if (c == a && a < b){ cout << c << " " << a << " " << b << endl; }


	return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
char s[100005]={0};
int a[100005]={0};
int main()
{
    scanf("%s",s);
    int n = strlen(s);
    int t='R';
    int j=1;
    int num=1;
    for(int i=1;i<n;i++){
        if(s[i]!=t){
            if(s[i]=='L'){
                a[i-1]=num;
                j=i;
                a[j]++;
            }
            num=1;
            t=s[i];
        }
        else if(s[i]=='R')
            num++;
        else if(s[i]=='L')
        {
            a[j]++;
            num++;
        }
    }
    int num1,num2,flag;
    for(int i=0;i<n;i++){
        if(a[i]!=0){
            num1=a[i]-1;
            num2=a[i+1]-1;
            a[i]=1;
            a[i+1]=1;
            flag=0;
            while(num1!=0||num2!=0){
                swap(a[i],a[i+1]);
                if(num1>0){
                    a[i]++;
                    num1--;
                }
                if(num2>0){
                    a[i+1]++;
                    num2--;
                }
                flag++;
            }
            if(flag&1==1)
                swap(a[i],a[i+1]);
            i++;
        }
    }
    s[j]=num;
    for(int i=0;i<n;i++){
        printf("%d ",a[i]);
    }
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h> 
using namespace std;
/* * * *   * * *   	* * * */
#define ll  long long
#define ld long double
#define ms(a,v) memset(a,v,sizeof a)
#define pii pair<int, int>
/* * * *   * * *   	* * * */
/* *
 *
 * Author: Hamkor
 *
 * */
int main(){
	int n; scanf("%d", &n);
	int a[n];
	for (int i=0; i<n; ++i)scanf("%d", a+i);
	sort(a, a+n);
	printf("%d", a[n/2] - a[n/2-1]);
	
	return 0;
}


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

int is_prime[1000005];

int main(){
  int n;  
  cin>>n;
  int a[200005];
  rep(i,n){
    cin>>a[i];
    is_prime[a[i]]++;
  }
  sort(a,a+n);

  int ans=0;
  for(int i=1;i<=1000000;i++){
    if(is_prime[i]==0)continue;
    if(is_prime[i]==1) ans++;
    for(int j=2*i;j<=1000000;j+=i){
      is_prime[j]=0;
    }
  }

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


Measured memory_bytes: 8256
#include<bits/stdc++.h>
#define INF 0x7fffffff
using namespace std;
typedef long long ll;
int n,m,MAX,ans=1;
struct str{
    int l,r;
}s[100001];
bool cmp(str a,str b)
{return a.r<b.r||(a.r==b.r&&a.l<b.l);}
int main()
{
    cin>>n>>m;
    for(int i=1;i<=m;i++)
        scanf("%d%d",&s[i].l,&s[i].r);
    sort(s+1,s+m+1,cmp);
    MAX=s[1].r;
    for(int i=2;i<=m;i++)
    {
        if(MAX>s[i].l)
            continue;
        else
        {
            MAX=s[i].r;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int N = in.i();
        int[] L = in.ii(N);
        int ans = 0;
        for (int i = 0; i < N; i++) {
            for(int j = i; j < N; j++) {
                for(int k = j; k < N; k++) {
                    boolean b1 = L[i] != L[j] && L[j] != L[k] && L[k] != L[i];
                    boolean b2 = L[i] < L[j] + L[k] && Math.abs(L[j] - L[k]) < L[i];
                    if (b1 && b2) {
                        ans++;
                    }
                }
            }
        }
        out.println(ans);
    }

    static class MyReader extends BufferedReader {
        char[] cbuf = new char[1024];
        int head = 0;
        int tail = 0;

        MyReader() {
            super(new InputStreamReader(System.in));
        }

        char next() {
            if (head == tail) {
                try {
                    tail = read(cbuf, 0, cbuf.length);
                } catch (IOException e) {}
                head = 0;
            }
            return cbuf[head++];
        }

        void back() {
            head--;
        }

        boolean minus() {
            boolean minus;
            while (true) {
                char c = next();
                if (c != ' ' && c != '\n' && c != '\r') {
                    if (!(minus = c == '-')) back();
                    return minus;
                }
            }
        }

        void skip() {
            while (true) {
                char c = next();
                if (c != ' ' && c != '\n' && c != '\r') {
                    back();
                    break;
                }
            }
        }

        char[] s(final int N) {
            skip();
            char[] s = new char[N];
            for (int i = 0; i < s.length; i++) {
                s[i] = next();
            }
            return s;
        }

        int i() {
            boolean minus = minus();
            int n = 0;
            while (true) {
                int k = next() - '0';
                if (k < 0 || 9 < k) break;
                n = 10 * n + k;
            }
            return minus ? -n : n;
        }

        int[] ii(final int N) {
            int[] a = new int[N];
            for (int j = 0; j < a.length; j++) a[j] = i();
            return a;
        }

        long l() {
            boolean minus = minus();
            long n = 0;
            while (true) {
                int k = next() - '0';
                if (k < 0 || 9 < k) break;
                n = 10 * n + k;
            }
            return minus ? -n : n;
        }
    }
}


Measured memory_bytes: 32832
a = []
for i in range(3):
    a.append([int(x) for x in input().split()])

n = int(input())
b = [int(input()) for x in range(n)]

def if_bingo(li):
    for i in range(3):
        if a[i][0] == a[i][1] == a[i][2] == -1:
            return True
        if a[0][i] == a[1][i] == a[2][i] == -1:
            return True
    if a[0][0] == a[1][1] == a[2][2] == -1:
        return True
    if a[0][2] == a[1][1] == a[2][0] == -1:
        return True
    return False

for num in b:
    for i, line in enumerate(a):
        for j, sq in enumerate(line):
            if a[i][j] == num:
                a[i][j] = -1

if if_bingo(a):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

int K , T;
int a;

int main(){
	scanf("%d%d" , &K , &T);
	repp(i,0,T){
		int x;
		scanf("%d" , &x);
		a = max(a , x);
	}
	K -= a;
	--a;
	printf("%d\n" , K < a ? a - K : 0);
	return 0;
}


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

const int INF = (int)1e9;
const int V = 10;

int H, W;
int cost[V][V];
int d[V];
bool used[V];
int cnt[V];

void dijkstra(int s) {
	fill(d, d + V, INF);
	fill(used, used + V, false);
	d[s] = 0;

	while (true) {
		int v = -1;
		for (int u = 0; u < V; u++) {
			if (!used[u] && (v == -1 || d[u] < d[v])) v = u;
		}
		if (v == -1) break;
		used[v] = true;
		for (int u = 0; u < V; u++) {
			d[u] = min(d[u], d[v] + cost[v][u]);
		}
	}
}

void input_data(void) {
	cin >> H >> W;
	for (int j = 0; j < V; ++j) {
		for (int i = 0; i < V; ++i) {
			cin >> cost[i][j];
			if (i == j)
				cost[i][j] = INF;
		}
	}
	fill(cnt, cnt + V, 0);
	for (int j = 0; j < H; ++j) {
		for (int i = 0; i < W; ++i) {
			int a;
			cin >> a;
			++cnt[a];
		}
	}
}

int main(void) {
	input_data();

	dijkstra(1);
	int ans = 0;
	for (int i = 0; i < V; ++i) {
		ans += cnt[i] * d[i];
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256