akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <ctime>
#include <climits>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <utility>
#include <cstdlib>

using namespace std;
long int pow107 = (int)pow(10, 9) + 7;
int ilimit = INT_MAX;
long int llimit = LONG_MAX;

bool comp(pair<int, int> a, pair<int, int> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

int Func2(int n,int m){
    long int s2 = 1,
        r = 1;


    for(int i = 1; i <= m; ++i){
        s2 = (s2*(n - (i - 1))/i) % pow107;
    }

    return s2;
}

//long intの最大llimit
//intの最大ilimit
//10^9+7    pow107
//素数pn
//n乗jou
//階乗factorial
//コンビネーションFunc2

int main(){
    int n;
    vector <pair<int , int> > v;

    cin >> n;

    for(int i = 0; i < n; ++i){
        int a,b;
        cin >> a >> b;
        v.push_back(make_pair(a,b));
    }
    float t;

    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j){
            t += sqrt(pow(v[i].first - v[j].first,2) + pow(v[i].second - v[j].second,2));
        }
    }

    cout << fixed << setprecision(6) << t  / factorial(n)* 2 * factorial(n-1) << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int N; cin >> N;
    int pos=-2; int res;
    int ans=0;
    int A[N],B[N],C[N];
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];
    rep(i,N-1) cin >> C[i];
    C[N-1]=-1;
    rep(i,N){
        A[i]--;
        ans+=B[A[i]];
        if(pos+1==A[i]) ans+=res; 
        pos=A[i]; res=C[A[i]];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e5 + 10;

int main() {
    int r, g, b, n, cnt = 0;
    cin >> r >> g >> b >> n;
    for(int i = 0; i <= n; i++) {
        if(i * r > n) break;
        for(int j = 0; j <= n; j++) {
            if(i * r + j * g > n) break;
            int res = i * r + j * g;
            if((n - res) % b == 0) {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#define Mod 998244353
#define INF 1e14
typedef long long int ll;
const ll N=1e5+5;
bool x[N+1]={false};
ll fast(ll n,ll a)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll res=fast(n/2,a)%Mod;
        if(n%2==0)
        {
            return (((res%Mod)*(res%Mod))%Mod);
        }
        else{
            return (((((res%Mod)*a)%Mod)*res)%Mod);
        }
    }
}

int main()
{
    ll n,i;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll pref[n];
    pref[0]=a[0];
    for(i=1;i<n;i++)
    {
        pref[i]=pref[i-1]+a[i];
    }
    ll res=1e17;
    for(i=1;i<n;i++)
    {
        ll a=pref[i-1];
        ll b=pref[n-1]-a;
        res=min(res,abs(a-b));
    }
    cout<<res;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
//#define INF (1LL<<31)-1
//#define MOD 998244353
#define MOD 1000000007

int a[200010];
int main(){
    int n;
    scanf("%d",&n);
    rep(i,1,n){
        int x;
        scanf("%d",&x);x--;
        a[x]++;
    }
    
    rep(i,0,n)printf("%d\n",a[i]);
}

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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> H(N);
  for (int i = 0; i < N; ++i) cin >> H[i];
  vector<vector<int>> d(M, vector<int>(2, 0));
  for (int i = 0; i < M; ++i) cin >> d[i][0] >> d[i][1];
  vector<int> tr(N, 0);
  for (auto i: d) {
    int a, b;
    a = i[0] - 1;
    b = i[1] - 1;
    if (H[a] < H[b]) swap(a,b);
    if (H[a] == H[b]) {
        tr[a] = b + 1;
    }
    tr[b] = a + 1;
  }
  int ans = 0;
  for (int i: tr) {
    if (i == 0) ++ans;
  }
  cout << ans << endl;
  //for(int i = 0; i < N; ++i) cout << tr[i] << " ";
  //cout << endl;
  return 0;
}


Measured memory_bytes: 9560
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

const ll mod = 1e9 + 7;

int main()
{
    FASTIO
     /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    // cin >> T;
    T = 1;
    for(int cs = 1; cs <= T; cs++)
    {
        int n;
        cin >> n;
        vector<pair<int, int > > v;
        bool flag = true;
        for(int i = 0; i < n; i++){
            int a,b;
            cin >> a >> b; // b = deadline
            v.push_back({b,a});
            if(a > b) flag  = false;
        }
        sort(v.begin(),v.end());
        if(!flag){
            cout << "No\n";
            return 0;
        }
        int day = 0;
        for(auto x: v){
            int need = x.second;
            int deadline = x.first;
            day +=  need;
            if(day > deadline){
                cout << "No\n";
                return 0;
            }
        }
        cout << "Yes\n";
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);

    return 0;
}


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

ll n;
char M[1010][1010]={};
ll dp[1010][1010]={};
ll cnt=LLONG_MAX;
ll B=1000000007;




int main(){
   int w,h;
   cin>>h>>w;
   rep(i,h){
      rep(j,w){
         cin>>M[i][j];
      }
   }
   dp[h-1][w-1]=1;
   repr(i,h){
      repr(j,w){
         
         if(M[i+1][j]=='.')dp[i][j]+=dp[i+1][j];
         if(M[i][j+1]=='.')dp[i][j]+=dp[i][j+1];
         dp[i][j]%=B;
      }
   }
   cout<<dp[0][0]<<endl;
}



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

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#pragma GCC optimize("Ofast")
//1.0 * clock() / CLOCKS_PER_SEC

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const ll NN = 1e10 + 7;
const int N = 1e5 + 7;
const int M = 11;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 7;
const dl rf = 1e-14;
const int B = sqrt(N);

void solve1()
{
    string s;
    cin >> s;
    if( s[0] == '7' || s[1] == '7' || s[2] == '7' )cout << "Yes\n";
    else cout << "No\n";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


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

ll gcd(ll a, ll b){
    if(b == 0) return a;
    else{
//        if(b>a) swap(a,b);
        return gcd(b,a%b);
    }
}

ll lcm(ll a, ll b){
    ll d = gcd(a,b);
    if(d == b) return a;
    return a/d*b;
}

int main(){
    int n; cin >> n;
    vl t(n);
    for(int ix=0;ix<n;ix++) cin >> t.at(ix);

    ll a = t.at(0), b;
    for(int ix=1;ix<n;ix++){
        b = t.at(ix);
        a = lcm(a,b);
    }
    cout << a << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <string>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define int long long
#define pii pair<int, int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define jai_shree_ram  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i, a, b, d) for (int i = a; i <= b; i += d)
#define brep(i, a, b, d) for (int i = a; i >= b; i -= d)
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl '\n'
int MOD = 998244353;
////////////////////////////////

int dp[3005][3005];

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

int32_t main(){
    jai_shree_ram
    int n, s;
    cin >> n >> s;
    int a[n+1];
    rep(i,1,n,1) cin >> a[i];
    dp[0][0] = binpow(2, n, MOD);

    map <int, int> inv;
    inv[1] = 1;
    int m = MOD;
    inv[2] = (m - (m/2) * inv[m%2] % m) % m;


    rep(i,1,n,1){
        rep(sum,0,s,1){
            dp[i][sum] += dp[i-1][sum];
            dp[i][sum] %= MOD;
            if(sum >= a[i]){

                dp[i][sum] += ((dp[i-1][sum-a[i]]%MOD  * inv[2]%MOD)%MOD);
                
                dp[i][sum] %= MOD;
            }
        }
    }

    cout << dp[n][s]%MOD << endl;
    return 0;    
}

Measured memory_bytes: 74004
def main():
    N = int(input())
    X = [int(x) for x in input().split()]
    Xsort = sorted(X)
    for i in range(N):
        if X[i] <= Xsort[N//2-1]:
            print(Xsort[N//2])
        else:
            print(Xsort[N//2-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 25556
#include <stdio.h>
#include <stdbool.h>

int main(void)
{
    int n, cnt[4] = {0};
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int a;
        scanf("%d", &a);
        cnt[a % 4]++;
    }
    int dec = cnt[2]? cnt[2] - 1: 0;
    if (cnt[0] >= (n - dec) / 2) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 128
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;


public class Main {
     
	public static void main (String[] args) {
	Scanner s=new Scanner(System.in);
	long n=s.nextLong();
	int m=s.nextInt();
	long sum=0;
	for(int i=0;i<m;i++)
	sum+=s.nextLong();
	if(sum>n)
	System.out.println("-1");
	else 
	System.out.println(n-sum);
	}
}

Measured memory_bytes: 46468
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

L, R = map(int, input().split())

l = L % 2019

nums = set()
for i in range(min(R - L + 1, 2019)):
    nums.add((l + i) % 2019)
# print(l, r)
# if r <= l:
#     r += 2019
ans = 2018
for i in nums:
    for j in nums:
        if i == j:
            continue
        ans = min(ans, (i * j) % 2019)
print(ans)


Measured memory_bytes: 9548
import java.util.*;
import java.awt.*;

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

    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    long K = sc.nextLong();

    if (K % 2 == 0) {
      System.out.println(A-B);
    } else {
      System.out.println(B-A);
    }
  }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RREP(i,n) for (int i=n-1;i>=0;i--)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=2e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

vector<int> ans;
ii d[MAXn];
int val[MAXn];
vector<ii> e[MAXn];
bool vis[MAXn];
int dfs(int x){
    vis[x] = true;
    int ret = val[x];
    for (auto i:e[x]) {
        int to = i.X, id = i.Y;
        if (!vis[to]) {
            int tmp = dfs(to);
            if (tmp) ans.eb(id);
            ret ^= tmp;
        }
    }
    return ret;
}
int main(){
    IOS();
    int n,m;
    cin >> n >> m;
    REP (i,n) cin >> d[i].X >> d[i].Y;
    sort(d,d+n);
    val[0] = d[0].Y;
    REP1 (i,n-1) val[i] = d[i].Y^d[i-1].Y;
    val[n] = d[n-1].Y;
    REP (i,m) {
        int l,r;
        cin >> l >> r;
        l = int(lower_bound(d,d+n,ii(l,0))-d);
        r = int(upper_bound(d,d+n,ii(r,1))-d);
        e[l].eb(r,i);
        e[r].eb(l,i);
    }
    REP (i,n) {
        if (!vis[i]) {
            if (dfs(i)) return cout << -1 << endl,0;
        }
    }
    sort(ALL(ans));
    cout << SZ(ans) << endl;
    REP (i,SZ(ans)) cout << ans[i] + 1 << " \n"[i==SZ(ans)-1];
}


Measured memory_bytes: 18044
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <atcoder/all>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
using namespace atcoder;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)

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

lli gcd2(lli x, lli y)
{
    lli t;
    while (y != 0)
        t = x % y, x = y, y = t;
    return (x);
}

lli lcm2(lli x, lli y)
{
    lli xy = x * y;
    if (xy < 0)
        xy = -xy;
    return (xy / gcd2(x, y));
}
lli m = 1e9 + 7;
int main(void)
{
    int K;
    cin >> K;
    for (int i = 0; i < K; i++)
    {
        cout << "ACL";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <map>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

#define ALL(V) (V).begin(),(V).end()

using namespace std;

typedef pair<int,int> ii_t;

#define MAX 100010
#define RMAX 1000
char is_prime[MAX];
#define PMAX 100000
int prime[PMAX];

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
  return 0;
}

Measured memory_bytes: 256
from collections import Counter
s = input()
x = Counter(s).most_common()
ans = 100
for p in x:
    ch = p[0]
    t = list(s)
    num = 0
    while set(t) != set(ch):
        num += 1
        temp = tuple(t)
        k = len(t)
        for i in range(k-1):
            if temp[i+1] == ch:
                t[i] = ch
        t = t[:-1]
    ans = min(num, ans)
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
template <class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >> p.second;
	return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
	rep(i, v.size()) { is >> v[i]; }
	return is;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
ll mod                = 1e9 + 7;
bool check(int state) {
	for (int i = 0; i < 10; i++) {
		if ((1 << i) & state and (1 << (i + 1) & state)) {
			return true;
		}
	}
	return false;
}
int main() {
	int h, w, k;
	ll ans = 0LL;
	cin >> h >> w >> k;
	VV dp(h + 1, V(w, 0LL));
	dp[0][0] = 1LL;
	rep(i,h){
		rep(bit,(1<<(w-1))){
			if (check(bit)) continue;

			rep(j, w) {
				dp[i][j] %= mod;
				if(j!=w-1 and (bit & (1<<j))){
						dp[i+1][j + 1] += dp[i][j];
				}else if(j!=0 and (bit&(1<<(j-1)))){
					dp[i + 1][j - 1] += dp[i][j];
				}else{
					dp[i + 1][j] += dp[i][j];
				}
				
				
			}
		}
	}
	cout << dp[h][k-1]%mod << endl;
}

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

using namespace std;

int main(){
    int n;
    
	cin >> n;
    std::vector<int> l(n,0);

    int ans = 0;
    long i = 0;
    while(i<n){
        cin >> l[i];
        i++;
    }
    std::sort(l.begin(), l.end());
    std::vector<int> l1(n,0);
    l1 = l;
    l1.erase(std::unique(l1.begin(), l1.end()), l1.end());
    int ss = l1.size();
    std::vector<int> l2(ss,0);
    i = 0;
    int j = 0;
    while(i<n){
        if(l[i]==l1[j]) l2[j]++;
        if(n>i+1) if(l[i]!=l[i+1]) j++;
        i++;
    }
    i = 0;
    while(i<ss-2){
        j = i+1;
        while(j<ss-1){
            int n = j+1;
            while(n<ss){
                if(l1[i]+l1[j] > l1[n]) ans += l2[i] * l2[j] * l2[n];
                //cout << l1[i] << l1[j] << l1[n] << endl;
                //cout << l2[i] * l2[j] * l2[n] << endl;
                n++; 
            }
            j++;
        }
        i++;
    }
    i = 0;
    while(i<ss){
        //cout << l2[i] << endl;
        i++;
    }
    cout << ans;
}

Measured memory_bytes: 3556
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int n;
	vector<int> vec1,vec2,vec3,vec4;
	cin >> n;
	for (int i = 0; i < n; i += 2) {
		int a, b;
		cin >> a >> b;
		bool flag1 = false;
		for (auto itr = vec1.begin(); itr != vec1.end(); itr++) {
			if (*itr == a) {
				vec2[distance(vec1.begin(), itr)] += 1;
				flag1 = true;
				break;
			}
		}
		if (flag1 == false) {
			vec1.push_back(a);
			vec2.push_back(1);
		}
		flag1 = false;
		for (auto itr = vec3.begin(); itr != vec3.end(); itr++) {
			if (*itr == b) {
				vec4[distance(vec3.begin(), itr)] += 1;
				flag1 = true;
				break;
			}
		}
		if (flag1 == false) {
			vec3.push_back(b);
			vec4.push_back(1);
		}
	}
	auto it1 = max_element(vec2.begin(), vec2.end());
	auto it2 = max_element(vec4.begin(), vec4.end());
	int repnum1 = n / 2 - *it1;
	int repnum2 = n / 2 - *it2;
	if (vec1[distance(vec2.begin(), it1)] == vec3[distance(vec4.begin(), it2)]) {
		vec2.erase(it1);
		vec4.erase(it2);
		if (vec2.size() == 0) {
			repnum2 = n / 2;
		}
		else {
			auto it3 = max_element(vec2.begin(), vec2.end());
			auto it4 = max_element(vec4.begin(), vec4.end());
			repnum2 = n/2-max(*it3, *it4);
		}
	}
	cout << repnum1 + repnum2 << endl;
	//cin >> repnum1;
	return 0;
}

Measured memory_bytes: 1152
import java.util.*;

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

        if (n * (n - 1) / 2 - (n - 1) < k) {
            System.out.println(-1);
            return;
        }

        ArrayList<String> buf = new ArrayList<String>();
        int num = (n - 2) * (n - 1) / 2;
        for (int i = 1; i < n; ++i) {
            buf.add(String.format("%d %d", 1, i + 1));
        }

        for (int i = 1; i < n; ++i) {
            boolean done = false;
            for (int j = i + 1; j < n; ++j) {
                if (num == k) {
                    done = true;
                    break;
                }
                buf.add(String.format("%d %d", i + 1, j + 1));
                num--;
            }
            if (done) {
                break;
            }
        }

        System.out.println(buf.size());
        for (String b: buf) {
            System.out.println(b);
        }
    }
}


Measured memory_bytes: 28976
#include<bits/stdc++.h>
using namespace std;
char s[10][10];
int a, b, cnt;
int x[10], y;
bool judge(int k)
{
    y = 0;
    while(k)
    {
        x[y ++] = k % 10;
        k /= 10;
    }
    for(int i = 0; i < y; i ++)
        if(x[i] != x[y - 1 - i]) return 0;
    return 1;
}

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt","w",stdout);
    scanf("%d%d", &a, &b);
    for(int i = a; i <= b; i ++)
    {
        if(judge(i)) cnt ++;
    }
    printf("%d\n", cnt);
    return 0;
}


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

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

#define REP(i,n) for(ll 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 110

signed main()
{
    ll N;
    cin >> N;
    vector<ll> cand;
    for(ll i = 1; i < 100000; ++i) {
        cand.push_back(i * i);
    }
    for(ll i = cand.size() - 1; i >= 0; --i) {
        if(cand[i] <= N) {
            printf("%lld\n", cand[i]);
            return 0;
        }
    }

    printf("1\n");
    return 0;
}


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

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

  int w[100];
  int v[1000];
  for(int i=0; i<N; i++){
    cin >> v[i] >> w[i];
  }

  int DP[N+1][W+1];

  for(int j=0; j<=W; j++)
    DP[0][j] = 0;

  for(int i=1; i<=N; i++)
    for(int j=0; j<=W; j++)
      if(j<w[i-1]){
        DP[i][j] = DP[i-1][j];
      }else{
        if(DP[i-1][j]>DP[i][j-w[i-1]]+v[i-1])
          DP[i][j] = DP[i-1][j];
        else
          DP[i][j] = DP[i][j-w[i-1]]+v[i-1];
        }

  cout << DP[N][W] << endl;

  return 0;
}



Measured memory_bytes: 7012
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define loop(i,a,b) for(int i=a; i<b; i++)
#define INF 10000000000099ll
#define mod 1000000007

struct activity{
    int a, b, c;
};

int solve(vector<activity> arr, int n)
{
    int dp[n+1][3];
    dp[1][0]= arr[1].a;
    dp[1][1]= arr[1].b;
    dp[1][2]= arr[1].c;
    for(int i=2; i<=n; i++){
        dp[i][0]= arr[i].a+ max(dp[i-1][1], dp[i-1][2]);
        dp[i][1]= arr[i].b+ max(dp[i-1][0], dp[i-1][2]);
        dp[i][2]= arr[i].c+ max(dp[i-1][0], dp[i-1][1]);
    }
    return max(dp[n][0], max(dp[n][1], dp[n][2]));
}

int main()
{
    FASTIO;
    int n;
    cin>>n;
    vector<activity> arr(n+1);
    for(int i=1; i<=n; i++){
        cin>>arr[i].a;
        cin>>arr[i].b;
        cin>>arr[i].c;
    }
    cout<<solve(arr, n);
    return 0;
}




Measured memory_bytes: 6628
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;
        Solver s = new Solver();
        for (int i = 1; i <= t; i++) {
            s.solve(i, in, out);
        }
        out.close();
    }

}

class Solver {

    static class Pair {
        int cost, dir, to;

        public Pair(int to, int cost, int dir) {
            this.cost = cost;
            this.dir = dir;
            this.to = to;
        }
    }

    ArrayList<Pair>[] v;

    int[] cost;
    boolean[] visited;
    boolean ok;

    void solve(int test, InputReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        int m = in.nextInt();
        v = new ArrayList[n];
        for (int i = 0; i < n; i++) v[i] = new ArrayList<>();
        visited = new boolean[n];
        cost = new int[n];
        while (m-- > 0) {
            int x = in.nextInt() - 1;
            int y = in.nextInt() - 1;
            int c = in.nextInt();
            v[x].add(new Pair(y, c, 1));
            v[y].add(new Pair(x, c, -1));
        }
        ok = true;
        for (int i = 0; i < n; i++) {
            if (!visited[i]) {
                cost[i] = 0;
                dfs(i);
            }
        }
        for (int i = 0; i < n; i++) if (!visited[i]) ok = false;
        out.println(ok ? "Yes" : "No");
    }

    private void dfs(int source) {
        if (!ok) return;
        visited[source] = true;
        for (Pair x : v[source]) {
            if (!visited[x.to]) {
                cost[x.to] = cost[source] + x.cost * x.dir;
                dfs(x.to);
            } else if (cost[x.to] != cost[source] + x.cost * x.dir) {
//                System.out.println("source = " + source);
//                System.out.println("x.to = " + x.to);
//                System.out.println("cost = " + Arrays.toString(cost));
//                System.out.println("x.dir = " + x.dir);
                ok = false;
                return;
            }
        }
    }
}

class InputReader {
    BufferedReader br;
    StringTokenizer st;

    public InputReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
        st = null;
    }

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

    public int nextInt() {
        return Integer.parseInt(next());
    }

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

    public String nextLine() throws IOException {
        return br.readLine();
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 84512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000003
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int mod_pow(Int x, Int a, Int m = MOD){
    if(a == 0)return 1;
    Int res = mod_pow(x, a / 2, m);
    res = res * res % m;
    if(a % 2)res *= x;
    return res % m;
}

Int inv(Int x, Int m = MOD){
    return mod_pow(x, m-2, m);
}

Int fact[1080000];
Int revfact[1080000];
Int rev[1080000];

void init(){
    Int m = MOD;
    fact[0] = 1;
    revfact[0] = 1;
    rev[0] = 0;
    rev[1] = 1;
    for(int i = 1;i < 1080000;i++){
        fact[i] = fact[i-1] * i % m;
        if(i>1)rev[i] = MOD / i * (MOD-rev[MOD % i]) % MOD;
        revfact[i] = revfact[i-1] * rev[i] % MOD;
    }
}

Int nCk(Int n, Int k){
    if(n < k)return 0;
    return fact[n] * revfact[n-k] % MOD * revfact[k] % MOD;
}

Int solve(Int x, Int d, Int n){
    if(d == 0)return mod_pow(x, n);
    Int from = x * inv(d) % MOD;
    Int to = from + n-1;
    if(to >= MOD || from == 0)return 0;
    Int ff = fact[from-1] * mod_pow(d,from-1) % MOD;    
    Int tt = fact[to] * mod_pow(d,to) % MOD;
    return tt * inv(ff) % MOD;
}
Int q, x, d, n;
int main(){
    init();
    cin >> q;
    for(int i =0;i < q;i++){
        cin >> x >> d >> n;
        cout << solve(x, d, n) << endl;
    }
    return 0;
}                

Measured memory_bytes: 26240
#include <iostream>

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

    if (n % 10 == 7)
    {
        std::cout << "Yes";
        return 0;
    }

    if ((n / 10) % 10 == 7)
    {
        std::cout << "Yes";
        return 0;
    }

    if ((n / 100) == 7)
    {
        std::cout << "Yes";
        return 0;
    }

    std::cout << "No";
    return 0;
}

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

int main() {
	string S, T;
	cin >> S >> T;
	int N = S.length();
	map<char, char> CS;
	map<char, char> CT;
	for (int i = 0; i < N; i++) {
		if (CS.find(S[i]) == CS.end() && CT.find(T[i]) == CT.end()) {
			CS[S[i]] = T[i];
			CT[T[i]] = S[i];
		}
		else {
			if (T[i] != CS[S[i]]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 776
s=int(input())

f=int(s/100)
l=s%100
ans=""
#YYMM
if l>0 and l<13:
  if f>0 and f<13:
    ans="AMBIGUOUS"
  else:
    ans="YYMM"
else:
  if f>0 and f<13:
    ans="MMYY"
  else:
    ans="NA"
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi p(n);
    rep(i, n) cin >> p[i];
    int ans = 0;
    for (int i = 1; i < n-1; ++i) {
        if ((p[i-1] - p[i]) * (p[i] - p[i+1]) > 0) ++ans;
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  map<int, int> a;
  int a_i;
  for (int i = 0; i < N; i++) {
    cin >> a_i;
    a[a_i]++;
  }
  vector<int> values(a.size());
  int j = 0;
  for (auto t : a) {
    values.at(j) = t.second;
    j++;
  }
  sort(values.begin(), values.end());

  
  if ((int)a.size() - K <= 0) {
    cout << 0 << endl;
    return 0;
  }
  int ans = 0;
  for (int i = 0; i < (int)a.size() - K; i++) {
    ans += values.at(i);
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 10368
#include<iostream>
#include<string>
#include<vector>

using namespace std;

typedef long long int llint;

llint X;

int main() {
	cin >> X;
	llint ans = 0;
	llint now = 100;
	while (now < X) {
		ans++;
		now = (llint)(now * 1.01);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3652
# include <cstdio>
# define rep(i , n ) for ( int i =0; i < n ; i ++)
int N ,C , X ;
int D [30][39];
int t [3][30];
int main ()
{
scanf ("%d %d " ,&N ,& C );
rep (i , C ) rep (j , C ) scanf ("%d " ,& D [ i ][ j ]);
rep (i , N ) rep (j , N ) scanf ("%d " ,& X ) , t [( i + j )%3][ X -1]++;
int res=1<<30;
rep (i , C ) rep (j , C ) if ( i != j ) rep (k , C ) if ( i != k && j != k )
{
int tt =0;
rep (l , C ) tt += D [ l ][ i ]* t [0][ l ];
rep (l , C ) tt += D [ l ][ j ]* t [1][ l ];
rep (l , C ) tt += D [ l ][ k ]* t [2][ l ];
if ( tt < res ) res = tt ;
}
printf ("%d\n " , res );
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		long h = scn.nextLong();
		long w = scn.nextLong();
      	long x = h*w;
      	if(x%2==1) x++;
      	if(h==1 || w==1) x=2;
      	System.out.println(x/2);
	}
}


Measured memory_bytes: 35816
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>

#define SIZE 100005
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
 
using namespace std;


int main()
{	
	ll N;
	scanf("%lld", &N);
	char s[N][SIZE];
	char X[SIZE];
	
	ll t[N];
	for(ll i=0;i<N;i++){
		scanf("%s",&s[i]);
		scanf("%lld", &t[i]);
	}
	scanf("%s",&X);
	ll count=0;
	ll sum=0;
	for(ll i=0;i<N;i++){
		if(count==1)
		{
			sum=sum+t[i];
		}
		
		if(strcmp(s[i],X)==0)
		{	
			count++;
		}
		
		
			}
	printf("%lld", sum);
}


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

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

    char* retu = new char[nagasa+1];
    cin >> retu;

    int flag = 2;
    int mResult = 0;

    for (int i = 0; i < nagasa; i++) {

        if (retu[i] == 'O') {
            if (flag == 1) {
                ++mResult;
                flag = 2;
            }
            else {
                flag = 0;
            }
        }
        if (retu[i] == 'X') {
            if (flag == 0) {
                ++mResult;
                flag = 2;
            }
            else {
                flag = 1;
            }
        }
    }

    cout << mResult <<endl;

    delete[] retu;
    return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define fi first
#define se second
#define rep(i,N) for(int i=0;i<(int)N;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<ll> p;

ll phi(ll x) {
    ll a = x;
    ll b = x;
    for (ll k = 0; k != p.size(); ++k) {
        if (a % p[k] == 0) {
            while (a % p[k] == 0) {
                a /= p[k];
            }
            b = b / p[k] * (p[k] - 1);
        }
        if (a == 1) { break; }
    }
    return b;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    IO;

    ll z = 2018;

    ll L, R; cin >> L >> R;
    if (R / 2019 != L / 2019) { cout << 0 << endl; return 0; }
    else {
        for (ll x = L; x <= R-1; ++x) {
            for (ll y = x + 1; y <= R; ++y) {
                z = min(z, x * y % 2019);
            }
        }
        cout << z << endl;
        return 0;
    }

}

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

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

int main(){
    char data[101][101]={'\0'};
    int h,w;
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>data[i][j];
        }
    }
    
    int d2_h=0,d2_w=w;
    char data2[101][101]={'\0'};
    for(int i=0;i<h;i++){
        int cnt_h=0;
        for(int j=0;j<w;j++){
            if(data[i][j]=='.'){
                cnt_h++;
            }
        }
        if(cnt_h!=w){
            for(int k=0;k<w;k++){
                data2[d2_h][k]=data[i][k];
            }
            d2_h++;
        }
    }
    
    int d3_h=d2_h,d3_w=0;
    char data3[101][101]={'\0'};
    for(int i=0;i<w;i++){
        int cnt_w=0;
        for(int j=0;j<d2_h;j++){
            if(data2[j][i]=='.'){
                cnt_w++;
            }
        }
        if(cnt_w!=d2_h){
            for(int k=0;k<d2_h;k++){
                data3[k][d3_w]=data2[k][i];
            }
            d3_w++;
        }
    }
    
    for(int i=0;i<d3_h;i++){
        for(int j=0;j<d3_w;j++){
            cout<<data3[i][j];
        }
        cout<<endl;
    }
    return 0;
}

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

int main(void) {
    int n,m;
    cin >> n >> m;

    vector<long> a(n);
    for(auto &x: a) cin >> x;

    for(size_t i=0; i<n-1; i++)
        a[i+1] += a[i], a[i+1] %= m;

    map<int, long> mp;
    for(auto &x: a)
        mp[x%m] = mp.find(x%m)==mp.end() ? 1 : mp[x%m]+1;
    mp[0] = mp.find(0)==mp.end() ? 1 : mp[0]+1;

    long r = 0;
    for(auto &it: mp)
        r += (it.second-1)*it.second/2;

    cout << r << endl;
}


Measured memory_bytes: 4992
N = int(input())

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

nl = [0] * 3

for a in A:
  if a % 4 == 0:
    nl[2] += 1
  elif a % 2 == 0:
    nl[1] += 1
  else:
    nl[0] += 1

# 2は2個以上あればとりあえず全部繋げとけば良い、1個だけなら１としてカウント同じ
if nl[1] == 1:
  nl[0] += 1

# 2が2個以上あれば、2.....2,4,1,4,1 num_4 >= num_1の形を満たせばOK
# ２が1,0個なら、1,4,1,4,...4,1 num_4 + 1 >= num_1の形を満たせばOK
if nl[1] >= 2 and nl[2] >= nl[0]:
  print("Yes")
elif nl[1] <= 1 and nl[2] >= nl[0] - 1:
  print("Yes")
else:
  print("No")

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

using namespace std;

int main()
{
	int n, mina = INT_MAX, maxa = INT_MIN;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		mina = min(mina, a);
		maxa = max(maxa, a);
	}
	cout << maxa-mina << endl;
	return 0;
}


Measured memory_bytes: 256
///*****************************************************///
///*.......................Shadman Sakib Utshob............................*///
///*...................................................................*///
///*.........................................*///
///*...................................................*///
///*****************************************************///

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

#define Boost      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define inf         1e9+8
#define mp          make_pair
#define rep(i,n)    for(int i=0;i<n;i++)
#define repo(i,a,n) for(int i=a;i<=n;i++)
#define ll          long long
#define pii         pair<ll,ll >
#define MOD         1000000007
#define fileout     freopen("output.txt","w",stdout)
#define mem(x,i)    memset(x,i,sizeof x)
#define PI          acos(-1.0)
#define ff          first
#define ss          second
#define T          int t;cin>>t;while(t--)

int main()
{
    Boost;

    int n,i=0,x,y;
    cin>>n;
    int d[n+1];
    rep(i,n)
    {
        cin>>d[i];
    }
    sort(d,d+n);
    //cout<<d[3]<<endl;
    x=d[((n-1)/2)+1];
    y=d[(n-1)/2];
    //cout<<x<<y<<endl;
    cout<<x-y<<endl;


}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define speedrap ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int be(int a,int b,int mod) {if(b == 0) return 1; if(b%2 == 1) return (a*be(a,b-1,mod))%mod; else return (be(a,b/2,mod)*be(a,b/2,mod))%mod;}
const int mod = 998244353;
#define PI 3.1415926535
#define pf push_front
#define pb push_back
#define bitcount __builtin_popcount
#define sc(a) scanf("%d", &a);
#define sz(s) (int)s.size()
#define eb emplace_back
#define pf push_front
const int siz = 2*(1e5 + 1);
const int logi = 21;
const double epsilon = 1e-6;
int has[siz];
int ifact[siz];
int bit[siz];
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}

bool ispalin(string s)
{
	string k = s;
	reverse(k.begin(),k.end());
	if(k == s)
	{
		return true;
	}

	return false;
}


signed main()
{
	
	speedrap

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

	int sum = 0 ;
	for(int i = 1 ; i <= n ; i++)
	{
		int x = has[i];
		sum += (x*(x-1))/2;
	}

	int val = sum;

	for(int i = 0 ; i < n ; i++)
	{
		int x = a[i];
		int v = has[x];
		sum -= (v*(v-1))/2;
		v--;
		sum += (v*(v-1))/2;
		cout<<sum<<"\n";
		sum  = val;
	}
}




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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, a, b, c, d;
char s[200005];

int main() {
    scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
    --a, --b, --c, --d;
    scanf("%s", s);

    int cnt = 0;
    for (int i = a; i <= c; ++i) {
        if (s[i] == '#') {
            if (++cnt == 2) {
                cout << "No" << endl;
                return 0;
            }
        } else {
            cnt = 0;
        }
    }

    cnt = 0;
    for (int i = b; i <= d; ++i) {
        if (s[i] == '#') {
            if (++cnt == 2) {
                cout << "No" << endl;
                return 0;
            }
        } else {
            cnt = 0;
        }
    }

    if (c > d) {
        bool ok = false;
        for (int i = b; i <= d; ++i) {
            if (s[i] == '.' && s[i + 1] == '.' && (i > 0 && s[i - 1] == '.')) {
                ok = true;
                break;
            }
        }
        if (!ok) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 384
// #include <bits/stdc++.h>
#include <iostream>
#include <ctime>
#include <vector>
#include <algorithm>

#define all(x) x.begin(), x.end()
#define pi 3.14159

using namespace std;
using ll = long long;


void solve() {
    int n, m, temp, sum{};
    cin >> n >> m;

    while(m--) {
        cin >> temp;
        sum += temp;
    }

    if(n-sum >= 0) cout << n-sum << endl;
    else cout << -1 << endl; 
}   

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

#ifndef ONLINE_JUDGE
    double st = clock();
    // freopen("input.txt", "r", stdin);
#endif

    solve();

#ifndef ONLINE_JUDGE
    // cerr <<"\ntime = " <<  (clock() - st)/CLOCKS_PER_SEC << endl;
#endif 
    return 0;
}

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

int main(void){
    int height,width;
    vector<int> vec_height,vec_width;
    cin >> height >> width;
    vec_height.push_back(height);
    vec_width.push_back(width);

    for(int i = 0;height + width;i++){
        cin >> height >> width;
        vec_height.push_back(height);
        vec_width.push_back(width);
    }
    for(int i = 0;vec_height[i] + vec_width[i];i++){
        for (int j=0;j < vec_height[i];j++){
           for(int k=0;k < vec_width[i];k++)
            printf("#");
        printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 3156
def int_raw():
    return int(input())


def ss_raw():
    return raw_input().split()


def ints_raw():
    return list(map(int, ss_raw()))


def ceil(num):
    if int(str(num)[-1]) == 0:
        return num
    return num + 10 - int(str(num)[-1])


ans = 0
max_height = 0
N = int_raw()
inputs = ints_raw()
for i in range(N):
    if max_height <= inputs[i]:
        ans += 1
    max_height = max(max_height, inputs[i])
print(ans)


Measured memory_bytes: 2568
#include <stdio.h>

int main(){
    int d, n;
    scanf("%d%d", &d, &n);
    long long base = 1;
    for(int i = 0; i < d; i++)
        base *= 100;
    printf("%lld\n", n >= 100 ? (n + 1) * base: n * base);
    return 0;
}


Measured memory_bytes: 128
from itertools import accumulate
V = [1]*(10**5+1)
P = [0]*(10**5+1)
V[0] = 0
V[1] = 0
for i in range(10**5+1):
    if V[i] == 0:
        continue
    P[i] = 1
    for j in range(2,10**5):
        if i*j >= 10**5:
            break
        V[i*j] = 0
W = [0]*(10**5+1)
for i in range(10**5+1):
    if not V[i]:
        continue
    if V[(i+1)//2] == 1:
        W[i] = 1
accW = list( accumulate(W))
Q = int( input())
for i in range(Q):
    l, r = map( int, input().split())
    print(accW[r] - accW[l-1])


Measured memory_bytes: 8868
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N; cin >> N;
	vector<pll> v(N);
	for (int i = 0; i < N; i++) cin >> v[i].fr >> v[i].sc;

	set<ll> st1, st2;
	for (int i = 0; i < N; i++) st1.insert(v[i].fr + v[i].sc);
	for (int i = 0; i < N; i++) st2.insert(v[i].fr - v[i].sc);

	ll ans = 0;
	ans = max(ans, *(st1.rbegin()) - *(st1.begin()));
	ans = max(ans, *(st2.rbegin()) - *(st2.begin()));
	cout << ans << '\n';

	return 0;
}

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

int main() {
  unsigned long long x;
  cin>>x;
   bool c =false;
  vector<unsigned long long > vec(200);
  for(unsigned long long a=0;a<200;a++){
    
   unsigned long long d=pow(a,5);
     cin>>d;
    vec.at(a)=d;
  }
  for (int i = 0; i < 200; i++) {
    for (int j = i; j < 200; j++) {
      if(vec.at(i)+vec.at(j)==x){
        cout<<j<<" "<<-i<<endl;
        c=true;
        break;
      }
      else if(vec.at(j)-vec.at(i)==x){
        cout<<j<<" "<<i<<endl;
        c=true;
        break;
      }
      
        
 
}


 if(c){
   break;
 }
}


  
    
      
  
  
  
  
}


Measured memory_bytes: 4056
// Author : MohamedSameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define IN(n) scanf("%d" , &n )
#define debug(x) cout<<#x<<" = { "<<x<<" }\n"
void fo (){fflush(stdout);}
using namespace std;
int main ()
{
   int n , x , y ;
   cin >> n >> x >> y ;
   cout << min (n * x , y ) <<"\n";
  cerr << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}


Measured memory_bytes: 256