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

using namespace std;

const int N = 2010;
const int NN = 2010;

unsigned long long one = 1;
unsigned long long g[N][NN];
unsigned long long was[NN];

bool alive[N];
bool can_put[N];

int a[N];
int x[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (__gcd(a[i], a[j]) > 1) {
        g[i][j >> 6] |= (one << (j & 63));
        g[j][i >> 6] |= (one << (i & 63));
      }
    }
  }
  int nn = ((n - 1) >> 6) + 1;
  for (int i = 0; i < n; i++) {
    alive[i] = true;
    can_put[i] = true;
  }
  for (int it = 0; it < n; it++) {
    for (int i = 0; i < nn; i++) {
      was[i] = 0;
    }
    for (int i = 0; i < n; i++) {
      if (!alive[i]) {
        was[i >> 6] |= (one << (i & 63));
      }
    }
    int best = -1;
    for (int i = 0; i < n; i++) {
      if (was[i >> 6] & (one << (i & 63))) {
        continue;
      }
      int b = 0, e = 1;
      x[0] = i;
      was[i >> 6] |= (one << (i & 63));
      while (b < e) {
        for (int j = 0; j < nn; j++) {
          if ((g[x[b]][j] & was[j]) != g[x[b]][j]) {
            for (int u = j * 64; u < (j + 1) * 64; u++) {
              if (g[x[b]][u >> 6] & (one << (u & 63))) {
                if (!(was[u >> 6] & (one << (u & 63)))) {
                  was[u >> 6] |= (one << (u & 63));
                  x[e++] = u;
                }
              }
            }
          }
        }
        b++;
      }
      int cur = -1;
      for (int j = 0; j < e; j++) {
        if (!can_put[x[j]]) {
          continue;
        }
        if (cur == -1 || a[x[j]] < a[cur]) {
          cur = x[j];
        }
      }
      if (best == -1 || (cur != -1 && a[cur] > a[best])) {
        best = cur;
      }
    }
    if (it > 0) putchar(' ');
    printf("%d", a[best]);
    alive[best] = false;
    for (int i = 0; i < n; i++) {
      if (!alive[i]) {
        continue;
      }
      if (g[best][i >> 6] & (one << (i & 63))) {
        can_put[i] = true;
      } else {
        if (a[best] < a[i]) {
          can_put[i] = false;
        }
      }
    }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 8704
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Aizu
{
	class Program
	{
		static void Main(string[] args)
		{
			var firstLine = ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();
			var v = firstLine[0];
			var e = firstLine[1];

			var pathes = new Dictionary<int, Dictionary<int, int>>();

			for(var i = 0; i < e; i++)
			{
				var line = ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();

				if(!pathes.ContainsKey(line[0]))
				{
					pathes.Add(line[0], new Dictionary<int, int>());
				}
				pathes[line[0]].Add(line[1], line[2]);
			}

			var costs = new long[(1 << v) + 1, v + 1];
			for(var i = 0; i <= (1 << v); i++)
			{
				for(var j = 0; j <= v; j++)
				{
					costs[i, j] = -1;
				}
			}

			long min = Dp(costs, pathes, (1 << v) - 1, 0, 0, v);

			WriteLine(min < int.MaxValue ? min : -1);
		}

		private static long Dp(long[,] costs, Dictionary<int, Dictionary<int, int>> pathes, int bit, int node, int goal, int v)
		{
			if(costs[bit, node] != -1)
			{
				return costs[bit, node];
			}

			if(bit == (1 << node))
			{
				return costs[bit, node] = 0;
			}

			long min = int.MaxValue;
			int previewBit = bit;
			if (node != goal)
			{
				previewBit &= ~(1 << node);
			}
			for(var i = 0; i < v; i++)
			{
				if((previewBit & (1 << i)) == 0)
				{
					continue;
				}

				if(!pathes.ContainsKey(node) || !pathes[node].ContainsKey(i))
				{
					continue;
				}

				if(i == goal && previewBit != (1 << goal))
				{
					continue;
				}

				min = Min(min, Dp(costs, pathes, previewBit, i, goal, v) + pathes[node][i]);
			}

			return costs[bit, node] = min;
		}
	}
}



Measured memory_bytes: 20316
N,K=map(int,input().split())
A=[list(map(int,input().split())) for i in range(N)]
V=2*N+2
INF=10**14
G=[[] for i in range(V)]
D=[INF]*V
PV,PE=[0]*V,[0]*V
def ae(fr,to,ca,co):
  global G
  G[fr].append([to,ca,co,len(G[to]),0])
  G[to].append([fr,0,-co,len(G[fr])-1,0])

def mcf(s,t,f):
  global G,V,INF,D,PV,PE
  for i in range(V):
    for j in range(len(G[i])):
      G[i][j][4]=0
  r=0
  z=f
  while z>0:
    D=[INF]*V
    D[s]=0
    ud=True
    while ud:
      ud=False
      for x in range(V):
        if D[x]==INF:
          continue
        for i in range(len(G[x])):
          if G[x][i][1]>0 and D[G[x][i][0]]>D[x]+G[x][i][2]:
            D[G[x][i][0]]=D[x]+G[x][i][2]
            PV[G[x][i][0]]=x
            PE[G[x][i][0]]=i
            ud=True
    if D[t]==INF:
      return -INF
    d=z
    x=t
    while x!=s:
      d=min(d,G[PV[x]][PE[x]][1])
      x=PV[x]
    z-=d
    r+=d*D[t]
    x=t
    while x!=s:
      G[PV[x]][PE[x]][1]-=d
      G[PV[x]][PE[x]][4]+=d
      G[x][G[PV[x]][PE[x]][3]][1]+=d
      G[x][G[PV[x]][PE[x]][3]][4]-=d
      x=PV[x]
  return r

s=N*2
t=s+1
for i in range(N):
  ae(s,i,K,0)
  ae(N+i,t,K,0)
  for j in range(N):
    ae(i,N+j,1,10**10-A[i][j])
ae(s,t,N*K,10**10)
print(N*K*10**10-mcf(s,t,N*K))
P=[['.']*N for i in range(N)]
for i in range(N):
  for j in range(len(G[i])):
    if G[i][j][4]>0:
      P[i][G[i][j][0]-N]='X'
  print(''.join(P[i]))

Measured memory_bytes: 69452
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<climits>
#include <sstream>
using namespace std;

int main() {
  int N;
  int cnt=0;
  int tmp=0;
  int f1=0;
  int f2=0;
  string S;
  string s1;
  string s2;
  string s3;
  istringstream ss1;
  istringstream ss2;
  istringstream ss3;
  int p1;
  int p2;
  int p3;

  cin >> S;

  s1 = S.substr(0,4);
  s2 = S.substr(5,2);
  s3 = S.substr(8,2);

  ss1 = istringstream(s1);
  ss2 = istringstream(s2);
  ss3 = istringstream(s3);

  ss1 >> p1;
  ss2 >> p2;
  ss3 >> p3;

  //2019/4
  if(p1 == 2019 && p2 == 4 && p3 <= 30){
    cout << "Heisei" << endl;
  }else if(p1 == 2019 && p2 <=4){
    cout << "Heisei" << endl;
  }else if(p1 < 2019){
    cout << "Heisei" << endl;
  }else{
    cout << "TBD" << endl;
  }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mset(m,v) memset(m,v,sizeof(m))
#define pr(a,s) printf("Case #%lld: %lld\n",a,s)
#define mod 1000000007
#define mp make_pair
#define all(a)                a.begin(),a.end()
#define pb push_back
#define scan(a) scanf("%d",&a)
#define scanl(a) scanf("%lld",&a)
#define se second
#define fi first
#define pi 3.14159265358979323
#define pii pair<ll,ll>
 
const ll inf = 1e15;
const int MAXM = 1e2+4;
const int MAXN = 1e5+10;

int n, w;
int weight[MAXM], value[MAXM];
ll dp[MAXM][MAXN];

ll solve(int n, int w)
{
	if (w < 0)	return -inf;
	if (n == 0)	return 0;
	if (dp[n][w] != -1)	return dp[n][w];
	ll ret = 0;
	ret = max(ret, value[n]*1LL + solve(n-1, w-weight[n]));
	ret = max(ret, solve(n-1, w));
	return dp[n][w] = ret;
}

int main() 
{
	mset(dp, -1);
	cin>>n>>w;
	for (int i=1;i<=n;i++) {
		cin>>weight[i]>>value[i];
	}
	cout << solve(n, w) << endl;
	return 0;
}

Measured memory_bytes: 81536
import java.util.Scanner;

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

    while (in.hasNext()) {
      int A = in.nextInt();
      int B = in.nextInt();

      if (A % 2 == 0 || B % 2 == 0) {
        System.out.println("No");
      } else {
        System.out.println("Yes");
      }
    }
  }
}

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

int main() {
  int N;
  cin >> N;
  int x = 0;
  for (int i = 0; i < N; i++) {
    int e;
    cin >> e;
    if (e == x+1) x += 1;
  }
  if (x == 0) {
    cout << -1 << endl;
    return 0;
  }
  cout << N-x << endl;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  
  int ret = 0;
  
  for(int i = 0;i < n;i++){
    int b;
    cin >> b;
    if(b >= k)ret++;
  }
  
  cout << ret << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int n, v[20], c[20], ans=0, i;
    scanf("%d", &n);
    for(i=0;i<n;i++){
        scanf("%d", &v[i]);
    }
    for(i=0;i<n;i++){
        scanf("%d", &c[i]);
    }

    for(i=0;i<n;i++){
        if(v[i]-c[i]>0) ans=ans+v[i]-c[i];
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>

using namespace std;

const long long md = 45;

vector<long long> A;
long long cnt[md];
long long sum1[md];
long long sum2[md];
long long N, K;
int main()
{
    cin >> N >> K;
    A.resize(N);

    for (long long i = 0; i < N;i++)
    {
        cin >> A[i];
        for (long long j = 0; j < md;j++)
        {
            if((1LL << j) & A[i])
            {
                cnt[j]++;
            }
        }
    }

    sum1[0] = max(cnt[0], N - cnt[0]);
    for (long long i = 1; i < md; i++)
    {
        sum1[i] = sum1[i - 1] + pow(2LL, i) * max(cnt[i], N - cnt[i]);
    }

    long long ans = 0;
    long long t = 0;
    for (long long i = md - 1; i >= 0; i--)
    {
        long long a1 = pow(2LL, i) * (N - cnt[i]);
        long long a2 = pow(2LL, i) * cnt[i];
        if (K & (1LL << i))
        {
            if(i != 0)
            {
                ans = max(ans, t + a2 + sum1[i - 1]);
            }
            t += a1;
        }
        else
        {
            t += a2;
        }
    }
    ans = max(ans, t);

    cout << ans << endl;

    return 0;
}


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

int main(){
    int N, K; cin >> N >> K;
    vector<int> A(N);
    for(int i = 0; i <N; i++ ) cin >> A[i];

    map<int, int> mp;
    for(int i = 0; i < N; i++){
        mp[A[i]]++;
    }
    vector<int> B;
    for(auto p: mp){
        B.push_back(p.second);
    }
    //cout << "Yes"<<endl;

    sort(B.begin(), B.end());
    int sum = 0;
    int f = B.size();
    //cout << B.size() << "  " << K << endl;
    if(f - K <= 0){
        cout << 0 <<endl;
        return 0;
    }
    else{
        for(int i = 0; i < B.size() - K; i++ ){
            sum += B[i];
        }
        cout << sum <<endl;
    }
}

Measured memory_bytes: 11516
<?php
$array = explode(" ", trim(fgets(STDIN)));
$N = $array[0];
$M = $array[1];
$red = array();
$num = array();
for($i = 0; $i < $N; $i++) {
  if($i == 0) {
    $red[$i] = true;
  } else {
    $red[$i] = false;
  }
  $num[$i] = 1;
}
for($i = 0; $i < $M; $i++) {
  $a = explode(" ", trim(fgets(STDIN)));
  $x = $a[0] - 1;
  $y = $a[1] - 1;
  if($red[$x]) {
    if($num[$x] == 1) {
      $red[$x] = false;
      $red[$y] = true;
    } else {
      $red[$y] = true;
    }
  }
  $num[$x]--;
  $num[$y]++;
}
$ans = 0;
for($i = 0; $i < $N; $i++) {
  if($red[$i]) $ans++;
}
print($ans);
?>

Measured memory_bytes: 14840
dice1 = input().rstrip().split(' ')
dice2 = input().rstrip().split(' ')
indication = "EEENEEENEEESEEESEEENEEENSWWSWWWNWWWNWWWSWWWSWWW"
indic = list(indication)
length = len(indic)
count =0
for i in range(length):
  newdice = [0] * 6
  if str(indic[i]) == "N":
    newdice[0] = dice2[1]
    newdice[1] = dice2[5]
    newdice[2] = dice2[2]
    newdice[3] = dice2[3]
    newdice[4] = dice2[0]
    newdice[5] = dice2[4]
    dice2 = newdice
    if dice2 == dice1:
      count += 1
  elif str(indic[i]) == "S":
    newdice[0] = dice2[4]
    newdice[1] = dice2[0]
    newdice[2] = dice2[2]
    newdice[3] = dice2[3]
    newdice[4] = dice2[5]
    newdice[5] = dice2[1]
    dice2 = newdice
    if dice2 == dice1:
      count += 1
  elif str(indic[i]) == "E":
    newdice[0] = dice2[3]
    newdice[1] = dice2[1]
    newdice[2] = dice2[0]
    newdice[3] = dice2[5]
    newdice[4] = dice2[4]
    newdice[5] = dice2[2]
    dice2 = newdice
    if dice2 == dice1:
      count += 1
  elif str(indic[i]) == "W":
    newdice[0] = dice2[2]
    newdice[1] = dice2[1]
    newdice[2] = dice2[5]
    newdice[3] = dice2[0]
    newdice[4] = dice2[4]
    newdice[5] = dice2[3]
    dice2 = newdice
    if dice2 == dice1:
      count += 1

if count == 0:
  print("No")
else:
  print("Yes")


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

#define ll              long long int
#define scan(any)       for(auto &i:any) cin>>i;
#define print(any)      for(auto i:any) cout<<i<<" "; 
#define endl            '\n'
#define pb push_back
#define vll vector<ll> 
#define f(i,x,y)  for(i=x;i<y;i++)
#define INF     LLONG_MAX
#define fast    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define p2(n,x)    cout << fixed << setprecision(x) <<n<<endl; 
#define pll    pair<ll,ll> 
#define ff first
#define ss second
#define blt(x)   __builtin_popcount(x)
void addedge(vector<ll> adj[],int u,int v)
{
    adj[u].pb(v);
    adj[v].pb(u);
}
ll c=0;
void dfs(vll adj[],ll u,vector<bool> &vis)
{
    c++;
    vis[u]=true;
    ll i;
    f(i,0,(int)adj[u].size())
    {
        if(!vis[adj[u][i]])
        {
            dfs(adj,adj[u][i],vis);
        }
    }
}
void solve()
{
    ll i,j,k,n,m;
    cin>>n>>m;
    vll adj[n];
    map<pll,ll> m2;
    f(i,0,m)
    {
        cin>>j>>k;
        j--;
        k--;
        if(!m2[{j,k}] && !m2[{k,j}])
        {
            m2[{j,k}]++;
            m2[{k,j}]++;
            addedge(adj,j,k);
        }
    }
    vector<bool> vis(n,false);
    ll mx=-10;
    f(i,0,n)
    {
        if(!vis[i])
        {
            c=0;
            dfs(adj,i,vis);
            mx=max(mx,c);
        }
    }
    cout<<mx;
}

int main()
{
    
    fast
    ll t = 1;

    

    while(t--)
    solve();
    
    return 0;
}

Measured memory_bytes: 48972
n = int(input())
d, x = map(int, input().split())
a = []
for i in range(n):
    a.append(int(input()))

choco = x

for i in a:
    for j in range(d+1):
        chocoday = i * j + 1
        if chocoday <= d:
            choco += 1
        else:
            break
        
print(choco)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main() {
    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin.exceptions(cin.failbit);
    int n;
    cin >> n;
    vector<vector<pii>> a(n);
    rep(i, 0, n){
        int ai;
        cin >> ai;
        a[i].resize(ai);
        rep(j, 0, ai) cin >> a[i][j].first >> a[i][j].second, a[i][j].first--;
    }
    /*rep(i, 0, n){
        rep(j, 0, sz(a[i])){
            cout << a[i][j].first << ' ' << a[i][j].second << '\n';
        }
        cout << '\n';
    }*/
    int ans = 0;
    rep(i, 0, 1 << n){
        int temp = 0;
        bool flag = false;
        //cout << i << '\n';
        rep(j, 0, n){
            if ((1 << j) & i){
                //cout << j << '\n';
                rep(k, 0, sz(a[j])){
                    int bit = ((1 << (a[j][k].first)) & i) > 0;
                    //cout << bit << '\n';
                    if ((bit) != a[j][k].second) flag= true;
                }
                //cout << '\n';
                //if (!flag) temp++;
                temp++;
            }
        }
        if (flag) temp = 0;
        //cout << temp << '\n' << '\n';
        //if(temp) cout << i << '\n'<<'\n';
        ans = max(ans, temp);
    }
    cout << ans << '\n';
    return 0;
}


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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
		cin.tie(0);							     \
		cout.tie(0);
#define sz(arr) (ll)arr.size()

using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18 + 9;
const double PI = 4.0 * atan(1.0);

ll powmod(ll a, ll b, const ll MOD) { ll res = 1; a %= MOD; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % MOD; a = a * a % MOD; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }

//vector<pair<ll,ll>> factors(ll n) {
//	vector<pair<ll,ll>> f;
//	for (ll x = 2; x * x <= n; ++x) {
//		ll cnt = 0;
//		while (n % x == 0) {
//			++cnt;
//			n /= x;
//		}
//		if (cnt > 0)
//			f.push_back({ x, cnt });
//	}
//	if (n > 1) f.push_back({ n,1 });
//	return f;
//}

//ll f[200005];
//ll kCn(ll k, ll n) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }

ll dp[2009][2009];

int main() {
	//#ifndef ONLINE_JUDGE
	//	(void)freopen("input.txt", "r", stdin);
	//	(void)freopen("output.txt", "w", stdout);
	//#endif // !ONLINE_JUDGE
	fastio;
	ll n, k;
	cin >> n >> k;
	int res = 0;
	while (n > 0) {
		++res;
		n /= k;
	}
	cout << res;
	return 0;
}


Measured memory_bytes: 256
// 全探索 (p.142 ~ p.145)

#include<stdio.h>

int n, A[50];

// 入力値のMから選んだ要素を引いていく再帰関数
int solve (int i, int m) {
  if ( m == 0 ) return 1;
  if ( i >= n ) return 0;
  int res = solve(i + 1, m) || solve(i + 1, m - A[i]);  // 選ばない→左、選ぶ→右
  return res;
}

int main() {
  int q, M, i;

  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);  // 材料になる数列
  scanf("%d", &q);
  for ( i = 0; i < q; i++) {
    scanf("%d", &M);  // 問題の数
    if ( solve(0, M) ) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}


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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> H(N, 0);
    vector<bool> X(N, true);
    for (int i = 0; i < N; i++)
    {
        cin >> H[i];
    }
    for (int i = 0; i < M; i++)
    {
        int A, B;
        cin >> A >> B;
        if (H[A - 1] == H[B - 1])
        {
            X[B - 1] = false;
            X[A - 1] = false;
        }
        else if (H[A - 1] > H[B - 1])
        {
            X[B - 1] = false;
        }
        else
        {
            X[A - 1] = false;
        }
    }
    cout << count(X.begin(), X.end(), true) << endl;

    return 0;
}

Measured memory_bytes: 3788
#include <stdio.h>
int main(void){
int i,x,y;
    for(i=1;i<=3000;i++){
        scanf("%d %d",&x,&y);
   
    if(0<=x&&x<=10000&&0<=y&&y<=10000){
        
        if(x==0&&y==0)
        break;
        
        if(x<y){
        printf("%d %d\n",x,y);
        }
        else{
        printf("%d %d\n",y,x);
    }
    }
        else break;
    }

    return 0;  
}


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

public class Main {

    public static void main(String[] args) throws Exception {
        PrintWriter pw = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        String t = sc.next();
        int sn = sc.nextInt();
        int tn = sc.nextInt();

        String in = sc.next();
        if (in.equals(s)) {
            sn = sn - 1;
        }
        else if (in.equals(t))
            tn-=1;
        pw.println(sn + " " + tn);

        pw.close();
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(String file) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(file));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

        public String nextLine() throws IOException {
            return br.readLine();
        }

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

        public boolean ready() throws IOException {
            return br.ready();
        }

    }
}




Measured memory_bytes: 21716
import copy
import itertools

def cooktime(n):
  if n % 10 == 0:
    ans  = n
  else:
    ans = (n//10+1)*10  
  return ans

l = []
for i in range(5):
  l.append(int(input()))
best = 9999
all_list = list(itertools.permutations(l))
while len(all_list):
  seq = all_list.pop()
  sum = 0
  for i in range(len(seq)):
    if i==4:
      sum += seq[i]
    else:
      sum = cooktime(sum+seq[i])
  if sum < best:
    best = sum

print(best)
    
      

Measured memory_bytes: 3444
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"

using namespace std;

const long long int MOD = 1000000007;

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

list<int> Prime(int num) {
	list<int>P;
	P.push_back(2);
	P.push_back(3);
	for (int i = 5; i <= num; i += 6) {
		bool flag = true;
		for (auto j : P) {
			if (j*j > i) {
				break;
			}
			if (i%j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i);
		flag = true;
		for (auto j : P) {
			if (j*j > i + 2) {
				break;
			}
			if ((i + 2) % j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i + 2);
	}
	return P;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	list<int>P = Prime(1299709);
	cin >> N;
	vector<int>num(1299710);
	int bef = 2;
	for (auto i : P) {
		num[i] = 0;
		for (int j = bef+1; j < i; j++) {
			num[j] = i - bef;
		}
		bef = i;
	}
	while (N) {
		cout << num[N] << endl;
		cin >> N;
	}
	return 0;
}

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


int main(){
	int k=0,n,m; //n:buy count  m: count
	std::vector<int> cheap;
	
	while(std::cin >> n >> m){
		if(n == 0 && m == 0)
			break;
		
		std::vector<int> p;
		p.resize(n);
		for(int i=0; i<n; ++i){
			std::cin >> p[i];
		}
		
		std::sort(p.begin(), p.end(), std::greater<int>());

		int sum=0;
		for(int i=0; i<n; ++i){
			if((i+1)%m != 0)
				sum += p[i];
		}
		cheap.push_back(sum);
		++k;
	}
	
	for(int i=0; i<k; ++i){
		std::cout << cheap[i] << std::endl;
	}
	
	return 0;
}

Measured memory_bytes: 1220
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;
U_MAP mp;

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

  cin >> n;
  rep(i, n) cin >> a[i];
  rep(i, n) {
    ll to = a[i];
    to--;
    if (a[to] - 1 == i) {
      ans++;
    }
  }
  Cout(ans / 2);
  return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
pair<int, int> P[201];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", &P[i].first), P[i].second = i;

    VI ans;
    while (1) {
	if ((P[0].first < P[N-1].first) != (P[0].second < P[N-1].second)) {
	    ans.push_back(N-1);
	    swap(P[0].first, P[N-1].first);
	}

	if (P[0].second == 0) {
	    bool ok = true;
	    REP (i, N) if (P[i].first != i) {
		ok = false;
		break;
	    }
	    if (ok) break;
	}
	ans.push_back(1);
	for (int i=1; i<N; i++) swap(P[i], P[i-1]);
    }

    printf("%d\n", (int)ans.size());
    EACH (e, ans) printf("%d\n", *e);

    REP (i, N) eprintf("%d %d, ", P[i].first, P[i].second);
    eprintf("\n");
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  
  rep(i,3){
    if(n%10==7) {
      cout << "Yes";
      return 0;
    }
    else n/=10;
  }
  cout << "No";
  return 0;
  
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iterator>
//#include<math.h>

using namespace std;
#define int long long
/*                      */    //#undef int
#define INF 1000000009
#define INFL 1000000000000000018ll
#define mod 1000000007ll
#define pb push_back
#define fi first
#define se second
#define mk(a, b) make_pair(a, b)
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef priority_queue<PA, vector<PA>, greater<PA> >PQG;

int Q, sum[100005];

bool prime(int n)
{
    bool res = true;
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0){
            res = false;
        }
    }
    return res;
}

bool similar(int n)
{
    n /= 2;
    if(n == 1 || n == 0){
        return false;
    }
    return prime(n);
}

signed main()
{
    for(int i = 2; i <= 100000; i++){
        if(prime(i)){
            if(similar(i + 1)){
                sum[i] = 1;
            }
        }
    }
    for(int i = 1; i <= 100000; i++){
        sum[i] += sum[i - 1];
    }
    cin >> Q;
    for(int i = 0; i < Q; i++){
        int l, r;
        cin >> l >> r;
        cout << sum[r] - sum[l - 1] << endl;
    }

    return 0;
}
/*


*/


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
using P = pair<ll, ll>;

template<class T> inline bool chmin(T& a,T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if (a < b) {a = b; return true;} return false;}

const ll MOD = 1000000007;
const int INF = 1<<29;

//Nが素数であるかどうか
bool is_prime(ll N){
  if (N == 1) return false;
  for (ll i = 2; i * i <= N; ++i){
    if (N % i == 0) return false;
  }
  return true;
}

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

  vector<ll> prime(200000);
  for (int i = 2; i < 200000; ++i){
    if (is_prime(i)) prime.push_back(i);
  }
  auto itr = lower_bound(prime.begin(), prime.end(), X);
  ll res_idx = distance(prime.begin(), itr);
  ll res = prime[res_idx];
  cout << res << endl;
}


Measured memory_bytes: 4736
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    int n,kk; cin >> n >> kk;
    vector<int> v(n); rep(i,n) cin >> v[i];
    int ans = 0;
    for(int i=0; i<=min(n,kk);i++){
        for(int j=0; j<=i;j++){
            vector<int> tv;
            for(int k=0;k<j;k++) tv.push_back(v[k]);
            for(int k=0;k<(i-j);k++) tv.push_back(v[n-k-1]);
            sort(all(tv));
            int t = 0;
            int kkk = kk - i;
            for(auto x: tv){
                if(x < 0 && kkk>0){ kkk--; continue;}
                else t += x;
            }
            ans = max(t,ans);
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,pair<int,int>> iii;
typedef vector<pair<int,int>> vii;
typedef vector<vector<int>> vvi;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LSOne(i) ((i) & -(i))

const int MAXN = 3010;
int n;
ll A[MAXN];

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

    cin >> n;
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
        ans += A[i]-1;
    }

    cout << ans << endl;

    return 0;
}


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

int main()
{
    int X;
    cin >> X;
    bool f[1000 + 1] = {};
    f[1] = true;
    for (int i = 2; i < 32; i++)
    {
        int idx = i * i;
        while (idx <= 1000)
        {
            f[idx] = true;
            idx *= i;
        }
    }
    while (X > 0)
    {
        if (f[X])
        {
            cout << X << endl;
            return 0;
        }
        X--;
    }
    cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
n = N
l = []
while True:
    a = n%26 if n % 26 != 0 else 26
    n = n // 26 - 1 if n % 26 == 0 else n // 26
    l.append(a)
    if n == 0:
        break
l.reverse()
print(*[chr(ans+96) for ans in l], sep='')

Measured memory_bytes: 9220
package main

import "fmt"

func main() {
	var A, B int
	fmt.Scanf("%d %d", &A, &B)

	var ans int
	if A >= 13 {
		ans = B
	} else if A >= 6 {
		ans = B / 2
	} else {
		ans = 0
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define fi first
#define se second
#define rep(i,N) for(int i=0;i<(int)N;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

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

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

ll waz = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<ll> p;

ll phi(ll x) {
    ll a = x;
    ll b = x;
    for (ll k = 0; k != p.size(); ++k) {
        if (a % p[k] == 0) {
            while (a % p[k] == 0) {
                a /= p[k];
            }
            b = b / p[k] * (p[k] - 1);
        }
        if (a == 1) { break; }
    }
    return b;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    IO;

    long double W, H, x, y;
    cin >> W >> H >> x >> y;

    cout << W * H / 2 << endl;

    if (x * 2 == W && y * 2 == H) { cout << 1 << endl; }
    else { cout << 0 << endl; }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
long long n;
vector <vector <long long> > v;
vector <vector <long long> > dp;

long long f(long long i,long long j) {
	if (dp[i][j] != 0) return dp[i][j];
	
	dp[i][0] = max(f(i+1,1),f(i+1,2)) + v[i][0];
	dp[i][1] = max(f(i+1,0),f(i+1,2)) + v[i][1];
	dp[i][2] = max(f(i+1,1),f(i+1,0)) + v[i][2];
	
	return dp[i][j];	
}

int main () {
	cin >> n;
	long long l = n;
	while (l--) {
		vector <long long> day;
		vector <long long> zeros;
		
		for (int i = 0;i < 3;i ++) {
		    long long x;
		    cin >> x;
		    day.push_back(x);
		    zeros.push_back(0);
		}
		v.push_back(day);
		dp.push_back(zeros);
	}
	
	for (int i = 0;i < 3;i++)dp[v.size()-1][i] = v[v.size()-1][i];
	
	f(0,0);
//	for (int i = v.size()-2;i >= 0;i--) {
//		dp[i][0] = max(dp[i+1][1],dp[i+1][2]) + v[i][0];
//		dp[i][1] = max(dp[i+1][0],dp[i+1][2]) + v[i][1];
//		dp[i][2] = max(dp[i+1][1],dp[i+1][0]) + v[i][2];
//	}
//	
	
	cout << max(dp[0][0],max(dp[0][1],dp[0][2]));
	
	return 0;
}

Measured memory_bytes: 18828
import java.io.*;
import java.util.*;
public class Main {
    private static MyScanner scanner;
    private int[] primeNumTable = new int[1001];
    private boolean[] primeTable;

    public static void main (String[] args){
        Main instance = new Main();
        scanner = instance.new MyScanner();
        instance.solve();
    }

    private void solve() {
        try {
            int N = scanner.nextInt();
            createPrimeTable(N);
            for (int i = 2; i <= N; i++) {
                countPrime(i);
            }
            long count = 1;
            for (int i = 2; i < primeNumTable.length; i++) {
                if (primeNumTable[i] != 0) {
                    count *= primeNumTable[i] + 1;
                    count %= 1000000007;
                }
            }
            System.out.println(count);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void createPrimeTable (int n) {
        primeTable = new boolean[n+1];
        for (int i = 1; i <= n; i++) {
            primeTable[i] = true;
        }
        for (int i = 2; i <= n; i++) {
            if (primeTable[i]) {
                int prime = i;
                int index = i+1;
                while(index < n+1) {
                    if (index % prime == 0) {
                        primeTable[index] = false;
                    }
                    index++;
                }
            }
        }
    }

    private void countPrime (int n) {
        int index = 2;
        while(n > 1) {
            while(!primeTable[index]) {
                index++;
            }
            int prime = index;
            while(n % prime == 0) {
                n /= prime;
                primeNumTable[prime]++;
            }
            index++;
        }
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String line = br.readLine();
            while (line.equals("")) {
                line = br.readLine();
            }
            s = line.split(reg, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }

        public long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }
    }
}

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

class DisJointSet {
public:
    vector<int> rank, p;
    DisJointSet();
    DisJointSet(int n) {
        rank.resize(n, 0);
        p.resize(n, 0);
        for (int i = 0; i < n; i++) createSet(i);
    }
    
    void createSet(int i) {
        rank[i] = 0;
        p[i] = i;
    }
    
    int find(int i) {
        if (p[i] != i) {
            p[i] = find(p[i]);
        }
        return p[i];
    }
    
    void unite(int a, int b) {
        int pa = find(a);
        int pb = find(b);
        if (rank[pa] > rank[pb]) {
            p[pb] = pa;
        } else if (rank[pa] == rank[pb]) {
            p[pb] = pa;
            rank[pa] += 1;
        } else {
            p[pa] = pb;
        }
    }
    
    bool same(int a, int b) {
        return (find(a) == find(b));
    }
    
    
};

int main(int argc, const char * argv[]) {
    int n,q,c,x,y;
    cin >> n >> q;
    DisJointSet d = DisJointSet(n);
    for (int i = 0; i < q; i++) {
        cin >> c >> x >> y;
        if (c == 0) {
            d.unite(x, y);
        } else {
            if (d.same(x, y)) {
                cout << 1 << endl;
            } else {
                cout << 0 << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3140
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << x << endl;
#else 
    #define dbg(x)
#endif

#define int long long
#define pb push_back
#define ppb pop_back()
#define mp make_pair
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int a[MX];

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
       
    int n;
    cin >> n;
    fi(0, n)
        cin >> a[i];
    int ans = a[0] - 1;
    a[0] = 1;
    int cur = 2;
    fi(1, n) {
        if (a[i] == cur) {
            ++cur;
        } else if (a[i] > cur) {
            ans += (a[i] - 1) / cur;
        }
    }
    cout << ans << '\n';
}

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

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

ll node[1000000];
ll cc;

void update(ll i){
    node[cc]=i;
    ll j=cc;
    ll a;
    while(j>0 && node[((j-1)-(j-1)%2)/2]<node[j]){
        a=node[((j-1)-(j-1)%2)/2];
        node[((j-1)-(j-1)%2)/2]=node[j];
        node[j]=a;
        j=((j-1)-(j-1)%2)/2;
    }
    cc++;
}

ll find(){
    ll a=node[0];
    if(cc==0)return 0;
    if(cc==1){
        node[0]=0;
        cc=0;
        return a;
    }
    node[0]=node[cc-1];
    node[cc-1]=0;
    cc--;
    ll j=0;
    ll b;
    while((node[2*j+1]!=0 || node[2*j+2]!=0) && (node[j]<node[2*j+1] || node[j]<node[2*j+2])){
        if(node[2*j+1]>=node[2*j+2]){
            b=node[2*j+1];
            node[2*j+1]=node[j];
            node[j]=b;
            j=2*j+1;
        }else{
            b=node[2*j+2];
            node[2*j+2]=node[j];
            node[j]=b;
            j=2*j+2;
        }
    }
    return a;
}


int main(){
    ll n,m;cin>>n>>m;
    ll a[n],b[n];
    vector<vector<ll>> job(m+1);
    for(ll i=0;i<n;i++){
        cin>>a[i]>>b[i];
        if(a[i]<=m) job[a[i]].push_back(b[i]);
    }
    ll ans=0;
    for(ll i=1;i<=m;i++){
        for(ll j=0;j<job[i].size();j++){
            update(job[i][j]);
        }
        ans+=find();
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 7168
// ABC 085 C
#include<bits/stdc++.h>
 
using namespace std;
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define PB(a) push_back(a)
#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
tuple<int,int,int> func(int y,int n){
  REP(i,y/10+1){
    REP(j,n-i+1){
      if(10*i+5*j+(n-i-j)==y) return forward_as_tuple(i,j,n-i-j); 
    }
  }
  return forward_as_tuple(-1,-1,-1);
}
int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------

  int n,y;
  int a,b,c;
  cin >> n >>y;
  //VI d(n);
  y/=1000;
  tie(a,b,c)=func(y,n);
  cout << a << " " << b << " " << c << endl;
  return 0;
}


Measured memory_bytes: 256
#include "iostream"
using namespace std;

int main(void)
{
	int num1, num2;
	for (int i = 0; i < 4; i++)
	{
		cin >> num1 >> num2;
		switch(num1) {
			case 1:
				cout << 6000*num2 << endl;
				break;
			case 2:
				cout << 4000*num2 << endl;
				break;
			case 3:
				cout << 3000*num2 << endl;
				break;
			case 4:
				cout << 2000*num2 << endl;
				break;
		}
	}
	
	return 0;
}

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

int main(){
    string S,T;
    cin >> S >> T;
    int i,j;
    int check=0;
    int ans=-1;

    for(i=S.length()-T.length(); i>=0; i--){
        for(j=0; j<T.length(); j++){
            if(S[i+j]!='?' && S[i+j]!=T[j]) check=1;
        }
        if(check==0){
            for(j=0; j<T.length(); j++){
                S[i+j]=T[j];
            }
            ans=i;
            i=-1;
        }
        else check=0;
    }

    if(ans==-1) cout << "UNRESTORABLE" << endl;
    else{
        for(i=0; i<S.length(); i++){
            if(S[i]=='?') S[i]='a';
            cout << S[i];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <cctype>
#include <complex>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::cerr;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::stack;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

typedef long long int ll;
const int MOD = 1e9 + 7;

int main() {
    ll n, x;
    cin >> n >> x;

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

    ll cnt = 0;
    for (ll i = 0; i < n - 1; i++) {
        if (a[i] + a[i + 1] <= x) {
            continue;
        }

        ll sub = a[i] + a[i + 1] - x;
        cnt += sub;

        a[i + 1] -= min(sub, a[i + 1]);
        if (a[i] + a[i + 1] <= x) {
            continue;
        }

        sub = a[i] + a[i + 1] - x;
        a[i] -= sub;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 1152
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int M;
	std::cin >> M;
	std::cout << (48-M) << "\n";
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int h, n;
  cin >> h >> n;
  vi a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
  vector<vi> dp(n + 1, vi(h + 1, 1e9));
  dp[0][0] = 0;
  rep(i, n) rep(j, h + 1) {
    // if(j == 0) dp[i][0] = 0;
    int ni = i, nj = min(h, j + a[i]);
    dp[ni][nj] = min(dp[ni][nj], dp[i][j] + b[i]);
    ni++;
    dp[ni][j] = dp[i][j];
  }
  cout << dp[n][h] << endl;
}

Measured memory_bytes: 39424