akhauriyash/Code-Regression huggingface dataset:
package main

import(
	"fmt"
)

func main(){
	var s string
	fmt.Scanln(&s)
	table:=make(map[byte]int)
	for i:=0; i<len(s);i++{
		table[s[i]]++
	}
	count:=0
	flag:=true
	for _,v:=range table { 
    count++
    if v!=2{
    	flag=false
    }
	}
	ans:=""
	if count==2 && flag{
		ans="Yes"
	} else{
		ans="No"
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n, m, x; cin >> n >> m >> x;
	int c[n], a[n][m];
	rep(i,n){
		cin >> c[i];
		rep(j,m) {
			cin >> a[i][j];
		}
	}
	int64_t anss = LINF;
	for(int mask = 0; mask < (1 << n); ++mask) {
		int64_t ans[m] = {};
		int64_t co = 0;
		for(int i = 0; i < n; ++i) {
			if(mask >> i & 1) {
				co += c[i];
				for(int j = 0; j < m; ++j) {
					ans[j] += a[i][j];
				}
			}
		}
		bool flg = true;
		for(int i = 0; i < m; ++i) {
			if(ans[i] < x) {
				flg = false;
			}
		}
		if(flg) {
			anss = min(anss, co);
		}
	}
	cout << (anss == LINF ? -1 : anss) << '\n';
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
int main() {
  int h,w;
  cin >> h >> w;;
  int** a = new int*[500];
  stringstream ans;
  int counter = 0;
  for(int i=0;i<h;i++){
    a[i] = new int[500];
    for(int j=0;j<w;j++){
      cin >> a[i][j];
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w-1;j++){
      if(a[i][j]%2==1){
        counter++;
        ans << i+1 << " " << j+1 << " " << i+1 << " " << j+2 << endl;
        a[i][j+1] += 1;
      }
    }
  }
  for(int i=0;i<h-1;i++){
    if(a[i][w-1]%2==1){
        counter++;
        ans << i+1 << " " << w << " " << i+2 << " " << w << endl;
        a[i+1][w-1] += 1;
    }
  }
  cout << counter << endl;
  cout << ans.str();
  return 0;
}


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

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

int gcd(int a, int b){return (a % b)? gcd(b, a % b) : b;}
int lcm(int a, int b){return a * b / gcd(a, b);}

void solve_A(){
    string s;
    cin >> s;

    if(s[1] == 'B') cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

int main(void){
    solve_A();
    
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <stdio.h>

using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main(){
    int M,N,X;
    cin>>N>>M>>X;
    
    ll C[N];
    ll A[N][M];
    ll Al_SUM[M];
    
    ll C_SUM=0;
    ll min=INF;

    
    for(int i=0;i!=N;++i){
        cin>>C[i];
        for(int j=0;j!=M;++j){
            cin>>A[i][j];
        }
    }
    
    for(int i=0;i!=M;++i) Al_SUM[i]=0;
   
   /*
    for(int i=0;i!=N;++i){
        for(int j=0;j!=M;++j){
            cout<<"A["<<i<<"]["<<j<<"]"<<A[i][j]<<" ";
        }
    }
    cout<<endl;
    */
    
    
    for(int bit=1;bit<(1<<N);bit++){

        for(int i=0;i<N;++i){        //iは本の冊数
            if(bit & (1<<i) ){
                for(int j=0;j!=M;++j){
                    Al_SUM[j]+=A[i][j];
                    //cout<<"Al_SUM["<<j<<"]:"<<Al_SUM[j]<<endl;
    
                }
                C_SUM+=C[i];
                //cout<<C_SUM<<endl;
            }
        }
        //for(int i=0;i!=M;++i)cout<<"Al_SUM["<<i<<"]:"<<Al_SUM[i]<<endl;
        bool ok=true;
        //cout<<C_SUM<<"\n";
        for(int j=0;j!=M;++j){
            if(Al_SUM[j]<X){
                ok=false;
                //cout<<flag<<endl;
                break;
            }else{
                
            }
        }
        if(ok){
        min=(C_SUM<min)?C_SUM:min;
        }
        for(int j=0;j!=M;++j)Al_SUM[j]=0;
        C_SUM=0;
    }
    
    //cout<<"flag:"<<flag<<endl;
    
    if(min!=INF){
        cout<<min<<endl;
       
    }else{
         cout<<-1<<endl;
    }
    
}



Measured memory_bytes: 3588
N = int(input())
L = list(map(int,input().split()))
if len(L)<3:
    print(0)
else:
    Lrev = sorted(L,reverse=True)
    count = 0
    for i in range(len(L)-2):
        e1 = Lrev[i]
        for j in range(i+1,len(L)-1):
            e2 = Lrev[j]
            if e1!=e2:
                for k in range(j+1,len(L)):
                    e3 = Lrev[k]
                    if e1!=e3 and e2!=e3 and e1<e2+e3:
                        count += 1
            
    print(count)


Measured memory_bytes: 9096
MOD = int(1e9+7)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    cnt = [0] * 3
    ans = 1
    for a in A:
        ans = (ans * cnt.count(a)) % MOD
        try:
            c = cnt.index(a)
        except ValueError:
            print(0)
            return
        cnt[c] += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 52928
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define sec second
#define fir first
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
typedef vector<int> Vec;
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;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



signed main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    string k;
    int d;
    cin >> k >> d;
    vector< vector<int> > dp(d, vector<int>(2));
    dp[0][true] = 1;

    rep(i, k.size()) {
        int here = k[i] - '0';
        vector< vector<int> > after(d, vector<int>(2));

        for(int prevmod = 0; prevmod < d; prevmod++) {
            for(int now = 0; now <= 9; now++) {
                int nowmod = (prevmod + now) % d;
                if(now < here) {
                    after[nowmod][false] += dp[prevmod][true];
                    after[nowmod][false] %= MOD;
                } else if(now == here) {
                    after[nowmod][true] += dp[prevmod][true];
                    after[nowmod][true] %= MOD;
                }
                after[nowmod][false] += dp[prevmod][false];
                after[nowmod][false] %= MOD;
            }
        }
        dp = after;
    }
    cout << (dp[0][true] + dp[0][false] - 1 + MOD) % MOD << endl;
    return 0;
}

Measured memory_bytes: 256
#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.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int A=0,B=0;
  for(int i = 0; i < N; i += 2) {
    A += vec.at(i);
    if(i + 1 >= N)
      break;
    B += vec.at(i + 1);
  }
  cout << A - B << endl;
}


Measured memory_bytes: 3532
import math

def primes(N):
    ps = []
    for i in range(2,N+1):
        flag = True
        for p in ps:
            if(i % p == 0):
                flag = False
        if(flag):
            ps.append(i)
    return ps

def p_counter(p, number):
    count = 0
    while True :
        if(number % p == 0):
            number = number//p
            count += 1
        else:
            break
    return count


if __name__=="__main__":
    N = int(input())
    ps = primes(1000)
    N = math.factorial(N)
    cs = [p_counter(p, N) for p in ps]
    pattern = 1
    for c in cs:
        pattern *= (c+1)
    ans = pattern % (10**9 + 7)
    print(ans)


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
namespace aizu
{
    class OnlineJudge
    {
        static readonly int[] BusStop = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1 };
        static readonly int StopCount = BusStop.Length;
        static void Main()
        {
            int count = int.Parse(Console.ReadLine());
            for(int i=0,now=0; i < count; ++i) {
                int[] input = Console.ReadLine().Split().Select(q => int.Parse(q)).ToArray();
                List<int> route = new List<int>();
                while(true) {
                    if(route.Count != 0) {
                        if(route[0] == BusStop[now]) {
                            route.Clear();
                        }
                        route.Add(BusStop[now]);
                    }
                    if(route.Count != 0 && input[1] == BusStop[now]) {
                        break;
                    }
                    if(route.Count == 0 && input[0] == BusStop[now]) {
                        route.Add(BusStop[now]);
                    }
                    now = now >= StopCount - 1 ? 0 : now + 1;
                }
                Console.WriteLine(string.Join(" ", route.Select(q => q.ToString()).ToArray()));
            }
        }
    }
}

Measured memory_bytes: 5968
#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

n,m = map(int,input().split())

#初期化
#根なら-size,子なら親の頂点
par = [-1]*n

for _ in range(m):
    a,b = map(int,input().split())
    unite(a-1,b-1)

arr = []
for i in range(n):
    if par[i]<0:
        arr.append(-par[i])
        
arr=sorted(arr)
ans=0
div=0
k=len(arr)
for j in range(k):
    if j!=k-1:
        if arr[j]-div!=0:
            ans+=arr[j]-div
            div+=arr[j]-div
    elif j==k-1:
        if arr[j]-div!=0:
            ans+=arr[j]-div


print(ans)
        


Measured memory_bytes: 14464
S = input()
K = int(input())

if len(S) == 1:
    print(K // 2)
    exit()
    
cnt, s, l, r = 1, S[0], 0, len(S)-1
while l + 1 <= r and S[l+1] == s:
    cnt += 1
    l += 1
while l <= r - 1 and S[r] == s:
    cnt += 1
    r -= 1
if cnt == len(S):
    print(len(S) * K // 2)
    exit()
changed = [False] * len(S)
for i in range(1, len(S)):
    if i > 1 and S[i] == S[i-1] == S[i-2] and changed[i-1]:
        continue
    elif S[i] == S[i-1]:
        changed[i] = True
ans = sum(changed)
res = ans * K
if changed[-1] or S[0] != S[-1] or cnt & 1:
    print(res)
    exit()
res += K - 1
print(res)
        

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<cstdio>
#include<iomanip>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int INF = 1e9 + 7;
int main() {
	double T;
	double X;
	cin >> T >> X;
	double ans = T / X;
	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sz(x) int(x.size())
#define pb push_back
#define ff first
#define ss second
typedef long long ll;
typedef pair<int,int> ii;
const int N=2e5+100;
const int mod=1e9+7;
int f[N],inv[N],ans[N];
int binpow(int a,int b){
	int ans=1;
	for(;b;b>>=1,a=(1LL*a*a)%mod)
		if(b&1)ans=(1LL*ans*a)%mod;
	return ans;
}

int cosmic(int u,int v){
	return 1LL*f[u+v]*inv[u]%mod*inv[v]%mod;
}

bool cmp(ii a,ii b){
	return a.ff<=b.ff&&a.ss<=b.ss;
}


int main(){
	f[0]=1;
	for(int i=1;i<200010;i++)
		f[i]=(1LL*f[i-1]*i)%mod;
	for(int i=0;i<200010;i++)
		inv[i]=binpow(f[i],mod-2);
	int h,w,n;cin>>h>>w>>n;h--,w--;
	vector<ii>vec(n);
	for(int i=0;i<n;i++){
		cin>>vec[i].ff>>vec[i].ss;
		vec[i].ff--,vec[i].ss--;
	}
	vec.pb({h,w});
	sort(vec.begin(),vec.end());
	for(int i=0;i<=n;i++){
		ans[i]=cosmic(vec[i].ff,vec[i].ss);
		for(int j=0;j<i;j++)if(cmp(vec[j],vec[i])){
			ans[i]-=1LL*ans[j]*cosmic(vec[i].ff-vec[j].ff,vec[i].ss-vec[j].ss)%mod;
			if(ans[i]<0)ans[i]+=mod;
		}
	}
	cout<<ans[n]<<endl;
	return 0;
}


Measured memory_bytes: 5264
MAX = 300000001

N, K = map(int, input().split())
xn = [int(i) for i in input().split()]


def main():
    if 0 <= xn[0]:
        print(xn[K - 1])
        return

    if xn[N - 1] < 0:
        print(abs(xn[N - K]))
        return

    ans = MAX

    for i in range(N - K + 1):
        ans = min(ans,
                  2 * abs(xn[i]) + abs(xn[i + K - 1]),
                  abs(xn[i]) + 2 * abs(xn[i + K - 1]))

    print(ans)
    return


main()


Measured memory_bytes: 14224
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];puts("");}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")

int f(int a){
	if(a%4==0)return a;
	if(a%4==1)return 1;
	if(a%4==2)return a+1;
	if(a%4==3)return 0;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int a,b;
	cin>>a>>b;
	cout<<(f(b)^f(max(0ll,a-1)))<<endl;
}


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

#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <ull> vu;
typedef vector <vector <int>> vvi;
typedef pair <int, int> pi;
typedef vector <pair <int, int>> vpi;

int n;

void read() {
  cin >> n;
}

void solve() {
  int sol = 0;
  for(int i = 1; i <= n; i += 2) {
    int nr = 2;
    for(int d = 2; d * d <= i; ++d) {
      if (i % d == 0) {
        ++nr;
        if (d * d != i)
          ++nr;
      }
    }
    sol = nr == 8 ? sol + 1 : sol;
  }
  cout << sol;
}

int main() {
  ios :: sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  //cin >> t; //please do not forget to comment this if there are no queries
  while(t) {
    --t;
    read();
    solve();
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < b; i++)
typedef pair<int,int> pii;

const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
template<int MOD> struct ModInt {
    static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
        return ModInt(u); }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, long long k) {
    ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
typedef ModInt<1000000007> mint;

int main(){
    int N; cin >> N;
    vector<ll> C(N);
    rep(i, 0, N){
        ll t; cin >> t;
        C[i] = t;
    }
    sort(C.begin(), C.end(), greater<ll>());
    
    mint ans = 0;
    rep(i, 0, N){
        ans = ans + (mint)(i + 2) * (mint)C[i];
    }
    mint t = 2;

    ans = ans * (t^(2*N-2));

    cout << ans << endl; 

}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    string s;
    int k;
    cin >> s >> k;
    int N = s.size();

    vector<int> v(26);  // 文字iを'a'に変えるのに必要な最小操作回数
    for(int i = 25; i >= 1; i--) {
        v[i] = 26 - i;
    }

    int nokori = k;  // 残り操作回数
    rep(i, N) {

        if(v[s[i] - 'a'] <= nokori) {  // i文字目を'a'に変えることができたら
            nokori -= v[s[i] - 'a'];  // 残り操作回数をv[s[i] - 'a']減らして
            s[i] = 'a';  // i文字目を'a'にする
        }

    }

    nokori %= 26;  // 26回操作するごとに'a'に戻るので、残り回数は26で割った余りとしてよい
    s[N-1] += nokori;  // sの最後の文字を、'a'に残り回数操作したものに変える
    
    cout << s << endl;
    return 0;
}

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

using namespace std;

int main()
{
    string s , t , u;
    cin >> s >> t;
    int S , T;
    cin >> S >> T;
    cin >> u;

    if(u == s)
        --S;
    else --T;

    cout << S << " " << T << "\n";

    return 0;
}


Measured memory_bytes: 256
n = int(input())
v = [[tuple(map(int, input().split()))for i in range(int(input()))]
     for i in range(n)]

ans = 0
for i in range(2**n):
    f = [0] * n
    xy = []
    for j in range(n):
        if (i >> j) & 1:
            f[j] = 1
            xy.append(v[j])
    flag = True
    for xyi in xy:
        for x, y in xyi:
            #print(f,x,y,bin(i))
            if (i>>(x-1))&1 != y:
                flag = False
                break
    if flag:
        ans = max(ans, len(xy))
print(ans)


Measured memory_bytes: 9160
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

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

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    string s,t;
    cin >> s;
    t = "";
    rp(i,s.length()){
        if(s[i] != 'B') t += string(1,s[i]);
        else if(t.length() > 0) t = t.substr(0,t.length()-1);
    }
    cout << t;
    cout <<endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const int MOD = 1000000007; 

int n, m, q;
vector<int> a, b, c, d;
int maxq = -1;

void fbd(vector<int>& as) {
    int len = as.size();
    if (len == n) {
        int ret = 0;
        rep(i, q) {
            if (as[b[i]-1]-as[a[i]-1] == c[i]) {
                ret += d[i];
            }
        }
        maxq = max(ret,  maxq);
    } else {
        int s = len==0 ? 1 : as[len-1];
        for(int i = s; i <= m; ++i) {
            as.push_back(i);
            fbd(as);
            as.pop_back();
        } 
    }
}


int main() {
   cin >> n >> m >> q;
   a.resize(q); b.resize(q); c.resize(q); d.resize(q);
   rep(i, q) {
      cin >> a[i]; 
      cin >> b[i]; 
      cin >> c[i]; 
      cin >> d[i]; 
   } 
   vector<int> as;
   fbd(as);
   cout << maxq << endl;
   return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    ll ans = 1e9 + 7;
    ll total = 0;
    for(int i = 0; i <= max(x, y); i++){
        total = 2*i*c + max(0, x-i) * a + max(0, y-i) * b;
        if(ans > total){
            ans = total;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  ll n,sum=0,max=0;
  cin>>n;
  ll a[n];
  for(ll i=0;i<n;i++) cin>>a[i];
  max=a[0];
  for(ll i=1;i<n;i++)
  {
    if(a[i]<max) sum+=max-a[i];
    if (a[i]>max) max=a[i];
  }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 5216
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int N,M;
vector<ll> D;
vector<int> g[100010];

const ll INF=1e15;
int col[100010];
const ll MA=1e9;

void dfs(int now,int c){
    col[now]=c;
    for(auto nex:g[now]){
        if(col[nex]==0) dfs(nex,-c);
    }
}

int main(){
  cin>>N>>M;
  D.resize(N);
  rep(i,N) cin>>D[i];
  map<pair<int,int>,int> mp;
  vector<vector<int>> v(N);
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    if(a>b) swap(a,b);
    mp[mkp(a,b)]=i;
    v[a].push_back(b);
    v[b].push_back(a);
  }

  vector<int> ans(M,0);
  for(int i=0;i<N;i++){
      pair<ll,int> mi=mkp(INF,0);
      for(auto nex:v[i]){
          if(D[nex]>D[i]) continue;
          mi=min(mi,mkp(D[nex],nex));
      }
      if(mi.first==INF){
          cout<<-1<<endl;
          return 0;
      }
      int a=min(i,mi.second),b=max(i,mi.second);
      if(a>b) swap(a,b);
      ans[mp[mkp(a,b)]]=D[i];
      g[a].push_back(b);
      g[b].push_back(a);
  }

  for(int i=0;i<N;i++){
      if(col[i]==0) dfs(i,1);
  }

  for(int i=0;i<N;i++){
    if(col[i]==1) cout<<'B';
    else cout<<'W';
  }
  cout<<endl;
  for(int i=0;i<M;i++){
      if(ans[i]==0) cout<<MA<<endl;
      else cout<<ans[i]<<endl;
  }

  return 0;
}


Measured memory_bytes: 28544
#include <stdio.h>
#include <string.h>

int main()
{
	int dataset = 0, out = 0, point = 0;
	int b1, b2, b3;
	char str[15];

	scanf( "%d", &dataset );
	for ( int i = 0 ; i < dataset ; i++ ) {
		out = 0;
		point = 0;
		b1 = b2 = b3 = 0;
		while ( out < 3 ) {
			scanf( "%s", str );

			if ( strcmp( str, "OUT" ) == 0 ) {
				out++;
			} else {
				if ( strcmp( str, "HIT" ) == 0 ) {
					if ( b3 == 1 ) { point++; }
					b3 = b2;
					b2 = b1;
					b1 = 1;
				} else if ( strcmp( str, "HOMERUN" ) == 0 ) {
					point += b1 + b2 + b3 + 1;
					b1 = b2 = b3 = 0;
				}
			}
		}

		printf( "%d\n", point );
	}

	return 0;
}



Measured memory_bytes: 2048
while line = gets
  a, b, p, c, d, q = line.split.map(&:to_f)
  z = a*d-b*c
  x = (p*d-b*q)/z + 0.0
  y = (a*q-p*c)/z + 0.0
  puts "%.3f %.3f" % [x, y]
end

Measured memory_bytes: 6132
#include <stdio.h>
int main(void)
{
	int a, b, d, r;//変数の宣言
	double f;
	scanf("%d %d", &a, &b);

	d = a / b;
	r = a % b;
	f = 1.00000 * a / b;

	printf("%d %d %If\n", d, r, f);
	return 0;//終了

}


Measured memory_bytes: 2068
#include<iostream>
#include<algorithm>

using namespace std;

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

long int n, m, v, p;
long int a[100000];
// 初期状態でp番目の要素のindex
long int mn;
// 上位i個の累積和
long int sm[100001];

bool C(long int x){
    long int poi = v - (p - 1) - (n - (x + 1)) - 1;
    

    long int dif;
    dif = sm[x] - sm[mn] - a[x] * (x - mn);
    long int imp = (x - mn) - poi;
    // cout << x << " " << poi << " " << imp << " " << dif << endl;
    if (a[x] == a[mn]){
        return true;
    }
    if (a[mn] - a[x] > m){
        return false;
    }
    if (poi <= 0){
        return true;
    }
    if (dif > imp * m){
        return false;
    }else{
        return true;
    }
}

int main(){
    cin >> n >> m >> v >> p;
    rep(i, n) cin >> a[i];
    sort(a, a + n, greater<long int>());
    sm[0] = 0;
    for (int i = 0; i < n; i++){
        sm[i+1] = sm[i] + a[i];
    }
    mn = p - 1;
    long int l = mn;
    long int r = n - 1;
    while(l < r - 1){
        long int mid = (l + r) / 2;
        if (C(mid)){
            l = mid;
        }else{
            r = mid;
        }
    }
    long int ans;
    if (C(r)){
        ans = r + 1;
    }else{
        ans = l + 1;
    }
    // rep(i, n) cout << a[i] << " ";
    // cout << endl;
    // rep(i, n + 1) cout << sm[i] << " ";
    // cout << endl;
    // cout << l << " " << r << endl;
    cout << ans << endl;
}

Measured memory_bytes: 1792
M, K = map(int, input().split())

if K >= 2 ** M:
    print(-1)
    quit()

if M == 0:
    if K == 0:
        print('0 0')
elif M == 1:
    if K == 0:
        print('0 0 1 1')
    if K == 1:
        print(-1)
else:
    b = [str(i) for i in range(2**M) if i != K]
    c = [str(i) for i in range(2**M-1, -1, -1) if i != K]
    print(' '.join(b) + ' ' + str(K) + ' ' + ' '.join(c) + ' ' + str(K))

Measured memory_bytes: 24452
n = int(input())
t = list(map(int, input().split()))
m = int(input())
px = [list(map(int, input().split())) for _ in range(m)]
for i in range(m):
    idx = px[i][0]-1
    print(sum(t[:idx]) + px[i][1] + sum(t[(idx+1):]))


Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 4e18;

int main() {
    string s; cin >> s;
    int ans = 0;
    if (s[0] == s[s.size()-1]) {
        if (s.size()%2 == 1) {
            puts("Second");
        }
        else {
            puts("First");
        }
    }
    else {
        if (s.size() % 2 == 0) {
            puts("Second");
        }
        else {
            puts("First");
        }
    }
    getchar(); getchar();
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long int
int main()
{
   ll n;
   cin>>n;
   vector<ll>v(n+1);
   for(int i=1;i<=n;i++)
    cin>>v[i];
   if(n%2==0)
   {
       sort(v.begin(),v.end());
       //cout<<v[(n/2)+1]<<v[n/2]<<endl;
       cout<<v[n/2+1]-v[n/2];
   }
    else
        cout<<0;
}


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

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

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

char next_char(char now, char pre, string s, int k) {
    if (s[k]=='o') {
        if (now=='S') return pre;
        else if (pre=='W') return 'S';
        else return 'W';
    }
    else {
        if (now=='W') return pre;
        else if (pre=='W') return 'S';
        else return 'W';
    }
}

int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    
    map<int,string> mp;
    mp[0] = "S";
    mp[1] = "W";

    rep(i,2) rep(j,2) {
        string ans = mp[i] + mp[j];
        rep(k,N-1) {
            char now = ans[k+1];
            char pre = ans[k];
            char next = next_char(now,pre,s,k+1);
            if (k==N-2) {
                if (next==ans[0]) {
                    pre = now;
                    now = ans[0];
                    next = next_char(now,pre,s,0);
                    if (next==ans[1]) {
                        cout << ans << endl;

                        return 0;
                    }
                }
            }
            else {
                ans += next;
            }
        }
    }
    cout << -1 << endl;
    return 0;
}


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

using namespace std;

#define rep(i, a, n) for (int i = a, _n = n; i <= _n; ++i)
#define drep(i, a, n) for (int i = a, _n = n; i >= _n; --i)
#define debug(x) cout << #x << " = " << x << endl

int n;

int a[100005];

int main () {
	scanf ("%d", &n);
	if (n & 1) {
		puts("0");
		return 0;
	}

	rep(i, 1, n) scanf ("%d", a + i);

	sort(a + 1, a + n + 1);

	printf ("%d\n", a[n / 2 + 1] - a[n / 2]);
	return 0;
}


Measured memory_bytes: 640
N = int(input())
A = list(map(int,input().split()))
l = [0]*(10**5)
for e in A:
    if e == 0:
        l[0] += 1
        l[1] += 1
    elif e == 99999:
        l[99999] += 1
        l[99998] += 1
    else:
        l[e-1] += 1
        l[e] += 1
        l[e+1] += 1
print(max(l))

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

using namespace std;
typedef long long ll;

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

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

void pV(vector<ll> A){
    cout << "[vector]";
    for(int i=0; i<A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

const int N_MAX = 200010;
vector<ll> beki;

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

    // べき集合を作る
    FOR(i, 1, 31){
        beki.push_back(pow(2, i));
    }

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    sort(ALL(A));

    // カウント
    map<int, int> mp;

    FOR(i, 0, N){
        mp[A[i]]++;
    }

    int answer = 0;

    // 値の大きい順にペアを探す
    for(int i=A.size()-1; i>=0; i--){

        // 残ってる？
        if(mp[A[i]]==0){
            continue;
        }

        for(int j=beki.size()-1; j>=0; j--){
            ll candidate = beki[j] - A[i];

            // 自身との結婚はできません
            if(A[i] == candidate && mp[candidate]==1){
                // 次へ
            }
            // いますかー？
            else if(mp[candidate]>0){
                //cout << "結婚しました 値 " << A[i] << " " << candidate << endl;
                // 結婚
                answer++;
                mp[candidate]--;
                mp[A[i]]--;
                goto koko;
            }else{
                // いないなら別の候補へ
            }
        }
        // goto
        koko:
            int a = 0;
    }

    p(answer);
    
    return 0;
}

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

using namespace std;

int a,b;
string s;

int main(){
    cin>>a>>b>>s;

    if(s[a]!='-'){
        cout<<"No"<<endl;
        return 0;
    }

    for(int i=0;i<a;i++){
        if(s[i]<'0'||s[i]>'9'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    for(int i=a+1;i<a+b;i++){
        if(s[i]<'0'||s[i]>'9'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
import Foundation

func readString() -> String {
  return readLine()!
}
func readTokens() -> [String] {
  return readString().componentsSeparatedByString(" ")
}
func readIntArray() -> [Int] {
  return readTokens().map { Int($0)! }
}
func readInt() -> Int {
  return Int(readString())!
}
func readInt(n: Int) -> [Int] {
  return (0..<n).flatMap { _ in Int(readString())! }
}

func printWitch<T>(b: Bool, l: T, r: T) {
  print(b ? l : r)
}

///
printWitch(readIntArray().reduce(1, combine: *) % 2 == 0,
           l: "Even",
           r: "Odd")

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define int long long
using namespace std;
int Knapsack(int* w,int* v,int n,int W)
{
    int dp[n+1][W+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=W;j++){
            if(i==0 || j==0)dp[i][j] = 0;
            else if(j>=w[i-1])dp[i][j] = max(dp[i-1][j],v[i-1]+dp[i-1][j-w[i-1]]);
            else dp[i][j] = dp[i-1][j];
        }
    }
    return dp[n][W];
}
signed main()
{
    int n,W;
    cin>>n>>W;
    int w[n],v[n];
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
    }
    cout<<Knapsack(w,v,n,W);
}

Measured memory_bytes: 79104
N, M, Q = map(int, input().split())
city = [[0] * (N+1) for i in range(N+1)]
for i in range(M):
  l, r = map(int, input().split())
  city[l][r] += 1

for i in range(N+1):
  for j in range(N):
    city[i][j+1] += city[i][j]

for i in range(N+1):
  for j in range(N):
    city[j+1][i] += city[j][i]

for i in range(Q):
  p, q = map(int, input().split())
  print(city[q][q] - city[p-1][q] - city[q][p-1] + city[p-1][p-1])

Measured memory_bytes: 13300
#include <stdio.h>

int main(){
  char s[3],t[3];
  if(scanf("%s",s)==1 && scanf("%s",t)==1){}
  int i;int sum=0;
  for(i=0;i<3;i++){
    if(s[i]==t[i]){
      sum++;
    }
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

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

        int n = s.nextInt();
        int x = s.nextInt();
        int t = s.nextInt();
        int res=(n/x);
        if(n%x!=0)
            res++;
        System.out.println(res*t);
    }
    static int gcd(int a, int b)
    {
        if(b==0) {
            return a;
        }
        return gcd(b,a%b);
    }
    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }


    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

Measured memory_bytes: 27060
void main()
{
    long a, b, c, d;
    rdVals(a, b, c, d);

    --a;
    long l = c / gcd(c, d) * d;
    long x = b - b / c - b / d + b / l;
    long y = a - a / c - a / d + a / l;

    writeln(x - y);
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MEM 100006
#define sanic ios_base::sync_with_stdio(0)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
const ll MOD = 1e9+7;
ll n,m;
string s;
int main()
{
    sanic; cin.tie(0);
    cin >> n;
    while(n>0){
        n--;
        s += (char)(97+n%26);
        n /= 26;
    }
    reverse(s.begin(), s.end());
    cout << s;
}


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

int64_t MOD = 1000000000 + 7;

int64_t f1(int64_t x, int64_t y) {
  if(y == 0) {
    return 1;
  }
  else {
    int64_t ans = f1(x, y / 2) * f1(x, y / 2) % MOD;
    if(y % 2 == 1) {
      ans *= x;
      ans %= MOD;
    }
    return ans;
  }
}

int main() {
  int64_t N, M, K;
  cin >> N >> M >> K;
  int64_t A = 1;
  for(int64_t i = 0; i < K - 2; i++) {
    A *= N * M - 2 - i;
    A %= MOD;
  }
  int64_t B = 1;
  for(int64_t i = 1; i <= K - 2; i++) {
    B *= i;
    B %= MOD;
  }
  A *= f1(B, MOD - 2);
  A %= MOD;
  int64_t X = (N - 1) * N * (N + 1) / 6;
  X %= MOD;
  X *= M;
  X %= MOD;
  X *= M;
  X %= MOD;
  X *= A;
  X %= MOD;
  int64_t Y = (M - 1) * M * (M + 1) / 6;
  Y %= MOD;
  Y *= N;
  Y %= MOD;
  Y *= N;
  Y %= MOD;
  Y *= A;
  Y %= MOD;
  cout << (X + Y) % MOD << endl;
}


Measured memory_bytes: 3608
def cmbp(n,k):
    nCk = 1
    MOD = 10**9+7

    for i in range(n-k+1, n+1):
        nCk *= i
        nCk %= MOD

    for i in range(1,k+1):
        nCk *= pow(i,MOD-2,MOD)
        nCk %= MOD
    return nCk
x,y=map(int,input().split())
if (x+y)%3==0:
  n=int((2*y-x)/3)
  m=int((2*x-y)/3)
  if n>=0 and m>=0:
    print(cmbp(m+n,n))
  else:
    print(0)
else:
  print(0)
    

Measured memory_bytes: 9148
#include <iostream>
#define NIL -1
using namespace std;

struct NODE{
    int left;
    int right;
    int parent;
};


struct NODE A[25];
int DEPTH[25];
int HEIGHT[25];

void setDepth(int root, int depth){
    if (root == NIL){
        return;
    }
    DEPTH[root] = depth;
    
    setDepth(A[root].left, depth + 1);
    setDepth(A[root].right, depth + 1);

}

int sibling(int u){   
    if (A[u].parent == NIL){
        return NIL;
    }else if ((A[A[u].parent].left != u) && (A[A[u].parent].left != NIL)){
        return A[A[u].parent].left;
    }else if ((A[A[u].parent].right != u) && (A[A[u].parent].right != NIL)){
        return A[A[u].parent].right;
    }else{
        return NIL;
    }
  
}

int degree(int u){
    if (A[u].left != NIL && A[u].right != NIL){
        return 2;
    }else if (A[u].left == NIL && A[u].right == NIL){
        return 0;
    }else{
        return 1;
    }
}

int max(int h1, int h2){
    if (h1 >= h2){
        return h1;
    }else{
        return h2;
    }
}

int sethight(int u){
    int h1 = 0, h2 = 0;

    if (A[u].left != NIL){
        h1 = sethight(A[u].left) + 1;
    }
    if (A[u].right != NIL){
        h2 = sethight(A[u].right) + 1;
    }

    return max(h1, h2);
}

void print(struct NODE *A, int n){
    int i;
    for (i = 0; i < n; i++){    
        cout << "node " << i << ": ";
        cout << "parent = " << A[i].parent << ", ";
        cout << "sibling = " << sibling(i) << ", ";
        
        cout << "degree = " << degree(i) << ", ";
        cout << "depth = " << DEPTH[i] << ", ";
        cout << "height = " << sethight(i) << ", " ;

        if (A[i].parent == NIL){;
            cout << "root" << endl;
        }else if ((A[i].left == NIL) && (A[i].right == NIL)){
            cout << "leaf" << endl;
        }else{
            cout << "internal node" << endl;
        }
    }
}

int main(void){
    
    int n;
    int i;
    int id, left, right;
    int root;

    cin >> n;

    for (i = 0; i < n; i++){
        A[i].parent = NIL;
    }

    for (i = 0; i < n; i++){
        cin >> id >> left >> right;
        A[id].left = left;
        A[id].right = right;

        if (left != NIL){
            A[left].parent = id;
        }
        if (right != NIL){
            A[right].parent = id;
        }
    }

    for (i = 0; i < n; i++){
        if (A[i].parent == NIL){
            root = i;
        }
    }

    setDepth(root, 0);


    print(A, n);

    return 0;
}

/*
9
0 1 4
1 2 3
2 -1 -1
3 -1 -1
4 5 8
5 6 7
6 -1 -1
7 -1 -1
8 -1 -1
*/




Measured memory_bytes: 3100
import sys
inp = sys.stdin.readline

S = inp().replace('\n', '')

cnt = 0
for i in range(1 << len(S)-1):
  tmp = S[0]
  for j in range(len(S)-1):
    if(((i >> j) & 1) == 1):
      tmp += '+'
    tmp += S[j+1]
  cnt += sum(map(int, tmp.split('+')))
print(cnt)

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

int main(void)
{
    int A,B,K;
    cin >> K;
    cin >> A >> B;
    int flag = 0;
    int i;

    for(i=A;i<=B;i++){
        if(i%K==0){
            flag=1;
            break;
        }
    }

    if(flag == 1){
      cout << "OK" << endl;
    }
    else{
      cout << "NG" << endl;  
    }

    return 0;

}

Measured memory_bytes: 3648
package main

import "fmt"

// Solve the problem of ABC128 C
func main() {
	var n, m int
	fmt.Scan(&n, &m)
	klist := make([]int, m)
	slist := make([][]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&klist[i])
		slist[i] = make([]int, klist[i])
		for j := 0; j < klist[i]; j++ {
			fmt.Scan(&slist[i][j])
		}
	}
	plist := make([]int, m)
	for l := 0; l < m; l++ {
		fmt.Scan(&plist[l])
	}

	count := 0
	for bits := 0; bits < (1 << uint64(n)); bits++ {
		state := make([]int, n)
		for i := 0; i < n; i++ {
			state[i] = bits >> uint64(i) & 1
		}
		ok := true
		for j := 0; j < m; j++ {
			sum := 0
			for _, sNo := range slist[j] {
				sum += state[sNo-1]
			}
			if sum%2 != plist[j] {
				ok = false
				break
			}
		}
		if ok {
			count++
		}
	}
	fmt.Println(count)
}


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

using namespace std;

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef long long ll;
typedef pair<int, int> pii;

const int N = 2e5 + 5;
int arr[N], ans[N];
int n;

int main() {

#ifndef ONLINE_JUDGE
    //freopen("in.in", "r", stdin);
    //freopen("out.in", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    vi a;
    cin >> n;
    range(i, 1, n)cin >> arr[i];
    for (int i = n; i >= 1; i--) {
        int sum = 0;
        for (int j = i; j <= n; j += i) {
            sum += ans[j];
        }

        if (sum % 2 == arr[i]) {
            ans[i] = 0;
        } else if ((sum + 1) % 2 == arr[i]) {
            a.push_back(i);
            ans[i] = 1;
        } else {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << SZ(a) << endl;
    for (int idx : a)cout << idx << " ";
    cout << endl;


    return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  double n;
  cin >> n;
  double a = floor(n/1.08);
  if (floor((a-1)*1.08) == n) {
    cout << int(a-1) << endl;
    return 0;
  }
  if (floor(a*1.08) == n) {
    cout << int(a) << endl;
    return 0;
  }
  if (floor((a+1)*1.08) == n) {
    cout << int(a+1) << endl;
    return 0;
  }
  cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename key> using ordered_set = tree <key, null_type, less<key>, rb_tree_tag, tree_order_statistics_node_update>;
 
int main () {
   IO;
   int n;
   string s, t;
   cin >> n >> s >> t;
   for(int i = 0; i < n; i++)
	  cout << s[i] << t[i];
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100006
using namespace std;
int n,c,k,v,st,ans,a[N];long long f[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)f[i]=f[i-1]+1LL*a[i];
	ans=1;
	for(int i=n-1;i>=1;i--){
		if(f[i]*2LL>=1LL*a[i+1])ans++;
		else break;
	}
	printf("%d\n",ans);
}

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

using ll = long long;

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

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    ll a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
}

Measured memory_bytes: 256