akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll s; cin >> s;
    if(s <= pow(10,9)) printf("0 0 1 0 0 %lld",s);
    else{
        ll ue,sita=0;
        ll tmp = s;
        /*ll cnt = 0;
        while(tmp >= 10){
            tmp = tmp / 10;
            cnt++;
        }
        cout << cnt << endl;
        tmp = s;*/
        ll a;
        for(int i=0; i<9; i++){
            a = tmp % 10;
            tmp = tmp / 10;
            //cout << tmp << endl;
            rep(j,i) a *= 10;
            sita += a;
            //cout << sita << endl;
        }
        sita = 1000000000 - sita;
        ue = tmp + 1;
        if(s == 1000000000000000000) printf("0 0 0 1000000000 1000000000 0");
        else printf("0 0 %lld 1000000000 %lld 1",sita,ue);
    }
}

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

int N;

struct s{
  int num;
  int p;
  int score;
  string name;
};

s rest[100];

void swap(s *s1, s *s2)
{
  s tmp = *s1;
  *s1 = *s2;
  *s2 = tmp;
}

void sort1()
{
  for(int i = 0; i < N; i++){
    int j = i;
    while(j >= 1 && rest[j - 1].name > rest[j].name){
      swap(&rest[j - 1], &rest[j]);
      j--;
    }
  }

  int cnt = 1;
  rest[N - 1].score = 1000;
  for(int i = N - 2; i >= 0; i--){
    string tmp = rest[i].name;
    if(rest[i].name != rest[i + 1].name){
      cnt++;
      rest[i].score = 1000 * cnt;
    }else{
      rest[i].score = 1000 * cnt;
    }
  }
}

void sort2()
{
  for(int i = 0; i < N; i++){
    int j = i;
    while(j >= 1 && rest[j - 1].p + rest[j - 1].score < rest[j].p + rest[j].score){
      swap(&rest[j - 1], &rest[j]);
      j--;
    }
  }
}

int main()
{
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> rest[i].name >> rest[i].p;
    rest[i].num = i;
  }
  sort1();
  sort2();
  for(int i = 0; i < N; i++)
    cout << rest[i].num + 1 << endl;

  return 0;
}


Measured memory_bytes: 256
import bisect
from operator import itemgetter
import math
import copy
import collections
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
A = IL()

cnt = 0
for i in range(N-2):
  if A[i] < A[i+1] < A[i+2] or A[i] > A[i+1] > A[i+2]:
    cnt += 1

print(cnt)

Measured memory_bytes: 21540
/*         Waha tufaan bhi haar jate hain...
        ...Jaha Kastiyan zid pe hoti hain
*/
#include <bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define fl(i,a,n) for(int i=a; i<n; i++)
#define rfl(i,a,n) for(int i=a; i>=n; i--)
#define ll long long 
#define pb push_back
#define all(v) v.begin(),v.end()
#define in(arr,n) fl(i,0,n)  cin>>arr[i];
#define out(arr,n) fl(i,0,n) cout<<arr[i]<<" ";	    cout<<endl;
#define test()  int tt;  cin>>tt;  while(tt--) 

int main()  {
    fast;
    long x; cin>>x;
    long temp=x/500;
    x-=temp*500;
    cout<<(temp*1000)+(x/5)*5;
}

Measured memory_bytes: 256
N = int(input())
S = input()
l = []

for i in S:
    l.append(i)

l = [ord(i) for i in l]     #ascii
newl = []
for i in l:
    if i + N >= 91:
        i = i - 26 + N
    else:
        i += N
    newl.append(i)

newl = [chr(i) for i in newl]
newl = ''.join(newl)
print(newl)

Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    sort(ALL(s));
    if(s == "abc")cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define inf (1<<29)

using namespace std;

struct Tree
{
  bool root;
  bool child[2];
  Tree *next[2];//left -> false, right -> true
  Tree()
  {
    child[0] = child[1] = false;
    root=false;
  }
};

string s[2];
Tree tree[2];

void ddfs(Tree *t)
{
  if(!t->child[0] && !t->child[1])return;
    
  if(t->child[0])
    {
      ddfs(t->next[0]);
      t->child[0] = false;
      delete t->next[0];
    }

  if(t->child[1])
    {
      ddfs(t->next[1]);
      t->child[1] = false;
      delete t->next[1];
    }
}

void init()
{
  tree[0].root = tree[1].root = true;
  rep(i,2)ddfs(&tree[i]);
}

void parse(int index,int &pos,Tree *t,int depth)
{
  if(pos >= s[index].size())return;
  bool LR = false;

  ++pos;
  while(pos < s[index].size() && !(LR && s[index][pos] == ')'))
    {

      if(s[index][pos] == '(')
	{
	  t->next[LR] = new Tree;
	  t->next[LR]->root = false;
	  t->next[LR]->child[0] = t->next[LR]->child[1] = false;
	  t->child[LR] = true;
	  parse(index,pos,t->next[LR],depth+1);
	  if(pos < s[index].size() && LR && s[index][pos] == ')')break;
	}
      if(s[index][pos] == ',') LR = true;
	
      ++pos;
    }
  ++pos;
}

void tree_walk(Tree *t,int depth)
{
  cout << '(';
  if(t->child[0])tree_walk(t->next[0],depth+1);
  cout << ',';
  if(t->child[1])tree_walk(t->next[1],depth+1);
  cout << ')';
}

void dfs_i(Tree *t1,Tree *t2,Tree *ans)
{
  if(t1->child[0] && t2->child[0])
    {
      ans->next[0] = new Tree;
      ans->child[0] = true;
      ans->next[0]->child[0] = ans->next[0]->child[1] = false;
      dfs_i(t1->next[0],t2->next[0],ans->next[0]);
    }

  if(t1->child[1] && t2->child[1])
    {
      ans->next[1] = new Tree;
      ans->child[1] = true;
      ans->next[1]->child[0] = ans->next[1]->child[1] = false;
      dfs_i(t1->next[1],t2->next[1],ans->next[1]);
    }

}

void dfs_u(Tree *t,Tree *ans)
{
  if(t->child[0])
    {
      if(ans->child[0])
	{//already exists
	  dfs_u(t->next[0],ans->next[0]);
	}
      else
	{//not yet
	  ans->next[0] = new Tree;
	  ans->child[0] = true;
	  ans->next[0]->child[0] = ans->next[0]->child[1] = false;
	  dfs_u(t->next[0],ans->next[0]);
	}
    }

  if(t->child[1])
    {
      if(ans->child[1])
	{//already exists
	  dfs_u(t->next[1],ans->next[1]);
	}
      else
	{//not yet
	  ans->next[1] = new Tree;
	  ans->child[1] = true;
	  ans->next[1]->child[0] = ans->next[1]->child[1] = false;
	  dfs_u(t->next[1],ans->next[1]);
	}
    }

}

void compute(char c)
{
  Tree ans;
  ans.root = true;
  ans.child[0] = ans.child[1] = false;
  if(c == 'i')
    {
      dfs_i(&tree[0],&tree[1],&ans);
      tree_walk(&ans,0);
      cout << endl;
    }
  else if(c == 'u')
    {
      dfs_u(&tree[0],&ans);
      dfs_u(&tree[1],&ans);
      tree_walk(&ans,0);
      cout << endl;
    }

  ddfs(&ans);
}

//deleteまわりも後で書く <- 忘れてた <- でも通らない <- なんでや <- parseが小さいケースでしかあってない <- 構文解析間違ってた

int main()
{
  char c;
  while(cin >> c)
    {
      cin >> s[0] >> s[1];
      init();

      int pos;
      rep(i,2)
	{
	  pos = 0;
	  parse(i,pos,&tree[i],0);
	}

      compute(c);
   
    }
  return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
//#include <bits/stdc++.h>

using namespace std;
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;}
const long long INF = 1LL << 60;
typedef pair<int, int> P;

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

    int T = N / 2;
    if (N % 2 == 1) {
        cout << "No\n"; return 0;
    }
    for (int i = 0; i < T; i++) {
        if (S[i] != S[i+T]) {
            cout << "No\n"; return 0;
        }
    }
    cout << "Yes\n";

}

/*
int main() {
    int N; cin >> N;
    cout << N * N << endl;
}*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N;
  cin >> N;
  int ans = (N + 1) / 2;
  cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
vector<vector<int>> w;
vector<int> r;
int main()
{
	string s;
	cin >> s;
	rep(i, 0, s.size() - 1) {
		if (s[i] == s[i + 1]) {
			printf("%d %d\n", i+1, i+2);
			return 0;
		}
		if (i + 2 < s.size() && s[i] == s[i + 2]) {
			printf("%d %d\n", i + 1, i + 3);
			return 0;
		}
	}
	puts("-1 -1");
	return 0;
}

Measured memory_bytes: 3756
while True:
    H, W = map(int,input().split())
    if H == 0 and W == 0:
        break
    else:
        for i in range(H):
            for j in range(W):
                if i % 2 == 0:
                    if j % 2 == 0:
                        print("#", end="")
                    else:
                        print(".", end="")                        
                else:
                    if j % 2 == 0:
                        print(".", end="")
                    else:
                        print("#", end="")
            print()
    print()


Measured memory_bytes: 7008
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<chrono>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define vint(a,n) vint a(n); rep(i, n) cin >> a[i];
#define vll(a,n) vll a(n); rep(i, n) cin >> a[i];
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
// #define MOD (998244353)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pl(T x){cout << x << " ";}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

 ll med(vll a){
    int n = a.size();
    sort(ALL(a));
    if(n%2==1){
        return a[(n+1)/2 - 1];
    }else{
        return a[n/2 -1 ] + a[n/2];
    }
}

int main()
{
    int n; cin >> n;
    vll a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];

    ll med_min, med_max;
    med_min = med(a);
    med_max = med(b);

    pr(med_max - med_min + 1);
    return 0;}

Measured memory_bytes: 7944
A,B,K = map(int, input().split())

for i in range(K):
    if i%2 == 0:      
        if A%2 == 1:
            A -= 1
        B += A//2
        A = A//2
    else:
        if B%2 == 1:
            B -= 1
        A += B//2
        B = B//2
        
print(A, B)

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
#include<stack>
#define st first
#define nd second

using namespace std;
struct O{
		int st;
		int nd;
		int val;
};
const int N = 2e3 + 10;

int dp[N][N],   a[3 * N], fr[N] , ba[N];

int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= 3 * n; i++) {
		scanf("%d", &a[i]);
	}
	dp[a[1]][a[2]] = dp[a[2]][a[1]] = ba[a[2]] = ba[a[1]] = fr[a[2]] = fr[a[1]] =1;
	int col = 0, ma = 1;
	for(int i = 3; i < 3 *  n; i += 3){
		if(a[i] == a[i + 1] && a[i] == a[i + 2]) {
			col ++;
			continue;
		}
		sort(a + i, a + i + 3);
		stack<O> stx;
		if(a[i + 1] == a[i + 2]){
			swap(a[i], a[i + 2]);	
		}	    
		if(a[i] == a[i + 1]){
			for(int j = 1; j <= n; j++){
				if(ba[j] != 0) stx.push({a[i + 2], j, max(dp[a[i]][j] + 1, ba[j])});
				if(fr[j] != 0) stx.push({j, a[i + 2], max(dp[j][a[i]] + 1, fr[j])});
			}
			stx.push({a[i], a[i], max(dp[a[i + 2]][a[i + 2]] + 1, ma)});			
		}
		else{
			int x = max(ma, dp[a[i]][a[i]] + 1), y = max(ma, dp[a[i + 1]][a[ i +1]] + 1), z = max(ma, dp[a[i + 2]][a[i+2]] + 1);
			stx.push({a[i + 1], a[i + 2], x}), stx.push({a[i], a[i + 2], y}), stx.push({a[i], a[i + 1], z});
			stx.push({a[i + 2], a[i + 1], x}), stx.push({a[i + 2], a[i], y}), stx.push({a[i + 1], a[i], z});
			for(int j = 1; j <= n; j++){
				for(int k = 0; k < 3; k++){
					if(fr[j] !=  0) stx.push({j, a[i + k], fr[j]});
					if(ba[j] != 0)  stx.push({a[i + k], j, ba[j]});
				}
			}
		}
		while(!stx.empty()){
			int x = stx.top().st, y = stx.top().nd, z= stx.top().val;
			stx.pop();
			dp[x][y] = max(dp[x][y], z);
			fr[x] = max(fr[x], z);
			ba[y] = max(ba[y],  z);
			ma = max(ma, z);
		}	
	}
	printf("%d", col +  max(ma, dp[a[3 *n]][a[3 * n]] + 1) - 1);
}		

Measured memory_bytes: 18668
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
import math
# stdin = open("sample.txt")

N, x = [int(x) for x in stdin.readline().rstrip().split()]
box = list(map(int,[int(x) for x in stdin.readline().rstrip().split()]))
box.insert(0,0)
ans = 0
for i in range(len(box)-1):
    a = box[i]
    b = box[i+1]
    # print(a,b)
    if a+b > x:
        box[i+1] -=  a+b-x
        ans += a+b-x
    else:
        continue
# print(box)
print(ans)

Measured memory_bytes: 14908
"""
Longest Common Subsequence
axyb
abyxb
-> axb or ayb
最長の共通部分文字列を取り出す
"""

S = input()
T = input()

N = 3300
dp = [[0] * N for i in range(N)]
for i, s in enumerate(S):
    for j, t in enumerate(T):
        dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j])
        if s == t:
            dp[i+1][j+1] = max(dp[i][j]+1, dp[i+1][j+1])

ns = len(S)
ts = len(T)
# for i in range(ns+1):
#     print(*dp[i][:ts+1])

cnt = dp[ns][ts]
ans_r = ""
for i in range(ns,-1,-1):
    flg = True
    for j in range(ts,-1,-1):
        if flg and dp[i][j] == dp[i+1][j] == dp[i][j+1] == dp[i+1][j+1] -1 == cnt-1: 
            # print(i,j,cnt, S[i],T[j])
            ans_r += S[i]
            flg = False
            cnt -= 1
print(ans_r[::-1])

Measured memory_bytes: 126300
n,k,s = map(int,input().split())

if s < 10**9:
    if k == n:
        for i in range(n-1):
            print(s, end = ' ')
        print(s,end = ' ')
    else:
        for i in range(k):
            print(s, end = ' ')
        for i in range(n-k-1):
            print(s+1, end = ' ')
        print(s+1,end = ' ')
else:
    if k == 0:
        for i in range(n-1):
            print(1, end = ' ')
        print(1,end = ' ')
    elif k == n:
        for i in range(n-1):
            print(s, end = ' ')
        print(s,end = ' ')
    else:
        for i in range(k-1):
            print(s, end = ' ')
        print(s-n+k, end = ' ')
        for i in range(n-k-1):
            print(1, end = ' ')
        print(1,end = ' ')


Measured memory_bytes: 4300
s = input()
ans = "AC"
if s[0] != "A":
    ans = "WA"
elif "C" not in s[2:len(s)-1]:
    ans = "WA"
else:
    cnt = 0
    for i in range(1,len(s)):
        if s[i] == "C":
            cnt += 1
        elif s[i].isupper():
            ans = "WA"
            break
        if cnt > 1:
            ans = "WA"
print(ans)

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

int main(){
    int n,q,t,x,y; cin>>n>>q;
    stack<int>a[n];
    for(int i=0;i<q;i++){
        cin>>t;
        if(t==0){
            cin>>x>>y;
            a[x].push(y);
        }
        if(t==1){
            cin>>x;
            if(!a[x].empty()) cout<<a[x].top()<<endl;
        }
        if(t==2){
            cin>>x;
            if(!a[x].empty()) a[x].pop();
        }
    }
    return 0;
}


Measured memory_bytes: 4376
n, k = map(int, input().split())
ans = 0

for i in range(1, n+1):
    if i >= k:
        ans += 1 / n
    else:
        tmp = i
        cnt = 0
        while tmp < k:
            tmp *= 2;
            cnt += 1
        ans += (1/n) * (1/2)**cnt

print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
#include<iomanip>
using namespace std;

int N;

int main() {
    cin >> N;
    vector<double> x(N), y(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
    }
    double d;
    double ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            d = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
            ans += sqrt(d);
        }
    }
    ans *= 2;
    ans /= N;
    cout << fixed << setprecision(10) << ans << endl;
}


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

using namespace std;
typedef long long ll;
#define lp(x,q) for(ll i=x ;i<q;i++)
#define sor(v) sort(v.begin(),v.end())
#define rsor(v) sort(v.rbegin(),v.rend())
#define df vector<ll>
#define minn(v) *min_element(v.begin(),v.end())
#define maxx(v) *max_element(v.begin(),v.end())
#define MY_TORNADO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#define rev(v) reverse(v.begin(),v.end())
#define print(v) for(auto f:v)cout<<f<<" ";
//Global variable :
ll cou,ans=0,mx=INT_MIN,mn=INT_MAX,sum=0,modu=1e9+7;

//use scanf,printf,getline
int main(){
MY_TORNADO;

int a,s;
cin>>a>>s;
set<int>ac;
map<int,int>m;
set<int>r;
ans=0,sum=0;
for(int x=0;x<s;x++){
int q;
string w;
cin>>q>>w;
if(w=="WA"&&!ac.count(q))m[q]++;
else if(!ac.count(q)){
if(m.count(q))sum+=m[q];
ans++;
ac.insert(q);
}



}cout<<ans<<" "<<sum;

return 0;}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
using namespace std;
int main()
{
    //std::ios::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    int n,a,b;
    cin>>n>>a>>b;
    if(abs(a-b)%2)
    	cout<<"Borys";
    else
    	cout<<"Alice";
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define contains(c, i) ((c).find(i) != (c).end())
#define present(i, c) (find(all(c), i) != (c).end())

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i <= n; i++)
#define repa(i, a, b) for(int i = (a); i < (b); i++)
#define repd(i, n) for(int i = (n)-1; i >= 0; i--)

#define TRACE(x...) x
#define dbg(x) TRACE(cerr << #x" = " << x << endl)
#define dbgall(x) TRACE(cerr << #x" = "; for(auto __i : x) cerr << __i << " "; cerr << endl)
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<class T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<class T, class S>  ostream& operator<<(ostream& os, const pair<T, S>& p) { os << "(" << p.first << ", " << p.second << ")"; return os; }

//=========================

void run_test() {
	int n, k; cin >> n >> k;
    vi p(n);
    rep(i, n) cin >> p[i];
    sort(all(p));
    cout << accumulate(p.begin(), p.begin() + k, 0) << endl;
}

//=========================

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	//int _t = 1, __t; cin >> __t; while(_t <= __t) { cout << "Case #" << _t++ << ": "; run_test(); }
	// int _t; cin >> _t; while(_t--) run_test();
	run_test();
	return 0;	
}



Measured memory_bytes: 3644
N = int(input())
alist = [int(i) for i in input().split()]
bestcost = 1000000000
besti = 1000000
for i in range(min(alist),max(alist)+1):
    cost = sum([(a-i)**2 for a in alist])
    if cost < bestcost:
        bestcost = cost
        besti = i
 
print(bestcost)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    ll h,w; cin >> h >> w;
    ll ans = 0;
    if(h == 1 || w == 1){
        ans = 1;
    }
    else{
        ans = h * (w / 2);
        if(w % 2 == 1){
            ans += (h + 1) / 2;
        }
    }

    cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    bool flag = true;
    int i,j;

    sort(a.begin(), a.end());
    rep(i,n-1){
        if(a[i+1] == a[i]){
            flag = false;
            break;
        }
    }
    
    if(flag == true){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))
template<typename T> inline bool __max__(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool __min__(T &x, const T &y) { return x > y ? x = y, 1 : 0; }

#define pb push_back
#define mp make_pair

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;

    cin >> n;

    map<ll, ll> table;
    map<ll, ll>::iterator it;
    ll a;
    ll ans = 0LL;

    int i;

    for (i = 0; i < n; i++) {
        cin >> a;

        table[a]++;
    }

    for (it = table.begin(); it != table.end(); it++) {
        if (it->first != it->second) {
            if (it->second < it->first) ans += it->second;
            else if (it->first < it->second) ans += (it->second - it->first);
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 6272
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#define N (400000+1000)
using namespace std;

struct edge{int to,next;}edge[N<<1];
int Father[N],Depth[N],Dfn[N],Low[N];
int n,x,y,S1,S2,cnt,ans,u[N],v[N];
int head[N],num_edge;

void add(int u,int v)
{
	edge[++num_edge].to=v;
	edge[num_edge].next=head[u];
	head[u]=num_edge;
}

bool check(int x,int y)
{
	if (Dfn[x]>Dfn[y]) swap(x,y);
	if (Low[x]>=Low[y])
		return (Depth[y]-Depth[x])>2;
	return Father[x]!=Father[y];
}

void Dfs1(int x)
{
	Dfn[x]=++cnt; Depth[x]=Depth[Father[x]]+1;
	for (int i=head[x]; i; i=edge[i].next)
		if (edge[i].to!=Father[x])
		{
			Father[edge[i].to]=x;
			Dfs1(edge[i].to);
		}
	Low[x]=++cnt;
}

void Dfs2(int x,int fa,int k)
{
	ans=max(ans,Depth[x]-1);
	if (Depth[x]<=k) return;
	for (int i=head[x]; i; i=edge[i].next)
		if (edge[i].to!=fa)
		{
			if (check(x,edge[i].to)) puts("-1"),exit(0);
			Dfs2(edge[i].to,x,k+1);
		}
}

int main()
{
	scanf("%d%d%d",&n,&S1,&S2);
	for (int i=1; i<=n-1; ++i)
		scanf("%d%d",&u[i],&v[i]);
	for (int i=1; i<=n-1; ++i)
		scanf("%d%d",&x,&y),add(x,y),add(y,x);
	Dfs1(S2); 
	memset(head,0,sizeof(head)); num_edge=0;
	for (int i=1; i<=n-1; ++i) add(u[i],v[i]),add(v[i],u[i]);
	Dfs2(S1,-1,1);
	printf("%d\n",ans<<1);
}

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

typedef unsigned long long ull;

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

  int A[300100];
  for (int i = 0; i < 3 * N; ++i) {
    cin >> A[i];
  }

  sort(A, A + 3 * N, greater<int>());

  ull ans = 0;
  for (int i = 1; i < 2 * N; i += 2) {
    ans += A[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back

#define rep(i, N) for(int i = 0; i < N; i++)
#define repa(i, a, N) for(int i = a; i < N; i++)
#define repr(i, N) for(int i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

const ll mod = 1e9 + 7;
// const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

const int M = 60;
ll f[M+1][2][2][2];

int main() {
	ll L, R;
	cin >> L >> R;

	int lb[M], rb[M];
	rep(i, M) {
		lb[i] = L % 2;
		rb[i] = R % 2;
		L /= 2;
		R /= 2;
	}
	// for (auto l : lb) { cout << l; } cout << endl;
	// for (auto l : rb) { cout << l; } cout << endl;

	f[0][0][0][0] = 1;
	
	repa(i, 0, M) {
		int l = lb[M - 1 - i], r = rb[M - 1 - i];

		trep(lf, 2, rf, 2, cf, 2) {
			// 0, 0
			if (lf || l == 0) {
				f[i + 1][lf][rf || r == 1][cf] += f[i][lf][rf][cf];
				f[i + 1][lf][rf || r == 1][cf] %= mod;
			}

			// 0, 1
			if (lf || l == 0)
				if(rf || r == 1)
					if (cf) {
						f[i + 1][lf][rf][cf] += f[i][lf][rf][cf];
						f[i + 1][lf][rf][cf] %= mod;
					}

			// 1, 1
			if (rf || r == 1) {
				f[i + 1][lf || l == 0][rf][1] += f[i][lf][rf][cf];
				f[i + 1][lf || l == 0][rf][1] %= mod;
			}

			// 1, 0
			// no operation
		}
	}

	ll ans = 0;

	trep(lf, 2, rf, 2, cf, 2) {
		ans += f[M][lf][rf][cf];
		ans %= mod;
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
	string s;
	cin >> s;
	int ans = 0;
	for(int i=0; i<s.size(); i++){
		int cnt = 0;
		for(int j=i; j<s.size(); j++){
			if(s[j] != 'A' && s[j] != 'G' && s[j] != 'C' && s[j] != 'T') break;
			else cnt++;
		}
		if(ans < cnt) ans = cnt;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
    int A1,A2,A3, sum;
    cin>>A1>>A2>>A3;
    sum = A1+A2+A3;
    if (sum>=22) {
        printf("bust\n");
    } else {
        printf("win\n");
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	string s;
	cin >> s;

	if (s == "MON") cout << 6 << endl;
	if (s == "TUE") cout << 5 << endl;
	if (s == "WED") cout << 4 << endl;
	if (s == "THU") cout << 3 << endl;
	if (s == "FRI") cout << 2 << endl;
	if (s == "SAT") cout << 1 << endl;
	if (s == "SUN") cout << 7 << endl;

	return 0;

}

Measured memory_bytes: 256
H, W = map(int, input().split())
C = []
for _ in range(10):
    c = list(map(int, input().split()))
    C.append(c)

A = []
for _ in range(H):
    a = list(map(int, input().split()))
    A.append(a)

# 0-9を1に変える時の最小のエネルギーをそれぞれ求める(ワーシャルフロイド法)
for k in range(10):
    for i in range(10):
        for j in range(10):
            C[i][j] = min(C[i][j], C[i][k] + C[k][j])

count = 0
for i in range(H):
    for j in range(W):
        if (A[i][j] == -1):
            continue
        else:
            count += C[A[i][j]][1]

print(count)


Measured memory_bytes: 9560
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >


using namespace std;

int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};

const long double Pi=acos(-1),e=2.718;
const int N=2e5+10,mod=1e9+7;


int main ()
{
    FASTIO
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        cin >> b[i];
    }
    vector<int> p(n);
    for(int i=0;i<n;i++){
        p[i]=i+1;
    }
    int ind1,ind2,cnt=0;
    do{
        cnt++;
        bool ok1=1,ok2=1;
        for(int i=0;i<n;i++){
            if(p[i]!=a[i]){
                ok1 = 0;
                break;
            }
        }
        for(int i=0;i<n;i++){
            if(p[i]!=b[i]){
                ok2 = 0;
                break;
            }
        }
        if(ok1)ind1=cnt;
        if(ok2)ind2=cnt;

    }while(next_permutation(all(p)));
    cout << abs(ind1-ind2) << endl;
    return 0;
}
/**

*/


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

#define FOR(i,k,n)  for(int i=(k);i<(int)(n);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(x)  begin(x),end(x)

using namespace std;

int main() {
  int n;
  cin>>n;
  map<int, int> m;
  REP(i,n) {
    int x;
    cin>>x;
    ++m[x];
  }
  int cnt = 0;
  for (auto p : m) {
    int x, c;
    tie(x, c) = p;
    if (c >= x) cnt += c-x;
    else cnt += c;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 4736
import java.util.*;

class Main{
	Scanner scan=new Scanner(System.in);
	int m;
	int f;
	int r;
	String han;
	public Main(){
		for(;;){
			m=scan.nextInt();
			f=scan.nextInt();
			r=scan.nextInt();
			if(m==-1&&f==-1&&r==-1){
				break;
			}else if(m==-1||f==-1){
				han="F";
	//			System.out.println("F");
			}else if(m+f>=80){
				han="A";
	//			System.out.println("A");
			}else if(65<=m+f&&m+f<80){
				han="B";
	//			System.out.println("B");
			}else if(50<=m+f&&m+f<65){
				han="C";
	//			System.out.println("C");
			}else if(30<=m+f&&m+f<50){
				han="D";
	//			System.out.println("D");
			}else if(m+f<30){
				han="F";
	//			System.out.println("F");
			}
	        if(r>=50){
				han="C";
			}
			System.out.println(han);
	    }
	}
	public static void main(String[] args){
		new Main();
	}
}

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

using ll = long long;
using pii = pair<int, int>;

int main() {
    int n, m;
    cin >> n >> m;
    vector<ll> a(n);
    ll sum = 0;
    vector<ll> sum1(2*m+1);
    vector<ll> sum2(2*m+1);
    for(int i=0; i<n; ++i) {
        cin >> a[i];
    }
    for(int i=1; i<n; ++i) {
        ll now = a[i-1];
        ll to = a[i] + (a[i] < a[i-1] ? m : 0);
        sum += to - now;
        if(now+1 >= to) {
            continue;
        }
        sum1[now+2]++;
        sum1[to+1]--;
        sum2[now+2] -= now+1;
        sum2[to+1] += now+1;
    }
    for(int i=1; i<2*m+1; ++i) {
        sum1[i] += sum1[i-1];
        sum2[i] += sum2[i-1];
    }
    ll res = sum;
    for(int i=1; i<=m; ++i) {
        ll tmp = sum - (sum1[i] * i + sum2[i]) - (sum1[i+m] * (i + m) + sum2[i+m]);
        res = min(res, tmp);
    }
    cout << res << endl;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int a[n];
    int dp[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        dp[i]=1e12;
    }
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1]<<endl;
}


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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>d(n);
  rep(i,0,n)cin>>d[i];
  sort(ALL(d));
  cout<<d[n/2]-d[n/2-1]<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    string S; cin >> S;
    string ans;

    REP(i,S.size()){
        if(S[i]=='0'){
            ans.push_back('0');
        }else if(S[i]=='1'){
            ans.push_back('1');
        }else if(ans.size()!=0 and S[i]=='B'){
            ans.pop_back();
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int N;

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

  int ans = INT_MAX;
  for (int i = 1; i < N; i++) {
    int a = i, b = N - i;
    int m = 0;
    while (a > 0) {
      m += a % 10;
      a /= 10;
    }
    while (b > 0) {
      m += b % 10;
      b /= 10;
    }
    ans = min(ans, m);
  }

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

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


#define ll long long
#define MOD 1000000007



int main(){
    string s,t;
    cin>>s>>t;
    
    int j=0;
    for(int i=0;i<s.size();i++){
        if(s.at(i)!=t.at(i)){
            j=1;
            break;
        }
    }
    if(s.size()+1!=t.size())j=1;
    
    if(j==1){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define FORR(i, m, n) for(int i=m; i>=n; i--)
#define INF 999999999
#define llong long long
#define VSORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
2 1000
)");
#define cin input
#endif

int main()
{
	int n, y;
	cin >> n >> y;

	REP(a,n+1)
	{
		REP(b,n+1)
		{	
			int sum=0;
			sum = 9000*a+4000*b+1000*n;
			if (sum==y && n-a-b>=0)
			{
				cout << a << " " << b << " " << n-a-b << endl;
				goto loopend;
			}
			else if (sum>y)
				break;
		}
	}
	cout << "-1 -1 -1" << endl;
	loopend:
		return 0;
}

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

int is_bipartite(vector<vector<int>> &g) {
    int cntW = 0;
    vector<int> color(g.size(), -1);
    function<bool(int, int)> dfs = [&](int u, int c) {
        if ((color[u] = c) > 0) cntW++;
        for (int v: g[u]) {
            if (color[v] == c) return false;
            if (color[v] < 0 && !dfs(v, 1 - c)) return false;
        }
        return true;
    };
    if (!dfs(0, 0)) return -1;
    return cntW;
}

int main() {
    int n, m; cin >> n >> m;
    vector<vector<int>> g(n);
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b; a--, b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    int cntW = is_bipartite(g);
    long long all = 0;
    if (cntW < 0) {
        all = 1LL * n * (n - 1) / 2;
    } else {
        all = 1LL * cntW * (n - cntW);
    }
    cout << all - m << endl;
    return 0;
}


Measured memory_bytes: 6656
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

int main(){
  int a,b,x;
  cin >> a>>b>>x;
  YN(a <= x && x <= a+b);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    string s;
  	cin >> s;
  	for(int i=0; i<5; i++){
      cout << s[i];
    }
  	cout << " ";
  	for(int i=6; i<13; i++){
      cout << s[i];
    }
  	cout << " ";
  	for(int i=14; i<19; i++){
      cout << s[i];
    }
  	cout << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        int cnt = 0, ans = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'R') {
                cnt++;
                ans = Math.max(ans, cnt);
            } else {
                cnt = 0;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35892
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n){
		cin >> a[i];
	}
	sort(all(a));
	if(n == 2) return cout << a[1] << ' ' << a[0] << '\n',0;
	int ans = *lower_bound(a.begin(),a.end()-1,a[n-1]/2);
	int ans2 = *(lower_bound(a.begin(),a.end()-1,a[n-1]/2)-1);
	if(abs(a[n-1] - ans * 2) < abs(a[n-1] - ans2 * 2)) cout << a[n-1] << ' ' << ans << '\n';
	else cout << a[n-1] << ' ' << ans2 << '\n';
	return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize ("-Ofast")
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(a) (long long)a.size()
#define all(a) a.begin(), a.end()
#define reset(a, n) a.clear(), a.resize(n)
#ifndef ONLINE_JUDGE
#define cin ___in
#endif
std::ifstream ___in("input.in");
using namespace std;
using ll = long long;
typedef pair<ll, ll> pi;
typedef vector<ll> vec;
typedef vector<vector<ll> > vvec;
typedef vector<pair<ll, ll> > vecpi;
typedef vector<vector<pair<ll, ll> > > vvecpi;
typedef set<ll> seti;
typedef set<pair<ll, ll> > setpi;
typedef multiset<ll> mseti;
typedef multiset<pair<ll, ll> > msetpi;
typedef map<ll, ll> mpi;

static const bool tc = 0;
static const ll mod = LLONG_MAX - 24;

void solve() {
        ll x, k, d, ans = 1e15;
        cin >> x >> k >> d;
        x = max(x, -x);
        ll l = 0, r = min(k, x / d), lf = 1e15;
        while(l <= r) {
                ll m = (l + r) >> 1;
                ll pos = x - d * m;
                if(abs(pos) < ans) {
                        ans = abs(pos);
                        lf = m;
                }
                ans = min(ans, abs(pos));
                if(abs(pos - d) < pos) {
                        l = m + 1;
                }
                else {
                        r = m - 1;
                }
        }
        ll mv = k - lf;
        if(mv % 2 == 0) {
                cout << ans << "\n";
        }
        else {
                cout << min(abs(ans - d), abs(ans + d));
        }
}

int main() {
        srand(time(0));
        int T = 1;
        if(tc) cin >> T;
        for(int i = 1; i <= T; ++i) {
                #ifndef ONLINE_JUDGE
                cout << "----- " << i << " -----\n";
                #endif
                solve();
        }
        return 0;
}


Measured memory_bytes: 3636