akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
Graph G(100010);

int dfs(int X,int par){
  int ret=0;
  FORE(to,G[X]){
    if(to==par) continue;
    ret+=dfs(to,X);
  }
  if(ret>=2){
    co("First");
    exit(0);
  }
  return(ret^1);
}

int main(){
  int N;
  cin>>N;
  REP(i,N-1){
    int a,b;
    cin>>a>>b;
    --a,--b;
    G[a].PB(b);
    G[b].PB(a);
  }
  
  if(dfs(0,-1)) co("First");
  else co("Second");
  return 0;
}

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



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

    int N,A,B;
    cin>>N>>A>>B;

     if(abs(A-B)%2==0)cout << "Alice"<<endl;
     else cout << "Borys" << endl;



    



}


Measured memory_bytes: 256
#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--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int a[200010], b[200010], c[200010], d[200010];
map<int, int> mpa, mpb;

int main(){
    int n;
    cin >> n;
    rep(i, n) cin >> a[i], mpa[a[i]]++, c[a[i]]++;
    rep(i, n) cin >> b[i], mpb[b[i]]++, d[b[i]]++;
    rep(i, n) c[i+1] += c[i], d[i+1] += d[i];

    int idx = 0;
    for(auto e : mpa){
        if (e.second + mpb[e.first] > n){
            cout << "No" << endl;
            return 0;
        }
    }

    rep(i, n) idx = max(idx, c[i+1] - d[i]);

    cout << "Yes" << endl;

    rep(i, n){
        cout << b[(i+n-idx)%n] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 25396
/*
-----------------------------------------------------------------------------
Author :            ---------------------------------------------------------
    UTKARSH SAXENA  ---------------------------------------------------------
    GOOGLE          ---------------------------------------------------------
-----------------------------------------------------------------------------
*/
#include <algorithm>
#include <assert.h>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;
#define fre freopen("0.in", "r", stdin), freopen("0.out", "w", stdout)
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD 1000000007
#define LL signed long long int
#define ps(x) push_back(x)
#define scan(x) scanf("%d", &x)
#define print(x) printf("%d\n", x)
#define scanll(x) scanf("%lld", &x)
#define printll(x) printf("%lld\n", x)
#define boost ios_base::sync_with_stdio(0)
// vector<int> g[2*100000+5];int par[2*100000+5];
int main() {
  // fre;
  int N;
  string S;
  cin >> N >> S;
  int R = 0;
  LL ans = 1;
  for (int i = 2 * N - 1; i >= 0; i--) {
    char deb = 'R';
    if (S[i] == 'B') {
      if (R % 2 == 1) {
        // place L.
        deb = 'L';
        ans *= R;
        R--;
      } else {
        R++;
      }
    } else {
      if (R % 2 == 1) {
        ++R;
      } else {
        // place L.
        deb = 'L';
        ans *= R;
        --R;
      }
    }
    // cout << i << ' ' << deb << endl;
    if (R < 0) {
      cout << 0;
      return 0;
    }
    ans %= MOD;
  }
  if (R != 0) {
    cout << 0;
    return 0;
  }
  for (int i = 1; i <= N; ++i) {
    ans = ans * i % MOD;
  }
  cout << ans;
}


Measured memory_bytes: 640
#include <cstdlib>
#include <cstdio>
#include <iostream>

typedef int type;
using namespace std;
const bool isDebug = false;

void showArray(type A[], int N){
    for(int i=0; i<N; i++){
        printf("%d", A[i]);
        if(i != N-1) printf(" ");
    }
    printf("\n");
}

int bubbleSort(type A[], int N){
    bool flag_inv = true;
    int changeTime = 0;
    while(flag_inv){
        if(isDebug) showArray(A, N);
        flag_inv = false;
        for(int j=N-1; j>=1; j--){
            if(A[j] < A[j-1]){
                type tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;

                changeTime++;
                flag_inv = true;
            }
        }
    }
    return changeTime;
}

#define MAX_N 100
int N;
int A[MAX_N];
void input(){
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
}

int main(){
    input();
    int changeTime = bubbleSort(A, N);
    showArray(A, N);
    printf("%d\n", changeTime);
    return 0;
}

Measured memory_bytes: 3220
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define mod 1000000007
#define F first
#define S second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
const int N = 1e6+5;
int main()
{
	sync;
	ll n, ans = 0;
	cin >> n;
	ll a[n];
	input(a, n);
	for(ll i = 0 ; i < n; i++)
		for(ll j = i + 1; j < n ;j++)
			for(ll k = j + 1; k < n; k++)
				if(a[i] + a[j] > a[k] && a[j] + a[k] > a[i] && a[k] + a[i] > a[j] && a[i] != a[j] && a[j] != a[k] && a[k] != a[i])
					ans++;
	cout << ans;
}

Measured memory_bytes: 3612
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <queue>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int gcd(int a, int b){
   int tmp;
   while(a%b==0){
      tmp=a%b;
      a=b;
      b=tmp;
   }
}

int lcm(int a,int b){
   return a*b/gcd(a,b);
}

bool prime_number(int n){
   vector<bool> i;
   if(n < 2){
      return false;
   }
   else if(n == 2){
      return true;
   }
   if(n % 2 == 0){
      return false;
   }
   for(int i=3;i<=n/i;i+=2){
      if(n % i == 0) return false;
      return true;
   }
}

int main(){
   double a;
   while(cin>>a){
      if(a<=48) cout << "light fly" << endl;
      else if(a<=51) cout << "fly" << endl;
      else if(a<=54) cout << "bantam" << endl;
      else if(a<=57) cout << "feather" << endl;
      else if(a<=60) cout << "light" << endl;
      else if(a<=64) cout << "light welter" << endl;
      else if(a<=69) cout << "welter" << endl;
      else if(a<=75) cout << "light middle" << endl;
      else if(a<=81) cout << "middle" << endl;
      else if(a<=91) cout << "light heavy" << endl;
      else cout << "heavy" << endl;
   }
}

Measured memory_bytes: 1228
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}
int main(){
  int i,k,n,zero,b,mem[100000],j,max,count,cmax;
  do{
    scanf("%d %d",&n,&k);
    if(!n&&!k) break;
    for(i=0,j=0,zero=0;i<k;i++){
      scanf("%d",&b);
      if(b) mem[j++]=b;
      else zero=1;
    }
    qsort(mem,k,sizeof(int),cmp);
    cmax=0;
    max=j;
    i=0;
    count=1;
    do{
      while(i<(max-1)&&((mem[i]+1)==mem[i+1])){
	count++;
	i++;
      }
      if(zero&&(mem[i]+2==mem[i+1])){
	j=i+1;
	count+=2;
	while(j<(max-1)&&((mem[j]+1)==mem[j+1])){
	  count++;
	  j++;
	}
      }else{
	if(k!=1)
	  count+=zero;
      }
      if(cmax<count) cmax=count;
      count=1;
      i++;
    }while(i<max);
    printf("%d\n",cmax);
  }while(1);
  return 0;
}

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

int main(){
    int x,y,a,b,c,i,j;
    long long int s=0;
    vector<int>d;
    vector<int>e;
    vector<int>V;
    cin >> x >> y >> a >> b >> c;
    for(i=0;i<a;i++){
        cin >> j;
        d.push_back(j);
    }
    sort(d.begin(),d.end());
    sort(d.rbegin(),d.rend());
    for(i=0;i<b;i++){
        cin >> j;
        e.push_back(j);
    }
    sort(e.begin(),e.end());
    sort(e.rbegin(),e.rend());
    for(i=0;i<c;i++){
        cin >> j;
        V.push_back(j);
    }
    if(a>x){
        for(i=0;i<x;i++){
            j=d[i];
            V.push_back(j);
        }
    }
    else{
        for(i=0;i<a;i++){
            j=d[i];
            V.push_back(j);
        }
    }
    if(b>y){
        for(i=0;i<y;i++){
            j=e[i];
            V.push_back(j);
        }
    }
    else{
        for(i=0;i<a;i++){
            j=e[i];
            V.push_back(j);
        }
    }
    sort(V.begin(),V.end());
    sort(V.rbegin(),V.rend());
    for(i=0;i<(x+y);i++){
        s=s+V[i];
    }
    cout << s <<"\n";
   
    return 0;
}

Measured memory_bytes: 3316
#include <iostream>

using namespace std;

int main(){
  int K, S;
  cin >>K >> S;

  int count = 0;
  int x, y, z;
  for(x=0; x<=K; x++){
    for(y=0; y<=K; y++){
      z = S-x-y;
      if(0<=z && z<=K)
	count++;
    }
  }

  cout << count << endl;
	

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python3


def countpars(s):
    lc = 0
    rc = 0
    for ch in s:
        if ch == '(':
            lc += 1
        else:
            if lc > 0:
                lc -= 1
            else:
                rc += 1
    return (lc, rc)


n = int(input())

ssl = []
ssr = []
for i in range(n):
    (clc, crc) = countpars(input())
    if clc >= crc:
        ssl.append((clc, crc))
    else:
        ssr.append((clc, crc))

ssl.sort(key=lambda x: x[1])
ssr.sort(reverse=True)

lc = 0
rc = 0

for (clc, crc) in ssl:
    lc -= crc
    if lc < 0:
        print('No')
        exit()

    lc += clc

for (clc, crc) in ssr:
    lc -= crc
    if lc < 0:
        print('No')
        exit()
    lc += clc
        

if lc == 0:
    print('Yes')
else:
    print('No')    
    






Measured memory_bytes: 172228
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
long long knap(int pos,int weight);
int n,W;
int w[105],v[105];
long long memo[105][100005];
int main(){
  memset(memo,-1,sizeof(memo));
  cin>>n>>W;
  for(int i=0;i<n;i++){
    cin>>w[i]>>v[i];
  }
  cout<<knap(0,0)<<"\n";
  return 0;
}
long long knap(int pos,int weight){
  if(pos==n)return 0;
  if(memo[pos][weight]!=-1)return memo[pos][weight];
  if(weight+w[pos]>W)return knap(pos+1,weight);
  return memo[pos][weight]=max(knap(pos+1,weight),knap(pos+1,weight+w[pos])+v[pos]);
}


Measured memory_bytes: 82304
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;

const long long MX = 1e18;
int main() {
  long long n;
  cin >> n;

  long long ans = 1;
  bool ng = false;
  for (long long i = 0; i < n; i++) {
    long long a;
    cin >> a;
    if (a == 0) {
      cout << 0 << endl;
      return 0;
    }
    if (ng || (MX+1) / ans < a || ans * a > MX) {
      ng = true;
    }
    ans *= a;
  }

  if (ng) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
}

Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    LL n;
    cin >> n;
    string s;
    string e;
    cout << 0 << endl;
    cin >> s;
    if(s == "Vacant"){
        return 0;
    }
    cout << n-1 << endl;
    cin >> e;
    if(e == "Vacant"){
        return 0;
    }

    LL left = 0;
    LL right = n-1;
    string leftstr = s;
    string rightstr = e;

    for(int i = 2; i < 20; i++){
        LL middle = (left+right)/2;
        cout << middle << endl;
        cin >> s;
        if(s == "Vacant"){
            return 0;
        }
        e = (s=="Male"?"Female":"Male");

        if(leftstr == e && (middle-1-left)%2 == 1){
            right = middle-1;
            rightstr = e;
        }else if(leftstr != e && (middle-1-left)%2 == 0){
            right = middle-1;
            rightstr = e;
        }else if(rightstr == e && (right-(middle+1))%2 == 1){
            left = middle+1;
            leftstr = e;
        }else{
            left = middle+1;
            leftstr = e;
        }
    }    
    return 0;
}

Measured memory_bytes: 852
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

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

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

    ll r = 0;
    int s = a[n / 2];
    for (int i = 0; i < n; i++) {
        r += abs(a[i] - s);
    }

    cout << r << endl;

    return 0;
}

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

#define REP(i,n) for (int i=0;i<(n);++i)

using namespace std;

using ll = long long;

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

    int N;
    cin >> N;
    ll A_sum = 0;
    map<ll, int> count;
    ++count[0];
    ll result = 0;
    REP(_, N) {
        int A;
        cin >> A;
        A_sum += A;
        result += count[A_sum]++;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 12800
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    ns = [0 for _ in range(N)]
    for a in A:
        ns[a - 1] += 1
    
    ls = [int(ns[i] * (ns[i] - 1) / 2) for i in range(N)]
    sm = sum(ls)

    for a in A:
        print(int(sm - ls[a - 1] + (ns[a - 1] - 1) * (ns[a - 1] - 2) / 2))



# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 31860
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N=2005;
inline int read()
{
	int x=0,f=1,ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-'){f=-1;}ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline int cread()
{
	int ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	return ch-'0';
}
int n,m,q;
int map[N][N];
int sum[N][N],sum1[N][N],sum2[N][N];
inline int query(int x1,int y1,int x2,int y2)
{
	return sum[x2][y2]-sum[x2][y1]-sum[x1][y2]+sum[x1][y1];
}
inline int query1(int x1,int y1,int x2,int y2)
{
	x2--;
	return sum1[x2][y2]-sum1[x2][y1]-sum1[x1][y2]+sum1[x1][y1];
}
inline int query2(int x1,int y1,int x2,int y2)
{
	y2--;
	return sum2[x2][y2]-sum2[x2][y1]-sum2[x1][y2]+sum2[x1][y1];
}
int main()
{
	n=read(),m=read(),q=read();
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			map[i][j]=cread();
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			sum[i][j]=sum[i-1][j]+sum[i][j-1]+map[i][j]-sum[i-1][j-1];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(map[i][j]&&map[i+1][j]) sum1[i][j]=1;
			if(map[i][j]&&map[i][j+1]) sum2[i][j]=1;
			sum1[i][j]+=sum1[i-1][j]+sum1[i][j-1]-sum1[i-1][j-1];
			sum2[i][j]+=sum2[i-1][j]+sum2[i][j-1]-sum2[i-1][j-1];
		}
	for(int i=1;i<=q;i++)
	{
		int x1=read(),y1=read(),x2=read(),y2=read();x1--,y1--;
//		cout<<query(x1,y1,x2,y2)<<"\t"<<query1(x1,y1,x2,y2)<<"\t"<<query2(x1,y1,x2,y2)<<endl;
		printf("%d\n",query(x1,y1,x2,y2)-query1(x1,y1,x2,y2)-query2(x1,y1,x2,y2));
	}
	return 0;
}

Measured memory_bytes: 64640
import java.util.Scanner;
//import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		int z = scan.nextInt();
		int n = 0;
		for(int i=x/y; 0<=i; i--){
			if(x >= y * i + z * (i+1)){
				n = i;
				break;
			}
		}
		System.out.println(n);
	}
}


Measured memory_bytes: 35540
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <tuple>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll q, h, s, d;
    cin >> q >> h >> s >> d;
    ll n;
    cin >> n;

    n *= 4;

    vector<tuple<double, ll, ll>> tmp = {
        make_tuple(q, 1, q),
        make_tuple((double)h / 2, 2, h),
        make_tuple((double)s / 4, 4, s),
        make_tuple((double)d / 8, 8, d)
    };
    sort(tmp.begin(), tmp.end());

    ll ans = 0;
    REP(i, 4){
        if(get<1>(tmp[i]) <= n){
            ans += get<2>(tmp[i]) * (n / get<1>(tmp[i]));
            n = n % get<1>(tmp[i]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n;
ll k,a[N],L,R;
int main(){
    scanf("%d%lld",&n,&k);
    for(int i=0;i<n;i++){
    	scanf("%lld",&a[i]);
	} 
    sort(a,a+n);//排序，升序 
    L=-1e18,R=1e18;
    while(L+1!=R){//二分查找 
        ll Mid=(L+R)/2;//中值 
        ll cnt=0;//计数 
        for(int i=0;i<n;i++){
            if(a[i]<0){//小于0则向下找
                int l=i,r=n;
                while(l+1!=r){
                    int mid=(l+r)/2;
                    if(a[i]*a[mid]<=Mid) r=mid;
                    else l=mid;
                }
                cnt=cnt+n-r;
            }else{//向上找 
                int l=i,r=n;
                while(l+1!=r){//大于0向上找
                    int mid=(l+r)/2;
                    if(a[i]*a[mid]<=Mid) l=mid;
                    else r=mid;
                }
                cnt=cnt+l-i;
            }
        }
        if(cnt<k){
        	L=Mid;
		}else{
			R=Mid;
		} 
    }
    printf("%lld",R);
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int map[12][12],ans;
void dp(int,int);

int main(){
	int i,j;
	while(1){
		ans = 0;
		for(i = 0;i < 12;i++){
			for(j = 0;j < 12;j++){
				if(scanf("%1d",&map[i][j]) == EOF) return 0;
			}
		}
		for(i = 0;i < 12;i++){
			for(j = 0;j < 12;j++){
				if(map[i][j] == 1) {
					dp(i,j);
					ans++;
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

void dp(int x,int y){
	int i,j;
	map[x][y] = 0;
	for(i = -1;i <= 1;i++){
		for(j = -1;j <= 1;j++){
			if((i + j == -1 || i + j == 1) && x + i >= 0 && x + i < 12 && y + j >= 0 && y + j < 12 && map[x + i][y + j] == 1) dp(x + i,y + j);
		}
	}
	return;
}

Measured memory_bytes: 604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final List<Integer> list = IntStream.range(0, n)
            .mapToObj(i -> scanner.nextInt())
            .collect(Collectors.toList());

        int count = 0;
        for (int i = 0; i < n; i++) {
            final int a = list.get(i);
            for (int j = i + 1; j < n; j++) {
                final int b = list.get(j);
                if (a == b) {
                    continue;
                }
                for (int k = j + 1; k < n; k++) {
                    final int c = list.get(k);
                    if (a == c || b == c) {
                        continue;
                    }

                    if (a + b > c && a + c > b && b + c > a) {
                        count++;
                    }
                }
            }
        }
        System.out.println(count);
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

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

Measured memory_bytes: 35368
#include <stdio.h>
int main(void){
	int n,i,amari,x,in;
	long long int ans=0;
	scanf("%d",&n);
	amari=n%15;
	x=n-amari;
	in=x/15;
	
	
	for(i=0;i<in;i++){
		ans+=60+15*i*8;
	}
	if(amari!=0){
		if(amari>=1){
			ans+=1+15*in;
		}if(amari>=2){
			ans+=2+15*in;
		}if(amari>=4){
			ans+=4+15*in;
		}if(amari>=7){
			ans+=7+15*in;
		}if(amari>=8){
			ans+=8+15*in;
		}if(amari>=11){
			ans+=11+15*in;
		}if(amari>=13){
			ans+=13+15*in;
		}if(amari>=14){
			ans+=14+15*in;
		}
	}
	printf("%lld\n",ans);
	
	return 0;
}

Measured memory_bytes: 1736
from collections import deque

n = int(input())

que = deque()

for i in range(n):
    order = input()

    if order == "deleteFirst":
        que.popleft()
    elif order == "deleteLast":
        que.pop()

    else:
        order,value = order.split()
        value = int(value)
        if order == "insert":
            que.appendleft(value)
        elif order == "delete":
            try:
                que.remove(value)
            except:
                pass

print(*que)


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

int main() {
    int n, limit;
    cin >> n >> limit;
    vector<int> value(n), weight(n);
    for (int i = 0; i < n; ++i) {
        cin >> value[i] >> weight[i];
    }
    vector<vector<int>> dp(110, vector<int>(20000));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= limit; ++j) {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            dp[i + 1][j + weight[i]] = max(dp[i + 1][j + weight[i]], dp[i + 1][j] + value[i]);
        }
    }
    cout << *max_element(dp[n].begin(), dp[n].begin() + (limit + 1)) << endl;
}



Measured memory_bytes: 11588
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define INF 999999999
using namespace std;

int main(){
    int a, b; cin >> a >> b;
    if(a % 3 == 0)goto ok;
    else if(b % 3 == 0) goto ok;
    else if((a + b) % 3 == 0) goto ok;
    cout << "Impossible" << endl;
    return 0;

    ok:;
    cout << "Possible" << endl;
}


Measured memory_bytes: 764
using System;
class Program
 {
        static void Main(string[] args)
        {
    　　string a = Console.ReadLine();
    　　if(a.Equals("a") || a.Equals("i") || a.Equals("u") || a.Equals("e") || a.Equals("o")){
    　　	Console.Write("vowel");
    　　}
    　　else{
    　　	Console.Write("consonant");
    　　}
        }
 }

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

using namespace std;

typedef long long ll;
typedef long double ld;
const ld INF = 1e10;
const ld eps = 1e-9, pi = acos(-1.0);
typedef pair<ll, ll> P;

int main(){
  string s;
  cin >> s;
  for(ll now = 0;now<1<<3;now++){
    ll ans = s[0]-'0';
    for(int k=0;k<3;k++){
      if(now & (1<<k))
	ans += s[k+1] - '0';
      else
	ans -= s[k+1] - '0';
    }
    if(ans == 7){
      cout << s[0];
      for(int k=0;k<3;k++){
	if(now & (1<<k))
	  cout << "+";
	else
	  cout << "-";
	cout << s[1+k];
      }
      cout << "=7" << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

const int N = 5;

int main() {
    ll n;
    cin >> n;
    ll amin = 2e15;
    int imin;
    for (int i = 0; i < N; i++) {
        ll a;
        cin >> a;
        if (a < amin) {
            amin = a;
            imin = i;
        }
    }

    ll ans = (n - 1) / amin + 5;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>

using namespace std;

int a,b,c,d;
int main(){
    scanf("%d %d %d %d",&a,&b,&c,&d);
    printf("%d\n",min(a,b)+min(c,d));
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {

	int N = 0;
	int K=0;
	int i;
	int temp;
	int count = 0;
	vector <int> h;
	cin >> N >> K;
	for (i = 0; i < N; i++) {
		cin >> temp;
		h.push_back(temp);
		if (temp >= K) {
			count += 1;
		}
	}
	cout << count;

	return 0;
}

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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int L, R, d;
    cin>>L>>R>>d;
    int count = 0;
    REP(i, L, R+1){
        if(i%d == 0) count++;
    }
    cout << count << endl;
}

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

int main() {
    int N;
    cin >> N;
    int cnt = N/15;
    cout << N*800 - cnt*200 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main() {

    while(1) {
        int n,x,sum,count=0;
        cin>>n>>x;
        if(n==0 && x==0)break;
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= n; ++j) {
                for (int k = 1; k <= n; ++k) {
                    if(i !=j && j != k && i != k) {
                        sum = i + k + j;
                        if (sum == x)count++;
                    }
                }
            }
        }
        cout << count/6 << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  
  int n,m,Q;
  cin>>n>>m>>Q;
  int sum_[n+1][n+1]={};
  int l,r;
  REP(i,m){
    cin>>l>>r;
    sum_[l][r]++;
  }
  REPP(i,n){
    REPP(j,n){
      sum_[i][j] += sum_[i-1][j];
      sum_[i][j] += sum_[i][j-1];
      sum_[i][j] -= sum_[i-1][j-1];
    }
  }
  
  int ans;
  int p,q;
  REP(i,Q){
    cin>>p>>q;
    ans = 0;
    ans += sum_[q][q];
    ans -= sum_[p-1][q];
    ans -= sum_[q][p-1];
    ans += sum_[p-1][p-1];
    cout<<ans<<endl;
  }
    
  return 0;
}


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

#define all(C) C.begin(),C.end()
#define size(C) int(C.size())
typedef long long int Long;
typedef long double Double;
const int MAXN = 1e5 + 5;

int n, ans;

int main() {
  scanf("%d", &n);
  for(int i = 0, a; i < n; ++i) {
    scanf("%d", &a);
    while(a % 2 == 0)
      a >>= 1, ++ans;
  }

  printf("%d\n", ans);
  return 0;
}

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



void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

// https://kyopro-friends.hatenablog.com/entry/2019/01/12/231000
void solve() {
  int dp[100005]; // 石の個数が i 個のとき直後の人が勝てるか
  fill_n(dp, 100005, 0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  rep(i, n) dp[a[i]] = 1;
  rep(i, k + 1) {
    rep(j, n) {
      if (i - a[j] >= 0 && dp[i - a[j]] == 0) dp[i] = 1;
    }
  }
  cout << (dp[k] ? "First" : "Second") << endl;
}


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

using namespace std;

int main(){
	ll n, i;
	
	cin>>n;
	
	vector <ll> a(n+1);
	bool b[101]={0};
	stack <ll> house;
	
	for(i=1;i<=n;i++){
		cin>>a[i];
	}
	
	ll k=0, g;
	for(i=1;i<=n;i++){
		if(a[i]>0){
			if(!b[a[i]]){
				b[a[i]]=1;
				house.push(a[i]);	
			}
				else{
					k=i;
					break;
				}
		}
			else {
				if(b[a[i]*(-1)]){
					g=house.top();
					house.pop();
					if(a[i]*(-1)==g) b[a[i]*(-1)]=0;
						else k=i;
				}
					else{
						k=i;
						break;
					}
			}
	}
	
	if(k==0) cout<<"OK\n";
		else cout<<k<<endl;
	
}


Measured memory_bytes: 3108
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val (n, a, b) = readIntegerList()
    val vList = readLongList().sortedDescending()

    println(vList.take(a).average())

    val c =pascalTriangle()
    if (vList.first() == vList[a - 1]) {
        val maxCount = vList.count { it == vList.first() }
        var ans = 0L
        for (i in a..b) {
            ans += c[maxCount][i]
        }
        println(ans)
    } else {
        val count = vList.count { it == vList[a - 1] }
        val i = vList.lastIndexOf(vList[a - 1]) + 1
        println(c[count][count - (i - a)])
    }
}

/**
 * O(n^2): n <= 10000
 * table[n][m]: nCm
 */
fun pascalTriangle(size: Int = 2000, MOD: Long = ((1L shl 62) - 1)): Array<LongArray> {
    val table = Array(size + 1) { LongArray(size + 1) }
    table[0][0] = 1L
    for (i in 0 until size) {
        for (j in 0..i) {
            val tmp = table[i][j]
            table[i + 1][j] = (table[i + 1][j] + tmp) % MOD
            table[i + 1][j + 1] = (table[i + 1][j + 1] + tmp) % MOD
        }
    }
    return table
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 90064
n=int(input())
t,a=map(int, input().split())
h = [int(i) for i in input().split()]

ret = int(1e9)
index = 0
for i, v in enumerate(h):
    tmp = abs(a - t + v * 0.006)
    if tmp < ret:
        ret = tmp
        index = i

print(index+1)

Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return ReadLine().Split().Select(int.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;
        static void Main(string[] args)
        {
            var HW = Sarray();
            var H = HW[0];
            var W = HW[1];

            var info = new string[H + 1];
            for (var i = 0; i < H; ++i)
                info[i] = ReadLine() + 'H';
            info[H] = new string(new char[W + 1].Select(_ => '#').ToArray());
            var dp = new long[H + 1, W + 1];
            dp[0, 0] = 1;
            for (var i = 0; i < H; ++i)
            {
                for (var j = 0; j < W; ++j)
                {
                    if (info[i][j] == '.')
                    {
                        if (info[i][j + 1] == '.')
                            dp[i, j + 1] = (dp[i, j + 1] + dp[i, j]) % Mod;
                        if (info[i + 1][j] == '.')
                            dp[i + 1, j] = (dp[i + 1, j] + dp[i, j]) % Mod;
                    }
                }
            }
            WriteLine(dp[H-1,W-1]);
        }
        
    }
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int l,k; cin >> l >> k;
    vector<vector<ll>> dp(l+1,vector<ll>(2,0));
    dp[0][0]=1;
    for (int i=0;i<l;++i){
        for (int j=0;j<2;++j){
            dp[i+1][j^1]+=dp[i][j];
            if (!j&&i+k<=l) dp[i+k][j^1]+=dp[i][j];
        }
    }
    ll ans=0;
    for (int i=1;i<=l;++i) ans+=dp[i][1];
    cout << ans << '\n';
}


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

int main() {
  long long N;
  cin >> N;
  vector<tuple<long long, long long, long long>> v(N);
  for (int i = 0; i < N; i ++) {
    long long x, y, h;
    cin >> x >> y >> h;
    v.at(i) = make_tuple(h, x, y);
  }
  sort(v.begin(), v.end(), greater<tuple<long long, long long, long long>>());
  for (int i = 0; i <= 100; i++) {
    for (int j = 0; j <= 100; j++) {
      bool flag = true;
      long long h = abs(get<1>(v.at(0))-i) + abs(get<2>(v.at(0))-j) + get<0>(v.at(0));
      for (int k = 1; k < N; k++) {
        long long tmp = max(h - abs(get<1>(v.at(k))-i) - abs(get<2>(v.at(k))-j), 0LL);
        if (tmp != get<0>(v.at(k))) flag = false;
      }
      if (flag) {
        cout << i << " " << j << " " << h << endl;
        return 0;
      }
    } 
  }
}

Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int myPower(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}

const int maxn = (int) 1e5 + 10;
int a[maxn], b[maxn];

int n;

int read() {
  if (scanf("%d", &n) < 1) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", a + i, b + i);
  }
  return 1;
}

void solve() {
  long long res = 0;
  for (int i = n - 1; i >= 0; --i) {
    int rem = (a[i] + res) % b[i];
    if (rem) {
      rem = b[i] - rem;
      res += rem;
    }
  }
  printf("%lld\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


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

using ll = long long int;
using P = std::pair<int, int>;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rag(con) std::begin(con), std::end(con)

int main()
{
    int n;

    std::cin >> n;

    std::vector<int> a(n), b(n);

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

    std::sort(rag(a));
    std::sort(rag(b));

    int l = (n % 2) ? a[n / 2] : a[n / 2] + a[n / 2 - 1];
    int r = (n % 2) ? b[n / 2] : b[n / 2] + b[n / 2 - 1];

    std::cout << (r - l + 1) << std::endl;

    return 0;
}

Measured memory_bytes: 4840
let n = read_int ()
let n' = int_of_float (sqrt (float_of_int n)) + 1

let rec solve k ans =
  if k = n' then ans
  else
    let k' = n / k in
    let f = k' * k' + k' - k * k in
    solve (k + 1) (ans + k * f)

let () = Printf.printf "%d\n" (solve 1 0)


Measured memory_bytes: 3720
//Stan EXO
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll x,y,z,m,f,k;
    x=a*c;
    y=a*d;
    z=b*c;
    m=b*d;
    f=max(x,y);
    k=max(z,m);
    cout<<max(f,k);
	return 0;
}

Measured memory_bytes: 3632
N, M, K=map(int, input().split())

class UnionFindTree:
    def __init__(self, n):
        self.parent = [-1 for _ in range(n)]

    def root(self, x):
        p, seq = self.parent[x], list()
        while p >= 0:
            seq.append(x)
            x, p = p, self.parent[p]
        for c in seq: self.parent[c] = x
        return x

    def same(self, x, y): return self.root(x) == self.root(y)

    def count(self, x): return -self.parent[self.root(x)]

    def unite(self, x, y):
        if self.count(x) < self.count(y): x, y = y, x
        xr, yr = self.root(x), self.root(y)
        if xr == yr: return
        self.parent[xr] += self.parent[yr]
        self.parent[yr] = xr

friend_or_block = [0 for _ in range(N)]
friends_chain = UnionFindTree(N)

for _ in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    friends_chain.unite(a, b)
    friend_or_block[a] += 1
    friend_or_block[b] += 1

for _ in range(K):
    c, d = map(int, input().split())
    c, d = c-1, d-1
    if friends_chain.same(c, d):
        friend_or_block[c] += 1
        friend_or_block[d] += 1

print(' '.join(map(str, [friends_chain.count(i) - friend_or_block[i] - 1 for i in range(N)])))


Measured memory_bytes: 18152
#include<stdio.h>
#define H 500000
int left(int);
int right(int);
void buildMaxHeap(int *,int );
void maxHeapify(int *,int ,int );

void maxHeapify(int *A,int i,int n){
  int largest,l,r,tmp;
  l = left(i);
  r = right(i);
   
  if (l<=n && A[l]>A[i])  largest = l;
  else  largest = i;
  
  if(r<=n && A[r]>A[largest])  largest = r;
  if (largest != i){
    tmp=A[i];
    A[i]=A[largest];
    A[largest]=tmp;
    maxHeapify(A, largest,n);
  }
}
int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}
void buildMaxHeap(int *A,int n){
  int i;  
  for(i=n/2;i>0;i--) maxHeapify(A, i,n);
}
	       
int main(){
  int n,i;
  int A[H];

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  buildMaxHeap(A,n);
 
  for(i=1;i<=n;i++){
    if(i<n)    printf(" %d",A[i]);
    else printf(" %d\n",A[i]);
  }
  return 0;
}

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

using namespace std;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<pair<int, int>> a(n);
  vector<ll> s;
  s.push_back(0);
  for(int i = 0; i < n; i++)
    cin >> a.at(i).first >> a.at(i).second;
  sort(a.begin(), a.end());
  for(int i = 0; i < n; i++)
    s.push_back(s.at(i) + a.at(i).second);
  cout
      << a.at(distance(s.begin(), lower_bound(s.begin(), s.end(), k)) - 1).first
      << endl;
}

Measured memory_bytes: 2168
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST            ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll              long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define mii             map<int,int>
#define vi              vector<int>
#define vll             vector<long long>
#define all(a)          (a).begin(),(a).end()
#define clz(a)          __builtin_clz(a) // count leading zeroes
#define ctz(a)          __builtin_ctz(a) // count trailing zeroes
#define popc(a)         __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul             1000000007
#define rep(i,a,b)      for(int i=a;i<b;i++)
#define rfor(i,a,b)     for(int i=a; i>=b; i--)
#define debug(x)        cerr << #x << " = " << x << endl;
#define F               first
#define S               second
#define mod             998244353 
#define pll             pair<ll,ll>
#define endl            '\n'
#define deci(n)         cout<<fixed<<setprecision(n)
#define ordered_set     tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

unordered_map<ll,int> ma;
ll power(ll n, ll p)
{
    if(p == 0) return 1;
    ll x = power((n*n)%lul, p/2)%lul;
    if(p&1) return (x*n)%lul;
    return x;
}
void solve()
{
    int n; cin>>n;
    vll a(n);
    rep(i,0,n)
    {
        cin>>a[i];
        ll x = a[i];
        for(ll j=2; j*j<=a[i]; j++)
        {
            int cur = 0;
            while(x%j == 0)
            {
                cur++;
                x/=j;
            }
            if(!cur) continue;
            if(ma.count(j) == 0) ma[j] = cur;
            else ma[j] = max(ma[j],cur);
        }
        if(x>1)
        {
            if(ma.count(x) == 0) ma[x] = 1;
        }
    }
    ll lcm = 1;
    for(auto i:ma)
    {
        lcm = (lcm*power(i.F,i.S))%lul;
        lcm+=lul;
        lcm%=lul;
    }
    ll ans = 0;
    rep(i,0,n)
    {
        ans = (ans+(lcm*power(a[i],lul-2))%lul)%lul;
        ans+=lul;
        ans%=lul;
    }
    cout<<ans;
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; /*cin>>t;*/ t=1;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 768
#include <iostream>

using namespace std;
using ll = long long;

ll solve(ll n)
{
  if (n == 1) return 1;
  return 1 + 2 * solve(n/2);
}

int main(int argc, char** argv) {
  ll n; cin >> n;
  cout << solve(n) << endl;
}


Measured memory_bytes: 256