akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <limits>
#include <iomanip>

using namespace std;

int main(){
  string K;
  int D;
  cin >> K >> D;
  int size= K.size();
  long long dp[size+1][D][2];
  for(int i=0; i<=size; i++){
     for(int j=0; j< D; j++){
        for(int k=0; k<2; k++){
           dp[i][j][k] = 0;
        }
     }
  }
  dp[0][0][0] = 1;
  int mod = 1000000007;
  for(int i = 0 ; i < size; i++){
     for(int j=0; j < D; j++){
        for(int k = 0 ; k <= 9; k++){
           int prevD = (j+D*k-k)%D;
           int d = K[size-1-i]-'0';
           if( k > d ){
              dp[i+1][j][1] += dp[i][prevD][0];
              dp[i+1][j][1] += dp[i][prevD][1];
              dp[i+1][j][1] %= mod;
           }
           else if( k < d ){
              dp[i+1][j][0] += dp[i][prevD][0];
              dp[i+1][j][0] += dp[i][prevD][1];
              dp[i+1][j][0] %= mod;
           }
           else{
              dp[i+1][j][0] += dp[i][prevD][0];
              dp[i+1][j][0] %= mod;
              dp[i+1][j][1] += dp[i][prevD][1];
              dp[i+1][j][1] %= mod;
           }
        }
        //cout << i+1 <<", "<< j <<" " ;
        //for(int k = 0 ; k < 2; k++){
        //   cout << dp[i+1][j][k] <<", ";
        //}
        //cout << endl;
     }
  }
  cout << (dp[size][0][0]+mod-1)%mod<<endl;

  return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int w, h;
char s[100][100];

struct edge {
	int to;
	ll cost;
};

ll dx[2][10] = { { 1,1,1, 1, 1,2,2, 2,3 },{ -1,-1,-1,-1,-1,-2,-2,-2,-3 } };
ll dy[2][10] = { { 2,1,0,-1,-2,1,0,-1,0 },{  2, 1, 0,-1,-2, 1, 0,-1, 0 } };
ll d[2][100][100];
vector<edge> G[100010];//各頂点からの辺

void dijkstra(P start, bool _t) {
	rep(i, 100)rep(j, 100) {
		d[0][i][j] = INF;
		d[1][i][j] = INF;
	}
	d[_t][start.first][start.second] = 0;

	typedef pair<P, P> PP;

	priority_queue<PP, vector<PP>, greater<PP>> que;
	que.push({ { 0,_t },start });

	while (que.size()) {
		PP p = que.top();
		que.pop();
		int y = p.second.first;
		int x = p.second.second;
		int t = p.first.second;
		for (int i = 0; i < 9; i++) {
			int ny = y + dy[t][i];
			int nx = x + dx[t][i];
			if (ny < 0 || ny >= h || nx < 0 || nx >= w)continue;
			if (s[ny][nx] == 'X')continue;
			if (d[!t][ny][nx] > d[t][y][x] + s[ny][nx] - '0') {
				d[!t][ny][nx] = d[t][y][x] + s[ny][nx] - '0';
				que.push({ { d[!t][ny][nx],!t}, P(ny,nx) });
			}
		}
	}
}

vector<P> S, T;

int main() {
	while (cin >> w >> h&&w + h) {
		S.clear();
		T.clear();
		rep(i, h) {
			rep(j, w) {
				cin >> s[i][j];
				if (s[i][j] == 'S') {
					S.push_back(P(i, j));
					s[i][j] = '0';
				}
				if (s[i][j] == 'T') {
					T.push_back(P(i, j));
					s[i][j] = '0';
				}
			}
		}
		ll ans = INF;
		rep(i, S.size()) {
			dijkstra(S[i], 0);
			rep(j, T.size()) {
				ans = min(ans, d[0][T[j].first][T[j].second]);
				ans = min(ans, d[1][T[j].first][T[j].second]);
			}
			dijkstra(S[i], 1);
			rep(j, T.size()) {
				ans = min(ans, d[0][T[j].first][T[j].second]);
				ans = min(ans, d[1][T[j].first][T[j].second]);
			}
		}
		if (ans == INF)cout << -1 << endl;
		else cout << ans << endl;
	}
}


Measured memory_bytes: 5620
import java.util.InputMismatchException;
import java.util.Scanner;

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

			int n = scanner.nextInt();

			long[] a = new long[n+1];
			for (int i = 0; i < a.length; i++) {
				a[i] = scanner.nextInt();
			}

			long[] b = new long[n];
			for (int i = 0; i < b.length; i++) {
				b[i] = scanner.nextInt();
			}

			Main citySavers = new Main();
			System.out.println(citySavers.citySavers(a, b));

			scanner.close();

		} catch (InputMismatchException e) {
			// TODO: handle exception
			System.out.println("整数を入力してください");
		}
	}


	public long citySavers(long[] a, long[] b) {
		long count = 0;

		for (int i = 0; i < b.length; i++) {
			if (a[i] >= b[i]) {					//1つ目の街の敵>倒せる数
				count = count + b[i];
			}else if (a[i+1] >= b[i] - a[i]){	//1つ目の街の敵+2つ目の街の敵>倒せる数
				count = count + b[i];
				a[i+1] = a[i+1] + a[i] - b[i];
			}else {								//1つ目の街の敵+2つ目の街の敵<倒せる数
				count = count + a[i] + a[i+1];
				a[i+1] = 0;
			}
		}

		return count;
	}

}



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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;

lli n;
vll dp;

lli l(lli n){
	if(n == 0) return 2;
	if(n == 1) return 1;
	if(dp[n]) return dp[n];
	return dp[n] = l(n-1)+l(n-2);
}

int main(){
	cin >> n;
	dp = vll(100);
	cout << l(n) << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    h = int(input())
    num = 1
    ans = 1

    while True:  # h以上で最小の2の累乗を探す
        num *= 2
        if h < num:
            break
        elif h == num:
            ans = 2 * ans + 1
            break
        ans = 2 * ans + 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61832
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<string>
using namespace std;
int main() {
  int N;
  string A,B,C;
  cin >> N >> A >> B >> C;
  int sum = 0;
  for (int i=0; i<N; i++) {
    int cnt = 0;
    if (A[i]==B[i]) cnt--;
    else if(A[i]!=B[i]) cnt++;
    if (B[i]==C[i]) cnt--;
    else if(B[i]!=C[i]) cnt++;
    if (A[i]==C[i]) cnt--;
    else if(A[i]!=C[i]) cnt++;
    if (cnt == 3) cnt = 2;
    cnt = max(0,cnt);
    sum += cnt;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
/*
    author: kartik8800
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(ll i = a; i < b; i++)
#define mod 1000000007
#define inf (1LL<<60)
#define all(x) (x).begin(), (x).end()
#define prDouble(x) cout << fixed << setprecision(10) << x 
#define triplet pair<ll,pair<ll,ll>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

ll dp[10001][101][2];
ll solve(string& k, int& D, int pos, int d, bool tight)
{
    if(dp[pos][d][tight] != -1)
        return dp[pos][d][tight];
    int ub = (tight) ? (k[pos] - '0') : 9;
    if(pos == k.length() - 1)
    {
        ll ans = 0;
        for(int x = 0; x <= ub; x++)
            if(x%D == d)
                ans++;
        return ans;
    }
    ll ans = 0;
    for(int x = 0; x <= ub; x++)
        ans = (ans + solve(k, D, pos+1, (D+d-x%D)%D, tight && (x == ub))) % mod;
    return dp[pos][d][tight] = ans;    
}

int main() {
   int D;
   string k;
   cin >> k;
   cin >> D;
   memset(dp, -1, sizeof dp);
   cout << (mod + solve(k, D, 0, 0, 1) - 1) % mod;
   return 0;
}


Measured memory_bytes: 17408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll int solve(ll int val[], ll int wet[], int w, int n)
{
    ll int dp[n+1][w+1];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(j<wet[i-1])
            dp[i][j]=dp[i-1][j];
            else
            dp[i][j]=max(dp[i-1][j],val[i-1]+dp[i-1][j-wet[i-1]]);
        }
    }
    return dp[n][w];
}

int main()
{
  int n,w;
  cin>>n>>w;
  ll int val[n], wet[n];
  for(int i=0;i<n;i++)
  {
     cin>>wet[i]>>val[i];
  }
  cout<<solve(val,wet,w,n)<<"\n";
    return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N(0), K(0);
  cin >> N >> K; 
  
  int x[N];
  for(int i = 0; i < N; i++)
  {
    cin >> x[i];
  }

  int dist(0);
  for(int i = 0; i < N; i++)
  {
	if( K - x[i] > x[i] )
    {
      // type A robot will collect the ball
      dist += 2 * x[i]; // type 
    }
    else
    {
      // type B robot will collect the ball
      dist += 2 * (K - x[i]); 
    }
  }
  cout << dist << endl;
}
 

Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main() { 
  int d;
  cin>>d;
  
  if(d==25) cout<<"Christmas"<<endl;
  else if(d==24) cout<<"Christmas Eve"<<endl;
  else if(d==23) cout<<"Christmas Eve Eve"<<endl;
  else  cout<<"Christmas Eve Eve Eve"<<endl;

  return 0;
}

Measured memory_bytes: 3648
def dfs(i):
    if all(visited):
        global ans
        ans += 1
        return
    for j in range(N):
        if g[i][j] and not visited[j]:
            visited[j] = True
            dfs(j)
            visited[j] = False

N, M = map(int, input().split())
g = [[False] * N for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    g[a-1][b-1] = True
    g[b-1][a-1] = True

ans = 0
visited = [False] * N
visited[0] = True
dfs(0)
print(ans)

Measured memory_bytes: 3064
N=int(input())
a,b,c,d,=0,0,0,0
for i in range(N):
    s=input()
    if s=="AC":
        a+=1
    elif s=="WA":
        b+=1
    elif s=="TLE":
        c+=1
    else:
        d+=1
print("AC x",a)
print("WA x",b)
print("TLE x",c)
print("RE x",d)

Measured memory_bytes: 9240
#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
using namespace std;
int i,j,k,n,m;
string s;

int main() {
  cin>>n;
  vector<int> h(n);
  for(i=0;i<n;++i) cin>>h[i];
  bool nonzero=false;
  int cnt=0;
  while(count(h.begin(), h.end(), 0) < n){
    for (j =0;j< n;++j){
      if(h[j] > 0){
        nonzero=true;
        --h[j];
      } else {
        if (nonzero) {
          ++cnt;
          nonzero = false;
        }
      }
      if (j==n-1 && nonzero) {
        ++cnt;
        nonzero = false;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<double> dp(n+1);
    dp[0]=1;
    for(int i=0;i<n;i++){
    double head;
    cin>>head;

        for(int j=i+1;j>=0;j--){
            if(j==0){
                dp[j]*=(1-head);
            }else{
                dp[j]=dp[j]*(1-head)+dp[j-1]*(head);
            }
        //cout<<dp[j]<<" ";
        }
        //cout<<endl;
    }

    double ans=0;
    for(int i=n/2+1;i<=n;i++){

        ans+=dp[i];
    }
    cout<<setprecision(10)<<ans<<endl;
    //printf("%lf \n",ans);

}


Measured memory_bytes: 256
S = input()

f = int(S[0:2])
b = int(S[2:])

year_list = list(range(100))
month_list = list(range(1,13))

if (f in month_list) & (b in month_list):
    print("AMBIGUOUS")
elif (f in month_list) & (b not in month_list):
    print("MMYY")
elif (f not in month_list) & (b in month_list):
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define INF 1000000000000000

using namespace std;

ll store[3005][3005];

ll get(ll l, ll r, ll arr[])
{
    if(r<l)
        return 0;
    if(l == r)
        return arr[l];
    if(store[l][r]!=INF)
        return store[l][r];
    ll ans = -get(l,r-1,arr) + arr[r];
    ans = max(ans, -get(l+1,r,arr) + arr[l]);
    
    return store[l][r] = ans;
}

int main()
{
   FAST/**/
   
   //ll n;
   //cin>>n;
   
  ll n;
  cin>>n;
  
  for(ll i=0;i<n;i++)
    for(ll j=0;j<n;j++)
        store[i][j] = INF;
  
  ll arr[n];
  for(ll i=0;i<n;i++)
        cin>>arr[i];
   
  ll ans = get(0,n-1,arr);        
  cout<<ans;          
   
   return 0;
}

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

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            int input = Integer.parseInt(br.readLine().replaceAll("/", ""));
            String result = "TBD";

            if (input <= 20190430) {
                result = "Heisei";
            }

            System.out.println(result);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 21332
import numpy as np

calc = lambda op1, op2, op3, xyz: xyz[:, 0]*op1 + xyz[:, 1]*op2 + xyz[:, 2]*op3

N, M = list(map(int, input().split()))
xyz = np.array([list(map(int, input().split())) for i in range(N)])
ans = 0
ops = [[1,1,1], [1,1,-1], [1,-1,1], [1,-1,-1], [-1,1,1], [-1,1,-1], [-1,-1,1], [-1,-1,-1]]
for op1, op2, op3 in ops:
    table = np.sort(calc(op1, op2, op3, xyz))[::-1]
    ans = max(ans, np.sum(table[:M]))

print(ans)

Measured memory_bytes: 12520
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mp make_pair
#define F first
#define S second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const unsigned ll l=1000000007;
const int MAX_=2000;
int T;
 
void print(string res, int i)
{
  printf("Case #%d: %s\n",T-i,res.c_str());
  // cout << res;
}
void print(ll res, int i)
{
  printf("Case #%d: %lld\n",T-i,res);
  // cout << res;
}

void solve(int t)
{
  ll n;
  cin >> n;

  ll cnt=0;
  bool c=0;
  vll a(n);
  ll prev=n+1;
  for(int i=0; i<n; i++)
  {
    cin >> a[i];
    if(a[i] <= prev)
    {
      cnt++;
      prev = a[i];
    }
  }

  cout << cnt << endl;
}
 
int main()
{
  IOS
  int t,testCases;
  testCases=1;
  #ifdef DEBUG
    freopen("input.txt","r",stdin);
    cin >> testCases;
    cout << "Running " << testCases << " testcases" << endl;
    freopen("output.txt","w",stdout);
    freopen("error.txt","w",stderr);
  #endif
 
 
  while(testCases--)
  {
    t=1;
    // cin >> t; //comment this in case of singular test case
    T = t;
    while(t--)
    {
      solve(t);
    }
  }
  return 0;
 
}

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

int partition(int A[],int p,int r){
  int x=A[r];
  int i=p-1;
  for(int j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      swap(A[i],A[j]);
    }
  }
  swap(A[i+1],A[r]);
  return i+1;
}

int main(){
  int n,A[100000],b;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  b=partition(A,0,n-1);
  for(int i=0;i<n;i++){
    if(i==0){
      if(i==b) cout<<"["<<A[i]<<"]";
      else cout<<A[i];
    }
    else{
      if(i==b) cout<<" "<<"["<<A[i]<<"]";
      else cout<<" "<<A[i];
    }
  }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 3372
<?php
fscanf(STDIN, "%d%d", $H, $W);
for($i = 0; $i < $H; $i++){
  $map[$i] = trim(fgets(STDIN))."#";
}
$map[$H] = str_repeat("#", $W);
for($i = 0; $i < $H; $i++){
  $h = 0;
  for($j = 0; $j <= $W; $j++){
    if($map[$i][$j] === "#"){
      for($k = 0; $k < $h; $k++){
        $p[$i][$j - 1 - $k] = $h;
      }
      $h = 0;
    }else{
      $h++;
    }
  }
}
$max = 0;
for($i = 0; $i < $W; $i++){
  $h = 0;
  for($j = 0; $j <= $H; $j++){
    if($map[$j][$i] === "#"){
      for($k = 0; $k < $h; $k++){
        $pp = $p[$j - 1 - $k][$i] + $h;
        if($max < $pp)$max = $pp;
      }
      $h = 0;
    }else{
      $h++;
    }
  }
}
echo $max - 1;

Measured memory_bytes: 154104
#include <iostream>
#include <vector>
#include <string>
#include <atcoder/maxflow>

using namespace std;

int main(){
    int N, M; cin >> N >> M;
    vector<string> S(N);
    for(auto& s : S) cin >> s;
    atcoder::mf_graph<int> flow(N*M+2);
    int cnt = 0;
    for(int i=0;i<N;i++){
        for(int j=i%2;j<M;j+=2){
            if(S[i][j] == '#') continue;
            int dx[] = {-1, 0, 1, 0};
            int dy[] = {0, -1, 0, 1};
            for(int d=0;d<4;d++){
                int nx = i+dx[d];
                int ny = j+dy[d];
                if(nx < 0 || N <= nx || ny < 0 || M <= ny || S[nx][ny] == '#') continue;
                flow.add_edge(i*M+j, nx*M+ny, 1);
                ++cnt;
            }
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            if(S[i][j] == '#') continue;
            if((i+j)%2 == 0) flow.add_edge(N*M, i*M+j, 1);
            else flow.add_edge(i*M+j, N*M+1, 1);
        }
    }
    cout << flow.flow(N*M, N*M+1) << endl;;
    for(int i=0;i<cnt;i++){
        auto e = flow.get_edge(i);
        if(!e.flow) continue;
        int src = e.from ,dst = e.to;
        if(src > dst) swap(src, dst);
        if(src+1 == dst && src%M != M-1){
            S[src/M][src%M] = '>';
            S[dst/M][dst%M] = '<';
        } else {
            S[src/M][src%M] = 'v';
            S[dst/M][dst%M] = '^';
        }
    }
    for(auto& s : S) cout << s << endl;
}


Measured memory_bytes: 5164
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    long K = sc.nextLong();
    long result = K;
    for (int i = 1; i <= N - 1; i++) {
      result *= (K - 1);
    }
    System.out.println(result);
  }
}

Measured memory_bytes: 21200
unittest
{
	assert( [ "4 4", "1 2", "2 3", "3 4", "4 2" ].parse.expand.solve == "Yes\n1\n2\n2" );
	assert( [ "6 9", "3 4", "6 1", "2 4", "5 3", "4 6", "1 5", "6 2", "4 5", "5 6" ].parse.expand.solve == "Yes\n6\n5\n6\n1\n1" );
}



import std.algorithm;
import std.container;
import std.conv;
import std.format;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	auto abs = new long[ 2 ][ nm[ 1 ] ];
	foreach( ref ab; abs )
	{
		input.popFront;
		ab = input.front.split.to!( long[] );
		ab[] -= 1;
	}
	return tuple( nm[ 0 ], abs );
}

auto solve( long n, long[ 2 ][] abs )
{
	auto anss = new long[ n - 1 ];
	
	auto nss = toAdjacencyList!true( n,abs );
	auto ds = new long[ nss.length ];
	ds[] = long.max;
	ds[ 0 ] = 0;
	
	auto queue = make!DList( 0L );
	while( !queue.empty )
	{
		auto f = queue.front;
		queue.removeFront();
		
		foreach( t; nss[ f ] )
		{
			if( ds[ t ] < long.max ) continue;
			
			ds[ t ] = ds[ f ] + 1;
			anss[ t - 1 ] = f + 1;
			queue.insertBack( t );
		}
	}
	if( ds.find( 0 ).empty ) return "No";
	else                     return format( "Yes\n%s", anss.to!( string[] ).join( "\n" ) );
}

// 辺配列から隣接リストを作成
auto toAdjacencyList( bool undirected = false )( long n, long[ 2 ][] es )
{
	auto nss = new long[][ n ];
	foreach( e; es )
	{
		nss[ e[ 0 ] ] ~= e[ 1 ];
		static if( undirected ) nss[ e[ 1 ] ] ~= e[ 0 ];
	}
	return nss;
}


Measured memory_bytes: 23276
#include<bits/stdc++.h>
using namespace std;
int Map[11][11];
const int dx[]={0,1},dy[]={1,0};
signed main(){
	int n,m;scanf("%d%d",&n,&m); 
	for(register int i=1;i<=n;i++)
		for(register int j=1;j<=m;j++){
			char c;
			while((c=getchar())!='.'&&c!='#');
			Map[i][j]=(c=='#');
		}
	queue<pair<int,int> >Q;
	Q.push(make_pair(1,1));Map[1][1]=0;
	while(!Q.empty()){
		int x=Q.front().first,y=Q.front().second,tot=0;Q.pop();
		for(register int i=0;i<2;i++){
			int xx=x+dx[i],yy=y+dy[i];
			if(xx<1||xx>n||yy<1||yy>m||!Map[xx][yy])continue;
			Map[xx][yy]=0;
			tot++;
			Q.push(make_pair(xx,yy));
		}
		if(tot>=2){
			puts("Impossible");
			return 0;
		}
	}
	for(register int i=1;i<=n;i++)
		for(register int j=1;j<=m;j++)
			if(Map[i][j]){
				puts("Impossible");
				return 0;
			}
	puts("Possible");
	return 0;
}

Measured memory_bytes: 3700
#include <iostream>
using namespace std;
 
int main() {
    int a;
  	cin >> a;
  	int map[2][a];
  	int dp[2][a];
  	for(int i = 0; i < 2; ++i){
      for(int j = 0; j < a; ++j){
        cin >> map[i][j];
      }
    }
  	for(int i = 0; i < 2; ++i){
      for(int j = 0; j < a; ++j){
        if(j >= 1 && i >= 1)
        	dp[i][j] = max(dp[i][j-1] + map[i][j], dp[i-1][j] + map[i][j]);
        else if(j >= 1)dp[i][j] = dp[i][j-1] + map[i][j];
        else if(i >= 1)dp[i][j] = dp[i-1][j] + map[i][j];
        else dp[i][j] = map[0][0];
      }
    }
  cout << dp[1][a-1] << endl;
}

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

int Partition(int *A, int p, int r)
{
        int x = A[r];
        int i = p;
        for ( int j = p; j < r; j++ ) {
                if ( A[j] <= x ) {
                        swap(A[i], A[j]);
                        i++;
                }
        }
        swap(A[i], A[r]);
        return ( i );
}
int main()
{
        int n;
        int A[100005];
        int idx;
        cin >> n;
        for ( int i = 0; i < n; i++ ) cin >> A[i];
        
        idx = Partition(A, 0, n - 1);
        
        for ( int i = 0; i < n; i++ ) {
                if ( idx == i ) cout << "[";
                cout << A[i];
                if ( idx == i ) cout << "]";
                if ( i < n - 1 ) cout << " ";
        }
        cout << endl;


        return ( 0 );
}



Measured memory_bytes: 3484
# -*- coding: utf-8 -*-
# abc139/abc139_c
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    H = i2nn()
    m = 0
    max_m = 0
    for i in range(N - 1):
        if H[i] >= H[i+1]:
            m += 1
        else:
            if m > max_m:
                max_m = m
            m = 0
    if m > max_m:
            max_m = m
    print(max_m)
    return

main()


Measured memory_bytes: 15476
#include <bits/stdc++.h>
using namespace std;
 
//DEFINE and TYPEDEF--------------------------------------------------------------
 
#define timeKyaHorhaH 1.0 * clock() / CLOCKS_PER_SEC

#define FORG(i,a,n) for(lld i=a;i<n;i++) //for - general
#define FORZ(i,n) for(lld i=0;i<n;i++) //for - zero
#define FORGI(i,a,n,inc) for(lld i=a;i<n;i+=inc) //for - general incremental
#define FORZI(i,n,inc) for(lld i=0;i<n;i+=inc) //for - zero incremental
#define SPEEDUP ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define MEM(a,val) memset(a,val,sizeof(a));
 
#define SORTall(m) sort(m.begin(),m.end());
 
#define st first
#define nd second
#define pb push_back
 
typedef long long int lld;
typedef unsigned long long int ulld;
 
//DEBUGGER------------------------------------------------------------------------
// #define DEBUG(x) cerr<<(#x)<<" is "<<(x)<<"\n" //to debug values of variables
// #define DEBUGON
#define ZINDA cerr<<"\nIdhar-ich hai apun!!\n"; //to debug if code reached that point

vector<string> vec_splitter(string s) {
	for(char& c: s) c = c == ',' ?  ' ': c;
	stringstream ss; ss << s;
	vector<string> res;
	for(string z; ss >> z; res.push_back(z));
	return res;
}

void debug_out(vector<string> args, int idx) { cerr << endl; }
template <typename Head, typename... Tail>
	void debug_out(vector<string> args, int idx, Head H, Tail... T) {
		if(idx > 0) cerr << ", ";
		stringstream ss; ss << H;
		cerr << args[idx] << " = " << ss.str();
		debug_out(args, idx + 1, T...);
	}

#ifdef DEBUGON
	#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__);
	#define DEBUG(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__);	
#else
	#define debug(...) 320;
	#define DEBUG(...) 320;
#endif

lld power(lld b, lld e)
{
    if(e==0)
        return 1;
    if(e%2==1)
        return b*power(b*b,(e-1)/2);
    else
        return power(b*b,e/2);
}
 
lld power(lld b, lld e, lld m)
{
	if(e==0)
		return 1;
	if(e%2==1)
		return b*power(((b%m)*(b%m))%m,(e-1)/2,m)%m;
	else
		return power(((b%m)*(b%m))%m,e/2,m)%m;
}
 
int nDig(lld n)
{
	if(n<0) 
		n*=-1;
	if(n==0)
		return 1;

    return floor(log10(n) + 1);
}

#define endl '\n'
#define mod 1000000007

//endl : changed to '\n', to flush comment that definition
//--------------------------------------------------------------------------------

void swagWaalaFunction()
{
	lld a,b,c,n=0,k;
	cin>>a>>b>>c>>k;

	if(a>k)
		cout<<k;
	else if(a+b>k)
		cout<<a;
	else
		cout<<a-(k-(a+b));
	return;
}

int main()
{
    SPEEDUP;
 	lld t=1;
 	//cin>>t;

 	while(t--)
 		swagWaalaFunction();
	
	// cerr<<"\n"<<timeKyaHorhaH; 	
 	return 0;
}

Measured memory_bytes: 3680
#include<iostream>
using namespace std;
int main(){
    int n,a[100]={},count=0;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++){
        if(i<n-1){if(a[i]==a[i+1] && a[i]==a[i+2]) a[i]=a[i];
            else if(a[i]==a[i+1] && a[i]!=a[i+2]){
                count++;
                a[i]=a[i+2];
            }
        }
        if(i>0){if(a[i-1]==a[i] && a[i]==a[i+1]){
            count++;
           a[i]++;
        }
        }
    }
    cout<<count<<endl;
    
    return 0;
}

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

#define ll long long

int sum(string s){
    int n = s.size();
    int ans = 0l;
    for(int i=0;i<n;i++) ans += (int)(s[i]-'0');
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n; cin >> n;
    string s;
    string c[4];
    c[0] = "AC";
    c[1] = "WA";
    c[2] = "TLE";
    c[3] = "RE";
    int ans[4] = {0};
    for(int i=0;i<n;i++){
        cin >> s;
        for(int j=0;j<4;j++){
            if(s==c[j]) ans[j]++;
        }
    }
    for(int i=0;i<4;i++) cout << c[i] << " x " << ans[i] << '\n';
    return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define ALL(A)		(A).begin(),(A).end()
#define DUMP(A)    cout<<#A<<"="<<(A)<< endl
#define SIZE(A)    (int)((A).size())
#define P2(A)   ((A)*(A))
using namespace std;
typedef long long ll;

int main(){
    int n;
    for(;;){
        scanf("%d\n",&n);
        if(n==0) break;
        vector<double> xs(n),ys(n);
        for(int i=0;i<n;i++){
            scanf("%lf,%lf\n",&xs[i],&ys[i]);
        }
        if(n==1){
            printf("1\n");
            continue;
        }
        int ma=1;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                double mx=(xs[i]+xs[j])/2,my=(ys[i]+ys[j])/2,vlen=sqrt(P2(xs[i]-xs[j])+P2(ys[i]-ys[j])),llen=sqrt(1-(P2(xs[i]-mx)+P2(ys[i]-my)));
                if(vlen>=2.00005) continue;
                double p1x=mx+(ys[i]-ys[j])*(llen/vlen),p1y=my-(xs[i]-xs[j])*(llen/vlen);
                double p2x=mx-(ys[i]-ys[j])*(llen/vlen),p2y=my+(xs[i]-xs[j])*(llen/vlen);
                int now1=0,now2=0;
                for(int k=0;k<n;k++){
                    if(P2(xs[k]-p1x)+P2(ys[k]-p1y)<=1.00005) now1++;
                    if(P2(xs[k]-p2x)+P2(ys[k]-p2y)<=1.00005) now2++;
                }
                ma=max(now1,ma);
                ma=max(now2,ma);
            }
        }
        printf("%d\n",ma);
    }
}

Measured memory_bytes: 0
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author RiaD
 */

#include <iostream>
#include <fstream>

#include <iostream>

using namespace std;

class D {
public:
	void solve(std::istream& in, std::ostream& out) {
		string s;
		in >> s;
		for (int i = 0; i + 1 < s.size(); ++i) {
			if (s[i] == s[i + 1]) {
				out << i + 1 << ' ' << i + 2;
				return;
			}
		}
		for (int i = 0; i + 2 < s.size(); ++i) {
			if (s[i] == s[i + 2]) {
				out << i + 1 << ' ' << i + 3;
				return;
			}
		}
		out << "-1 -1";
	}
};


int main() {
	std::ios_base::sync_with_stdio(false);
	D solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	in.tie(0);
	out << std::fixed;
	out.precision(20);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100005


enum Type{
	COUNT,
	WEIGHT,
};

struct Info{
	int index;
	ll weight;
};

int N;
ll C,BIT[NUM][2];
Info info[NUM];

void add(ll loc,ll value,Type type, ll maximum){

	BIT[loc][type] += value;

	loc += loc & -loc;

	while(loc <= maximum){

		BIT[loc][type] += value;
		loc += loc & -loc;
	}
}

ll getSum(ll loc,Type type){

	ll sum = BIT[loc][type];

	loc -= loc & -loc;

	while(loc > 0){
		sum += BIT[loc][type];
		loc -= loc & -loc;
	}
	return sum;
}

ll calc(ll left,ll right,Type type){
	return getSum(right,type)-getSum(left-1,type);
}

ll query(int node_id,int node_left,int node_right){

	if(node_left >= N || node_left > node_right)return 0;
	if(node_left == node_right)return 0;

	ll ret = 0;
	ret += query(2*node_id+1,node_left,(node_left+node_right)/2);
	ret += query(2*node_id+2,(node_left+node_right)/2+1,min(node_right,N-1));

	vector<Info> L,R;

	for(int i = node_left; i <= (node_left+node_right)/2; i++){

		L.push_back(info[i]);
	}

	for(int i = (node_left+node_right)/2+1; i <= node_right; i++){

		R.push_back(info[i]);
	}

	for(int i = 0; i < L.size(); i++){

		add(L[i].weight,1,COUNT,NUM-1);
		add(L[i].weight,L[i].weight,WEIGHT,NUM-1);
	}

	int L_index = 0,R_index = 0;

	for(int i = 0; i < L.size()+R.size(); i++){

		if((R_index == R.size()) || (L_index < L.size() && L[L_index].index < R[R_index].index)){

			add(L[L_index].weight,-1,COUNT,NUM-1);
			add(L[L_index].weight,-L[L_index].weight,WEIGHT,NUM-1);
			info[node_left+i].index = L[L_index].index;
			info[node_left+i].weight = L[L_index].weight;
			L_index++;

		}else{

			if(L_index < L.size()){

				ret += calc(R[R_index].weight,NUM-1,COUNT)*C*R[R_index].weight+calc(R[R_index].weight,NUM-1,WEIGHT);
				ret += calc(1,R[R_index].weight-1,WEIGHT)*C+calc(1,R[R_index].weight-1,COUNT)*R[R_index].weight;
			}

			info[node_left+i].index = R[R_index].index;
			info[node_left+i].weight = R[R_index].weight;
			R_index++;
		}
	}

	return ret;
}

int main(){

	scanf("%d %lld",&N,&C);

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

		scanf("%d %lld",&info[i].index,&info[i].weight);
		info[i].index--;
	}

	for(int i = 0; i <= NUM-1; i++){
		BIT[i][COUNT] = 0;
		BIT[i][WEIGHT] = 0;
	}

	printf("%lld\n",query(0,0,N-1));

	return 0;
}



Measured memory_bytes: 8352
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
#include <algorithm>
#include <vector>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main(){
  int w,h,n;
  cin>>w>>h>>n;
  vector<int>x(n);
  vector<int>y(n);
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i]>>a[i];
  }
  int l=0,r=w,u=h,d=0;
  for(int i=0;i<n;i++){
    if(a[i]==1){l=max(l,x[i]);}
    if(a[i]==2){r=min(r,x[i]);}
    if(a[i]==3){d=max(d,y[i]);}
    if(a[i]==4){u=min(u,y[i]);}
  }
  if(r-l<0||u-d<0){cout<<0<<endl;}
  else{cout<<(r-l)*(u-d)<<endl;}
  return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<cstring>
using namespace std;
typedef long long LL;
#define F(i) for(int i=0;i<n;i++)
int d[555][555]={0},c[555][555]={0};
int qu(int l,int r){
	if(l>r)return 0;
	if(d[l][r]!=-1)return d[l][r];
	return d[l][r]=c[l][r]+qu(l+1,r)+qu(l,r-1)-qu(l+1,r-1);
}
int main(){
	memset(d,-1,sizeof(d));
	int n,m,q;
	cin>>n>>m>>q;
	while(m--){
		int l,r;
		cin>>l>>r;
		c[l][r]++;
	}
	while(q--){
		int l,r;
		cin>>l>>r;
		cout<<qu(l,r)<<endl;
	}
	return 0;
}

Measured memory_bytes: 3200
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    println!("{}", n * (n - 1) / 2);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8572
#include<bits/stdc++.h>
using namespace std;
#define MAX 1000000007
#define ll long long
#define pb push_back
#define mp make_pair
int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(0); cout.tie(0);
   ll n;
   cin >> n;
   ll ans = (n / 500) * (1000) + ((n - (n / 500) * 500) / 5) * 5;
   cout << ans;
   return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.TreeMap;
import java.math.BigDecimal;
import java.math.BigInteger;
    
public class Main{
 
static final InputStream in=System.in;
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE;
static final long LINF=Long.MAX_VALUE;
 
public static void main(String[] args) throws IOException{
InputReader ir=new InputReader(in);
int n=ir.nextInt();
out.println(n*n*n);
out.flush();
}

static class InputReader {
 private InputStream in;
 private byte[] buffer=new byte[1024];
 private int curbuf;
 private int lenbuf;
 
 public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}
  
 public boolean hasNextByte() {
  if(curbuf>=lenbuf){
   curbuf= 0;
   try{
    lenbuf=in.read(buffer);
   }catch(IOException e) {
    throw new InputMismatchException();
   }
   if(lenbuf<=0) return false;
  }
  return true;
 }
 
 private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}

 private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}
 
 private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}

 public boolean hasNext(){skip(); return hasNextByte();}
 
 public String next(){
  if(!hasNext()) throw new NoSuchElementException();
  StringBuilder sb=new StringBuilder();
  int b=readByte();
  while(!isSpaceChar(b)){
   sb.appendCodePoint(b);
   b=readByte();
  }
  return sb.toString();
 }
 
 public int nextInt() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  int res=0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }
 
 public long nextLong() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  long res = 0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }
 
 public double nextDouble(){return Double.parseDouble(next());}
 
 public BigInteger nextBigInteger(){return new BigInteger(next());}
 
 public int[] nextIntArray(int n){
  int[] a=new int[n];
  for(int i=0;i<n;i++) a[i]=nextInt();
  return a;
 }
 
 public char[][] nextCharMap(int n,int m){
  char[][] map=new char[n][m];
  for(int i=0;i<n;i++) map[i]=next().toCharArray();
  return map;
 }
}
}

Measured memory_bytes: 24496
import math

num = int(input())
num_sqrt = int(math.sqrt(num))

ans = 11
for A in range(1, num_sqrt+1):
    if num % A == 0:
        B = int(num / A)
        A, B = str(A), str(B)
        now_ans = max(len(A), len(B))
        ans = min(ans, now_ans)
print(ans)


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

int main(void){
  int y,m,d;
  int data;
  while(~scanf("%d %d %d",&y,&m,&d)){
    data=y*10000+m*100+d;
    if(data<=18680907){
      printf("pre-meiji\n");
    }
    else if(18680908<=data&&data<=19120729){
      printf("meiji %d %d %d\n",y-1867,m,d);
    }
    else if(19120730<=data&&data<=19261224){
      printf("taisho %d %d %d\n",y-1911,m,d);
    }
    else if(19261225<=data&&data<=19890107){
      printf("showa %d %d %d\n",y-1925,m,d);
    }
    else if(19890108<=data){
      printf("heisei %d %d %d\n",y-1988,m,d);
    }
  }
  return 0;
}

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

int main() {
  string str;
  cin >> str;
  vector<string> A(str.size());
  rep(i, str.size()){
    if (str.at(i) == '0'){
      A.push_back("0");
    }
    else if (str.at(i) == '1'){
      A.push_back("1");
    }
    else {
      A.pop_back();
      if (A.size() == 0) continue;
    }
  }
  
  rep(i, A.size()){
    cout << A.at(i);
  }
  
  cout << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

const int INF = 1 << 29;

int solve(const vec<int, 2> G, int S, int T) {
  int N = G.size();
  vec<int, 2> dist = make_v(N, 3, INF);
  dist[S][0] = 0;
  queue<int> Q;
  Q.emplace(S * 3);
  while (!Q.empty()) {
    int id = Q.front();
    Q.pop();
    int v = id / 3, m = id % 3;
    int cost = dist[v][m];
    for (int u : G[v]) {
      int ncost = cost + 1;
      int nm = (m + 1) % 3;
      if (dist[u][nm] <= ncost) continue;
      dist[u][nm] = ncost;
      Q.emplace(u * 3 + nm);
    }
  }
  if (dist[T][0] < INF) {
    return dist[T][0] / 3;
  }
  return -1;
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, M;
  while (cin >> N >> M) {
    vec<int, 2> G(N);
    for (int i = 0; i < M; i++) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      G[a].push_back(b);
    }
    int S, T;
    cin >> S >> T;
    --S;
    --T;
    cout << solve(G, S, T) << endl;
  }
  return 0;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1000000007;
const long double PI=3.14159265358979;
const ll MAX=200020;

int main() {
  ll N;
  cin>>N;
  ll a[N];
  ll b[N];
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  for(int i=0;i<N;i++){
    cin>>b[i];
  }
  ll cnt=0;
  for(int i=0;i<N;i++){
    if(a[i]>b[i]){
      cnt+=a[i]-b[i];
    }
    else{
      cnt-=(b[i]-a[i])/2;
    }
  }
  if(cnt>0){
    cout<<"No";
  }
  else{
    cout<<"Yes";
  }
}


Measured memory_bytes: 384
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<cstring>
#define N 200010
using namespace std;
typedef long long ll;
int k1[N],pos,to,n,m;
ll k2[N],all=0;
int main(){
	cin>>n>>m;
	cin>>pos;pos--;
	for (int i=1;i<n;i++){
		cin>>to;to--;
		pos%=m;
		if (pos>to) to+=m;
		all+=to-pos;
		k1[pos+1]++;
		k1[to+1]--;
		k2[pos+1]+=pos;
		k2[to+1]-=pos;
		pos=to;
	}
	for (int i=1;i<2*m;i++){
		k1[i]+=k1[i-1];
		k2[i]+=k2[i-1];
	}
	ll res=all;
	for (int i=0;i<m;i++){
		int a=k1[i];
		ll b=k2[i],nxt=all;
		nxt-=(ll)a*(ll)i-b-a;
		a=k1[i+m],b=k2[i+m];
		nxt-=(ll)a*(ll)(i+m)-b-a;
		res=min(res,nxt);
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 2560
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn vec<T, F: FnMut(usize) -> T>(n: usize, mut f: F) -> Vec<T> {
    (0..n).map(|i| f(i)).collect()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let t: usize = scan(tokens);
    let ab: Vec<(usize, usize)> = vec(n, |_| (scan(tokens), scan(tokens)));
    let mut dp0 = vec![vec![0; n + 1]; t];
    let mut dp1 = vec![vec![0; n + 1]; t];
    for i in 0..n {
        let (ai, bi) = ab[i];
        for s in 0..t {
            let mut max = dp0[s][i];
            if s >= ai {
                max = std::cmp::max(max, dp0[s - ai][i] + bi);
            }
            dp0[s][i + 1] = max;
            let mut max = dp1[s][i];
            max = std::cmp::max(max, dp0[s][i] + bi);
            if s >= ai {
                max = std::cmp::max(max, dp1[s - ai][i] + bi);
            }
            dp1[s][i + 1] = max;
        }
    }
    println!("{}", dp1[t - 1][n]);
}


Measured memory_bytes: 176380
S = int(input())

list = []
for _ in range(S):
  num, currency = input().split()
  d = {num: currency}
  list.append(d)

sum = 0
for l in list:
  for k, v in l.items():
    if v == 'JPY':
      sum += int(k)
    else:
      k = float(k)
      sum += k * 380000
print(sum)

Measured memory_bytes: 3060
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<tuple>
#include<utility>
#define rep0(i,n) for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define rep1(i,n) for(ll i=1; i<=n; i++)
#define rrep1(i,n) for(ll i=n; 1<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
using ll = long long;
using namespace std;
/*ビットxにi番目のフラグが立っているかどうか
if(x & (1 << i))
↑ a << b == a*pow(b,2)
/*{0, 1, ..., n-1} の部分集合の全探索
for (int bit = 0; bit < (1 << n); ++bit)
*/

int main(){
  ll n,k,q;  cin >> n >> k >> q;
  vll a(q+1);
  vi point(n+1);
  rep1(i,q){
    cin >> a[i];
    point[a[i]]++;
  }
  rep1(i,n){
    if( (q-k) < point[i] ){
      cout << "Yes";
    }else{
      cout << "No";
    }
    cout << endl;
  }
}


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

int main(){
  int N,K,d,box;
  cin >>N>>K;
  vector<int> A(N,0);
    
  for(int i=0;i<K;i++){
    cin >> d;
    for(int j=0;j<d;j++){
      cin >> box;
      box--;
      A.at(box)++;
    }
  }
  
  //0個の人を数える
  int count=0;
  for(int i=0;i<N;i++){
    if(A.at(i)==0)
      count ++;
  }
  cout<<count<<endl;
  
}

Measured memory_bytes: 3636
package main

import (
	"fmt"
)

func main() {

	for {
		var s string
		fmt.Scan(&s)
		if s == "-" {
			break
		}
		var m int
		fmt.Scan(&m)

		var h int
		for i := 0; i < m; i++ {
			fmt.Scan(&h)
			s = shuffle(s, h)
		}
		fmt.Println(s)
	}
}

func shuffle(s string, m int) string {
	return s[m:] + s[:m]
}



Measured memory_bytes: 1108
<?php

fscanf(STDIN, "%d %d", $n, $m);
$A = [];
for ($i = 0; $i < $m; ++$i) {
    fscanf(STDIN, "%d %d", $x, $y);
    $A[] = [$x, $y];
}

usort($A, function($a, $b) {
    return $a[1] > $b[1];
});

$x = PHP_INT_MIN;
$cnt = 0;
foreach ($A as $p) {
    $a = $p[0];
    $b = $p[1];

    if ($a < $x) {

    } else {
        ++$cnt;
        $x = $b;
    }
}

echo $cnt, PHP_EOL;


Measured memory_bytes: 59664
#include <iostream> 
#include <vector>
#include <string>
#include <math.h>
#include <stack>
using namespace std;
#define ll long long int
int main() {
  ll x,y,z,k;
  cin >> x >> y >> z >> k;
  vector <ll> a(x),b(y),c(z),ab,abc;
  for ( int i = 0; i < x; ++i ) {
    cin >> a[i];
  }
  for ( int i = 0; i < y; ++i ) {
    cin >> b[i];
  }
  for ( int i = 0; i < z; ++i ) {
    cin >> c[i];
  }

  for ( int i = 0; i < x; ++i ) {
    for ( int j = 0; j < y; ++j ) {
      ab.push_back( a[i] + b[j] );
    }
  }
  sort( ab.begin(), ab.end() );
  reverse( ab.begin(), ab.end() );
  for ( int i = 0; i < min( k,(ll)ab.size() ); ++i ) {
    for ( int j = 0; j < z; ++j ) {
      abc.push_back( ab[i] + c[j] );     
    }
  }
  sort( abc.begin(), abc.end() );
  reverse( abc.begin(), abc.end() );

  for ( int i = 0; i < k; ++i ) {
    cout << abc[i] << endl;  
  }
  return 0;
}


Measured memory_bytes: 43368