akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define all(a) (a).begin(),(a).end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define ub(s,x) upper_bound(all(s),x)-s.begin()
#define uniq(a) a.erase(unique(all(a)),a.end())
#define debug(x) cout<<#x<<": "<<x<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
typedef long long ll;
const int INF = 1e9;


struct P{
    int l,r,id;
    bool q;
};

bool operator<(const P a, const P b) {
    if(a.r != b.r) return a.r < b.r;
    if(a.q != b.q) {
        return b.q;
    }
    return a.l < b.l;
}

void TLE(bool x){
    while(!x);
}

template <typename T>
class SegmentTree{
  public:
    int n;
    T element;
    vector<T> dat;
    function<T(T,T)> operate;

    SegmentTree(){}
    SegmentTree(int n_,T element_,function<T(T,T)> operate_){
        element = element_;
        operate = operate_;
        n = 1;
        while(n < n_) n *= 2;
        dat = vector<T>(n*2,element);
    }

    void update(int k,T a){
        k += n-1;
        dat[k] += a;
        while(k > 0){
            k = (k-1)/2;
            dat[k] = operate(dat[k*2+1],dat[k*2+2]);
        }
    }

    T query(int a,int b,int k,int l,int r){
        if(r<=a || b<=l) return element;
        if(a<=l && r<=b) return dat[k];
        T vl = query(a,b,k*2+1,l,(l+r)/2);
        T vr = query(a,b,k*2+2,(l+r)/2,r);
        return operate(vl,vr);
    }

    T query(int a,int b) { return query(a,b,0,0,n);}
};

int add(int a,int b){
    return a+b;
}


int main(void){
    int n,m,q;
    cin>>n>>m>>q;
    vector<P> v;
    rep(i,m){
        int l,r;
        cin>>l>>r;
        v.push_back({l,r+1,0,false});
    }
    rep(i,q){
        int l,r;
        cin>>l>>r;
        v.push_back({l,r+1,i,true});
    }
    vector<int> res(q);
    // TLE(false);
    sort(all(v));
    SegmentTree<int> seg(n+1, 0, add);

    rep(i,m+q){
        if(v[i].q){
            res[v[i].id] = seg.query(v[i].l, v[i].r);
        }else{
            seg.update(v[i].l, +1);
        }
    }
    rep(i,q){
        cout<<res[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 10604
use std::io::{Read, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    let mut iter = input.split_whitespace();

    let n: i32 = iter.next().unwrap().parse().unwrap();

    let mut cards = [[false; 14]; 4];
    let s = ["S", "H", "C", "D"];

    for _ in 0..n {
        let suit = iter.next().unwrap();
        let num: i32 = iter.next().unwrap().parse().unwrap();
        match suit {
            "S" => cards[0][num as usize]=true,
            "H" => cards[1][num as usize]=true,
            "C" => cards[2][num as usize]=true,
            "D" => cards[3][num as usize]=true,
            _ => () ,
        }
    }

    for i in 0..4 {
        for j in 1..13+1 {
            if cards[i][j] == false {
                out.write_fmt(format_args!("{} {}\n", s[i], j)).unwrap();
            }
        }
    }

}



Measured memory_bytes: 5032
#include <bits/stdc++.h>
int n, r;
double xa, ya, ra, xb, yb, rb, d;

int main() {
	scanf("%d",&n);
	while (n--) {
		scanf("%lf %lf %lf %lf %lf %lf", &xa, &ya, &ra, &xb, &yb, &rb);
		d = sqrt((xa-xb)*(xa-xb) + (ya-yb)*(ya-yb));
		if (d+ra<rb) r = -2;
		else if (d+rb<ra) r = 2;
		else if (d>ra+rb) r = 0;
		else r = 1;
		printf("%d\n",r);
	}
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
const int N=2e6+7,p=1e9+7;
int X1,X2,X3,X4,X5,X6,Y1,Y2,Y3,Y4,Y5,Y6,ans,fac[N+5],inv[N+5],f[4][3],g[4][3];
int C(int a,int b){return 1ll*fac[a+b]*inv[a]%p*inv[b]%p;}
void add(int&x,int y){x=(x+y)%p;}
int qpow(int a,int b)
{
	int ret=1;
	while(b)
	{
		if(b&1)ret=1ll*ret*a%p;
		a=1ll*a*a%p,b>>=1;
	}
	return ret;
}
void prepare()
{
	fac[0]=1;for(int i=1;i<N;i++)fac[i]=1ll*fac[i-1]*i%p;
	inv[N-1]=qpow(fac[N-1],p-2);
	for(int i=N-1;i;i--)inv[i-1]=1ll*inv[i]*i%p;
}
int calc(int x1,int y1,int s1,int x2,int y2,int s2)
{
	int ret=0;
	for(int x=X3;x<=X4;x++)
	{
		add(ret,p-1ll*C(x-x1,Y3-1-y1)*(x+Y3)%p*C(x2-x,y2-Y3)%p);
		add(ret,1ll*C(x2-x,y2-Y4-1)*(x+Y4+1)%p*C(x-x1,Y4-y1)%p);
	}
	for(int y=Y3;y<=Y4;y++)
	{
		add(ret,p-1ll*C(y-y1,X3-1-x1)*(y+X3)%p*C(y2-y,x2-X3)%p);
		add(ret,1ll*C(y2-y,x2-X4-1)*(y+X4+1)%p*C(y-y1,X4-x1)%p);
	}
	ret=(1ll*ret*s1*s2+p)%p;
	return ret;
}
int main()
{
	prepare();
	scanf("%d%d%d%d%d%d%d%d%d%d%d%d",&X1,&X2,&X3,&X4,&X5,&X6,&Y1,&Y2,&Y3,&Y4,&Y5,&Y6);
	f[0][0]=1,f[0][1]=X1-1,f[0][2]=Y1-1;
	f[1][0]=-1,f[1][1]=X1-1,f[1][2]=Y2;
	f[2][0]=-1,f[2][1]=X2,f[2][2]=Y1-1;
	f[3][0]=1,f[3][1]=X2,f[3][2]=Y2;
	g[0][0]=1,g[0][1]=X6+1,g[0][2]=Y6+1;
	g[1][0]=-1,g[1][1]=X6+1,g[1][2]=Y5;
	g[2][0]=-1,g[2][1]=X5,g[2][2]=Y6+1;
	g[3][0]=1,g[3][1]=X5,g[3][2]=Y5;
	for(int i=0;i<4;i++)
	for(int j=0;j<4;j++)
	add(ans,calc(f[i][1],f[i][2],f[i][0],g[j][1],g[j][2],g[j][0]));
	printf("%d",ans);
}

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

using namespace std;

int main(void) {
  int n, m, d;
  cin >> n >> m >> d;

  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      bool ok = false;
      for (int k = 0; k < d; k++) {
        if (i + k >= n || s[i + k][j] == '#') break;
        ok |= k == d - 1;
      }
      ans += ok;
      ok = false;
      for (int k = 0; k < d; k++) {
        if (j + k >= m || s[i][j + k] == '#') break;
        ok |= k == d - 1;
      }
      ans += ok;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3200
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

int W, H; 
long long int  solve(vector<vector<int>>&yls, vector<vector<int>>&xls) {
	vector<vector<long long int>>anss(H+1,vector<long long int>(W+1));
	anss[0][0]=1;
	for (int y = 0; y <= H; ++y) {
		for (int x = 0; x <= W; ++x) {
			if (y != H) {
				if(yls[y][x])anss[y+1][x]+=anss[y][x];
			}
			if (x != W) {
				if(xls[y][x])anss[y][x+1]+=anss[y][x];
			}
		}
	}
	return anss[H][W];
}

int main() {
	int T;cin>>T;
	while (T--) {
		
		cin >> W >> H;
		int Q; cin >> Q;
		vector<vector<int>>yls(H, vector<int>(W + 1, true));
		vector<vector<int>>xls(H + 1, vector<int>(W, true));
		while (Q--) {
			int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
			
			if (x1 == x2) {
				if(y1>y2)swap(y1,y2);
				for (int ay = y1; ay < y2; ++ay) {
					yls[ay][x1]=false;
				}
			}else{
				if(x1>x2)swap(x1,x2);
				for (int ax = x1; ax < x2; ++ax) {
					xls[y1][ax]=false;
				}
			}
		}
		auto ans = solve(yls, xls);
		if (ans)cout << ans << endl;
		else cout << "Miserable Hokusai!" << endl;
	}
	return 0;
}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
int main() {
	int n;
	cin >> n;
	vector<int> l(n);
	for(int i=0;i<n;i++) {
		cin >> l[i];
	}
	//sort(l.begin(),l.end());
	int trips = 0;
	for(int i=0;i<n;i++) {
		for(int j=i+1;j<n;j++) {
			for(int k=j+1;k<n;k++) {
				int s1 = l[i],s2 = l[j],s3 = l[k];
				if(s1 == s2 || s2==s3 || s3==s1) continue;
				if((s1 + s2 > s3) && (s2 + s3>s1) && (s1 + s3> s2)) {
					debug()<<imie(i+1) imie(j+1) imie(k+1);
					trips++;
				}
			}
		}
	}
	cout<<trips;
}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, A,B;
  cin >> N >> A >> B;
  cout << min(A*N, B);
  return 0;
}


Measured memory_bytes: 3564
stdin.ReadLine()
|> fun x -> x.Split(' ')
|> Array.map int
|> fun x -> (x.[0], x.[1], x.[2], x.[3], x.[4])
|> fun (a, b, c, x, y) -> (
  [1..(max x y)]
  |> List.fold (
    fun ret i ->
      a * (max (x - i) 0) +
      b * (max (y - i) 0) +
      c * i * 2
      |> min ret
  ) (x * a + y * b)
)
|> printfn "%d"

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

int main() {
  
  int n,m,p;
  string s;
  cin >> n >> m;
  
  vector<int> a(n+1,0),w(n+1,0);
  
  int Asum = 0,Wsum = 0;
  
  for ( int i = 0; i < m; i++){
    cin >> p >> s;
    if ( a[p] == 0 && s == "AC" ){
      a[p] = 1;
      Asum++;
    }else if ( a[p] == 0 && s == "WA" ){
      w[p]++;
    }
  }
  
  for ( int i = 1; i <= n; i++){
    if ( a[i] == 1 ){
      Wsum += w[i];
    }
  }
  
  cout << Asum << ' ' << Wsum << endl;  
  
}

Measured memory_bytes: 4040
XS,YS,XT,YT=map(int,input().split())
N=int(input())
V=[[XS,YS,0],[XT,YT,0]]
for i in range(N):
  V.append(list(map(int,input().split())))
INF=10**12
G=[[INF]*len(V) for i in range(len(V))]
def d(a,b):
  return ((a[0]-b[0])**2+(a[1]-b[1])**2)**0.5
for i in range(len(V)):
  G[i][i]=0
  for j in range(len(V)):
    G[i][j]=max(0,d(V[i][:2],V[j][:2])-V[i][2]-V[j][2])
D=[0]*len(V)
U=[0]*len(V)
def ijk(s):
  global D,U,G,V,INF
  for i in range(len(V)):
    D[i]=INF
    U[i]=False
  D[s]=0
  v=0
  while True:
    v=-1
    for i in range(len(V)):
      if not(U[i]) and (v==-1 or D[i]<D[v]):
        v=i
    if v==-1:
      break
    U[v]=True
    for i in range(len(V)):
      D[i]=min(D[i],D[v]+G[v][i])

ijk(0)
print(D[1])

Measured memory_bytes: 101548
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 
 int main(){
  ll n , p ; cin>>n >> p;
  string s ; cin>> s ;
  ll ans=0 ;
  
  if(p==2 || p==5 ){
    rep(i,n){
      int x= s[i]-'0' ;
      if(x%p==0){
        ans += i+1 ;
       }
    } 
  }
  else{
   vector<ll> sum(n+1) ; 
   vector<ll> keta(n) ;
   rep(i,n){
     if(i==0) keta[i]=1 ;
     else{
       keta[i]= (keta[i-1]*10) %p ;
     }
   }
  sum[0]=0 ;
  rep(i,n){
    int x = s[n-1-i]-'0' ;
    sum[i+1]= (sum[i]+x*keta[i]) % p ;
  }
  map<ll,ll> mp ;
  rep(i,n+1){
    mp[sum[i]]++ ;
  }
  for(auto u : mp){
    ll y= u.se ;
    ans += y*(y-1)/2 ;
  }

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

Measured memory_bytes: 6940
#include <bits/stdc++.h>
using namespace std;
int main() {
    vector<int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;cin>>k;
    cout<<a[k-1]<<endl;
}

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

// cin >> a >> b;
// coud << "" << << endl;

void Main() {
    long long a, b, c;
    cin >> a >> b >> c;

    // if (sqrt(c) - (sqrt(a) + sqrt(b)) >= 0) {
    //     cout << "Yes" << endl;
    // } else {
    //     cout << "No" << endl;
    // }
    if (c > (a + b) && 4*a*b < (c - (a+b))*(c - (a+b))) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}



int main() {
    Main();
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(false) , cin.tie(0) ;
#define all(v) v.begin(),v.end()
#define w(x) cout << (#x) << " is " << x << "\n" ;

int main()
{
    fast ;
    int n,c=0,i;
    string s ;
    cin >> n >> s ;
    for(i= 0 ; i < n-1 ; i++)
    {
        if(s[i]!=s[i+1])
            c++;
    }
    cout << c+1 << "\n";
    return 0;
}


Measured memory_bytes: 3700
import sys
from bisect import bisect_right as br
from bisect import bisect_left as bl
input = sys.stdin.readline
N = int(input())
mod = 10 ** 9 + 7
a = []
for _ in range(N): a.append(int(input()))
t = 0
table = [[] for _ in range(max(a) + 1)]
for i in range(N):
  if a[i] != t:
    t = a[i]
    table[a[i]].append(i)
dp = [0] * N
dp[0] = 1
#print(table)
#print(a)
for i in range(N):
  r = br(table[a[i]], i)
  l = bl(table[a[i]], i)
  if r < len(table[a[i]]) and (table[a[i]][l] == i):
    dp[table[a[i]][r]] += dp[i]
    dp[table[a[i]][r]] %= mod
    """
    for k in range(j, len(table[a[i]])):
      print(i, table[a[i]][k])
      dp[table[a[i]][k]] += dp[i]
      dp[table[a[i]][k]] %= mod
    """
  if i + 1 < N:
    dp[i + 1] += dp[i]
    dp[i + 1] %= mod
print(dp[-1])

Measured memory_bytes: 73896
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
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; }
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define MM <<" "<<
#define Endl endl

signed main(void){
    string S;
    cin >> S;
    int a[30]={};
    REP(i,S.size()){
        a[S[i]-'A']++;
    }
    REP(i,26){
        if(a[i]!=0&&a[i]!=2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int ans = 700;
  rep(i, 3){
    char s;
    cin >> s;
    if(s == 'o') ans += 100;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
#define fori(n) for ( int i = 0; i < (n);i++)
#define forj(n) for ( int j = 0; j < (n);j++)
#define fork(n) for ( int k = 0; k < (n);k++)
#define forghj(n) for ( int ghj = 0; ghj < (n);ghj++)
#define fori1(n) for ( int i = (n)-1; i >= 0;i--)
#define all(vector) (vector).begin(),(vector).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
/*
                            |~~~~~~~|
                            |       |
                            |       |
                            |       |
                            |       |
                            |       |
 |~.\\\_\~~~~~~~~~~~~~~xx~~~         ~~~~~~~~~~~~~~~~~~~~~/_//;~|
 |  \  o \_         ,XXXXX),                         _..-~ o /  |
 |    ~~\  ~-.     XXXXX`)))),                 _.--~~   .-~~~   |
  ~~~~~~~`\   ~\~~~XXX' _/ ';))     |~~~~~~..-~     _.-~ ~~~~~~~
           `\   ~~--`_\~\, ;;;\)__.---.~~~      _.-~
             ~-.       `:;;/;; \          _..-~~
                ~-._      `''        /-~-~
                    `\              /  /
                      |         ,   | |
                       |  '        /  |
                        \/;          |
                         ;;          |
                         `;   .       |
                         |~~~-----.....|
                        | \             \
                       | /\~~--...__    |
                       (|  `\       __-\|
                       ||    \_   /~    |
                       |)     \~-'      |
                        |      | \      '
                        |      |  \    :
                         \     |  |    |
                          |    )  (    )
                           \  /;  /\  |
                           |    |/   |
                           |    |   |
                            \  .'  ||
                            |  |  | |
                            (  | |  |
                            |   \ \ |
                            || o `.)|
                            |`\\\\) |
                            |       |
                            |       |
                            |       |
*/


int main() {
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    if (a > b) {
        cout << a-1;
    } else {
        cout << a;
    }
    cout << "\n";
    return 0;
}














Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <unordered_map>

typedef long long ll;

using namespace std;

int main(void) {
  int n; cin >> n;
  vector<int> a(n);
  unordered_map<int,int> count;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (count.find(a[i]) == count.end()) {
      count[a[i]] = 1;
    } else {
      count[a[i]]++;
    }
  }

  int ans = -1;
  for (int X = 0; X <= 100000; X++) {
    int cX = count[X-1] + count[X] + count[X+1];
    ans = max(ans, cX);
  }
  cout << ans << endl;
}


Measured memory_bytes: 4772
// AOJ 2189: Addition Game
// 2017.10.7 bal4u@uu

#include <stdio.h>
#include <string.h>

char s[1002];

int main()
{
	int t, k, w, a;
	char *msg[2] = { "Audrey", "Fabre" };

	scanf("%d", &t);
	while (t-- > 0) {
		scanf("%s", s); w = strlen(s);
		for (k = 0; w > 1; k++) {
			a = (s[w-1]-'0') + (s[w-2]-'0');
			if (a >= 10) s[w-2] = a/10 + '0', s[w-1] = a%10 + '0';
			else s[w-2] = a + '0', w--;
		}
		printf("%s wins.\n", msg[k & 1]);
	}
	return 0;
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
#include <fstream>
#define ll long long
#define ld long double
#define int long long
#define MOD 1000000007
#define mod 1000000007
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define vvi vector<vi>
#define mp make_pair
#define endl "\n"
using namespace std;
const int f=100000;
int solvevec(vi vec);
void solve1();
void solve()
{
    int T;cin>>T;
    for(int z=1;z<=T;z++)
    {
        solve1();
    }
}
signed main()
{
    std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    solve1();
    return 0;
}
void solve1()
{
    string s,t;cin>>s>>t;
    int n=s.length(),m=t.length();
    int ans=m,c=0;
    for(int i=0;i<n-m+1;i++)
    {
        c=0;
        for(int j=0;j<m;j++)
        {
            if(s[i+j]!=t[j])c++;
        }
        ans=min(ans,c);
    }
    cout<<ans<<endl;
}




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

const int MAXN = 55;

int n;
double arr[MAXN];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%lf", &arr[i]);
    }
    std::sort(arr + 1, arr + n + 1);
    for (int i = 1; i < n; ++i) {
        arr[i + 1] = (arr[i] + arr[i + 1]) / 2;
    }
    printf("%.10lf", arr[n]);
    return 0;
}

Measured memory_bytes: 128
from collections import deque


def D(K):
    d = deque()
    c = 0

    for i in range(1, 10):
        d.append(i)
        c += 1
        if c == K:
            return d

    while True:
        num = d.popleft()
        mod = num % 10
        
        if mod != 0:
            d.append(num * 10 + mod - 1)
            c += 1
            if c == K:
                return d
            
        d.append(num * 10 + mod)
        c += 1
        if c == K:
            return d
        
        if mod != 9:
            d.append(num * 10 + mod + 1)
            c += 1
            if c == K:
                return d
              
              
K = int(input())
print(D(K).pop())

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

int main(){
    int n;
    cin >> n;
    vector<double> a(n);
    rp(i,n) cin >> a[i];
    double dou=0.0;
    rp(i,n){
        dou+=1.0/a[i];
    }
    cout << fixed << setprecision(8) << 1.0/dou << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
using P = pair<int,int>;
int main() {
   int n;cin>>n;
   int cnt=0;
   bool yn=false;
   rep(i,n){
      int d1,d2;cin>>d1>>d2;
      if(d1==d2)cnt++;
      else cnt=0;
      if(cnt>=3){
         yn=true;
      }
   }
   cout<<(yn?"Yes":"No")<<endl;
}

Measured memory_bytes: 3632
a, b, c, x = (int(input()) for _ in range(4))
cnt = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                cnt += 1
print(cnt)


Measured memory_bytes: 2940
A = list(map(int,input().split()))
a = 1
k = 0
b = 0

if A[0]>A[1]:
    k = A[1]
    A[1] = A[0]
    A[0] = k

while a != 0:
    a = A[1]%A[0]
    if a==0:
        print(A[0])
    A[1] = A[0]
    A[0] = a
    


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
bool done[N];

int n, m, x;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    set<int> ss;
    for (int i = 0; i < n; i++) {
        int in;
        cin >> in;
        ss.insert(in);
    }
    if (n == ss.size())
        cout <<"YES";
    else
        cout << "NO";
    return 0;
}


Measured memory_bytes: 9600
var
	N,i,j,ans:int64;
begin
	read(N);
	i:=1;
	while i<=N do begin
		j:=N div(N div i)+1;
		inc(ans,(j-i)*(i+j-1)*(N div i)*(N div i+1)div 4);
		i:=j;
	end;
	writeln(ans);
end.

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

using namespace std;

typedef long long ll;

const int INF = 1e9;

int main()
{
  int n = 0;
  fscanf(stdin, "%d", &n);
  vector<int> A(n);
  for (int i = 0; i < n; ++i) {
    fscanf(stdin, "%d", &A[i]);
  }
  for (int p = 0; p < n; ++p) {
    if (p) { fprintf(stdout, " "); }
    fprintf(stdout, "%d", A[p]);
  }
  fprintf(stdout, "\n");
  for (int i = 1; i < n; ++i) {
    int j = i - 1;
    int key = A[i];
    while (j >= 0 && key < A[j]) {
      A[j + 1] = A[j];
      --j;
    }
    A[j + 1] = key;
    for (int p = 0; p < n; ++p) {
      if (p) { fprintf(stdout, " "); }
      fprintf(stdout, "%d", A[p]);
    }
    fprintf(stdout, "\n");
  }
  return 0;
}

Measured memory_bytes: 1196
#include<stdio.h>

int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);

	int max = 0;
	if (a >= b&&a >=c)printf("%d", b + c);
	else if (b >= c&&b >= a)printf("%d", a + c);
	else printf("%d", a + b);

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s;
	cin >> s;
	int cost = 700;
	int counter = 0;
		if (s[0] == 'o')++counter;
		if (s[1] == 'o')++counter;
		if (s[2] == 'o')++counter;
		cout << cost + counter*100 << endl;
		return 0;
}

Measured memory_bytes: 256
#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;
using pii = std::pair<int, int>;
#define SORT(v) std::sort(v.begin(), v.end())

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	long long n, sum = 0, a, ans1 = 0, ans2 = 0, sum1 =0 ,sum2=0;
	cin >> n;
	

	for (int i = 0; i < n; ++i) {
		cin >> a;
		sum1 += a;
		sum2 += a;
		if (i % 2 == 0) {
			if (sum1 <= 0) {
				ans1 += 1 - sum1;
				sum1 = 1;
			}
			if (sum2 >= 0) {
				ans2 += 1 + sum2;
				sum2 = -1;
			}
		}
		else {
			if (sum1 >= 0) {
				ans1 += 1 + sum1;
				sum1 = -1;
			}
			if (sum2 <= 0) {
				ans2 += 1 - sum2;
				sum2 = 1;
			}
		}
	}
	cout << min(ans1,ans2) << endl;
	return 0;
}

Measured memory_bytes: 256
// AOJ 1142 列車の編成
import java.util.ArrayList;
import java.util.Scanner;
 
public class Main{
	
	static String reverse(String ss) {
		StringBuffer s = new StringBuffer(ss);
		s.reverse();
		return s.toString();
	}
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = Integer.parseInt(sc.nextLine());
        for(int i = 0; i < m; i++) {
        	String arrive = sc.nextLine();
        	int n = arrive.length();
        	ArrayList<String> train = new ArrayList<String>();
        	for(int j = 1; j <= n - 1; j++) {
        		String f = arrive.substring(0, j);
        		String b = arrive.substring(j);        	
        		String fre = reverse(f);
        		String bre = reverse(b);
        		//System.out.println(f + " " + b + " " + fre + " " + bre);
        		train.add(f + b);
        		train.add(f + bre);
        		train.add(fre + b);
        		train.add(fre + bre);
        		train.add(b + f);
        		train.add(b + fre);
        		train.add(bre + f);
        		train.add(bre + fre);
        	}
        	
//        	for(int k = 0; k < train.size(); k++) {
//        		System.out.println(train.get(k));
//        	}
//        	System.out.println();
//        	
        	int cnt = 0;
        	for(int j = 0; j < train.size(); j++) {
        		String s = train.get(j);
        		boolean flag = true;
        		for(int k = j + 1; k < train.size(); k++) {
        			String t = train.get(k);
        			if(s.equals(t)) {     // 自分より末尾に同じ文字列があればカウントしない
        				flag = false;
			            break;
        			}
        		}
        		if(flag) cnt++;
        	}
        	System.out.println(cnt);
        }
    }
}


Measured memory_bytes: 55004
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string x;
	int ans = 0;
	cin >> x;
	for (int i = 1; i < x.length(); i++)
		{
			if (x[i-1] != x[i]) ans++;
		}
	cout << ans << endl;	 
 } 

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    int N;
    cin >> N;
    
    cout << ((N+1000-1)/1000) * 1000 - N  << endl;
    
    

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

int main() {
    cin>>N;
    vec a_num(N, 0), b_num(N, 0);
    rep(i, N){
        cin>>A; --A;
        ++a_num[A];
    }
    rep(i, N){
        cin>>A; --A;
        ++b_num[A];
    }
    rep(i, N) {
        if(a_num[i] + b_num[i] > N){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    vec ans(N, -1), ans_id(N, -1);
    multiset<ll> s;
    rep(i, N) rep(j, b_num[i]) s.insert(i);
    int k(0), last(-1), id(0);
    rep(i, N){
        if(k + a_num[i] + b_num[i] >= N) {
            last = i;
            break;
        }
        reps(j, k, k + a_num[i]) ans_id[j] = id++;
        reps(j, k + a_num[i], k + a_num[i] + b_num[i]) ans[j] = i;
        s.erase(i);
        k += a_num[i] + b_num[i];
    }
    int over = k + a_num[last] + b_num[last] - N, restofa = a_num[last];
    Rrep(i, k){
        if(over == 0 || restofa == 0) break;
        if(ans_id[i] != -1) continue;
        ans_id[i] = id++;
        --restofa;
        --over;
    }
    rep(i, k){
        if(over == 0) break;
        if(ans[i] != -1) continue;
        ans[i] = last;
        s.erase(s.begin());
        --over;
    }
    reps(i, k, N){
        if((restofa--) > 0) ans_id[i] = id++;
        else {
            ans[i] = last;
            s.erase(s.begin());
        }
    }
    rep(i, N){
        if(ans_id[i] == -1) ans_id[i] = id++;
        if(ans[i] == -1) {
            ans[i] = *s.begin();
            s.erase(s.begin());
        }
    }
    vec res(N);
    rep(i, N) res[ans_id[i]] = ans[i];
    rep(i, N) cout<<res[i] + 1<<" \n"[i == N - 1];
}

Measured memory_bytes: 18792
#include <stdio.h>

int main(void)
{
	int i,j,coin,money,count;
	int n[10];
	coin=0;
	for(i=1;i<=5;i++){
		scanf("%d",&n[i-1]);
		j++;
		if(n[i-1]==0){
			break;
		}
	}
	for(i=1;i<=j;i++){
		if(n[i-1]==0){
			break;
		}
		money=1000-n[i-1];
		count=money/500;coin+=count;money=money-500*count;
		count=money/100;coin+=count;money=money-100*count;
		count=money/50;coin+=count;money=money-50*count;
		count=money/10;coin+=count;money=money-10*count;
		count=money/5;coin+=count;money=money-5*count;
		count=money/1;coin+=count;money=money-1*count;
		printf("%d\n",coin);
		coin=0;
	}
	return 0;
}

Measured memory_bytes: 596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		long N = sc.nextLong();
		long A = sc.nextLong();
		long B = sc.nextLong();
		long ans;
		if ((B - A) % 2 == 0) {
			ans = (B - A) / 2;
		} else {
			ans = Math.min(A, N - B + 1) + (B - A) / 2;
		}
		out.println(ans);
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 23252
#include <stdio.h>

//求最大公约数
int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}


int main()
{
	int n = 0;
	scanf("%d",&n);
	//最小公倍数是两数乘积除以最大公约数
	int s = n * 2 / gcd(n, 2);
	printf("%d", s);

	return 0;
}

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

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		vector<int>nums(7);
		for (int i = 0; i < N; ++i) {
			int a; cin >> a;
			a /= 10;
			if (a >= 6)a = 6;
			nums[a]++;
		}
		for (auto n : nums)cout << n << endl;
	}
	return 0;
}

Measured memory_bytes: 2980
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		List<String> l = new ArrayList<>();
		l.add("dream");
		l.add("dreamer");
		l.add("erase");
		l.add("eraser");
		

		boolean dp[] = new boolean[s.length()+1];
		dp[0] = true;
		for(int i=0;i<=s.length();i++) {			
			for(String t : l) {
				int len = t.length();
				if(i-len>=0) {
					if(dp[i-len]==false)continue;
					if(s.substring(i-len, i).equals(t)) dp[i]=true;
				}
			}
		}
		if(dp[s.length()]==true)System.out.println("YES");
		else System.out.println("NO");
	}
}



Measured memory_bytes: 33684
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<iomanip>
using namespace std;
#define ll int64_t
#define REP(i, n) for (int i=0; i<n; i++)

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

    ll N, K;
    cin >> N >> K;

    double ans = 0;

    for (ll i=1; i<=N; i++){
        double temp = 1.0/N;
        ll j = i;
        while (j<K){
            j *= 2;
            temp /= 2;
        }
        ans += temp;
    }

    cout << fixed << setprecision(10) << ans << "\n";
}

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

int main(){
    int r,c;
    cin>>r>>c;
    int a[101][101]={};
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            a[i][c]+=a[i][j];
            a[r][j]+=a[i][j];
            a[r][c]+=a[i][j];
        }
    }

    for(int i=0;i<=r;i++){
        for(int j=0;j<=c;j++){
            cout<<a[i][j];
            if(j<c){
                cout<<' ';
            }
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3124
// D - Wizard in Maze
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)

pair<int, int> dhw[] = { // <h, w>
        { 1, 0},
{ 0,-1},        { 0, 1},
        {-1, 0},
{ 2,-2},{ 2,-1},{ 2, 0},{ 2, 1},{ 2, 2},
{ 1,-2},{ 1,-1},        { 1, 1},{ 1, 2},
{ 0,-2},                        { 0, 2},
{-1,-2},{-1,-1},        {-1, 1},{-1, 2},
{-2,-2},{-2,-1},{-2, 0},{-2, 1},{-2, 2}
};

int main(){
	int H, W; cin>>H>>W;
	int C[2],D[2]; cin>>C[0]>>C[1]>>D[0]>>D[1];
	C[0]--, C[1]--, D[0]--, D[1]--;
	string S[H]; rp(i, 0, H) cin>>S[i];

	vvi dst(H, vi(W, -1));
	deque<tuple<int, int, int>> dq; // <h, w, gid>
	dq.push_back({C[0], C[1], 0});
	while(dq.size()){
		int h, w, gid; tie(h, w, gid) = dq.front(); dq.pop_front();
		if(dst[h][w] >= 0 || S[h][w] == '#') continue;
		dst[h][w] = gid;

		rp(i, 0, 4){
			int nx_h = h + dhw[i].first, nx_w = w + dhw[i].second;
			if(nx_h < 0 || H <= nx_h || nx_w < 0 || W <= nx_w) continue;
			dq.push_front({nx_h, nx_w, gid});
		}
		rp(i, 4, 24){
			int nx_h = h + dhw[i].first, nx_w = w + dhw[i].second;
			if(nx_h < 0 || H <= nx_h || nx_w < 0 || W <= nx_w) continue;
			dq.push_back({nx_h, nx_w, gid+1});
		}

	}

	cout<< dst[D[0]][D[1]] <<endl;
}


Measured memory_bytes: 11824
#include <iostream>

using namespace std;


class Solution{

public:
    string process(const string& s){

        string res = "";
        for(char c: s)
            if(c == 'B'){
                if(res.size()) res.pop_back();
            }
            else res += c;
        return res;
    }
};

int main() {

    string s;
    cin >> s;
    cout << Solution().process(s) << endl;
    
    return 0;
}


Measured memory_bytes: 3024
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main() {
    int W; cin >> W;
    int H; cin >> H;
    int N; cin >> N;

    vector<int> x, y, a;
    rep(i, N) {
       int xx; cin >> xx; x.push_back(xx);
       int yy; cin >> yy; y.push_back(yy);
       int aa; cin >> aa; a.push_back(aa);
    }

    // ２次元配列
    vector<vector<int>> xy;
    xy.resize(W);
    rep(i, W) xy[i].resize(H);
    rep(i, W) rep(j, H) xy[i][j] = 0;

    rep(i, N) {
        switch (a[i]) {
            case 1:
                rep(j, x[i]) rep(k, H) xy[j][k] = 1;
                break;
            case 2:
                rrep(j, x[i], W-1) rep(k, H) xy[j][k] = 1;
                break;
            case 3:
                rep(j, W) rep(k, y[i]) xy[j][k] = 1;
                break;
            case 4:
                rep(j, W) rrep(k, y[i], H-1) xy[j][k] = 1;
                break;
        }
    }

    int count = 0;
    rep(i, W) rep(j, H) if(xy[i][j] == 0) count++;
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define inf 1e10
#define mod 1000000007
#define mii map<int,int>
#define pii pair<int,int>
#define setbits(x) __builtin_popcountll(x)
#define lcm(x,y)  (x*y)/__gcd(x,y)
vi graph[100000];
int vis[100000], c[100000], dis[100000];
void c_p_c()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef  ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
bool func(int x, int y)
{
	return x > y;
}

int32_t main()

{
	//c_p_c();
	int t;
	cin >> t;
	int r = t % 10;


	if (r == 2 || r == 4 || r == 5 || r == 7 || r == 9)
		cout << "hon";
	else if (r == 3)
		cout << "bon";
	else
		cout << "pon";
}






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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define test(t) int t;cin>>t;while(t--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
const int MOD = 1e9+7,MAX = 1e5+5;
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
ll modInv(ll a)
{
	return powN(a,MOD-2);
}


int main()
{
	int n,w;
	cin>>n>>w;
	vl dp(w+1);
	for(int i=0;i<n;i++)
	{
		int wi,vi;
		cin>>wi>>vi;
		for(int we=w-wi;we>=0;we--)
		{
			dp[we+wi]=max(dp[we+wi],dp[we]+vi);
		}
	}
	ll ans=0;
	for(int i=0;i<=w;i++)
	{
		ans=max(ans,dp[i]);
	}
	cout<<ans<<endl;
}

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

void input(int **, int, int);
int howManyIslands(int **, int, int);
void howBigIslands(int **, bool **, int, int, int, int);

int main()
{
	int **island, w, h;
	while(true){
		cin >> w >> h;
		if(w==h && h==0) break;
		island = new int*[w];
		for(int i=0; i<w; i++)
			island[i] = new int[h];
		input(island, w, h);
		cout << howManyIslands(island, w, h) << endl;
		for(int i=0; i<w; i++)
			delete[] island[i];
		delete[] island;
	}
	return 0;
}

void input(int **island, int w, int h)
{
	char *buf;
	cin.clear();cin.ignore();
	for(int i=0; i<h; i++){
		buf = new char[w*2];
		cin.getline(buf, sizeof(char)*w*2);
		int j=0, k=0;
		while(buf[j] != '\0'){
			if(buf[j] != ' '){
				switch(buf[j]){
				case '0':
					island[k][i] = 0;
					k++;
					break;
				case '1':
					island[k][i] = 1;
					k++;
					break;
				}
				if(w==k) break;
			}
			j++;
		}
		delete[] buf;
	}
}

int howManyIslands(int **island, int w, int h)
{
	bool **check;
	int ans = 0;
	check = new bool*[w];
	for(int i=0; i<w; i++){
		check[i] = new bool[h];
		for(int j=0; j<h; j++)
			check[i][j] = false;
	}
	for(int i=0; i<w; i++){
		for(int j=0; j<h; j++){
			if(check[i][j])continue;
			if(island[i][j]){
				ans++;
				howBigIslands(island, check, i, j, w, h);
			} else {
				check[i][j] = true;
			}
		}
	}
	for(int i=0; i<w; i++)
		delete[] check[i];
	delete[] check;

	return ans;
}

void howBigIslands(int **island, bool **check, int x, int y, int w, int h)
{
	if(check[x][y]) return;
	enum __DIR{ UPPER_LEFT, UP, UPPER_RIGHT, LEFT, RIGHT, LOWER_LEFT,
		UNDER, LOWER_RIGHT, DIR_END};
	int periphe[DIR_END][2]={
			{-1, -1}, {0, -1}, {1, -1},
			{-1, 0}, {1, 0},
			{-1, 1}, {0, 1}, {1, 1}
	};
	check[x][y] = true;
	for(int i=0; i<DIR_END; i++){
		int newx = x+periphe[i][0],
			newy = y+periphe[i][1];
		if(newx < 0 || w-1 < newx ||
			newy < 0 || h-1 < newy) continue;
		if(island[newx][newy]){
			if(!check[newx][newy])
				howBigIslands(island, check,
				newx, newy, w, h);
		}
	}
}

Measured memory_bytes: 1540
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; ++i) cin >> vec[i];
    sort(vec.begin(), vec.end());
 
    int ans = 0;
 
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < i; ++j) {
            for (int k = 0; k < j; ++k) {
                if (vec[k] != vec[j] and vec[i] != vec[j] and
                    vec[k] + vec[j] > vec[i]) {
                    ans++;
                }
            }
        }
    }
 
    cout << ans << endl;

  return 0;
 }

Measured memory_bytes: 3604
unittest
{
	assert( [ "8 3", "ACACTACG", "3 7", "2 3", "1 8" ].parse.expand.solve == "2\n0\n3" );
}



import std.conv;
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 nq = input.front.split.to!( long[] );
	input.popFront;
	auto s = input.front;
	auto lrs = new long[][]( nq[ 1 ], 2 );
	foreach( ref lr; lrs )
	{
		input.popFront;
		lr = input.front.split.to!( long[] );
	}
	return tuple( s, lrs );
}

auto solve( string s, long[][] lrs )
{
	// s[ 0 .. i ]の"AC"の数を集計
	auto ts = new long[ s.length + 1 ];
	for( auto i = 1L; i < ts.length; i++ )
	{
		ts[ i ] = ts[ i - 1 ] + ( s[ i - 1 ] == 'A' && s[ i ] == 'C' );
	}
	
	// 集計結果からs[ l - 1 .. r ]の"AC"の数を計算
	auto anss = new long[]( lrs.length );
	foreach( ref ans, lr; lockstep( anss, lrs ) )
	{
		ans = ts[ lr[ 1 ] - 1 ] - ts[ lr[ 0 ] - 1 ];
	}
	
	return anss.to!( string[] ).join( "\n" );
}


Measured memory_bytes: 27388
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
   int n,m;
   while(cin>>n>>m){
       if(n==0&&m==0) break;
       int hit=0,blow=0,pl[4],ans[4];
       for(int i=0;i<4;i++){
           pl[i]=ans[i]=0;
       }
       for(int i=3;i>=0;i--){
           pl[i]=n%10;
           ans[i]=m%10;
           n/=10;
           m/=10;
       }
       for(int i=0;i<4;i++){
           if(pl[i]==ans[i]) hit++;
       }
       for(int i=0;i<4;i++){
           for(int j=0;j<4;j++){
               if(pl[i]==ans[j]){
                   blow++;
                   break;
               }
           }
       }
       cout<<hit<<' '<<blow-hit<<endl;
   }
    return 0;
}


Measured memory_bytes: 5364
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  string s;
  cin>>s;
  int n = s.size();
  int cnt = 0;
  REP(i,n){
     if(s[i]=='2'){
         cnt++;
     }
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256