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

using namespace std;

int main()
{
    int x, y, s;
    char c;
    vector<vector<int>> v(14, vector<int>(14, 0));
    while (cin >> x >> c >> y >> c >> s) {
        x += 2; y += 2;
        switch (s) {
            case 3:
                v[x][y-2]++; v[x][y+2]++;
                v[x-2][y]++; v[x+2][y]++;
            case 2:
                v[x-1][y-1]++; v[x-1][y+1]++;
                v[x+1][y-1]++; v[x+1][y+1]++;
            case 1:
                v[x+1][y]++; v[x-1][y]++;
                v[x][y-1]++; v[x][y+1]++;
                v[x][y]++;
                break;
        }
    }
    
    int mx = 0, cnt = 0;
    for (int i = 2; i < 12; i++) {
        for (int j = 2; j < 12; j++) {
            mx = max(mx, v[i][j]);
            if (v[i][j] == 0) cnt++;
        }
    }
    cout << cnt << "\n" << mx << endl;
    return 0;
}

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

def f(a, b, c):
    if (a%2 != 0) | (b%2 != 0) | (c%2 != 0):
        return 0
    if (a == b) & (b == c):
        return -1
    return f((b+c)//2, (a+c)//2, (a+b)//2) + 1
def main():
    a, b, c = map(int, readline().split())
    print(f(a, b, c))
if __name__ == '__main__':
    main()


Measured memory_bytes: 9212
import bisect

n = int(input())
a = [i*(i+1)//2 for i in range(1,5000)]
number = bisect.bisect(a,n)
diff = n - a[number-1]
plus = number - diff
for i in range(number):
  if i < plus:
    print(i+1)
  else:
    print(i+2)

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

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

  if(s == "SUN") cout << 7;
  if(s == "MON") cout << 6;
  if(s == "TUE") cout << 5;
  if(s == "WED") cout << 4;
  if(s == "THU") cout << 3;
  if(s == "FRI") cout << 2;
  if(s == "SAT") cout << 1;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    char s[3];
    int i;
    int output=0;

    scanf("%c%c%c",&s[0],&s[1],&s[2]);

    for(i=0;i<3;i++)
    {
        if(s[i]=='1')
            output++;
    }
    printf("%d",output);

    return 0;
}

Measured memory_bytes: 128
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
H,W = map(int,input().split())
h,w = map(int,input().split())
print((H-h)*(W-w))

Measured memory_bytes: 10532
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/ICPC/Prelim/1600?year=2015

#include <bits/stdc++.h>

using namespace std;

int main() {
    int m, n_min, n_max;

    while (cin >> m >> n_min >> n_max, m | n_min | n_max) {
        vector<int> a(m);
        for (int i = 0; i < m; ++i) {
            cin >> a[i];
        }

        int ans = 0;
        int gap = 0;
        for (int k = n_min; k <= n_max; ++k) {
            if (a[k - 1] - a[k] >= gap) {
                gap = a[k - 1] - a[k];
                ans = k;
            }
        }
        cout << ans << endl;
    }

    return 0;
}

/*
 * 「k人受かる」＝「n-k人落ちる」なので，
 * 合格者の最低点はa[k-1]。
 * 不合格者の最高点はa[k]，
 * これらの差が最大になる場合を調べる。
 *
 */


Measured memory_bytes: 3096
N = int(input())
T,A = map(float,input().split())
H = list(map(int,input().split()))
D = []

for i in range(N):
    D.append(T - H[i]*0.006)

D = [abs(A - D[i]) for i in range(N)]
ans = min(D)

for i in range(N):
    if ans == D[i]:
        print(i + 1)

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

#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define INF 1e+10;

int main()
{
    int n, k;
    cin >> n >> k;
    int h[n];
    for(int i=0; i<n; i++)
        cin >> h[i];
    if(n <= k+1)
        cout << abs(h[n-1] - h[0]) << "\n";
    else
    {
        int dp[n];
        for(int i=0; i<=k; i++)
        {
            dp[i] = abs(h[i] - h[0]);
        }
        for(int i=k+1; i<n; i++)
        {
            dp[i] = INF;
            for(int j=i-1; j >= i-k; j--)
                dp[i] = min(dp[i], abs(h[i] - h[j]) + dp[j]);
        }
        cout << dp[n-1] << "\n";
    }
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
  int x,a,b;
  scanf("%d %d %d",&x,&a,&b);
  int da,db;
  if(x>=a){
    da=x-a;
  }else if(x<=a){
    da=a-x;
  }
  if(x>=b){
    db=x-b;
  }else if(x<=b){
    db=b-x;
  }
  if(da<db){
    printf("A");
  }else{
    printf("B");
  }
  putchar('\n');
  return 0;
}

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

const int MOD = 1e9 + 7;

map< pair<long long, long long>, long long > memo;

long long func(long long S, long long X)
{
    if (S < 0 || X < 0) return 0;
    else if (S == 0) return 1;
    else if (S == 1) return 1 + (X >= 1);
    else if (memo.find(make_pair(S, X)) != memo.end()) return memo[make_pair(S, X)];
    else {
        return memo[make_pair(S, X)] = (func(S / 2, X / 2) + func((S - 1) / 2, (X - 1) / 2) + func((S - 2) / 2, X / 2)) % MOD;
    }
}

int main()
{
    long long N;
    scanf("%lld", &N);
    printf("%lld\n", func(N, N));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;
const ll INFll = 1E+18;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    if (s.back()=='s') {
        s += "es";
    }
    else {
        s += "s";
    }
    
    
    pr(s);
    return 0;
}


Measured memory_bytes: 3648
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    int n;
    cin >> n;
    int con=0;
    bool ok=0;
    rep(i,n){
        int a,b;
        cin >> a>> b;
        if(a==b){
            con++;
            if(con>=3){
                ok=1;
            }
        }else{
            con=0;
        }
    }
    if(ok){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3600
s = input()
n = int(input())
top = 0
llist = ""
rlist = ""
for i in range(n):
    x = input()
    if x == "1":
        top += 1
        top = top%2
    else:
        if x.split()[1] == '1':
            if top == 0:
                llist = x.split()[2] + llist
            else:
                rlist += x.split()[2]
        else:
            if top == 1:
                llist = x.split()[2] + llist
            else:
                rlist += x.split()[2]
if top == 0:
    print(llist + s + rlist)
else:
    print(rlist[::-1] + s[::-1] + llist[::-1])


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

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

  vector<vector<pii> > G(k);
  rep (u, k) {
    int nu = (u + 1) % k;
    G[u].push_back(pii(nu, 1));
    nu = u * 10 % k;
    G[u].push_back(pii(nu, 0));
  }

  vi d(k, inf);
  d[1] = 1;
  priority_queue<pii, vector<pii>, greater<pii> > pq;
  pq.push(pii(1, 1));
  while (!pq.empty()) {
    int u = pq.top().second;
    int c = pq.top().first;
    pq.pop();
    if (c > d[u]) continue;
    
    rep (i, G[u].size()) {
      int v = G[u][i].first;
      int nc = c + G[u][i].second;
      if (d[v] > nc) {
        d[v] = nc;
        pq.push(pii(nc, v));
      }
    }
  }
  cout << d[0] << endl;
}


Measured memory_bytes: 6780
/*
 * a.cc:
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
#include<iomanip>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  cout<<a*b/2<<endl;
  
}














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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int A, B, C, K;

int main(){
  cin >> A >> B >> C >> K;

  int cnt = 0;
  while (A >= B){
    B *= 2; cnt++;
  }
  while (B >= C){
    C *= 2; cnt++;
  }
  if (cnt <= K) Yes();
  else No();

  return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#define N 102
#define WHITE 0
#define GRAY 1
#define BLACK 2
 
struct info{
  int ver;
  int color;
  int dis_time;
  int fin_time;
} typedef Info;
 
void Dfs(int);
void Visit(int, int);
 
int gin[N][N];
Info x[N];
int vtime = 0;
 
int main(){
  int n, i, j;
 
  scanf("%d", &n);
  for(i = 1; i < n + 1; i++){
    scanf("%d%d", &gin[i][0], &gin[i][1]);
    for(j = 2; j < 2 + gin[i][1]; j++){
      scanf("%d", &gin[i][j]);
    }
  }
  
  Dfs(n);
 
  for(i = 1; i < n + 1; i++){
    printf("%d %d %d\n", gin[i][0], x[i].dis_time, x[i].fin_time);
  }
 
  return 0;
}
 
void Dfs(int n){
  int i, j;
 
  for(i = 1; i < n + 1; i++){
      x[i].ver = gin[i][0];
      x[i].color = WHITE;
      x[i].dis_time = 0;
      x[i].fin_time = 0;
  }
 
  for(i = 1; i < n; i++){
    if (x[i].color == WHITE) Visit(i, n);
  }
   
}
 
void Visit(int k, int n){
  int i;
 
  x[k].color = GRAY;
  x[k].dis_time = ++vtime;
    for(i = 2; i < 2 + gin[k][1]; i++){
     if(x[ gin[k][i] ].color == WHITE) Visit(gin[k][i], n) ;
  }
  x[k].color = BLACK;
  x[k].fin_time = ++vtime;
 
}

Measured memory_bytes: 636
#include <cstdio>
#include <string>
#include <vector>
#include <deque>
#include <map>

using namespace std;

const int INFTY=1<<29;

bool isgoto(const string& line){
	return *line.rbegin()==';';
}
bool islabel(const string& line){
	return *line.rbegin()==':';
}

int main()
{
	int n; scanf("%d%*c",&n);
	vector<string> lines(n);
	for(int i=0;i<n;i++){
		char s[20]; scanf("%[^\n]%*c",s);
		lines[i]=s;
	}
	
	map<string,int> ltoi; // label -> lineNum
	for(int i=0;i<n;i++)
		if(islabel(lines[i])){
			string label(lines[i].begin(),lines[i].end()-1);
			ltoi[label]=i;
		}
	
	vector<int> jump(n,-1); // ジャンプ先の行番号．i行目がgoto文でなければjump[i]=-1
	for(int i=0;i<n;i++)
		if(isgoto(lines[i])){
			string label(lines[i].begin()+5,lines[i].end()-1);
			jump[i]=ltoi[label];
		}
	
	deque<pair<int,int> > q(1,make_pair(0,0)); // (lineNum,delCount)
	vector<int> cost(n+1,-1);
	while(!q.empty()){
		pair<int,int> cur=q.front(); q.pop_front();
		int ci=cur.first,cc=cur.second;
		if(cost[ci]!=-1) continue;
		
		cost[ci]=cc;
		if(ci==n) break;
		
		if(isgoto(lines[ci])){
			q.push_front(make_pair(jump[ci],cc));
			q.push_back(make_pair(ci+1,cc+1));
		}
		else
			q.push_front(make_pair(ci+1,cc));
	}
	
	printf("%d\n",cost.back());
	
	return 0;
}

Measured memory_bytes: 1088
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,flag=0;
	char a[101];
	cin>>n;
	for(int i=1;i<=n;i++)
		{
		cin>>a[i];
		if(a[i]=='Y')
			flag=1;
		}
	if(flag==1)
		cout<<"Four";
	else
		cout<<"Three";
	return 0;	
} 

Measured memory_bytes: 384
fun main(args: Array<String>){
    var n = readLine()!!.toInt()
    var la = readLine()!!.split(" ").map(String::toInt).toMutableList()
    while(n > 1){
        la[1] %= la[0]
        if(la[1] > 0) {
            val tmp = la[0]
            la[0] = la[1]
            la[1] = tmp
        }else{
            la.removeAt(1)
            n--
        }
    }
    println(la[0])
}

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

int main() {
  string s, t;
  cin >> s >> t;
  vs ans;
  rep(i, s.size() - t.size() + 1) {
    bool same = true;
    string tmp = s;
    rep(j, t.size()) {
      if(s[i + j] != t[j] && s[i + j] != '?')
        same = false;
      else
        tmp[i + j] = t[j];
    }
    if(same) {
      replace(all(tmp), '?', 'a');
      ans.push_back(tmp);
    }
  }
  cout << (ans.size() ? *min_element(all(ans)) : "UNRESTORABLE") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  int ans[3] = {};
  cin >> a >> b;
  ans[a-1] = 1;ans[b-1] = 1;
  for(int i=0;i<3;i++){
    if(ans[i] == 0){
      cout << i+1 << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
s = input()
t = input()

s_l = len(s)
t_l = len(t)

ans = len(t)

for i in range(s_l - t_l + 1):
    s_split = s[i:t_l + i] 
   # print(s_split)
    cnt = len(t)
    for j in range(t_l):
        if s_split[j] == t[j]:
            cnt -= 1
    ans = min(ans, cnt)


print(ans)

Measured memory_bytes: 9076
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1
from collections import defaultdict

N=int(input())

M=10**6

D=[-1]*(M+1)
D[0]=D[1]=1
for i in range(2,int(M**0.5)+1):
    if D[i]!=-1:
        continue
    for j in range(i*2,M+1,i):
        if D[j]==-1:
            D[j]=i

ans=0
for i in range(1,N):
    ab=N-i
    d=defaultdict(int)
    while D[ab]>1:
        d[D[ab]]+=1
        ab//=D[ab]
    if ab>1:
        d[ab]+=1
    tmp=1
    for v in d.values():
        tmp*=(v+1)
    ans+=tmp
print(ans)

Measured memory_bytes: 77840
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			String s = sc.next();
			
			if ( s.equals("AAA") || s.equals("BBB")) {
				System.out.println("No");
			}
			else {
				System.out.println("Yes");
			}
		}
	}
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    int n;
    cin >> n;
    cout << precise(10) << ((double)(n - n / 2)) / n;
}


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

int C[30],V[30],ans[30];
int main(void){
	int N,lo=0;
	std::cin>>N;

	for(int i=0;i<N;i++){
		std::cin>>V[i];
	}

	for(int i=0;i<N;i++){
		std::cin>>C[i];
	}

	for(int i=0;i<N;i++){
		ans[i] = V[i] - C[i];
		if(ans[i] >=0){
			lo += ans[i];
		}
	}

	std::cout<<lo;

	return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		if (n % 2 == 0) {
			System.out.println("-1");
			return;
		}

		long b = 7l;
		int count = 1;
		while (count < 10000000) {
			if (b % n == 0) {
				System.out.println(count);
				return;
			}
			b *= 10;
			b += 7;
			b %= n;
			count++;
		}
		System.out.println(-1);
	}
}

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

int main()
{
	int N, M;
	scanf("%d%d", &N, &M);
	std::vector<std::pair<int64_t, int>> AB(N);
	for (auto& e: AB) scanf("%d%d", &e.first, &e.second);
	std::sort(AB.begin(), AB.end());
	int64_t ans{};
	for (int i{}; M > 0; i++)
	{
		int64_t tmp{std::min(M, AB[i].second)};
		M -= tmp;
		ans += tmp * AB[i].first;
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 1792
import sys
import copy
import  math
import bisect
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
ans = [0, 1]
for i in range(1, n+1):
    num = i
    ct = 0
    while num > 1:
        if num % 2 == 0:
            num //= 2
            ct += 1
        else:
            break
    if ct > ans[0]:
        ans = [ct, i]
print(ans[1])

Measured memory_bytes: 3444
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Part(vec, b, e) vec.begin() + b, vec.begin() + e
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(vec, s) vec.find(s) != vec.end()
#define Set_union(A, B, res) set_union(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_intersection(A, B, res) set_intersection(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_difference(A, B, res) set_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_symmetric_difference(A, B, res) set_symmetric_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));

int main() {
	string S, T;
	cin >> S >> T;
	int ans = INFTY;
	Rep(i, S.size() - T.size() + 1) {
		int cnt = 0;
		string tmp = S.substr(i, i + T.size());
		Rep(j, T.size()) {
			if (tmp[j] != T[j]) cnt++;
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''
#import copy

#import numpy as np

n, m = list(map(int, input().split()))

print(n*(n-1)//2+m*(m-1)//2)

Measured memory_bytes: 2940
n, q = map(int,input().split())
ikeru = [[] for _ in range(n)]
for i in range(n-1):
	a, b = map(int, input().split())
	ikeru[a-1].append(b-1)
	ikeru[b-1].append(a-1)

kasan = [0 for _ in range(n)]
for i in range(q):
	p, x = map(int,input().split())
	kasan[p-1] += x

ansl = [0 for _ in range(n)]
ansl[0] = kasan[0]
kaisuu = 0
settansaku = set([])
setmada = {0}
kouho = 1

while kouho != 0:
	kaisuu += 1
	for i in list(setmada):
		settansaku.add(i)
		setmada.remove(i)
		kouho -= 1
		for k in ikeru[i]:
			if not k in setmada:
				if not k in settansaku:
					setmada.add(k)
					kouho += 1
					ansl[k] = ansl[i] + kasan[k]

print(" ".join([str(ansl[i]) for i in range(n)]))

Measured memory_bytes: 84368
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define all(x) (x).begin(), (x).end()
#define pb push_back

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi b(n);
    for (int i=0; i<n; i++) cin >> b[i];
    vi ans;
    while (!b.empty()) {
        int next = 0;
        for (int i=b.size()-1; i>=0; i--) {
            if (b[i] == i+1) {
                next = i+1;
                break;
            }
        }
        if (next == 0) return cout << "-1\n", 0;
        ans.pb(next);
        for (int j=next; j<(int)b.size(); j++)
            b[j-1] = b[j];
        b.pop_back();
    }
    reverse(all(ans));
    for (int x:ans) {
        cout << x << '\n';
    }
}


Measured memory_bytes: 256
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 1e9 + 7;
const long long inf = 1e18;
 
using namespace std;
 

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 
ll binomialCoeff(ll n, ll k) 
{ 
	ll C[n + 1][k + 1]; 
	ll i, j; 


	for (i = 0; i <= n; i++) 
	{ 
		for (j = 0; j <= min(i, k); j++) 
		{ 
			
			if (j == 0 || j == i) 
				C[i][j] = 1; 

			else
				C[i][j] = (C[i - 1][j - 1] + 
										C[i - 1][j])%MOD; 
		} 
	} 

	return C[n][k]; 
}
bool compare(const string &a , const string&b){
	
}
 
void solve()
{
    int n ; 
    cin>>n ;
    int k ; 
    cin>>k ;
    int dp[n] ;
    int h[n] ;
    rep(i , n)cin>>h[i] ;
    dp[0] = 0 ;

    repu(i , 1, n-1){
    	dp[i] = INT_MAX ;
    	repu(j , 1 , k){
    		if(i-j>=0){
    			dp[i] = min(dp[i] , abs(h[i] - h[i-j])+dp[i-j]) ;
    		}
    	}
    }
    cout<<dp[n-1]<<endl;
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) puts("error")
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    inline int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> inline void add(T &x,const T y){x=mm(x+y);}
    inline ll qpower(ll x,ll e)
    {
        ll ans=1;GG(e<0);
        while(e){if(e&1)ans=ans*x%MOD;x=x*x%MOD;e>>=1;}return ans;
    }
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e6+10;

    int a[N];
    void main()
    {
        int n=qread();fo(i,1,n) a[i]=qread();
        ll ans=0,sum=0;fo(i,1,n) {sum+=a[i];if(a[i+1]==0)ans+=sum/2,sum=0;}write(ans);
    }
};//(ans+MOD)%MOD
int main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    if (n == 1) {
      System.out.println("Hello World");
    } else {
      int a = sc.nextInt();
      int b = sc.nextInt();
      System.out.println(a + b);
    }
  }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K;
  cin >> K;
  
  if (K%2 == 0){
    cout << K*K/4 << endl;
  }
  else {
    cout << (K/2)*((K+1)/2) << endl;
  }
}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ii> P;
typedef unsigned long long int ull;
const int MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;

ll power(ll a,ll x){
    ll res=1;
    while(x>0){
        if(x&1){
            res*=a;
        }
        a*=a;
        x>>=1;
    }
    return res;
}

int main(){
    int n,m;cin>>n>>m;
    vector<int> cnt(n,1);
    vector<bool> p(n,false);
    p[0]=true;
    for(int i=0;i<m;i++){
        int x,y;cin>>x>>y;
        x--;y--;
        p[y]=p[y]||p[x];
        cnt[y]++;
        cnt[x]--;
        if(cnt[x]==0) p[x]=false;
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(p[i]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define ll long long
#define re register
#define IL inline
using namespace std;
const int maxn=1<<21+5;
const int mod=1e9+7;
template<typename T> void read(T &x){
	T f=1;x=0;
	char s=getchar();
	while(s<'0' || s>'9'){if(s=='-') f=-1;s=getchar();}
	while(s>='0' && s<='9'){x=(x<<3)+(x<<1)+s-48;s=getchar();}
	x*=f;
}
int n;
int f[maxn];
int a[22][22];
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	read(n);
	for(re int i=1;i<=n;i++){
		for(re int j=1;j<=n;j++){
			read(a[i][j]);
		}
	}
	f[0]=1;
	for(re int i=1;i<=n;i++){
		for(re int j=0;j<(1<<n);j++){
			int tmp=j,cnt=0;
			while(tmp){
				cnt+=tmp&1;
				tmp>>=1;
			}
			if(cnt==i){
				for(re int k=1;k<=n;k++){
					if(a[i][k] && (j>>(k-1))&1){
						f[j]=(f[j]+f[j-(1<<(k-1))])%mod;
					}
				}
			}
		}
	}
	cout<<f[(1<<n)-1]<<endl;
	return 0;
}


Measured memory_bytes: 10496
def mi():
    return map(int, input().split())

def ii():
    return int(input())

def div2(n):
    cnt = 0
    while n%2==0:
        n //= 2
        cnt += 1
    return cnt


def main():
    N = ii()
    a = list(mi())
    print(sum(map(div2, a)))


if __name__ == '__main__':
    main()

Measured memory_bytes: 68720
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
int main()
{
	int N, K;
	cin >> N >> K;

	double win = 0;
	int cnt=0;
	int tmp=0;
	int bunbo=1;
	for(int i=1; i<=N; i++){
		tmp=i;
		for(cnt = 0; cnt<K; cnt++){
			if(tmp>=K){
				break;
			}
			tmp *= 2;
		}
		bunbo=N;
		for(tmp=0; tmp<cnt; tmp++){
			bunbo*=2;
		}
		win += 1.0 / bunbo;
	}
	
	cout << setprecision(13) << win << endl;
	return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
h = list(map(int, input().split()))

import collections

lis_h, all_h = [], [0]*n
for j in range(m):
  a,b = map(int, input().split())
  all_h[a-1]+=1
  all_h[b-1]+=1

  if h[a-1]>h[b-1]:
    lis_h.append(b)
  elif h[b-1]>h[a-1]:
    lis_h.append(a)
  else: 
    lis_h.append(a)
    lis_h.append(b)

#two_ = [j+1 for j,k in enumerate(all_h) if all_h[j]>1 ]
print(n-len(set(lis_h)))
  
  

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

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

    string s;
    cin >> s;

    int ans = 0;
    if(s[0] == '2') ans++;    
    if(s[1] == '2') ans++;    
    if(s[2] == '2') ans++;    
    if(s[3] == '2') ans++;    

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
num = 0
while num < 20000:
    s = input().split()
    a = int(s[0])
    b = int(s[2])
    op = s[1]
    if op == "?":
        break
    elif op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)
    num += 1



Measured memory_bytes: 5596
h, w = gets.split.map(&:to_i)
cm = Array.new(h + 2){Array.new(w + 2, 0)}
que = []
1.upto(h) do |i|
  s = gets.chomp
  1.upto(w) do |j|
    if s[j - 1] == '.'
      cm[i][j] = -1
    else
      que << i << j
      cm[i][j] = 0
    end
  end
end
ans = 0
while que.size > 0
  y = que.shift
  x = que.shift
  ans = cm[y][x] + 1
  if cm[y + 1][x] == -1
    cm[y + 1][x] = ans
    que << y + 1 << x
  end
  if cm[y - 1][x] == -1
    cm[y - 1][x] = ans
    que << y - 1 << x
  end
  if cm[y][x + 1] == -1
    cm[y][x + 1] = ans
    que << y << x + 1
  end
  if cm[y][x - 1] == -1
    cm[y][x - 1] = ans
    que << y << x - 1
  end
end
puts ans - 1

Measured memory_bytes: 27132
import math
K = int(input())
A = list(map(int, input().split()))
N, n = 2, 2
k = [0, 0]
for i in reversed(range(K)):
    k[0] = (N // A[i])*A[i]
    k[1] = math.ceil(n / A[i]) * A[i]
    if k[0]*A[i] >= n and k[1] <= N:
        N = k[0]+A[i] - 1
        n = k[1]
    else:
        print(-1)
        exit(0)
print(n, N)


Measured memory_bytes: 15020
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a%2 == 0 || b%2 == 0 || c%2 == 0) {
        cout << 0 << endl;
        return 0;
    }
    else {
        int x[3] = {a, b, c};
        sort(x, x+3);
        ll ans = (ll)x[0]*x[1];
        cout << ans << endl;
        return 0;
    }
}

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

int main(){
    int a,b,i;
    string s;
    cin >> a >> b >> s;

    if(s[a] != '-'){
        cout << "No" << endl;
        return 0;
    }

    for(i = 0;i < s.size();i++){
        if(i != a && s[i] == '-'){
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
}


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

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using ull = unsigned long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

int main(){
    ll a, b, c; cin >> a >> b >> c;
    string ans;
    if (c - a - b <= 0) ans = "No";
    else{
        if (4 * a * b < (c - a - b) * (c - a - b)) ans = "Yes";
        else ans = "No";
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<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; }



int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<ll> a(n);
  ll sum = 0;
  rep(i, n) {
    cin >> a[i];
    if(i!=0) sum += a[i];
    sum %= MOD;
  }
  ll ans = 0;
  rep(i, n-1) { 
    ans += (a[i] * sum)%MOD;
    ans %= MOD;
    sum -= a[i + 1];
    if (sum < 0) sum += MOD;
  }
  cout << ans%MOD << endl;
  return 0;
}

Measured memory_bytes: 4796
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B;
    cin >> A >> B;
    if (A >= 1 && B >= 1 && A <= 9 && B <= 9) {
        cout << (A * B) << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;


//mod演算ライブラリ
//mod=1000000007

LL add(LL a,LL b){
  return (a+b)%mod;
}

LL sub(LL a,LL b){
  return (a+mod-b)%mod;
}

LL mul(LL a,LL b){
  return ((a % mod) * (b % mod)) % mod;
}

LL power(LL x,LL y){//繰り返し二乗法 単品利用可
  if(y==0)return 1;
  else if(y==1)return x%mod;
  else if(y%2==0){
    LL tmp=power(x, y/2) % mod;
    return tmp*tmp%mod;
  }else {
    LL tmp=power(x, y/2) % mod;
    return ((tmp*tmp)%mod)*x%mod;
  }
}

LL dvs(LL a,LL b){
  return mul(a,power(b,mod-2));
}

const int SIZE_mod=200005;
int invfact[SIZE_mod];
int fact[SIZE_mod];

LL factset(int a){//aまでの階乗%mod表を作成
  fact[0]=1;
  FORQ(i,1,a){
    fact[i]=mul(fact[i-1],i);
  }
}

LL cmbset(int a){//1~aまでの階乗と階乗数の逆元のmod(mod)を用意 O(a)
  factset(a);
  invfact[a]=power(fact[a],mod-2);
  invfact[0]=1;
  FORD(i,a,1){
    invfact[i]=mul(invfact[i+1],i+1);
  }

}

LL cmb(int n,int r){//nCr%mod  (cmbset後に使用)
  if(n<r||r<0||n<0)return 0;
  return mul(fact[n],mul(invfact[r],invfact[n-r]));
}

LL prm(int n,int r){//nPr%mod
    return mul(cmb(n,r),fact[n]);
}

LL homo(int n,int r){//nHr%mod
  return cmb(n+r-1,r);
}

LL ncr(LL n, int r){
    LL t=1;
    FOR(i,n-r+1,n+1){
        t=mul(t,i);
    }
    FOR(i,2,r+1){
        t=dvs(t,i);
    }

    return t;
}

int main(){
	int n,a,b;
    cin>>n>>a>>b;
    LL ans=sub(power(2,n),1);
    cerr<<ans<<endl;
    cout<<sub(sub(ans,ncr(n,a)),ncr(n,b));


}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var t []byte
	fmt.Scan(&t)
	for i := range t {
		switch t[i] {
		case '?':
			fmt.Print("D")
		default:
			fmt.Print(string([]byte{t[i]}))
		}
	}
	fmt.Println()
}

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

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

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


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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int taxi = b;
  int train = a * n;
  cout << min(taxi, train) << endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

// mod.m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while(b){
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>=1;
    }
    return res;
}

const int MAX_N = 200010;
int root[MAX_N], t_rank[MAX_N]; // tree_rank (rankが予約語だから)
void UFinit(int n){
    rep(i,n){
        root[i] = i;
        t_rank[i] = 0;
    }
}
int find(int x){
    if(root[x] == x) return x;
    else return root[x] = find(root[x]);
}
void unite(int x, int y){
    x = find(x); y = find(y);
    if(x == y) return;
    if(t_rank[x] < t_rank[y]){
        root[x] = y;
    }else{
        root[y] = x;
        if(t_rank[x] == t_rank[y]){
            t_rank[x]++;
        }
    }
}
bool same(int x, int y){
    return find(x) == find(y);
}

int main(){
    int n, m;
    cin >> n >> m;
    UFinit(n);
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--, b--;
        unite(a,b);
    }
    map<int, int> unite_sum;
    int ans = 0;
    rep(i,n){
        int tmp = ++unite_sum[find(i)];
        ans = max(ans, tmp);
    }
    cout << ans << endl;

}



Measured memory_bytes: 14464
s=input()
tmp=s[0]
tmp_n=1
li=[]

for i in range(1,len(s)):

    if s[i]==tmp:
        tmp_n+=1
    else:
        tmp=s[i]
        li.append(tmp_n)
        tmp_n=1
li.append(tmp_n)

ans=[0 for i in range(len(s))]
st="r"
tmp_p=-1

for i in li:
    tmp1=i//2+i%2
    tmp2=i//2
    if st=="r":
        tmp_p+=i
        ans[tmp_p]+=tmp1
        ans[tmp_p+1]+=tmp2
        st="l"
    else:
        ans[tmp_p+1]+=tmp1
        ans[tmp_p]+=tmp2
        tmp_p+=i
        st="r"
    #print(ans)
    
for i in ans:
    print(i, end=" ")

Measured memory_bytes: 52000
A, B, C, K = map(int, input().split())
temp = K
ans = 0

if A <= K:
    temp -= A
    ans = A
else:
    temp = 0
    ans = K

if B <= temp:
    temp -= B
else:
    temp = 0

if C <= temp:
    ans -= C
else:
    ans -= temp

print(ans)

Measured memory_bytes: 61636
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<ll>a(n), b(n), c(m), d(m);
	REP(i, n) {
		cin >> a[i] >> b[i];
	}
	REP(i, m) {
		cin >> c[i] >> d[i];
	}
	REP(i, n) {
		ll dist = 10000000000;
		ll l, num=0;
		REP(j, m) {
			l = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (l < dist) {
				dist = l;
				num = j + 1;
			}
		}
		cout << num << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#include <cstdio>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef std::vector<int> VI;
typedef std::pair<int,int> P;
int read()
{
    int x=0,flag=1; char c=getchar();
    while((c>'9' || c<'0') && c!='-') c=getchar();
    if(c=='-') flag=0,c=getchar();
    while(c<='9' && c>='0') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return flag?x:-x;
}

const int maxn=1e3+5;
char s[maxn][maxn];
int ans[maxn][maxn],vis[maxn][maxn],n,m,fx,fy,tx,ty;
int dir[4][2]={1,0,-1,0,0,1,0,-1};

struct node
{
    int x,y,step=0;
};
deque<node> Q;

int main()
{
    n=read(),m=read();
    fx=read(),fy=read();
    tx=read(),ty=read();
    REP(i,1,n) scanf("%s",s[i]+1);
    REP(i,1,n) REP(j,1,m) ans[i][j]=-1;
    Q.push_back((node){fx,fy,0});
    while(!Q.empty())
    {
        node nd=Q.front(); Q.pop_front();
        int x=nd.x,y=nd.y,step=nd.step;
        if(vis[x][y]) continue;
        //cout<<x<<' '<<y<<endl;
        vis[x][y]=1;
        ans[x][y]=step;
        for(int i=0;i<4;i++)
        {
            int xx=x+dir[i][0],yy=y+dir[i][1];
            if(xx>0 && xx<=n && yy>0 && yy<=m && !vis[xx][yy] && s[xx][yy]=='.')
                Q.push_front((node){xx,yy,step});
        }
        for(int xx=x-2;xx<=x+2;xx++)
            for(int yy=y-2;yy<=y+2;yy++)
            {
                if(xx>0 && xx<=n && yy>0 && yy<=m && !vis[xx][yy] && s[xx][yy]=='.')
                    Q.push_back((node){xx,yy,step+1});
            }
    }
    if(ans[tx][ty]<0) puts("-1");
    else printf("%d\n",ans[tx][ty]);

    return 0;
}

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

int main(){
  long N;
  cin >> N;
  long long ans = 0;
  ans += N-1;
  if((N-1)%2==0){
    ans /= 2;
    ans *= N;
  }else ans *= N/2;
  cout << fixed;
  cout << setprecision(20) << ans << endl;
}

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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  int N;
  cin >> N;
  int A;
  cin >> A;
  cout << (N % 500 <= A ? "Yes" : "No") << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
string s[100];
int n;
int rec(int i){
    int cnt=s[i].size();
    if(s[i][cnt-1]>='0' && s[i][cnt-1]<='9') return s[i][cnt-1]-'0';
    else if(s[i][cnt-1]=='+'){
        int res=0,j=i+1;
        while(s[j].size()>=cnt+1 && j<n ){
            if(s[j].size()==cnt+1) res+=rec(j);
            //cout<<res<<endl;

            j++;
        }
        return res;
    }
    else{
        int res=1,j=i+1;
        while(s[j].size()>=cnt+1 && j<n){
            if(s[j].size()==cnt+1) res*=rec(j);
            j++;
        }
        return res;
    }
}
int main(){
    while(1){
        cin>>n;
        //for(int i=0;i<100;i++) s[i].clear();
        if(n==0) break;
        for(int i=0;i<n;i++) cin>>s[i];
        cout<<rec(0)<<endl;
    }
    //cout<<rec(0)<<endl;
    return 0;
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
int main()
{
ll a,b,c,d,e,f,g,h,t,tt,ans;
cin>>a>>b>>c>>d;
e=a*c;
f=a*d;
g=b*c;
h=b*d;
ans=max(max(e,f),max(g,h));
cout<<ans<<endl;
}

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

int main(){

  int a,b;
  cin >> a >> b;
  int x = 0;
  x = a * b;
  if (x % 2  == 0){
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }
}


Measured memory_bytes: 3596
n = int(input())
h = list(map(int,input().split()))

dp = [0]*n
dp[1] = abs(h[0]-h[1])

for i in range(2,n):
    dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]))
print(dp[-1])

Measured memory_bytes: 20544
#include<bits/stdc++.h>
using namespace std;
char a[10000],b[10000];
int lena,lenb;
int main(){
	scanf("%s%s",a,b);
	lena=strlen(a)-1;
	lenb=strlen(b)-1;
	for(int i=0,j=0;i<=lena || j<=lenb;i++,j++){
		if(i<=lena) printf("%c",a[i]);
		if(j<=lenb) printf("%c",b[j]);
	}
}

Measured memory_bytes: 256