akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
 
int main(){
    int countTable[256] = {0};
    char ch;
 
    while((ch = getchar()) != EOF){
                countTable[ch]++;
    }
    for(int i = 97; i <=122;i++)printf("%c : %d\n",i,countTable[i]+countTable[i-32]);
}


Measured memory_bytes: 2628
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <functional>
#include <iomanip>
#include <queue>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
const int MOD = 1e9+7;
const ll INF = 1e16;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

// debug
template<class T>ostream& operator<<(ostream& os, vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& out,const pair<T1,T2>& rhs){out<<"("<<rhs.first<<", "<<rhs.second<<")";return out;}
#include<type_traits>
template<typename T,size_t SIZE,enable_if_t<!is_same<remove_cv_t<T>,char>::value,nullptr_t> = nullptr>ostream& operator<<(ostream& os,T(&arr)[SIZE]){os<<"{";for(size_t i=0;i<SIZE;++i)os<<(i?", ":"")<<arr[i];os<<"}";return os;}
#ifdef LOCAL
    #define debug(v) cerr<<v<<"\n"
#else
    #define debug(...) 42
#endif

using Edges = vector<vector<pii>>;

void dijkstra(Edges &edge, vector<ll> &cost, int start, int N) {
  cost.resize(N);
  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>> > q;
  fill(cost.begin(), cost.end(), INF); cost[start] = 0;
  q.push(make_pair(0, start));

  while (!q.empty()) {
    pair<ll, ll> p = q.top(); q.pop();
    ll u = p.second;
    ll cur_cost = p.first;

    if (cost[u] < cur_cost)
      continue;
    for (const pii e : edge[u]) {
      int v = e.first;
      ll edge_cost = e.second;
      if (cost[v] > cost[u] + edge_cost) {
        cost[v] = cost[u] + edge_cost;
        q.push(make_pair(cost[v], v));
      }
    }
  }
}

int main() {
  int N, M; cin >> N >> M;
  int s, t; cin >> s >> t;
  --s, --t;

  Edges edge(N, vector<pii>()),
       edge2(N, vector<pii>());
  rep(i, M) {
    int u, v;
    int a, b;
    cin >> u >> v >> a >> b;
    --u, --v;
    edge[u].emplace_back(v, a);
    edge[v].emplace_back(u, a);
    edge2[u].emplace_back(v, b);
    edge2[v].emplace_back(u, b);
  }
  vector<ll> cost1, cost2;
  dijkstra(edge, cost1, s, N);
  dijkstra(edge2, cost2, t, N);

  ll max_snuuk = 0;
  ll res[N];
  rrep(i, N-1) {
    // sからiまで円で行って、iからtまでスヌークで行く
    ll tmp = 1e15 - (cost1[i] + cost2[i]);
    max_snuuk = max(max_snuuk, tmp);
    res[i] = max_snuuk;
  }
  rep(i, N) {
    cout << res[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 16196
N, K = map(int, input().split())
A = list(map(int, input().split()))

X = 0
k = 1 << 41
for _ in range(41):
  k = k >> 1
  if X + k > K:
    continue
  
  count = 0
  for i in range(N):
    if A[i] & k:
      count += 1
  
  if count < N / 2:
    X += k
    
ans = 0
for i in range(N):
  ans += A[i] ^ X
  
print(ans)

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

int main() {
    vector<int> v(3);
    vector<int> s = {5, 5, 7};
    for (int i = 0; i < 3; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    if (v == s) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

bool is_finised(vector<int>& poss, int n) {
	FOR_LT(i, 0, n) {
		if (poss[i] != n - 1) return false;
	}
	return true;
}

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

	int n; cin >> n;
	vector<vector<int>> as(n, vector<int>(n - 1));
	FOR_LT(i, 0, n) {
		FOR_LT(j, 0, n - 1) {
			cin >> as[i][j];
			as[i][j]--;
		}
	}

	vector<int> poss(n);
	int d = 0;

	queue<pair<int, int>> pair;
	{
		vector<bool> used(n);
		FOR_LT(i, 0, n) {
			if (poss[i] == n - 1) continue;
			if (used[i]) continue;

			int c = as[i][poss[i]];
			if (used[c]) continue;
			if (as[c][poss[c]] == i) {
				pair.push({ i, c });
				used[i] = true;
				used[c] = true;
			}
		}
	}

	int p = 0;
	while (p != (n * (n - 1) / 2)) {
		if (pair.empty()) {
			cout << -1 << endl;
			return 0;
		}

		queue<int> ps;
		while (!pair.empty()) {
			auto c = pair.front();
			pair.pop();

			p++;

			poss[c.first]++;
			poss[c.second]++;
			ps.push(c.first);
			ps.push(c.second);
		}

		vector<bool> used(n);
		while (!ps.empty()) {
			int i = ps.front();
			ps.pop();

			if (poss[i] == n - 1) continue;
			if (used[i]) continue;

			int c = as[i][poss[i]];
			if (used[c]) continue;
			if (as[c][poss[c]] == i) {
				pair.push({ i, c });
				used[i] = true;
				used[c] = true;
			}
		}

		d++;
	}

	while (!is_finised(poss, n)) {
		vector<bool> used(n);
		bool has_pair = false;

		FOR_LT(i, 0, n) {
			if (poss[i] == n - 1) continue;
			if (used[i]) continue;

			int c = as[i][poss[i]];
			if (used[c]) continue;
			if (as[c][poss[c]] == i) {
				poss[i]++;
				poss[c]++;
				used[i] = true;
				used[c] = true;
				has_pair = true;
			}
		}

		if (!has_pair) {
			cout << -1 << endl;
			return 0;
		}
		d++;
	}

	cout << d << endl;

	return 0;
}

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

int main()
{
    int a,b;
    std::string text;
    std::cin >> a;
    std::cin >> b;

    if (a == b) {
        std::cout << "a == b" << std::endl;
        return(0);
    }

    a > b ? text = "a > b" : text = "a < b";
    std::cout << text << std::endl;
}


Measured memory_bytes: 3120
#include <iostream>
using namespace std;
int field[9][9];

bool check(int x, int y) {
	int count = 0;
	for (int i = 0; i < 9; i++) {
		if (field[x][i] == field[x][y]) count++;
		if (field[i][y] == field[x][y]) count++;
	}
	int ofx = x / 3;
	int ofy = y / 3;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			if (field[ofx * 3 + i][ofy * 3 + j] == field[x][y]) count++;
		}
	}
	return count == 3;
}

int main() {
	int n;
	bool flg = true;
	cin >> n;
	for (int i = 0; i < n ; i++) {
		if (flg) {
			flg = false;
		}
		else {
			cout << endl;
		}
		for (int j = 0; j < 9; j++) {
			for (int k = 0; k < 9; k++) {
				cin >> field[j][k];
			}
		}
		for (int j = 0; j < 9; j++) {
			for (int k = 0; k < 9; k++) {
				char c = ' ';
				if (!check(j, k)) {
					c = '*';
				}
				cout << c << field[j][k];
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	ll now=n%10;
	if(now==3){
		cout << "bon";
	}
	else if(now==0||now==1||now==6||now==8){
		cout << "pon";
	}
	else{
		cout <<"hon";
	}
	// your code goes here
	return 0;
}

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

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	int a[n];
	int idx = 1;
	int last_i = -1;
	int count = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] == idx) {
			count += (i-last_i-1);
			last_i = i;
			idx++;
			continue;
		}
		if (i == n-1) {
			if (idx == 1) {
				cout << "-1" << endl;
				return 0;
			}
			count += i-last_i;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 4352
#include <iostream>
using namespace std;
typedef long long LL;
const int N=5022;
LL dp[N][N];
int n,a,b,x[N],pos[N];
int main(){
    scanf("%d%d%d",&n,&a,&b);
    for(int i=1;i<=n;i++) scanf("%d",&x[i]), pos[x[i]]=i;
    for(int i=0;i<N;i++)for(int j=0;j<N;j++)dp[i][j]=1e18;
    dp[0][0]=0;
    for(int i=1;i<=n;i++){
        LL mn=dp[i-1][0];
        for(int j=0;j<=n+1;j++){
            mn=min(mn,dp[i-1][j]);

            if(j==pos[i]) dp[i][j]=mn;
            else if(j<pos[i]) dp[i][j]=mn+b;
            else dp[i][j]=mn+a;
    
            //printf("dp[%d][%d]=%lld\n", i,j,dp[i][j]);
        }
    }
    LL ans=1e18;
    for(int i=0;i<=n+1;i++)ans=min(ans,dp[n][i]);
    cout<<ans<<endl;
}

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

int func(char c){
	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

int main(){
	int n,low;
	int sum1,sum2,sum3;
	string temp1,temp2;

	cin >>n;
	low=n;
	for(int i=1;i<n;i++){
		temp1=to_string(i);
		temp2=to_string(n-i);
		sum1=0;
		sum2=0;
		for(int j=0;j<(int)temp1.size();j++){
			sum1+=func(temp1[j]);
		}
		for(int j=0;j<(int)temp2.size();j++){
			sum2+=func(temp2[j]);
		}
		sum3=sum1+sum2;
		if(low>sum3)low=sum3;
	}
	cout<<low<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<vector<int> > V(N+1);
    for (int i = 0; i < N-1; ++i) {
        int a, b;
        cin >> a >> b;
        V[a].push_back(b);
        V[b].push_back(a);
    }
    vector<bool> passed(N+1, false);
    int start = 1;
    passed[start] = true;
    long long ans = K;
    queue<int> Q;
    Q.push(start);
    int dist = 0;
    while (!Q.empty()) {
        int size = Q.size();
        dist++;
        while (size--) {
            int c = Q.front();
            Q.pop();
            if (dist > 2) dist = 2;
            int cv = K-dist;
            for (const auto v : V[c]) {
                if (passed[v]) continue;
                Q.push(v);
                passed[v] = true;
                if (cv < 1) {
                    puts("0");
                    return 0;
                }
                ans *= cv;
                ans %= mod;
                cv--;
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 6520
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
constexpr int MOD = 1000000007;
constexpr ll INF = 50000000000000000;
typedef std::pair<int, int> P;
constexpr ll SIZE = 100010;

ll N, A[100010], B[SIZE];
ll ans = 0, sum = 0, wa = 0;
int main() {
	std::ios_base::sync_with_stdio(false);
	cin >> N;
	REP(i, N) {
		cin >> A[i];
		sum += A[i];
		wa += i + 1;
	}
	REP(i, N) {
		B[i] = A[(i + 1) % N] - A[i];
	}
	bool f = true, g = true;
	if (sum%wa != 0)g = false;
	REP(i, N) {
		B[i] -= sum / wa;
	}
	int cnt = 0;
	REP(i, N) {
		DEB((B[i] - B[(i + 1) % N]))END
		if (B[i]<=0 && -B[i] % N == 0)cnt += -B[i] / N;
		else if (B[i] != 0)f = false;
	}
	if (cnt != sum / wa)f = false;

	cout << (f&&g ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
// const ll mod = 1000000007;
const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"


bool solve(){
    ll n,t;cin>>n>>t;
    vector<ll>A(n);
    rep(i,n)cin>>A[i];

    ll ma=0;
    set<ll>set;
    rep(i,n){
        set.insert(A[i]);
        chmax(ma,A[i]-*set.begin());
    }
    ll ans=0;
    rep(i,n){
        set.erase(A[i]);  
        if(set.find(A[i]+ma)!=set.end()){
            // cout<<A[i]<<endl;
            ans++;
        }
    }
    cout<<ans<<endl;

    return false;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(30);
    solve();
}


Measured memory_bytes: 5888
/*** keep hungry and calm CoolGuang!***/
#include <bits/stdc++.h>
#include<algorithm>
#include<stdio.h>
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll INF=1e13;
const ll maxn=1e6+5;
const int mod=998244353;
const double eps=1e-12;
ll n,m,p;
ll num[maxn];
int pre[maxn][2];
int cur[maxn][2];
ll st[maxn][30];
ll lg[maxn];
void work()
{
    ll cnt=0;
    for(int i=1;i<=n;i++)
        lg[i]=lg[i/2]+1;
    for(int i=1;i<=n;i++)
        st[i][0]=num[i];
    for(int j=1;j<=25;j++)
        for(int i=1;i+(1<<j)-1<=n;i++)
            st[i][j]=max(st[i][j-1],st[i+(1<<(j-1))][j-1]);
}
ll query(ll x,ll y)
{
    ll len=lg[y-x+1]-1;
    return max(st[x][len],st[y-(1<<len)+1][len]);//为啥+1
}
void work_one(){//预处理左边第一个比他大的
    for(int i=1;i<=n;i++){
        pre[i][1]=pre[i][0]=0;//假设第一个比他大的和第二个比他大的都木有
        ll l=1,r=i-1;
        ll ans=-1,aim=num[i];
        while(l<=r){
            ll mid=(l+r)/2;
            if(query(mid,i)>aim){
                l=mid+1;
                ans=mid;
            }
            else r=mid-1;
        }
       // printf("%lld\n",ans);
        if(ans==-1) continue;
        pre[i][0]=ans;
        ll temp=-1;
        l=1,r=ans-1;
        while(l<=r){
            ll mid=(l+r)/2;
            if(query(mid,ans-1)>aim){
                l=mid+1;
                temp=mid;
            }
            else r=mid-1;
        }
        if(temp==-1) continue;
        pre[i][1]=temp;
    }
}
void work_two(){
    for(int i=n;i>=1;i--){
        cur[i][1]=cur[i][0]=n+1;
        ll l=i+1,r=n;
        ll ans=-1,aim=num[i];
        while(l<=r){
            ll mid=(l+r)/2;
            if(query(i,mid)>aim){
                r=mid-1;
                ans=mid;
            }
            else l=mid+1;
        }
       // printf("%lld\n",ans);
        if(ans==-1) continue;
        cur[i][0]=ans;
        ll temp=-1;
        l=ans+1,r=n;
        while(l<=r){
            ll mid=(l+r)/2;
            if(query(ans+1,mid)>aim){
                r=mid-1;
                temp=mid;
            }
            else l=mid+1;
        }
        if(temp==-1) continue;
        cur[i][1]=temp;
    }
}
int main()
{
    scanf("%lld",&n);
    for(int i=1;i<=n;i++) scanf("%lld",&num[i]);
    work();
    work_one();
    work_two();
    ll ans=0;
    for(int i=1;i<=n;i++){
        ans+=(pre[i][0]-pre[i][1])*(cur[i][0]-i)*num[i];
        ans+=(cur[i][1]-cur[i][0])*(i-pre[i][0])*num[i];
    }
    printf("%lld\n",ans);
    return 0;
}
/***
5
1 2 3
2 2 3
3 1 2
2 1 2
1 1 2
***/


Measured memory_bytes: 35840
N = int(input())
a = list(map(int, input().split()))
s = sum(a)
x = int(s / len(a))

if (x + 1) - (s / len(a)) < (s / len(a)) - x:
    x += 1
cost = 0
for y in a:
    cost += pow(y - x, 2)

print(cost)

Measured memory_bytes: 9088
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  int ans = 0;
  while (N != 0) {
    if (N % 10 == 2) ++ans;
    N /= 10;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

def main():
    S = readline().rstrip()
    T = readline().rstrip()
    N = len(S)
    M = len(T)
    for i in range(N-M, -1, -1):
        s = S[i:i+M]
        flg = True
        for e1, e2 in zip(s, T):
            if e1 != '?' and e1 != e2:
                flg = False
                break
        if flg:
            ans = list(S)
            for j in range(i, i+M):
                ans[j] = T[j-i]
            ans = ''.join(ans)
            print(ans.replace('?', 'a'))
            return

    print('UNRESTORABLE')


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

int main(){
    int N; cin >> N;
    vector<long long> a(N);
    cin >> a[0];
    long long lcm = a[0];
    for (int i = 1; i < N; i++){
        cin >> a[i];
        lcm = LCM(lcm,a[i]);
    }
    //cout << lcm-1 << endl;
    long long ans = 0;
    for (int i = 0; i < N; i++){
        ans += (a[i]-1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

#define MAX_T 100

int K, T, a[MAX_T];

int main()
{
  scanf("%d %d", &K, &T);
  for (int i = 0; i < T; i++)
    scanf("%d", &a[i]);
  
  int aMax=0, aSecondMax=0;
  while (true){
    int aMaxIndex = 0;
    int aSecondMaxIndex = 0;
    for (int i = 0; i < T; i++)
    {
      if (a[i] > aMax){
        aMax = a[i];
        aMaxIndex = i;
      }
    }
    for (int i = 0; i < T; i++)
    {
      if (a[i] > aSecondMax && i != aMaxIndex){
        aSecondMax = a[i];
        aSecondMaxIndex = i;
      }
    }
    if (aSecondMax == 0){
      break;
    }
    a[aMaxIndex]--;
    a[aSecondMaxIndex]--;
    aMax = 0;
    aSecondMax = 0;
  }
  if (aMax == 0){
    aMax = 1;
  }
  printf("%d\n", aMax-1);
  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> edge(n, vector<int>());
    rep(i, 0, m) {
        int from, to;
        cin >> from >> to;
        from--;
        to--;
        edge[from].push_back(to);
    }
    for (int fst : edge[0]) {
        for (int sec : edge[fst]) {
            if (sec == n - 1) {
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }

    cout << "IMPOSSIBLE" << endl;

    return 0;
}


Measured memory_bytes: 8576
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <algorithm>
#include <cassert>
#include <string>

using namespace std;
using ll = long long;

int N, A, B, C;
vector<int> l;

int dfs(int cur, int a, int b, int c) {
	if (cur == N) {
		int minValue = min(min(a, b), c);
		return (minValue > 0) ? abs(a - A) + abs(b - B) + abs(c - C) - 30 : 1000000;
	}

	int ret0 = dfs(cur+1, a, b, c);
	int ret1 = dfs(cur+1, a+l[cur], b, c) + 10;
	int ret2 = dfs(cur+1, a, b+l[cur], c) + 10;
	int ret3 = dfs(cur+1, a, b, c+l[cur]) + 10;
	return min(min(ret0, ret1), min(ret2, ret3));
}

int main(void) {
	cin >> N >> A >> B >> C;
	l.resize(N);
	for (int i = 0; i < N; i++) {
		cin >> l[i];
	}

	cout << dfs(0, 0, 0, 0) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;typedef long long ll;typedef pair<ll,ll>pll;
#define fi first
#define se second
#define pb(x) push_back(x)
#define m_p(a,b) make_pair(a,b);
#define sz(a) ((int)(a).size())
#define f(i,a,b) for(int i=a;i<b;++i)
#define ff(i,a,b) for(int i=a;i<=b;++i)
#define de(a) cout << #a << " = " << a << endl;
#define dd(a) cout << #a << " = " << a << "  ";
#define file freopen("in.txt","r",stdin)
#define mem(a,b) memset(a,b,sizeof(a))
#define INF 0x3f3f3f3f
#define jkl ios::sync_with_stdio(false);cin.tie(false);
#define all(x) x.begin(),x.end()
/*********************************************/
int main() {
	int a,b,c;
	cin >> a >> b >> c;
	if(a*b<c) cout << a*b;
	else cout << c;
	cout << endl;
}

Measured memory_bytes: 256
h,w = map(int,input().split())

s = []
for _ in range(h):
	s.append(list(input()))

inf = float('inf')
dp = [[inf for _ in range(w)] for _ in range(h)]
dp[0][0] = 0

for i in range(h):
	for j in range(w):
		if s[i][j] == ".":
			if j > 0 and i > 0:
				dp[i][j] = min(dp[i-1][j],dp[i][j-1])
			elif j > 0 and i == 0:
				dp[i][j] = dp[i][j-1]
			elif j == 0 and i > 0:
				dp[i][j] = dp[i-1][j]
		else:
			tmp1 = inf
			tmp2 = inf
			if i > 0:
				tmp1 = dp[i-1][j]
				if s[i-1][j] == ".":
					tmp1 += 1
			if j > 0:
				tmp2 = dp[i][j-1]
				if s[i][j-1] == ".":
					tmp2 += 1
			dp[i][j] = min(tmp1,tmp2)
			if i==0 and j==0:
				dp[i][j] = 1

print(dp[h-1][w-1])



Measured memory_bytes: 42676
import { readFileSync } from 'fs'
function main() {
  const input = readFileSync('/dev/stdin', 'utf8')
  const [a, b] = input.trim().split('\n')
  const n = Number(a)
  const takoyaki = b.split(' ').map(v => Number(v))
  let result = 0
  for (let i = 0; i < takoyaki.length; i++) {
    const t1 = takoyaki[i];
    for (let j = i + 1; j < takoyaki.length; j++) {
      const t2 = takoyaki[j];
      result += t1 * t2
    }
  }
  console.log(result)
}
main()


Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std; 
int main(){
 ios_base::sync_with_stdio(false);
   cin.tie(NULL);
    long long int x;
    cin>>x;
    if(x%1000==0){
    	cout<<"0\n";
	}
	else{
		long long int h=ceil((float)x/1000);
		cout<<(h*1000-x)<<"\n";
	}
 return 0;
}

Measured memory_bytes: 3780
#include<iostream>
#include<string>
#include<cstdio>
#define N 1000
using namespace std;

int ans[N+1][N+1];

int deal(string s1,string s2){
    int maxl=-1;

    for(int i=0;i<s1.length();i++){
        ans[i][0]=0;
    }
    for(int j=0;j<s2.length();j++){
        ans[0][j]=0;
    }
    for(int i=1;i<s1.length();i++){
        for(int j=1;j<s2.length();j++){
            if(s1[i]==s2[j]){
                ans[i][j]=ans[i-1][j-1]+1;
            }else{
                ans[i][j]=max(ans[i-1][j],ans[i][j-1]);
            }
            maxl=max(maxl,ans[i][j]);
        }
    }
    return maxl;
}

int main(){
    int n;
    string s1,s2;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s1>>s2;
        s1=" "+s1;
        s2=" "+s2;
        cout<<deal(s1,s2)<<endl;
    }
    return 0;
}



Measured memory_bytes: 7068
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("POSSIBLE")
#define p_no() p("IMPOSSIBLE")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    int N, M;
    cin >> N >> M;

    vector<ll> A(M);
    vector<ll> B(M);
    FOR(i, 0, M){
        ll a, b;
        cin >> a >> b;
        A[i] = a;
        B[i] = b;
    }

    vector<ll> reachable;
    FOR(i, 0, M){
        if(A[i]==1){
            reachable.push_back(B[i]);
        }
    }

    vector<ll> goalable;
    FOR(i, 0, M){
        if(B[i]==N){
            goalable.push_back(A[i]);
        }
    }

    if(reachable.size()==0 || goalable.size()==0){
        p_no();
        return 0;
    }

    sort(ALL(reachable));
    sort(ALL(goalable));

    // 積集合
    vector<ll> result;
    set_intersection(ALL(reachable), ALL(goalable), inserter(result, result.end()));

    if(result.size()>0){
        p_yes();
    }else{
        p_no();
    }
    
    return 0;
}

Measured memory_bytes: 5748
# -*- coding: utf-8 -*-
import sys 
import math
sys.setrecursionlimit(10**6)
MOD = 10**9+7 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, D = map(int, readline().split())
ans = 0
for i in range(N):
    x, y = map(int, readline().split())
    d = math.sqrt(x**2+y**2)
    if d <= D:
        ans += 1
print(ans)

Measured memory_bytes: 73908
#include<iostream>
using namespace std;
int main(){
  int a,b,c,x;
  cin>>a>>b>>c>>x;
  int count=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){
          count++;
        }
      }
    }
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 256
dpw = [[0 for i in range(105)] for j in range(105)]
dph = [[0 for i in range(105)] for j in range(105)]
while 1:
    w,h = map(int,raw_input().split())
    if w==0 and h==0: break
    for i in range(h+2):
        for j in range(w+2): dpw[i][j] = dph[i][j] = 0;
    dpw[1][0] = dph[0][1] = 1
    for i in range(h):
        for j in range(w):
            if i==h-1 and j==w-1:break
            dph[j][i+1] += dph[j][i]; dpw[j+1][i] += dpw[j][i];
            dph[j][i+2] += dpw[j][i]; dpw[j+2][i] += dph[j][i];
    print (dpw[w-1][h-1]+dpw[w][h-1]+dph[w-1][h-1]+dph[w-1][h])%10**5

Measured memory_bytes: 4768
#include<iostream>
#include<fstream>
#include<string>
#include<cstdio>
#include<algorithm>
using namespace std;
int s[5];
int main()
{
 
 cin>>s[1]>>s[2]>>s[3];
 sort(s+1,s+3+1);
 cout<<s[1]+s[2];
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll>   vl;
#define f(i,n)  for(i=0;i<n;i++)
#define f1(i,n)  for(i=1;i<n;i++)
#define fr(i,n) for(i=n-1;i>=0;i--)
#define em emplace_back
#define mp make_pair
#define in insert
#define fi first
#define sc second
#define b begin
#define e end
#define er erase
#define l length
#define c clear
#define si size
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
const double pi=3.141592653;
const ll infi=1000000001;
const ll MOD=1000000007;
const ll mod=998244353;
const string no="NO\n",yes="YES\n";

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

// void dfs(vl v[],ll node,ll hai[]){
//     hai[node]=1;
//     for(auto i:v[node]){
//         if(hai[i]==0){
//             dfs(v,i,hai);
//         }
//     }
// }

// ll con(vl v[],ll hai[],ll sz){
//     ll count=0;
//     for(int i=1;i<sz;i++){
//         if(hai[i]==0){
//             count++;
//             dfs(v,i,hai);
//         }
//     }
    // return count;
// }

// void gcde(int a,int b,int *x,int *y){
//     if(a==0){
//         *x=0;
//         *y=1;
//         return;
//     }    
//     int x1,y1;
//     gcde(b%a,a,&x1,&y1);
    
//     *x=y1-(b/a)*x1;
//     *y=x1;
// }


// ll recur(vl v,ll in,ll m,ll n){
//     if(in==-1)  return 1000000000001;
//     ll d,e,c;
//     d=max(m/v[in],n*v[in]);
//     c=recur(v,in-1,m/v[in],n*v[in]);
//     e=recur(v,in-1,m,n);
//     return min(c,min(e,d));
// }

// ll bexpo(ll a,ll p){
//     ll x=1;
//     while(p){
//     if(p&1){
//         x=(x*a)%mod;
//     }
//     a=(a*a)%mod;
//     p>>=1;
//     }
//     return x;
// }
// int dx[8]{-1,0,0,1,-1,-1,1,1};
// int dy[8]{0,-1,1,0,-1,1,-1,1};


int main() {
    fastio
    int t=1;
    // cin>>t;
    ll n,m,i,l,d,bank,s,k,j,x,y,ans,q;

    while(t--){ans=0;
        cin>>n;
        f(i,n){
            ans+=((n+i)/(i+1) -1);
        }
        cout<<ans;
    }
    
    
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using P = pair<ll,ll>;
P pan[51];

ll dfs(ll N,ll X){
    if(N==0){
        return 1;
    }
    if(X==0){
        return 0;
    }
    if(pan[N].second == X+1){
        return pan[N].first;
    }
    if(pan[N-1].second+1>X){
        return dfs(N-1,X-1);
    }
    if(pan[N-1].second+1==X){
        return pan[N-1].first+1;
    }
    return pan[N-1].first + 1 + dfs(N-1,X-2-pan[N-1].second);
}

int main() {
    ll N,X;
    cin >> N >> X;
    --X;
    pan[0] = P(1,1);
    for(int i=0;i<N;i++){
        pan[i+1] =P(pan[i].first*2 +1,pan[i].second*2+3); 
    }
    cout << dfs(N,X) << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll=long long;  
using pLL = std::pair<ll, ll>;

#define SORT(v) std::sort(v.begin(), v.end())
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,H,W;
    cin >> N>>H >> W;
    if(H==1&&W==1){
        cout << N*N <<endl;
        return 0;
    }
    int ans=0;
    for(int i=0;i<N;++i){
       for(int j=0;j<N;++j){
           if(i+H<=N&&j+W<=N){
               ans++;
               
           }
       }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <list>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

int i,j,k,l,m,n;
/////////////////////////////////////////////////////
#define INF 1010101010101010101;
#define vl vector<ll>
#define llp pair<ll,int>
ll N;
ll a[101010];
vl av;

ll ab[101010];
//ll S[202020];
ll C[202020];
priority_queue<llp> aq;

ll gets(ll num){
    fornum(i,-N,N){
        C[i+N]=0;
    }

    C[N]=1;
    int n=N;
    ll P=1l;
    ll A=0l;

    fornum(i,0,N){
        if(a[i]<num){
            P-=C[n];
            n++;  
        }else{
            n--;
            P+=C[n];
        }
        A+=P;
        C[n]++;
        P++;
        //cout<<P<<" "<<A<<endl;
    }
   
    return A;
}

int main(){
    cin>>N;
    fornum(i,0,N){
        cin>>a[i];
        av.push_back(a[i]);
    }
    sort(av.begin(),av.end());

    ll half=N*(N+1)/2;
    half=half/2+half%2;
    ll low=0,high=N-1,mid;
    ll ref=INF;
    ll check;
    //cout<<half<<endl;
    do{
        mid=(high+low)/2;
        check=gets(av[mid]);
        /*
        if(check-N%2==0){
            ref=av[mid];
            break;
        }
        */
        //cout<< ref<<" "<< av[mid] <<" "<< high<<" "<<low<<" "<<check<<" "<<endl;
        if(check>=half){
            low=mid+1;
            ref=av[mid];
        }else{
            high=mid-1;
        }
    }while(low<=high);
    cout<<ref<<endl;
    
    return 0;
}

Measured memory_bytes: 3444
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[100005];
ll a[100005];
ll n,k;
ll solve(ll id){
    if(id==n)
    return 0;
    if(dp[id]!=-1)
    return dp[id];
    ll mini = INT_MAX;
    for(ll i = id+1; i<=min(id+k,n);i++)
    mini = min(mini, abs(a[i]-a[id])+solve(i));
   return  dp[id]= mini;
    
    
}

int main() {
	//cout<<"GfG!";
	cin>>n>>k;
	memset(dp,-1,sizeof(dp));
	for(ll i=1;i<=n;i++)
	cin>>a[i];
	cout<<solve(1);
	return 0;
}

Measured memory_bytes: 9828
from collections import defaultdict

N, K, C = map(int, input().split())
s = list(input())
llst = []
rlst = []

index = 0
lcnt = 0
while index < N:
    if s[index] == 'o':
        llst.append(index)
        index += C + 1
        lcnt += 1
        if lcnt == K:
            break
    else:
        index += 1
index = N - 1
rcnt = 0
while index >= 0:
    if s[index] == 'o':
        rlst.append(index)
        index -= (C + 1)
        rcnt += 1
        if rcnt == K:
            break
    else:
        index -= 1

ans = []
for i in range(len(llst)):
    if i <= len(rlst):
        if llst[i] == rlst[-i - 1]:
            ans.append(llst[i] + 1)
    else:
        break

for i in ans:
    print(i)

Measured memory_bytes: 30268
#include <iostream>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  int a,b,c,d;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  if(a*b>c*d){
	
  	cout << a*b<<endl;
  }else{
	cout << c*d<<endl;
  }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int b[200010];

int main()
{
	int n;
	cin >> n;
	vi a(n+10);
	for(int i = 1; i <= n; i++) cin >> a[i];

	int cnt;
	for(int i = n; i >= 1; i--){
		cnt = 0;
		for(int j = 2; i*j <= n; j++){
			if(b[i*j]) cnt++;
		}
		if(a[i] != cnt%2) b[i] = 1;
	}

	int sum = 0;
	for(int i = 1; i <= n; i++) if(b[i]) sum++;

	cout << sum << endl;
	if(sum != 0){
		int cnt = 0;
		for(int i = 1; i <= n; i++){
			if(b[i]){
				cout << i;
				cnt++;
			}
			if(cnt != sum) cout << ' ';
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2560
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debg cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans,n,m;
void solve()
{
    cin>>n>>m;
    while(n>0)
    {
        n/=m;ans++;
    }
    cout<<ans<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    string S, T;
    cin >> S >> T;

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

    bool f = false;
    REP(i, S.size()) {
        if (S[i] != T[0] && S[i] != '?') continue;

        f = true;
        REP(j, T.size()) {
            if (S[i + j] == T[j] || S[i + j] == '?') continue;

            f = false;
            break;
        }

        if (f) {
            REP(j, T.size()) {
                S[i + j] = T[j];
            }
            break;
        }
    }

    if (f) {
        reverse(S.begin(), S.end());
        REP(i, S.size()) if (S[i] == '?') S[i] = 'a';
        cout << S << endl;
    } else {
        cout << "UNRESTORABLE" << endl;
    }

    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Abra_Ka_Dabra ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;

const long long mod = 1e9 + 7;
const double PI = acos(-1);
const double EPS = 1e-9;


int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif

	Abra_Ka_Dabra

	int n;
	cin >> n;
	set<int> x;
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		x.insert(tmp);
	}
	if (x.size() == n) cout << "YES\n";
	else cout << "NO\n";

	return 0;
}



Measured memory_bytes: 12916
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000007



void solve(void)
{
  string str;
  cin>>str;
  vector<char> vec;

  for (int i = 0; i < str.size(); i++)
  {
    if(str[i] == '0')
    {
      vec.push_back('0');
    }
    else if(str[i] == '1')
    {
      vec.push_back('1');
    }
    else
    {
      if(vec.size() != 0)
      {
        vec.erase(vec.begin() + vec.size() - 1 );
      }
    }
  }

  for (int i = 0; i < vec.size(); i++)
  {
    cout<<vec[i];
  }
  cout<<endl;
  
  
  return;
}



int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // std::cout << std::fixed;
  // std::cout << std::setprecision(8);

  solve();

 
  return 0;
}

Measured memory_bytes: 256
s = gets.chomp.each_char.to_a.sort
t = gets.chomp.each_char.to_a.sort.reverse

if s == t
  puts("No")
elsif s[0] < t[0]
  puts("Yes")
else
  fl = true
  (0...s.length).each do |i|
    if i >= t.length || s[i] != t[i]
      puts("No")
      fl = false
      break
    end
  end
  puts("Yes") if fl
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){int b=0;for(auto itr :a){if(b++!=0)cout << " "; cout << itr;} }
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
#define int ll
class Prime{
public:
    vector<bool>Isprime;
    vector<int>prime;
    int size;
    Prime(int n) : Isprime(n+1,true),size(n+1){
        Isprime[0] = Isprime[1] = false;
        for(int i = 2; i<=size; i++){
            if(!Isprime[i])continue;
            prime.push_back(i);
            for(int j = 2;i*j <=size;j++) Isprime[i*j] = false;
        }
    }
    bool IsPrime(int n){return (n<=size? Isprime[n]:false);}
    int indexOf(int i){return (i<prime.size()?prime[i]:INF);}
};

signed main(){
    int n,p;
    Prime pr(10000000);
    while(cin >> n >> p){
        if(n == -1 && p == -1)break;
        vector<int>v;
        rep(i,pr.prime.size()){
            if(pr.prime[i] > n)v.push_back(pr.prime[i]);
            if(v.size()>300)break;
        }
        vector<int>hoge;
        rep(i,v.size()){
            for(int j = i; j < v.size();j++){
                hoge.push_back(v[i]+v[j]);
            }
        }
        sort(all(hoge));
        cout << hoge[--p] << endl;
    }
}




Measured memory_bytes: 12304
# python3 (3.4.3)
import sys
input = sys.stdin.readline

# main
W,H,N = map(int,input().split())
XYA = [list(map(int,input().split())) for _ in range(N)]

x_lb,x_ub,y_lb,y_ub = 0,W,0,H

for x,y,a in XYA:
    if a==1:
        x_lb = max(x_lb,x)
    elif a==2:
        x_ub = min(x_ub,x)
    elif a==3:
        y_lb = max(y_lb,y)
    else:
        y_ub = min(y_ub,y)

x = max(0, x_ub - x_lb)
y = max(0, y_ub - y_lb)

print(x*y)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
string S[9999],U;int n,a,b,c,d,p[9999][2],i,j;
int main(){
while(1){
cin>>a>>b;if(!a){break;}
for(i=0;i<a;i++){
n=0;cin>>U>>c>>d;
S[i]=U;
p[i][0]=d-c+1;
p[i][1]=d;
}
for(i=0;i<b;i++){
cin>>c;
for(j=0;j<a;j++){
if(c>=p[j][0] && c<=p[j][1]){
cout<<S[j]<<' '<<c-p[j][0]+1<<endl;
goto E;
}
}
printf("Unknown\n");
E:;
}
}
}

Measured memory_bytes: 1356
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    string s;
    int k;
    cin >> s >> k;
    vector<string> subs;
    For(i,1,k+1){
        for(int j=0;j+i<s.size()+1;j++){
            subs.push_back(s.substr(j,i));
        }
    }
    sort(ALL(subs));
    unique(ALL(subs));
    cout << subs[k-1] << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
#define INF (1<<29)

int _not[3]={2,1,0};
int _and[3][3]={{0,0,0},{0,1,1},{0,1,2}};
int _or[3][3]={{0,1,2},{1,1,2},{2,2,2}};
int p,q,r;
char s[128],*pos;
int formula(){
	char c=*pos++;
	switch(c){
	case '0':return 0;
	case '1':return 1;
	case '2':return 2;
	case 'P':return p;
	case 'Q':return q;
	case 'R':return r;
	case '-':return _not[formula()];
	case '(':
		int a,b;
		a=formula();
		c=*pos++;
		b=formula();
		pos++;
		if(c=='*')return _and[a][b];
		return _or[a][b];
	}
	return -1;
}
int main(){
	while(cin>>s,s[0]!='.'){
		int ans=0;
		for(p=0;p<=2;p++){
			for(q=0;q<=2;q++){
				for(r=0;r<=2;r++){
					pos=s;
					if(formula()==2)ans++;
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1140
/* ex4_1
   takafumi_ueki */
#include <stdio.h>
#include <math.h>
int main(void){
    double tree_num,watch_num,tree_range;
    int min_num;
    //tree_num(木の本数)とwatch_num(監視員の数)を受け取る
    scanf("%lf %lf",&tree_num,&watch_num);
    //監視員が見れる木の本数を計算する
    tree_range = 2*watch_num + 1;
    //「全ての木の本数」を「監視員が見れる木の本数」で割り、割り切れない場合は一人追加する
    min_num = ceil(tree_num/tree_range);
    printf("%d\n",min_num);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {
	int N, A, B, C, X;
	while ( cin >> N >> A >> B >> C >> X, N || A || B || C || X ) {
		int Y[100];
		for (int i = 0; i < N; ++i) {
			cin >> Y[i];
		}
		int need[10001] = {0};
		int cnt = 0;
		for (int i = 0; i < N; ++i) {
			if ( !need[Y[i]] ) ++cnt;
			++need[Y[i]];
		}

		int ans = -1;
		int pos = 0;
		for (int t = 0; t <= 10000; ++t) {
			if (Y[pos] == X) {
				if (++pos == N) {
					ans = t;
					break;
				}
			}
			X = (A * X + B) % C;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for ( int (i) = 0; (i) < (n); (i)++ )
using namespace std;
using ll = long long int;
const long long int INF = 1001001001001001LL;
const int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

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

    ll n, d, a;
    cin >> n >> d >> a;
    vector<pair<ll, ll>> p(n);
    rep(i, n) cin >> p[i].first >> p[i].second;
    sort( p.begin(), p.end() );

    vector<ll> imos(n+1, 0);
    ll cnt = 0;
    rep(i, n) {
        if ( i > 0 ) imos[i] += imos[i-1];
        ll h = p[i].second - imos[i];

        if ( h > 0 )
        {
            ll c = (h+a-1) / a;
            ll damage = c*a;

            ll out = upper_bound( p.begin()+i, p.end(), make_pair( p[i].first+2*d, INF ) ) - p.begin();
            
            imos[i] += damage;
            imos[out] -= damage;
            cnt += c;
        }
    }

    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 4992