akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define BPhuong ""
#define maxn 3002
#define maxm
#define fi(i,a,b) for(int i = a; i<= b; i++)
#define fid(i,a,b) for(int i = a; i>= b; i--)
#define se second
#define f first
#define ll long long
#define pii pair<int, int>
#define pb push_back
#define bit(x, i) ((x>>i)&1)
#define oo 1e9
struct data{
    int x, y, z;
};
using namespace std;
int l[maxn][maxn];
string s, t, c;
char luu[maxn];
void ngh(int n, int m)
{
    if(n == 0 || m == 0) return;
    if(s[n] == t[m])
    {
        c = s[n]+c;
        n--; m--;
        ngh(n, m);
    }
    else
    {
        if(l[n-1][m] > l[n][m-1]) ngh(n-1, m);
        else ngh(n, m-1);
    }
}
void nhap(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);
    //freopen(BPhuong".inp","r",stdin);
    //freopen(BPhuong".out","w",stdout);
    //getline(cin, );
    getline(cin, s);
    getline(cin, t);
    //cin >> s >> t;
}

void xuli(){
    int n = s.length();
    int m = t.length();
    s = ' ' + s;
    t = ' ' + t;
    fi(i, 1, n)
        fi(j, 1, m)
        {
            if(s[i] == t[j])
            {
                l[i][j] = l[i-1][j-1] + 1;
                luu[l[i][j]] = s[i];
            }
            else{
                    l[i][j] = max(l[i-1][j], l[i][j-1]);
                    if(l[i-1][j] > l[i][j-1]) luu[l[i][j]] = luu[l[i-1][j]];
                    else luu[l[i][j]] = luu[l[i][j-1]];
            }
        }
    ngh(n, m);
    cout << c;
}

int main(){
    nhap();
    xuli();
}


Measured memory_bytes: 39160
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
constexpr int INF = 1001001001;
constexpr long long INFL = (1LL<<60);
constexpr double eps = (1e-9);

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

  vector<int> a(5);
  rep(i, 5) cin >> a[i];

  rep(i, 5) {
    if (a[i] == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 3640
// In The Name Of God
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long
#define ll long long
#define for2(a,b,c) for(int a = b; a < c; a++)
#define setp cout << fixed << setprecision(7)
#define endl "\n"
#define minit(a,b) a = min(a,b)
#define maxit(a,b) a = max(a,b)
#define PII pair<int,int>
#define Vec vector<int>
#define error(x) cerr << #x << " = " << (x) << endl;

const ll inf = ~0ull/4;
const int maxn = 210000;

/////////////////////////////////////////////////////////////////////

int a[50];

int32_t main()
{
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	int n; cin >> n;
	for2(i,0,n)  cin >> a[i];
		//a[i] = 1e16 + 1000;

	int k = 0;
	while(1){
		bool found = 0;
		for2(i,0,n) if(a[i] >= n){
			for2(j,0,n) if(j != i) a[j] += a[i]/n;
			k += a[i]/n;
			a[i] %= n;
			found = 1;
		}
		if(!found) break;
	}
	cout << k << endl;
	return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=1e5+10;
const int mod=1e9+7;
struct A
{
    int x,y,h;
} a[120];
int main()
{
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>a[i].x>>a[i].y>>a[i].h;
    }
    int p=0;
	while(a[p].h==0) p++;
    for(int i=0; i<=101; i++)
    {
        for(int j=0; j<=101; j++)
        {
            int f=0;
            int tem=abs(a[p].x-i)+abs(a[p].y-j)+a[p].h;
            for(int k=0; k<n; k++)
            {
                int ans=tem-abs(a[k].x-i)-abs(a[k].y-j);
                if(ans<0)
                {
                    ans=0;
                }
                if(ans!=a[k].h)
                {
                    f=1;
                    break;
                }
            }
            if(f==0)
            {
                cout<<i<<' '<<j<<' '<<tem<<endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,x,now=0,ans=1;cin>>n>>x;
	while (n--){
		int p;cin>>p;now+=p;
		if(now<=x) ans++;
	}
	cout<<ans;
}

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

int main()
{
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;

  int na=0,nb=0,nab=0;

  if(a+b>2*c)
  {
    if(x>y)
    {
      nab = 2*y;
      x -= y;
      y = 0;
      if(a>2*c)
      {
        nab += 2*x;
      }
      else
      {
        na += x;
      }
    }
    else
    {
      nab = 2 * x;
      y -= x;
      x = 0;
      if(b>2*c)
      {
        nab += 2*y;
      }
      else
      {
        nb += y;
      }
    }
  }
  else
  {
    na = x;
    nb = y;
  }
  cout << (a*na+b*nb+c*nab) << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int n = Integer.parseInt(br.readLine());
		int k = Integer.parseInt(br.readLine());
		int x = Integer.parseInt(br.readLine());
		int y = Integer.parseInt(br.readLine());
 
		int cost = n>k ? k*x + (n-k)*y : n*x;
		System.out.println(cost);
	}
}

Measured memory_bytes: 8020
#include<cstdio> 
#include<cmath> 
using namespace std;
long long n,ans;
int s;
int main(){
    scanf("%lld",&n);
    for(int i=sqrt(n);i>0;--i) 
        if(n%i==0){
            ans=n/i;
            break;
        }
    while(ans>0){
        ++s;
        ans/=10;
    }
    printf("%d\n",s); 
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main(){
  int m1,d1,m2,d2,ans;
  cin >> m1 >> d1;
  cin >> m2 >> d2;
  if(d1+1 == d2){
    ans = 0;
  }else{
    ans = 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;

int main()
{
	int bit[64] = {};
	int n, i, x, j, m, coun;
	cin >> n;
	vector<int> cpp[n];

	r(i, n)
	{
		cin >> m;
		r(j, m)
		{
			cin >> x;
			cpp[i].push_back(x);
		}
	}

	int com, q, key;
	bool flag;
	cin >> q;

	while (q--)
	{
		cin >> com >> key;;
		switch (com)
		{
		case 0:
			if (bit[key] == 0)cout << "0" << endl;
			else cout << "1" << endl;
			break;
		case 1:
			r(i, cpp[key].size())
				bit[cpp[key][i]] = 1;
			break;
		case 2:
			r(i, cpp[key].size())
				bit[cpp[key][i]] = 0;
			break;
		case 3:
			r(i, cpp[key].size())
			{
				if (bit[cpp[key][i]] == 1)bit[cpp[key][i]] = 0;
				else bit[cpp[key][i]] = 1;
			}
			break;
		case 4:
			flag = true;
			r(i, cpp[key].size())
			{
				if (bit[cpp[key][i]] == 0) 
				
					flag = false;
			}
			if (flag)cout << "1" << endl;
			else cout << "0" << endl; 
			
			break;
		case 5:
			flag = false;
			r(i, cpp[key].size())
			{
				if (bit[cpp[key][i]] == 1)
				{
					flag = true; 
				}
				
			}if (flag)cout << "1" << endl;
				else cout << "0" << endl;
			break;
		case 6:
			flag = true;
			r(i, cpp[key].size())
			{
				if (bit[cpp[key][i]] == 1)
				{
					flag = false; 
				}
			
			}	if (flag)cout << "1" << endl;
				else cout << "0" << endl;
			break;
		case 7:
			coun = 0;
			r(i, cpp[key].size())
				if (bit[cpp[key][i]] == 1) 
					coun++;
			cout << coun << endl;
			break;
		case 8:
			unsigned long long sum = 0;
			unsigned long long z = 1;
			unsigned long long val[64];
			for (int i = 0; i < 64; i++)
			{
				val[i] = z;
				z *= 2;
			}
			r(i, cpp[key].size())
				if (bit[cpp[key][i]] == 1)
					sum += val[cpp[key][i]];
			cout << sum << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3160
S=input()
T=input()
start=[-1]*26
goal=[-1]*26
ans='Yes'
for i in range(len(S)):
    a=ord(S[i])-ord('a')
    b=ord(T[i])-ord('a')
    if start[a]!=-1 or goal[b]!=-1:
        if start[a]!=b or goal[b]!=a:
            ans='No'
    else:
        start[a]=b;
        goal[b]=a;
print(ans)

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

int main()
{
    int l;
    cin >> l;
    double x = (double) l / 3;
    cout << setprecision(15) << x * x * x << endl; 
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
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 (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	int x;
	cin>>x;
	FOR(i,1,1000){
		if(x*i%360==0){
			cout<<i<<endl;
			return ;
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

int n, i, j, ans;
string s;
char c;

bool any_dif(string aux, char c) {
    for (int i = 0; i < aux.size(); i++)
        if (aux[i] != c)
            return true;
    return false;
}

int solve(char c) {
    int ans = 0, i;
    string aux;

    aux = s;
    while (!aux.empty() && any_dif(aux, c)) {
        ans++;
        for (i = 0; i + 1 < aux.size(); i++) {
            if (aux[i] == c || aux[i + 1] == c)
                aux[i] = c;
        }
        aux.pop_back();
    }

    return ans;
}

int main()
{
    //freopen("test.in","r",stdin);

    cin >> s;
    ans = s.size() - 1;

    for (c = 'a'; c <= 'z'; c++) {
        ans = min(ans, solve(c));
    }

    cout << ans;

    return 0;
}


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

            using namespace std;
            typedef long long ll;




int main() {

   ll n , T;

   cin >> n >> T ;

   ll W[n];
   ll V[n];
   T=T+1;
   ll C[n][T];
   for(int i=0 ; i<n ; i++){
    cin >> W[i] >> V[i] ;
                           }
                           for(int i=0 ; i<n ; i++){
                  for(int j=0 ; j<T ; j++){
                    C[i][j] =0;
                  }

              }

                           for(int i=W[0] ; i<T ; i++){


                                C[0][i]=V[0];



                        }

           

              for(int i=1 ; i<n ; i++){
                  for(int j=1 ; j<T ; j++){

                      if(W[i]>j){
                         C[i][j]= max(C[i-1][j],C[i][j-1]);
                      }
                      else {
                 ll Y= max(V[i]+C[i-1][j-W[i]],C[i][j-1]);
                 //cout << j << endl;
                // cout << V[i] << " "<< C[i-1][j-W[i]] << " "<< C[i][j-1] << endl;
                        C[i][j]= max(C[i-1][j],Y);
                    //    cout <<  C[i][j] <<endl;
                      }

                           }
                           }
                  

                           cout << C[n-1][T-1];

return 0;
}


Measured memory_bytes: 81568
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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; }

using Graph=vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const int MAX = 500000;
const int MOD = 1000000007;

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

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

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll RepeatSquaring(ll N, ll P, ll M) {
	if (P == 0) return 1;
	if (P % 2 == 0) {
		ll t = RepeatSquaring(N, P / 2, M);
		return t * t% M;
	}
	return N * RepeatSquaring(N, P - 1, M);
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

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

	COMinit();

	ll n;
	cin >> n;
	ll a, b;
	cin >> a >> b;
	ll ans = 0;
	ll sum = 1;

	ans += RepeatSquaring(2, n, MOD);
	ans -= 1;
	ans %= MOD;

	ll tmp = 1;
	for (int i = n; i > n - a; i--)
	{
		tmp *= i;
		tmp %= MOD;
	}
	ll tmp1 = 1;
	for (int i = a; i > 0; i--)
	{
		tmp1 *= i;
		tmp1 %= MOD;
	}

	ans -= tmp * modinv(tmp1, MOD) % MOD;
	ans %= MOD;
	tmp = 1;
	tmp1 = 1;

	for (int i = n; i > n - b; i--)
	{
		tmp *= i;
		tmp %= MOD;
	}

	for (int i = b; i > 0; i--)
	{
		tmp1 *= i;
		tmp1 %= MOD;
	}
	ans -= tmp * modinv(tmp1, MOD) % MOD;
	ans %= MOD;

	if (ans < 0)
		cout << ans + MOD;
	else
		cout << ans;
	cout << endl;

	return 0;
}

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

int main() {
  int x[5] = {0};
  for (int i = 0; i < 3; i++) {
    int a, b;
    cin >> a >> b;
    x[a]++;
    x[b]++;
  }
  int sum = 0;
  for (int i = 1; i <= 4; i++) {
    if (x[i] % 2 == 1) {
      sum++;
    }
  }
  if (sum == 2) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import numpy as np

D=int(input())
c=np.array(list(map(int,input().split())))
s=[list(map(int,input().split())) for _ in range(D)]
t=[np.random.randint(1,27) for _ in range(D)]

MAX=0
for _ in range(1500):
    d=np.random.randint(1,D+1)
    q=np.random.randint(1,27)
    last=np.array([0]*26)
    v=0
    for i in range(1,D+1):
        if i==d:
            v+=s[d-1][q-1]
            last[q-1]=d
            v-=np.dot(c,d-last)
            continue
        v+=s[i-1][t[i-1]-1]
        last[t[i-1]-1]=i
        v-=np.dot(c,i-last)
    if v>MAX:
        MAX=v
        t[d-1]=q

for i in range(D):
    print(t[i])

Measured memory_bytes: 27784
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    multiset<int> S;
    auto it = S.end();
    int Q; cin >> Q;
    Int A1 = 0, A2 = 0, B = 0;
    int index = 0;
    for (int i = 0; i < Q; i++) {
        int type; cin >> type;
        if (type == 1) {
            Int a, b; cin >> a >> b;
            S.insert(a);
            if (S.size() == 1) {
                it = S.begin();
                A1 += a;
                index = 0;
            } else {
                if (*it <= a) {
                    A2 += a;
                } else {
                    A1 += a;
                    index++;
                }
                if (index < (S.size() - 1) / 2) {
                    ++it;
                    A1 += *it;
                    A2 -= *it;
                    index++;
                }
                if (index > (S.size() - 1) / 2) {
                    A1 -= *it;
                    A2 += *it;
                    --it;
                    index--;
                }
            }
            B += b;
        } else {
            cout << *it << ' ';
            Int k = *it * (S.size() % 2);
            cout << (k - A1 + A2 + B) << '\n';
        }
    }
    return 0;
}


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

using namespace std;

int main(){
  int N;
  long long int ans=0;
  cin >> N;
  vector<int> L(N);
  vector<int>::iterator k;
  for(int i=0; i<N; i++) cin >> L[i];
  sort(L.begin(), L.end());

  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      k = lower_bound(L.begin(), L.end(), L[i]+L[j]);
      ans += (int)(k-L.begin())-j-1;
    }
  }

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


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main() {
	llong H, W;
	vector<string> S;

	cin >> H >> W;
	S.resize(H);
	for (int i = 0; i < H; ++i)
		cin >> S[i];

	vector<vector<llong> > hpos(W, {-1, H}), wpos(H, {-1, W});
	for (int h = 0; h < H; ++h) {
		for (int w = 0; w < W; ++w) {
			if (S[h][w] == '#') {
				hpos[w].push_back(h);
				wpos[h].push_back(w);
			}
		}
	}
	for (auto &h : hpos)
		sort(ALL(h));
	for (auto &w : wpos)
		sort(ALL(w));

	llong ans = 0;
	for (int h = 0; h < H; ++h) {
		for (int w = 0; w < W; ++w) {
			if (S[h][w] == '#') continue;
			auto left = --lower_bound(ALL(wpos[h]), w);
			auto right = lower_bound(ALL(wpos[h]), w);
			auto up = --lower_bound(ALL(hpos[w]), h);
			auto down = lower_bound(ALL(hpos[w]), h);

			llong res = 1;
			res += w - *left - 1;
			res += *right - w - 1;
			res += h - *up - 1;
			res += *down - h - 1;
			ans = max(ans, res);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 71168
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val A = IntArray(N) { sc.next().toInt() }
        var ans = 0L
        for (i in 0 until N step 2) {
            ans += A[i] % 2
        }
        pw.println(ans)
    }
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  ll n,k;cin>>n>>k;
  ll a[n];rep(i,n){cin>>a[i];}

  ll result=0;
  for(int d=41;d>=-1;d--){
    if( d!=-1 && !(k & (1LL<<d)) )continue;

    ll tmp=0;
    for(int e=40;e>=0;e--){
      ll mask = 1LL<<e;
      ll num=0;
      rep(i,n)if(mask & a[i])num++;

      if(e>d){
        if(k & mask) tmp += mask*(n-num);
        else tmp += mask*num;
      }else if(e==d){
        tmp += mask*num;
      }else{
        tmp += mask*max(num, n-num);
      }
    }
    result = max(result, tmp);
  }

  cout<<result;

  return 0;
}

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

int main() {
    int n,k,q;
    cin >> n >> k >> q;
    vector<int> a(n);
    for(int i = 0; i < q; i++){
        int buf;
        cin >> buf;
        a.at(buf-1)++;
    }

    for(int i = 0; i < n; i++){
        if((q - a.at(i)) < k){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

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

typedef long long LL;

string s;
stringstream ss;
LL V, N;

int main() {
    cin >> s;
    ss << s; ss >> V;
    N = s.size();
    LL N10 = 1; for (int j = 0; j < N; ++j) { N10 *= 10; }

    string t = "0123456789";

    LL max_diff = -2;
    string ret;
    LL ret_int;

    do {
        string u = t.substr(0, N);
        LL x;
        ss.clear();
        ss << u; ss >> x;


        LL diff = min(abs(V-x), N10-abs(V-x));
        if (diff > max_diff || (diff == max_diff && x < ret_int)) {
            max_diff = diff;
            ret = u;
            ret_int = x;
        }
    } while (next_permutation(begin(t), end(t)));

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 68680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

ll n, arr[200005], ans, vis = 0, cur = 1;

int main() {
	fastio; cin >> n;
	FOR(i, 1, n) cin >> arr[i];
	sort(arr+1, arr+n+1, greater<int>());
	FOR(i, 2, n) {
		ans += arr[cur];
		vis ^= 1;
		if (vis) cur++;
	}
	cout << ans;
}


Measured memory_bytes: 5176
#!python3

iim = lambda: map(int, input().rstrip().split())

inf = 10**18 + 1

def cnt_val(a, b, x, cache):
    ai = 1 if a == b else 0
    ans = 0

    la, lb = len(a), len(b)
    if len(cache) == 0:
        loa = [i+1 for i in range(la-1)] if ai else [0] * la
        hia = [lb] * la
        mia = [0] * la

        cache.append([-inf, loa])
        cache.append([x, mia])
        cache.append([inf, hia])
        ic = 1
    else:
        if x < cache[1][0]:
            cache[1], cache[2] = cache[2], cache[1]
        else:
            cache[0] ,cache[1] = cache[1], cache[0]

        cache[1][0] = x

        loa = cache[0][1]
        mia = cache[1][1]
        hia = cache[2][1]

    for i in range(len(a) - ai):
        xa = a[i]

        lo, hi = loa[i], hia[i]

        #print(ic, lo, hi)

        while lo < hi:
            mid = (lo + hi) // 2
            x1 = b[mid] * xa
            #print(i, (lo, hi), x1)

            if x1 <= x:
                lo = mid + 1
            else:
                hi = mid
        #print("x", (lo, lo0))
        mia[i] = lo
        ans += lo
        if ai:
            ans -= i + 1
    return ans

def resolve():
    N, K = iim()
    A = [[] for i in range(3)]
    for x in input().split():
        x = int(x)
        if x < 0:
            i = 0
        elif x == 0:
            i = 1
        else:
            i = 2

        A[i].append(x)

    a0 = len(A[0]) * len(A[2])
    s1 = len(A[1])
    a1 = s1 * (2*N - s1 -1) // 2
    K1 = K - 1

    if a0 < K1 < a0 + a1:
        print(0)
        return

    if K1 < a0:
        A[0].sort()
        A[2].sort(reverse=True)
        #print(A[0], A[2])
        lo, hi = A[0][0]*A[2][0], A[0][-1] * A[2][-1] + 1
        cache1 = []
        #print((lo, hi), K1)
        while lo < hi:
            mid = (lo + hi) // 2
            k = cnt_val(A[0], A[2], mid, cache1)
            #print((lo, hi), mid, k, K1)
            if k <= K1:
                lo = mid + 1
            else:
                hi = mid
        print(lo)
        return

    A0 = list(map(lambda x: -x, A[0]))
    A0.sort()
    A[2].sort()
    K3 = K - a0 - a1 - 1
    #print(A[0], A[2], a0, a1, K3)
    lo, hi = 0, 10**18
    cache1, cache2 = [], []
    while lo < hi:
        mid = (lo + hi) // 2
        k3 = cnt_val(A0, A0, mid, cache1) + cnt_val(A[2], A[2], mid, cache2)
        #print((lo, hi), k3, K3)
        if k3 <= K3:
            lo = mid + 1
        else:
            hi = mid
    print(lo)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 100816
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
vector<int> input(int N) {
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  return vec;
}

int main() {
  int h,n;
  cin >> h >> n;
  vector<int> v = input(n);
  
  int sum=0;
  rep(i,n){
    sum += v[i];
  }
  
  if(sum<h){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

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

#define SZ(x) (int)((x).size())
#define xx first
#define yy second



void solve() {
    int n; 
    cin >> n;
    cout << (1000 * ((n + 999) / 1000) - n) << '\n';
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // int _; cin >> _; while (_--)
    solve();
    return 0;
}


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

int v, e;
struct Edge {
  Edge() : isBridge(true) {}
  Edge(int src_, int dest_) : src(src_), dest(dest_), isBridge(true) {}
  int src;
  int dest;
  bool isBridge;
};
std::vector<Edge> graph[112345];

void load() {
  scanf("%d %d", &v, &e);
  for(int i = 0; i < e; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    graph[a].push_back(Edge(a, b));
    graph[b].push_back(Edge(b, a));
  }
}

int dfi[112345];
int parent[112345];
int dfiid = 1;
std::vector<int> backEdges[112345];
std::vector<int> ascNodes;

void dfs(int i, int prev) {
  dfi[i] = dfiid;
  dfiid += 1;
  ascNodes.push_back(i);
  for(Edge edge : graph[i]) {
    int src = edge.src;
    int dest = edge.dest;
    if( dest == prev ) continue;
    if( dfi[dest] == 0 ) {
      dfs(dest, src);
      parent[dest] = src;
    }
    else {
      // backEdge
      backEdges[dest].push_back(src);
      // printf("backEdge %d %d\n", src, dest);
    }
  }
}

bool visited[112345];
bool traversed[112345];
void traverse(int id) {
  if( visited[id] ) return;
  visited[id] = true;
  traversed[id] = true;
  traverse(parent[id]);
}
void calcChains() {
  for(int id : ascNodes) {
    visited[id] = true;
    for(int parent : backEdges[id]) {
      traverse(parent);
    }
  }
}

int main() {
  load();
  parent[0] = -1;
  dfs(0, -1);
  // for(int i = 0; i < v; ++i) {
  //   printf("(v, parent, dfi) = (%d, %d, %d)\n", i, parent[i], dfi[i]);
  // }
  calcChains();
  std::vector<std::pair<int, int>> res;
  for(int i = 0 + 1; i < v; ++i) {
    if( not traversed[i] ) {
      res.push_back(std::make_pair(std::min(i, parent[i]), std::max(i, parent[i])));
    }
  }
  std::sort(res.begin(), res.end());
  for(std::pair<int, int> st : res) {
    printf("%d %d\n", st.first, st.second);
  }

  return 0;
}

Measured memory_bytes: 11256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()
    println(problem078c(n, m))
}

fun problem078c(n: Int, m: Int): Long {
    return (1900 * m + (100 * (n - m))) * Math.pow(2.0, m.toDouble()).toLong()
}

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

int n;
int a, b;

int main() {
  cin >> n >> a >> b;
  if (a - 1 == 0 && a + 1 == b)
  	return cout << "Borys" << '\n',0;
  b -= a;
  b--;
  if (b % 2)
    return cout << "Alice" << '\n', 0;
  cout << "Borys" << '\n';
 	return 0; 
}

Measured memory_bytes: 256
import sys
S=input()
a,b,c,d=S[0],S[1],S[2],S[3]
lst=['+','-']
for i in lst:
  for j in lst:
    for k in lst:
      if eval(a+i+b+j+c+k+d+'==7'):
        print(a+i+b+j+c+k+d+'=7')
        sys.exit()


Measured memory_bytes: 38512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			long K = inputArray[1];

			var inp = retreiveStringArray()[0];

			//境目の数をSとすると、
			//ans = MIn(N-(S+1) + K*2, N-1)となる
			long sakaime = 0;
			var previous = inp[0];
			for (int i = 1; i < N; i++) {
				if (previous != inp[i]) {
					sakaime++;
					previous = inp[i];
				}
			}

			//答えの出力
			var ans = Math.Min(N-(sakaime+1)+K*2,N-1);
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}

Measured memory_bytes: 13920
from collections import Counter
 
M = 998244353
n = int(input())
a = map(int, input().split())
x, c = next(a), Counter(a)
r = 0
if x == c[0] == 0:
  r = p = 1
  try:
    for i in range(1, n + 1):
      r = r * pow(p, c.get(i), M) % M
      p = c[i]; n -= p
  except:
    pass
print((r, 0)[n > 1])

Measured memory_bytes: 22636
import           Control.Monad                  ( forM_ )


main :: IO ()
main = do
    [n, k] <- map read . words <$> getLine :: IO [Int]
    let pascals 0 = [1] :: [Integer]
        pascals n =
            1 : (zipWith (\a b -> (a + b) `mod` 1000000007) a (tail a)) ++ [1]
            where a = pascals (n - 1) :: [Integer]

        solve n k i = b * r `mod` 1000000007
          where
            b = pascals (k - 1) !! (i - 1)
            r = pascals (n - k + 1) !! i

    forM_ ([1 .. k] :: [Int])
        $ \i -> print $ if n - k + 1 < i then 0 else solve n k i



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

void printVector(vector<int> v) {
    for (auto x : v) {
        cout << x << ' ';
    }
    cout << '\n';
}

int main() {
    int n;
    cin >> n;
    vector<int> v1, v2;
    for (int i = 0; i <= n - 1; i++) {
        int a;
        cin >> a;
        v1.push_back(a);
    }
    for (int i = 0; i <= n - 1; i++) {
        int a;
        cin >> a;
        v2.push_back(a);
    }
    //printVector(v1);
    //printVector(v2);
    int tot = 0;
    for (int i = 0; i <= n - 1; i++) {
        if (v1[i] > v2[i]) tot += v1[i] - v2[i];
    }
    cout << tot << '\n';
    return 0;
}

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

int dx[]={0,1,1,1,0,-1,-1,-1}, dy[]={-1,-1,0,1,1,1,0,-1};

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

  int H, W, N; cin >> H >> W >> N;
  map<pair<int, int>, int> mp;
  REP(i, N){
    int a, b; cin >> a >> b;
    if(a>1&&a<H&&b>1&&b<W) mp[make_pair(a, b)]++;
    REP(j, 8){
      int nx = a+dx[j], ny = b+dy[j];
      if(nx>1&&nx<H&&ny>1&&ny<W) mp[make_pair(nx, ny)]++;
    }
  }
  int ans[10] = {};
  for(auto itr : mp){
    ans[itr.second]++;
  }
  int zero = (H-2)*(W-2);
  REP(i, 9) zero -= ans[i+1];
  cout << zero << endl;
  REP(i, 9) cout << ans[i+1] << endl;

  return 0;
}


Measured memory_bytes: 56576
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <map>
#include <stack>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926

typedef long long int ll;

//ll chk[55];
//ll num[55];
//ll num2[55];
//ll num[ten5];
//ll num2[ten5];
//char cmap[10][10];
priority_queue<long long int> pq;   //�j���\�e��
//stack<int> stk;
//vector<pair<ll,ll>> vint;
//vector<ll> vtime;
//deque<ll> deq[55];
//list<int> li;
//set<int> sint;
//set<ll> sll;
//map<ll,ll> mp;

ll solve(ll);

int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,n1=0,n2=0,n3,range;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=1;
    long long int a,a1,a2,a3,a4,a5,a6;
    a=a1=a2=a3=a4=a5=a6=0;
    //float f,g,h;
    //string s,s1;
    //char now,pre,c;
    cin>>n;
    cout<<solve(n);
}

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



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

int calcGcd(int a, int b, int c)
{
    int x = a, y = b, rem = x % y;
    while (rem != 0)
    {
        x = y;
        y = rem;
        rem = x % y;
    }

    int gcd = y;

    x = gcd;
    y = c;
    rem = x % y;
    while (rem != 0)
    {
        x = y;
        y = rem;
        rem = x % y;
    }

    gcd = y;

    return y;
}

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

    long long gcdSum = 0;

    int maxSum = k * 3;

    for (int a = 1; a <= k; ++a)
    {
        for (int b = 1; b <= k; ++b)
        {
            for (int c = 1; c <= k; ++c)
            {
                gcdSum += calcGcd(a, b, c);
            }
        }
    }

    cout << gcdSum << endl;
}

Measured memory_bytes: 3596
def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a

n=int(input())
C=[]
cnt=0
for i in range(3,n+1,2):
    fct = factorize(i)
    for div in divisorize(fct):
        C.append(num(div))
    if len(C)==8:
        cnt+=1
    C=[]
print(cnt)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long ln[] = {Math.max(sc.nextLong() - 1, 0), sc.nextLong()};
		long fn[] = new long[2];
		for(int i = 0; i < 2; i ++) {
			if(ln[i] % 2 == 0) {
				fn[i] = ln[i] ^ (ln[i] % 4 == 0 ? 0 : 1);
			}else {
				fn[i] = ln[i] % 4 == 3 ? 0 : 1;
			}
		}
		System.out.println(fn[0] ^ fn[1]);
	}
}

Measured memory_bytes: 21972
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

class Main{
    public static void main(String[] Args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final int n = Integer.parseInt(br.readLine());
        final vec[][] matrix = new vec[n][];
        for(int i = 0; i<n; i++){
            final StringTokenizer st = new StringTokenizer(br.readLine(), " ");
            final int u = Integer.parseInt(st.nextToken());
            final int k = Integer.parseInt(st.nextToken());
            matrix[u] = new vec[k];
            for(int j = 0; j<k; j++){
                matrix[u][j] = new vec(Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken()));
            }
        }
        final int[] cost = new int[n];
        Arrays.fill(cost, Integer.MAX_VALUE);
        cost[0] = 0;
        final PriorityQueue<vec> pq = new PriorityQueue<vec>();
        pq.add(new vec(0, 0));
        while(!pq.isEmpty()){
            final int t = pq.peek().t;
            final int c = pq.poll().c;
            if(cost[t]<c) continue;
            for(final vec v:matrix[t]){
                final int nc = c+v.c;
                if(nc<cost[v.t]){
                    cost[v.t] = nc;
                    pq.add(new vec(v.t, nc));
                }
            }
        }
        final StringBuilder sb = new StringBuilder();
        for(int i = 0; i<n; i++){
            sb.append(i).append(' ').append(cost[i]).append('\n');
        }
        System.out.print(sb);
    }
}

class vec implements Comparable<vec>{
    final int t;
    final int c;
    vec(int to, int cost){
        t = to;
        c = cost;
    }
    
    public int compareTo(vec other){
        return c-other.c;
    }
    
}



Measured memory_bytes: 85248
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	string s;
	cin >> s;
	cout << s[0] << s.length() - 2 << s[s.length() - 1] << endl;
}

Measured memory_bytes: 256
s = input()

import sys

for i in range(len(s)):
    if (i + 1) % 2 == 1 and s[i] not in 'RUD':
        print('No')
        sys.exit(0)
    if (i + 1) % 2 == 0 and s[i] not in 'LUD':
        print('No')
        sys.exit(0)
print('Yes')


Measured memory_bytes: 38384
/*
我们有两瓶装水的。

瓶子1可以容纳A毫升水，现在它包含B毫升水。瓶2含有C毫升的水。我们将尽可能将水从第2瓶转移到第1瓶。

瓶子2里还有多少水？
*/

#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int a,b,c;
int main()
{
	scanf("%d%d%d",&a,&b,&c);
	if(c-a+b > 0) printf("%d\n",c-a+b);
	else printf("0\n");
	return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	vector<string> a;
	a.resize(n);
	int i;
	map<string,int> mp;
	for(i=0;i<n;i++){
	    cin>>a[i];
	    sort(a[i].begin(),a[i].end());
	    mp[a[i]] += 1;
	}
	long long int ans = 0;
	long long int vl ;
	map<string,int>::iterator it;
	for(it=mp.begin();it!=mp.end();it++)
	{
	    vl = it->second;
	    long long int curval = (vl*(vl-1))/2;
	    ans += curval;
	}
	cout<<ans;
	return 0;
}


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

//nの2^iの位の数を出力する関数
ll pla(ll n,ll i)
{
  ll x = pow(2,i + 1),y = pow(2,i);
  return n % x / y;
}



int main() {
  ll N,M,X;
  cin>>N>>M>>X;
  vector<ll> C(N);
  vector<vector<ll>> A(N,vector<ll>(M));
  rep(i,N)
  {
    cin>>C.at(i);
    rep(j,M)
    {
      cin>>A.at(i).at(j);
    }
  }
  ll kane=100000000;
  rep(i,pow(2,N))
  {
    vector<ll> wis(M);
    rep(j,N)
    {
      if(pla(i,j)==1)
      {
        rep(k,M)
        {
          wis.at(k)+=A.at(j).at(k);
        }
      }
    }
    bool a=true;
    rep(j,M)
    {
      if(wis.at(j)<X)
      {
        a=false;
      }
    }
    if(a)
    {
      ll mon=0;
      rep(j,N)
      {
        if(pla(i,j)==1)
        {
          mon+=C.at(j);
        }
      }
      kane=min(kane,mon);
    }
  }
  if(kane!=100000000)
  {
    cout<<kane<<endl;
  }
  else
  {
    cout<<-1<<endl;
  }  
  return 0;
}


Measured memory_bytes: 4068
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 2000005

class PQ{
public:

	PQ(int arg_size){

		table = new int[arg_size];
        size = arg_size;
        num_nodes = 0;

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

        	table[i] = NONE;
        }
    }

	bool isEmpty(){

		return num_nodes == 0;
	}

	bool isFull(){

		return num_nodes == size;
	}

	void push(int value){

		table[num_nodes] = value;
        int loc = num_nodes++;

        int parent;

        //親 < 挿入値である間、データを上下に交換
        while(loc != root){
        	parent = (loc-1)/2;

        	if(table[parent] >= table[loc]){

        		break;
        	}else{

        		swap(table[parent],table[loc]);
        		loc = parent;
        	}
        }
    }

    int pop(){

    	int ret = table[root];

    	//末尾のデータをrootに引っ張ってくる
    	num_nodes--;
    	table[root] = table[num_nodes];
    	table[num_nodes] = NONE;

    	int loc = root;
    	int left,right;

    	//親 >= 左右の子となるように、データを交換
        while(true){
        	left = 2*loc+1;
        	if(left >= size)break; //locが一番下の層に到達

        	right = 2*loc+2;

        	if(table[loc] >= table[left] && table[loc] >= table[right]){

        		break;

        	}else{ //左の子と右の子で、大きい方と交換する

        		if(table[left] >= table[right]){

        			swap(table[loc],table[left]);
        			loc = left;

        		}else{

        			swap(table[loc],table[right]);
        			loc = right;
        		}
        	}
        }

        return ret;
    }

private:
    int* table;
    int num_nodes,size;
    const int NONE = -1,root = 0;
};

int main(){

    int value;
    char buf[22];
    PQ Q(SIZE);

    while(true){
        fgets(buf,22,stdin);
        if(buf[2] == 'd') break;
        if(buf[0] == 'i'){
            value = 0;
            for(int i = 0; buf[i] != '\0';i++){
                if(buf[i] >= '0' && buf[i] <= '9'){
                    value = 10*value+(buf[i] - '0');
                }
            }
            Q.push(value);
        }else{
            printf("%d\n",Q.pop());
        }
    }
}



Measured memory_bytes: 10968
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var INF int = (2 << 30) - 1

var sc = bufio.NewScanner(os.Stdin)

func next() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i

}

func min(a, b int) int {
	if a >= b {
		return b
	}
	return a
}

type RMQ struct {
	data []int
	size int
}

func NewRMQ(size int) *RMQ {
	s := 1
	for s < size {
		s *= 2

	}
	r := make([]int, s*2)
	for i := 0; i < s*2; i++ {
		r[i] = INF
	}
	return &RMQ{data: r, size: s}
}

func (r *RMQ) update(k, a int) {
	k += r.size - 1
	r.data[k] = a
	for k > 0 {
		k = (k - 1) / 2
		r.data[k] = min(r.data[k*2+1], r.data[k*2+2])
	}

}

/// [a,b]
func (r *RMQ) findMin(a, b int) int {
	return r.query(a, b+1, 0, 0, r.size)
}

// [a,b)
func (rmq *RMQ) query(a, b, k, l, r int) int {
	// case1
	if r <= a || b <= l {
		return INF
	}
	if a <= l && r <= b {
		return rmq.data[k]
	}

	vl := rmq.query(a, b, k*2+1, l, (l+r)/2)
	vr := rmq.query(a, b, k*2+2, (l+r)/2, r)
	return min(vl, vr)
}

func main() {
	sc.Split(bufio.ScanWords)

	n, q := next(), next()

	rmq := NewRMQ(n)

	for i := 0; i < q; i++ {
		com, x, y := next(), next(), next()

		if com == 0 {
			rmq.update(x, y)

		} else {
			fmt.Println(rmq.findMin(x, y))

		}
	}

}



Measured memory_bytes: 5352
a,b,c,d=map(int,input().split())
x1=a*c
x2=a*d
x3=b*c
x4=b*d
lst=[]
lst.append(x2)
lst.append(x3)
lst.append(x4)
lst.append(x1)
lst.sort()
print(lst[-1])

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

	int cards[4][13];
	for(int i=0; i<4; i++){
        for(int j=0; j<13 ;j++){
            cards[i][j]=0;
        }
}
	int n;
	cin >> n;
	for (int h = 0; h < n; h++){
		int num;
		char mar;
		cin >> mar >> num;
		if (mar == 'S')			cards[0][num - 1] = 1;
		if (mar == 'H') cards[1][num - 1]= 1;
		if (mar == 'C')cards[2][num - 1] = 1;
		if (mar == 'D')cards[3][num - 1] = 1;
	}
	for (int i = 0; i<4; i++){
		for (int j = 0; j<13; j++){
			if (cards[i][j]==0){
 if(i == 0){cout<< "S " <<j+1 <<endl;}
                if(i == 1){cout<< "H " <<j+1 <<endl;}
                if(i == 2){cout<< "C " <<j+1 <<endl;}
                if(i == 3){cout<< "D " <<j+1 <<endl;}
            }
        }
    }
    return 0;
    }


Measured memory_bytes: 3048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    int k = 0;
    for (int i = 0; i < N; ++i) {
        ll a;
        cin >> a;
        if (a % 2 == 1) ++k;
    }

    if (k % 2 == 0) {
        cout << "YES" << endl;
        return 0;
    }

    cout << "NO" << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
 
#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  int ans = 0;
  rep(i,N){
    if(i!=0){
      ans += (N-1)/i;
      //cout << ans << endl;
    }
  }
  cout << ans << endl;
}

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

public class Main {

    static long gcd(long a, long b) {
        if (b < a) {
            return gcd(b, a);
        }
        if (a == 0) {
            return b;
        }
        return gcd(b % a, a);
    }

    public static void main(String[] args) throws Exception {
        MyScanner scan = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        long a = scan.nextLong();
        long b = scan.nextLong();
        long c = scan.nextLong();
        long d = scan.nextLong();

        long botC = (a - 1) / c;
        long topC = (b) / c;
        long allC = topC - botC;

        long botD = (a - 1) / d;
        long topD = (b) / d;
        long allD = topD - botD;

        long gcd = gcd(c, d);
        long botCD = (a - 1) / ((c / gcd) * (d / gcd) * gcd);
        long topCD = (b) / ((c / gcd) * (d / gcd) * gcd);
        long allCD = topCD - botCD;

        long output = (b - a + 1) - allC - allD + allCD;

        out.println(output);
        out.close();
    }


    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
    //--------------------------------------------------------

}

Measured memory_bytes: 22100
fun main() {
    val (D, T, S) = readInts()

    val timeNeeded = D.toDouble() / S.toDouble()

    if (timeNeeded <= T) {
        println("Yes")
    } else {
        println("No")
    }
}

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints

Measured memory_bytes: 36392