akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define each(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair
#define all(c) c.begin(),c.end()
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
const int inf=(int)1e9;
const double EPS=1e-9, INF=1e12;

int n, P, Q, R, C;
int id[1000], p[1000], q[1000], r[1000];

int main(){
	while(cin >> n, n){
		rep(i, n) cin >> id[i] >> p[i] >> q[i] >> r[i];
		cin >> P >> Q >> R >> C;
		
		bool ok = 0;
		rep(i, n){
			int c = p[i] * 4 + q[i] * 9 + r[i] * 4;
			if(p[i] <= P && q[i] <= Q && r[i] <= R && c <= C){
				cout << id[i] << endl;
				ok = 1;
			}
		}
		if(!ok) cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 1176
def solve(n, A):
    A = [0] + A + [0]
    diffs = [abs(A[i] - A[i + 1]) for i in range(n + 1)]
    total = sum(diffs)
    return [total - diffs[i] - diffs[i + 1] + abs(A[i] - A[i + 2]) for i in range(n)]

_n = int(input())
_A = list(map(int, input().split()))
print(*solve(_n, _A), sep='\n')


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

int main()
{
  int64_t X,Y ;
  cin>>X>>Y ;
  X=(Y/X) ;
  
  int64_t Z=1 ;
  for(int64_t i=1;;i++){
    Z*=2 ;
    if(Z>X){
      cout<<i<<endl ;
      return 0 ;
    }
  }
  
  return 0 ;
}

Measured memory_bytes: 256
#include <stdio.h>

int gcd(int a, int b);

int main(void)
{
	int a, b;
	int g;
	
	while (scanf("%d%d", &a, &b) != EOF){
		g = gcd(a, b);
		
		printf("%d %d\n", g, a / g * b);
	}
	
	return (0);
}

int gcd(int a, int b)
{
	if(a % b == 0)return (b);
	
	return (gcd(b, a % b));
}

Measured memory_bytes: 596
N = int(input())
l = list(map(int, input().split()))

ans = 1
if 0 in l:
  print(0)
else:
  for i in l:
    ans *= i
    if ans >10**18:
      break
  
  if ans >10**18:
    print('-1')
  else:
    print(ans)

  



Measured memory_bytes: 21772
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
signed main()
{
    ios_base::sync_with_stdio(0);
    int TESTS=1;
    // cin>>TESTS;
    while(TESTS--)
    {   
        int n;
        cin>>n;
        cout<<(n*(n-1))/2;
    }   
}     

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
using namespace std ; 
int main(){
	ll n , k ; 
	cin>> n >> k ; 
	string m =""; 
	while(n > 0 ){
	int x = n%k ; 
	m+=(x - 48) ; 
	n = n/k ; 
}
//reverse(m.begin() , m.end()) ; 

	cout<<m.size()<<endl;
	
	
	
	
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,sum,sub,mul;
    scanf("%d%d",&a,&b);
    sum=a+b;
    sub=a-b;
    mul=a*b;
    if(sum>=sub&&sum>=mul)
        printf("%d",sum);
    else if(sub>=sub&&sub>=mul)
        printf("%d",sub);
    else
        printf("%d",mul);
        return 0;
}


Measured memory_bytes: 128
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

X = int(read())

def test(x):
    low = 100 * x
    high = 105 * x
    return low <= X <= high

bl = any(test(x) for x in range(X))

print(bl * 1)

Measured memory_bytes: 3060
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

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

	n, m := nextInt(), nextInt()
	fm := make(map[int]int, m)

	for i := 0; i < n; i++ {
		k := nextInt()
		for j := 0; j < k; j++ {
			fm[nextInt()-1]++
		}
	}

	c := 0
	for i := 0; i < m; i++ {
		if fm[i] == n {
			c++
		}
	}

	fmt.Println(c)
}


Measured memory_bytes: 640
#include<stdio.h>
int main()
{
    int a, b, c;
    while(1){
    scanf("%d%d%d", &a, &b, &c);
        if(a == -1 && b == -1 && c == -1)break;
        else if((30 > (a + b)) || (a == -1 || b == -1))
            printf("F\n");
        else if(a + b >= 80)
            printf("A\n");
        else if(80 > (a + b) && (a + b) >= 65)
            printf("B\n");
        else if((65 > (a + b) && (a + b) >= 50)
            || ((50 > (a + b) && (a + b) >= 30) && c >=50))
            printf("C\n");
        else if(50 > (a + b) && (a + b) >= 30)
            printf("D\n");
    }
    return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
int n,k,a[1010];
int main(){
	cin>>n>>k;
	int i,j,sum=0;
	for(i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+1+n);
	for(i=1;i<=k;i++)sum+=a[i];
	cout<<sum;
}

Measured memory_bytes: 3628
#include <stdio.h>
using namespace std;

int N, K, C;
char S[200200]; int P[200200], Q[200200];

int main()
{
	scanf ("%d %d %d", &N, &K, &C);
	scanf ("%s", S);

	for (int i = 0, c = 0; i < N; i++) if (S[i] == 'o'){
		P[i] = ++c;
		i += C;
		if (c == K) break;
	}

	for (int i = N - 1, c = K; i >= 0; i--) if (S[i] == 'o'){
		Q[i] = c--;
		i -= C;
		if (c == 0) break;
	}

	for (int i = 0; i < N; i++) if (P[i] && P[i] == Q[i]) printf ("%d\n", i + 1);

	return 0;
}

Measured memory_bytes: 4968
// header {{{
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <complex>
#include <utility>
#include <string>
#include <sstream>
#include <queue>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;

#define ALPHABET    (26)
#define EPS         (1e-10)
#define INF         (1000000005LL)
#define MOD         (1000000007LL)
#define EQ(a, b)    (abs((a)-(b)) < EPS)
// ciling(x/y) = (x+y-1)/y

typedef long long ll;
typedef unsigned long long ull;
// }}}

int main() {
    int n[3];
    cin >> n[0] >> n[1] >> n[2];
    sort(n, n+3);
    if(n[0] == 5 && n[1] == 5 && n[2] == 7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

vector<int> makePrimes(int n) {
    vector<int> res, pr(n + 1, 1);
    pr[0] = pr[1] = 0;
    for (int p = 2; p < sqrt(n) + 2; p++)
        if (pr[p])
            for (int x = p * 2; x <= n; x += p) pr[x] = 0;
    for (int p = 2; p < n + 1; p++)
        if (pr[p]) res.push_back(p);
    return res;
}

constexpr int divcount2operationcount(int d) {
    for (int i = 1;;i++) {
        d -= i;
        if (d < 0) return i - 1;
    }
}

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

    int n;
    cin >> n;

    int ans = 0;

    auto primes = makePrimes(sqrt(n) + 10);

    for (auto &&p : primes) {
        if (n == 1) break;

        int divcount = 0;
        while (n % p == 0) {
            n /= p;
            divcount++;
        }

        ans += divcount2operationcount(divcount);
    }

    if (n != 1) {
        n = 1;
        ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 12104
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;

int main()
{
    int n;
    cin >> n;
    ll cnt[5] = {}; char x[5] = {'M','A','R','C','H'};
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        for(int j = 0; j < 5; j++) if(s[0] == x[j]) cnt[j]++;
    }

    ll ans = 0;
    for(int i = 0; i < 5; i++){
        for(int j = i + 1; j < 5; j++){
            for(int k = j + 1; k < 5; k++){
                ans += cnt[i] * cnt[j] * cnt[k];
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
# frozen_string_literal: true

s = gets.chomp.split
stack = []
sp = 0
s.each do |x|
  if x == '+'
    stack[sp - 2] = stack[sp - 1] + stack[sp - 2]
    sp -= 1
  elsif x == '-'
    stack[sp - 2] = stack[sp - 2] - stack[sp - 1]
    sp -= 1
  elsif x == '*'
    stack[sp - 2] = stack[sp - 1] * stack[sp - 2]
    sp -= 1
  else
    stack[sp] = x.to_i
    sp += 1
  end
end
puts stack[0]



Measured memory_bytes: 6876
#include<bits/stdc++.h>
using namespace std;
int n,a[510][510]={},ans[510][510]={};
int main()
{
	cin>>n;
	for(int i=1;i<=2;i++)
		for(int j=1;j<=n;j++)
			cin>>a[i][j];
	for(int i=1;i<=2;i++)
	{
		for(int j=1;j<=n;j++)
		{
			ans[i][j]=max(ans[i-1][j],ans[i][j-1])+a[i][j];
		}
	}
	cout<<ans[2][n]<<endl;
	return 0;
}

Measured memory_bytes: 256
<?php
  
  fscanf(STDIN,"%d",$n);


$v_li = explode(" ",trim(fgets(STDIN)));
$c_li = explode(" ",trim(fgets(STDIN)));

$benfit = 0;

for($i=0;$i<$n;$i++){
  if($v_li[$i]>$c_li[$i]){
    $benfit +=($v_li[$i]-$c_li[$i]);
  }
}

echo $benfit."\n";

Measured memory_bytes: 4604
import numpy as np

N,M=map(int,input().split())
A=np.array([list(str(input())) for i in range(N)])
B=np.array([list(str(input())) for j in range(M)])
ans="No"

for i in range(N-M+1):
    for j in range(N-M+1):
        x=[s[j:M+j] for s in A[i:M+i]]
        if np.count_nonzero((x==B)==0) == 0:
            ans="Yes"

print(ans)

Measured memory_bytes: 27308
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;


bool odddigits(int n){
   int cnt = 0;
   while(n){
      cnt++;
      n /= 10;
   }
   return cnt % 2;
}

int32_t main(){_

   int n;
   cin>>n;
   int ans = 0;
   for (int i = 1; i <= n; ++i)
   {
      ans += odddigits(i);
   }
   
   cout<<ans;


   return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int n;
  int d[101];
  int i, j;
  int count=0;

  scanf("%d", &n);
  for (i=0; i<n; i++){
    scanf("%d", &d[i]);
  }
  for(i=0;i<n;i++){
    count++;
    for(j=0;j<i;j++){
      if(d[i] == d[j]){
        count--;
        break;
      }
    }
  }
  printf("%d", count);
  return 0;
}


Measured memory_bytes: 128
/**
 *   author: malviyanshiv
 *   created: 10 August 2019  17:24:50
**/

#include <bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for(int i = a; i < b; i++)
#define RREP(i, a, b) for(int i = a-1; i >= b; i--)
#define FORE(a) for(auto ele : a )
#define ALL(a) begin(a), end(a)
#define RPB(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define PB push_back
#define MP make_pair
#define MOD 1000000007
#define INF 0x7fffffff
#define LINF 2000000000000000007
#define F first
#define S second
#define TC int t; cin >> t; while(t--)
#define SET(a,b) memset(a,b,sizeof(a))

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

typedef long long ll;
typedef pair< int, int > PII;


void optimizeIO(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
}

int main(){
    optimizeIO();

    int a, b;
    cin >> a >> b;
    cout << max( max(a+b, a-b), a*b) << endl;
    
    return 0;
}

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

using namespace std;
int main()
{
    string s, s2;
    cin >> s >>s2;
    int len, len2;
    len=s.size(), len2=s2.size();
    if(len>len2) puts("GREATER"), exit(0);
    if(len<len2) puts("LESS"), exit(0);
    if(s>s2) puts("GREATER"), exit(0);
    if(s<s2) puts("LESS"), exit(0);
    if(s==s2) puts("EQUAL"), exit(0);
}


Measured memory_bytes: 256
n,m=map(int,input().split())
h=list(map(int,input().split()))
lst=[]
ok=[1]*n
for i in range(m):
  a,b=map(int,input().split())
  if h[a-1]>h[b-1]:
    ok[b-1]=0
  elif h[a-1]==h[b-1]:
    ok[a-1]=0
    ok[b-1]=0
  else:
    ok[a-1]=0
print(sum(ok))
    
  

Measured memory_bytes: 84628
def insertion_sort(array, size, gap=1):
    """ AOJ??¬??¶?????¬???
    http://judge.u-aizu.ac.jp/onlinejudge/commentary.jsp?id=ALDS1_1_A

    :param array: ?????????????±??????????
    :return: ?????????????????????
    """
    global Count

    for i in range(gap, len(array)):  # i????¬??????????????????????????????????
        v = array[i]  # ?????¨?????\???????????¨????????????????????????????????´???
        j = i - gap
        while j >= 0 and array[j] > v:
            array[j + gap] = array[j]
            j = j - gap
            Count += 1
        array[j + gap] = v
    return array

def shell_sort(array, n):
    Count = 0
    G = calc_gap(n)
    m = len(G)
    print(m)
    print(' '.join(map(str, G)))
    for i in range(0, m):
        insertion_sort(array, n, G[i])


def calc_gap(n):
    results = [1]
    while results[-1] < n:
        results.append(3 * results[-1] + 1)
    if len(results) > 1:
        results = results[:-1]
    results.sort(reverse=True)
    return results


Count = 0
if __name__ == '__main__':
    # ??????????????\???
    # data = [5, 1, 4, 3, 2]
    data = []
    num = int(input())
    for i in range(num):
        data.append(int(input()))

    # ???????????????
    shell_sort(data, len(data))

    # ???????????¨???
    print(Count)
    for i in data:
        print(i)

Measured memory_bytes: 47516
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main() {
    int n;
    int m;
 
   cin >> n >> m;
  
   int ans;
  
  if(m!=100){
    
    
   if(n==0){
     
      cout << m << endl;
     
   }else if(n==1){
 
    ans = 100*m;

    cout << ans << endl;
     
   }else if(n==2){
     
     ans = 10000*m;

    cout << ans << endl;
     
   }
    
  }else{
    
      if(n==0){
     
      cout << m+1 << endl;
     
   }else if(n==1){
 
    ans = 101*m;

    cout << ans << endl;
     
   }else if(n==2){
     
     ans = 10100*m;

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

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int x=0,y=0,t=0;
  scanf("%d %d",&x,&y);
  if(y>x){
    t=x;x=y;y=t;//????????????,??????x?????§??????
  }
  while (x!=0) {
    x=x%y;
    if(x>0){
      t=x;x=y;y=t;//????????????,??????x?????§??????
    }
  }
  printf("%d\n",y);
  return 0;
}

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

int main()
{
    int h,w,n;
    cin >> h >> w >> n;
    int a;
    a = max(h,w);
    int b = a, ans = 1;
    
    if (b >= n) {
        cout << ans << endl;
        return 0;
    } else {
        while (b < n) {
            ans++;
            b += a;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import math
import copy
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np
 
def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W
 
# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

N, M = l_inpl()
l = []
for _ in range(M):
    li = l_inpl()
    l.append(li)

l.sort(key=lambda x:x[1])

ans = 0
cur = None
for li in l:
    if cur is None:
        cur = li[1] - 1
        ans += 1
    elif not (li[0] <= cur <= li[1]):
        cur = li[1] - 1
        ans += 1

print(ans)


Measured memory_bytes: 65240
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, D;
    cin >> N >> D;
    cout << (N + D * 2) / (D * 2 + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

typedef struct heapNode{
  int v;
  int val;
} node;

int cmp(const node *a,const node *b){
  return a->val<=b->val;
}

void swap(node *a,node *b){
  node t=*a;
  *a=*b;
  *b=t;
  return;
}

void push(node *h,int v,int val){
  h[0].v++;
  int k=h[0].v;
  h[k].v=v;
  h[k].val=val;
  while(k>1){
    if(cmp(h+k/2,h+k)) return;
    swap(h+k/2,h+k);
    k/=2;
  }
  return;
}

int pop(node *h){
  int res=h[1].v;
  h[1]=h[h[0].v--];
  int k=1;
  int n=h[0].v;
  while(2*k+1<=n){
    if(cmp(h+k,h+2*k) && cmp(h+k,h+2*k+1)) break;
    int next=cmp(h+2*k,h+2*k+1)?2*k:2*k+1;
    swap(h+k,h+next);
    k=next;
  }
  if(2*k<=n && !cmp(h+k,h+2*k)) swap(h+k,h+2*k);
  return res;
}

typedef struct listGraph{
  int v;
  int e;
  int *start;
  int *vertex;
  int *cost;
  int *next;
} graph;

graph* newGraph(const int v,const int e){
  graph *g=(graph *)malloc(sizeof(graph));
  g->v=v;
  g->e=0;
  g->start=(int *)malloc(sizeof(int)*v);
  int i;
  for(i=0;i<v;i++) g->start[i]=-1;
  g->vertex=(int *)malloc(sizeof(int)*e);
  g->cost=(int *)malloc(sizeof(int)*e);
  g->next=(int *)malloc(sizeof(int)*e);
  return g;
}

void freeGraph(graph *g){
  free(g->start);
  free(g->vertex);
  free(g->cost);
  free(g->next);
  free(g);
  return;
}

void addEdge(graph *g,int from,int to,int cost){
  int e=g->e;
  g->vertex[e]=to;
  g->cost[e]=cost;
  g->next[e]=g->start[from];
  g->start[from]=e;
  g->e++;
  return;
}

const int inf=2000000000;

void dijkstra(graph *g,int source,int *path){
  int *used=(int *)malloc(sizeof(int)*g->v);
  int i;
  for(i=0;i<g->v;i++){
    path[i]=inf;
    used[i]=0;
  }
  node *h=(node *)malloc(sizeof(node)*(g->e+1));
  h[0].v=0;
  path[source]=0;
  push(h,source,0);
  while(h[0].v>0){
    int v=pop(h);
    if(used[v]) continue;
    used[v]=1;
    int p;
    for(p=g->start[v];p!=-1;p=g->next[p]){
      int u=g->vertex[p];
      if(path[v]+g->cost[p]>=path[u]) continue;
      path[u]=path[v]+g->cost[p];
      push(h,u,path[u]);
    }
  }
  free(h);
  free(used);
  return;
}

void run(void){
  int v,e,r;
  scanf("%d%d%d",&v,&e,&r);
  graph *g=newGraph(v,e);
  int i;
  for(i=0;i<e;i++){
    int s,t,d;
    scanf("%d%d%d",&s,&t,&d);
    addEdge(g,s,t,d);
  }
  int *path=(int *)malloc(sizeof(int)*v);
  dijkstra(g,r,path);
  for(i=0;i<v;i++){
    if(path[i]==inf){
      printf("INF\n");
    } else {
      printf("%d\n",path[i]);
    }
  }
}

int main(void){
  run();
  return 0;
}



Measured memory_bytes: 8872
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef pair<lint, pii> plp;
typedef complex<double> xy_t;
typedef vector<lint> poly;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

const lint mod = 1e9+7;
const lint INF = mod*mod;
const int MAX = 500010;

lint powmod(lint x, lint n){
    lint ret = 1;
    while(n > 0){
        if(n&1) ret *= x, ret %= mod, n -= 1;
        else x *= x, x %= mod, n >>= 1;
    }
    return ret;
}

vector<lint> fact;
vector<lint> revfact;

void setfact(int n){
    fact.resize(n+1); revfact.resize(n+1);
    fact[0] = 1;
    rep(i, n) fact[i+1] = fact[i] * (i+1) % mod;

    revfact[n] = powmod(fact[n], mod-2);
    for(int i=n-1; i>=0; i--) revfact[i] = revfact[i+1] * (i+1) % mod;
}

lint getC(int n, int r){
    if(n<r) return 0;
    return fact[n] * revfact[r] % mod * revfact[n-r] % mod;
}

int main(){
    int B, W;
    scanf("%d%d", &B, &W);
    setfact(B+W);
    lint b=0, w=0;
    lint p=revfact[2], q=p;
    For(i, 1, B+W+1){
        lint ans=(1-b+w+mod)%mod*p%mod;
        printf("%lld\n", ans);
        (b+=getC(i-1, B-1)*q%mod)%=mod;
        (w+=getC(i-1, W-1)*q%mod)%=mod;
        (q*=p)%=mod;
    }
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define fio() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define int long long
#define MOD 998244353
using namespace std;
int32_t main()
{
	fio();
	int n;
	cin>>n;
	vector<int>a(n),b(n);
	priority_queue<pair<int,int> >pq;

	for(int i =0;i<n;i++)cin>>a[i];
	for(int i =0;i<n;i++)
	{
		cin>>b[i];
		if(b[i]!=a[i])
		pq.push({b[i],i});
	}
	int ans = 0;int f = 1;
	while(!pq.empty())
	{
		int val = pq.top().first;
		int idx = pq.top().second;
		pq.pop();
		int sm = b[(idx+1)%n] + b[(idx-1+n)%n];
		ans+=(val-a[idx])/sm;
		int lol = (val-a[idx])/sm;
		if((val-a[idx])/sm <= 0)
		{
			f = 0;
			break;
		}
		b[idx] -=lol*sm;
		if(b[idx]>a[idx])
			pq.push({b[idx],idx});
	}
	if(f==1)
		cout<<ans;
	else cout<<-1;
}

Measured memory_bytes: 9584
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
class TSort {
public:
	int n;
	vector<vi> G;
	vi deg,res;
	TSort(int n_) : n(n_), G(n), deg(n, 0) {}
	void add_edge(int from,int to){
		G[from].push_back(to);
		deg[to]++;
	}
	bool solve() {
		queue<int> q;
		for(int i = 0; i < n; i++){
			if(deg[i] == 0){
				q.push(i);
			}
		}
		while(!q.empty()){
			int p = q.front();
			q.pop();
			res.push_back(p);
			for(int v : G[p]){
				if(--deg[v] == 0){
					q.push(v);
				}
			}
		}
		return (*max_element(deg.begin(),deg.end()) == 0);
	}
};

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

    int m; cin >> m;
    vector<vi> A(m, vi(m-1));
    rep(i, m) rep(j, m-1) cin >> A[i][j], A[i][j]--;

    using Pa = tuple<int, int>;
    map<Pa, int> dic;
    int n = 0;
    rep(i, m){
        rep(j, i+1, m){
            dic[Pa(i, j)] = n;
            dic[Pa(j, i)] = n++;
        }
    }
    assert(n == m * (m - 1) / 2);
    
    TSort ts(n);
    rep(i, m){
        rep(j, 1, m-1){
            int u = dic[Pa(i, A[i][j-1])];
            int v = dic[Pa(i, A[i][j])];
            ts.add_edge(u, v);
        }
    }
    if(not ts.solve()){
        cout << -1 << endl;
        return 0;
    }

    vi dp(n, 1);
    vector<vi>& G = ts.G;

    for(auto& v : ts.res){
        for(auto& nv : G[v]){
            chmax(dp[nv], dp[v] + 1);
        }
    }
    int res = *max_element(_all(dp));

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 99952
mod = 10 ** 9 + 7
n, k = map(int, input().split())
red, blue = n-k, k
ai = red + 1
print(ai)
for i in range(2, blue+1):
    ai = ai * (red-i+2) * (blue-i+1) // (i*(i-1))
    print(ai % mod)

Measured memory_bytes: 3316
<?php
	fscanf(STDIN, "%d", $n);

	for($i = 0; $i < $n; $i++) {
		fscanf(STDIN, "%lf %lf %lf %lf %lf %lf", $x1, $y1, $x2, $y2, $x3, $y3);
		$a1 = 2 * ($x2 - $x1);
		$b1 = 2 * ($y2 - $y1);
		$c1 = $x1 * $x1 - $x2 * $x2 + $y1 *$y1 - $y2 * $y2;
		$a2 = 2 * ($x3 - $x1);
		$b2 = 2 * ($y3 - $y1);
		$c2 = $x1 * $x1 - $x3 * $x3 + $y1 *$y1 - $y3 * $y3;

		$x = ($b1 * $c2 - $b2 * $c1) / ($a1 * $b2 - $a2 * $b1);
		$y = ($c1 * $a2 - $c2 * $a1) / ($a1 * $b2 - $a2 * $b1);
		$r = sqrt(($x - $x1) * ($x - $x1) + ($y - $y1) * ($y - $y1));

		printf("%.3f %.3f %.3f\n", $x, $y, $r);
	}
?>

Measured memory_bytes: 6576
N,M = map(int,input().split())
a = []
d = {}
MOD = 10**9+7
for i in range(N+1):
    d[i] = 0
for i in range(M):
    a.append(int(input()))
    d[a[i]] = 1

dp = [0] *(N+1)

dp[0] = 1
if d[1] == 0:
    dp[1] = 1

for i in range(2,N+1):
    if d[i-1] == 1 and d[i-2] == 1:
        print(0)
        exit()

    if d[i] == 0:
        dp[i] = dp[i-1] + dp[i-2]
    else:
        dp[i] = 0

print(dp[N]%MOD)


Measured memory_bytes: 476416
#include <iostream>
#include <string>
#include <math.h>
#include <vector>

using namespace std;

int main()
{
    int n, d;
    cin >> n >> d;

    if (n % (d * 2 + 1) == 0)
    {
        cout << n / (d * 2 + 1) << endl;
    }
    else
    {
        cout << n / (d * 2 + 1) + 1 << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
total = list(str(N))
ntotal = 0
for i in range(len(total)):
  ntotal += int(total[i])
#print(ntotal,ntotal % 9)
if ntotal % 9 == 0 or ntotal == 0:
  print("Yes")
else:
  print("No")
  

Measured memory_bytes: 10840
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <list>
#include <set>

using namespace std;
typedef long long ll;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
Graph G;
ll inf = 1LL<<60;

int main() {
    ll N,M,R;
    cin >> N >> M >> R;
    vector<ll> r(R);
    vector<vector<ll>> d(N,vector<ll>(N));
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            d[i][j]=inf;
        }
    }
    for(int i=0;i<R;i++){
        ll tmp;
        cin >> tmp;
        tmp--;
        r[i]=tmp;
    }
    sort(r.begin(),r.end());
    for(int i=0;i<M;i++){
        ll a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        d[a][b]=c;
        d[b][a]=c;
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            for(int v=0;v<N;v++){
                d[j][v] = min(d[j][v],d[j][i]+d[i][v]);
            }
        }
    }
    ll ans=inf;
    while(next_permutation(r.begin(),r.end())){
        ll tmp=0;
        for(int i=0;i<R-1;i++){
            tmp+=d[r[i]][r[i+1]];
        }
        ans = min(ans,tmp);
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 512
from itertools import product
from sys import stdin
readline = stdin.readline

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

result = 0
for s in product([1, -1], repeat=3):
    xyz.sort(reverse=True, key=lambda e: s[0] * e[0] + s[1] * e[1] + s[2] * e[2])
    cx, cy, cz = 0, 0, 0
    for x, y, z in xyz[:M]:
        cx += x
        cy += y
        cz += z
    result = max(result, abs(cx) + abs(cy) + abs(cz))
print(result)


Measured memory_bytes: 9344
import bisect
import math

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

am = 0
Bs = []

for _ in range(N):
  a,b = map(int, input().split())
  am = max(am, a)
  Bs.append(b)
  
Bs.sort()
j = bisect.bisect_right(Bs, am)

rlt = 0
for i in range(N-1, j-1, -1):
  H -= Bs[i]
  rlt += 1
  if H <= 0:
    break
    
if H > 0:
  rlt += math.ceil(H/am)
  
print(rlt)

Measured memory_bytes: 81324
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

int main()
{
    string a, b, c; cin >> a >> b >> c;
    int ia = 0, ib = 0, ic = 0;
    int next = 0;
    while (1) {
        if (next == 0) {
            if (ia == a.length()) {
                cout << "A" << endl;
                return 0;
            }
            next = a[ia] - 'a';
            ia++;
        } else if (next == 1) {
            if (ib == b.length()) {
                cout << "B" << endl;
                return 0;
            }
            next = b[ib] - 'a';
            ib++;
        } else {
            if (ic == c.length()) {
                cout << "C" << endl;
                return 0;
            }
            next = c[ic] - 'a';
            ic++;
        }
    }

    return 0;
}


Measured memory_bytes: 3608
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        Long[] aa = new Long[a];
        Long[] ba = new Long[b];
        Long[] ca = new Long[c];

        for(int i = 0; i<a; i++) {
            aa[i] = sc.nextLong();
        }
        for(int i = 0; i<b; i++) {
            ba[i] = sc.nextLong();
        }
        for(int i = 0; i<c; i++) {
            ca[i] = sc.nextLong();
        }

        Arrays.sort(aa,Collections.reverseOrder());
        Arrays.sort(ba,Collections.reverseOrder());
        Arrays.sort(ca,Collections.reverseOrder());

        long[] ansa = new long[x+y];
        for(int i = 0; i<x+y; i++) {
            if(i<x) ansa[i] = aa[i];
            else ansa[i] = ba[i-x];
        }

        Arrays.sort(ansa);

        long ans = 0;
        for(int i = 0; i<ansa.length; i++) {
            if(i<ca.length && ansa[i]<ca[i]) ansa[i]=ca[i];
            ans += ansa[i];
        }
        p(ans);



    }

    public static <T> void p(T message) {
        System.out.println(message);
    }

}

Measured memory_bytes: 104776
#include <bits/stdc++.h>
using namespace std;
//Coded in Dongge Jifang 4

int n,k,N;
long long a[100005],b[100005];
long long qzh[100005];
long long liml[100005],limr[100005];
long long dp[100005],dp2[100005];
long long ans=0x3f3f3f3f3f3f3f3fLL;

struct Node{
	long long num;
	Node *l,*r;
	Node(){
		num=n+1;
		l=r=0;
	}
}*root,*root2;

struct segtree{
	void init(Node* &now){
		if(!now){
			return;
		}
		init(now->l);
		init(now->r);
		delete now;
		now=0;
	}
	void update(int l,int r,long long x,Node* &now,int nl=0,int nr=k-1){
		if(!now){
			now=new Node();
		}
		if(nl>=l&&nr<=r){
			now->num=min(now->num,x);
			return;
		}
		if(nl>r||nr<l){
			return;
		}
		int m=(nl+nr)>>1;
		update(l,r,x,now->l,nl,m);
		update(l,r,x,now->r,m+1,nr);
		//now->num=min(now->l->num,now->r->num);
	}
	void upd(int l,int r,long long x,Node* &now){
		l=(l%k+k)%k;
		r=(r%k+k)%k;
		if(l<=r){
			update(l,r,x,now);
		}else{
			update(l,k-1,x,now);
			update(0,r,x,now);
		}
	}
	long long qmin(int whr,Node* &now,int nl=0,int nr=k-1){
		if(!now){
			now=new Node();
		}
		if(nl==whr&&nr==whr){
			return now->num;
		}
		int m=(nl+nr)>>1;
		if(m>=whr){
			return min(now->num,qmin(whr,now->l,nl,m));
		}else{
			return min(now->num,qmin(whr,now->r,m+1,nr));
		}
	}
}seg1,seg2;

int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",a+i,b+i);
		if(b[i]==1&&a[i]*2>k){
			puts("-1");
			return 0;
		}
	}
	for(int i=1;i<=n;i++){
		qzh[i]=qzh[i-1]+a[i];
	}
	for(int i=1;i<=n;i++){
		if(b[i]==1){
			liml[N]=2*(k-qzh[i]%k)%k;
			limr[N]=2*(k-qzh[i-1]%k)%k;
			N++;
		}
	}
	seg1.init(root);
	seg2.init(root2);
	dp[N-1]=dp2[N-1]=0;
	seg1.upd(liml[N-1]+1,limr[N-1]-1,N-1,root);
	seg2.upd(liml[N-1]+1,limr[N-1]-1,N-1,root2);
	//cerr<<liml[N-1]<<' '<<limr[N-1]<<endl;
	for(int i=N-2;i>=0;i--){
		int x=seg1.qmin(liml[i],root);
		//cerr<<liml[i]<<' '<<' '<<x<<endl;
		if(x==n+1){
			dp[i]=0;
		}else{
			dp[i]=min(dp[x]+((liml[x]-liml[i])%k+k)%k,dp2[x]+((limr[x]-liml[i])%k+k)%k);
		}
		x=seg2.qmin(limr[i],root2);
		if(x==n+1){
			dp2[i]=0;
		}else{
			dp2[i]=min(dp2[x]+((limr[x]-limr[i])%k+k)%k,dp[x]+((liml[x]-limr[i])%k+k)%k);
		}
		seg1.upd(liml[i]+1,limr[i]-1,i,root);
		seg2.upd(liml[i]+1,limr[i]-1,i,root2);
	}
	seg1.init(root);
	seg2.init(root2);
	for(int i=0;i<N;i++){
		int x=seg1.qmin(liml[i],root);
		//cerr<<i<<' '<<x<<' '<<n<<' '<<dp[i]<<endl;
		if(x==n+1){
			ans=min(ans,dp[i]);
		}
		x=seg2.qmin(limr[i],root2);
		if(x==n+1){
			ans=min(ans,dp2[i]);
		}
		seg1.upd(liml[i]+1,limr[i]-1,i,root);
		seg2.upd(liml[i]+1,limr[i]-1,i,root2);
	}
	printf("%lld\n",ans+qzh[n]*2);
	return 0;
}

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

int h[3][100005], a[100005], b[100005], c[100005];

int main(){

    int n; cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }

    h[0][1] = a[1];
    h[1][1] = b[1];
    h[2][1] = c[1];

    for(int i = 2; i <= n; i++){
        h[0][i] = max({h[0][i - 2] + a[i], h[1][i-1] + a[i], h[2][i-1] + a[i]});
        h[1][i] = max({h[1][i - 2] + b[i], h[0][i-1] + b[i], h[2][i-1] + b[i]});
        h[2][i] = max({h[2][i - 2] + c[i], h[0][i-1] + c[i], h[1][i-1] + c[i]});
    }

    cout << max({h[0][n], h[1][n], h[2][n]}) << endl;
    return 0;
}



Measured memory_bytes: 2560
/*
       Hi there <3 
──────▄▀▄─────▄▀▄
─────▄█░░▀▀▀▀▀░░█▄
─▄▄──█░░░░░░░░░░░█──▄▄
█▄▄█─█░░▀░░┬░░▀░░█─█▄▄█

*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <sstream>
#include <cstring>
#include <numeric>
#include <ctime>
#include <cassert>
#include <unordered_set>
#include<unordered_map>
#include <random>
#include <valarray>
//#include <fstream>
#define MOD 1000000007
#define re return
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define y0 y32479
#define y1 y95874
#define next next239
#define prev prev239
#define fill(x, y) memset(x, y, sizeof(x))
#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(abs(x))
#define unq(x) (x.resize(unique(all(x)) - x.begin()))
#define ba back()
#define popcount __builtin_popcountll
#define fastIO()                 \
    {                            \
        ios::sync_with_stdio(0); \
        cin.tie(0);              \
        cout.tie(0);             \
    }
#define in(x) \
    int x;    \
    cin >> x;
#define in1(x) \
    int x;     \
    cin >> x;  \
    x--;
#define inll(x) \
    ll x;       \
    cin >> x;
#define ins(x) \
    string x;  \
    cin >> x;

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef pair<double, double> pdd;
typedef long double LD;
typedef double D;

void Solve()
{
    ll d,n;
    cin>>d>>n;
    if(n==100)
        n++;
    ll ans=n*pow(100,d);
    cout<<ans<<"\n";
}

int main()
{
    fastIO();
    int t;
    t=1;
    while (t--)
    {
        Solve();
    }
    return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n,m;
P ps[11111];

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>n>>m;
		if(n==0)break;
		rep(i,n)cin>>ps[i].se>>ps[i].fi;
		sort(ps,ps+n,greater<P>());
		int res=0;
		rep(i,n){
			if(m==0)res+=ps[i].fi*ps[i].se;
			else if(m>ps[i].se){
				m-=ps[i].se;
			}else{
				res+=(ps[i].se-m)*ps[i].fi;
				m=0;
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 3220
#include <stdio.h>
 

#define MAX 20001
 
struct pair{
  int x;
  int ar;
};

int top_stack1 = 0, top_stack2 = 0;
 

int stack1[MAX];
struct pair stack2[MAX];


void pushStack1(int x) {
  
  stack1[top_stack1] = x;

  top_stack1 ++;

}
 
void pushStack2(int j, int a) {

  stack2[top_stack2].x = j;

  stack2[top_stack2].ar = a;

  top_stack2 ++;
}
 
int popStack1(void) {

  int r = 0;
 
  top_stack1--;
   
  if(top_stack1 < 0) {
    top_stack1 = 0;
    return 0;
  }
  
  r = stack1[top_stack1];

  return r;
}
 
struct pair popStack2(void){

  struct pair s;
 
  top_stack2--;
   
  if(top_stack2 < 0) {

    top_stack2 = 0;

    return;
  }

  s = stack2[top_stack2];

  return s;
 
}
  
int main() {

  int i, j,sum = 0, a;

  struct pair c;

  char input[MAX];
 
  
  scanf("%s", input);
 
  
  for (i = 0;input[i] != '\0';i ++)
    {
      if(input[i] == '\\')pushStack1(i);
      else if((input[i] == '/') && (top_stack1 > 0)){

	j = popStack1();

	sum += i - j;

	a = i - j;

	while ((top_stack2 > 0) && stack2[top_stack2 - 1].x > j) {

	  a += stack2[top_stack2 - 1].ar ;

	  c = popStack2();
	}
	pushStack2(j, a);
      }
    }
 
  
  printf("%d\n", sum);
  
  printf("%d", top_stack2);
  
  for(i = 0;i < top_stack2;i ++)
    {
      if(i < top_stack2)
	{
	  printf(" ");
	}
      printf("%d", stack2[i].ar);
    }
  printf("\n");
 
 
  return 0;
}
 

Measured memory_bytes: 644
import fractions
n = int(input())
l = list(map(int, input().split()))
m = l[0]
for i in range(1, n):
    m = m * l[i] // fractions.gcd(m, l[i])
m = m - 1
ans = 0
for i in l:
    ans += m % i
print(ans)

Measured memory_bytes: 5304
Format = ["((( a . b ) . c ) . d )", "(( a . b ) . ( c . d ))", "(( a . ( b . c )) . d )", "( a . (( b . c ) . d ))", "( a . ( b . ( c . d )))"]
Operator = ["*", "+", "-"]
def rec(expression)
  return [expression] if !expression.include?(".")
  result = Array.new
  Operator.each do |operator|
    result += rec(expression.sub(/\./, operator))
  end
  result
end
while (a, b, c, d = gets.chomp.split.sort).find{|v| v != "0"} do
  answer = "0"
  [a, b, c, d].permutation(4) do |list|
    Format.each do |expression|
      list.each do |n|
        expression = expression.sub(/[a-d]/, n)
      end
      rec(expression).each do |e|
        answer = e if eval(e) == 10
      end
    end
  end
  puts answer
end

Measured memory_bytes: 6352
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  char a[12];
  cin>>n;
  for(int i=1;i<=n;i++)
    cin>>a[i];
  cin>>k;
  for(int i=1;i<=n;i++){
  	if(a[i]!=a[k]){
      cout<<'*';
    }
    else{
      cout<<a[i];
    }
  }
}
  

Measured memory_bytes: 256
import copy
# 入力
D = int(input())
C = list(map(int, input().split()))
S_2d = []
for i in range(D):
    s_1d = list(map(int, input().split()))
    S_2d.append(s_1d)

last_days = [0] * 26
tot_score = 0

def scoring(day, tot_score, today_contest, last_days):
    today_plus = S_2d[day - 1][today_contest]
    today_minus = 0
    for j, c in enumerate(C):
        today_minus += c * (day - last_days[j])
    # print(today_plus, today_minus)
    return (today_plus - today_minus)

# A
for i in range(D):
    best_score = -10**100
    best_contest = 0
    for k, _ in enumerate(C):
        last_days_tmp = copy.copy(last_days)
        last_days_tmp[k] = i + 1
        k_score = scoring(i + 1, tot_score, k, last_days_tmp)
        if best_score < k_score:
            best_score, best_contest = k_score, k
    last_days[best_contest] = i + 1
    tot_score += best_score
    print(best_contest + 1)

# # B
# T = []
# for i in range(D):
#     t = int(input())
#     T.append(t)
# for i in range(D):
#     last_days[T[i] - 1] = i + 1
#     tot_score += scoring(i+1, tot_score, T[i] - 1)
#     print(tot_score)


Measured memory_bytes: 9336
n = int(input())
a = list(map(int,input().split()))+[0]
dp = [0 for _ in range(n+1)]
dp[0] = abs(a[0])
for i in range(1,n+1):
    dp[i] = abs(a[i] - a[i-1]) + dp[i-1]

for i in range(n):
    if i == n-1:
        print(dp[n-2]+abs(a[n-2]))
        exit()
    elif i == 0:
        print(dp[-1] -abs(0-a[i]) - abs(a[i] - a[i+1]) + abs(0-a[i+1]))

    else: print(dp[-1] +abs(a[i+1]-a[i-1]) - abs(a[i+1]-a[i])- abs(a[i]-a[i-1]))

Measured memory_bytes: 14040
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

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

	for (int i = 1; i <= 12; i++) {
		long long a = pow(26, i);
		if (N <= a) {
			for (int j = 1; j <= i; j++) {
				long long b = pow(26, i - j);
				long long c = (N - 1) / b;
				
				char o = 'a' + c;
				cout << o;
				N -= b * c;
			}
			break;
		}
		N -= a;
	}

	cout << endl;
	return 0;
}

Measured memory_bytes: 3508
#include <iostream>
#include <malloc.h>
int main()
{
	
	int n;
	scanf("%d", &n);
	
	int* x = (int*)malloc(sizeof(int)*n);
	for (int m = 0; m < n; m++) {
		scanf("%d", x + m);
	}
	int rec = 0;
	for (int k = 0; k < n; k++) {
		for (int l = k; l < n; l++) {
			rec += (*(x + k))*(*(x+l));
		}
		rec -= *(x+k)*(*(x + k));
	}
	printf("%d", rec);
	
	free(x);
	
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline())

a,b,c = LI()
if a==b==c or a!=b!=c!=a:
    print('No')
else:
    print('Yes')

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

typedef uint32_t u32;
typedef uint64_t u64;
typedef std::pair<int, int> pii;
constexpr int INF = (1 << 28);

int main() {

  std::string eraname[2000];
  int erabasedyear[2000];
  int westernyear[2000];
  
  for(;;) {
    int N, Q; std::cin >> N >> Q;
    if( N == 0 and Q == 0 ) break;

    for(int i = 0; i < N; ++i) {
      std::cin >> eraname[i] >> erabasedyear[i] >> westernyear[i];
    }
    for(int i = 0; i < Q; ++i) {
      int query; std::cin >> query;
      std::string era;
      int res = INF;      
      for(int j = 0; j < N; ++j) {
        if( query > westernyear[j] ) continue;
        auto t = query - westernyear[j] + erabasedyear[j];
        if( t <= 0 ) continue;
        if( t < res ) {
          res = t;
          era = eraname[j];
        }
      }
      if( res == INF ) {
        std::cout << "Unknown" << std::endl;
      }
      else {
        std::cout << era << ' ' << res << std::endl;
      }
    }    
  }
  
  return 0;
}

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

using namespace std;
long long n, pref[200005], a;

int main () {
    cin >> n;
    for (int i = 1; i <= n; i ++) {
        cin >> a;
        pref[i] = pref[i - 1] + a;
    }
    long long ans = 0, cur = 1;
    sort (pref, pref + n + 1);
    for (int i = 1; i <= n; i ++) {
        if (pref[i] == pref[i - 1]) {
            cur++;
        }
        else {
            ans += cur * (cur - 1) / 2;
            cur = 1;
        }
    }

    ans += cur * (cur - 1) / 2;
    cout << ans;
    return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 w,a,b;
  cin >> w >> a >> b;
  ANS(max<int32>({b-a-w,a-b-w,0}));
  return 0;
}

Measured memory_bytes: 256