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

/* #pragma */
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int GCD(int a,int b){return b?GCD(b,a%b):a;}
long long GCD(long long a, long long b){return b ? GCD(b, a%b) : a;}
int LCM(int a, int b){return a * b / GCD(a, b);}
long long LCM(long long a, long long b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/



signed main()
{
	int mod = 2019;
	int l,r;cin >> l >> r;
	if(l == 0){
		cout << 0 << endl;
		return 0;
	}
	int a=INF;/*
	if(l <= r/2)
	for(int i = l; i < sqrt(r); ++i){
		for(int j = l+1; j <= sqrt(r)-sqrt(i); ++j){//-sqrt(i)
			a = min(a, i*j%mod);
		}
	}
	else{
		for(int i = l; i < r; ++i){
			for(int j = l+1; j <= r; ++r){
			a = min(a, i*j%mod);
			}
		}
	}*/
	if(r-l >= 10000){
		cout << 0 << endl;
		return 0;
	}
	for(int i = l; i < r; ++i){
		for(int j = i+1; j <= r; ++j){
			a = min(a, i*j%mod);
		}
	}

	cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf 1e18
#define g(x) cout<<x<<" "<<endl;
#define gg(x,y) cout<<x<<" & "<<y<<" "<<endl
#define jam(t) cout<<"Case #"<<t<<": "
#define ggg(x,y,z) cout<<x<<" & "<<y<<" & "<<z<<" "<<endl
#define all(x) x.begin(),x.end()
#define input_from_file  freopen("input.txt", "r", stdin);
#define mod 1000000007ll
#define sz 400005
#define bitcnt(x) __builtin_popcountll(x)
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

bool chk(string s){
    ll len  = s.length();
    ll i=0;
    ll j = len-1;
    while(j > i){
        if(s[i] != s[j])
            return false;
        j--;
        i++;
    }
    return true;
}

void solve(){
    string s;
    cin >> s;
    string one = s;
    ll n = s.length();
    string two = s.substr(0,n/2);
    string three = s.substr(n/2+1,n/2);
    if(chk(one)&&chk(two)&&chk(three)){
        g("Yes");
        return;
    }
    g("No");
}
int main()
{

    FASTIO
    cin.tie(NULL);
    fflush(stdout);
    ll t = 1;
    //cin >> t;
    for(ll tcase = 1;tcase <= t;tcase++){
        solve();
        
    }
return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

N,K = map(int,input().split())
edge = [[] for i in range(N)] #隣接リスト
for i in range(N-1) :
    u,v = map(lambda x: int(x)-1, input().split())
    edge[u].append(v)
    edge[v].append(u)

deg = [len(E) for E in edge] #隣接頂点数

MOD = 10**9 + 7
u = 10**5 + 1

fact = [1]*(u+1)
for i in range(1, len(fact)) :
    fact[i] = (fact[i-1] * i) % MOD

fact_inv = [1]*(u+1)
fact_inv[u] = pow(fact[u], MOD-2, MOD)
for i in range(u-1,0,-1) :
    fact_inv[i] = (fact_inv[i+1] * (i+1)) % MOD

def perm(n, k) : #nPk
    if k < 0 or n < k :
        return 0
    return (fact[n] * fact_inv[n-k]) % MOD

def F(node, parent=None) :
    if parent is None :
        res = perm(K, deg[node] + 1) #根は自身の場合の数を計算する
    else :
        res = perm(K-2, deg[node] - 1) #根以外は自身の場合の数を計算しない. 親は計算済みなので,差し引く.
    
    for next_node in edge[node] :
        if next_node == parent :
            continue
        res *= F(next_node, parent=node)
        res %= MOD
    return res

ans = F(0, parent=None)

print(ans)

    

Measured memory_bytes: 110188
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.14159265358979;
const int INF=1000000007;
const ll LMAX=1000000000000000001;
const ll mod=1000000007;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  ll h; cin>>h;
  ll sum=0;
  ll s=1;
  ll now=h;
  while(now>0){
    sum+=s;
    now/=2;
    s*=2;
  }
  cout<<sum<<endl;

  return 0;
}


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

int main(){
  int64_t a,b,c,d;
  cin>>a>>b>>c>>d;
  int64_t x1,x2,x3,x4;
  x1=a*c;
  x2=a*d;
  x3=b*c;
  x4=b*d;
  x1=max(x1,x2);
  x3=max(x3,x4);
  cout<<max(x1,x3)<<endl;
}

Measured memory_bytes: 3644
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var (
	reader = bufio.NewReader(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
)

func main() {
	defer writer.Flush()
	var N string
	fmt.Fscanf(reader, "%s\n", &N)
	ns := strings.Split(N, "")
	if ns[0] == ns[2] {
		fmt.Fprintf(writer, "%s\n", "Yes")
		return
	}
	fmt.Fprintf(writer, "%s\n", "No")
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int64 H, W, N, M;
vector<int64> v;
string s, t;

int main(void){
	int64 A, B;
	cin >> N >> A >> B;
	int32 cnt[3] = {};
	REP(i, N){
		int64 p;
		cin >> p;
		cnt[(p <= A) + (p <= B)]++;
	}
	cout << min({cnt[0], cnt[1], cnt[2]}) << endl;

}


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

using namespace std;

using ll = long long;

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

void ALLIN1_NUMBER(vector<ll>& V)
{
    for(auto& x : V)
    {
        cin >> x;
    }
}

template<class T>
void OUT0(T N)
{
    cout << N << endl;
}

static const double pi = acos(-1.0);

double Cos(double D)
{
    return cos(pi/180 * D);
}

class Dishes
{
    public:
    ll point_takahashi;
    ll point_aoki;
    ll sum;
    ll number;
};

void ALLIN1_DISHES(ll N, vector<Dishes>& dishes)
{
    for(ll i=0;i<N;i++)
    {
        dishes[i].number = i;
        cin >> dishes[i].point_takahashi >> dishes[i].point_aoki;
        dishes[i].sum = dishes[i].point_takahashi + dishes[i].point_aoki;
    }
}

bool Sort_TA(vector<Dishes>& dishesTA)
{
    sort
    (ALL(dishesTA),
    [](Dishes& a, Dishes& b)
    {
        return (a.sum == b.sum) ? (a.point_takahashi > b.point_takahashi) : (a.sum > b.sum);
    });
}

void Sort_AT(vector<Dishes>& dishes)
{
    sort
    (ALL(dishes),
    [](Dishes& a, Dishes& b)
    {
        return (a.sum == b.sum) ? (a.point_aoki > b.point_aoki) : (a.sum > b.sum);
    });
}

ll Ans(ll N, vector<Dishes> dishes_TA, vector<Dishes> dishes_AT)
{
    vector<bool> eaten(N,false);
    ll takahashi_point = 0;
    ll aoki_point = 0;

    ll itr_TA = 0;
    ll itr_AT = 0;

    for(ll i=0;i<N;i++)
    {
        if(i%2==0)
        {
            for(ll& j=itr_TA;j<N;j++)
            {
                if(!eaten[dishes_TA[j].number])
                {
                    eaten[dishes_TA[j].number] = true;
                    takahashi_point += dishes_TA[j].point_takahashi;
                    j++;
                    break;
                }
            }
        }
        else
        {
            for(ll& j=itr_AT;j<N;j++)
            {
                if(!eaten[dishes_AT[j].number])
                {
                    eaten[dishes_AT[j].number] = true;
                    aoki_point += dishes_AT[j].point_aoki;
                    j++;
                    break;
                }
            }
        }
    }
    return takahashi_point - aoki_point;
}

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

    vector<Dishes> dishes(N);
    ALLIN1_DISHES(N,dishes);

    vector<Dishes> dishes_TA = dishes;
    Sort_TA(dishes_TA);

    vector<Dishes> dishes_AT = dishes;
    Sort_AT(dishes_AT);

    OUT0(Ans(N,dishes_TA,dishes_AT));

    return 0;
}

Measured memory_bytes: 15872
#include<stdio.h>
int main(){
  int n,a,b,i,j,x,y,c;
  while(scanf("%d",&n),n){
    int p[10001]={0};
    int d[10001]={0};
    for(i=c=0;i<n;i++){
      for(j=0;j<n;j++){
	scanf("%d %d",&x,&y);
	for(a=i*100+j+1;p[a];a=p[a]);
	for(b=y*100+x+1;p[b];b=p[b]);
	if(a-b){
	  if(d[b]< d[a])p[b]=a;
	  if(d[b]>=d[a])p[a]=b;
	  if(d[a]==d[b])d[b]++;
	  c++;
	}
      }
    }
    printf("%d\n",n*n-c);
  }
  return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;

}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u != NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);   
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }

  return 0;
}





Measured memory_bytes: 25172
number = int(input())
coordinates = list(map(int, input().split()))
coordinates.sort()
coordinates.reverse()
#print(coordinates)
list = []
for i in range(coordinates[0]+1):
    total=0
    for j in range(number):
        total += (coordinates[j]-i)**2
    list.insert(0, total)
list.sort()
print(list[0])

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
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()

int main() {
  int n;
  while(cin >> n,n) {
    vector<int> v(n);
    REP(i,n)
      cin >> v[i];
    int ans = 0;
    while(true) {
      vector<int> nextv(n);
      REP(i,n) {
        nextv[i] = count(ALL(v),v[i]);
      }
      if (v == nextv) break;
      ans++;
      v = nextv;
    }
    cout << ans << endl;
    REP(i,n) {
      if (i) cout << " ";
      cout << v[i];
    }
    cout << endl;
  }
  
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> vec(n);
	vector<int> dp(n,0);
	for(int i=0;i<n;i++){
		int temp;
		cin>>temp;
		vec[i]=temp;
	}
	dp[0]=0;
	dp[1]=abs(vec[1]-vec[0]);
	for(int i=2;i<n;i++){
		dp[i]=min(dp[i-1]+abs(vec[i]-vec[i-1]),dp[i-2]+abs(vec[i]-vec[i-2]));
	}
	cout<<dp[n-1];
	return 0;
	
}


Measured memory_bytes: 4000
from collections import defaultdict
h, w = [int(i) for i in input().split()]
num_count = defaultdict(int)
for i in range(h):
    for j in input():
        num_count[j] += 1
#finish counting

n1 = (h%2) * (w%2)
n2 = h%2 * (w//2)*2 + w%2 * (h//2)*2 # I would have exactly e
n4 = h * w - n1 - n2

for i in num_count:
    while num_count[i] % 4 in [1,3]:
        num_count[i] -= 1
        n1 -= 1
if n1 != 0:
    print("No")
else:
    for i in num_count:
        while num_count[i] % 4  == 2:
            num_count[i] -= 2
            n2 -= 2
    if n2 < 0: #it's ok to have leftover as it can be covered by 4
        print("No")
    else:
        n4 += n2 # those that are not covered yet
        for i in num_count:
            while num_count[i] % 4 == 0 and num_count[i] > 0:
                num_count[i] -= 4
                n4 -= 4
        if n4 != 0:
            print("No")
        else:
            print("Yes")


Measured memory_bytes: 9436
import java.util.ArrayList;
import java.util.Scanner;

public class Main{

	public static void main(String[] args){
		ArrayList<Integer> list = new ArrayList<>();
		ArrayList<Integer> ViewList = new ArrayList<>();
		Scanner scanner = new Scanner(System.in);
		int count = scanner.nextInt();
		for(int i = 0; i < count; i++){
			int action = scanner.nextInt();

			switch(action){

			case 0:
				int num = scanner.nextInt();
				list.add(num);
				break;
			case 1:
				int num1 = scanner.nextInt();

				ViewList.add(list.get(num1));
				break;
			case 2:
				list.remove(list.size() - 1);
				break;
			default:
				System.out.println("0から2の間で入力してください");

			}
		}

		for(int i = 0; i < ViewList.size(); i++){
			int test = ViewList.get(i);
			System.out.println(test);
		}

	}


}



Measured memory_bytes: 138220
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
int MOD = 1000000007;

int main() {
	int a, b;
	while (cin >> a >> b) {
		int x = a + b;
		stringstream ss;
		ss << x;
		cout << ss.str().length() << endl;
	}
}

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

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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  string s, t;
  cin >> s >> t;
  bool main_flag = 0;
  rep(i, s.size()) {
    if (s.at(i) == t.at(0)) {
      bool semi_flag = 1;
      rep(j, s.size()) {
        if (s.at((i+j)%s.size()) != t.at(j)) {
          semi_flag = 0;
          break;
        }
      }
      if (semi_flag) {
        main_flag = 1;
        break;
      }
    }
  }
  if (main_flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}



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

#define pb push_back
#define inf INT_MAX
#define pii pair<int,int>
#define f first
#define s second
#define mp make_pair
#define mod 1000000009
#define ld long double
#define eps 1e-8
#define MAXN 2123
#define int long long

multiset<int> red;
multiset<int> green;

int32_t main (){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<setprecision(2)<<fixed;

    int r,g,nr,ng,nc;
    cin>>r>>g>>nr>>ng>>nc;
    for(int i=0;i<nr;i++){
        int x;
        cin>>x;
        red.insert(x);
    }
    for(int i=0;i<ng;i++){
        int x;
        cin>>x;
        green.insert(x);
    }
    while(red.size()>r)red.erase(red.begin());
    while(green.size()>g)green.erase(green.begin());
    for(int i=0;i<nc;i++){
        int x;
        cin>>x;
        if(red.size()<r){
            red.insert(x);
        }
        else if(green.size()<g){
            green.insert(x);
        }
        else{
            int pr=*red.begin();
            int pg=*green.begin();
            if(pr<pg && x>pr){
                red.erase(red.begin());
                red.insert(x);
            }
            else if(x>pg){
                green.erase(green.begin());
                green.insert(x);
            }
        }
    }
    int resp=0;
    for(auto x:red)resp+=x;
    for(auto x:green)resp+=x;
    cout<<resp<<endl;
    return 0;
}



Measured memory_bytes: 9600
/*
Author : N_o_o_B
Created : December 28 2019 17:52:48 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    ll n,m,v,p;
    cin >> n >> m >> v >> p;
    vl a(n);
    fori(i,n) cin >> a[i];
    sort(all(a));
    ll ans = p;
    ll sum = 0;
    fori(i,n-p+1){
        sum += a[i];
    }
    fori(i,n-p){
        sum -= a[i];
        ll req = v - (i+1);
        if(req < p){
            if(a[i] + m >= a[n-p]){
                ans++;
            }
            continue;
        }
        if(a[i] + m < a[n-p]){
            continue;
        }
        ll rem = v - (i+p);
        ll can = (a[i]+m)*(n-p-i) - sum;
        if(can >= m*rem) {ans++;}
    }
    cout << ans << endl;

    time_taken();
    return 0;
}


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

typedef long long ll;

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

    int x;
    cin >> x;

    for (int i = -1000; i <= 1000; i++)
    {
        for (int j = -1000; j <= 1000; j++)
        {
            if (pow(i, 5) - pow(j, 5) == x)
            {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  if(n==1){
    cout<<1<<endl;
    return 0;
  }
  int ans=1;
  while(ans<=n){
	ans*=2;
  }
  cout<<ans/2<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#define LL long long
#define INF 0x3f3f3f3f
#define io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const int N=2e5+100;
using namespace std;	
int main()
{
	string str;
	while(cin>>str)
	{
		int len=str.length();
		int ans=0;
		for(int i=1;i<len;i++)
			if(str[i]!=str[i-1])ans++;
		cout<<ans<<endl;
		
	}
	return 0;
} 

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define f first
#define s second
 
using ld = long double;
using ll = long long;
using ii = pair <int,int>;
using pll = pair <ll,ll>;
using vi = vector <int>;
using vll = vector <ll>;
using vii = vector <ii>;
using vpll = vector<pll>;


int main(){
 
  ios_base :: sync_with_stdio(false);
  cin.tie(NULL);
  
  map <char,int> cnt;
  int n;
  string a;
  cin >> n >> a;
  for(char c:a)
    cnt[c]++;
  string ref = "";
  while(cnt['R']--)
    ref+="R";
  while(cnt['W']--)
    ref+="W";
  
  int cw = 0;
  int cr = 0;

  for(int i=0;i<n;i++){
    if(a[i] != ref[i]){
      if(a[i] == 'W')
        cw++;
      else
        cr++;
    }
  }

  cout << max(cw,cr) << endl;
  return 0;
}

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

string N;

int main(){
   
    cin >> N ;
   
    if (N[0] == N[1] && N[1] == N[2])
    {
        cout << "Yes" << endl;
    }
    else if (N[1] == N[2] && N[2] == N[3])
    {
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 2e18;


signed main() {
    int N, Z, W;
    cin >> N >> Z >> W;
    vector<int> a(N);
    cin >> a;
    if (N == 1) {
        cout << abs(a[0] - W) << endl;
        return 0;
    }
    cout << max(abs(a[N - 1] - W), abs(a[N - 1] - a[N - 2])) << endl;
}


Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    A, B = LI()
    A_bottom,A_upper = A/0.08,(A+1)/0.08
    B_bottom,B_upper = B/0.10,(B+1)/0.10
    # print(A_bottom,A_upper,B_bottom,B_upper)
    if A_bottom>=B_bottom and A_bottom<B_upper:
        print(int(A_bottom) if A_bottom<=int(A_bottom) else int(A_bottom)+1)
    elif B_bottom>=A_bottom and B_bottom<A_upper:
        print(int(B_bottom) if B_bottom<=int(B_bottom) else int(B_bottom)+1)
    else:
        print(-1)

main()



Measured memory_bytes: 12936
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAX=100+10;
int main()
{	
	int n,a[MAX],x,ans;
	cin>>n>>x;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		if(x>=a[i])
			x-=a[i],ans++;
	if(x&&ans==n)
		ans--;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>

using namespace std;
int main() {
	int N;
	long long A[100000];
	int ans = 0;
	int cnt = 0;

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A, A + N);
	for (int i = 1; i < N; i++) {
		if (i == 1)cnt++;
		
		if (A[i] == A[i - 1])cnt++;
		else {
			if (cnt % 2 == 1) {
				ans++;
			}
			cnt = 1;
		}
		if (i + 1 == N) {
			if (cnt % 2 == 1)ans++;
			break;
		}
	}
	cout << ans << endl;


	return(0);
}

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

using namespace std;
#define ll long long
#define ull unsigned long long
#define mp make_pair
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int> > small_heap;
typedef priority_queue<int> big_heap;
const int N = 2e5 + 100;
char str[N];
int a[3000];

int main() {
    scanf("%s", str + 1);
    int len = strlen(str + 1);
    ll ans = 0;
    ll res = 0, t = 1;
    a[0]++;
    for (int i = len; i >= 1; i--) {
        res = ((str[i] - '0') * t + res) % 2019;
        ans += a[res];
        t = (t * 10) % 2019;
        a[res]++;
    }
    printf("%lld\n", ans);
    return 0;
}

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

#define ll long long 
#define sz(x) (int)x.size()

using namespace std;

int main(){
	string t;
	set<char>s;
	cin>>t;
	for(char c:t){
		s.insert(c);
	}
	cout<<(sz(t)==sz(s)?"yes":"no");


	
	
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n,k;
    string s;
    cin>>n>>s>>k;
    for(int i=0;i<n;i++){
        if(s[i]!=s[k-1])s[i]='*';
    }
    cout<<s<<endl;
}


Measured memory_bytes: 256
# AOJ 0588: Simple Calculator
# Python3 2018.6.30 bal4u

a = int(input())
while True:
	op = input().strip()
	if op == '=': break
	b = int(input()) 
	if   op == '+': a += b
	elif op == '-': a -= b
	elif op == '*': a *= b
	else:          a //= b
print(a)


Measured memory_bytes: 5592
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();

        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < N; i++) {

            int A = sc.nextInt();

            if (list.size() == 0 || list.get(list.size()-1) >= A) {
                list.add(A);
            } else if (A > list.get(0)) {
                list.set(0, A);
            } else {
                int ok = list.size()-1;
                int ng = 0;
                while (ng+1 < ok) {
                    int m = (ok+ng)/2;
                    if (list.get(m) < A) {
                        ok = m;
                    } else {
                        ng = m;
                    }
                }
                list.set(ok, A);
            }
        }

        System.out.println(list.size());
    }
}


Measured memory_bytes: 50476
a[3001];main(i,n,f,k){for(i=0;i<3001;i++)if(!(i&3)&&(i%100||!(i%400)))a[i]=1;for(f=0;scanf("%d%d",&i,&n),n;k?1:puts("NA"),f=1)for(k=0,f?puts(""):1;i<=n;i++)if(a[i])printf("%d\n",i),k=1;exit(0);}

Measured memory_bytes: 624
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

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

	cin >> H >> W;
	cin >> N >> M;
	vector<long long int>by(200001, 1);
	for (int i = 1; i <= 200000; i++) {
		by[i] = by[i - 1] * i;
		by[i] %= MOD;
	}
	long long int ans = 0;
	for (int i = M; i < W; i++) {
		long long int bag = by[i + H - N - 1];
		bag *= power(by[i], MOD - 2, MOD);
		bag %= MOD;
		bag *= power(by[H - N - 1], MOD - 2, MOD);
		bag %= MOD;
		bag *= by[N - 1 + W - i - 1];
		bag %= MOD;
		bag *= power(by[N - 1], MOD - 2, MOD);
		bag %= MOD;
		bag *= power(by[W - i - 1], MOD - 2, MOD);
		bag %= MOD;
		ans += bag;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define M ((int)1e9)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pi acos(-1)
typedef long long ll;
using namespace std;
int n;

void solve()
{
    int n;
    cin>>n;
    printf("%0.6lf",((n/2+n%2)*1.0/n));
}



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

Measured memory_bytes: 384
import java.util.Scanner;

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

		int h = sc.nextInt();
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++){
			a[i] = sc.nextInt();
			h -= a[i];
		} 
		if (h <= 0) {
			System.out.println("Yes");
		}
		else System.out.println("No");
	}
}

Measured memory_bytes: 49640
#include <iostream>
#include <string>

using namespace std;

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

	if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I'){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

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

int main() {
    int n,k;
    cin>>n>>k;
    int a[n+1];
    rep(i,n){
        cin>>a[i+1];
    }
    ll dp[n+1][k+1];//dp[i][j]でi人目まで配ってk個余るような配り方の場合の数
    rep(i,n+1){
        rep(j,k+1){
            dp[i][j]=0;
        }
    }
    dp[0][k]=1;
    for (int i=1;i<n+1;i++){
        ll ss[k+2];
        ss[0]=0;
        ss[1]=dp[i-1][0];
        rep(j,k){
            ss[j+2]=(dp[i-1][j+1]+ss[j+1]);
            //cout<<ss[j+1]<<endl;
        }
        //cout<<ss[k+1]<<endl;
        for (int j=0;j<k+1;j++){
            dp[i][j]=(ss[1+min(j+a[i],k)]-ss[j])%MOD;//dp[i-1]のj~min(j+a[i],k)の和
        }
    }
    cout<<dp[n][0]<<endl;

    return 0;
}

Measured memory_bytes: 79872
/**
 *  author: andychen
 *  created: 09.13.2020 20:43:32
**/

#include <bits/stdc++.h>

using namespace std;

const long long mod = 1e9 + 7;

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

    vector<long long> dp(s + 1);
    dp[s] = 1;
    for (int i = s; i >= 0; i--){
        for (int j = 3; i + j <= s; j++){
            dp[i] += dp[i + j];
            dp[i] %= mod;
        }
    }
    
    cout << dp[0] << '\n';

    return 0;
}


Measured memory_bytes: 3652
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (w, h, x, y) = (v[0], v[1], v[2], v[3]);
    let mut flag = 0;
    if x * 2 == w && y * 2 == h {
        flag = 1;
    }
    println!("{} {}", (w * h) as f64 / 2.0, flag);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2108
import heapq

def prime_method():
    not_went = [True] * n  # n個の点に行ったかという話
    edges = []
    start = graph[0]
    for e in start:
        heapq.heappush(edges,e)
    not_went[0] = False
    cost = 0
    while len(edges) != 0:
        minedge = heapq.heappop(edges)
        if not not_went[minedge[1]]:
            continue
        v = minedge[1]
        gv = graph[v]
        not_went[v] = False
        for temp in gv:
            if not_went[temp[1]]:  # その頂点に行ってなければ
                heapq.heappush(edges, temp)
        cost += minedge[0]
    return cost
    # a[1] = [[2,3],[5,11]] → 点1からコスト2で頂点3に行ける辺、点1からコスト5で頂点11に行ける辺がある


n = int(input())
graph = [[] for i in  range(n)]
cities = []
for i in range(n):
    cities.append(tuple(map(int,input().split()))+tuple([i]))


citiesX=sorted(cities,key=lambda x:x[0])
citiesY=sorted(cities,key=lambda x:x[1])

for i in range(n-1):
    graph[citiesX[i][2]].append(((citiesX[i+1][0] - citiesX[i][0]),citiesX[i+1][2]))
    graph[citiesX[i+1][2]].append(((citiesX[i+1][0] - citiesX[i][0]),citiesX[i][2]))
    graph[citiesY[i][2]].append(((citiesY[i+1][1] - citiesY[i][1]),citiesY[i+1][2]))
    graph[citiesY[i+1][2]].append(((citiesY[i+1][1] - citiesY[i][1]),citiesY[i][2]))
print(prime_method())

Measured memory_bytes: 74924
#include <iostream>
#include <array>
#include <vector>
#include <string>

using namespace std;

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

int h, w, i = 0;
vector<string> s;
vector<vector<int>> d, re, now;

void calc(int x, int y) {
    d[x][y] = i;
    re.push_back({x,y});
    if(x < h-1 && s[x+1][y] == '.' && d[x+1][y] > i) calc(x+1, y);
    if(x > 0 && s[x-1][y] == '.' && d[x-1][y] > i) calc(x-1, y);
    if(y > 0 && s[x][y-1] == '.' && d[x][y-1] > i) calc(x, y-1);
    if(y < w-1 && s[x][y+1] == '.' && d[x][y+1] > i) calc(x, y+1);
}

int main() {
    int ch, cw, dh, dw, xx, yy;
    cin >> h >> w;
    cin >> ch >> cw;
    cin >> dh >> dw;

    s.assign(h, string());
    d.assign(h, vector<int>(w, INT_MAX));
    rep(i, h) cin >> s[i];

    vector<vector<int>> warp;
    rep(i, 5) {
        rep(j, 5) {
            if(abs(i-2) + abs(j-2) > 1) warp.push_back({i-2,j-2});
        }
    }

    now = {{ch-1, cw-1}};
    while (!now.empty()) {
        for(auto xy : now) {
            if(d[xy[0]][xy[1]] > i) calc(xy[0], xy[1]);
        }
        now.clear();

        for(auto xy : re) {
            for(auto ij : warp) {
                xx = xy[0] + ij[0];
                yy = xy[1] + ij[1];
                if(xx < 0 || h-1 < xx || yy < 0 || w-1 < yy) continue;
                if(s[xx][yy] == '.' && d[xx][yy] > i) now.push_back({xx, yy});
            }
        }
        re.clear();
        ++i;
    }

    cout << (d[dh-1][dw-1] == INT_MAX ? -1 : d[dh-1][dw-1]) << endl;
}

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

main(){
    string s;
    cin >> s;
    int one = 0 , zero = 0;
    for(int i = 0 ; s[i] ; i ++)
        if(s[i] == '0')zero ++;
        else one ++;

    printf("%d\n" , min(zero , one) * 2);
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
using namespace std;

int main(void){
    int n,m;
    cin >> n >> m;
    int box[100005];
    for(int i=0; i<n; i++){
        cin >> box[i];
    }

    int sum[100005];
    map<int, int> M;
    sum[0]=0;
    for(int i=1; i<=n; i++){
        sum[i]=(box[i-1]+sum[i-1])%m;
    }
    
    long long int ans=0;
    for(int i=0; i<=n; i++){
        ans+=M[sum[i]];
        M[sum[i]]++;
    }

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

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

int main()
{
	int N;
	cin >> N;
	vector<pair<int, int> > A(N);
	for (int i = 0; i < N; i++) {
		int Ai;
		cin >> Ai;
		A[i] = make_pair(Ai, i + 1);
	}
	sort(A.begin(), A.end());
	for (int i = 0; i < N; i++) {
		cout << A[i].second;
		if (i < N - 1) {
			cout << " ";
		}
	}

	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>

using namespace std;
typedef long long ll;

int n;
ll ar[10000];

int main() {
	
	while (1) {
		cin >> n;
		if (n == 0)break;
		ll avep = 0;
		for (int i = 0; i < n; i++) {
			cin >> ar[i];
			avep += ar[i];
			ar[i] *= n;
		}

		sort(ar, ar + n);
		cout << upper_bound(ar, ar + n, avep) - ar << endl;


	}

	return 0;
}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ads(ll a, ll b, ll c) {
  ll ma = max(a, max(b, c));
  ll mi = min(a, min(b, c));
  return ma - mi;
}
int main () {
  ll H, W;
  cin >> H >> W;
  ll ans = 1e14;
  for (ll i = 1; i < H; i ++) {
    ll sa = W * (H - i);
    ll sb = i * (W / 2);
    ll sc = i * ((W + 1) / 2);
    ll sd = ads(sa, sb, sc);
    ans = min(ans, sd);
  }
  for (ll i = 1; i < W; i ++) {
    ll sa = H * (W - i);
    ll sb = i * (H / 2);
    ll sc = i * ((H + 1) / 2);
    ll sd = ads(sa, sb, sc);
    ans = min(ans, sd);
  }
  if (H % 3 == 0) {
    ans = 0;
  }
  else {
    ans = min(ans, W);
  }
  if (W % 3 == 0) {
    ans = 0;
  }
  else {
    ans = min(ans, H);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3552
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
	int n;
	cin >> n;
	int mx=0,ans=0;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin >> x;
		mx=max(mx,x);
		ans+=x==mx;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>
int main()
{
long int a=0,b=0,c=0,d=0,w=0,i,str1=0,str2=0,flag,j,count=0,max=0;
char x[101];
scanf("%s",x);

for(i=0;i<strlen(x);i++)
{
    if(x[i]==',')
    {
        printf(" ");
    }else{
        printf("%c",x[i]);
    }
   
}


 return 0;
}


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

using ll = long long;
using vi = vector<int>;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	n = n%10;
	if( n == 2 || n == 4 || n == 5 ||  n == 7 || n == 9){
		cout << "hon\n";
		return 0;
	}
	if( n == 3){
		cout << "bon\n";
		return 0;
	}
	cout << "pon\n";	
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
using lint = long long;

signed main(){
  lint N; cin >> N;
  vector<lint> a(N);
  lint sum = 0;
  for(lint i = 0; i < N; i++) cin >> a[i], sum += a[i];
  if(sum % 10 != 0){
    cout << sum << endl;
    return 0;
  }
  sort(a.begin(), a.end());
  for(lint i = 0; i < N; i++){
    if(a[i] % 10 != 0){
      cout << sum - a[i] << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}

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

using namespace std;

using ll = long long;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T;
    cin >> T;
    for (int tcase = 1; tcase <= T; tcase++) {
        [&] {
            ll N, A, B, C, D;
            cin >> N >> A >> B >> C >> D;
            map<int, ll> vals{{2, A}, {3, B}, {5, C}};
            unordered_set<ll> vis;
            priority_queue<pair<ll, ll>> q;
            q.push({0, N});
            while (1) {
                ll w, n;
                tie(w, n) = q.top();
                q.pop();
                if (n == 1) {
                    cout << -w + D << endl;
                    return;
                }
                if (vis.count(n))
                    continue;
                vis.emplace(n);
                for (auto kv : vals) {
                    int mod = n % kv.first;
                    ll n2 = (n - mod) / kv.first;
                    ll cost = D * mod + kv.second;
                    if (n - n2 < 2e9) {
                        cost = min(cost, D * (n - n2));
                    }
                    q.emplace(w - cost, n2);
                    if (mod == 0)
                        continue;
                    mod = kv.first - mod;
                    n2 = (n + mod) / kv.first;
                    cost = D * mod + kv.second;
                    if (n - n2 < 2e9) {
                        cost = min(cost, D * (n - n2));
                    }
                    q.emplace(w - cost, n2);
                }
            }
        }();
    }
}


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

int main() {
  int N;
  long long K;
  cin >> N >> K;
  vector<pair<int, int>> ab(N);
  for (int i = 0; i < N; i++) cin >> ab.at(i).first >> ab.at(i).second;
  sort(ab.begin(), ab.end());
  for (int i = 0; i < N; i++) {
    K -= ab.at(i).second;
    if (K <= 0) {
      cout << ab.at(i).first << endl;
      break;
    }
  }
}

Measured memory_bytes: 4000
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in sys.stdin.readline().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v

def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    A, B = int(input()), int(input())
    print(6 - A - B)


main()


Measured memory_bytes: 4916
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//def   puts(a) printf("%s\n", a) 文字はこっち
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
//your code here!


int main(void){
    char O[55], E[55];
    ins(O); ins(E);
    rep(i,strlen(O)){
        printf("%c", O[i]);
        if(i!=strlen(E)) printf("%c", E[i]);
    }
    return 0;
}


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

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

  int zero = 0, one = 0;
  int ans = 0;
  for (int i = 0; i < s.size(); i ++) {
    if (s[i] == '0' && one) {
      ans += 2;
      one --;
    } else if (s[i] == '0') {
      zero ++;
    } else if (s[i] == '1' && zero) {
      ans += 2;
      zero --;
    } else {
      one ++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define Vi vector<int>

using namespace std;

const int N=1e4+10;
int n,a[N],g,b[N],c[N]; Vi V;

bool is_prime(int x){
	for (int i=2;i*i<=x;i++) if (x%i==0) return 0;
	return 1;
}
bool chk(int p){
	if (a[0]%p) return 0;
	rep (i,0,n-1) b[i]=a[i+1]%p;
	for (int i=n-1;i>=p-1;i--) (b[i-(p-1)]+=b[i])%=p,b[i]=0;
	rep (i,0,n-1) if (b[i]%p) return 0;
	return 1;
}

int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	rep (i,0,n) cin>>a[i],g=__gcd(g,a[i]);
	g<0?g=-g:0; reverse(a,a+n+1);
	for (int i=2;i*i<=g;i++)
		if (g%i==0){
			V.push_back(i);
			while (g%i==0) g/=i;
		}
	if (g>1) V.push_back(g);
	rep (i,2,n) if (is_prime(i)&&chk(i)) V.push_back(i);
	sort(V.begin(),V.end());
	rep (i,0,(int)V.size()-1) if (!i||V[i]!=V[i-1]) cout<<V[i]<<'\n';
	return 0;
}

Measured memory_bytes: 384
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int A, P; cin >> A >> P;
    cout << (3*A + P) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
 long long int a,ans,count,tmp;
 cin>>a;
 ans=0;
 tmp=1;
 count=0;
 while(a>=tmp){
   tmp*=2;
   count++;
 }

 for(int i=0;i<count;i++){
   ans+=pow(2,i);
 }
 cout<<ans<<endl;
 return 0;


}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<cstring>
#include <iomanip>

using namespace std;

#ifdef LDEBUG
#define debug(x) cout << #x << ":" << (x) << endl
#else
#define debug(...)
#endif

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

typedef unsigned long long u64;
typedef long long i64;

u64 n;

u64 dfs(u64 k, int m, u64 s, int a, int b, int c) {
        u64 r = 0;

        if ((k >> m) < s)
                return 0;

        if (m == 0)
                return (a > 0 && b > 0 && c > 0 ? 1 : 0);

        if (a > 0 && b > 0 && c > 0)
                r++;

        r += dfs(k, m-1, s*10 + 7, a,b,c+1);
        r += dfs(k, m-1, s*10 + 5, a,b+1,c);
        r += dfs(k, m-1, s*10 + 3, a+1,b,c);

        return r;
}


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

        cin >> n;

        int m = 0;
        u64 nn = n;
        while (nn > 0) {
                nn /= 10;
                m++;
        }

        cout << dfs(n,m,0,0,0,0) << endl;

        return 0;
}


Measured memory_bytes: 256