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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    vector<ll> dish(5, 0);
    vector< pair<ll, ll> > dish_mod(5, {0, 0}); // first: 余り second: インデックス
    REP(i, 5) {
        cin >> dish[i];
        dish_mod[i] = make_pair(dish[i] % 10, i);
        if(dish_mod[i].first == 0) { dish_mod[i].first = 10; }
    }
    SORT(dish_mod);
    ll ans = dish[dish_mod[0].second];
    for(int i = 1; i < 5; ++i) {
        ll ind = dish_mod[i].second;
        ll val = dish[ind];
        ans += val;
        if(val % 10 != 0) {
            ans += 10 - (val % 10);
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 200000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	ll cost;
	edge(int _t, ll _cost) : t(_t)
		, cost(_cost) {
	}
};
bool isPrime(int n) {

	if (n == 1) return false;
	for (ll i = 2; i * i <= n; i++)
	{
		if (n % i == 0) return false;
	}
	return true;
}
void Solve() {
	
	int n;
	cin >> n;
	ll a[100010];
	int oc = 0;
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
		oc += a[i] % 2;
	}

	if (oc % 2 == 0) {
		cout << "YES" << endl;
	}else
		cout << "NO"<< endl;
}
int main() {
	Solve();
	return 0;
}



Measured memory_bytes: 1024
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////
#define R(i,n) for(int i=0;i<(n);i=i+1)
/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int N;
	cin >> N;
	vector<vector<int>>X(N, vector<int>(2));
	R(i, N) {
		cin >> X[i][1] >> X[i][0];
	}
	SO(X);
	LL now = 0;
	R(i, N) {
		now += X[i][1];
		if (now > X[i][0]) {
			cout << "No" << endl;
			return;
		}
	}
	cout << "Yes" << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

typedef complex<double> P;
typedef vector<P> G;
#define here(g, i) g[i]
#define next(g, i) g[(i + 1) % g.size()]
#define prev(g, i) g[(i - 1 + g.size()) % g.size()]
const double EPS = 1e-10;
const double INF = 1e12;

struct L {
    P a, b, v;
    L(){}
    L(P _a, P _b) {a = _a, b = _b, v = b - a;}
    L(double _ax, double _ay, double _bx, double _by) {
        a = P(_ax, _ay), b = P(_bx, _by), v = b - a;
    }
};

double cross(P a, P b) {
    return imag(conj(a) * b);
}

double dot(P a, P b) {
    return real(conj(a) * b);
}

double areaG(G g) {
    int n = g.size();
    double ret;
    rep(i, n) {
        ret += cross(here(g, i), next(g, i));
    }
    return ret / 2;
}

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

    int n;
    cin >> n;
    G g;
    while (n--) {
        double x, y;
        cin >> x >> y;
        g.emplace_back(x, y);
    }

    printf("%.1f\n", areaG(g));
}

Measured memory_bytes: 3308
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) {
		int i;
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		String[] s = new String[n];
		int a=0;
		int b=0;
		int ba=0;
		int ab=0;
		int j;
		for(i=0; i<n; i++) {
			s[i] = sc.next();
			for(j=0; j<s[i].length()-1; j++){
				if(s[i].charAt(j) == 'A' && s[i].charAt(j+1) == 'B') {
					ab++;
					j++;
				}
			}
			if(s[i].charAt(0)=='B') {
				b++;
				if(s[i].charAt(s[i].length()-1)=='A') {
					ba++;
				}
			}
			if(s[i].charAt(s[i].length()-1)=='A') {
				a++;
			}
		}
		sc.close();
		sc = null;
		if(a>0 && a==b && a==ba) {
			System.out.println(a+ab-1);
		} else {
			System.out.println(min(a, b)+ab);
		}
	}
}


Measured memory_bytes: 32256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.conv;
import std.typecons;

void main() {
	(rs.uniq.array.length - 1).writeln;
}

// ===================================

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (isBasicType!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

int ri() {
	return readAs!int;
}

string rs() {
	return readln.chomp;
}

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

int main()
{
    int n,m,i,a[101],b[51]={0};
    cin>>n>>m;
    for(i=0;i<2*m;i++){
        cin>>a[i];
    }
    sort(a,a+2*m);
    int sum=1;
    for(i=0;i<2*m;i++){
        if(a[i]==a[i+1]){
            sum+=1;
        }
        else if(a[i]!=a[i+1]){
            b[a[i]-1]=sum;
            sum=1;
        }
    }
    for(i=0;i<n;i++){
        cout<<b[i]<<'\n';
    }
    return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>

int main(){
  long long int X, A, B, nokori;
  
  scanf("%ld%ld%ld", &X, &A, &B);
  nokori = X;
  nokori -= A;

  for (;nokori - B >= 0; nokori -= B) {

  }
  printf("%ld\n", nokori);
}


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

int main(){
  int n,x,t,ans=0;cin>>n>>x>>t;
  ans=t*((n+x-1)/x);

  cout<<ans;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <math.h>


struct Point {double x, y;};

void koch(int n, Point a, Point b){
	if (n == 0)
	return;
	
	Point s,t,u;
	double th = M_PI * 60.0 / 180.0;
	
	s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
	s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;
    
    koch(n - 1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(n - 1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(n - 1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(n - 1, t, b);
}



int main(){

    Point a, b;
    int n;

    scanf("%d", &n);
    
    a.x = 0;
    a.y = 0;
    b.x= 100;
    b.y = 0;
    
    
	printf("%.8f %.8f\n", a.x, a.y);
	koch(n, a, b);
	printf("%.8f %.8f\n", b.x, b.y);
	
	
	return 0;
}

Measured memory_bytes: 2736
# include <bits/stdc++.h>
# define ll long long
using namespace std;
const ll mod = 1e9 + 7, N = 3e5 + 10;
ll a[N], res, count_ones[65], count_zeros[65]; 
int main(){
	int n;
	cin >> n;
	for(int i = 1; i <= n; i ++) cin >> a[i];
	for(int i = n; i >= 1; i --){
		ll cur = a[i];
		for(ll j = 0; j <= 62; j ++){
			if((1ll << j) & cur){
				res += (ll)count_zeros[j] * ((1ll << j) % mod);
			} else{
			    res += (ll)count_ones[j] * ((1ll << j) % mod);
			}
		}
		for(ll j = 0; j <= 62; j ++){
			if((1ll << j) & cur) count_ones[j] ++;
			else count_zeros[j] ++;
		}
		res %= mod;
	}
	cout << res << '\n';
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  string S,T;
  cin>>S>>T;
  
  cout<<T<<S<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include<stack>
#include<string>
#include<algorithm> 
#include <set>
#include<list>
#include <bit>
#include <bitset>
#include <cstdint>
#include <initializer_list>
typedef long long int ll;
using namespace std;
const int MOD = 1000000007;


int main() {
	int N; cin >> N;
	vector<ll> data(N);
	for (int i = 0; i < N; i++)cin >> data.at(i);
	ll ans=0;
	sort(data.begin(), data.end());
	for (int i = 0; i < N-2; i++) {
		for (int j = i + 1; j < N - 1; j++) {
			for (int k = j + 1; k < N; k++) {
				if (data[i] != data[j] && data[j] != data[k]) {
					if (data[i] + data[j] > data[k])ans++;
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y,sx,sy,cost;
};

int main() {

	int a,b;
	ll a2=0,b2=0;
	cin>>a>>b;
	if(b<=a)rep(i,a)b2=b2*10+b;
	else rep(i,b)a2=a2*10+a;
	cout<<max(a2,b2)<<endl;

	return 0;
}


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

int main(){
  int N;
  cin>>N;
  int ans=1e9+1e9;
  for(int i=0;i<N;i++){
    int a,b;
    cin >> a >> b;
    ans = min(ans, a+b);
  }
  
  cout << ans << endl;
}




Measured memory_bytes: 3588
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long a,b,k;
        a = Long.parseLong(sc.next());
        b = Long.parseLong(sc.next());
        k = Long.parseLong(sc.next());

        if(k <= a) {
            System.out.print(a-k);
            System.out.print(" ");
            System.out.print(b);
        } else if (a < k && k <= a+b) {
            System.out.print(0);
            System.out.print(" ");
            System.out.print(b+a-k);
        } else {
            System.out.print(0);
            System.out.print(" ");
            System.out.print(0);
        }
    }
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n, c, k; cin >> n >> c >> k;
    vector<ll> t(n);
    for (ll i = 0; i < n; ++i) {
        cin >> t[i];
    }
    sort(t.begin(), t.end());

    ll ans = 0;
    for (ll i = 0; i < n; ++i) {
        ll limit = t[i] + k;
        ll cnt = 1;
        ++i;

        while (t[i] <= limit && cnt + 1 <= c) {
            ++cnt;
            ++i;
        }

        --i;
        ++ans;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define MAX (1<<17)
using namespace std;
int n,q;
int data[MAX*2];
void Segtree(){
  int tmp=1;
  while(tmp<n)tmp*=2;
  n=tmp;
  for(int i=0;i<n*2-1;i++)data[i]=INT_MAX;
}
void update(int k,int x){
  k+=n-1;
  data[k]=x;
  while(k>0){
    k=(k-1)/2;
    data[k]=min(data[k*2+1],data[k*2+2]);
  }
}
int find(int a,int b,int k,int l,int r){
  if(r<=a || b<=l)return INT_MAX;
  if(a<=l && r<=b)return data[k];
  int v1=find(a,b,k*2+1,l,(l+r)/2);
  int v2=find(a,b,k*2+2,(l+r)/2,r);
  return min(v1,v2);
}
int main(){
  int c,x,y;
  cin>>n>>q;
  Segtree();
  for(int i=0;i<q;i++){
    scanf("%d%d%d",&c,&x,&y);
    if(c)cout<<find(x,y+1,0,0,n)<<endl;
    else update(x,y);
  }
}

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

int digits(int x){
  int sum=0;
  while(x>0){
    sum+=x%10;
    x/=10;
  }
  return sum;
}

int main(){
  int N;
  cin >>N;
  int ans=100;
  for(int i=1;i<N;i++){
    if(ans>digits(i)+digits(N-i))
      ans=digits(i)+digits(N-i);
  }
  cout <<ans <<endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
   ll k,ans=0; cin>>k;
   queue<ll> que;
   rep(i,9) que.push(i+1);
   rep(i,k){
       ans=que.front();
       if(ans%10!=0) que.push(ans*10+ans%10-1);
       que.push(ans*10+ans%10);
       if(ans%10!=9) que.push(ans*10+ans%10+1);
       que.pop();
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
char a[100010];
int main(){
	cin>>a+1;
	int n=strlen(a+1);
	for(int i=1;i<n;i++){
		if(a[i]==a[i+1]) return cout<<i<<' '<<i+1<<'\n',0;
	}
	for(int i=1;i+2<=n;i++){
		if(a[i]==a[i+2]) return cout<<i<<' '<<i+2<<'\n',0;
	}
	cout<<-1<<' '<<-1<<'\n';
}
	

Measured memory_bytes: 3728
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int a;
  cin >> a;
  cout << a + a * a + a * a * a << endl;
}

Measured memory_bytes: 3616
using System;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        var m = new int[]
            {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};
        var k = sc.NextInt();
        Console.WriteLine(m[k-1]);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13140
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

int main() {
    int n, k, r, s, p, ans = 0;
    string t;
    cin >> n >> k >> r >> s >> p >> t;
    for (int i = 0; i < k; ++i) {
        if (t[i] == 'r')
            ans += p;
        if (t[i] == 's')
            ans += r;
        if (t[i] == 'p')
            ans += s;
        bool win = true;
        for (int j = i + k; j < n; j += k) {
            if (t[j] != t[j - k] || (t[j] == t[j - k] && win == false)) {
                if (t[j] == 'r')
                    ans += p;
                if (t[j] == 's')
                    ans += r;
                if (t[j] == 'p')
                    ans += s;
                win = true;
            }
            else {
                win = false;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
def f():
    n,k=map(int,input().split())
    l=list(map(int,input().split()))
    now=1
    for d in range(k.bit_length()):
        if k%2:now=l[now-1]
        l=tuple(l[i-1]for i in l)
        k//=2
    print(now)
if __name__ == "__main__":
    f()


Measured memory_bytes: 32256
#include<bits/stdc++.h>
#define inf ((int)0x3f3f3f3f)
#define neinf ((int)0xc1c1c1c1)
#define llinf ((ll)0x3f3f3f3f3f3f3f3f)
#define nellinf ((ll)0xc1c1c1c1c1c1c1c1)
#define ull unsigned long long
#define lson root<<1
#define rson root<<1|1
#define uint usigned int
#define Mid int mid=(l+r)>>1;
#define FREI freopen("in.txt","r",stdin)
#define FREO freopen("out.txt","w",stdout)
#define Mem(a,b) memset(a,b,sizeof(a))
#define Memv(a,b) for(int i=0;i<=b;i++) a[i].clear()
#define ll long long
#define eps 1e-6
#define PB push_back
#define PI acos(-1)
#define lmove(n) (1<<(n))
#define FI first
#define SE second
#define Ceil(x,y) ((x+y-1)/y)
#define EULER_C 0.57721566490153286060651209
using namespace std;
const int MAXN=1e5+10;
unordered_map<int,int>f;
int n;
vector<int>a;
bool cmp(int a,int b){
    return a>b;
}
int main() {
#ifdef ONLINE_JUDGE
#else
    //freopen("/home/jason/data/out.txt","r",stdin);
    //FREI;
    //FREO;
#endif // ONINLE_JUDGE
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        int x;
        scanf("%d",&x);
        a.PB(x);
        f[x]++;
    }
    sort(a.begin(),a.end(),cmp);
    a.erase(unique(a.begin(),a.end()),a.end());
    ll res=0;
    bool flag=0;
//    for(auto u:a){
//        cout<<u<<' ';
//    }
//    cout<<endl;
    for(int i=0;i<a.size();i++){
        ll x=(ll)a[i];
        if(f[a[i]]>3&&res==0){
            res=x*x;
            flag=1;
            break;
        }
        if(f[a[i]]>1) {
            if(res==0) res=x;
            else {
                res*=x;
                flag=1;
                break;
            }
        }
    }
    flag?printf("%lld\n",res):puts("0");
}


Measured memory_bytes: 4764
#include<bits/stdc++.h>
  using namespace std;
vector<int>dp[200005];
int total=0;
void dfs(int index,int par,int col)
{
  total+=col;
  for(auto it:dp[index])
  {
    if(it!=par)
      dfs(it,index,col^1);
  }


}
  

  int main()
  {


       ios_base::sync_with_stdio(false);
       cin.tie(NULL);
      /*#ifndef ONLINE_JUDGE
          freopen("input.txt","r",stdin);
          freopen("output.txt","w",stdout);
      #endif
*/

    int t;
    cin>>t;
    int temp=(t+999)/1000;
    cout<<(temp*1000)-t<<endl;

    return 0;

  }

Measured memory_bytes: 8336
#include "iostream"
#include "string"
using namespace std;

int main()
{
	string s1,s2;
	cin >> s1;
	s2 = "";
	for (int i = 0; i < s1.length(); i++) {
		if (s1[i] == '0')
			s2.push_back('0');
		if (s1[i] == '1')
			s2.push_back('1');
		if (s1[i] == 'B') {
			if (s2.empty() == false)
				s2.pop_back();
		}
	}
	cout << s2 << endl;
    return 0;
}

Measured memory_bytes: 256
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

//Degree <-> Radian
double toRad(double d){ double rad; rad=d*PI/180; return rad; }
double toDegree(double rad){ double d; d=rad*180/PI; return d; }
//The least common multiple : lcm
ll lcm(int a,int b){ return a*b/__gcd(a,b); }
//素数判定
bool isPrime(int n){
    int i; 
    if(n<2) return 0;
    else if(n==2) return 1;
    if(n%2==0) return 0;
    for(i=3;i*i<=n;i+=2) if(n%i==0) return 0;
    return 1;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s,t; cin >> s >> t;
    cout << t+s ENDL;
    
    return 0;
}

Measured memory_bytes: 3604
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)
//#define MULTI_TEST
//#define GOOGLE
#ifdef LOCAL
#include "debugger.h"
#else
#define db(...)
#endif
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

void solve(int tc)
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max({a * c, b * d, a * d, c * b}) << ln;
	return;
}

int main()
{
#ifndef LOCAL
	FASTIO;
#endif
	int t = 1;
#ifdef LOCAL
	clock_t start, stop;
	start = clock();
#endif
#ifdef MULTI_TEST
	cin >> t;
#endif
	for (int tc = 1; tc < t + 1; tc++)
	{
#ifdef GOOGLE
		cout << "Case #" << tc << ": ";
#endif
		solve(tc);
	}
#ifdef LOCAL
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 3652
n, q = map(int, input().split())
s = input()
questions = [list(map(int, input().split())) for _ in range(q)]

ac_index = [0]*n

for i in range(1, n):
    if s[i-1] == 'A' and s[i] == 'C':
        ac_index[i] = ac_index[i-1] + 1
    else:
        ac_index[i] = ac_index[i-1]

for j in range(q):
    l = questions[j][0]-1
    r = questions[j][1]-1
    print(ac_index[r] - ac_index[l])

Measured memory_bytes: 69080
#include<bits/stdc++.h>
using namespace std;
const long long mod=998244353;

int main(){
    long long n; cin >> n;
    long long x;
    long long count[100000]={};
    int m=0;
    for(int i=0;i<n;i++) {
        cin >> x;
       // m=max(m,x);
        count[x]++;
        if(i==0 && x!=0){
            cout << 0 << endl;
            return 0;
        }
    }
    if(count[0]!=1){
        cout << 0 << endl;
        return 0;
    }
    long long ans=1;
    for(int i=1;i<n;i++){
       long long c=count[i];
       while(c>0){
        ans*=count[i-1];
        ans=ans%mod;
        c--;
       }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

ll rec(ll x){
	if(x == 1) return 1;
	else return 1+2*rec(x/2);
}

int main(){
	ll H;
	cin >> H;
	cout << rec(H) << endl;

	return 0;
}


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

      int h = sc.nextInt();
      int w = sc.nextInt();
      int n = sc.nextInt();

      int max = Math.max(h,w);
      int count = 1;

      if (n==0) {
        System.out.println(0);
        System.exit(0);
      }

      for (int i = 1;i<h*w ;i++ ) {
        if (n<=max*i) {
          System.out.println(count);
          System.exit(0);
        }
        count++;
      }

  }
}


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

void insertionSort(vector<int>& a) {
	int n = a.size();
	for (int i = 0; i < n; ++i) {
		if (!i) cout << a[0];
		else cout << " " << a[i];
	}
	cout << endl;
	for (int i = 1; i < n; ++i) {
		int v = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] > v) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
		for (int j = 0; j < n; j++) {
			if (!j) cout << a[0];
			else cout << " " << a[j];
		}
		cout << endl;
	}
}

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

	insertionSort(a);

	return 0; 
}



Measured memory_bytes: 3096
#include <stdio.h>

int main(void)
{
    int k;
    
    scanf("%d", &k);
    
    if(k % 2 == 0) {
        printf("%d\n", k * k / 4);
    } else {
        printf("%d", (k + 1) * (k - 1) / 4);
    }
    
    return 0;
}


Measured memory_bytes: 128
import java.util.*
import kotlin.*

import java.io.InputStream
import java.lang.NumberFormatException
import java.lang.StringBuilder


fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = FastScanner()
        val n = sc.nextInt()
        val t = sc.nextInt()
        val a = Array(n) { sc.nextInt() }

        var ans = 0L
        var time = a[0]
        for (i in 1 until n) {
            ans += Math.min(a[i] - time, t)
            time = a[i]
        }
        ans += t
        println(ans)
    }
}


class FastScanner {
    companion object {
        val input: InputStream = System.`in`
        val buffer = ByteArray(1024) { 0 }
        fun isPrintableChar(c: Int): Boolean = c in 33..126
    }

    var ptr = 0
    var buflen = 0
    private fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = input.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }

    private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1

    private fun skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++
    }

    fun hasNext(): Boolean {
        skipUnprintable()
        return hasNextByte()
    }

    fun next(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b)
            b = readByte()
        }
        return sb.toString()
    }

    fun nextInt(): Int {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0
        var b = readByte()
        // '-' = 45
        val minus = b == 45
        if (minus) {
            b = readByte()
        }

        // '0' = 48 '9' = 57
        if (b !in 48..57) {
            throw NumberFormatException()
        }

        while (true) {
            if (b in 48..57) {
                n *= 10
                n += b - 48
            } else if (b == -1 || !isPrintableChar(b)) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextLong(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var b = readByte()
        // '-' = 45
        val minus = b == 45
        if (minus) {
            b = readByte()
        }

        // '0' = 48 '9' = 57
        if (b !in 48..57) {
            throw NumberFormatException()
        }

        while (true) {
            if (b in 48..57) {
                n *= 10
                n += b - 48
            } else if (b == -1 || !isPrintableChar(b)) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextDouble(): Double = next().toDouble()
}


Measured memory_bytes: 33696
#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>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

	// Sがa,b,cをそれぞれ1文字ずつ持つか判定
	if (count(S.cbegin(), S.cend(), 'a') == 1 &&
		count(S.cbegin(), S.cend(), 'b') == 1 &&
		count(S.cbegin(), S.cend(), 'c') == 1) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long 
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll; 
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
// int ab  (int  x ) { return (x>0?x:-x); }
const int N = 2e5+5 ; 
ll st[N*4],a[N] ; 
int n , h[N] ; 
int L(int u ){return (2*u+1);}
int R(int u ){return (2*u+2);}
void update(int in , ll val , int i , int j , int u = 0 ){
	if( i == j ){
		st[u]=val ; 
		return ; 
	}
	if( i > j )return ; 
	int mid = (i+j)/2 ;  
	if( in <= mid )update(in,val,i,mid,L(u)); 
	else update(in,val,mid+1,j,R(u)); 
	st[u]=max(st[L(u)],st[R(u)]); 
}

ll query(int qL , int qR , int i , int j , int u = 0 ){
	if( i >= qL && j <= qR )return st[u]; 
	if( i > qR || j < qL || i > j )return 0; 
	int mid = (i+j)/2;
	return max(query(qL,qR,i,mid,L(u)),query(qL,qR,mid+1,j,R(u))); 
}

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

for(int i = 0 ; i < n ; i++ )cin >> h[i]; 
for(int i = 0 ; i < n ; i++ )cin >> a[i];
for(int i = 0 ; i < n ; i++ ){ 
	ll Quer = query(1,h[i],1,n);
	update(h[i] , (Quer+a[i]) , 1 , n ) ; 
}
cout << st[0] << endl; 

}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string(string(s)); }
string to_string(bool b) { return to_string(int(b)); }
string to_string(char b) { return "'" + string(1, b) + "'"; }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) {
	string res = "{";
	for (const auto& x : v) res += (res == "{" ? "" : ", ") + to_string(x);
	return res + "}";
}
void debug() { cerr << endl; }
template <typename Head, typename... Tail>
void debug(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug(T...);
}
#define db(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define db(...) 42
#endif
typedef long long ll;
typedef long double ld;
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	vector<int> A(n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &A[i]);
		--A[i];
	}
	vector<ll> add(m), numSeg(m);
	auto addSeg = [&](int s, int e, int init) {
		numSeg[s]++;
		numSeg[e]--;
		add[s] += init;
		if (e + 1 < m) add[e + 1] -= init + e - s;
	};
	ll ans = 0;
	for (int i = 0; i + 1 < n; ++i) {
		int a = A[i], b = A[i + 1];
		int d = b - a;
		if (d < 0) d += m;
		ans += d;
		if (a < b) {
			addSeg(a + 1, b, 0);
		} else if (b < a) {
			if (a + 1 < m) addSeg(a + 1, m - 1, 0);
			addSeg(0, b, m - (a + 1));
		}
	}
	ll best = 0;
	ll cur = 0, curSegs = 0;
	for (int i = 0; i < m; ++i) {
		cur += add[i];
		cur += curSegs;
		curSegs += numSeg[i];
		db(cur);
		best = max(best, cur);
	}
	assert(best <= ans);
	printf("%lld\n", ans - best);
}


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

static const int MAX = 200000;

int main(void){
    int R[MAX], n;
    cin >> n;
    for(int i=0; i<n; i++) cin >> R[i];
    
    int minv = R[0];
    int maxv = R[1] - minv;
    for(int i=1; i<n; i++){
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    cout << maxv << endl;
    return 0;
    
}

Measured memory_bytes: 3872
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int v = sc.nextInt();
            Integer saved = map.get(v);
            map.put(v, saved == null ? 1 : ++saved);
        }
        int m  = sc.nextInt();
        for (int i = 0; i < m; i++) {
            int need = sc.nextInt();
            Integer saved = map.get(need);
            if (saved == null || saved == 0) {
                System.out.println("NO");
                return;
            }
            map.put(need, --saved);
        }
        System.out.println("YES");
    }
}

Measured memory_bytes: 133544
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<queue>
#include<map> 
#include<bitset>
#include<vector>
using namespace std;
#define re register int
inline int read(){
    int x=0,ff=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')ff=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
    return x*ff;
}
int x,y;
signed main(){
	x=read();y=read();
	cout<<(x+y-1)/y<<endl;
   	return 0;
}


Measured memory_bytes: 256
a,b,n= map(int,input().split())
if b>n:
  l = ((a*n)//b)-(a*(n//b))
elif b==n:
  l = ((a*(n-1))//b)-(a*((n-1)//b))
else:
  l = (a*(b-1)//b)-(a*((b-1)//b))
print(l) 




Measured memory_bytes: 9188
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            long N = in.nextLong();
            long A = in.nextLong();
            long B = in.nextLong();
            long cnt = 0;
            if ((B - A) % 2 == 0) {
                cnt = (B - A) / 2;
            } else {
                long ad = A - 1;
                long bd = N - B;
                if (ad < bd) {
                    cnt = ad + 1;
                    A = 1;
                    B -= ad + 1;
                } else {
                    cnt = bd + 1;
                    A += bd + 1;
                    B = N;
                }
                cnt += (B - A) / 2;
            }
            out.println(cnt);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 22356
#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll n,a[10005],b[10005],s,ans;

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= n; i++)
    {
        cin >> b[i];
        s+=b[i]-a[i];
    }
    for (int i = 1; i <= n; i++)
        if (a[i]<b[i]) ans+=(b[i]-a[i]+1)/2;
    if (ans<=s) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  ll H;
  int N;
  cin >> H >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  if(accumulate(all(A), 0LL) >= H)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 640
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
a = 0
b = 0
c = []
for i in range(n):
    a = s.count(s[i])
    b = t.count(s[i])
    c.append(a-b)
if max(c) < 0:
    print(0)
else:
    print(max(c))

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    template <bool nl>
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { final(); }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << ' ' << val;
            return *this;
        }
        template <bool f = nl>
        auto final() -> std::enable_if_t<f> { cout << '\n'; }
        template <bool f = nl>
        auto final() -> std::enable_if_t<!f> {}
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy<true> operator,(T&& val)
    {
        cout << val;
        return {};
    }
    proxy<false> noreturn() { return {}; }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
                first = false;
            }
            cout << x;
        }
    }
};

void prog()
{
    input in;
    output out;

    auto N = in.read<int>();
    auto d = in.read<int>(N);
    std::sort(std::begin(d), std::end(d));
    out, d[N / 2] - d[N / 2 - 1];
}

int main()
{
    prog();
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
ll a,b,L,mod,mi[100],tmp,lst,k;
ll cnt[20],sum[20];
ll s1[100],s2[100];
ll ans;
int main() {
	//freopen("1.txt","r",stdin);
	read(L); read(a); read(b); read(mod);
	ll l,r,res,mid,x,y,t1,t2; tmp=1; lst=-1;
	for (int i=1;i<=18;i++) {
		l=lst,r=L-1; tmp*=10; res=lst-1;
		while (l<=r) {
			mid=(l+r)/2;
			if (a+mid*b<tmp) res=mid,l=mid+1;
			else r=mid-1;
		}
		k=res-lst;
		if (k<0) continue;
		lst=res;
		mi[0]=tmp%mod;
		s1[0]=1; s2[0]=0;
		for (int j=1;j<=62;j++) {
			mi[j]=mi[j-1]*mi[j-1]%mod;
			s1[j]=(mi[j-1]+1)*s1[j-1]%mod;
			s2[j]=(mi[j-1]+1)*s2[j-1]%mod+(1LL<<(j-1))%mod*s1[j-1]%mod*mi[j-1]%mod;
			s2[j]%=mod;
		}
		cnt[i]=1;
		x=0,y=0; t1=1,t2=0;
		for (int j=62;j>=0;j--)
			if (k&(1LL<<j)) {
				x+=s1[j]*t1%mod; x%=mod;
				y+=(s2[j]+s1[j]*t2%mod)*t1%mod; y%=mod;
				t1=t1*mi[j]%mod;
				t2=(t2+(1LL<<j))%mod;
				cnt[i]=cnt[i]*mi[j]%mod;
			}
		sum[i]=(a+b*res)%mod*x%mod-b%mod*y%mod;
		sum[i]=(sum[i]%mod+mod)%mod;
	}
	tmp=1;
	for (int i=18;i>=1;i--) {
		ans+=sum[i]*tmp%mod; ans%=mod;
		tmp=tmp*cnt[i]%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

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

class Prime {
    using ll = long long;

public:
    int MAX_V;
    std::vector<int> primes;
    std::vector<bool> isp;

    explicit Prime(int N) : MAX_V(N) {
        isp.assign(MAX_V + 1, true);
        isp[0] = isp[1] = false;
        for (int i = 2; i * i <= MAX_V; ++i) {
            if (isp[i]) {
                for (int j = i; i * j <= MAX_V; ++j) {
                    isp[i * j] = false;
                }
            }
        }
        for (int p = 2; p <= MAX_V; ++p) {
            if (isp[p]) primes.push_back(p);
        }
    }

    bool isprime(ll N) const {
        if (N <= MAX_V) return isp[N];
        for (ll p : primes) {
            if (p * p > N) break;
            if (N % p == 0) return false;
        }
        return true;
    }

    std::vector<std::pair<ll, int>> factorization(ll N) const {
        std::vector<std::pair<ll, int>> ret;
        for (ll p : primes) {
            if (p * p > N) break;
            if (N % p != 0) continue;
            int cnt = 0;
            while (N % p == 0) {
                N /= p;
                ++cnt;
            }
            ret.emplace_back(p, cnt);
        }
        if (N > 1) ret.emplace_back(N, 1);
        return ret;
    }
};

const Prime P(100000);

int main() {
    int N;
    std::cin >> N;
    auto v = P.factorization(N);
    for (auto p : v) {
        N -= N / p.first;
    }
    std::cout << N << std::endl;
}


Measured memory_bytes: 3268
#include <stdio.h>

int main(){
   int i,n,w,r,ans;
   char c[200001];

   scanf("%d",&n);
   scanf("%s",c);
   for (w=r=i=0;i<n;i++)
      if (c[i]=='W') w++;
      else           r++;
   if (w==n || r==n) {
      puts("0");
      return 0;
   }
   ans=0;
   if (w<r) {
      for (i=n-1;w>0;i--,w--)
         if (c[i]=='R') ans++; 
   } else {
      for (i=0;r>0;i++,r--)
         if (c[i]=='W') ans++; 
   }
   printf("%d\n",ans);
   return 0;
}


Measured memory_bytes: 1924
#include <stdio.h>

#define N 100000
#define M 10000
#define O 0
#define I 1
#define W 2

int n,k;
double T[N];

int check(double);
int solve(void);

int main(){
  int i;
  double a;
  scanf("%d%d",&n,&k);
  for(i=O;i<n;i++){
    scanf("%lf",&T[i]);
  }
  a=solve();
  printf("%d\n",(int)a);
  return 0;
}
int check(double p){
  int i=O,j;
  double s;
  for(j=O;j<k;j++){
    s=O;
    while(s+T[i]<=p){
      s+=T[i];
      i++;
      if(i==n){
	return n;
      }
    }
  }
  return i;
}

int solve(){
  double left=O;
  double right=N*M;
  double mid;
  int v;

  while(right-left>I){
    mid=(left+right)/W;
    v=check(mid);
    if(v>=n){
      right=mid;
    }
    else{
      left=mid;
    }
  }
  return right;
}



Measured memory_bytes: 2516
#include <stdio.h>

int main() {
    int a, b, c;
    int flag = 0;

    scanf("%d %d %d", &a, &b, &c);

    if (a == 5 && b == 5 && c == 7) {
        flag = 1;
    }
    if (a == 5 && b == 7 && c == 5) {
        flag = 1;
    }
    if (a == 7 && b == 5 && c == 5) {
        flag = 1;
    }

    if (flag == 1) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, x;
    cin >> n >> x;
    int l[n];
    forn(i, 0, n) {
        cin >> l[i];
    }
    
    int cur = 0, ans = 1;
    forn(i, 0, n) {
        cur += l[i];
        if (cur > x) break;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3540