akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

int main() {
    ll q, h, s, d;
    ll n;
    cin >> q >> h >> s >> d >> n;
    n *= 4;
    vector<P> table = {{1, q}, {2, h}, {4, s}, {8, d}};
    sort(table.begin(), table.end(), [](P x, P y) {
        return (x.second * y.first) < (y.second * x.first);
    });

    ll ans = 0;
    rep(i, 4) {
        ll count = (ll) n / table.at(i).first;
        n -= (ll) count * table.at(i).first;
        ans += (ll) count * table.at(i).second;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
def hit(point, base, out_count):
    new_base = (base << 1) + 1
    return point + (new_base > 0b111), new_base & 0b111, out_count


def homerun(point, base, out_count):
    return point + (bin(base & 0b111).count('1') + 1), 0, out_count


def out(point, base, out_count):
    return point, base, out_count - 1


F = {'HIT': hit, 'HOMERUN': homerun, 'OUT': out}

i, point, base, out_count = int(input()), 0, 0, 3

while i:

    point, base, out_count = F[input().strip()](point, base, out_count)

    if not out_count:
        i -= 1
        print(point)
        point, base, out_count = 0, 0, 3

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for1(i, a, b) for (int i = (int)a; i < (int)(b); ++i)
#define rfor1(i, a, b) for (int i=(int)b-1;i>=(int)a;i--)
#define for2(i, a, b) for (int i = (int)a; i <= (int)(b); ++i)
#define for3(i, a, b) for (int i = (int)a; i < (int)(b); i=i+2)
#define for4(i, a, b) for (int i = (int)a; i <= (int)(b); i=i+2)
#define tc(t) int t; cin>>t; while(t--)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x; cin>>x;
    if(x<1200){
        cout<<"ABC"<<endl;
    }
    else if(x>=12 && x<2800){
        cout<<"ARC"<<endl;
    }
    else{
        cout<<"AGC"<<endl;
    }

}






Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repin(a, n)  \
	vector<ll> a(n); \
	rep(i, n) { cin >> a[i]; }
#define repins(a, n)     \
	vector<string> a(n); \
	rep(i, n) { cin >> a[i]; }
#define repind(a, n)     \
	vector<double> a(n); \
	rep(i, n) { cin >> a[i]; }
#define in(a) \
	ll a;     \
	cin >> a;
#define ins(a) \
	string a;  \
	cin >> a;
#define ind(a) \
	double a;  \
	cin >> a;
template <class T>
inline void out(T a)
{
	cout << a << endl;
}
inline void out(double a) { printf("%.10f\n", a); }
#define all(x) (x).begin(), (x).end()
#define rep2(i, a, b) for (ll i = (a); i < (b); ++i)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
#define yes out("Yes")
#define no out("No")
#define degtorad(deg) (deg * M_PI / 180.0)
#define radtodeg(rad) (rad * 180.0 / PI)

int main()
{
	ull a;
	cin >> a;
	ins(b);
	b = b.erase(b.find("."),1);
	ull ans = stoull(b) * a;
	auto s = to_string(ans);
	if(s.size()<=2){
		out(0);
	}else{
		out(s.substr(0,s.size()-2));
	}
}

Measured memory_bytes: 3696
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations,combinations,combinations_with_replacement
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N,M,X = map(int,input().split())
rows = [list(map(int,input().split())) for _ in range(N)]
rows = np.array(rows)

ans = 10**5 * N +1
for bitlines in range(0,1<<N):
    tmp = np.array([0]*(M+1))
    for target in range(N):
        if bitlines>>target & 1:
            tmp = tmp + rows[target]
        else:
            continue
    if np.bincount((tmp>=X)[1:],minlength=2)[1]==M:
        ans = min(ans,tmp[0])

if ans == 10**5 * N +1:
    ans = -1

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 27288
#include <stdio.h>
#include <stdlib.h>
int main(void){
	int a,b,c,d,e,k;
	scanf("%d %d %d %d %d %d", &a, &b, &c,&d,&e,&k);
	if ( abs(a-b)<=k &&  abs(a-c)<=k &&  abs(a-d)<=k &&  abs(a-e)<=k &&  abs(b-c)<=k &&  abs(d-b)<=k &&  abs(e-b)<=k &&  abs(c-d)<=k &&  abs(c-e)<=k && abs(d-e)<=k )printf("Yay!\n");

	else printf(":(\n");
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#include <cmath>
#include <iomanip>
using namespace std;
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))
 
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)
 
#define nl '\n'
#define ioi exit(0);
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;
 
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

struct point{
	int x, y;
	bool operator < (const point & a){
		if(x == a.x){
			return y < a.y;
		}
		return x < a.x;
	}
} v[100];

point nexttotop(stack<point>& st){
	point t = st.top();
	st.pop();
	point r = st.top();
	st.push(t);
	return r;
}

int compare(point  a, point  b, point  c){
	point u, v;
	u.x = a.x-b.x;
	u.y = a.y-b.y;
	v.x = c.x-b.x;
	v.y = c.y-b.y;
	int val = v.x*u.y - v.y*u.x;
	if( val == 0) return 0;
	else if(val > 1) return 1;
	else return -1;
}

int main(){
	ll n; cin>> n;
	ll mini = linf;
	bool ok = false;
	
	for(ll i = 2; i*i <= n; i++){
		if(n % i == 0){
			mini = min (mini, i - 1 + (n / i) - 1);
			ok = true;
		}
		
	}
	if(ok)
		cout<< mini;
	else
		cout<< n - 1;
	return 0;
}
 


Measured memory_bytes: 256
import java.util.*;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        String ans = "No";
        for (int i = 0; i < 3; i++) {
            if (N.charAt(i) == '7') {
                ans = "Yes";
                break;
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 26992
#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 println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int main(){
	string s;
	cin>>s;
	int r = 0, ans = 0;
	rep(i, s.size()){
		if(s[i]=='S') r++;
		else{
			if(r == 0) ans++;
			else r--;
		}
	}
	cout<<ans+r<<endl;
}

Measured memory_bytes: 644
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    A, B, C = LI()

    if (A, B, C).count(5) == 2 and (A, B, C).count(7) == 1:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9 + 7;
const int INF = (int)100100100;

int main() {
    int W,H; cin >> W >> H;
    int N; cin >> N;
    //int N,M; cin >> N >> M;
    //string S; cin >> S;
    //int H,W; cin >> H >> W;
    int xmin=W,ymin=H,xmax=0,ymax=0;
    for(int i=0;i<N;i++){
        int x,y,a;
        cin >> x >> y >> a;
        if (a==1 && x>xmax){
            xmax=x;
        }
        if (a==2 && x<xmin){
            xmin=x;
        }
        if (a==3 && y>ymax){
            ymax=y;
        }
        if (a==4 && y<ymin){
            ymin=y;
        }
    }
    if(xmin<xmax)xmin=xmax;
    cout << max(0,(xmin-xmax)*(ymin-ymax)) << endl;
}

/*



 */



Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#define rep(i, n) for(int i=0; i<n; i++)
#define rep_one(i, n) for(int i=1; i<n; i++)
using namespace std;
typedef long long ll;


int main(){
    string s, t; cin >> s >> t;
    int c = 0;
    rep(i, s.length()){
        if(s[i] != t[i]) c++;
    }
    cout << c << endl;
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
//#define int long long
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}


const int N = 100100;
int cor[N];
vector<pii> g[N];
int vis[N];
int cor0,cor1=0;
void dfs(int v){
  vis[v] = 1;
  for(auto e : g[v]){
    if(vis[e.ff])continue;
    cor[e.ff] = cor[v]^e.ss;
    dfs(e.ff);
  }
  if(cor[v]==0)cor0++;
  else cor1++;
}

int32_t main(){
 fastio;
 int n,m;
 cin>>n>>m;
 for(int i=1;i<=m;i++){
   int x,y,z;
   cin>>x>>y>>z;
    // x + y == z mod2
   z%=2;
   if(z==0){
    g[x].pb(pii(y,0));
    g[y].pb(pii(x,0));
   }else{
    g[x].pb(pii(y,1));
    g[y].pb(pii(x,1));
   }
 }

 int res=0;
 for(int i=1;i<=n;i++){
  if(g[i].size()==0){
    res ++ ;
  }else if(!vis[i]){
    cor0 = cor1 = 0;
    cor[i] = 0;
    dfs(i);
    //res+=min(cor0,cor1);
    res ++;
  }
 }
 cout << res << endl;

  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

Measured memory_bytes: 9600
import itertools
N, K = [int(_) for _ in input().split()]
XY = [[int(_) for _ in input().split()] for _ in range(N)]
X, Y = [x for x, y in XY], [y for x, y in XY]
X_s, Y_s = sorted(X), sorted(Y)
ans = float('inf')
for x1, x2 in itertools.combinations(X_s, 2):
    for y1, y2 in itertools.combinations(Y_s, 2):
        k = sum([x1 <= X[i] <= x2 and y1 <= Y[i] <= y2 for i in range(N)])
        if k >= K:
            ans = min(ans, (x2 - x1) * (y2 - y1))
print(ans)


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, m);
    priority_queue<int> pq;

    int ans = 0.0;
    rep(i, n) {
        int tmp;
        cin >> tmp;
        pq.push(tmp);
        ans += tmp;
    }

    rep(i, m) {
        int tmp = pq.top();
        pq.pop();

        ans -= (tmp / 2) + (tmp % 2);
        pq.push(tmp / 2);
    }

    cout << Decimal << ans << endl;


    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
 
using namespace std;
 
int main(void) {
  int n;
  cin >> n;
  int p[n];
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  int c = 0;
  for (int i = 0; i < n - 2; i++) {
    if ((p[i] < p[i+1] && p[i+1] < p[i+2]) || (p[i+2] < p[i+1] && p[i+1] < p[i])) {
      c++;
    }
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
#include <deque>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;
Graph G;
const int AMAX = 100000;
/*int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}



int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}

*/


/*
 * 最大公約数計算
 */
int gcd(int a, int b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int A,B,C,D;
	cin >> A >> B >> C >> D;
	int n4 = 0;
	int n2 = 0;
	int n1 = 0;
	int fin = min(B, D);
	int st = max(A, C);
	int ans = fin - st;
	if (ans <= 0)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << ans << endl;
	}
		

	
	
	return 0;

	


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
using namespace std;

int main() {
  int N,  alice = 0, bob = 0;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i<N; i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  for (int i = 0; i<(N+1)/2; i++){
    alice += a.at(N-1-2*i);
  }
  for (int i = 0; i<N/2; i++){
    bob += a.at(N - 2- 2 *i);
  }
  cout << alice - bob << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60;
const ll mod=1e9+7;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1};
double dp[101010][20], a[20][20];
int n, m;
double rec(int mask, int x)
{
    if(dp[mask][x]!=-1)
        return dp[mask][x];
    if(x==m)
        return dp[mask][x] = 1;
    if(mask==0)
        return dp[mask][x] = 0;
    double ret = 0;
    rep(i,n){
        if(mask & 1<<i){
            double res = 0,pos=1.0;
            REP(j, x, m){
                res += rec(mask ^ (1 << i), j) * pos * (1.0 - a[i][j]);
                pos = pos * a[i][j];
            }
            res += pos;
            ret = max(res, ret);
        }
    }
    return dp[mask][x] = ret;
}
int main(){
    cin >> n >> m;
    rep(i,n)rep(j,m){
        cin >> a[i][j];
    }
    int all = 1 << n;
    rep(i, all) rep(j, m) dp[i][j] = -1;
    cout << fixed << setprecision(12) << rec(all - 1, 0) << endl;
    return 0;
}


Measured memory_bytes: 13528
#include<iostream>
using namespace std;
int main(){
    int a;
    string moji;
    cin >> a >>moji;

    if(a>=moji.length()){
        cout<<moji;
    }else{
        for(int i =0;i<a;i++){
            cout<<moji[i];
        }
        cout<<"...\n";

    }
    

}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define ll long long
double sum = 0 ,a[60];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
         cin>>a[i];
    }
    sort(a+1,a+1+n);
    for(int i=2;i<=n;i++){
        a[i] = (a[i-1] + a[i])/2;
    }

    printf("%.5lf\n",a[n]);

    return 0;
}



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

bool m(int x) { return x == -1; }

void check(vector<vector<int>>& a, int b) {
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      if (a[i][j] == b) a[i][j] = -1;
    }
  }
}
bool yoko(vector<vector<int>>& a, int row) {
  return m(a[row][0]) && m(a[row][1]) && m(a[row][2]);
}
bool tate(vector<vector<int>>& a, int col) {
  return m(a[0][col]) && m(a[1][col]) && m(a[2][col]);
}
bool naname0(vector<vector<int>>& a) {
  return m(a[0][0]) && m(a[1][1]) && m(a[2][2]);
}
bool naname1(vector<vector<int>>& a) {
  return m(a[2][0]) && m(a[1][1]) && m(a[0][2]);
}
int main() {
  vector<vector<int>> a(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> a[i][j];
    }
  }

  int N; cin >> N;
  for (int i = 0; i < N; i++) {
    int b; cin >> b;
    check(a, b);
  }

  bool sum = false;
  for (int i = 0; i < 3; i++) {
    sum |= yoko(a, i);
    sum |= tate(a, i);
  }
  sum |= naname0(a);
  sum |= naname1(a);
  if (sum) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int x=scan.nextInt(),a=scan.nextInt(),b=scan.nextInt();
		if(b-a<=0) {
			System.out.println("delicious");
		}
		else if(b-a<=x) {
			System.out.println("safe");
		}
		else {
			System.out.println("dangerous");
		}
	}

}

Measured memory_bytes: 35728
#include<stdio.h>
int main(){
  int i=0;
  int ians;
  int x[10000];
  while(1){
    scanf("%d",&x[i]);
    if(x[i]==0)  break;
    i++;
    }
    for(ians=0;ians<i;ians++){
      printf("Case %d: %d\n",ians+1,x[ians]);
    }
    return 0;
}

Measured memory_bytes: 640
amax = 100000
cnt = [0 for i in range(amax+1)]


N, K = list(map(int, input().split()))

for i in range(N):
    a, b = list(map(int, input().split()))
    cnt[a] += b


for ans in range(1, amax+1):
    if K <= cnt[ans]:
        print(ans)
        break
    K -= cnt[ans]

Measured memory_bytes: 5912
import java.io.*;
import java.util.Scanner;
 
public class Main {
    public static void print() {
        Scanner sc = new Scanner(System.in);
        int count = 1, i;
        while (true) {
            i = sc.nextInt();
            if (i == 0) break;
            System.out.println("Case " + count++ + ": " + i);
        }
    }
 
    public static void main (String[] args) {
        // Scanner sc = new Scanner(System.in);
        // int W = sc.nextInt();
        // int H = sc.nextInt();
        // int x = sc.nextInt();
        // int y = sc.nextInt();
        // int r = sc.nextInt();
        print();
    }
}


Measured memory_bytes: 42416
#include <iostream>
    using namespace std;
    int main() {
       string s ;
       cin >>s;
       for( int i=0;i<s.size();i++){
           if(s[i]==','){
               s[i]=' ';
               cout<<s[i];
           }
           else{
               cout<<s[i];
           }
       }
    }

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

using namespace std;
typedef long long ll;

int n;
int h[200100];
const int mx = 1 << 18;
ll bit[mx];
void ins(int idx, ll val)
{
    while (idx < mx)
    {
        bit[idx] = max(bit[idx], val);
        idx += idx & -idx;
    }
}
ll gt(int idx)
{
    ll ret = 0;
    while (idx)
    {
        ret = max(ret, bit[idx]);
        idx -= idx & -idx;
    }
    return ret;
}
int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
    {
        scanf("%d", &h[i]);
    }
    for (int i = 0, x; i < n; ++i)
    {
        scanf ("%d", &x);
        ins(h[i], x + gt(h[i]-1));
    }
    printf("%lld\n", gt(mx-1));

    return 0;
}


Measured memory_bytes: 2560
fn c() {

    input! {
        n: u64
    }

    let m = (n as f64).sqrt() as u32;

    for q in 1..=n {
        let mut count = 0;
        for x in 1..m {
            let x_sq = x.pow(2);
            for y in 1..=x {
                let y_sq = y.pow(2);
                for z in 1..=y {
                    let z_sq = z.pow(2);
                    let ans: u64 = (x_sq + y_sq + z_sq + x * y + y * z + z * x).into();
                    if ans == q {
                        let mut add = 1;
                        if x == y && y == z {
                            count += 1;
                        }
                        else if x == y || y == z {
                            count += 3;
                        }
                        else {
                            count += 6;
                        }
                    }
                }
            }
        }
        println!("{}", count);
    }
}

use proconio::{input, marker::Chars};

fn main() {
    c();
}

Measured memory_bytes: 2148
#include <stdio.h>

// insertion sort


void output(int a[], int n){
    for(int i=0; i<n-1; i++) {
        printf("%d ", a[i]);
    }
        printf("%d\n", a[n-1]);
}


int main() {
    int n;
    int now_position = 1;
    int sorted_position = 0;
    int v;
    int slide = 0;
    int a[100];
    scanf("%d", &n);

    for(int i=0; i<n; i++) {
        scanf("%d", &a[i]);
    }


    


    while (now_position < n ) {
        output(a, n);
        //printf("now_position: %d, sorted_position: %d\n", now_position, sorted_position);
        //for(int i=0; i<n; i++) {
        //    printf("%d ", a[i]);
        //}
        //printf("\n");
        v = a[now_position];
        
        for (int i=now_position-1; i>=0; i--){
            if (v <= a[i]) {
                slide++;
            }
        }
        int tmp = 0 ;
        for (int i=0; i<slide; i++){
            a[now_position + tmp] = a[now_position + tmp - 1];
            tmp--;

        }
        
        //printf("slide %d\n", slide);
        //printf("v = %d\n", v);
        a[now_position + tmp] = v;
        slide=0; 
        now_position++;  
        
        
        
    }
        output(a, n);
        //for(int i=0; i<n; i++) {
        //    printf("%d ", a[i]);
        //}
        //printf("\n");

    
    return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int digit_sum(int n) {
  int sum=n%10;
  while(n!=0) {
    n/=10;
    sum+=n%10;
  }
  return sum;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}

int main() {
  int n,m;
  cin >> n >> m;
  vector<tuple<int, int , int>> py;
  REP(i,m) {
    int p,y;
    cin >> p >> y;
    py.emplace_back(p,y,i);
  }
  sort(ALL(py));
  int city=0,cnt=0;
  vpi ans(m);
  for(auto i:py) {
    if(get<0>(i)!=city) {
      city=get<0>(i);
      cnt=1;
    } else {
      cnt++;
    }
    ans[get<2>(i)]=pi(city,cnt);
  }
  REP(i,m) {
    cout << setfill('0') << right << setw(6) << ans[i].first;
    cout << setfill('0') << right << setw(6) << ans[i].second;
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 5332
#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};

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for(int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if(k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

combination c(100);

int main() {
  string n;
  int k;
  cin >> n >> k;
  int N = n.size();
  reverse(all(n));
  ll dp[N + 1][k + 1][2] = {};
  dp[0][0][0] = dp[0][0][1] = 1;
  rep(i, N) rep(j, k + 1) rep(m, 2) {
    if(j == 0)
      dp[i + 1][j][m] = 1;
    else if(m == 1)
      dp[i + 1][j][m] = c(i + 1, j).x * pow(9, j);
    else if(n[i] == '0')
      dp[i + 1][j][m] = dp[i][j][0];
    else
      dp[i + 1][j][m] =
          dp[i][j][1] + dp[i][j - 1][1] * (n[i] - '1') + dp[i][j - 1][0];
  }
  cout << dp[N][k][0] << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
long long k = 1, c, a, b;
int main() {
	cin >> a >> b;
	c = __gcd( a, b );
	for(int i = 2; i <= sqrt( c ); i++){
		if(c % i == 0){
			while(c % i == 0){
				c = c / i;
			}
			k++;
		}
	}
	if(c == 1)
		cout << k;
	else
		cout << k + 1;
	return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<ll, ll>
const ll  MOD = 1000000007;

int main() {
	ll n, m;
	cin >> n >> m;
	if (n >= m) {
		cout << 0;
		return 0;
	}
	vector<ll> x(m);
	priority_queue<ll> d;
	rep(i, m) cin >> x.at(i);
	sort(all(x));
	rep(i, m - 1) d.push(x.at(i + 1) - x.at(i));
	n--;
	rep(i, n) d.pop();
	ll ans = 0;
	rep(i, m - n - 1) {
		ans += d.top();
		d.pop();
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 2168
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
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; }
const int INF = 1<<30;
const int mod = 1000000007;

int main(){
	int a, b;
	cin >> a >> b;
	char ans = 'x';
	if(a+b==15) ans = '+';
	else if(a*b==15) ans = '*';
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
s = input()

maybe = True

def ok1(c):
    if c == 'R' or c == 'U' or c == 'D':
        return True
    return False

def ok2(c):
    if c == 'L' or c == 'U' or c == 'D':
        return True
    return False


for i in range(0 , len(s) , 2):
    if not ok1(s[i]):
        maybe = False

for i in range(1 , len(s), 2):
    if not ok2(s[i]):
        maybe = False
#print(s)
#for i in range(0 , len(s) , 2):
#    print(s[i] , end=' ')

if maybe:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import copy
N = int(input())
T = list(map(int, input().split()))
M = int(input())
P, X = [0] * M, [0] * M
for i in range(M):
    P[i], X[i] = map(int, input().split())
    
    
for i in range(M):
    tmp = copy.deepcopy(T)
    tmp[P[i] - 1] = X[i]
    print(sum(tmp))

Measured memory_bytes: 3444
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
 
ll i,j,k,ii,jj;
ll n,m,sum,num;
ll a,b,c,d,e,ans=0;
ll x[100005],y[100005],z[100005];

int main(){
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>a;
		if(a==1){
			ans=(n-1+m-2)/(m-1);
			p(ans);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 5248
import java.util.Scanner;

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

       int n=scan.nextInt();
       int m=scan.nextInt();
       int l=scan.nextInt();

       long a[][]=new long[n][m];
       long b[][]=new long[m][l];
       long c[][]=new long[n][l];

       for(int i=0;i<n;i++){
           for(int j=0;j<m;j++){
               a[i][j]=scan.nextLong();
           }
       }
       for(int i=0;i<m;i++){
           for(int j=0;j<l;j++){
               b[i][j]=scan.nextLong();
           }
       }

        for(int i=0;i<n;i++){
            for(int j=0;j<l;j++){
                for(int k=0;k<m;k++){
                    c[i][j]+=a[i][k]*b[k][j];
                }
            }
        }

        for(int i=0;i<n;i++){
            for(int j=0;j<l;j++){
                System.out.print(c[i][j]);
                if(j<l-1){
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
    }
}



Measured memory_bytes: 52712
// Nguyen Anh Tu
#include <bits/stdc++.h>
#define FOR(x,a,b) for(int x=a;x<=b;x++)
#define FORD(x,a,b) for(int x=a;x>=b;x--)
#define maxn 100005
#define maxc 1000000007
#define MOD 1000000007
#define reset(x,y) memset(x,y,sizeof(x))
#define task ""
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define pii pair<int,int>
#define ll long long
#define bit(p,x) ((x>>p) & 1)
#define remain(a,b) (a+b >= MOD) ? (a+b - MOD) : (a+b)

using namespace std;
int n,a,b;
int main()
{
   ios_base::sync_with_stdio(NULL);
   cin.tie(NULL);
   cout.tie(NULL);
    cin >> a >> b;
    for(int i=1; i<=1000; ++i)
    {
        if((int)(i * 0.08) == a){
            if ((int)(i/10) == b) {
                cout << i;
                return 0;
            }
        }

    }
    cout << -1;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long  
#define mod 1000000007
#define am 998244353
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c=0;
    cin>>a;
    for(int i=1;i<=a;i++){
	b=i*1.08;
	
	if(b==a){
	    cout<<i<<"\n";
	    c=0;
	    break;
	}
	
	else{
	    if(b>a) c=1;
	}
    }
    if(c) cout<<":(\n";
}



Measured memory_bytes: 256
// AOJ 1153
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

const int NMAX = 108;

int sum(vector<int> v) {
  int s = 0;
  for (int x : v) {
    s += x;
  }
  return s;
}

int main() {
  int n, m;
  while (cin >> n >> m and n) {
    vector<int> S(n), T(m);
    REP(i, n) { cin >> S[i]; }
    REP(i, m) { cin >> T[i]; }

    sort(S.begin(), S.end());
    sort(T.begin(), T.end());

    int sums = sum(S), sumt = sum(T);
    int diff = sums - sumt;

    if (diff % 2 == 0) {
      diff /= 2;
      bool flag = true;
      for (int s : S) {
        if (find(T.begin(), T.end(), s - diff) != T.end()) {
          cout << s << " " << s - diff << endl;
          flag = false;
          break;
        }
      }
      if (flag) {
        cout << -1 << endl;
      }
    } else {
      cout << -1 << endl;
    }
  }
}

Measured memory_bytes: 1220
def read_tiles(h, w):
    c = []
    for _ in range(h):
        c.append([int(x) for x in input().split()])
    return c


def largest_square(h, w, c):
    ls = 0
    dp = [[None] * w for _ in range(h)]
    for i in range(h):
        for j in range(w):
            if c[i][j] == 1:
                dp[i][j] = 0
            elif i == 0 or j == 0:
                dp[i][j] = 1
            else:
                dp[i][j] = (
                    min(dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1]) + 1
                )
            ls = max(ls, dp[i][j] ** 2)
    return ls

def main():
    h, w = map(int, input().split())
    c = read_tiles(h, w)
    print(largest_square(h, w, c))


main()



Measured memory_bytes: 55840
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	private static final List<String> WEATHERS = Arrays.asList("Sunny", "Cloudy", "Rainy");

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			String s = scanner.next();
			System.out.println(WEATHERS.get((WEATHERS.indexOf(s) + 1) % WEATHERS.size()));
		}
	}
}


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

int main(){
    int h, w; cin >> h >> w;
    vector<string> C;
    
    for(int i = 0; i < h; i++){
        string line;
        cin >> line;
     //   cout << "input" << line << endl;
        C.push_back(line);
        C.push_back(line);
    }
    
    for(int i = 0; i < 2*h; i++){
        cout << C.at(i) << endl;
    }
    
}




Measured memory_bytes: 256
S=set(input())
Al="qwertyuiopasdfghjklzxcvbnm"
AL=list(Al)
l=[]
for i in range(len(Al)):
  if not AL[i] in S:
    l.append(AL[i])
if l!=[]:
  print(sorted(l)[0])
else:
  print("None")

Measured memory_bytes: 3188
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def main():
    r = intin()

    if r < 1200:
        print('ABC')
    elif r < 2800:
        print('ARC')
    else:
        print('AGC')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3548
import sys
sys.setrecursionlimit(10**6)
n = int(input())
*P, = map(int, input().split())
memo = {(n-1, i): i for i in range(P[-1]+1)}
def dfs(pos, t):
    if (pos, t) in memo:
        return memo[pos, t]
    res = memo[pos, t] = dfs(pos+1, max(0, P[pos+1]-t)) + t*2
    return res
print(min(dfs(0, P[0]-i)+i for i in range(P[0]+1)))

Measured memory_bytes: 14488
//Problema C
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int N;
    cin >> N;
    long long int resultado = 0;
    int previous = 0;
    int current;
    for(int i = 0; i < N; i++)
    {
        cin >> current;
        resultado += max(0, previous - current);
        previous = max(previous, current);
    }
    cout << resultado;

    return 0;
}



Measured memory_bytes: 3628
#include<stdio.h>

int main(){
  int len = 0, i = 0, j;
  char s[11], t[11];
  
  scanf("%s", s);
  while(s[len]){
    if(s[len] == '0'){
      t[i++] = '0';
      t[i] = '\0';
    } else if(s[len] == '1'){
      t[i++] = '1';
      t[i] = '\0';
    } else if(s[len] == 'B'){
      if(i > 0){
        t[--i] = '\0';
      }
    }
    len++;
  }
  
  printf("%s\n", t);
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int MAXN=100+10;
int n,x;
int l[MAXN];
int ans=1,t;
int main(){
	scanf("%d%d",&n,&x);
	for(int i=1;i<=n;i++)
		scanf("%d",&l[i]);
	for(int i=1;i<=n;i++){
		t+=l[i];
		if(t>x) break;
		ans++;
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  set<int> Mochi;
  for (int i = 0; i < N; i++) {
    int d;
    cin >> d;
    Mochi.insert(d);
  }
  cout << Mochi.size() << endl;
}


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

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define FOR(n) for(int i = 0;i < n;i++)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define ipow(x,y) LL(pow(x,y))

//Debug
#define TEST cout << "OK\n"

const double PI = M_PI;
const long long INF = int(999999999);
const long long MOD = int(1000000007);

//Settings
const bool DO_BENCHMARK = false;
const int DOUBLE_ACCURACY = 15;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    void solve();
    if(DO_BENCHMARK){
        clock_t clock_start = clock();
        solve();
        clock_t clock_end = clock();
        const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
        cout << "\n" << time << "[ms]\n";
    }
    else solve();
}

void solve(){
    int K,X;
    cin >> K >> X;
    if(K*500 >= X){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


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

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=a;i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(a>b)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	
	int n;cin>>n;
	vi a(n);
	rep(i,n)cin>>a[i];
	sort(all(a));
	vi neg(n);
	int val=0;
	rep(i,n)val+=abs(a[i]);
	if(a[0]>=0){
		neg[0]=1;
		val-=a[0]*2;
	}else if(a[n-1]<=0){
		fill(neg.bg,neg.ed-1,1);
		val+=a[n-1]*2;
	}else{
		rep(i,n)if(a[i]<0)
			neg[i]=1;
	}
	cout<<val<<endl;
	vi x,y;
	rep(i,n)if(!neg[i])
		x.pb(a[i]);
	else
		y.pb(a[i]);
	
	dmp(x);
	dmp(y);
	
	int c=1,d=0;
	vvc<int> tr(1);
	vi sgn{1};
	rep(i,n*2-1){
		dmp(i);
		dmp(c);
		dmp(d);
		dmp(sgn);
		if((sgn[i]==1&&d+1<=int(y.size()))||(sgn[i]==-1&&c+1<=int(x.size()))){
			int s=tr.size();
			tr[i].pb(s);
			tr[i].pb(s+1);
			tr.eb();
			tr.eb();
			sgn.pb(sgn[i]);
			sgn.pb(-sgn[i]);
			if(sgn[i]==1)
				d++;
			else
				c++;
		}
	}
	
	function<int(int)> rec=[&](int v){
		if(tr[v].size()){
			int e=rec(tr[v][0]);
			int f=rec(tr[v][1]);
			cout<<e<<" "<<f<<"\n";
			return e-f;
		}else{
			int ret;
			if(sgn[v]==1){
				ret=x.back();x.pop_back();
			}else{
				ret=y.back();y.pop_back();
			}
			return ret;
		}
	};
	rec(0);
}


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

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vi a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  vi a_sorted = a;
  sort(a_sorted.begin(), a_sorted.end());

  for (int i = 0; i < n; i++) {
    if (a[i] == a_sorted[n - 1]) {
      cout << a_sorted[n - 2] << endl;
    } else {
      cout << a_sorted[n - 1] << endl;
    }
  }

  return 0;
}


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

int main(){
	string s;
	int k;
	cin >> k >> s;
	if(s.size() <= k){
		cout << s << endl;
	}else{
		rep(i, k){
			cout << s.at(i);
		}
		cout << "..." << endl;
	}
	return 0;
}

Measured memory_bytes: 3632
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

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;
}

//想定解答との絶対誤差または相対誤差が 10−6以下の場合+1以上だしておく。適当に15とかでもおｋ．
//cout << fixed << setprecision(15);

int main() {
    ll N, K;
    cin >> N >> K;
    //vector<vector<int>> data(3, vector<int>(4));
    //初期値0
    //vector<int> data(i, 0);
    vl a(N);
    rep(i, 0, N) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    ll res = INF;
    rep(i, 0, N-K+1) {
        ll temp = a[i+K-1] - a[i];
        res = min(temp, res);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  int64_t a=0;
  for(int i=0;i<N;i++){
  if(i%2==0)
    a+=A.at(i);
    else
      a-=A.at(i);
  }a/=2;
  vector<int64_t>B(N);
  B.at(0)=a;
  for(int i=1;i<N;i++)
    B.at(i)=A.at(i-1)-B.at(i-1);
  for(int i=0;i<N-1;i++)
    cout<<2*B.at(i)<<" ";
  cout<<2*B.at(N-1)<<endl;
    return 0;
}

Measured memory_bytes: 2944