akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

long long a;
long long b;
long long c;

long long ans = 0;

int main(){
	scanf("%lld%lld%lld", &a, &b, &c);
	long long tmp = min(a + b + 1, c);
	printf("%lld", tmp + b);	

	return 0;
}


Measured memory_bytes: 256
import math

A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())

a_f=math.ceil(float(A)*0.1)*10
b_f=math.ceil(float(B)*0.1)*10
c_f=math.ceil(float(C)*0.1)*10
d_f=math.ceil(float(D)*0.1)*10
e_f=math.ceil(float(E)*0.1)*10

x=a_f+b_f+c_f+d_f+e_f

y=set([A%10,B%10,C%10,D%10,E%10])
if 0 in y:
	y.remove(0)
if len(y)==0:
    print(x)
else:
    z=min(y)
    print(x+z-10)



Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
#define LP(i, a, b) for (int i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (int i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-11

#define INF 1e16

const int MaxSize = 200000 + 10;

int main() {

	ios_base::sync_with_stdio(false);
	//freopen("/Users/george/A_1.in", "r", stdin);

	LL n, T;
	cin >> n >> T;
	LL ans = 0;
	LL t[MaxSize];

	LP(i, 0, n)
		cin >> t[i];

	LP(i, 0, n -1)
	{
		if (t[i] + T >= t[i + 1])
			ans += t[i + 1] - t[i];
		else
			ans += T;
	}

	ans += T;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
/**
 * https://atcoder.jp/contests/abc168/tasks/abc168_b
 * 
 * ■問題文
 * 英小文字からなる文字列 S があります。
 * S の長さが K 以下であれば、S をそのまま出力してください。
 * S の長さが K を上回っているならば、先頭 K 文字だけを切り出し、末尾に ... を付加して出力してください。
 * 
 * ■制約
 * ・K は 1 以上 100 以下の整数
 * ・S は英小文字からなる文字列
 * ・S の長さは 1 以上 100 以下
 */
export function Main(input: string) {
  // 問題文解体エリア
  const inputs = input.split("\n");
  const limit = new Number(inputs[0]).valueOf();
  const str = inputs[1];

  // console.log(nums);
  // 問題解決エリア
  const answer = fuck(limit, str);

  //出力エリア
  console.log(answer.toString());
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
// 提出する時にコメントアウト解除せよ
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

export function fuck(limit:number, str:string): string {
  if (str.length > limit) {
    return str.substr(0, limit) + "...";
  } else {
    return str;
  }
}

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

int main () {
	int n;
  	cin >> n;
  	vector <int> L(2*n);
  
  	for (int i=0; i<L.size(); i++)
      	cin >>  L[i];
  	
  	sort (L.begin(), L.end());
  	int res = 0;
  	for (int i=0; i<L.size(); i+=2) {
    	res += min (L[i], L[i+1]);
    }
  
  	cout << res;
  
}

Measured memory_bytes: 3588
#include<iostream>
#include <cmath>
using namespace std;
int main(){
	int n;
	cin >> n;
	double a[n],sum=0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		sum+=a[i];
	}
	//cout<< sum <<" "<< round(sum/n) << endl;
	int cost = 0;
	for(int i=0;i<n;i++){
		//cout << cost << " ";
		cost += pow(a[i]-round(sum/n),2);
	}
	cout << cost << endl;
}


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

#define rep(i, n) for(int (i) = 0; i < (n); ++(i))

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

int main() {
  int N, Q;
  ll K;

  std::cin >> N >> K >> Q;
  std::vector<int> cnt(N, 0);
  rep(i, Q) {
    int A;
    std::cin >> A;
    ++cnt[A - 1];
  }

  rep(i, N) {
    if(Q - cnt[i] >= K) std::cout << "No" << '\n';
    else std::cout << "Yes" << '\n';
  }
}


Measured memory_bytes: 1024
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    int n;
    cin >>n;
    cout << (int)(n/3) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, k, i, j, x, fx, ans, aa, bb, cc, sum, s;
	cin >> n >> k;
	vector<long long> f(n), a(n), ss(n);

	sum = 0;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	for (i = 0; i < n; i++) cin >> f[i];
	
	sort(a.rbegin(), a.rend());
	//sort(f.rbegin(), f.rend());

	aa = 0; bb = 1LL << 62; 
	while (aa < bb) {
		cc = (aa + bb) / 2;
		ss.clear();
		for (i = 0; i < n; i++) {
			ss.push_back(cc / f[i]);
		}
		s = 0;
		sort(ss.rbegin(), ss.rend());
		for (i = 0; i < n; i++) {
			if (ss[i] < a[i]) s += a[i] - ss[i];
		}

		if (s <= k) bb = cc;
		else aa = cc + 1;
	}

	cout << aa << "\n";

	return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define debug(x) cerr<<#x<<" = "<<x
#define sp <<"  "
#define el <<endl
#define fgx cerr<<" ---------------------------------------------- "<<endl
#define uint unsigned int 
#define ULL unsigned long long
#define LDB long double
#define DB double
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
inline LL read(){
	LL nm=0; bool fh=true; char cw=getchar();
	for(;!isdigit(cw);cw=getchar()) fh^=(cw=='-');
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return fh?nm:-nm;
}
#define mod 998244353
namespace  CALC{
	inline int add(int x,int y){return (x+y>=mod)?(x+y-mod):(x+y);}
	inline int mns(int x,int y){return (x-y<0)?(x-y+mod):(x-y);}
	inline int mul(int x,int y){return (LL)x*(LL)y%mod;}
	inline void upd(int &x,int y){x+=y;(x>=mod)?(x-=mod):0;}
	inline void dec(int &x,int y){x-=y;(x<0)?(x+=mod):0;}
	inline int qpow(int x,int sq){int res=1;for(;sq;sq>>=1,x=mul(x,x))if(sq&1)res=mul(res,x);return res;}
}using namespace CALC;
#define M 2000000
int n,m,t[M],p[M],hv[M],hv1;
char ch[M];
inline int C(int N,int K){return hv[N]==hv[K]+hv[N-K];}
int main(){
	n=read(),scanf("%s",ch+1);
	for(int rem,i=1;i<=n;i++) for(hv[i]=hv[i-1],rem=i;!(rem&1);rem>>=1,hv[i]++);
	for(int i=1;i<=n;i++) t[i]=ch[i]-'1',hv1|=(t[i]==1);
	if(hv1){
		int ans=0;
		for(int i=1;i<=n;i++) ans^=(t[i]==1&&C(n-1,i-1));
		putchar(ans+'0');puts("");return 0;
	}
	int ans=0;
	for(int i=1;i<=n;i++) ans^=(t[i]==2&&C(n-1,i-1));
	ans<<=1,putchar(ans+'0');puts("");return 0;
	return 0;
} 

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

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

    for (int a = 0; a <= X; a++) {
        int b = X - a;
        if (2 * a + 4 * b == Y) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
 
int main(){
 int n ;cin>> n;
 cout<<(n-2)*180<<endl ;
    return 0;
  }

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    int h,w,k;
    cin >> h >> w >> k;
    vector<string> c(h);
    rep(i,h) cin >> c[i];

    int ans = 0;

    for(int bit1 = 0; bit1 < (1 << h); bit1++){
        for(int bit2 = 0; bit2 < (1 << w); bit2++){
            vector<vector<bool>> c2(h,vector<bool> (w,false));

            rep(i,h){
                if(bit1 & (1 << i)){
                    rep(j,w){
                        c2[i][j] = true;
                    }
                }
            }
            rep(i,w){
                if(bit2 & (1 << i)){
                    rep(j,h){
                        c2[j][i] = true;
                    }
                }
            }
            int cnt = 0;
            rep(i,h){
                rep(j,w){
                    if(c[i][j] == '#' && !c2[i][j]) cnt++;
                }
            }
            if(cnt == k) ans++;
        }
    }
    dunk(ans);
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main(){
    int N;
    cin >> N;
    for(int i = 1; i <= 9; i++){
        if(N % i == 0 && N / i <= 9){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 10010
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,tot,ans[N];
vector<int> G[N],c;
void dfs(int u,int fa){
	ans[u]=c.back();
	c.pop_back();
	for(auto v:G[u]){
		if(v==fa)continue;
		dfs(v,u);
	}
}
int main(){
	n=read();
	for(int i=1;i<n;++i){
		int u=read(),v=read();
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for(int i=1;i<=n;++i){
		c.push_back(read());
	}
	sort(c.begin(),c.end());
	for(auto x:c)tot+=x;
	tot-=c.back();
	dfs(1,0);
	printf("%d\n",tot);
	for(int i=1;i<=n;++i){
		printf("%d ",ans[i]);
	}
	return 0;
}



Measured memory_bytes: 4792
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strArray = Console.ReadLine().Split(' ').ToArray();
            for (int i = 0; i < 5; i++)
            {
                if(strArray[i] == "0")
                {
                    Console.WriteLine(i + 1);
                    break;
                }
            }
        }
    }
}

//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



Measured memory_bytes: 26436
#include <stdio.h>

int main() {
    int h,w,n;
    scanf("%d", &h);
    scanf("%d", &w);
    scanf("%d", &n);
    int counter = 0;
    int sum = 0;
    while (n > sum){
        if(w >= h){
            sum += w;
            counter++;
        }else if(h > w){
            sum+= h;
            counter++;
        }
    }
    printf("%d\n",counter);
    
    return 0;
}

Measured memory_bytes: 1704
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int n;
	cin>>n;
	cout<<(n<1000?"ABC":"ABD")<<endl;
}


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

int main(void){
    
    long long int a, cnt = 0, treat, deno;
    cin >> a ;
    treat = a;
    
    for(long long int i = 2; i <= sqrt(treat); i++){
        if(treat % i == 0){
            deno = i;
            while(treat % deno == 0){
                treat /= deno;
                deno *= i;
                cnt++;
                //cout << treat << endl;
            }

        }
        
        while(treat % i == 0){
            treat /= i;
        }
        
    }
    
    if(treat > 1){
        cnt++;
    }

    cout << cnt << endl;

    return 0; 
}


Measured memory_bytes: 3676
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

char d[50][60];
bool w[50][50];
bool b[50][50];

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

#define REP(i,n) for(int i = 0; i<(n); i++)

void dfsw(int y, int x){
  w[y][x] == true;
  REP(i,4){
    int xx = x + dx[i];
    int yy = y + dy[i];
    if(xx < 0 || yy < 0) continue;
    if(xx >=ww || yy >=hh) continue;
    if(d[yy][xx] != 'B' && !w[yy][xx]){
      w[yy][xx] = true;
      dfsw(yy,xx);
    }
  }
}
void dfsb(int y, int x){
  b[y][x] == true;
  REP(i,4){
    int xx = x + dx[i];
    int yy = y + dy[i];
    if(xx < 0 || yy < 0) continue;
    if(xx >=ww || yy >=hh) continue;
    if(d[yy][xx] != 'W' && !b[yy][xx]){
      b[yy][xx] = true;
      dfsb(yy,xx);
    }
  }
}

int main(){
  while(scanf("%d%d",&ww,&hh),ww+hh){
    memset(w,0,sizeof(w));
    memset(b,0,sizeof(b));
    REP(i,hh) scanf("%s",d[i]);
    REP(i,hh) REP(j,ww){
      if(d[i][j] == 'W' && !w[i][j])
	dfsw(i,j);
      if(d[i][j] == 'B' && !b[i][j])
	dfsb(i,j);
    }
    int a1 = 0, a2 = 0;
    //REP(i,hh){ REP(j,ww) putchar(w[i][j]?'w':'.'); puts("");}
    //REP(i,hh){ REP(j,ww) putchar(b[i][j]?'b':'.'); puts("");}
    REP(i,hh) REP(j,ww){
      if(d[i][j]=='.' && w[i][j] && !b[i][j]) a2++;
      if(d[i][j]=='.' && !w[i][j] && b[i][j]) a1++;
    }
    printf("%d %d\n",a1,a2);
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

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


int main(){

    int n;
    ll k;
    cin >> n >> k;
    vector<pair<int, int> > p;

    for(int i=0; i<n; i++){
        int a, b;
        cin >> a >> b;
        p.pb(mp(a, b));
    }
    //bさき aあと

    sort(p.begin(), p.end());

    for(int i=0; i<n; i++){
        if(k - p[i].second > 0) {
            k -= p[i].second;
        }
        else{
            cout << p[i].first << endl;
            break;
        }
    }



}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll x;
int main(){
  cin >> n >> x;
  vector<ll>  a;
  for(int i=0 ; i<n ; i++){
    ll x; cin >> x;
    a.push_back(x);
  }
  sort(a.begin(),a.end());
  ll cnt = 0;
  for(int i=0 ; i<n ; i++){
    if(a[i] <= x){
      cnt++;
      x -= a[i];
    }else{
      cout << cnt << endl;
      return 0;
    }
  }
  if(x>0) cnt--;
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ std::cin >> head; _cin(std::forward<Tail>(tail)...); }
void _cout(){ std::cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ std::cout << head; _cout(std::forward<Tail>(tail)...); }
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; For(i, n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__);
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Couty(cond) Cout((cond) ? "Yes" : "No")
#define CoutY(cond) Cout((cond) ? "YES" : "NO")

using namespace std;
using ll = long long;

bool isEven(string s){
    if(s.size() % 2) return false;
    For(i, s.size()/2){
        if(s[i] != s[i+s.size()/2]) return false;
    }
    return true;
}

int main(void){
    Cin(string, s);
    do s.pop_back(); while(!isEven(s));
    Cout(s.size());
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        // 満足度低下係数
        int[] c = new int[26];
        Arrays.setAll(c, i -> sc.nextInt());
        // 満足度増加度
        int[][] s = new int[d][26];
        for (int i = 0; i < d; i++) {
            Arrays.setAll(s[i], i1 -> sc.nextInt());
        }
        // 最終開催履歴
        int[] last = new int[26];
        for (int i = 0; i < d; i++) {
            int index = 0;
            long v = s[i][0] + c[0] * (i + 1 - last[0]);
            for (int j = 1; j < 26; j++) {
                long t = s[i][j] + c[j] * (i + 1 - last[j]);
                if (t > v) {
                    index = j;
                    v = t;
                }
            }
            last[index] = i + 1;
            System.out.println(index + 1);
        }
    }
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x) 
#define rep(i, n) for (int i = 0; i < n; ++i) 
#define fo(i, a, b) for (int i = a; i <= b; ++i)

#define MOD 1000000007
int h, w;
string g[1005];
int res[1005][1005];

int dp(int i, int j) {
    if (i >= h || j >= w || g[i][j] == '#') return 0;
    if (i == h-1 && j == w-1) return 1;
    if (~res[i][j]) return res[i][j];

    res[i][j] = 0;
    res[i][j] = (dp(i+1, j) + dp(i, j+1)) %MOD;
    return res[i][j];
}

int main() {
    //freopen("in.txt", "r", stdin);
    cin >> h >> w;
    rep(i, h) cin >> g[i];

    memset(res, -1, sizeof res);
    cout << dp(0, 0) << '\n';
}



Measured memory_bytes: 5376
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include<bits/stdc++.h>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>*/

#define sz(s) (int)(s.size())
#define all(s) s.begin(), s.end()
#define rep(a, b, c) for(int a = b; a <= c; ++a)
#define per(a, b, c) for(int a = b; a >= c; --a)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;
//using namespace __gnu_pbds;

typedef unsigned long long ull;
typedef long long ll;
/*typedef tree<pair<int, int>, 
null_type, less<pair<int, int>>, 
rb_tree_tag, tree_order_statistics_node_update>
ordered_set;*/
//find_by_order() order_of_key()

const double eps = 1e-7;
const int mod = 1e9+7, MXN = 5e5+17;
const int dx[] = {0,0,1,-1}, dy[] = {1,-1,0,0};

template<typename T>inline bool updmin(T &a, const T &b) {return a > b ? a = b,1 : 0;}
template<typename T>inline bool updmax(T &a, const T &b) {return a < b ? a = b,1 : 0;}

int n, res, ans, a[MXN];

inline int calc(int x) {
	return res-2*x*ans+n*x*x;
}

int32_t main() { _
#ifdef DanQQQQQ
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	cin >> n;
	rep(i,1,n) cin >> a[i];
	rep(i,1,n) res += a[i]*a[i];
	rep(i,1,n) ans += a[i];
	int l = -100, r = 100;
	while(r-l > 1) {
		int mid = (r+l)>>1;
		if(calc(mid-1) > calc(mid)) l = mid;
		else r = mid;
	}
	cout << min(calc(r),calc(l)) << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

fun main(args: Array<String>){
    val sc = Scanner(System.`in`)
    val N = sc.nextInt()
    val X = sc.nextInt()
    var position = 0
    var bounds = 1
    for(i in 0 until N){
       position += sc.nextInt()
       if(position <= X){
           bounds++
       }
    }
    println(bounds)
}

Measured memory_bytes: 29596
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, M;
  cin>>N>>M;

  string ans = N == M? "Yes":"No";
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
n = input()
if n == "a":
    print("b")
if n == "b":
    print("c")
if n == "c":
    print("d")
if n == "d":
    print("e")
if n == "e":
    print("f")
if n == "f":
    print("g")
if n == "g":
    print("h")
if n =="h":
    print("i")
if n == "i":
    print("j")
if n == "j":
    print("k")
if n == "k":
    print("l")
if n == "l":
    print("m")
if n == "m":
    print("n")
if n == "n":
    print("o")
if n == "o":
    print("p")
if n == "p":
    print("q")
if n == "q":
    print("r")
if n == "r":
    print("s")
if n == "s":
    print("t")
if n == "t":
    print("u")
if n == "u":
    print("v")
if n == "v":
    print("w")
if n == "w":
    print("x")
if n == "x":
    print("y")
if n == "y":
    print("z")
if n == "z":
    print("a")


Measured memory_bytes: 3064
H, W = [int(n) for n in input().split()]

if H % 3 == 0 or W % 3 == 0:
    print(0)

else:
    m = H * W
    for i in range(1,H+1):
        a = i * W
        b = (H-i) * (W//2)
        c = (H-i) * (W - W//2)
        if m > max(a,b,c)-min(a,b,c):
            m = max(a,b,c)-min(a,b,c)
    for i in range(1,W+1):
        a = i * H
        b = (W-i) * (H//2)
        c = (W-i) * (H - H//2)
        if m > max(a,b,c)-min(a,b,c):
            m = max(a,b,c)-min(a,b,c)
    if m > H:
        m = H
    if m > W:
        m = W
    print(m)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main () {
    long long X;
    cin >> X;
    long long x = 100;
    for (int i = 1;; i++) {
        x = x+x/100;
        if (x >= X) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3624
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
//		new A().doIt();
		new B().doIt();
//		new C().doIt();
//		new D().doIt();
	}
	class A{
		void doIt() {
			int N = sc.nextInt();
			int sum = 0;
			for(int i = 1;i <= N;i++) {
				sum = sum + i;
			}
			System.out.println(sum);
		}
	}
	class B{
		void doIt() {
			String str = sc.next();
			char ctr[] = str.toCharArray();
			ArrayList<Character> array = new ArrayList<Character>();
			for(int i = 0;i < str.length();i++) {
				if(ctr[i] == 'B') {
					if(array.size() > 0)array.remove(array.size() - 1);
				}else array.add(ctr[i]);
			}
			for(int i = 0;i < array.size();i++)System.out.print(array.get(i));
			System.out.println();
		}
	}
	class C{
	}
	class D{
	}
}


Measured memory_bytes: 21588
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <map>
#include <queue>
#include <bitset>
#include <sstream>
using namespace std;
typedef long long ll;

void count_num(map<int,int> &Map, vector<vector<int>> &M, vector<int> &count){
        for(int i=1; i<M.size()+1; i++){
                for(auto ite=Map.begin(); ite!=Map.end(); ++ite){
//cout << ite->first << endl;
                        if(ite->first == i) continue;
                        count[i-1] += ite->second*M[ite->first-1][i-1];
                }
        }
}

int main(){
        int N, C;
        cin >> N >> C;
        vector<vector<int>> D(C, vector<int>(C)), M(N, vector<int>(N)),
        Count(3, vector<int>(C));
        map<int, int> Map0, Map1, Map2;
        for(int i=0; i<C; i++){
                for(int k=0; k<C; k++){
                        cin >> D[i][k];
                }
        }
        for(int i=0; i<N; i++){
                for(int k=0; k<N; k++){
                        cin >> M[i][k];
                        if((i+k+2)%3 == 0) Map0[M[i][k]]++;
                        else if((i+k+2)%3 == 1) Map1[M[i][k]]++;
                        else Map2[M[i][k]]++;
                }
        }
        count_num(Map0, D, Count[0]);
        count_num(Map1, D, Count[1]);
        count_num(Map2, D, Count[2]);
//      for(int i=0; i<C; i++){
//      cout << Count[2][i] << ", ";
//      }

        ll AllCount = 1e13;
        for(int i=0; i<C; i++){
                for(int k=0; k<C; k++){
                        for(int l=0; l<C; l++){
                                if(i==k || k==l || l==i) continue;
                                if(AllCount > Count[0][i]+Count[1][k]+Count[2][l]) AllCount = Count[0][i]+Count[1][k]+Count[2][l];
                        }
                }
        }
        cout << AllCount;
}


Measured memory_bytes: 1280
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(ll i=0; i<(n); i++)
#define REPj(n) for(ll j=0; j<(n); j++)
#define REPinit(i,a,n) for(ll i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(ll j=(a); j<(n); j++)

//algorithm
#define SORT(c) sort((c).begin(),(c).end())
#define CONTAINER_ALL(a) a.begin(),a.end()

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


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

    int r, D, x;
    cin >> r >> D >> x;

    REPinit(i, 0, 10) {
        x = r * x - D;
        cout << x << endl;
    }

    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <cstring>
using namespace std;

int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int n1=a/d;
	if(a%d!=0) n1++;
	int n2=c/b;
	if(c%b!=0) n2++;
	if(n2>n1) puts("No");
	else puts("Yes");
	return 0;
}


Measured memory_bytes: 3124
N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
B=sorted(A,key=lambda x:x[1])

T=0
for i in range(N):
  T+=B[i][0]
  if T > B[i][1]:
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 55264
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;

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

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

int main()
{
  int s, w;
  cin >> s >> w;
  if (s <= w)
  {
    cout << "unsafe" << endl;
  }
  else
  {
    cout << "safe" << endl;
  }
  return 0;
}

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

int main(){

    while(1){
           int a,b;
           string op;
           cin>>a>>op>>b;
           if(op == "?") break;
            
           int ans;
           if(op == "+") ans = a + b;
           if(op == "-") ans = a - b;
           if(op == "*") ans = a * b;
           if(op == "/") ans = a / b;

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


Measured memory_bytes: 3104
from bisect import bisect_right
N = int(input())
c = 0
def croku(N):
    roku =[0,1] + [6**i for i in range(1,7)]
    c = 0
    while N != 0:
        N = N - roku[bisect_right(roku,N)-1]
        c += 1
    return c

def ckyu(N):
    kyu = [0,1] + [9**i for i in range(1,6)]
    c = 0
    while N != 0:
        N = N - kyu[bisect_right(kyu,N)-1]
        c += 1
    return c

K = 10**5
for i in range(0,N+1):
    K = min(K, croku(i) + ckyu(N-i))
print(K)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    scanf("%d %d", &n,&k);
    int sum=0;
    for(int i=0;i<n;i++){
        int a=0;
        scanf("%d", &a);
        if(k-a<=a){
            sum+=2*(k-a);
        }
        else{
            sum+=2*a;
        }
    }
    printf("%d", sum);
}

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

int main() {
  long long int N;
  cin >> N;
  vector<long long int> A(N), B(N);
  for (long long int i = 0; i < N; i++) {
    cin >> A.at(i);
    B.at(A.at(i) - 1) += 1;
  }
  long long int S = 0;
  for (long long int i = 0; i < N; i++) S += B.at(i) * (B.at(i) - 1) / 2;
  for (long long int i = 0; i < N; i++) {
    cout << S - (B.at(A.at(i) - 1) - 1) << endl;
  }
}


Measured memory_bytes: 5760
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
//map.containsKey(A)
//Map<String, Integer> map = new HashMap<String, Integer>(n);
//ArrayList<String> cc = new ArrayList<>(n);
//Collections.sort(list);
//Array.sort(list);
//Arrays.asList(c).contains("a")

public class Main {
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	//static String eikomoji[]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
	static int Y,N;
	public static void main(String[] args) {
		int x=sc.nextInt();
		boolean a=true;
		boolean aa=true;
		if(x==2) {
			a=false;
			aa=false;
			p(2);
		}
		if(x%2==0&&a) {
			x++;
		}
		int ans=0;
		for(int z=x;a;z++) {
			for(int i=2;i!=z;i++) {
				if(z%i==0) {
					break;
				}
				if(i==z-1) {
					ans=z;
					a=false;
				}
			}
			
			
			
			
		}
		if(aa)p(ans);
	}
}


Measured memory_bytes: 22868
fun main(args: Array<String>) {
    val N = nextInt()
    var ans: Double
    if (N % 2 == 0) ans = 0.5
    else ans = ((N + 1) / 2).toDouble() / N.toDouble()
    println(ans)

}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta

Measured memory_bytes: 29896
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <iterator>
#include <stack>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cstring>
#include <bitset>

#include <random>

using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

void precalc() {}

//#define solvsh
//#define multi

#ifdef solvsh

void solve() {

}

#else
typedef vector<int> vi;
#define INF 0x3f3f3f3f
#define FOR(i, n) for(int i = 0; i < n; i++)
template<class T>
T rnd(T l,T r){	//[l,r)
    using D = uniform_int_distribution<T>;
    static random_device rd;
    static mt19937 gen(rd());
    return D(l,r-1)(gen);
}
const int MAXN =1e5 + 30;

int usd[MAXN];
int comps[MAXN];

set<int> blocks[MAXN];
set<int> g[MAXN];

int dfs(int ver, int color){
    if (usd[ver])
        return 0;
    int ret = 1;
    usd[ver] = true;
    comps[ver] = color;

    for (auto out : g[ver]){
        ret += dfs(out, color);
    }

    return ret;
}

void solve() {
    int n;
    cin >> n;
    int m;
    cin >> m;
    int k ;
    cin >> k;

    for (int i = 0 ; i < m; ++ i){
        int a, b;
        cin >> a >> b;
        g[a].insert(b);
        g[b].insert(a);
    }

    for (int i = 0 ; i < k; ++ i){
        int a, b;
        cin >> a >> b;
        blocks[a].insert(b);
        blocks[b].insert(a);
    }

    int comp = 0;
    map<int, int> cnts;
    for (int i = 1; i <= n; ++ i){
        if (!usd[i]){
            cnts[comp] = dfs(i, comp);
            ++comp;
        }
    }

    for (int i = 1; i <= n; ++i){
        int answr = cnts[comps[i]];
        answr -= g[i].size();
        for (int el : blocks[i]) {
            if (comps[el] == comps[i])
                answr--;
        }
        cout << answr - 1 << " ";
    }
}

#endif


void multisolve() {
    int t;
    cin >> t;

    while (t--)
        solve();
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);

    precalc();

#ifdef multi
    multisolve();
#else
    solve();
#endif

#ifdef LOCAL
    //cout << '\n' << (double)clock() / CLOCKS_PER_SEC << '\n';
#endif
}

Measured memory_bytes: 34048
from sys import stdin
while True:
    s = stdin.readline()
    if not s:
        break
    n = int(s)
    a = [] 
    b = []
    f = []
    for i in xrange(60):
        f.append(2**i)
    bi = [] 
    s = 0 
    cur = 59 
    while cur>=0:
        if f[cur ]-1 <=n:
            break 
        cur -= 1 
    hi = cur
    done = 2**hi - 1 
    for u in xrange(1,hi+1):
        b.append(u)
    co = 1 
    nn = n 
    n -= done 
    while cur >=1 :
        a.append(cur)
        if f[cur-1]<= n:
            hi += 1 
            a.append(hi)
            b.append(hi)
            n-= f[cur-1]
        
        cur -=1 
    a.reverse()
    c =  a + b 
    print  len(c)
    for i in c:
        print i,
    print ""

Measured memory_bytes: 2696
#include <iostream>
 
using namespace std;
int main() {
    string S,T;
    string nT;
    cin>>S>>T;
    nT=S;
    long long len =S.length();
    for(int i=0;i<len;i++)
      nT[i]=T[i];
    
    if(S==nT)
    	cout<<"Yes"<<endl;
    else 
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3632
# x1, y1, x2, y2 = map(int, input().split())

n = int(input())
s = []
for i in range(n):
    s.append(input())

m = int(input())
t = []
for i in range(m):
    t.append(input())

price = []
tmp = 0 
for i in range(n):
    price.append(s.count(s[i]) - t.count(s[i]))

print(max(0, max(price)))

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

int main()
{
        int H, W;
        cin >> H >> W;
        string s[H];
        for (int i = 0; i < H; ++i) {
                cin >> s[i];
        }

        for (int i = 0; i < H; ++i) {

                cout << s[i] << endl;
                cout << s[i] << endl;
        }


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for (ll i = 0; i < (a); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;

int s[1001][1001];

int main(){
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    rep(i,h){
        rep(j,w){
            if(j < a){
                if(i < h-b) cout << 1;
                else cout << 0;
            }else{
                if(i < h-b) cout << 0;
                else cout << 1;
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280
#include <cstdio>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

int page;
char buf[100000];
map<string, vector<int> > table;

int main() {
  while (1) {
    if (scanf(" %s%d", buf, &page) != 2) break;
    table[buf].push_back(page);
  }

  for (auto itr=table.begin(); itr!=table.end(); itr++) {
    sort(itr->second.begin(), itr->second.end());
    itr->second.erase(unique(itr->second.begin(), itr->second.end()), itr->second.end());

    printf("%s\n", itr->first.c_str());
    printf("%d", itr->second[0]);
    for (int i=1; i<itr->second.size(); i++) {
      printf(" %d", itr->second[i]);
    }
    puts("");
  }
}

Measured memory_bytes: 2912
N,M = (map(int, input().split()))
li = [list(map(int,input().split())) for i in range(N)]

li.sort()

li3 = []
for j in range(len(li)):
    li3.extend([li[j][0]]*li[j][1])
    if len(li3)>M:
        break
print(sum(li3[0:M]))

Measured memory_bytes: 29668
N = int(input())
P = list(map(float,input().split()))

dp = [[0]*(N+1) for _ in range(N+1)]
# dp[i+1][j]:i枚目のコインまで見たときに表がj枚でている確率
dp[0][0] = 1.0

for i in range(N):
    t = P[i]
    for j in range(i+1):
        dp[i+1][j+1] += dp[i][j]*t
    t = 1-P[i]
    for j in range(i+1):
        dp[i+1][j] += dp[i][j]*t

ans = sum(dp[N][N//2+1:])
print(ans)
    

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

#define INF ((1<<30)-1)  //int32_t
#define MOD 1000000007
#define MOD2  

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll calc(ll n,ll x,bool is3,bool is5,bool is7){

    if(x > n)return 0;
    ll ret=0;
    if(is3&&is5&&is7)++ret;
    ret += calc(n,(10*x)+3,true,is5,is7);
    ret += calc(n,(10*x)+5,is3,true,is7);
    ret += calc(n,(10*x)+7,is3,is5,true);

    return ret;
}

int main(){
    bool flag=true;
    ll ans=0,sum=0;

    int n,m;
    cin >>n;


    //cout <<fixed<<setprecision(16)<< << endl;
    cout << calc(n,0,false,false,false) << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
public class Main {
	public static void main(String args[]) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		int K = sc.nextInt();
		int X = sc.nextInt();

		if (500 * K >= X) {
			System.out.print("Yes");
		} else {
			System.out.print("No");
		}
	}
}


Measured memory_bytes: 24276
#include<stdio.h>
#include<string.h>

int main(){
	int ti[300][3],i,j,k,a,b;
	i=0;
	
	while(0<=scanf("%d,%d",&ti[i][0],&ti[i][1])){
		if(ti[i][0]==0 && ti[i][1]==0)break;
		++i;
	}
	
	for(j=0;j<i;j++){
		for(k=j;k<i;k++){
			if(ti[k][1]>ti[j][1]){
				for(a=0;a<2;a++){
					b=ti[k][a];
					ti[k][a]=ti[j][a];
					ti[j][a]=b;
				}
			}
		}
	}
	j=1;
	ti[0][2]=1;
	for(k=1;k<i;k++){
		if(ti[k-1][1]>ti[k][1])++j;
		ti[k][2]=j;
	}
	
	while(0<=scanf("%d",&i)){
		for(j=0;;j++){
			if(ti[j][0]==i)break;
		}
		printf("%d\n",ti[j][2]);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
class Main {
    static long[][] cp;
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int H = Integer.parseInt(sc.next());
	int W = Integer.parseInt(sc.next());
	int K = Integer.parseInt(sc.next());

	long[][] a = new long[H+1][W+2];
	cp = new long[W+1][W+1];
	a[0][1] = 1;
	for(int i = 1; i<=H; i++) {
	    for(int j = 1; j<=W; j++) {
		a[i][j] = a[i-1][j-1]*countP(j-3, W-(j+1)) % 1000000007
		    + a[i-1][j]*countP(j-2, W-(j+1)) % 1000000007
		    + a[i-1][j+1]*countP(j-2, W-(j+2)) % 1000000007;
		a[i][j] %= 1000000007;
		//		System.out.println(i+ " "+ j + " " + countP(j-3, W-(j+1)) + " " + countP(j-2, W-(j+1)) + " " + countP(j-2, W-(j+2)) + " " + a[i][j]);
	    }
	}
	System.out.println(a[H][K]);
    }
    public static long countP(int l, int r) {
	if(l<0)  l = 0;
	if(r<0)  r = 0;

	if(cp[l][r] != 0) return cp[l][r];
	long cnt=0;
	for(int i = 0; i<=Math.pow(2,l) && l>0; i++) {
	    int ci = i;
	    boolean f = false;
	    while(ci>0) {
		if (ci%2 == 1 && f== false) f = true;
		else if(ci%2==1) break;
		else f = false;
		ci/=2;
		if(ci==0) cnt++;
	    }
	}

	if(cnt==0) cnt++;
	long cnt2 = 0;
	for(int i = 0; i<=Math.pow(2,r) && r>0; i++) {
            int ci = i;
            boolean f =false;
	    while(ci>0) {
                if (ci%2 == 1 && f== false) f = true;
                else if(ci%2==1) break;
		else f = false;
                ci/=2;
		if(ci==0) cnt2++;
            }
        }
	if(cnt2==0) cnt2++;
	cnt = cnt % 1000000007;
	cnt2 = cnt2 % 1000000007;
	cp[l][r] = cnt*cnt2 % 1000000007;
	return cp[l][r];

    }
}

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

int main() {
  int L,R,d;
  cin >> L >> R >> d;
  
  int answer=0;
  
  for(int i=L; i<=R; i++){
    if(i%d==0) answer++;
  }
  
  cout << answer << endl;
}


Measured memory_bytes: 3620
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


############ ---- Input Functions ---- ############
def in_int():
    return (int(input()))


def in_list():
    return (list(map(int, input().split())))


def in_str():
    s = input()
    return (list(s[:len(s) - 1]))


def in_ints():
    return (map(int, input().split()))


n = in_int()

print((n+1)//2)

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

int main()
{
    llong H, W;
    while (true) {
        cin >> H >> W;
        if (H == 0 && W == 0) {
            break;
        }
        REP(i,H){
            REP(j,W) cout << "#";
            cout << endl;
        }
        cout << endl;
    }


    return 0;
}

Measured memory_bytes: 3068
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)






int main() {
    ll n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> v(n);
    REP(i, n){
        ll a, b;
        cin >> a >> b;
        v[i] = {a, b};
    }
    sort(v.begin(), v.end());
    ll sum = 0, ans = 0;
    REP(i, n){
        ll a = v[i].first, b = v[i].second;
        if(sum + b <= m){
            ans += a * b;
        }
        else{
            ans += a * (m - sum);
        }
        sum += b;
        if(sum >= m) break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <functional>
#include <queue>
#include <map>
#include <set>
#include <string>
#define SIZE 5005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

bool dp[SIZE];
int A[SIZE];
P pos[SIZE];

int main()
{
	int n,K;
	scanf("%d %d",&n,&K);
	for(int i=0;i<n;i++) scanf("%d",&A[i]);
	//iを含む中で、K以上K+A[i]未満のものがあればok
	//i以外でぎりぎりK未満のものがあればよさそう
	sort(A,A+n);
	ll sum=0;
	for(int i=0;i<n;i++) sum+=A[i];
	memset(dp,false,sizeof(dp));
	dp[0]=true;
	int ret=0;
	for(int i=n-1;i>=0;i--)
	{
		bool up=false;
		for(int j=0;j<K;j++)
		{
			if(dp[j]&&j+sum>=K) up=true;
		}
		if(!up) ret++;
		sum-=A[i];
		for(int j=K-1;j>=A[i];j--) dp[j]|=dp[j-A[i]];
	}
	printf("%d\n",ret);
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long k = sc.nextLong();
        long ans = n - n/k * k;
        ans = Math.min(ans, Math.abs(ans - k));
        System.out.println(ans);
    }
}


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

int n, a[100009], b[100009], col[100009]; bool used[100009]; vector<int>x[100009]; bool flag = false;

int dfs(int pos) {
	int cl = 0, cr = 0;
	used[pos] = true;
	for (int i = 0; i < x[pos].size(); i++) {
		if (used[x[pos][i]] == true) continue;
		int F = dfs(x[pos][i]);
		if (F == 0) cl++; else cr++;
	}
	if (cl == 0) {
		if (pos == 1)flag = true;
		col[pos] = 0;
		return 0;
	}
	if (cl >= 2)flag = true;
	col[pos] = 1;
	return 1;
}

int main() {
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		cin >> a[i] >> b[i];
		x[a[i]].push_back(b[i]);
		x[b[i]].push_back(a[i]);
	}
	dfs(1);
	if (flag == true) cout << "First" << endl;
	else cout << "Second" << endl;
	return 0;
}

Measured memory_bytes: 7040