akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

int main(){
    iostream::sync_with_stdio(false);

    START:

    int n;
    cin >> n;
    if(n == 0) return 0;
    int m,p,q,r;
    cin >> m >> p >> q >> r;
    vector<pair<int, int> > updown; //1オリジン
    updown.push_back(MP(1,r));
    for(int i=0; i<m; i++){
        int x,y;
        cin >> x >> y;
        //塊の切断処理
        for(int j=0; j<updown.size(); j++){
            int a = updown[j].first;
            int b = updown[j].second;
            if(a<=x && x<b){
                updown[j].second = x;
                updown.push_back(MP(x+1,b));
                continue;
            }
            if(a<=y && y<b){
                updown[j].second = y;
                updown.push_back(MP(y+1,b));
            }
        }
        //塊の移動処理
        for(int j=0; j<updown.size(); j++){
            int a = updown[j].first;
            if(a <= x){
                updown[j].first += n-x;
                updown[j].second += n-x;
            }
            else if(a <= y){
                updown[j].first += (n-y)-x;
                updown[j].second += (n-y)-x;
            }
            else{
                updown[j].first -= y;
                updown[j].second -= y;
            }
        }
    }
    int ans = 0;
    for(int i=0; i<updown.size(); i++){
        int a = updown[i].first;
        int b = updown[i].second;
        //cout << a << " " << b << endl;
        if(p <= a && b <= q) ans += b - a + 1;
        else if(p <= b && b <= q) ans += b - p + 1;
        else if(p <= a && a <= q) ans += q - a + 1;
    }
    cout << ans << endl;

    goto START;
    
    return 0;
}



Measured memory_bytes: 3144
# abc163B
# https://atcoder.jp/contests/abc163/tasks/abc163_b

# 夏休みはN日間
# 夏休みの宿題はM個
# 宿題は同じ日に複数できない、宿題の時は遊ぶことはできない
# 最大何日間遊ぶことが出来るか
# 夏休み中に終わらせられない場合は、"-1"

# 入力
n, m = map(int, input().split())
a = list(map(int, input().split()))

# 処理
# 宿題にかかる合計日数
answer = n - sum(a)

if answer < 0:
    print("-1")
else:
    print(answer)


Measured memory_bytes: 9964
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        boolean[] invalid = new boolean[10];
        for(int i = 0; i < k; i++){
            invalid[sc.nextInt()] = true;
        }
        int curr = n;
        int tmp;
        boolean valid;
        while(true){
            tmp = curr;
            valid = true;
            while(tmp != 0){
                if(invalid[tmp % 10]){
                    valid = false;
                    break;
                }
                tmp = tmp / 10;
            }
            if(valid){
                break;
            }
            curr += 1;
        }
        System.out.println(curr);
    }
}


Measured memory_bytes: 21844
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
  /*int N, M; cin >> N >> M;
  for (int i = 0; i < N; ++i) {
    int x, y; cin >> x >> y;
  }
  for (int i = 0; i < M; ++i) {
    int p, q; cin >> p >> q;
  }*/
  while (1) {
    int N; cin >> N;
    if (!N)break;
    vector<pair<int, string>>ps;
    for (int i = 0; i < N; ++i) {
      string st; cin >> st;
      int num = 0;
      while (st[num] == '.')num++;
      ps.push_back(make_pair(num, st.substr(num, st.size() - num)));
    }
    vector<vector<char>>needs(N,vector<char>(N+2,' '));
    for (int i = 0; i < N; ++i) {
      int anum = ps[i].first;
      for (int j = i + 1; j < N; ++j) {
        if (anum > ps[j].first) {
          break;
        }
        else if (anum == ps[j].first) {
          for (int k = i + 1; k < j; ++k) {
            needs[k][anum-1] = '|';
          }
          break;
        }
      }
      if (anum) {

        needs[i][anum - 1] = '+';
      }
      for (int j = 0; j < anum; ++j) {
        
        cout << needs[i][j];
      }
      cout  << ps[i].second << endl;
    }
    
  }
  return 0;
  while (1) {
    long long int A, B, D; cin >> A >> B >> D;
  }
}

Measured memory_bytes: 4056
s = input()
t = input()
rs = list(reversed(s))
rt = list(reversed(t))
for i in range(len(s)-len(t)+1):
         for j in range(len(t)):
                  if not (rs[i+j] == "?" or rs[i+j] == rt[j]):
                           break
         else:
                  for k in range(len(t)):
                           rs[i+k] = rt[k]
                  for l in range(len(s)):
                           if rs[l] == "?":
                                    rs[l] = "a"
                  ans = list(reversed(rs))
                  answer = "".join(ans)
                  print(answer)
                  exit()
print("UNRESTORABLE")


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

int main() {
  int n;cin>>n;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  int cnt=0;
  while(1){
    int ans=0;
    rep(i,n){
      if(a[i]%2==0){
        ans++;
        a[i]/=2;
      }
    }
      if(ans!=n)break;
    cnt++;
  }
  cout<<cnt<<endl;
}

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

int main() {
    int a , b;
    cin >> a >>b;
    if(a > b){
        cout << "a > b" << endl;
    }
    else if(a < b){
        cout << "a < b" << endl;
    }
    else {
        cout << "a == b" << endl;
    }
}


Measured memory_bytes: 3120
#include <iostream>
#include <cstdint>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <cassert>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define loop(i, a, b) for (int i = a; i < (int)(b); i++)


int solve(int h, int w, vector<string> map) {
    //hcount
    int hCount[h][w];
    memset(hCount, 0, sizeof(int) * h * w);
    rep(y, h) {
        int last = -1;
        rep(x, w + 1) {
            if (x == w || map[y][x] == '#') {
                loop(i, last + 1, x) {
                    hCount[y][i] = (x - last) - 1;
                }
                last = x;
            }
        }
    }
    //vcount
    int vCount[h][w];
    memset(vCount, 0, sizeof(int) * h * w);
    rep(x, w) {
        int last = -1;
        rep(y, h + 1) {
            if (y == h || map[y][x] == '#') {
                loop(i, last + 1, y) {
                    vCount[i][x] = (y - last) - 1;
                }
                last = y;
            }
        }
    }
    // calc
    int ans = 0;
    rep(y, h) {
        rep(x, w) {
            int c = hCount[y][x] + vCount[y][x] - 1;
            ans = max(c, ans);
        }
    }
    return ans;
}

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> map;
    rep(i, h) {
        string s;
        cin >> s;
        map.push_back(s);
    }
    int ans = solve(h, w, map);
    cout << ans << "\n";
}

Measured memory_bytes: 39552
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second) return a.second < b.second;
    else return a.first < b.first;
}
std::uint32_t euclidean_gcd(std::uint32_t a, std::uint32_t b){return b != 0 ? euclidean_gcd(b, a % b) : a;}


void solve(long long N, long long K, std::vector<int> H){
    SORT(H);
    // reverse(ALL(H));
    if(K>N){
        cout<<0<<endl;return;
    }
    REP(i,K){
        H[N-i-1]=0;
    }
    LL ans=0;
    REP(i, N){
        ans+=H[i];
    }
    cout<<ans<<endl;
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<int> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%d",&H[i]);
    }
    solve(N, K, std::move(H));
    return 0;
}


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

using namespace std;

int A[600000],C[600000],D[600000]; char sd[600000];
int main()
{
	scanf("%s",sd);int L=0,R=strlen(sd);
	for(int i=R-1;i>=0;i--) A[R-i]=sd[i]-'0'; A[0]=R; C[0]=1;
	for(int t=1;t<=9;t++)
	{
		for(int j=1;j<=max(C[0],A[0]);j++)
		{
			C[j]+=A[j]; C[0]=max(C[0],j);
			if(C[j]>=10)
			{
				C[j+1]+=C[j]/10;
				C[j]%=10; C[0]=max(C[0],j+1);
			}
		}
		while(C[C[0]]>=10)
		{
			C[C[0]+1]+=C[C[0]]/10;
			C[C[0]]%=10; C[0]++;
		}
	}
	int Ans=0;
	while(L<=R)
	{
		int mid=(L+R)>>1,ts=1;
		for(int i=0;i<=C[0];i++) D[i]=C[i];
		D[1]+=mid*9; 
		while(D[ts]>=10)
		{
			D[ts+1]+=D[ts]/10;
			D[ts]%=10; ts++;
		}D[0]=max(D[0],ts);
		int cnt=0;
		for(int i=1;i<=D[0];i++) cnt+=D[i];
		if(cnt<=mid*9) R=mid-1,Ans=mid;
		else L=mid+1;
	}
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,c;
	cin>>n;
	for(n;n>0;){
		if(n%10==7)
		   c++;
		n=n/10;
	}
	if(c)
	 cout<<"Yes";
	 else
	 cout<<"No";
	return 0;
}

Measured memory_bytes: 3628
/**
*	  Name: Ajay
*	  Institute: IIITH 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define ll long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<ppi>
#define vll vector<ll>
#define mp make_pair
#define fi first
#define se second
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}

const int N=100001;
ll dp[N][13];

string s;
 
int f(int i,int num)
{
	if(i==s.size())
		return num==5;
	if(dp[i][num]!=-1)
		return dp[i][num];
	ll& ans=dp[i][num];
	ans=0;
	if(s[i]!='?')
	{
		int new_num=10*num+(s[i]-'0');
		new_num=new_num%13;
		ans+=f(i+1,new_num);
		ans=ans%mod;
	}
	else
	{
		for(int j=0;j<=9;j++)
		{
			int new_num=(10*num+j)%13;
			ans+=f(i+1,new_num);
			ans=ans%mod;
		}
	}
	return ans;
}
int main()
{
  fastio();
  cin>>s;
  memset(dp,-1,sizeof dp);
  int n=s.size();
  cout<<f(0,0);
  return 0;
}

Measured memory_bytes: 16848
program prob1
    implicit none
    character(len=3)::S, T
    integer::i, ans
    read(*,*) S, T
    ans = 0
    do i = 1, 3
        if(S(i:i) .eq. T(i:i)) then
            ans = ans + 1
        end if
    end do
    write(*,*) ans
    stop
end program

Measured memory_bytes: 2852
#include <cstdio>
#include <iostream>
using namespace std;
int main(){
    int a,b;
    int max;
    cin >> a >> b;
    int add=a+b;
    int sub=a-b;
    int mul=a*b;
    if(add>=sub && add>=mul){
        max=add;
    }
    else if(sub>=add && sub>=mul){
        max=sub;
    }
    else{
        max=mul;
    }
    cout << max;
    
    
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;
#define int long long

signed main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;

	vector <int> ar(n);
	for(int &x: ar) cin >> x;
	int mn = 0;
	for(int i=0; i<n-1; i++){
		if(ar[i] <= ar[i+1]) continue;
		if(ar[i]-ar[i+1] > 1){
			cout << "No";
			return 0;
		}

		if(ar[i]-1 < mn ){
			cout << "No";
			return 0;
		}
		ar[i]--;
		mn = ar[i];
	}	
	cout << "Yes";
	return 0;
}

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

int main(){
	int N; cin >> N;
	vector<P> A, B;
	vector<int> C(N);
	rep(i, N){ cin >> C[i]; A.push_back(P(C[i], i)); }
	rep(i, N){ int b; cin >> b; B.push_back(P(b, i)); }
	sort(ALL(A));
	sort(ALL(B));
	sort(ALL(C));
	int to[N];
	rep(i, N){
		if(A[i].first > B[i].first){ cout << "No" << endl; return 0; }
		to[A[i].second] = B[i].second;
	}
	int x = 0, c = 1;
	while(to[x] != 0){ c++; x = to[x]; }
	if(c < N){ cout << "Yes" << endl; return 0; }
	rep(i, N){
		if((upper_bound(ALL(C), B[i].first) - C.begin()) > i+1){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


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

int get_gcd(int a, int b) {
  int r;
  while (r = a % b) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  int a, b;
  while (cin >> a >> b) {
    int gcd = get_gcd(a, b);
    int lcm = a / gcd * b;
    cout << gcd << " " << lcm << endl;
  }
  return 0;
}


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

int main()
{
	int N;
	cin >> N;
	vector<int> a( N + 1);
	for( int i = 1; i <= N; i++ ) {
		cin >> a[i];
	}

	vector<int> d( N + 1 );
	for( int i = N; i > 0; i-- ) {
		int sum = 0;
		for( int j = i; j <= N; j += i ) {
			if( d[j] ) {
				sum++;
			}
		}
		if( sum % 2 != a[i] ) {
			d[i] = 1;
		}
	}

	int m = 0;
	for( int i = 1; i < N + 1; i++ ) {
		if( d[i] ) {
			m++;
		}
	}
	cout << m << endl;
	if( m ) {
		int first = 0;
		for( int i = 1; i <= N; i++ ) {
			if( d[i] ) {
				if( first ) {
					cout << " ";
				}
				cout << i;
				first = 1;
			}
		}
		cout << endl;
	}
}


Measured memory_bytes: 2432
// D - Sum of Divisors

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

ll n_div[10000001];

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

	for (int i=1; i<=N; i++) {
		for (int j=i; j<=N; j+=i) {
			n_div[j]++;
		}
	}

	ll ans = 0;
	for (int i=1; i<=N; i++) {
		//cout << i << " " << n_div[i] << endl; // **** debug ****
		ans += i * n_div[i];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 81712
from math import ceil
N, A, B = map(int, input().split())
h = []
for i in range(N):
  h += [int(input())]

Th = 2*max(h)//B
Tl = 0
while Tl+1<Th:
  t = (Th+Tl)//2
  d = []
  for i in range(N):
    c = h[i]
    d += [c-B*t]
  for i in range(N):
    c = d[i]
    if c<=0:
      continue
    t -= ceil(c/(A-B))
    if t<0:
      Tl = (Th+Tl)//2
      break
  else:
    Th = (Th+Tl)//2
print(Th)

Measured memory_bytes: 12976
#include<cstdio>
#include<algorithm>
using namespace std;

typedef long long ll;
const int MAXN=2e5+5;
const int MOD=1e9+7;

int n;
int a[MAXN],b[MAXN];
ll ans,fac[MAXN],inv[MAXN],d[4005][4005];

ll P(ll x,ll y){return (fac[x+y]*inv[x]%MOD)*inv[y]%MOD;}

int main(){

    fac[0]=1;
    for(int i=1;i<MAXN;i++) fac[i]=fac[i-1]*i%MOD;
    inv[1]=1;
    for(int i=2;i<MAXN;i++) inv[i]=1ll*(MOD-MOD/i)*inv[MOD%i]%MOD;
    ll inv2=inv[2];
    inv[0]=1;
    for(int i=1;i<MAXN;i++) inv[i]=inv[i-1]*inv[i]%MOD;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d%d",&a[i],&b[i]);
        d[2001-a[i]][2001-b[i]]++;
    }
    for(int i=1;i<=4001;i++)
        for(int j=1;j<=4001;j++){
            d[i][j]=(d[i][j]+d[i][j-1])%MOD;
            d[i][j]=(d[i][j]+d[i-1][j])%MOD;
        }
    for(int i=1;i<=n;i++) (ans+=d[2001+a[i]][2001+b[i]])%=MOD;
    for(int i=1;i<=n;i++) ans=((ans-P(2*a[i],2*b[i])%MOD)+MOD)%MOD;
    ans=ans*inv2%MOD;
    printf("%lld\n",(ans+MOD)%MOD);

    fclose(stdin);
    fclose(stdout);
}


Measured memory_bytes: 130176
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := getNextInt(scanner)
	ac := make([]int, n)
	wa := make([]int64, n)

	for i := 0; i < m; i++ {
		no := getNextInt(scanner) - 1
		result := getNextString(scanner)
		if result == "AC" {
			ac[no] = 1
			continue
		}
		wa[no] += int64(1 - ac[no])
	}

	nac := 0
	nwa := int64(0)
	for i := 0; i < n; i++ {
		nac += ac[i]
		if ac[i] == 0 {
			continue
		}
		nwa += wa[i]
	}

	fmt.Fprintln(writer, fmt.Sprintf("%d %d", nac, nwa))
}


Measured memory_bytes: 3456
package main

import (
	"fmt"
)

func main() {
	var n, d, x, step int
	fmt.Scan(&n, &d, &x)

	total := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&step)
		total += countChocEated(d, step)
	}
	fmt.Println(total + x)
}

func countChocEated(day, step int) int {
	count := 0
	for i := 0; step*i+1 <= day; i++ {
		count++
	}
	return count
}


Measured memory_bytes: 512
import * as fs from 'fs';

const k = +fs.readFileSync("/dev/stdin", "utf8");

const list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];

const result = list[k - 1];
console.log(result);


Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    string s;
    cin>>s;
    REP(i,s.size()){
        REP(y,s.size()){
            if(i!=y){
                if(s[i]==s[y]){
                    cout<<"no"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"yes"<<endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
span = []
mod = 998244353
for i in range(k):
    span.append(list(map(int, input().split())))
dp = [0 for i in range(n+1)]
acc = [0 for i in range(n + 1)]
dp[0] = 1
for i in range(n+1):
    acc[i] += acc[i-1]
    acc[i] %= mod
    dp[i] += acc[i]
    for j in range(k):
        l, r = span[j]
        if l + i < n + 1:
            acc[l + i] += dp[i]
        if r + 1 + i < n + 1:
            acc[r+1 + i] -= dp[i]
    dp[i] %= mod
print(dp[-2] % mod)

Measured memory_bytes: 94040
n  = int(input())
xs = []
hs = [1] * n

for _ in range(0, n):
	xs.append([None] * n)

for i in range(0, n):
	a = int(input())
	
	for _ in range(0, a):
		x, y         = [int(x) for x in input().split()]
		xs[i][x - 1] = y

def solve(hs, i):
	if i == n:
		for j in range(0, n):
			if hs[j] != 0:
				for k in range(0, n):
					if j != k and xs[j][k] != None and hs[k] != xs[j][k]:
						return 0
		return sum(hs)
	
	hs[i] = 1
	x     = solve(hs, i + 1)
	hs[i] = 0
	y     = solve(hs, i + 1)
	
	return max(x, y)

print(solve(hs, 0))


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;

int ConvStrToInt(std::string checkStr)
{
	return atoi(checkStr.c_str());
}

int ConvStrToInt(char c)
{
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}

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

	string year = S.substr(0, 4);
	string month = S.substr(5, 2);
	string day = S.substr(8, 2);

	bool isBefore = false;


	if (ConvStrToInt(year) == ConvStrToInt("2019"))
	{
		if (ConvStrToInt(month) == ConvStrToInt("04"))
		{
			isBefore = true;
		}
		else if (ConvStrToInt(month) <= ConvStrToInt("04"))
		{
			isBefore = true;
		}
		else
		{
			isBefore = false;
		}
	}
	else if (ConvStrToInt(year) < ConvStrToInt("2019"))
	{
		isBefore = true;
	}
	else
	{
		isBefore = false;
	}

	cout << ((isBefore == true) ? "Heisei" : "TBD") << endl;
	return 0;
}


Measured memory_bytes: 256
(defun split-at-space (str)
  (labels ((inter-func (seq acc)
	     (let ((index (position #\space seq)))
	       (if (null index)
		   (reverse (cons seq acc))
		   (inter-func (subseq seq (1+ index) (length seq)) (cons (subseq seq 0 index) acc))))))
    (inter-func str nil)))

(defun solve (string)
  (coerce (mapcar
	   (lambda (x) (char-upcase (car (coerce x 'list))))
	   (split-at-space string))
	  'string))

(format t "~A~%" (solve (read-line)))

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

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

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

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

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

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

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

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

fn main() {
    input!{
        a: String,
        b: String,
    }
   println!("{}", if a == b {"H"} else {"D"});
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=100000000000000007;
const int MOD=1000000007;
signed main(){
  int n,k;cin>>n>>k;
  n%=k;
  int res=min(n,abs(k-n));
  cout<<res<<"\n";
  return 0;
}


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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

int n, r;

signed main()
{
    cin >> n >> r;
    if (n < 10){
        cout << r + 100 * (10 - n) << endl;
    } else {
        cout << r << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

typedef long long ll;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> s(M), c(M);
    rep(i, M) cin >> s[i] >> c[i];
    rep(i, 1000) {
        if (N == 1 && i > 9) break;
        if (N == 2 && i < 10) continue;
        if (N == 2 && i > 99) break;
        if (N == 3 && i < 100) continue;
        bool f = false;
        string t = to_string(i);
        rep(j, M) {
            if (t[s[j] - 1] - '0' != c[j]) f = true;
        }
        if (!f) {
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1\n";
}

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
#define PI acos(-1)
#define eps 1e-10
#define mem(x) memset(x,0,sizeof(x))
#define _for(x,y,z) for(int (x)=(y);(x)<=(z);(x)++)
#define __for(x,y,z) for(int (x)=(y);(x)>=(z);(x)--)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}

const int INF=0x3f3f3f3f;
const int MAX=1e5+5;
const int MOD=1e9+7;

string blue[105],red[105];
int n,m;

int main(){
    std::ios::sync_with_stdio(false);
    cin>>n;
    _for(i,1,n){
    	cin>>blue[i];
    }
    cin>>m;
    _for(i,1,m){
    	cin>>red[i];
    }
    int ans=0;
    _for(i,1,n){
    	string tstr=blue[i];
    	int tans=0;
    	_for(j,1,n){
    		if(blue[j]==tstr) tans++;
    	}
    	_for(j,1,m){
    		if(red[j]==tstr) tans--;
    	}
    	ans=max(ans,tans);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		
		int cnt = 0;
		for (int i = 0; i <= a; i++) {
			for (int j = 0; j <= b; j++) {
				for (int k = 0; k <= c; k++) {
					if (i * 500 + j * 100 + k * 50 == x) cnt++;
				}
			}
		}
		
		System.out.println(cnt);
		
		sc.close();
	}
}




Measured memory_bytes: 27068
#include<iostream>
#include<cstring>
#include<queue>
using namespace std;
//masu,count
struct Greater{
  bool operator() (pair<int,int>a,pair<int,int> b)
  {
    if(a.second!=b.second)
      return a.second>b.second;
    return  a.first<b.first;
  }
};

int main()
{
  int n;
  for(;cin>>n;)
    {
      int p[n];
      for(int i=0;i<n;i++)
	{
	  cin>>p[i];
	}
      bool closed[n];
      memset(closed,false,sizeof(closed));
      priority_queue<pair<int,int> ,vector<pair<int,int> >, Greater> qu;
      qu.push(make_pair(0,0));
      while(!qu.empty())
	{
	  pair<int,int >data = qu.top();qu.pop();
	  if(data.first>=n-1)
	    {
	      cout<<data.second<<endl;
	      break;
	    }
	  //	  cout<<qu.top().first<<" "<<qu.top().second<<endl;
	  for(int i=1;i<=6;i++)
	    {
	      int dx=data.first+i;
	      while(dx<n-1 && p[dx]!=0)
		{
		  if(closed[dx])
		    break;
		  closed[dx]=true;
		  dx+=p[dx];
		}
	      if(!closed[dx])		
		qu.push(make_pair(dx,data.second+1));
	      closed[dx]=true;
	    }
	}
    }

}

Measured memory_bytes: 1704
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int N, W, dp[110][100010];
signed main() {
    cin >> N >> W;

    fill(dp[0], dp[N+1], -1);
    dp[0][0] = 0;
    for(int i=0; i<N; i++) {
        int w, v; cin >> w >> v;
        for(int j=0; j<=W; j++) {
            if(dp[i][j] < 0) continue;
            if(j+w <= W) chmax(dp[i+1][j+w], dp[i][j] + v);
            chmax(dp[i+1][j], dp[i][j]);
        }
    }
    int ans = 0;
    for(int i=0; i<=W; i++) chmax(ans, dp[N][i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 80128
#include "bits/stdc++.h"

using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long

int main()
{
  IOS;
  ll n, k;
  cin >> n >> k;
  ll arr[n];
  for (int i=0; i<n; i++)
    {
      cin >> arr[i];
    }
  sort (arr, arr+n);
  ll ans=0;
  if (n>k)
    {
      for (int i=0; i<n-k; i++)
	{
	  ans+=arr[i];

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


Measured memory_bytes: 5172
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		int a = stdin.nextInt();
		int b = stdin.nextInt();
		int c = stdin.nextInt();
		int d = stdin.nextInt();
		int e = stdin.nextInt();
		int k = stdin.nextInt();
		if(e-a<=k) {
			System.out.println("Yay!");
		}else {
			System.out.println(":(");
		}
		

	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
 
signed main(){
    int A,B;
    cin >>A>>B;
    cout<<(A*3+B)/2<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define Int long long
#define rep(i,n) for(Int i=0; i<n; ++i)
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 chmas(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  Int N; cin >> N;
  vector<Int> dp(N+100, INF);
  dp[0] = 0;
  rep(i, N) {
    chmin(dp[i+1],dp[i]+1);
    for(Int j=6; j<=N-i; j*=6) { chmin(dp[i+j],dp[i]+1); }
    for(Int j=9; j<=N-i; j*=9) { chmin(dp[i+j],dp[i]+1); }
  }

  cout << dp[N] << endl;
}


Measured memory_bytes: 1024
# 5000兆 = 5 * 10 ** 15
LONGDAYS = 5 * 10 ** 15
S = gets.chomp.split("").map(&:to_i)
K = gets.to_i
count = 0
flag = false
S.each do |num|
  if num == 1
    count += 1
    if count >= K
      puts num
      break
    end
  else
    current = 1
    LONGDAYS.times do
      current *= num
      if count + current >= K
        flag = true
        puts num
        break
      end
    end
    count += current
  end
  break if flag
end


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

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;

const int INF=2000000000;
const ll LINF = 1e18+5;

int main() {
    ll A, B;
    cin >> A >> B;
    ll oriA, oriB;
    oriA = A;
    oriB = B;
    if(A<B) {
        ll tmp = A;
        A = B;
        B = tmp;
    }
    ll r = A % B;
    while(r!=0) {
        A = B;
        B = r;
        r = A % B;
    }
    ll aa = oriA / B;
    ll bb = oriB / B;
    cout << aa*bb*B << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main() {
	int a[5], t = 0, i, b = 0;
	for(i = 0; i < 5; i++) scanf("%d", &a[i]);
	
	for(i = 0; i < 5; i++) {
		if(a[i] % 10) {
			b = i;
			break;
		}
	}
	
	for(i = 0; i < 5; i++) {
		if(a[i] % 10 && a[i] % 10 < a[b] % 10) b = i;
	}
	
	for(i = 0; i < 5; i++) {
		if(i == b) continue;
		if(t % 10 != 0) t = (t / 10 + 1) * 10;
		t += a[i];
	}
	
	if(t % 10 != 0) t = (t / 10 + 1) * 10;
	t += a[b];
	
	printf("%d\n", t);
}

Measured memory_bytes: 128
#include <cassert>
#include <cstdint>
#include <tuple>
#include <vector>

template <typename Abelian> class PotentializedUnionFind {

public:
  using value_type = Abelian;
  using reference = value_type &;
  using const_reference = const value_type &;
  using size_type = std::uint_fast32_t;

private:
  std::vector<std::tuple<bool, size_type, value_type>> tree;
  value_type potential(const size_type x) {
    find(x);
    return std::get<2>(tree[x]);
  }

public:
  PotentializedUnionFind(const size_type size)
      : tree(size, std::forward_as_tuple(1, 1, value_type())) {}
  size_type find(const size_type x) {
    assert(x < size());
    if (std::get<0>(tree[x]))
      return x;
    const size_type t = std::get<1>(tree[x]);
    std::get<1>(tree[x]) = find(t);
    std::get<2>(tree[x]) = std::get<2>(tree[t]) + std::get<2>(tree[x]);
    return std::get<1>(tree[x]);
  }
  value_type diff(const size_type x, const size_type y) {
    assert(x < size());
    assert(y < size());
    return potential(y)+ (-potential(x));
  }
  bool unite(size_type x, size_type y, value_type d) {
    assert(x < size());
    assert(y < size());
    d = d + diff(y, x);
    x = find(x);
    y = find(y);
    if (x == y)
      return false;
    if (std::get<1>(tree[x]) < std::get<1>(tree[y]))
      std::swap(x, y), d = -d;
    std::get<1>(tree[x]) += std::get<1>(tree[y]);
    tree[y] = std::forward_as_tuple(0, x, d);
    return true;
  }
  bool same(const size_type x, const size_type y) {
    assert(x < size());
    assert(y < size());
    return find(x) == find(y);
  }
  size_type size(const size_type x) {
    assert(x < size());
    return std::get<1>(tree[find(x)]);
  }
  size_type size() const noexcept { return tree.size(); }
  bool empty() const noexcept { return tree.empty(); }
};
 
#include<iostream>
int main(void) {
	int n, m;
	std::cin >> n >> m;
	PotentializedUnionFind<int> T(n);
	while (m--) {
		int l, r, d;
		std::cin >> l >> r >> d;
		--l;--r;
		if (!T.unite(l, r, d)) {
			if (T.diff(l, r) != d) {
				std::cout << "No" << std::endl;
				return 0;
			}
		}
	}
	std::cout << "Yes" << std::endl;
	return 0;
}

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

int main() {
    ll N;
    cin >> N;
    vector<double> A(N);
    for (auto& a : A) {
        cin >> setprecision(9) >> a;
    }

    vector<vector<ll>> mat(100, vector<ll>(100));
    for (ll i = 0; i < N; ++i) {
        ll a = (ll)(A[i] * 1e9+0.1);
        int n5 = 0;
        while (a % 5 == 0) {
            a /= 5;
            ++n5;
        }
        int n2 = 0;
        while(a % 2 == 0) {
            a /= 2;
            ++n2;
        }
        mat[n2][n5] += 1;
    }

    vector<vector<ll>> count(100, vector<ll>(100));
    for (int k = 0; k < 100; ++k) {
        for (int l = 0; l < 100; ++l) {
            for (int i = k; i < 100; ++i) {
                for (int j = l; j < 100; ++j) {
                    count[k][l] += mat[i][j];
                }
            }
        }
    }
    
    ll num = 0;
    for (int k = 0; k < 9; ++k) {
        for (int l = 0; l < 100; ++l) {
            num += mat[k][l] * count[18-k][18-l];
        }
    }
    for (int k = 9; k < 100; ++k) {
        for (int l = 0; l < 9; ++l) {
            num += mat[k][l] * count[9][18-l];
        }
    }
    ll num99 = count[9][9] * (count[9][9] - 1) / 2;
    num += num99;

    cout << num << endl;

}

Measured memory_bytes: 5080
ls = list(map(int,input().split()))
S = input()
for i in range(len(S)):
    if S[i] == "N":
        ls[0],ls[1],ls[5],ls[4] = ls[1],ls[5],ls[4],ls[0]
    if S[i] == "E":
        ls[0],ls[3],ls[5],ls[2] = ls[3],ls[5],ls[2],ls[0]
    if S[i] == "W":
        ls[0],ls[3],ls[5],ls[2] = ls[2],ls[0],ls[3],ls[5]
    if S[i] == "S":
        ls[0],ls[1],ls[5],ls[4] = ls[4],ls[0],ls[1],ls[5]
print(ls[0])


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n, w;
		cin >> n >> w;
		ll wt[n + 1], val[n + 1], mxval = 0;
		for (int i = 0; i < n; i++) cin >> wt[i + 1] >> val[i + 1], mxval += val[i + 1];
		ll dp[n + 1][mxval + 1], ans = 0;
		for (ll i = 0; i <= mxval; i++) dp[0][i] = 1e18;
		dp[0][0] = 0;
		for (int i = 1; i <= n; i++) {
			for (ll j = 0; j <= mxval; j++) {
				if (val[i] > j) dp[i][j] = dp[i - 1][j];
				else dp[i][j] = min(dp[i - 1][j], wt[i] + dp[i - 1][j - val[i]]);
				if (dp[i][j] <= w) ans = max(ans, j);
			}
		}
		cout << ans << '\n';

	}
	return 0;
}

Measured memory_bytes: 82496
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	string s;cin >> s;
	vector<char> stack;
	int n = s.size();
	rep(i,n){
		if(s[i] == 'B'){
			
			if(stack.size())stack.pop_back();
		}
		else{
			stack.push_back(s[i]);
		}
	}
	rep(i,stack.size())cout << stack[i];

	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    string s;cin>>s;
    int k;cin>>k;
    vector<string> v;
    int n=s.length();
    for(int i=0;i<n;i++){
        for(int j=i;j<min(i+k,n);j++){
            v.push_back(s.substr(i,j-i+1));
        }
    }
    sort(all(v));
    v.erase(unique(all(v)),v.end());
    cout<<v[k-1]<<endl;
    return 0;
}


Measured memory_bytes: 1660
// Exawizards2019_A
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf   = 1<<29;）

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll A, B, C;
	cin >> A >> B >> C;
    
    // calculation
    if (A == B && A == C) {
		cout << "Yes" << "\n";
	} else {
		cout << "No" << "\n";
	}
    
    return 0;
}

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

char grid[100][100];
int dist[100][100];

int main()
{
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; i++)
    {
        string line;
        cin >> line;
        for (int j = 0; j < w; j++)
        {
            grid[i][j] = line[j];
        }
    }
    dist[0][0] = (grid[0][0] == '#');
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (i == 0 && j == 0) {continue;}
            dist[i][j] = 300;
            if (i > 0)
            {
                dist[i][j] = min(dist[i][j], dist[i - 1][j] + (grid[i][j] != grid[i - 1][j]));
            }
            if (j > 0)
            {
                dist[i][j] = min(dist[i][j], dist[i][j - 1] + (grid[i][j] != grid[i][j - 1]));
            }
        }
    }
    int result = (dist[h - 1][w - 1] + (grid[h - 1][w - 1] == '#')) / 2;
    cout << result << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int i,j,x[10000];

	for(i=0;i<10000;i++){
		x[i] = 0;
	}
	i=0;
	scanf("%d",&x[i]);
	
	while(x[i] != 0){
		i++;
		scanf("%d",&x[i]);
	}
	
	for(j=0;j<i;j++){
		printf("Case %d: %d\n",j+1,x[j]);
	}
	
	return 0;
}

Measured memory_bytes: 636
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let input = s.trim();
    let mut output = String::new();
    for i in 0..input.len() {
        if input.chars().nth(i).unwrap() == '0' {output.push('0');}
        else if input.chars().nth(i).unwrap() == '1' {output.push('1');}
        else if output.len() == 0 {();}
        else {output.pop().unwrap();}
    }
    println!("{}", output);
}



Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc130/tasks/abc130_e>
 問題文============================================================
 =================================================================
 解説=============================================================
 dp[i][j] := [S_1,S_i]及び[T_1,T_j]の二つの文字列を使って作れる共通部分列の総数
 としてdpする。
 
 更新は二次元累積和の要領で行えばいい
 具体的には
 
 dp[i][j] = dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1] + (S[i]==T[j]?dp[i-1][j-1]:0)
 
 で計算できる。
 ================================================================
 */

const ll MOD = 1e9+7;
template<class Type>
Type solve(Type res = Type()){
    ll N,M; cin >> N >> M;
    vector<ll> S(N),T(M);
    for(auto& in:S) cin >> in;
    for(auto& in:T) cin >> in;
    
    
    auto add = [](ll& t,const ll v){
        (t += v)%=MOD;
    };
    
    // dp[i][j] := [S_1,S_i]及び[T_1,T_j]の二つの文字列を使って作れる共通部分列の総数
    vector<vector<ll>> dp(N+1,vector<ll>(M+1));
    dp[0][0] = 1;
    for(int i = 0; i <= N;i++) dp[i][0] = 1;
    for(int j = 0; j <= M;j++) dp[0][j] = 1;

    
    for(int i = 1; i <= N;i++){
        for(int j = 1; j <= M;j++){
            add(dp[i][j],dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1] + MOD + (S[i-1]==T[j-1]?dp[i-1][j-1]:0));
        }
    }
    
    res = dp[N][M];
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  long long a, b, c; cin >> a >> b >> c;
  long long s = a + b + c;
  if (a % 2 or b % 2 or c % 2) {
    cout << 0 << "\n";
    return 0;
  }
  if (a == b and b == c) {
    cout << -1 << "\n";
    return 0;
  }
  int ca = 0, cb = 0, cc = 0;
  while (a % 2 == 0 and 3 * a != s) {
    a = (s - a) / 2;
    ca++;
  }
  if (not ca) ca = (int) 2e9;
  while (b % 2 == 0 and 3 * b != s) {
    b = (s - b) / 2;
    cb++;
  }
  if (not cb) cb = (int) 2e9;
  while (c % 2 == 0 and 3 * c != s) {
    c = (s - c) / 2;
    cc++;
  }
  if (not ca) ca = (int) 2e9;
  cout << min({ca, cb, cc}) << "\n";
  return 0;
}

Measured memory_bytes: 256
A, B, C, D = map(int, input().split())

if A <= C and C <= B:
    if B <= D:
        print(B - C)
    else:
        print(D - C)
elif A > C and A <= D:
    if B <= D:
        print(B - A)
    else:
        print(D - A)
else:
    print(0)


Measured memory_bytes: 2940