akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define IOS {ios :: sync_with_stdio(false); cin.tie(0);cout.tie(0); }
#define F first
#define S second
#define pb push_back
typedef long double ld;
#define deci(n) cout << fixed << setprecision(n);
typedef long long ll;

#define mem0(x)  memset(x,0,sizeof(x));
#define memm1(x) memset(x,-1,sizeof(x));
#define all(a) a.begin(), a.end()
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define fori2(n) for(ll i=1;i<=n;i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define forj2(n) for(ll j=1;j<=n;j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define fork2(n) for(ll k=1;k<=n;k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
const ll md = 1e9 + 7;

#define BSET(a, p) ((a) | (1ll << (p)))
#define BCHK(a, p) ((a) & (1ll << (p)))
#define BXOR(a, p) ((a) ^ (1ll << (p)));
#define BREM(a, p) (BCHK(a, p)?(BXOR(a, p)):(a))
#define BSHO(a, N) (bitset<N>(a))
// const ll N = 100005;
// ll fac[N] = {1};
// #define calfac for(ll i=1  ;i<N;i++) fac[i] = (fac[i-1]*i)%md;
// ll C[N+1][M+1]; 
// void  ncr(){
//     ll n = N,k = M; 
//     for (ll i = 0; i <= n; i++) { 
//         for (ll j = 0; j <= min(i, k); j++) { 
//             if (j == 0 || j == i)  C[i][j] = 1; 
//             else C[i][j] = C[i - 1][j - 1] +  C[i - 1][j]; 
//         } 
//     } 
// } 


#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 
// Ordered set docs:
// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}
ll modInv(ll a)
{
    return pow(a,md-2);
}
 
// ll nCr(ll n,ll r)
// {
//     return (fac[n]*modInv((fac[r]*fac[n-r])%md))%md;
// }

 
ll po(ll x,ll n){
    if(n==0) return 1;
    if(n%2==1) return (x*po(x,n-1));
    else {
        ll k=po(x,n/2);
        return (k*k);
    }
}
 
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
}
 
int32_t main(){
    IOS;
    string s;
    cin >> s;
    ll sum = 0,n=s.size();
    fori(n){
        sum += (s[i]-'0');
        sum %= 9;
    }
    if(sum%9) cout <<"No\n";
    else cout <<"Yes\n";

} 

Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
using namespace std;
using v = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}

int main(int argc, char *argv[]){
    int x; cin >> x;
    string res;
    if(x < 1200) res = "ABC";
    else res = "ARC";
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(){

int i, ans;
string s , t;
cin >> s >> t;

ans = 0;

for (i = 0; i < s.size(); i++){
  if (s.at(i) != t.at(i)){
    ans = 1;
  }
}

if (ans == 1){
  cout << "No" << endl;
}
else{
  cout << "Yes" << endl;
}

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

template <class T>
T inf = numeric_limits<T>::max();

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

  ll L,R,d;
  cin >> L >> R >> d;

  int ans = 0;
  for (int i = L; i <= R; ++i) {
    if (i % d == 0) {
      ans += 1;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3596
#include <stdio.h>

int main(){
    int x,y;
    int a,b;
    scanf("%d %d",&x,&y);

    if(y%2==0 && 2*x<= y && y<=4*x){
        printf("Yes\n");
    }else {
        printf("No\n");
    }
    // A resposta vai ser Yes se: Y é par e 2X<=Y<=4X

//    a = (4*x - y); // eh smp par
//    b = (y - 2*x); // aqui tb

//    if(a/2>=0 && b/2>=0 &&  a%2==0 && b%2==0){
//        printf("Yes\n");
//    }else{
//        printf("No\n");
//    }



return 0;
}


Measured memory_bytes: 1656
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
typedef long long ll;
  
int main(){
  ll n,ans=0,res=0;
  cin>>n;
  for(int i=0; i<n; i++) {
    ll x; cin>>x;
    ll y = sqrt(x);
    for(int j=1; j<=y; j++) {
      if(x % j == 0) res++;
    }
    if(res==1) ans++; 
    res = 0;
  }
  cout<<ans<<"\n";
}


Measured memory_bytes: 3088
#include <stdio.h>

int main(void)
{
    int n=0,count=0,min=0;
    int P[200000]={};
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&P[i]);
    }
    for(int i=0;i<n;i++){
        if(i==0){
            min=P[0];
            count+=1;
        } else {
            if(min>P[i]){
                min=P[i];
                count+=1;
            }
        }
    }
    printf("%d",count);
    return 0;
}


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

int main()
{
  int N,i,p,sum =0 ,min =100000000;
  int *x;

  scanf("%d",&N);

  x= calloc(N, sizeof(int));
  
  for(i=0;i<N;i++)
    scanf("%d",&x[i]);

  for(p=1; p <= 100; p++)
    {
      for(i=0; i<N; i++){
        sum += ((x[i]-p)*(x[i]-p)) ;
      }
      if( sum < min ){min = sum;}
    sum = 0;
    }
  printf("%d", min);

  free(x);
  return 0;
}


Measured memory_bytes: 1712
f a b n
    | a * b == n    = "Yes"
    | a == 0        = "No"
    | b > 0         = f a (b-1) n
    | b == 0        = f (a-1) 9 n
    | otherwise     = "No"

solve n = f 9 9 n

main = do
    n <- readLn
    putStrLn $ solve n

Measured memory_bytes: 508
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = [None] * (n + 1)
    for i, j in enumerate(a):
        ans[j] = i + 1
    print(*ans[1:])

if __name__ == '__main__':
    main()


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

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

vector<vector<ll>> d;
ll ans = LINF;

void rec(ll start, map<ll, ll> done, ll sum) {
    bool last = true;
    for (auto town : done) {
        if (town.second == 0) last = false;
    }

    if (last) {
        ans = min(ans, sum);
        return;
    }

    for (auto town : done) {
        if (town.second == 1) continue;

        done[town.first] = 1;
        rec(town.first, done, sum + d[start][town.first]);
        done[town.first] = 0;
    }
};

int main() {

    ll n, m, r; cin >> n >> m >> r;
    vector<ll> t(r);
    for (ll i = 0; i < r; ++i) {
        cin >> t[i];
        t[i]--;
    }

    d.resize(n, vector<ll>(n, LINF));
    for (int i = 0; i < n; ++i) {
        d[i][i] = 0;
    }
    for (ll i = 0; i < m; ++i) {
        ll a, b, c; cin >> a >> b >> c;
        --a; --b;

        d[a][b] = c;
        d[b][a] = c;
    }

    // ワーシャルフロイド
    for (ll k = 0; k < n; ++k) {
        for (ll i = 0; i < n; ++i) {
            for (ll j = 0; j < n; ++j) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    map<ll, ll> done;
    for (ll i = 0; i < r; ++i) {
        done[t[i]] = 0;
    }

    for (ll i = 0; i < r; ++i) {
        done[t[i]] = 1;
        rec(t[i], done, 0);
        done[t[i]] = 0;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3904
// Coded by- Rad0n

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define lb(a,x) (lower_bound(all(a),x)-a.begin())
#define ub(a,x) (upper_bound(all(a),x)-a.begin())
#define forn(i,n) for(ll i=0;i<ll(n);i++)
#define forr(i,n) for(ll i=ll(n-1);i>=0;i--)
#define fora(i,a,b) for(int i=int(a);i<=int(b);i++)
#define forb(i,a,b) for(int i=int(a);i>=int(b);i--)
#define test int t,o;cin>>o;for(t=1;t<=o;t++)
#define kickstart int t,o;cin>>o;for(t=1;t<=o;t++){cout<<"Case #"<<t<<": ";solve();}
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define o_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define o_multiset tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using ll=long long int;
#define mod 1000000007
mt19937 rng(time(NULL));
double p=3.1415926535897;
void solve()
{
	
	double n;
	cin>>n;
	cout<<fixed<<setprecision(10)<<2.0*p*n;
	

}

int main()
{
	
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    solve();
}


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

using namespace std;

int main(){
    vector<string> s(3);
    cin >> s[0] >> s[1] >> s[2];
    int pos = 0;
    for(int i = 0; i < 3; i++){
        s[i].push_back('0');
    }
    while(true){
        if(s[pos][0] == '0'){
            break;
        }
        int next = s[pos][0] - 'a';
        s[pos].erase(s[pos].begin());
        pos = next;
    }
    cout << (char)(pos + 'A') << endl;



	return 0;
}



Measured memory_bytes: 256
/*
*   Copyright (C) 2015 All rights reserved.
*   
*   filename: 1341.cpp
*   author: doublehh
*   e-mail: sserdoublehh@foxmail.com
*   create time: 2015-03-11
*   last modified: 2015-03-11 23:11:23
*/
#include<bits/stdc++.h>
using namespace std;

const int maxn = 4e5;
struct Point
{
	int x, y, z, f;
};
int n, m;
Point pt[maxn];
int c[maxn];
int z[maxn];

bool cmpxY(const Point &p1, const Point &p2)
{ return p1.x < p2.x || (p1.x == p2.x && p1.y > p2.y); }
bool cmpyID(int a, int b)
{ return pt[a].y < pt[b].y || (pt[a].y == pt[b].y && a > b); }

#define lowbit(p) (p&-p)
void update(int p, int x)
{
	for (; p <= m; p += lowbit(p))
		c[p] = max(c[p], x);
}
int query(int p)
{
	int ret = 0;
	for (; p; p -= lowbit(p))
		ret = max(ret, c[p]);
	return ret;
}
void cls(int p)
{
	for (; p <= m; p += lowbit(p))
		c[p] = 0;
}

int id[maxn];
void rec(int l, int r)
{
	if (r - l == 1)
		return;

	int m = (l + r) >> 1;
	rec(l, m);

	for (int i = l; i < r; i++)
		id[i] = i;
	sort(id + l, id + r, cmpyID);

	for (int i = l; i < r; i++)
	{
		if (id[i] < m) update(pt[id[i]].z, pt[id[i]].f);
		else pt[id[i]].f = max(pt[id[i]].f, query(pt[id[i]].z - 1) + 1);
	}
	for (int i = l; i < m; i++) cls(pt[i].z);

	rec(m, r);
}
int a, b, C = ~(1<<31);
int M = (1<<16) - 1;
int r()
{
	a = 36969 * (a & M) + (a >> 16);
	b = 18000 * (b & M) + (b >> 16);
	return (C & ((a << 16) + b)) % 1000000;
}

void init()
{
	n += m;
	for (int i = 0; i < m; i++)
		scanf("%d %d %d", &pt[i].x, &pt[i].y, &pt[i].z);
	for (int i = m; i < n; i++)
		pt[i].x = r(), pt[i].y = r(), pt[i].z = r();
}

void solve()
{
	for (int i = 0; i < n; i++)
	{
		pt[i].f = 1;
		z[i] = pt[i].z;
	}

	sort(pt, pt + n, cmpxY);
	sort(z, z + n);
	m = unique(z, z + n) - z;
	for (int i = 0; i < n; i++)
		pt[i].z = lower_bound(z, z + m, pt[i].z) - z + 1;
	for (int i = 1; i <= m; i++)
		c[i] = 0;

	rec(0, n);

	int ans = 0;
	for (int i = 0; i < n; i++)
		ans = max(ans, pt[i].f);
	printf("%d\n", ans);
}

int main()
{
	while (~scanf("%d %d %d %d", &m, &n, &a, &b) && m + n + a + b)
	{
		init();
		solve();
	}
}

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

int main(){
    int a1,a2,a3;
    cin >> a1 >> a2 >> a3;
    if(a1+a2+a3>=22){
        cout << "bust" << endl;
    }
    else{
        cout << "win" << endl;
    }
}

Measured memory_bytes: 256
# wrong answer

w_right, h_top, n = map(int, input().split())
w_left, h_bottom = 0, 0

for _ in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        if w_left < x:
            w_left = x
    elif a == 2:
        if w_right > x:
            w_right = x
    elif a == 3:
        if h_bottom < y:
            h_bottom = y
    elif a == 4:
        if h_top > y:
            h_top = y

if w_right >= w_left and h_top >= h_bottom:
    print((w_right - w_left) * (h_top - h_bottom))
else:
    print(0)
    


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,zan;
ll ans;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		int x;cin>>x;
		ans+=(x+zan)/2;
		if(x>0) zan=(x+zan)%2;
		else zan = 0;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};

const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};


ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

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

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

/*
//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}
*/

int main(){
  string S;
  cin >> S;
  S += "aaaaaa";
  if(S.substr(0, 4) == "YAKI") cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long Q,H,S,D,N,ans,k,kk,kkk;
int main()
{
    cin>>Q>>H>>S>>D>>N;
    k=min(Q*4,min(H*2,S));
    if(k*2<=D)cout<<k*N<<endl;
    else cout<<((N%2)*k)+N/2*D<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int n;
  cin >> n;
  vector<int> v(2*n);
  REP(i,2*n) v[i] = i+1;
  int m;
  cin >> m;
  REP(ccc,m) {
    int k;
    cin >> k;
    vector<int> tmp(2*n);
    if (k == 0) {
      REP(i,n) {
        tmp[2*i] = v[i];
        tmp[2*i+1] = v[n+i];
      }
    }else {
      REP(i,k)
        tmp[2*n-k+i] = v[i];
      REP(i,2*n-k)
        tmp[i] = v[k+i];
    }
    v = tmp;
  }
  FOR(it, v)
    cout << *it << endl;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#define il inline
#define re register
#define fo(i,j,k) for(register int i=j;i<=k;i++)
#define do(i,j,k) for(register int i=j;i>=k;i--) 
#define inf 0x7fffffff
typedef long long ll;
using namespace std;
il ll read()
{
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return f*x;	
}
int n,m,cnt; 
int a[100000];
ll sum;
/*int h[200010],dis[200010],v[200010];
int dp[1005][1005];
struct edge
{
	int v,w,next;
}e[200010*2];
il void add(int u,int v)
{
	e[++cnt].v=v;
//	e[cnt].w=w;
	e[cnt].next=h[u];
	h[u]=cnt;
}*/ 
int main()
{
	n=read(),m=read();
	fo(i,1,m)
	{
		a[i]=read();
		sum+=a[i];
	}
	if(sum>n)
	{
		printf("-1\n");
	}
	else printf("%d\n",n-sum);
	return 0;
}

Measured memory_bytes: 3736
import math
n,d = map(int, input().split())
xy = [ list(map(int, input().split())) for _ in range(n)]

cnt = 0
for i in range(n):
    dis = math.sqrt(xy[i][0] * xy[i][0] + xy[i][1] * xy[i][1])
    if d >= dis:
        cnt += 1
print(cnt)


Measured memory_bytes: 45456
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e16
using namespace std;
typedef pair<ll, ll> P;


int main(void) {
	ll n, ans = 0, num = 0;
	cin >> n;
	vector<ll>a(3*n);
	for (ll i = 0;i < 3*n;i++)cin >> a[i];
	sort(a.begin(), a.end());
	for (ll i = 3 * n - 2;;i-=2) {
		ans += a[i];
		if (++num == n)break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
		char a[100];
		int len;

		scanf("%s",a);
		len = strlen(a);

		for(int i=0;i<len;i++){
			a[i] = 'x';
		}
		printf("%s\n",a);


		return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
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; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int v[200005];

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n,k;
    cin >> n >> k;
    vector<int> a(n+1);
    rep(i,n)cin >> a[i+1];
    v[1] = 1;
    int now = 1;
    for(ll i = 1;i<=k;i++){
        int next = a[now];
        if(v[next]){
            int dis = (i+1) - v[next];
            k -= i-1;
            k %= dis;
            for( ll i = 1;i<=k;i++){
                int next = a[now];
                now = next;
            }
            cout << now << endl;
            return 0;
        }else{
            v[next] = i+1;
            now = next;
        }
    }
    cout << now << endl;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M;
vector <int> Graph[int(2e5+5)];
int Group[int(2e5+5)];
int cnt[int(2e5+5)];

int DFS(int num){
  Group[num] = num;
  queue <int> que; que.push(num);

  while (!que.empty()){
    int Q = que.front(); que.pop();
    for (int j : Graph[Q]){
      if (Group[j] != 0) continue;
      Group[j] = num;
      que.push(j);
    }
  }
  return 0;
}

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

  for (int i = 0; i < M; i++){
    int A, B; cin >> A >> B;
    Graph[A].push_back(B);
    Graph[B].push_back(A);
  }

  for (int i = 1; i <= N; i++){
    if (Group[i] != 0) continue;
    DFS(i);
  }

  for (int i = 1; i <= N; i++){
    cnt[Group[i]]++;
  }
  sort(cnt + 1, cnt + N + 1, greater<int>());
  cout << cnt[1] << endl;



  return 0;
}


Measured memory_bytes: 16444
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int mn = 1000000001;
  int mx = -1;
  int tmp;
  for(int i = 0; N > i; i++){
    cin >> tmp;
    if(mx < tmp){
      mx = tmp;
    }
    if(mn > tmp){
      mn = tmp;
    }
  }
  cout << mx - mn << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back

int main()
{
    ll n,d;
    cin>>n>>d;
    d*=2;
    d++;
    if(n%d==0)
        cout<<n/d;
    else
        cout<<n/d+1;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
using namespace std;
const int N=1e7+5;
int a[N];
ll ans=0;
int main()
{
    for(int i=1;i<=10000000;i++)
    {
        for(int j=i;j<=10000000;j+=i)
        {
            a[j]++;
        }
    }
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        ans=ans+(long long)i*a[i];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 42616
#include<stdio.h>
#define N 100
#define DISCOVERY 0
#define FINISHING 1

int n, k, l, t;
int A[N][N];
int B[N][2];
int cnt;

int searchYet() {
    int i;
    for ( i = 0; i < n; i++) {
        if(B[i][DISCOVERY] == 0) return i;
    }
    return -1;
}

void dfs(int v) {
    int i, j;
    B[v][DISCOVERY] = ++cnt;
    for ( i = 0; i < n; i++) {
        if (A[v][i] == 1 && B[i][DISCOVERY] == 0) {
            dfs(i);
        }
    }
    B[v][FINISHING] = ++cnt;
    return;
}

int main() {
    int i, j;
    int res;
    
    for ( i = 0; i < N; i++) {
        for ( j = 0; j < N; j++) {
            A[i][j] = 0;
        }
    }
    for ( i = 0; i < N; i++) {
        for ( j = 0; j < 2; j++) {
            B[i][j] = 0;
        }
    }

    scanf("%d", &n);
    for(i=0;i<n;i++) {
        scanf("%d%d",&l , &k);
        for ( j = 0; j < k; j++) {
            scanf("%d", &t);
            A[l-1][t-1] = 1;
        }
    }
    
    dfs(0);
    while(1){
        res = searchYet();
        if (res == -1) break;
        dfs(res);
    }

    for ( i = 0; i < n; i++) {
        printf("%d ", i+1);
        printf("%d %d", B[i][DISCOVERY], B[i][FINISHING]);
        printf("\n");
    }
    
    return 0;
}

Measured memory_bytes: 644
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var b = Console.ReadLine();
            var ans = "";
            if (b == "A")
            {
                ans = "T";
            }
            else if (b == "T")
            {
                ans = "A";
            }
            else if (b == "C")
            {
                ans = "G";
            }
            else
            {
                ans = "C";
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define ll long long
#define llv vector<long long>
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;i++)

using namespace std;

int main(void){
    ll n,k;
    cin >> n >> k;
    llv v (n,0);
    rep(i,k){
        ll d;
        cin >> d;
        rep(j,d){
            ll a;
            cin >> a;
            v[a-1] = 1;
        }
    }
    ll cnt = 0;
    rep(i,n) if (v[i] == 0) cnt++;
    cout << cnt;
    return 0;
}

Measured memory_bytes: 3192
N,M = map(int,input().split())
foods = [0]*M
 
for i in range(N):
  KA = list(map(int,input().split()))
  
  for a in KA[1:]:
    foods[a-1] += 1
  
cnt = 0
for j in foods:
  if j == N:
    cnt += 1
    
print(cnt)

Measured memory_bytes: 9124
import collections as col
import itertools as iter

n=int(input())
a=list(map(int,input().split()))
ans = 0
for v in iter.combinations(col.Counter(a).items(), 3):
    a, b, c = map(lambda x: x[0], v)
    if a + b > c and b + c > a and c + a > b:
        p, q, r = map(lambda x: x[1], v)
        ans += p * q * r
print(ans)

Measured memory_bytes: 9344
<?php 
$N = intval(trim(fgets(STDIN)));
$tmp = trim(fgets(STDIN));
$a = array_map("intval", explode(" ", $tmp));

$ans = 0;

//$ansの初期化 絶対に大きい値に
foreach($a as $key => $value){
	$ans += abs($value);
}
$l = 0;
$left = [];
$left[0] = 0;
foreach($a as $key => $value){
	$l += $value;
	array_push($left, $l);
}

$r = 0;
$right = [];
$right[0] = 0;
$r_a = array_reverse($a);
foreach($r_a as $key => $value){
	$r += $value;
	array_push($right, $r);
}
$right = array_reverse($right);

for($i = 1;$i<count($right)-1;$i++){
	if($ans > abs($right[$i] - $left[$i])){
		$ans = abs($right[$i] - $left[$i]);
	}
}

echo $ans . PHP_EOL;

Measured memory_bytes: 53732
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//ll dx[4] = {1, 0, -1, 0};
//ll dy[4] = {0, 1, 0, -1};

int main() {
	ll q;
	cin >> q;
	ll sum = 0;
	priority_queue<ll> mque;
	priority_queue<ll, vector<ll>, greater<ll>> Mque;
	for (int i = 0; i < q; i++) {
		int unko;
		cin >> unko;
		if (unko == 1) {
			ll a, b;
			cin >> a >> b;
			sum += b;
			Mque.push(a);
			mque.push(a);
			ll avem = mque.top(), aveM = Mque.top();
			if (avem > aveM) {
				sum += avem - aveM;
				mque.pop();
				Mque.pop();
				mque.push(aveM);
				Mque.push(avem);
			}
		} else {
			cout << mque.top() << " " << sum << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 4588
#include<iostream>

using namespace::std;
#define int long long int
#define MOD 1000000007
int ar[60];

main(){
    int n;
    cin>>n;
    for(int i=0,t;i<n;i++){
        cin>>t;
        for(int j=0;j<60;t>>=1,j++)
            ar[j]+=t&1;
    }
    int ans=0;
    for(int i=0;i<60;i++)
        ans=(ans+(((((((int)1<<i)%MOD)*(ar[i]))%MOD)*(n-ar[i]))%MOD))%MOD;//,cout<<i<<' '<<ar[i]<<'\n';
    cout<<ans<<'\n';
}

Measured memory_bytes: 256
n,m=map(int,input().split())
ab = []
for i in range(n):
    ab.append(list(map(int, input().split())))
cd=[]
for i in range(m):
    cd.append(list(map(int, input().split())))


for i in range(n):
    mnh=0
    tmp=100000000000000000000
    ans=0
    for j  in range(m):
        mnh=abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        if tmp>mnh:
            tmp=mnh
            ans=j+1
    print(ans)

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections.Generic;

public static class NagataKanaIsAGenius {
    public static void Main() {
        int n=int.Parse(Console.ReadLine());
        if(n==3){
            Console.WriteLine(61);
            return;
        }
        bool[]ng=new bool[256];
        for(int bs=0;bs<256;bs++){
            ng[bs]=IsNg(bs);
        }
        int[]dp=new int[64];
        for(int i=0;i<256;i++){
            if(!ng[i])Add(ref dp[i%64],1);
        }
        for(int i=4;i<n;i++){
            int[]swp=new int[64];
            for(int j=0;j<64;j++){
                for(int k=0;k<4;k++){
                    if(!ng[j*4+k])Add(ref swp[(j*4+k)%64],dp[j]);
                }
            }
            dp=swp.ToArray();
        }
        int ans=0;
        for(int i=0;i<64;i++){
            Add(ref ans,dp[i]);
        }
        Console.WriteLine(ans);
    }
    public static bool IsNg(int x){
        if(ContainsAGC(x)) return true;
        for(int i=0;i<3;i++){
            if(ContainsAGC(TwoBitsSwapped(x,i,i+1)))return true;
        }
        return false;
    }
    public static void BitSwap(ref int x, int i, int j){
        if((x>>i&1)!=(x>>j&1)){
            x^=1<<i;
            x^=1<<j;
        }
    }
    public static int TwoBitsSwapped(int x, int i, int j){
        BitSwap(ref x,2*i,2*j);
        BitSwap(ref x,2*i+1,2*j+1);
        return x;
    }
    public static bool ContainsAGC(int x){
        return (x>>6&3)==0&&(x>>4&3)==1&&(x>>2&3)==2
            || (x>>4&3)==0&&(x>>2&3)==1&&(x>>0&3)==2;
    }
    static int mod = 1000000007;
    public static void Add(ref int x, int y){
        x+=y;
        if(mod<=x)x-=mod;
    }
}


Measured memory_bytes: 11220
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

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

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

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

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

/*
thx
http://kmjp.hatenablog.jp/entry/2017/01/11/1030
*/
void solve(){
	int N;
	cin >> N;
	vector<bool> OP(N);
	vector<LL> A(N);
	OP[0] = false;
	cin >> A[0];
	for(int i=1;i<N;++i){
		char op;
		cin >> op >> A[i];
		OP[i] = (op=='-');
	}
	vector< vector<LL> > dp(N+1,vector<LL>(3,-LINF));
	dp[0][0] = 0;
	for(int i=0;i<N;++i){
		if( OP[i] == false){//'+' 開かない。閉じれる
			dp[i+1][2] = dp[i][2] + A[i];
			//dp[i+1][2]から一つ閉じるとdp[i+1][1]にいける
			dp[i+1][1] = max(dp[i+1][2], dp[i][1] - A[i]);
			//dp[i+1][1]から一つ閉じるとdp[i+1][0]にいける
			dp[i+1][0] = max(dp[i+1][1], dp[i][0] + A[i]);
		}else{//'-':必ず開き括弧を前につける。必ず開く。閉じれる
			dp[i+1][2] = dp[i][1] + A[i];
			//LL res1 = max(dp[i][0],dp[i][2]);//括弧をすべて閉じる
			LL res1 = dp[i][0];//前の項で括弧全部閉じてる
			dp[i+1][1] = max(dp[i+1][2], res1 - A[i]);
			dp[i+1][0] = max(dp[i+1][1], dp[i][1] + A[i]);
		}
	}
	LL ans = dp[N][0];//ここにまとまってる
	cout << ans << endl;
}

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

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 6528
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;



int main(int argc, char* argv[])
{
    char str[1205]={0};
    fgets(str, 1200, stdin);

    int len = strlen(str);
    if (str[len-1]=='\n') {
        str[--len] = '\0';
    }
    int i;
    for(i=0; i<len; i++) {
        if(str[i]>='a' && str[i]<='z') {
            str[i]+=('A'-'a');
        }
        else if(str[i]>='A' && str[i]<='Z') {
            str[i]+=('a'-'A');
        }
    }
    printf("%s\n", str);

    return 0;
}



Measured memory_bytes: 2560
NM = list(map(int, input().split()))

N = NM[0]; M = NM[1]

H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]

result = [0]*N

for i in range(M):
    if H[AB[i][0]-1]>H[AB[i][1]-1]:
        result[AB[i][1]-1] = 1
    elif H[AB[i][0]-1] == H[AB[i][1]-1]:
        result[AB[i][1]-1] = 1
        result[AB[i][0]-1] = 1
    else:
        result[AB[i][0]-1] = 1

print(N-sum(result))
            

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

#define f(i, a, b, c) for(int i = a ; i < b ; i += c)
#define fr(i, a, b, c) for(int i = a ; i >= b ; i -= c)
#define fit(it, v) for(auto it = v.begin() ; it != v.end() ; ++it)
#define frit(it, v) for(auto it = v.rbegin() ; it != v.rend() ; ++it)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define NL '\n'
#define modn 1000000007
#define EPS 1e-9

using namespace std;

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< lli > vli;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< char > vc;
typedef vector< string > vs;
typedef vector< bool > vb;
typedef set< int > si;
typedef set< ii > sii;

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

	#ifdef LOCAL_TEST
		ifstream h("in");
		ofstream g("out");
		clock_t z = clock();
	#else
		#define h cin
		#define g cout
	#endif//LOCAL_TEST

	int n, m, a, b, x, y;
	h >> n >> m >> a >> b >> x >> y;
	a--, b--, x--, y--;
	vs v(n);
	f(i, 0, n, 1)
		h >> v[i];
	int dr[] = {-1, 0, 1, 0};
	int dc[] = {0, 1, 0, -1};
	vvi dist(n, vi (m, INT_MAX));
	dist[a][b] = 0;
	deque< ii > q;
	q.pb({a, b});
	while(!q.empty()){
		int nx = q.front().first, ny = q.front().second;
		q.pop_front();
		f(i, 0, 4, 1){
			int dx = nx + dr[i], dy = ny + dc[i];
			if (dx < 0 || dx >= n || dy < 0 || dy >= m || v[dx][dy] == '#')
				continue;
			if (dist[dx][dy] > dist[nx][ny]){
				dist[dx][dy] = dist[nx][ny];
				q.push_front({dx, dy});
			}
		}
		f(i, -2, 3, 1){
			f(j, -2, 3, 1){
				int dx = nx + i, dy = ny + j;
				if (dx < 0 || dx >= n || dy >= m || dy < 0 || v[dx][dy] == '#')
					continue;
				if (dist[dx][dy] > dist[nx][ny] + 1){
					dist[dx][dy] = dist[nx][ny] + 1;
					q.pb({dx, dy});
				}
			}
		}
	}
	g << (dist[x][y] == INT_MAX ? -1 : dist[x][y]);

	#ifdef LOCAL_TEST
		cerr << "Time taken is: " << double(clock() - z) / CLOCKS_PER_SEC << NL;
		h.close();
		g.close();
	#endif//LOCAL_TEST
}


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

const ll MOD = (ll)pow(10,9)+7;

int main(){
  int s;
  cin >> s;
  vector<vector<ll>> pas(2001,vector<ll>(2001));
  pas[0][0] = 1;
  rep(i,2000){
    rep(j,2000){
      pas[i+1][j] += pas[i][j];
      pas[i+1][j] %= MOD;
      pas[i+1][j+1] += pas[i][j];
      pas[i+1][j] %= MOD;
    }
  }
  ll ans = 0;
  for(int i=1;3*i<=2000;i++){
    if(s < i*3) break;
    int h = s - 3*i;
    ans += pas[h+i-1][i-1];
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 34656
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int p1[200020], p2[200020];
int main()
{
	int n;
	cin>>n;
	string x; cin>>x;
	int c[200020];
	c[0]=0;
	for(int i=1; i<=n; i++){
		c[i]=c[i%popcount(i)]+1;
	}
	int cnt=0;
	for(int i=0; i<n; i++){
		if(x[i]=='1') cnt++;
	}
	int r1=-1;
	if(cnt-1>=1){
		r1=0;
		for(int i=0; i<n; i++){
			r1=r1*2%(cnt-1);
			if(x[i]=='1') r1=(r1+1)%(cnt-1);
		}
		p1[n-1]=1%(cnt-1);
		for(int i=n-2; i>=0; i--){
			p1[i]=p1[i+1]*2%(cnt-1);
		}
	}
	int r2=-1;
	if(cnt+1>=1){
		r2=0;
		for(int i=0; i<n; i++){
			r2=r2*2%(cnt+1);
			if(x[i]=='1') r2=(r2+1)%(cnt+1);
		}
		p2[n-1]=1%(cnt+1);
		for(int i=n-2; i>=0; i--){
			p2[i]=p2[i+1]*2%(cnt+1);
		}
	}
	for(int i=0; i<n; i++){
		if(x[i]=='1'){
			if(cnt-1==0){
				cout<<0<<endl;
				continue;
			}
			cout<<c[(r1-p1[i]+cnt-1)%(cnt-1)]+1<<endl;
		}else{
			cout<<c[(r2+p2[i]+cnt+1)%(cnt+1)]+1<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 6092
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
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; } return false; }
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

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

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

    priority_queue<int> p;
    rep(i,n) p.push(a[i]);
    rep(j,m){
        int q=p.top();
        p.pop();
        p.push(q/2);
    }

    
    ll sum=0;
    rep(i,n){
        sum+=p.top();
        p.pop();
    }

    cout<<sum<<endl;
    return 0;

}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  
  for(int i = 0; i < N; i++ ){
    cin >> a.at(i);
  }
  
  int count = 0;
  while( true ){
    for( int i = 0; i < N; i++ ){
      if( a.at(i) % 2 == 1 ){
        cout << count << endl;
        return 0;
      }else{
        a.at(i) /= 2;
      }
    }
    count++;
  }
  
}


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

int main(){
    int n;
    cin >> n;
    if(n==1){
        cout << "Hello World" << endl;
    }
    else if(n==2){
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
    return 0;
}

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


void solve(long long N, long long D){
    long long ans;
    if(N%(2*D+1)==0){ans=N/(2*D+1);}
    else{ans=N/(2*D+1)+1;}
    printf("%lld\n",ans);
}


int main(){
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    solve(N, D);
    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
T = gets.split.map(&:to_i)
M = gets.to_i
P,X = M.times.map { gets.split.map(&:to_i) }.transpose

sum_t = T.inject(:+)
M.times do |i|
  # 合計からブースト問題の時間を差し替える
  p sum_t - T[P[i]-1] + X[i]
end

Measured memory_bytes: 1788
N = int(input())
S = input().strip()

dp = [[0 for _ in range(N+1)] for _ in range(N+1)]

for i in reversed(range(N)):
    for j in reversed(range(N)):
        if i >= j:
            continue
        if S[i] != S[j]:
            dp[i][j] = 0
        if S[i] == S[j]:
            dp[i][j] = dp[i+1][j+1] + 1

ans = 0
for i in range(N):
    for j in range(N):
        if i >= j:
            continue
        now = min([dp[i][j], j-i])
        ans = max(ans, now)

print(ans)


Measured memory_bytes: 247944
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int N,M,max = 0;
	N = sc.nextInt();
	M = sc.nextInt();
	int n[] = new int [N];
	int m[] = new int [M];
	int vote[] = new int [N];
	for(int i = 0;i < N;i++){
		n[i] = sc.nextInt();
		vote[i] = 0;
	}
	for(int i = 0;i < M;i++){
		m[i] = sc.nextInt();
	}
	for(int i = 0;i < M;i++){
		for(int k = 0;k < N;k++){
			if(m[i] >= n[k]){
				vote[k]++;
				break;
			}
		}
	}
	for(int i = 0;i < N;i++){
		if(vote[max] < vote[i])max = i;
		//System.out.println(vote[i]);
	}
	System.out.println(max + 1);
	}
}

Measured memory_bytes: 33660
n = int(input())
lister = []
for i in range(n):
    lister.append([int(i) for i in input().split()])
 
if n % 2 == 1:
    lister.sort(key=lambda x:x[0])
    miner = lister[n//2][0]
    lister.sort(key=lambda x:x[1])
    maxer = lister[n//2][1]
    print(maxer- miner + 1)
else:
    lister.sort(key=lambda x:x[0])
    miner = lister[n//2 - 1][0]
    miner += lister[n//2][0]
    lister.sort(key=lambda x:x[1])
    maxer = lister[n//2][1]
    maxer += lister[n//2 - 1][1]
    print(1 + (maxer- miner))


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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

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

  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> e;
  map<ll, ll> mp;
  rep(i, n) {
    cin >> a[i];
    if(mp[a[i]]==1) e.push_back(a[i]);
    if(mp[a[i]]==3) e.push_back(a[i]);
    mp[a[i]]++;
  }
  sort(e.begin(), e.end(), greater<ll>());
  if (e.size() < 2) {
    cout << 0 << endl;
    return 0;
  }
  cout << e[0] * e[1] << endl;
  return 0;
}


Measured memory_bytes: 7296
from collections import Counter

n,m = map(int, input().split())
x = list(map(int, input().split()))
mod_count = [0] * m
pair = [0] * m
count = Counter(x)

for i in x:
  mod_count[i%m] += 1
for k,v in count.items():
  pair[k%m] += v // 2
ans = mod_count[0] // 2
if m % 2 == 0:
  ans += mod_count[m//2] // 2
for i in range(1,(m+1)//2):
  a1,a2 = mod_count[i], pair[i]
  b1,b2 = mod_count[m-i], pair[m-i]
  if a1 > b1:
    if a1 - a2 * 2 >= b1:
      ans += a2 + b1
    else:
      ans += (a1 + b1) // 2
  else:
    if b1 - b2 * 2 >= a1:
      ans += b2 + a1
    else:
      ans += (a1+b1) // 2
print(ans)
    

Measured memory_bytes: 21204
import heapq as he

n,m = map(int,input().split())
a = list(map(int,input().split()))
a = list(map(lambda x: x*(-1),a))
he.heapify(a)

for i in range(m):
    he.heappush(a,he.heappop(a)*(-1)//2*(-1))

print(sum(a)*(-1))

Measured memory_bytes: 20412
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define IO ios::sync_with_stdio(0);cin.tie(0); cout.tie(0) ; 
#define adsw  ll Test ;cin >> Test; while(Test--)
using namespace std;

int main(){ IO 
  
 ll x;
 cin >> x;
 
 if(x>=400&&x<=599) cout<<"8\n";
 else if(x>=600&&x<=799) cout<<"7\n";
 else if(x>=800&&x<=999) cout<<"6\n";
 else if(x>=1000&&x<=1199) cout<<"5\n";
 else if(x>=1200&&x<=1399) cout<<"4\n";
 else if(x>=1400&&x<=1599) cout<<"3\n";
else  if(x>=1600&&x<=1799) cout<<"2\n";
 else if(x>=1800&&x<=1999) cout<<"1\n";
 
 
 
 
 
 
 
 
 
 
 
 
   
    return 0;
} 


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

#define MAX_N 200002
typedef long long ll;
typedef pair<ll, ll> P;

vector <P> v;
ll x, y, n, k;

int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        v.push_back(make_pair(x, y));
    }
    sort(v.begin(), v.end());
    /*for(int i=0;i<v.size();i++)
        cout << v[i].first << " " << v[i].second << "\n";*/
    ll sum = 0;
    for(int i=0;i<v.size();i++){
        sum += v[i].second;
        if(k <= sum){
            cout << v[i].first <<"\n";
            return 0;
        }
    }
    cout << v[v.size()-1].first<<"\n";
    return 0;
}


Measured memory_bytes: 2420