akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
void maximumHeap(int A[], int n, int i){
	int l=i*2;
	int r=i*2+1;
	int largest=i;
	if(l<=n && A[l]>A[i]){
		largest=l;
	}
	if(r<=n && A[r]>A[largest])
		largest=r;
	if(largest!=i){
		int memo=A[i];
		A[i]=A[largest];
		A[largest]=memo;
		maximumHeap(A, n, largest);
	}
}
void buildMaxHeap(int A[], int n){
	for(int i=n/2; i>0; i--)
		maximumHeap(A, n, i);
}
int main(){
	int n;
	cin>>n;
	int A[n+1];
	for(int i=1; i<n+1; i++)
		cin>>A[i];
	buildMaxHeap(A, n);
	for(int i=1; i<n+1; i++)
		cout<<" "<<A[i];
	cout<<endl;
	return 0;
}


Measured memory_bytes: 5016
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int h, w;
    cin >> h >> w;
    mat c(10, vec(10));
    rep(i, 10) rep(j, 10) cin >> c[i][j];
    mat a(h, vec(w));
    rep(i, h) rep(j, w) cin >> a[i][j];

    rep(k, 10) rep(i, 10) rep(j, 10) {
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
    }

    int res = 0;

    rep(i, h) rep(j, w) {
        if (a[i][j] == -1) continue;
        res += c[a[i][j]][1];
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k, size_s;
  string s;
  cin >> k >> s;
  size_s = (int) s.size();
  if(size_s <= k) cout << s << endl;
  else{
    cout << s.substr(0, k) << "..." << flush;
  }
  return 0;
}


Measured memory_bytes: 3600
//Jai Shree Krishna
#include <vector>
#include <list>
#include <map>
#include <set>
#include "queue"
#include <deque>
#include <stack>
#include <numeric>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <complex>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include "fstream"
using namespace std;
#define PI acos(-1)
#define MOD (ll)1000000007
#define pii pair<long long ,long long >
#define ll  long long int
#define loop(i,n) for(ll i=0;i<n;i++)
#define loop2(i,n) for(ll i = 1;i<=n;i+=1)
#define pb push_back
#define mp make_pair
#define EPS 1e-8
void display(vector<int> v1){loop(i,v1.size()){cout<<v1[i]<<" ";}cout<<endl;}
ll dx[8] = {0,1,0,-1,1,1,-1,-1};
ll dy[8] = {1,0,-1,0,1,-1,1,-1};

//Never giving in, fighting to the end




int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    //freopen("/Users/ashish/Desktop/B-large-practice.in.txt", "r", stdin);
    //freopen("/Users/ashish/Desktop/A-large-practice.out.txt", "w", stdout);
    ll n;
    vector<string>v1;
    cin>>n;
    loop(i,n)
    {
        string s1;
        cin>>s1;
        v1.push_back(s1);
    }
    loop(i,26)
    {
        ll mex = (ll)1e18;
        loop(j,v1.size())
        {
            ll cnt = 0 ;
            loop(k,v1[j].size())
            {
                if(v1[j][k]==(char)(i+'a'))
                {
                    cnt+=1;
                }
            }
            mex = min(mex,cnt);
        }
        if(mex==(ll)1e18){
            continue;
        }
        loop(j,mex)
        {
            cout<<(char)(i+'a');
        }
    }
    
    
    
    
    

    return 0;
}


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

int main(void) {
  int n,k;
  cin >> n >> k;
  int a,x;
  x=0;
  a=1;
  while(a<=n){
  a *= k;
  x++;
  }
  cout << x << endl;
  
               
   
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(in.readLine());
      String line = in.readLine();
      int nHalf = n >> 1;

      Integer num;
      Map<Integer,Integer> mapA = new HashMap<>();
      Map<Integer,Integer> mapB = new HashMap<>();;
      int offset=0,next=0;
      char regx = ' ';

      for(int i=0; i<n; i++) {
        if((next = line.indexOf(regx,offset)) == -1)
          next = line.length();
        num = new Integer(line.substring(offset, next));
        offset = ++next;

        if((i&1) == 0)
          mapA.merge(num, 1, Integer::sum);
        else
          mapB.merge(num, 1, Integer::sum);
      }

      int[] vm1 = {0,0};
      int[] vm2 = {0,0};
      int[] x   = {0,0};

      for (Map.Entry<Integer,Integer> m : mapA.entrySet()) {
        int val = m.getValue();
        if(vm1[0] <val) {
          vm2[0] = vm1[0];
          vm1[0] = val;
          x[0]  = m.getKey();
        } else if(vm2[0] < val) {
          vm2[0] = val;
        }
      }
      for (Map.Entry<Integer,Integer> m : mapB.entrySet()) {
        int val = m.getValue();
        if(vm1[1] <val) {
          vm2[1] = vm1[1];
          vm1[1] = val;
          x[1]  = m.getKey();
        } else if(vm2[1] < val) {
          vm2[1] = val;
        }
      }

      int ans = 0;
      int cca1 = nHalf - vm1[0];
      int ccb1 = nHalf - vm1[1];
      int cca2 = nHalf - vm2[0];
      int ccb2 = nHalf - vm2[1];

      if(x[0] == x[1])
        ans = cca2 > ccb2 ? cca1 + ccb2 : cca2 + ccb1;
      else
        ans = cca1 + ccb1;

      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 45320
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

	int M;
   	cin >> M;

	cout << 24+(24-M) << endl;	
	return 0;
}


Measured memory_bytes: 3608
from collections import defaultdict, deque

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

D = defaultdict(set)
for a, b in AB:
    D[a].add(b)
    D[b].add(a)

ans = 0
queue = deque([(1, {1})])
while queue:
    q = queue.popleft()
    for x in D[q[0]] - q[1]:
        s = q[1] | {x}
        if len(s) == N:
            ans += 1
        else:
            queue.append((x, s))
print(ans)


Measured memory_bytes: 6132
mazui_med, umai_med, umai_doku = map(int, input().split())

tmp = min(umai_doku, umai_med)
umai_doku -= tmp
umai_med -= tmp
cnt = 2 * tmp

tmp = min(umai_doku, mazui_med)
umai_doku -= tmp
cnt += tmp


if (umai_doku > 0):
    cnt += 1
if (umai_med > 0):
    cnt+=umai_med

print(cnt)

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll K;
    int n, q;
    cin >> n >> K >> q;

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

    for (int i = 0; i < n; i++) {
        cout << (K - q + cnt[i] > 0 ? "Yes" : "No") << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main() {
	int byou, fun, zikan;
	cin >> byou;
	fun = byou / 60;
	byou = byou - fun * 60;
	zikan = fun / 60;
	fun = fun - zikan * 60;
	cout << zikan <<":"<<fun<<":"<<byou<<endl;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
#define mo 998244353
#define M 4000
long long ksm(long long a,int k) {
    long long s=1;
    while(k)
	{
	    if(k&1) s=s*a%mo;
	    a=a*a%mo;
	    k>>=1;
	}
    return s;
}
int n,k;
long long f[M+5][M+5],h[M+5][M+5],tol[M+5],jc[M+5],nc[M+5];
long long G(int n,int m) {
    if(n==0&&m==0) return 1;
    if(n<=0||m<0) return 0;
    return jc[n+m-1]*nc[m]%mo*nc[n-1]%mo;
}
long long cal(int l) {
    long long s=0;
    if(l&1)
	{
	    for(int i=1;i<=k;i++) tol[i]=(f[l>>1][i]+f[l>>1][i-1])%mo;
	    tol[0]=1;
	    for(int i=0;i<=k;i++) s=(s+G(n-l,k-i)*tol[i]%mo)%mo;
	}
    else for(int i=0;i<=k;i++) s=(s+G(n-l,k-i)*f[l>>1][i]%mo)%mo;
    s=(s%mo+mo)%mo;
    return s;
}
int main()
{
    //freopen("1.in","r",stdin);
    //freopen("1.out","w",stdout);
    jc[0]=1;
    for(int i=1;i<=M;i++) jc[i]=jc[i-1]*i%mo;
    nc[M]=ksm(jc[M],mo-2);
    for(int i=M-1;i>=0;i--) nc[i]=nc[i+1]*(i+1)%mo;
    cin>>n>>k;
    f[0][0]=1;
    for(int i=0;i<=k;i++) h[0][i]=1;
    for(int i=1;i<=n/2;i++)
	for(int j=0;j<=k;j++)
	    {
		if(j) f[i][j]=2*h[i-1][j-1]%mo;
		f[i][j]=(f[i][j]+f[i-1][j])%mo,h[i][j]=(h[i][j-1]+f[i][j])%mo;
	    }
    for(int i=2;i<=2*n;i++)
	{
	    int l=i-1;
	    if(l>n) l=2*n-l;
	    cout<<cal(l)<<'\n';
	}
    return 0;
}

Measured memory_bytes: 65024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <cassert>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define sys system("pause")
const int maxn=1e5+10;
const int N=2e5+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}
int n,t;
ll a[maxn],b[maxn];
ll ret1,ret2,m,k;
int main()
{
    int i,j;
    scanf("%d",&n);
    rep(i,1,n)
    {
        scanf("%lld",&a[i]);
        a[i]+=a[i-1];
        b[i]=a[i];
    }
    if(a[1]<=0)m+=-a[1]+1,ret1+=-a[1]+1,a[1]=1;
    rep(i,2,n)
    {
        a[i]+=m;
        if(a[i-1]>0)
        {
            if(a[i]>=0)m-=a[i]+1,ret1+=a[i]+1,a[i]=-1;
            else continue;
        }
        else
        {
            if(a[i]<=0)m+=-a[i]+1,ret1+=-a[i]+1,a[i]=1;
            else continue;
        }
    }
    if(b[1]>=0)k-=b[1]+1,ret2+=b[1]+1,b[1]=-1;
    rep(i,2,n)
    {
        b[i]+=k;
        if(b[i-1]>0)
        {
            if(b[i]>=0)k-=b[i]+1,ret2+=b[i]+1,b[i]=-1;
            else continue;
        }
        else
        {
            if(b[i]<=0)k+=-b[i]+1,ret2+=-b[i]+1,b[i]=1;
            else continue;
        }
    }
    printf("%lld\n",min(ret1,ret2));
    return 0;
}


Measured memory_bytes: 1792
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}



enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    int N;
    scan(N);
    auto t = readln.split.to!(int[]);
    long s = t.sum();
    long ans;
    int M;
    scan(M);
    foreach (i ; 0 .. M) {
        int pi, xi;
        scan(pi, xi);
        pi--;
        writeln(s - t[pi] + xi);
    }
}


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

vector<string> ss;
int n;

bool works(int a, int b) {
  bool ans = true;
  for(int i=0;i<n;i++) {
    for(int j=i;j<n;j++) {
      int x1 = (i + a) % n;
      int y1 = (j + b) % n;
      int x2 = (j + a) % n;
      int y2 = (i + b) % n;
      ans = ans && (ss[x1][y1] == ss[x2][y2]);
    }
  }

  return ans;
}

int main() {
  cin >> n;
  ss.resize(n);
  for(int i=0;i<n;i++) {
    cin >> ss[i];
  }

  long long ans = n * works(0, 0);
  for(int i=1;i<n;i++) {
    bool x = works(i, 0);
    ans += (n - i) * x;

    x = works(0, i);
    ans += (n - i) * x;
  }

  cout << ans << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
int main() {
  int N;
  int C0=0,C1=0,C2=0,C3=0;
  char text[N];
scanf("%d",&N);
  for(int i=0;i<N;i++){
  scanf("%s",text);
  if(!strcmp(text, "AC"))   C0++;
    else if(!strcmp(text, "WA"))   C1++;
    else if(!strcmp(text, "TLE"))  C2++;
    else C3++;
  }
  printf("AC x %d\n",C0);
  printf("WA x %d\n",C1);
  printf("TLE x %d\n",C2);
  printf("RE x %d\n",C3);
  return 0;
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
int64_t lucasf(int n){
  
  vector<int64_t> L(87);
  L.at(0) = 2;
  L.at(1) = 1;
  
  for(int i = 2; i <= n; i++){
      L.at(i) = L.at(i-1) + L.at(i-2);
    }
  
  return L.at(n);
}


int main() {
  int n;
  cin >> n;
  
  cout << lucasf(n) << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n,m,k, ans, a[200001], b[200001], pa[200001], pb[200001];

int main(){
	cin >> n >> m >> k;
	for(int i = 1;i <= n;i++){
		cin >> a[i];
		pa[i] = pa[i-1] + a[i];
	}
	for(int i = 1;i <= m;i++){
		cin >> b[i];
		pb[i] = pb[i-1] + b[i];
	}


	for(int i = 0;i <= n;i++){
		if(pa[i] > k)
			break;
		ans = max((long long)ans, (long long) (i + (max( (long long) 0,(long long)(upper_bound(pb, pb + m + 1, (k - pa[i])) - pb) ) ) ) );
	}
	
	cout << ans - 1;


	
}

Measured memory_bytes: 9880
import bisect
mod = 10 ** 9 + 7


def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    if len(A) != len(set(A)):
        return 0
    if len(B) != len(set(B)):
        return 0

    Amemo = [False] * (N * M + 1)
    Bmemo = [False] * (N * M + 1)

    for a in A:
        Amemo[a] = True
    for b in B:
        Bmemo[b] = True

    A.sort()
    B.sort()
    res = 1
    cnt = 0
    for x in reversed(range(1, N * M + 1)):
        if Amemo[x] and Bmemo[x]:
            cnt += 1
            continue
        if Amemo[x]:
            i = bisect.bisect_left(B, x)
            C = (M - i)
            res = res * C % mod
        elif Bmemo[x]:
            i = bisect.bisect_left(A, x)
            C = (N - i)
            res = res * C % mod
        else:
            i = bisect.bisect_left(B, x)
            j = bisect.bisect_right(A, x)
            C = (M - i) * (N - j) - cnt
            res = res * C % mod
        cnt += 1
    return res


if __name__ == "__main__":
    print(main())

Measured memory_bytes: 18804
def search(start: int, visited: list, power: list, min_power: int, min_powers: int) -> int:
    minimum = 10**4
    if min_powers[start] != -1:
        return min_powers[start] + min_power
    if visited[1] == True:
        #print(f'{min_power=}')
        return min_power
    for i, v in enumerate(visited):
        if not v:
            visited[i] = True
            min_power += power[start][i]

            #min_powers[i] = search(i,visited,power,min_power,min_powers)
            minimum = min(minimum, search(i,visited,power,min_power,min_powers))

            visited[i] = False
            min_power -= power[start][i]
            #print(f'{minimum=}')
    return minimum


H, W = map(int, input().split())

power = [[] for _ in range(10)]

for i in range(10):
    power[i] = list(map(int, input().split()))

world = [[] for _ in range(H)]

for i in range(H):
    world[i] = list(map(int, input().split()))

min_powers = [-1] * 10
visited = [False] * 10

#print(f'{power[8][4]=}')
for i in range(10):
    min_power = 0
    visited[i] = True
    min_powers[i] = search(i,visited,power,min_power,min_powers)
    visited[i] = False
    #visited = [False] * 10
for i in range(10):
    pass
    #print(f'{i=}, {min_powers[i]=}')
ans = 0
for wor in world:
    for w in wor:
        if w != -1:
            ans += min_powers[w]

print(ans)



Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;

int main(){
    string num; cin >> num;
    vector<int> a(4);
    rep(i,4){
        a[i] = (int)(num[i] - '0');
    }
    int n = 3;

    for(int bit = 0; bit < (1 << n); ++bit) {
        int sum = 0;

        for (int i = 0; i < n; i++) {
            if (bit & (1 << i)) {
                sum += a[i + 1];
            } else {
                sum -= a[i + 1];
            }
        }
        if(sum == 7 - a[0]){
            _print(a[0]);
            for (int i = 0; i < n; i++) {
                if(bit & (1 << i)){
                    _print('+');
                }else{
                    _print('-');
                }
                _print(a[i + 1]);
            }
            print("=7");
            break;
        }
    }
}



Measured memory_bytes: 256
X, N = map(int, input().split())
p = list(map(int, input().split()))
if N==0:
	p = [0]
r = 0
n = 0
while True:
    a = X+n
    if a not in p:
        b = a
        r = 1
    a = X-n
    if a not in p:
        b = a
        r = 1
    if r == 1:
        break
    else:
        n +=  1
print(b)

Measured memory_bytes: 9200
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n, h, w, a[1000], b[1000];
    cin >> n >> h >> w;
    int i = 0;
    
    for (i = 0; i < n; ++i)
        cin >> a[i] >> b[i];
    
    int count = 0;

    
    for (i = 0 ; i < n; ++i)
        if (a[i] >= h and b[i] >= w)
            count = count + 1;
        
    
    
    cout << count << endl;
}


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

int main() {
  int A, B, C, D, E; cin >> A >> B >> C >> D >> E;
  int ans = 0;
  if (A <= 0) {
    ans += -A * C + D;
    A = 0;
  }
  ans += (B - A) * E;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
	long long city[5];
	long long N;
	cin >> N;

	int index = -1;
	long long minimum = (long long)(1e15 + 2);
	for (int i = 0; i < 5; i++) {
		cin >> city[i];
		if (minimum > city[i]) {
			minimum = city[i];
			index = i;
		}
	}

	long long ans = 0;

	ans = ceil((double)N / minimum) + index;
	ans += 4 - index;

	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int h, w, d;
char ans[2010][2010];

signed main() {
	std::random_device rnd;
	std::mt19937_64 mt(rnd());
	cin >> h >> w >> d;
	if (d % 2) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (i % 2 == j % 2)cout << 'G';
				else cout << 'B';
			}
			cout << endl;
		}
		return 0;
	}
	for (int i = 0; i < 1010; i += d) {
		for (int j = 500; j < 1510; j += d) {
			char c = 'R';
			if ((j - 500) % (2 * d) == i % (2 * d))c = 'Y';
			int x = j, y = j;
			for (int k = 0; k < d / 2; k++) {
				for (int l = x; l <= y; l++)ans[i + k][l] = c;
				x--; y++;
			}
			x = j - d / 2 + 1, y = j + d / 2 - 1;
			for (int k = d / 2; k < d; k++) {
				for (int l = x; l <= y; l++)ans[i + k][l] = c;
				x++; y--;
			}
		}
	}
	for (int i = d / 2; i < 1000; i += d) {
		int p = 0;
		if ((i - d / 2) % (2 * d))p = 1;
		for (int j = 500 + d / 2; j < 1510; j += d) {
			char c = 'G';
			if (p)c = 'B';
			int x = j, y = j;
			for (int k = 0; k < d / 2; k++) {
				for (int l = x; l <= y; l++)ans[i + k][l] = c;
				x--; y++;
			}
			x = j - d / 2 + 1, y = j + d / 2 - 1;
			for (int k = d / 2; k < d; k++) {
				for (int l = x; l <= y; l++)ans[i + k][l] = c;
				x++; y--;
			}
			p = 1 - p;
		}
	}
	for (int i = 500; i < 500 + h; i++) {
		for (int j = 500; j < 500 + w; j++)cout << ans[i][j];
		cout << endl;
	}
}

Measured memory_bytes: 7384
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int sum[2] = { 0 };
  int point;

  for(int i = 0;i < 2;i++){
    for(int j = 0;j < 4;j++){
      cin >> point;
      sum[i] += point;
    }
  }
  if(sum[0] > sum[1])cout << sum[0] << endl;
  else if(sum[0] < sum[1])cout << sum[1] << endl;
  else cout << sum[0] << endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//素因数分解 (連想配列)
template<typename T>
T prime_fact(ll n) {
	auto is_prime = [] (ll n) {
		if (n == 1) return false;
		if (n == 2) return true;
		if (n % 2 == 0) return false;
		ll m = sqrt(n);
		for (ll i = 3; i <= m; i += 2) {
			if (n % i == 0) return false;
		}
		return true;
	};

	T mp;
	if (n % 2 == 0) {
		ll cnt = 0;
		while (n % 2 == 0) {
			n /= 2;
			cnt++;
		}
		mp[2] += cnt;
	}
	for (ll i = 3; i <= n; i += 2) {
		if (i % (ll)1e6 == 1) {
			if (is_prime(n)) {
				mp[n]++;
				break;
			}
		}
		if (n % i) continue;
		ll cnt = 0;
		while (n % i == 0) {
			n /= i;
			cnt++;
		}
		mp[i] += cnt;
	}
	return mp;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n;
	cin >> n;

	map<ll, ll> mp = prime_fact<map<ll, ll>>(n);

	ll ans = 0;
	for (auto i : mp) {
		ll x = i.second, y = 1;
		while (x >= y) {
			ans++;
			x -= y;
			y++;
		}
	}

	cout << ans << endl;
}

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


/*
???????§?????§????????????±???3??´
????°???°??????

??????????¨????????????????0??????????§??????????????????§
?????????????????£???????????????????????£????????????????°???\?????¨accepted??§?????????

*/


int e;

/*
int main(){

  while(true){
    int min, ylim, zlim;
    cin >> e;
    min = e;

    ylim = pow(e,1.0/2.0);
    zlim = pow(e,1.0/3.0);
    
    if(e == 0)break;
    for (int z = 0; z <= zlim; ++z){
       for (int y = 0; y <= ylim; ++y){
	  for (int x = 0; x <= e; ++x){
	    if((x + y*y + z*z*z) == e){
	      if((x + y + z) <= min){
		min = x + y + z;
		//cout << "xyz = " << x << " " << y << " " << z << " min = " << min << endl;
		break;
	      }
	    }
	  }
       }
    }
    cout << min << endl;
    
  }
}
*/


int main(){

  while(true){
    int min, ylim, zlim;
    cin >> e;
    min = e;

    ylim = pow(e,1.0/2.0) + 1;
    zlim = pow(e,1.0/3.0) + 1;
    
    if(e == 0)break;
    for (int z = 0; z <= zlim; ++z){
      for (int y = 0; y <= ylim; ++y){
	int x = e - z*z*z - y*y;
	if((x + y + z) <= min && x >= 0){
	  min = x + y + z;
	  //cout << "xyz = " << x << " " << y << " " << z << " min = " << min << endl;
	}
      }
    }
    cout << min << endl;
    
  }
}

Measured memory_bytes: 3124
N , K = map(int, input().split())
A = list(map(int, input().split()))
s = sum(A)
divisor = []
n = 1
while n ** 2 <= s:
    q, r = divmod(s, n)
    if r == 0:
        divisor.append(q)
        divisor.append(n)
    n += 1
if n ** 2 == s:
    divisor.pop()
ans = 1
for d in divisor:
    m = []
    for a in A:
        m.append(a % d)
    m.sort(reverse=True)
    l = sum(m) // d
    a = l * d - sum(m[:l])
    if a <= K:
        ans = max(ans, d)
print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
using namespace std;
struct point {
	int x, y;
	point operator +(const point &p)const {
		return { x + p.x,y + p.y };
	}
	point operator -(const point &p)const {
		return { x - p.x,y - p.y };
	}
	int Mul(point &p) {
		return x*p.x + y*p.y;
	}
}w[20];
int n, Res, D[65536], U[65536];
void Do(point a) {
	point A = { a.y,-a.x };
	int i, j, k;
	for (i = 0; i < (1<<n); i++)D[i] = -1;
	D[0] = 0;
	for (k = 0; k < (1 << n); k++) {
		if (D[k] == -1)continue;
		for (i = 0; i < n; i++) {
			for (j = i + 1; j < n; j++) {
				int mask = (1 << i) | (1 << j);
				if (mask & k)continue;
				if ((w[j] - w[i]).Mul(A) == 0) {
					D[mask | k] = max(D[mask | k], D[k] + 1);
				}
			}
		}
		int mask = (1 << n) - 1 - k;
		for (i = mask; ; i = (i - 1)&mask) {
			U[i | k] = max(U[i | k], U[i] + D[k]*(D[k]-1)/2);
			if (!i)break;
		}
	}
}
int main() {
	int i, j;
	scanf("%d", &n);
	for (i = 0; i < n; i++)scanf("%d%d", &w[i].x, &w[i].y);
	for (i = 0; i < n; i++) {
		for (j = i + 1; j < n; j++) {
			Do(w[j] - w[i]);
		}
	}
	int res = 0;
	for (i = 0; i < (1 << n); i++)res = max(res, U[i]);
	printf("%d\n", res);
}

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

int main(){
  int N;
  cin >> N;
  set<string> a;
  vector<string> s(N);
  bool judge = true;
  for(int i = 0; i < N; i++){
    cin >> s.at(i);
    a.insert(s.at(i));
    if(i != 0){
      int n = s.at(i-1).size();
      if(s.at(i-1).at(n-1) != s.at(i).at(0)) judge = false;
    }
    
  }
  if(judge && a.size() == N) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var a = ReadLine().Split(' ').Select(int.Parse).ToArray();

        static long DivideCount(long x, long y) => (x % y != 0) ? 0 : 1 + DivideCount(x / y, y);

        var ans = a.Select(x => DivideCount(x, 2)).Sum();

        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 29172
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

class Sieve:
    def __init__(self, n):
        self.plist = [2]  # n以下の素数のリスト
        min_prime_factor = [2, 0] * (n // 2 + 5)
        for x in range(3, n + 1, 2):
            if min_prime_factor[x] == 0:
                min_prime_factor[x] = x
                self.plist.append(x)
                if x ** 2 > n: continue
                for y in range(x ** 2, n + 5, 2 * x):
                    if min_prime_factor[y] == 0:
                        min_prime_factor[y] = x
        self.min_prime_factor = min_prime_factor

    def isprime(self, x):
        return self.min_prime_factor[x] == x

    # これが素因数分解(prime factorization)
    def pfct(self, x):
        pp, ee = [], []
        while x > 1:
            mpf = self.min_prime_factor[x]
            if pp and mpf == pp[-1]:
                ee[-1] += 1
            else:
                pp.append(mpf)
                ee.append(1)
            x //= mpf
        return [(p, e) for p, e in zip(pp, ee)]

def main():
    md=10**9+7
    sv=Sieve(1005)
    cnt_e=[0]*1005
    for a in range(2,II()+1):
        pe=sv.pfct(a)
        for p,e in pe:cnt_e[p]+=e
    ans=1
    for e in cnt_e:ans=ans*(e+1)%md
    print(ans)

main()

Measured memory_bytes: 3188
N = int(input())
As = list(map(int, input().split()))

def solve(N, As):
    total = sum(As)
    record = abs(total - As[0] - As[0])
    cum = 0
    for a in As[:-1]:
        cum += a
        record = min(record, abs(total - cum - cum))
    return record

print(solve(N, As))


Measured memory_bytes: 24932
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long lint;
typedef unsigned long long ulint;



//??????
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
//template <typename T> void print(T* v, int N) { if (N == 0) cout << "{ }"; cout << "{" << v[0]; for (int i = 1; i < N; i++) cout << ", " << v[i]; cout << "}"; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()

string binary(int n, int len = 32)
{
	string ret;
	for (int i = len - 1; i >= 0; i--) {
		ret.push_back((n & (1 << i)) ? '1' : '0');
	}
	return ret;
}

int main()
{
	map<char, string> ctob;
	for (char ch = 'A'; ch <= 'Z'; ch++) {
		ctob[ch] = binary(ch - 'A', 5);
	}
	ctob[' '] = "11010";		ctob['.'] = "11011";
	ctob[','] = "11100";		ctob['-'] = "11101";
	ctob['\''] = "11110";	ctob['?'] = "11111";


	char alpha[32] = { ' ', '\'', ',', '-', '.', '?' };
	for (int i = 6; i < 32; i++) alpha[i] = char('A' + i - 6);
	string code[32] = {
		"101", "000000", "000011", "10010001", "010001", "000001", "100101", "10011010",
		"0101", "0001", "110", "01001", "10011011", "010000", "0111", "10011000",
		"0110", "00100", "10011001", "10011110", "00101", "111", "10011111", "1000",
		"00110", "00111", "10011100", "10011101", "000010", "10010010", "10010011", "10010000"
	};

	string S;
	while (getline(cin, S)) {
		string src, dst;
		for (int i = 0; i < S.size(); i++) src += ctob[S[i]];
	
		bool flag = true;
		while (flag) {
			flag = false;
			for (int i = 0; i < 32; i++) {
				int len = code[i].size();
				if (len > src.size()) continue;
				if (code[i] == src.substr(0, code[i].size())) {
					dst.push_back(alpha[i]);
					src.erase(src.begin(), src.begin() + len);
					flag = true;
				}
			}
		}
		cout << dst << endl;
	}

	return 0;
}

Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
int n,k,s;
int cnt,head[2010],to[4010],nxt[4010];
void add(int x,int y)
{
	cnt++;
	to[cnt]=y;
	nxt[cnt]=head[x];
	head[x]=cnt;
}
void dfs(int x,int fa,int d)
{
	if (d>(k>>1))
	{
		s++;
	}
	for (int i=head[x];i;i=nxt[i])
	{
		int y=to[i];
		if (y==fa)
		{
			continue;
		}
		dfs(y,x,d+1);
	}
}
int main()
{
	scanf("%d%d",&n,&k);
	int ans=n;
	for (int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}
	if (k&1)
	{
		for (int i=1;i<=n;i++)
		{
			for (int j=head[i];j;j=nxt[j])
			{
				int y=to[j];
				s=0;
				dfs(i,y,0);
				dfs(y,i,0);
				ans=min(ans,s);
			}
		}
	}
	else
	{
		for (int i=1;i<=n;i++)
		{
			s=0;
			dfs(i,0,0);
			ans=min(ans,s);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
//#include "graph.cpp"
#define ll long long
#define loop(i,n) for(int i=0 ; i<n ; ++i)
#define rep(i,x,n) for(int i=x ; i<=n ; ++i)
#define iteloop(type,data,name,it) for(type<data>::iterator it=name.begin() ;it!=name.end() ; ++it)
#define getOpp(x) (x^2)
#define NOT(x) (x^1)
using namespace std;
using namespace __gnu_pbds;

typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_set;
const int N=1e5 + 5;
int arr[N] , n;
int solve(int x){
    set<int> divFirst,divSec;
    divFirst.insert(x);
    for(int i=2 ; i*i <= x ; i++){
        if(x%i == 0){
            divFirst.insert(i);
            divFirst.insert(x/i);
        }
    }
    loop(i,n){
        for(auto it=divSec.begin() ; it!=divSec.end();){
            if(arr[i]%*it != 0){
                it = divSec.erase(it);
            }else{
                ++it;
            }
        }
        for(auto it=divFirst.begin() ; it!=divFirst.end();){
            if(arr[i]%*it != 0){
                divSec.insert(*it);
                it = divFirst.erase(it);
            }else{
                ++it;
            }
        }
    }
    int mx=1;
    for(auto it=divFirst.begin() ; it!=divFirst.end();++it){
        mx=max(mx,*it);
    }
    for(auto it=divSec.begin() ; it!=divSec.end();++it){
        mx=max(mx,*it);
    }
    return mx;
}
int main(){
    cin.sync_with_stdio(false), cin.tie(0) , cout.tie(0);
    cin>>n;
    loop(i,n){
        cin>>arr[i];
    }
    cout<<max(solve(arr[0]) , solve(arr[1]))<<endl;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  int a = 1;
  
  for(int i = 0; i < N; i++) {
    if(a * 2 > a + K) {
      a += K;
    }
    else {
      a *= 2;
    }
  }
  cout << a << endl;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;
vector<tuple<int,int,int,int>> vec;

int calAns(vector<int>& A){
    int ans = 0;
    for(auto it : vec){
        int a,b,c,d;
        tie(a,b,c,d) = it;
        if(A[b-1]-A[a-1] == c)
            ans += d;
    }
    return ans;
}

int sol(vector<int>& A, int cur, int end, int m){
    if(cur == end){
        return calAns(A);
    }
    int res = 0;
    int s = A.size() ? A[cur-1] : 1;

    for(int i = s; i <= m ; ++i){
        A.push_back(i);
        res = max(res,sol(A,cur+1, end,m));
        A.pop_back();
    }
    return res;
}

int main(){
    int n,m,q;
    cin >> n >> m >> q;
    for(int i = 0,a,b,c,d; i < q ; ++i){
        cin >> a >> b >> c >> d;
        vec.emplace_back(a,b,c,d);
    }
    vector<int> A;
    cout << sol(A,0,n,m);

    return 0;
}

Measured memory_bytes: 3612
using System;

namespace AOJ
{
    class GcdAndLcm
    {
        public static void Main()
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }

                var tmp = input.Split(' ');
                int large = Math.Max(int.Parse(tmp[0]), int.Parse(tmp[1]));
                int small = Math.Min(int.Parse(tmp[0]), int.Parse(tmp[1]));

                int gcd = 0, lcm = 0;
                if (small == 0) { gcd = 0; }
                else
                {
                    int mod = large % small;
                    while (mod > 0)
                    {
                        large = small;
                        small = mod;
                        mod = large % small;
                    }
                    gcd = small;
                    lcm = int.Parse(tmp[0]) * (int.Parse(tmp[1]) / gcd);
                    Console.WriteLine(string.Format("{0} {1}", gcd, lcm));
                }
            }
        }
    }
}

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

int main()
{
int A;
int B;
int X;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> A;
	cin >> B;
	cin >> X;

	if( A <= X && X <= A + B )
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}






Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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 main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<P> ans;
	if(n%2 == 0){
		for(int i = 1; i <= n; ++i){
			for(int j = i+1; j <= n; ++j){
				if(i+j == n+1) continue;
				ans.emplace_back(i, j);
			}
		}
	}
	else{
		for(int i = 1; i <= n; ++i){
			for(int j = i+1; j <= n; ++j){
				if(i+j == n) continue;
				ans.emplace_back(i, j);
			}
		}
	}
	cout << ans.size() << endl;
	for(auto p : ans){
		cout << p.first << " " << p.second << endl;
	}
	return 0;
}

Measured memory_bytes: 3656
// Copyright 2020 yaito3014
#include <bits/stdc++.h>

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  array<int, 3> ABC = {};
  {
    auto& [A, B, C] = ABC;
    cin >> N >> A >> B >> C;
  }
  vector<pair<int, int>> choices(N);
  for (auto& p : choices) {
    string s;
    cin >> s;
    p = make_pair(s[0] - 'A', s[1] - 'A');
  }
  vector<int> ans(N);
  auto dfs = [](auto&& f) {
    return
        [=](auto&&... args) { return f(f, forward<decltype(args)>(args)...); };
  }([&](auto&& self, int n) -> bool {
    if (n == N) return true;
    auto& [f, s] = choices[n];
    ++ABC[f], --ABC[s];
    ans[n] = f;
    if (ABC[f] >= 0 && ABC[s] >= 0)
      if (self(self, n + 1)) return true;
    ABC[f] -= 2;
    ABC[s] += 2;
    ans[n] = s;
    if (ABC[f] >= 0 && ABC[s] >= 0)
      if (self(self, n + 1)) return true;
    ++ABC[f], --ABC[s];
    return false;
  });
  bool res = dfs(0);
  cout << (res ? "Yes" : "No") << '\n';
  if (res)
    for (const auto& e : ans) cout << char('A' + e) << '\n';
}


Measured memory_bytes: 9012
#!/usr/bin/env python3

s = int(input())

a = set([s])


for i in range(2, 1000001):
    # print(s)
    if s % 2 == 0:
        s = s//2
    else:
        s = 3*s+1
    if s in a:
        print(i)
        exit()
    a.add(s)


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

typedef struct _data
{
	long A;
	long B;
} data;

int q_cmp(const void *a, const void *b)
{
	return ((_data*)a)->A - ((_data*)b)->A;
}

int main()
{
	int n, m;
	cin >> n >> m;
	struct _data list[n];
	rep(i, n)
	{
		cin >> list[i].A >> list[i].B;
	}
	long s = sizeof(list) / sizeof(_data);
	qsort(list, s, sizeof(_data), q_cmp);
	// printf("-------\n");
	long sum = 0;
	long cnt = 0;
	rep(i, n)
	{
		if (list[i].B >= m)
		{
			sum += list[i].A * m;
			m -= m;
		}
		else if (list[i].B < m)
		{
			sum += list[i].A * list[i].B;
			m -= list[i].B;
		}
		if (m == 0)
			break;
		// cout << list[i].A << " " << list[i].B << endl;
	}
	printf("%ld\n", sum);
	return (0);
}


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

    int P, Q, R, T;
    cin >> P >> Q >> R;
    
    if(P+Q > Q+R){T=Q+R;} else{T=P+Q;}
    if(T>P+R){T=P+R;}
    
    cout << T <<endl;
    
    return 0;
    

    
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main()  {
	var A int
	var B int
	var C int

	_, _ = fmt.Scan(&A, &B, &C)

	A, B = SwapNumbers(A, B)
	A, C = SwapNumbers(A, C)

	fmt.Println(A, B, C)
}

func SwapNumbers(num1 int, num2 int) (int, int){
	return num2, num1
}


Measured memory_bytes: 512
x1,y1,x2,y2=map(int,input().split())
x=x2-x1
y=y2-y1
x3,y3,x4,y3=0,0,0,0
x,y=-y,x
x3=x2+x
y3=y2+y
x,y=-y,x
x4=x3+x
y4=y3+y
print(x3,y3,x4,y4)

Measured memory_bytes: 3060
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  int N, x;
  cin >> N >> x;
  int a[100];
  rep(i, N) cin >> a[i];
  sort(a, a + N);

  int ans = 0;
  rep(i, N){
    if(i == N - 1){
      if(a[i] == x) ans++;
    }else{
      if(a[i] <= x){
        x -= a[i];
        ans++;
      }else{
        break;
      }
    }
  }

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


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };


signed main() {
	int n, k, maxn = 0;
	vector<int>list;
	int r, D, x2000;

	cin >> r >> D >> x2000;

	int num = r * x2000 - D;
	cout << num << endl;

	for (int i = 0; i < 9; i++) {
		num = r * num - D;
		cout << num << endl;
	}


	getchar();
	getchar();
	return 0;
}

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

const int N = 3010;

int n, P, pow2[N * N], S2[N][N], fac[N], inv[N], ans;

inline int fpow(int x, int y, int P = ::P) {
  int ret = 1;
  for ( ; y; y >>= 1, x = 1ll * x * x % P)
    if (y & 1) ret = 1ll * ret * x % P;
  return ret;
}

int main() {
  std::cin >> n >> P;
  pow2[0] = 1;
  for (int i = 1; i <= n * n; ++i)
    pow2[i] = 1ll * pow2[i - 1] * 2 % P;
  S2[0][0] = 1;
  for (int i = 1; i <= n + 1; ++i)
    for (int j = 1; j <= i; ++j)
      S2[i][j] = (S2[i - 1][j - 1] + 1ll * S2[i - 1][j] * j) % P;
  fac[0] = 1;
  for (int i = 1; i <= n; ++i)
    fac[i] = 1ll * fac[i - 1] * i % P;
  inv[n] = fpow(fac[n], P - 2);
  for (int i = n; i; --i)
    inv[i - 1] = 1ll * inv[i] * i % P;
  ans = fpow(2, fpow(2, n, P - 1));
  for (int i = 1; i <= n; ++i) {
    int f = 0;
    for (int j = 0; j <= i; ++j)
      f = (f + 1ll * S2[i + 1][j + 1] * pow2[(n - i) * j]) % P;
    f = 1ll * f * fpow(2, fpow(2, n - i, P - 1)) % P;
    f = 1ll * f * fac[n] % P * inv[i] % P * inv[n - i] % P;
    if (i & 1)
      ans = (ans - f + P) % P;
    else
      ans = (ans + f) % P;
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 69504
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

N,K = MI()

from collections import defaultdict

d = defaultdict(int)
for i in range(N):
    a,b = MI()
    d[a] += b

A = list(d.keys())
A.sort()

a = 0
for b in A:
    if K <= a+d[b]:
        print(b)
        break
    else:
        a += d[b]
        

Measured memory_bytes: 80792
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using itn = int;//typpo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true;} return false; }
intl kai(intl k){//k!を求める関数
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

//--------------入力受け取る場所,分けてた方がデバッグしやすい気がする---------------------
intl a,b,h,m;

void input_var(){
    cin >> a >> b >> h >> m;
}
//-------------------------------------------------------------------------------

/*
void dfs(vector<intl> &v) {
    if (v.size() == 数列の長さ) {
        return;
    }
    for (int i = 0; i < 各項の値; i++) {
        v.push_back(i);
        dfs(v);
        v.pop_back();
    }
}*/

signed main(){
    cout << fixed << setprecision(15);
    input_var();
    ld ha = h * 30 + m * 0.5;
    ld ma = m * 6;
    ld c = abs(ha - ma);
    if(c > 180) c = 360 - c;
    //debug(c);
    //debug(cos(c * PI / 180));
    ld ans = a * a + b * b - (2 * b * a * cos(c / 180 * PI));
    //debug(a * a + b * b);
    cout << sqrtl(ans) << endl;
    return 0;
}

Measured memory_bytes: 4156
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 S;
  cin >> S;
  cout << S / 3600 << ":" << S % 3600 / 60 << ":" << S % 60 << endl;
  return 0;
}



Measured memory_bytes: 3092
#include<cstdio>
#include<algorithm>
#include<functional>
#include<queue>
using namespace std;
int main(void)
{
	int q,x,d,p,i,n,t,a;
	queue<int> qu[1000];

	scanf("%d %d",&n,&q);
	for(i=0;i<q;i++)	{
		scanf("%d",&a);
		if(a==0)	{
			scanf("%d %d",&t,&x);
			qu[t].push(x);
		}
		else if(a==1)	{
			scanf("%d",&t);
			if(!qu[t].empty())	printf("%d\n",qu[t].front());
		}
		else {
			scanf("%d",&t);
			if(!qu[t].empty())	qu[t].pop();
		}
	}
	return 0;
}


Measured memory_bytes: 3988