akhauriyash/Code-Regression huggingface dataset:
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();

    int[] a = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }

    List<Long> negatives = new LinkedList<>();
    List<Long> positives = new LinkedList<>();
    int zeros = 0;

    for (long num : a) {
      if (num < 0) negatives.add(num);
      if (num > 0) positives.add(num);
      if (num == 0) zeros++;
    }

    while (zeros > 0) {
      if (positives.size() > negatives.size()) {
        negatives.add(0L);
      } else {
        positives.add(0L);
      }
      zeros--;
    }

    negatives.sort(Long::compareTo);
    positives.sort(Long::compareTo);

    List<long[]> operations = new ArrayList<>(n - 1);

    while (negatives.size() + positives.size() > 1) {
      if (negatives.size() == 0) {
        // create positives
        long min = positives.remove(0);
        long max = positives.remove(positives.size() - 1);
        long val = min - max;
        long[] operation = new long[2];
        operation[0] = min;
        operation[1] = max;
        operations.add(operation);

        negatives.add(val);
        // TODO
        negatives.sort(Long::compareTo);
      } else if (positives.size() == 0) {
        // create negatives
        long min = negatives.remove(0);
        long max = negatives.remove(negatives.size() - 1);
        long val = max - min;
        long[] operation = new long[2];
        operation[0] = max;
        operation[1] = min;
        operations.add(operation);

        positives.add(val);
        // TODO
        positives.sort(Long::compareTo);
      } else if (positives.size() > negatives.size() ) {
        long min = negatives.remove(0);
        long max = positives.remove(positives.size() - 1);

        long[] operation = new long[2];
        operation[0] = min;
        operation[1] = max;
        operations.add(operation);

        negatives.add(0, min - max);
      } else {
        long min = negatives.remove(0);
        long max = positives.remove(positives.size() - 1);

        long[] operation = new long[2];
        operation[0] = max;
        operation[1] = min;
        operations.add(operation);

        positives.add(max - min);
      }
    }
    if (positives.size() > 0) {
      os.println(positives.get(0));
    } else {
      os.println(negatives.get(0));
    }
    for (long[] operation : operations) {
      os.println(operation[0] + " " + operation[1]);
    }
  }
}

Measured memory_bytes: 70512
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>

using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

struct Rule {
	int type, value;
};
typedef vector<Rule> Rules;

int Na, Nt, Ng, Nc;
vector<Rules> rule_set;

vector<int> decoded;

ll dp[201][51][51][51] = { { { { 0 } } } };
ll dp2[51][51][51][51] = { { { { 0 } } } };

int recur(const Rules &r, int p){
	int Ntot = Na + Nt + Ng + Nc, i;
	for(i = 0; i < r.size() && p <= Ntot; ++i){
		if(r[i].type == 0){
			decoded.push_back(r[i].value);
			++p;
		}else{
			p = recur(rule_set[r[i].value], p);
		}
	}
	return p;
}

int main(){
	cin >> Na >> Nt >> Ng >> Nc;
	int m;
	cin >> m;
	map<string, int> name_table;
	string s;
	getline(cin, s);
	vector<string> raw_rules;
	for(int i = 0; i < m; ++i){
		getline(cin, s);
		name_table[s.substr(0, s.find(':'))] = i;
		raw_rules.push_back(s);
	}
	rule_set.resize(m);
	for(int i = 0; i < m; ++i){
		stringstream ss(raw_rules[i]);
		ss >> s;
		while(ss >> s){
			Rule r;
			if(s[0] == '['){
				int st = 0;
				for(int i = 1; i + 1 < s.size(); ++i){
					switch(s[i]){
						case 'A': st |= 1; break;
						case 'T': st |= 2; break;
						case 'G': st |= 4; break;
						case 'C': st |= 8; break;
					}
				}
				r.type = 0;
				r.value = st;
			}else{
				r.type = 1;
				r.value = name_table[s];
			}
			rule_set[i].push_back(r);
		}
	}
	int length = recur(rule_set[0], 0);
	int Ntot = Na + Nt + Ng + Nc;
	if(length > Ntot){
		cout << 0 << endl;
		return 0;
	}
	dp[0][0][0][0] = 1;
	for(int i = 0; i < length; ++i){
		for(int a = 0; a <= Na; ++a){
			for(int t = 0; t <= Nt; ++t){
				for(int g = 0; g <= Ng; ++g){
					if(a + t + g > i){ continue; }
					int c = i - a - t - g;
					ll cur = dp[i][a][t][g];
					if((decoded[i] & 1) && (a < Na)){
						dp[i + 1][a + 1][t][g] = (dp[i + 1][a + 1][t][g] + cur) % MOD;
					}
					if((decoded[i] & 2) && (t < Nt)){
						dp[i + 1][a][t + 1][g] = (dp[i + 1][a][t + 1][g] + cur) % MOD;
					}
					if((decoded[i] & 4) && (g < Ng)){
						dp[i + 1][a][t][g + 1] = (dp[i + 1][a][t][g + 1] + cur) % MOD;
					}
					if((decoded[i] & 8) && (c < Nc)){
						dp[i + 1][a][t][g] = (dp[i + 1][a][t][g] + cur) % MOD;
					}
				}
			}
		}
	}
	ll answer = 0;
	answer = dp[length][Na][Nt][Ng];
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 204024
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define debug(x) cerr<<#x<<" = "<<(x)<<endl
#define eps 1e-8
#define pi acos(-1.0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int MAXN=(int)2e5+5;
const int MOD=(int)1e9+7;
int a[MAXN];
ll b[MAXN],sum[MAXN];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        b[i]=b[i-1]+a[i];
        sum[i]=sum[i-1]^a[i];
    }
    int l=1;
    ll ans=1;
    for(int r=2;r<=n;r++){
        while((sum[r]^sum[l-1])!=(b[r]-b[l-1]))l++;
        ans+=r-l+1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

int main(void)
{
	int A, B;
	cin >> A >> B;

	string S;
	cin >> S;

	const string num = "0123456789";
	string ret = "Yes";
	for(int i=0; i<S.size(); i++){
		if(i == A){
			if(S[i] != '-')
				ret = "No";
		}
		else if(find(num.begin(), num.end(), S[i]) == num.end())
			ret = "No";
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
N=int(input())

import sys
sys.setrecursionlimit(10**5)
ab=[list(map(int, input().split())) for _ in range (N-1)]
con=[[] for _ in range(N+1)]

#print(ab)
for a,b in ab :
  con[a].append(b)
  con[b].append(a)

#black Fennec
pc=[0]*(N+1)
q=[(1,0)]
vis=[False]*(N+1)
vis[1]=True
Fcnt=N
while q:
  n,c=q.pop()
  pc[n]=c
  for ch in con[n]:
    if vis[ch]==True:
      continue
    vis[ch]=True
    q.append((ch,c+1))
    
q=[(N,0)]
vis=[False]*(N+1)
vis[N]=True
while q:
  n,c=q.pop()
  if pc[n]>c:
    Fcnt-=1
  for ch in con[n]:
    if vis[ch]==True:
      continue
    vis[ch]=True
    q.append((ch,c+1))
    
if Fcnt>N-Fcnt:
  print("Fennec")
else:
  print("Snuke")


Measured memory_bytes: 40140
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 10000;
// const int mod = 1000000007;
const int mod = 998244353;
const double pi = 3.141592653589;
/* struct for mod Calculation*/
struct mint {
        ll x;
        mint(ll x = 0):x((x % mod + mod) % mod) {}
        mint operator-() const { return mint(-x); }
        mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; }
        mint& operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; }
        mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
        mint operator+(const mint a) const { mint res(*this); return res += a; }
        mint operator-(const mint a) const { mint res(*this); return res -= a; }
        mint operator*(const mint a) const { mint res(*this); return res *= a; }
        mint pow(ll t) const {
            if(!t) return 1;
            mint res = pow(t/2);
            res *= res;
            return (t&1)?res*x:res;
        }
        // for prime mod
        mint inv() const { return pow(mod - 2); }
        mint& operator/=(const mint a) { return (*this) *= a.inv(); }
        mint operator/(const mint a) const { mint res(*this); return res /= a; }
        bool operator<(const mint& a)const{ return x < a.x;}
        bool operator==(const mint& a)const{ return x == a.x;}
};
mint ex(mint x, ll t) { return x.pow(t);}
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
struct combination {
        // vector size : n + 1
        vector<mint> fact, ifact;
        // precaliculation O(n)
        combination(int n):fact(n+1), ifact(n+1) {
            assert(n < mod);
            // 0! = 1;
            fact[0] = 1;
            // 1! = 0! * 1 ... n! = (n-1)! * n
            for (int i = 1; i <= n; i++) fact[i] = fact[i-1] * i;
            // 1/n! = n!^(-1)
            ifact[n] = fact[n].inv();
            // (n-1)!^(-1) = n!^(-1) * n ... 0!^(-1) = 1!^(-1) * 1
            for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i] * i;
        }
        // combination O(1)
        // nCk = n! / (k! * (n-k)!)
        //     = n! * k!^(-1) * (n-k)!^(-1)
        mint operator()(int n, int k) {
            if (k < 0 || k > n) return 0;
            return fact[n] * ifact[k] * ifact[n-k];
        }
};
/* global variables */
/* function */
/* main */
int main(){
    int n, k;
    cin >> n >> k;
    vector<pii> range(k);
    for (pii &p : range) {
        int l, r; cin >> l >> r;
        p = pii(l, r);
    }

    vector<mint> dp(n + 5, 0);
    // vector<int> dp(n + 5, 0);
    dp[1] = 1;
    dp[2] = -1;

    for (int i = 1; i < n; i++) {
        for (int j = 0; j < k; j++) {
            if (i + range[j].first > n) continue;
            int l = i + range[j].first, r = min(i + range[j].second, n);
            dp[r + 1] -= dp[i];
            dp[l] += dp[i];
        }
        dp[i + 1] += dp[i];
    }
    cout << dp[n] << '\n';
}


Measured memory_bytes: 4808
#include <bits/stdc++.h>
// C - Triangular Relationship

using namespace std;

int main() {
    int N,K,halves;

    scanf("%d%d",&N,&K);

    if (K % 2 == 0) {
        halves = N / K;
        if (N % K >= (K >> 1))
            halves++;
    }
    else
        halves = 0;

    printf("%lld\n",((long long) (N / K)) * (N / K) * (N / K) + ((long long) halves) * halves * halves);

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    set<long long> st;
    for(int i = 0; i < n; i++){
        long long a;
        cin >> a;
        auto itr = st.find(a);
        if(i != 0 && itr != st.end()){
            cout << "NO" << endl;
            return 0;
        }
        st.insert(a);
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 9600
#include <stdio.h>

typedef long long ll;

int main(void){
    ll n;
    char s[50] = {0};
    scanf("%lld", &n);

    int i = 0;
    while(n > 0){
        n -= 1;
        s[i] = 'a' + (n % 26);
        i++;
        n /= 26;
    }
    for(int j = (i - 1); j >= 0; --j){
        printf("%c", s[j]);
    }
    puts("\n");

    return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
#include<string.h>
#define L 100005

typedef struct pp{
  char name[100];
  int t;
}A;

A deq();
void enq(A x);
A Q[L];
int t,h, n;

int min(int a,int b){ return a<b ? a : b;}

int main(){

  int elaps=0, c;
  int i, q;
  A u;

  scanf("%d %d", &n, &q);

  for(i=1;i<=n;i++){
    
    scanf("%s",Q[i].name);

    scanf("%d",&Q[i].t);

  }
  
  h=1; t=n+1;

  while(h !=t){

    u=deq();
    c=min(q, u.t);
    u.t -=c;
    elaps+=c;
    if(u.t>0) enq(u);
    else{
      printf("%s %d\n",u.name, elaps);
    }
  }

  return 0;
}



A deq(){
  A x =Q[h];
  h = (h+1)%L;
  return x;
}

void enq(A x){
  Q[t]=x;
  t=(t+1)%L;
}



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

# define ll long long
ll mod=pow(10,9)+7;

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

    int n;
    cin>>n;
    int ar[n];
    for(int i=0;i<n;i++)
        cin>>ar[i];
    int dp[n]={0};
    dp[0]=0;
    dp[1]=abs(ar[1]-ar[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(ar[i]-ar[i-1]),dp[i-2]+abs(ar[i]-ar[i-2]));
    }
    cout<<dp[n-1]<<endl;
}


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

void divide(int d, int* d1, int* d10){
  *d1 = d % 10;
  *d10 = (d - *d1) /10;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int m,d,d1,d10;
  cin >>m>>d;
  int ans = 0;
  for(int i = 4; i <= m; i++){
    for(int j = 22; j <= d; j++){
      int j1, j10;
      divide(j, &j1, &j10);
      if(j1 <= 1 || j10 <= 1) continue;
      if(j1 * j10 == i) ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
   int n, a, b;
   cin >> n >> a >> b;

   if (n == 1) {
       cout << "Hello World" << endl;
   } else {
       cout << a + b << endl;
   }
}

Measured memory_bytes: 256
N, K = map(int, input().split())
*A, = map(int, input().split())
A.sort()

def chk(x):
    D = []
    c = 0
    for a in A:
        y = a % x
        D.append(y)
    D.sort()
    s = sum(D)
    e = 0; r = N*x - s
    for d in D:
        e += d
        r -= x - d
        if e == r and e <= K:
            return 1
    return 0

ans = 1
S = sum(A)
for x in range(1, int(S**.5)+1):
    if S % x == 0:
        if chk(x):
            ans = max(ans, x)
        if chk(S // x):
            ans = max(ans, S // x)
print(ans)

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

const int mod(1e9 + 7);

inline void inc(int &x, const int y) {  x = x + y >= mod ? x + y - mod : x + y;  }

inline void dec(int &x, const int y) {  x = x - y < 0 ? x - y + mod : x - y;  }

inline int add(const int x, const int y) {  return x + y >= mod ? x + y - mod : x + y;  }

inline int sub(const int x, const int y) {  return x - y < 0 ? x - y + mod : x - y;  }

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

const int maxn(205);
const int maxm(1e5 + 5);

int n, x, s[maxn], f[maxn][maxm], ans;

int main() {
	int i, j;
	scanf("%d%d", &n, &x);
	for (i = 1; i <= n; ++i) scanf("%d", &s[i]);
	sort(s + 1, s + n + 1), reverse(s + 1, s + n + 1), f[0][x] = 1;
	for (i = 1; i <= n; ++i)
		for (j = 0; j <= x; ++j)
			if (f[i - 1][j]) inc(f[i][j], (ll)f[i - 1][j] * (n - i) % mod), inc(f[i][j % s[i]], f[i - 1][j]);
	for (j = 0; j <= x; ++j) inc(ans, (ll)f[n][j] * j % mod);
	printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 78208
#include <iostream>
#include<algorithm>
using namespace std;
int main(){
  int a,b,i;
  int c=100;
  cin >> a;
  for(i=0;i<a;i++){
    int count=0;
    cin>>b;
  while(b%2==0){
      b/=2;
     count++;
    } 
   c=min(c,count);
  }
  cout<<c<<endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	K := getInt()
	a := 7
	cnt := 1
	m := make(map[int]int)
	for {
		// out(a, cnt)
		if a%K == 0 {
			out(cnt)
			return
		}
		// if cnt > 10000000 {
		// 	break
		// }
		a = a*10 + 7
		cnt++
		a %= K
		if m[a] != 0 {
			break
		}
		m[a]++
	}
	out(-1)
}


Measured memory_bytes: 82012
let n = Scanf.scanf "%d" (fun x -> x)
let s = Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x))
let a = Array.make 10010 false
let () =
  a.(0) <- true;
  s |> Array.iter begin fun c ->
    for i = (10010-1) downto c do
      a.(i) <- a.(i) || a.(i-c)
    done
  end;
  a |> Array.to_list |> List.mapi (fun i e -> i, e)
  |> List.filter (fun (i,e) -> i mod 10 <> 0 && e)
  |> List.fold_left (fun v (i,e) -> max v i) 0
  |> Printf.printf "%d\n"

Measured memory_bytes: 3968
#include  <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  int N,K,count;
  char str[100],*p;
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  N=atoi(p);
  p=strtok(NULL," \n");
  K=atoi(p);
  
  for(count=1;(K-1)*count<=N-2;count++);
  
  printf("%d\n",count);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream> 
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

using ll = long long;
#define INF 1e9
#define MOD 1e9 + 7
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, a, n) for(int i = a; i < n; i++)
#define all(in) in.begin(), in.end()
int main(){
    int N;
    cin >> N;
    int A[N];
    int cnt0 = 0, cnt1 = 0, cnt2 = 0;
    rep(i, N) cin >> A[i];
    int div[N];
    rep(i, N){
        int count = 0, r = A[i];
        while(r% 2 == 0 ){
            r = r/ 2;
            count++;
        }
        div[i] = count;
        if(count == 0) cnt0++;
        if(count == 1) cnt1++;
        if(count >= 2) cnt2++;
    }
    if(cnt1 == 0){
        if(cnt2 + 1 >= cnt0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }else{
         if(cnt0 <= cnt2) cout << "Yes" << endl;
         else cout << "No" << endl;
    }
    return 0;
    
}

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

int main() {
  int n,m;
  cin >> n;
  vector<int> h(n);
  for(int i=0; i<n; i++) {
    cin >> h.at(i);
    h.at(i)--;
  }
  
  bool flag = true;
  
  for(int i=0; i<n-1; i++) {
    if(h.at(i) <= h.at(i+1))
      continue;
    else if(h.at(i) == h.at(i+1) + 1) {
      h.at(i+1)++;
      continue;
    }
    else {
      flag = false;
      break;
    }
  }
  
  if(flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pi 3.141592653
#define pb push_back
#define pp pop_back
#define mp make_pair
#define in insert
#define ff first
#define ss second
#define mod 1000000007
#define rep(i,n) for(int i = 0 ; i<n ; i++)
#define repr(i,n) for(int i = n-1 ; i>=0 ; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define SORT(v) sort(v.begin(),v.end())
void solve();
ll gc(ll a,ll b)
{
    if(b==0) return a;
    return gc(b,a%b);
}
signed main()
{
    fast;
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}
void solve() 
{
    int n,k;
    cin>>n>>k;
    ll h[n];
    for(int i=0;i<n;i++)cin>>h[i];
    sort(h,h+n);
    ll x =0;
    if(k>=n)cout<<0<<endl;
    else{
        for(int i=0;i<n-k;i++){
            x+=h[i];
        }
        cout<<(x)<<endl;
    }
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int a, b, k[15], l[15], maxmon, ans = 1e9, sum, mon;
	cin >> a >> b;
	for (int i = 0; i < a; ++i) cin >> k[i] >> l[i];

	for (int bit = 0; bit < (1 << a); ++bit) {
		sum = 0; maxmon = -1; mon = 0;
		for (int i = 0; i < a; ++i) {
			if (bit&(1 << i)) {
				sum += k[i] * (i + 1) * 100 + l[i];
				mon += k[i];
			}
			else {
				maxmon = i;
			}
		}
		if (sum < b) {
			int n = (maxmon + 1) * 100, m = (b + n - sum - 1) / n;
			if (m >= k[maxmon]) continue;
			mon += m;
		}
		ans = min(ans, mon);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  ll n,m;
  cin >> n >> m;

  vector<ll> x(m),l(m-1);
  rep(i,m) cin >> x[i];

  vsort(x);

  rep(i,m-1)
  {
    l[i] = x[i+1] - x[i];
  }

  vsort(l);

  ll cn = (m - n > 0 ? m - n : 0);

  ll ans = 0;
  rep(i,cn)
  {
    ans += l[i];
  }

  cout << ans << endl;


  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
  int i;double n,g;
  while(scanf("%lf",&n)!=EOF){
    g=n;
    for(i=1;i<=5;i++){
      n*=2.0;
      g+=n;
      n/=3.0;
      if(i!=5)g+=n;
    }
    printf("%.10lf\n",g);
  }
  return 0;
}

Measured memory_bytes: 652
#include <stdio.h>
    #include <stdlib.h>
 
    int main(void){
     int a,b,n,p,q;
     
      if( scanf("%d%d%d",&n,&a,&b) < 3 ){
        return -1;
     }   
     
     if(a<b) {
                 if(a+b < n){
                 q=0;
                 }
                 else{       
                 q=b+a-n;
                }            
                 p=a;             
         } 
     else{
                 if(a+b < n){
                 q = 0;
                 }
                 else{
                 q=a+b-n;
              }
                 p=b;
         }
     if(a==b){
                if(b==n){
                        q=a;
                        p=b;
                  }
      }
     
     printf("%d %d\n",p,abs(q));
     
     return 0;
    }

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

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

    int N,K; cin >> N >> K;
    vector<int> A(N + 1,0);
    rep(i,N) cin >> A[i + 1];

    rep(i,K) {
        vector<int> nex(N + 1,0);
        rep(i,N) {
            int l = max(1,i + 1 - A[i + 1]);
            int r = i + 1 + A[i + 1];
            nex[l]++;
            if (r < N) nex[r + 1]--;
        }
        rep(i,N) {
            nex[i + 1] += nex[i];
        }
        if (nex == A) {
            break;
        }
        swap(nex,A);
    }
    rep(i,N) cout << A[i + 1] << ' ';
    cout << '\n';
    return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  const ll INF = 1e18;
  vector<ll> d(n + 1, INF);
  d[0] = 0;
  vector<ll> pre(n + 1, -1);
  queue<ll> q;
  q.push(0);
  ll maxi = 0;
  while (!q.empty()) {
    ll cur = q.front();
    q.pop();
    FOR(i, max(1LL, maxi - cur + 1), m + 1) {
      ll nxt = cur + i;
      if (nxt > n) continue;
      if (s[nxt] == '1') continue;
      if (d[nxt] != INF) continue;
      d[nxt] = d[cur] + 1;
      pre[nxt] = cur;
      q.push(nxt);
      maxi = max(maxi, nxt);
    }
  }
  vector<ll> ans;
  if (d[n] == INF) {
    cout << -1 << endl;
  }

  ll p = n;
  ans.push_back(n);
  while (p != -1) {
    ans.push_back(pre[p]);
    p = pre[p];
  }
  reverse(ALL(ans));
  FOR(i, 2, SZ(ans)) { cout << ans[i] - ans[i - 1] << " \n"[i == SZ(ans) - 1]; }
}

Measured memory_bytes: 3064
#include <iostream>

using namespace std;
int main() {
	int a,b,k;
    cin >> a;
	for (int i = 0; i < 4; ++i) cin >> b;
  	cin >> k;
  	if (b - a <= k) cout << "Yay!" << endl;
  	else cout << ":(" << endl;
}


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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC   
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

const ll MOD = (ll)1e9+7; //change it for other mods

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}

void solve(ll testnum)
{
    string s,t;
    cin >> s;
    cin >> t;
    if(s.size() == t.size() - 1) {
    	ll check = 0;
    	for(ll i=0;i<s.size();i++) {
    		if(s[i] != t[i]) {
    			check = 1;
    			break;
    		}
    	}
    	if(check == 0) {
    		cout << "Yes\n";
    		return;
    	}
    }
    cout << "No\n";
}

int main()
{
    FAST_IO;
    #ifdef STIO 
      freopen("input.txt" , "r", stdin);
      freopen("output.txt" , "w", stdout);
    #endif
    ll t = 1;
    // cin >> t;
    for (ll i = 1; i <= t; i++) {
        solve(i);
    }
}

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

int main() {
    int n,a[1000],i;
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &a[i]);
    }
    i--;
    for(i; i>=0; i--){
        printf("%d", a[i]);
        if(i==0){break;}
        printf(" ");
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 3184
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



int n;
string str;

int main() {
    while (cin >> n) {
        for (int it = 0; it < n; ++it) {
            int out = 0, rui[5] = {0};
            while (out < 3) {
                cin >> str;
                if (str == "HIT") {
                    if (rui[3] == 1) rui[4] += 1, rui[3] = 0;
                    if (rui[2] == 1) rui[3] += 1, rui[2] = 0;
                    if (rui[1] == 1) rui[2] += 1; rui[1] = 0;
                    rui[1] += 1;
                }
                if (str == "OUT") ++out;
                if (str == "HOMERUN") {
                    rui[4] += rui[1] + rui[2] + rui[3] + 1, rui[1] = rui[2] = rui[3] = 0;
                }
            }
            cout << rui[4] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
inline int add(int a,int b)
{a+=b;return a>=MOD?a-MOD:a;}
inline int mul(int a,int b)
{return 1LL*a*b%MOD;}
int f[1<<10];
int C[1<<10][1<<10];
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=0;i<=n;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++)
			C[i][j]=add(C[i-1][j-1],C[i-1][j]);
	}
	f[0]=1;
	while(k--){
		int x;
		scanf("%d",&x);
		for(int i=n;i>=0;--i){
			int tmp=0;
			for(int j=0;j<=i&&j<=x;j++)
				tmp=add(tmp,mul(f[i-j],mul(C[i][j],C[n-j][x-j])));
			f[i]=tmp;
		}
	}
	printf("%d\n",f[n]);
	return 0;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll h,w,k;
  cin >> h >> w >> k;
  for(ll i=0;i<=h;i++) {
    for(ll j=0;j<=w;j++) {
      if(i*j+(h-i)*(w-j)==k||i*j+(h-i)*(w-j)==h*w-k) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 384
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <cmath>
#include <random>
#include <cctype>
#include <cstdlib>
#include <algorithm>
using namespace std;

#define MK make_pair
#define PB push_back
#define LL long long
#define VS vector<string>
#define VI vector<int>
#define VII vector<int,int>
#define MSI map<string,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define W1 while(1);
const int MOD = 1000000007;
int main()
{
	int H, W;
	VS C;
	cin >> H >> W;
	REP(i,H)
	{
		string temp;
		cin >> temp;
		C.PB(temp);
	}
	REP(i,H)
	{
		cout << C[i] << endl;
		cout << C[i] << endl;
	}
	return 0;
}

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

using namespace std;

int main(){
  int i, n, a, b, c, x, y, ans;
  vector<int> data;

  while(1){
    cin >> n >> a >> b >> c >> x;
    if(n == 0 && a == 0 && b == 0 && c == 0 && x == 0) break;

    for(i=0; i<n; ++i){
      cin >> y;
      data.push_back(y);
    }

    for(i=0, ans=-1; i<=10000; ++i){
      if(x == data[0])
	data.erase(data.begin());

      if(data.size() == 0){
	ans = i;
	break;
      }
      x = (a * x + b) % c;
    }

    cout << ans << endl;
    data.clear();
  }

  return 0;
}

Measured memory_bytes: 908
N = int(input())
arr = []
sum = 0
for i in range(N):
    iin = int(input())
    arr.append(iin)
    sum += iin
arr = sorted(arr)
point = 0
if sum%10 != 0:
    print(sum)
else:
    for i in range(N):
        if arr[i]%10 != 0:
            point = sum -arr[i]
            break
        elif i == N-1:
            point == 0
    print(point)

Measured memory_bytes: 3064
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
vector<ll> tree[100010];
void solve(){
    ll N,M;
    cin >> N >> M;
    rep(i,0,M){
        ll u,v;
        cin >> u >> v;
        u--; v--;
        tree[u].push_back(v);
        tree[v].push_back(u);
    }
    priority_queue pq([](lpair l1, lpair l2){return l1 > l2;}, vector<lpair>());
    
    // priority_queue<lpair, vector<lpair> ,compare > pq;
    ll dist[100010] = {};
    rep(i,1,N) dist[i] = INF;
    pq.push({0,0});
    while(!pq.empty()){
        lpair l1 = pq.top();
        pq.pop();
        if(dist[l1.second] < l1.first) continue;
        for(auto &e: tree[l1.second]){
            if(dist[e] > dist[l1.second] + 1){
                dist[e] = dist[l1.second] + 1;
                pq.push(make_pair(dist[e], e));
            }
        }
    }
    ll ans[100010] = {};
    rep(i,1,N){
        for(auto &e: tree[i]){
            if(dist[e] == dist[i]-1){
                ans[i] = e+1;
            }
        }
    }
    print("Yes");
    rep(i,1,N) print(ans[i]);



}

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

Measured memory_bytes: 14812
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	string a;
	cin>>a;
	for(int i=0;i<a.size();i++){
		
		a[i]=a[i]+n;
		if(a[i]>90)a[i]-=26;
		cout<<a[i];
	} 
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int[][] A = new int[3][10];
		int[][] B = new int[3][10];
		int[][] C = new int[3][10];
		int[][] D = new int[3][10];
		for (int i=0; i<n; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt() - 1;
			int c = sc.nextInt() - 1;
			int d = sc.nextInt();
			if (a==1) {A[b][c] += d;}
			else if (a==2) {B[b][c] += d;}
			else if (a==3) {C[b][c] += d;}
			else if (a==4) {D[b][c] += d;}
		}
		
		for (int i=0; i<3; i++) {
			for (int j=0; j<10; j++) {
				System.out.print(" "+A[i][j]);
			}
			System.out.println();
		}
		System.out.println("####################");
		for (int i=0; i<3; i++) {
			for (int j=0; j<10; j++) {
				System.out.print(" "+B[i][j]);
			}
			System.out.println();
		}
		System.out.println("####################");
		for (int i=0; i<3; i++) {
			for (int j=0; j<10; j++) {
				System.out.print(" "+C[i][j]);
			}
			System.out.println();
		}
		System.out.println("####################");
		for (int i=0; i<3; i++) {
			for (int j=0; j<10; j++) {
				System.out.print(" "+D[i][j]);
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 30172
#include <iostream>
using namespace std;
int main(void){
    long int H, W;
    
    while(1) {
        cin >> H >> W;
        if ( H == 0 && W == 0) break;
        for (int i = 0 ; i < H ; ++i) {
            for(int j = 0 ; j < W ; ++j) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
        
    }
    return 0;
}


Measured memory_bytes: 3072
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: String,
    }
    let mut ans = vec![];
    let mut acc = 0;
    for s_ in s.chars() {
        if s_ == 'A' || s_ == 'T' || s_ == 'C' || s_ == 'G' {
            acc += 1;
        } else {
            ans.push(acc);
            acc = 0;
        }
    }
    ans.push(acc);
    println!("{}", ans.iter().max().unwrap());
}


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

// Shrotening
#define fst first
#define snd second
#define pb push_back

#define REP(i,a) for(long i=0;i<(a);++i)
#define SORT(a) std::sort((a).begin(), (a).end())

typedef long long LL;
typedef std::pair<int,int> PII;

int N;
LL K;

std::vector< PII > arr;
int main() {
    std::cin >> N >> K;
    REP(i, N) {
        int a, b;
        std::cin >> a >> b;
        arr.pb(std::make_pair(a, b));
    }
    SORT(arr);

    int i = 0;
    while(K > arr[i].snd) K -= arr[i++].snd;
    std::cout << arr[i].fst << std::endl;
}

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

// x以下のyの倍数の個数を返す
ll count(ll x, ll y){
  return(x / y);
}

int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  
  ll e = __gcd(c,d);
  ll f = c*d / e;
  
  ll tmp1 = b/c + b/d - b / f;
  ll tmp2 = (a-1)/c + (a-1)/d - (a-1)/f;
  cout << b - (a-1) - (tmp1 - tmp2) << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
using namespace std;
#define MAX make_pair(-1,INT_MAX)
vector<pair<int,int> > ary;
int n;
int right(int k){
  return 2*k+2;
}
int left(int k){
  return 2*k+1;
}
int parent(int k){
  return (k-1)/2;
}
void update(int s,int t,int p,pair<int,int> x,int l,int r){
  if(r<=s||t<=l)return;
  if(s<=l&&r<=t)ary[p]=x;
  else{
    update(s,t,left(p),x,l,(l+r)/2);
    update(s,t,right(p),x,(l+r)/2,r);
  }
}
int query(int x){
  x+=n-1;
  pair<int,int> res=ary[x];
  while(x>0){
    x=parent(x);
    res=(res<ary[x])?ary[x]:res;
  }


  return res.second;
}

void find(int x){
  cout<<query(x)<<endl;
}

int main(){
  int m,q,com,s,t,x,i=0;
  cin>>n>>q;
  while(n>pow(2,i))i++;
  n = pow(2,i);
  m = n*2-1;
  ary.resize(m*2);
  for(int i=0;i<m*2;i++)ary[i] = MAX;
  for(int i=0;i<q;i++){
    cin>>com;
    if(!com){
      cin>>s>>t>>x;
      update(s,t+1,0,make_pair(i,x),0,n);
    }
    else{
      cin>>x;
      find(x);
    }
  }
  return 0;
}


Measured memory_bytes: 7244
//#pragma GCC target("avx2")
//#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")
//assert(q==w) если q!=w --> runtime error
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bit __builtin_popcount
#define memset(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vector<int>> matrix;

inline void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const ll maxn=2e5+123;
const ll inf=1e9+123;
const ll linf=1e18+123;
const ll mod=1e9+7;
const double eps=1e-9;
const double pi=acos(-1);
int dx[8]={0,1,-1,0,1,-1,1,-1};
int dy[8]={1,0,0,-1,1,1,-1,-1};
pll a[maxn];
int main(){
    boost();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>a[i].F>>a[i].S;
    }
    sort(a+1,a+1+n);
    ll ans=0;
    for(int i=1;i<=n;i++){
        if(m<a[i].S){
            ans+=m*a[i].F;
            m=0;
        }
        else{
            ans+=a[i].F*a[i].S;
            m-=a[i].S;
        }
    }
    cout<<ans;
    exit(0);
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
using namespace std;

int max(int x, int y);
int min(int x, int y);
int gcd(int x, int y);	/*最大公約数*/
int lcm(int x, int y);	/*最小公倍数*/
void swap(int* x, int* y);	/*値の交換*/
void downsort(int* a, int n);	/*降順ソート*/
void upsort(int* a, int n);	/*昇順ソート*/

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

/*ここまでテンプレ*/

/*ここからmain関数*/

int main()
{
	int N, K;
	char S[100000];
	cin >> N >> K >> S;

	int gp = 1, G[100000];

	if (N == 0)
		G[0] = 1;
	else
		G[0] = 1;
		for (int i = 1;i < N;i++)
		{
			if (S[i - 1] != S[i])
			{
				gp++;
				G[gp - 1] = 0;
			}
			G[gp - 1]++;
		}

	//cout << "gp:" << gp << "\n";
	
	//cout << "G:";
	//for (int i = 0;i < gp;i++)
	//	cout << G[i];
	//cout << "\n";
	
	int H[100000];
	H[0] = G[0];
	for (int i = 1;i < gp;i++)
		H[i] = H[i - 1] + G[i];

	//cout << "H:";
	//for (int i = 0;i < gp;i++)
	//	cout << H[i];
	//cout << "\n";

	int m = 0;
	if (S[0] == '1')
		m = H[min(gp - 1, 2 * K)];
	if (S[0] == '0')
		m = H[min(gp - 1, 2 * K - 1)];

	for (int i = 1;i < gp;i++)
	{
		if (S[H[i-1]] == '1')
			m = max(m, H[min(i + 2 * K, gp - 1)] - H[i - 1]);
		if (S[H[i-1]] == '0')
			m = max(m, H[min(gp - 1, i + 2 * K - 1)] - H[i - 1]);
	}

	cout << m;

	return 0;
}

/*2数の大きい方を返す*/
int max(int x, int y)
{
	int max;

	if (x < y)
		max = y;
	else
		max = x;

	return max;
}

/*2数の小さい方を返す*/
int min(int x, int y)
{
	int min;

	if (x < y)
		min = x;
	else
		min = y;

	return min;
}

/*2数の最大公約数を返す*/
int gcd(int x, int y)
{
	int m;
	int gcd = 1;

	m = min(x, y);

	for (int i = 1;i <= m; i++)
	{
		if (x%i == 0 && y%i == 0)
			gcd = i;
	}

	return gcd;
}

/*2数の最小公倍数を返す*/
int lcm(int x, int y)
{
	int m;

	for (int i = 1;i <= y;i++)
	{
		if ((x*i) % y == 0) {
			m = x * i;
			break;
		}
	}

	return m;
}

/*2数の値を交換する*/
void swap(int* px, int* py)
{
	int temp;

	temp = *px;
	*px = *py;
	*py = temp;
}

/*クイックソートによる降順並べ替え*/
void downsort(int* a, int n)
{
	//初期設定
	int l = 0, r = n - 1;

	// ピボットの決定
	int piv = *a;

	//ピボットより大を左に、ピボット以下を右に
	while (l < r)
	{
		if (*(a + l) > piv)
			l++;
		else if (*(a + r) <= piv)
			r--;
		else
			swap(a + l, a + r);
	}

	//再帰処理
	if (n == 2)
		return;
	else if (l == 1 || l == 0)
		downsort(a + 1, n - 1);
	else if (r == n - 1)
		downsort(a, n - 1);
	else
	{
		downsort(a, l);
		downsort(a + l, n - l);
	}
}

/*クイックソートによる昇順ソート*/
void upsort(int* a, int n)
{
	downsort(a, n);

	for (int i = 0;i < n / 2;i++)
		swap(a[i], a[n - 1 - i]);
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define TEST(...)                                                              \
    { printf("! "), printf(__VA_ARGS__); }
#else
#define TEST(...)
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
  public:
    void solve() {
        vector<pi> f;
        vector<i64> g;
        int x, y, a, b, c;
        cin >> x >> y >> a >> b >> c;
        for (int i = 0; i < a; ++i) {
            int t;
            cin >> t;
            f.emplace_back(t, 0);
        }
        for (int i = 0; i < b; ++i) {
            int t;
            cin >> t;
            f.emplace_back(t, 1);
        }
        sort(f.begin(), f.end(), [](pi a, pi b) { return a.first > b.first; });
        for (int i = 0; i < c; ++i) {
            int t;
            cin >> t;
            g.push_back(t);
        }
        sort(g.begin(), g.end(), [](int a, int b) { return a > b; });
        for (int i = 1; i < c; ++i)
            g[i] += g[i - 1];
        int A = 0, B = 0;
        i64 ans = 0, cur = 0;
        for (int i = 0; i < f.size(); ++i) {
            if (f[i].second == 0) {
                if (A != x) {
                    A++;
                    cur += f[i].first;
                }
            } else {
                if (B != y) {
                    B++;
                    cur += f[i].first;
                }
            }
            if (x + y - A - B == 0) {
                ans = max(ans, cur);
            } else if (x + y - A - B <= c)
                ans = max(ans, cur + g[x + y - A - B - 1]);
        }
        cout << ans << '\n';
    }
} NSPACE;
int main() {
    FPEN;
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    NSPACE.solve();
}

Measured memory_bytes: 3696