akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int n;
vector<int> g[210000];
bool used[210005];
ll cnt_x, cnt_y;

void dfs(int v) {
	if (v >= 100001) cnt_y++;
	else cnt_x++;
	used[v] = true;
	for (int c : g[v]) {
		if (used[c]) continue;
		dfs(c);
	}
	return;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		b += 100000;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	memset(used, 0, sizeof(used));
	ll ans = 0;
	rep(i, 100001) {
		if (g[i].size() && !used[i]) {
			cnt_x = 0, cnt_y = 0;
			dfs(i);
			ans += (cnt_x * cnt_y);
		}
	}
	ans -= n;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 10496
#pragma GCC optimize("O2")
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cmath>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    for (int i=0;s[i];i++) {
        cout << '9'-s[i]+1;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
maze = [input() for _ in range(h)]

from collections import deque

que = deque()
que.append((0,0))

d = [[0]*w for _ in range(h)]

direction = [(1, 0), (0, 1), (-1, 0), (0, -1)]
d[0][0] = 1

flag = False
while que:
    x, y = que.popleft()

    if x == h-1 and y == w-1:
        flag = True
        break

    for i, j in direction:
        dx, dy = x + i, y + j
        if 0<=dx<h and 0<=dy<w and d[dx][dy] == 0 and maze[dx][dy] != '#':
            d[dx][dy] = d[x][y] + 1
            que.append((dx, dy))

if flag == False:
    print(-1)
    exit()

res = 0
for i in range(h):
    res += maze[i].count('#')

res += d[-1][-1]


print(h*w - res)



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

int main() {
  int n;
  cin >> n;
  
  int x = n / 1.08 + 0.99;
  if ((int)(x * 1.08) == n)
    cout << x << endl;
  else
    cout << ":(" << endl;
  
  return 0;
}

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

int main() {

  int N, Y;
  cin >> N >> Y;
  int a = -1;

  for (int i = 0; i <= N; i++) {
      for (int j = 0; j <= N-i; j++) {
          int k = N-i-j;
          if(a == 0)
            break;
          else if (Y==10000*i+5000*j+1000*k) {
            cout << i << " " << j <<" " << k << endl;
            a = 0;
          }
      }
      if(a == 0) break;
  }
  if (a == -1)
     cout << "-1 -1 -1" << endl;
  return 0;           
}

Measured memory_bytes: 256
num = gets.to_i

data = readlines

data_set = []

data.each do |d|
  a,b = d.chomp.split(" ").map(&:to_i)
  data_set << (a == b)
end

count = 0
res = "No"

data_set.each do |d|
  if d
    count += 1
    if count >= 3
      res = "Yes"
    end
  else
    count = 0
  end
end

puts res

Measured memory_bytes: 14260
#include <bits/stdc++.h>
using namespace std;
int R;
int main() {
    cin >> R;
    if(R < 1200) {
        cout << "ABC" << endl;
    }else if(R < 2800) {
        cout << "ARC" << endl;
    }else {
        cout << "AGC" << endl;
    }
}

Measured memory_bytes: 256
import itertools
import math

#方針: A*B = B (A,Bは整数, A>=N)となる最大のBを探せばいい

N, M = map(int, input().split())

P = []
F = []
M_ = M
for n in range(2, int(math.sqrt(M))+1):
    num = 0
    while M_ % n == 0:
        M_ /= n
        num +=1
    if num != 0:
        P.append(n)
        F.append(num)
if M_ != 1:
    P.append(M_)
    F.append(1)

min_A = M
for F_ in itertools.product(*list(map(lambda i: range(i+1), F))):
    A = 1
    for p,f in zip(P,F_): A *= pow(p,f)
    if A >=N and A < min_A: min_A = A

print(int(M/min_A))
    


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

#define rep(i,n) for(int (i)=0;(i)<(n); ++(i))
using namespace std;

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

    vector<int> h(n+1, 0);
    rep(i, n) {
        cin >> h[i+1];
    }

    map<int, int> mp;
    for(int i=1; i<=n; i++) {
        mp[i] = 0;
    }

    int a, b;
    rep(i, m) {
        cin >> a >> b;
        if(h[a] > h[b]) {
            mp[b] += 1;
        } else if(h[a] < h[b]) {
            mp[a] += 1;
        } else {
            mp[a] += 1;
            mp[b] += 1;
        }
    }

    int count = 0;
    for(int i=1; i<=n; i++) {
        if(mp[i] == 0)
            count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 7896
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final String a = scanner.next();
        final String b = scanner.next();
        final String c = scanner.next();

        int min = Integer.MAX_VALUE;
        for (final int candidate : Arrays.asList(solve(a, b, c), solve(a, c, b), solve(b, a, c), solve(b, c, a), solve(c, a, b), solve(c, b, a))) {
            min = Math.min(min, candidate);
        }

        System.out.println(min);
    }

    private static int solve(final String a, final String b, final String c) {
        final int all = a.length() + b.length() + c.length();
        final boolean[] ab = init(all, a, b);
        final boolean[] ac = init(all, a, c);
        final boolean[] bc = init(all, b, c);

        int min = Integer.MAX_VALUE;
        for (int i = 0; i <= a.length(); i++) {
            for (int j = 0; j <= Math.max(b.length(), a.length() - i); j++) {
                if (ab[i] && bc[j] && ac[i + j]) {
                    min = Math.min(min, max(a.length(), i + b.length(), i + j + c.length()));
                }
            }
        }
        return min;
    }

    private static int max(final int... array) {
        int max = 0;
        for (final int i : array) {
            max = Math.max(i, max);
        }
        return max;
    }

    private static boolean[] init(final int length, final String a, final String b) {
        final boolean[] array = new boolean[length];
        Arrays.fill(array, true);
        for (int i = 0; i < a.length(); i++) {
            for (int j = 0; j < b.length() && i + j < a.length(); j++) {
                if (!match(a.charAt(i + j), b.charAt(j))) {
                    array[i] = false;
                    break;
                }
            }
        }

        return array;
    }

    private static boolean match(final char a, final char b) {
        return a == '?' || b == '?' || a == b;
    }
}


Measured memory_bytes: 58196
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long ll;
typedef std::pair<int,int> pii;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    a-=b;
    while(a>0){
        a-=c;
    }
    cout<<((a!=0)?a+c:a)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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; }

__attribute__ ((constructor))
void init() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

//n -> big, a -> small
mint choose(int n,int a){
    mint x = 1, y = 1;
    rep(i,a){
        x *= n-i;
        y *= i+1;
    }
    return x / y;
}

signed main(){
    int n, k;
    cin >> n >> k;
    FOR(i,1,k+1){
        cout << ((choose(k - 1, i - 1) * choose(n - k + 1, i)).x) % (ll(1e9 + 7)) << endl;
    }
    return 0;
}

Measured memory_bytes: 3600
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		int N = GetInt();
		long[] A = new long[N];
		long[] B = new long[N];
		for(int i = 0; i < N; i++)
		{
			A[i] = GetLong();
			B[i] = GetLong();
		}

		long num = 0;
		for(int i = N - 1; i >= 0; i--)
		{
			long tmp = A[i] + num;
			long r = tmp % B[i];
			num += (r != 0) ? B[i] - r : 0;
		}

		Console.WriteLine(num);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 17284
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++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(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    ll n, p;
    cin >> n >> p;
    if (n == 1){
        cout << p << endl;
    }else{
        ll ans = 1;
        for (ll x = 2; x <= 1000001; x++){
            ll y = p;
            bool ok = true;
            REP(i,n){
                if (y % x == 0){
                    y /= x;
                }else{
                    ok = false;
                    break;
                }
            }
            if (ok) ans = x;
        }
        cout << ans << endl;
    }
    return 0;
}


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

typedef long long int ll;
typedef unsigned long long ull;
typedef double db;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
#define fi first
#define sc second 
#define w(n) while(n--)
#define f(i,n) for(ll i=1;i<=n;i++)
#define fr(i,n) for(ll i=0;i<n;i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
db pie=3.141592653589793238;
int main()
{
	 ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   ll t;
   t=1;
  //cin>>t;
   w(t)
   {
   		ll n;
   		cin>>n;
   		ll cnt=0;
   		f(i,n)
   		{
   		    ll x;
   		    cin>>x;
   		    if(x%2!=0 && i%2!=0)
   		    cnt++;
   		}
   		std::cout << cnt << std::endl;
   }
}

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

A_=[]
a_=0
for a in A:
    a_+=a
    A_.append(a_)

Z=A_[-1]
ans=10**20
for a_ in A_[:-1]:
    if ans > abs(Z-2*a_):
        ans = abs(Z-2*a_)
print(ans)

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

int main(){
    int a, b;
    cin >> a >> b;
    int count = 0;
    for(int i = a;i <= b;i++){
        if(i / 10000 == i % 10 && (i % 100) / 10 == (i % 10000) / 1000){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3624
mod = 10**9+7
import sys
from collections import Counter, defaultdict, deque
from itertools import product, permutations, combinations, combinations_with_replacement
from itertools import accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil,floor
from copy import deepcopy
from heapq import heappop,heappush,heapify
import heapq


# l = ['a', 'a', 'a', 'a', 'b', 'c', 'c']
# c = Counter(l)

# d = defaultdict(int)

sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

# リストの要素を改行を挟んで表示する
p2D = lambda x: print(*x, sep="\n")
# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

# 入力全てを整数に変換したものの配列を受け取る
# def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI(): return list(map(lambda x:int(x), sys.stdin.readline().split()))
def HI(): return list(map(lambda x:int(x)*(-1), sys.stdin.readline().split()))

x = II()
def make_divisors(n):
	divisors = []
	for i in range(1, int(n**0.5)+1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n//i)

	# divisors.sort()
	return divisors

if x==0:
	print(0,0)
else:
	div = make_divisors(x)
	tmp = []
	for l in div:

		tmp.append(-1*l)
	div += tmp
	p = 0
	a = None
	b = None
	while(1):
		for l in div:
			s = p**5 - (p-l)**5
			# mp = -p
			# print(s)
			if s ==x:
				# print('!!!!!')
				a=p
				b=p-l
			if s==(-x):
				# print(p,l)
				b=p
				a=p-l

			# s = mp**5-(mp-l)**5
			# if s ==x:
			# 	a=mp
			# 	b=mp-l
			# elif s==(-x):
			# 	b=mp-l
			# 	a=mp

		if a is not None:
			break
		p += 1
	print(a,b)















Measured memory_bytes: 69292
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <cassert>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
typedef complex<double> P;
typedef vector<P> G;
const double EPS = 1e-8;
const double INF = 1e18;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
  L(){}
};

double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}

//内積
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
    ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}

P crosspointLL(const L &l, const L &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0] + B / A * (m[1] - m[0]);
}


vector<double> check(L l, vector<L> &ls){
  vector<double> res;
  REP(i, ls.size()) if(intersectSS(ls[i], l)) res.push_back(crosspointLL(ls[i], l).real());
  SORT(res);
  return res;
}

int main() {
  int N;
  while(cin >>N && N){
    int ans = 0;
    vector<P> _ps(N);
    REP(i, N){
      double x, y; cin >>x >>y;
      _ps[i] = P(x + 2000, y + 2000);
    }
    vector<L> ls(N);
    REP(i, N) ls[i] = L(curr(_ps, i), next(_ps, i));
    REP(i, 4010){
      vector<double> tps = check(L(P(0, i + EPS), P(5000, i)), ls), bps = check(L(P(0, i + 1 - EPS), P(5000, i + 1)), ls);
      if(tps.size() < 2) continue;
      vector<bool> v(5000, 0);
      for(int j = 0 ; j < (int)tps.size(); j += 2){
        int r = ceil(max(tps[j + 1], bps[j + 1])) , l = floor(min(tps[j], bps[j]));
        FOR(k, l, r) if(!v[k]) { v[k] = 1; ++ans; }
      }
    }
    cout <<ans <<endl;
  }
  return 0;
}

Measured memory_bytes: 1292
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)

typedef long long ll;
typedef pair<ll, int> P;
//typedef complex<double> C;

const double pi = acos(-1);

int N;
ll x[100010];
ll sum_x = 0;

void input() {
	cin >> N;
	REP(i, N) {
		cin >> x[i];
		sum_x += x[i];
	}
}

const int MAX_N = 1 << 17;

int width;
ll dat[2 * MAX_N - 1];

void init(int n_) {
    // let width be the power of 2
    width = 1;
    while (width < n_) width *= 2;

    // set all values by INF(0)
    REP(i, 2 * width - 1) dat[i] = 0;
}

// change the k-th(0-index) value to a
void update(int k, ll a) {
    // set a in the leaf
    k += width - 1;
    dat[k] = a;

    // update upward
    while (k > 0) {
        k = (k - 1) / 2;
        dat[k] = max(dat[2 * k + 1], dat[2 * k + 2]);
    }
}

// get the minimum(maximum) value in [a, b)
// k: num of the node corresponds to [l, r)
// call like this: 'query(a, b, 0, 0, n)'
ll query(int a, int b, int k, int l, int r) {
    // if [a, b) & [l, r) = 0, then return nonsense value
    if (r <= a || b <= l) return 0;

    // if [a, b) covers the whole [l, r),
    // then return the value of this node
    if (a <= l && r <= b) return dat[k];

    // otherwise, return the min of two children
    ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);

    return max(vl, vr);
}


void solve() {
	// DP with segtree
	ll ma = 0;

	// dp[i] = max(dp[j] s.t. j < i && x[j] < x[i]) + 1
	init(N);
	REP(i, N) {
		ll dpi = query(0, (int)x[i], 0, 0, width) + x[i];
		ma = max(ma, dpi);
		update((int)x[i] - 1, dpi);
	}

	cout << sum_x - ma << endl;
}


int main() {
	input();
    solve();
    return 0;
}

Measured memory_bytes: 5932
#include<iostream>
using namespace std;
int n,q,a[20],dp[21][2001];
int solve(int x,int y){
  if(x>n||y<0) return 0;
  if(y==0) return dp[x][y]=1;
  if(dp[x][y]>=0) return dp[x][y];    
  return dp[x][y]=solve(x+1,y)||solve(x+1,y-a[x]);
}    
int main(){
  for(int i=0;i<21;++i)
    for(int j=0;j<2001;++j) dp[i][j]=-1;
  cin>>n;
  for(int i=0;i<n;++i) cin>>a[i];
  cin>>q;
  for(int i=0;i<q;++i){
    int m; cin>>m;
    cout<<(solve(0,m)?"yes":"no")<<endl;
  }
  return 0;
}



Measured memory_bytes: 3280
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#define DEBUG_OUT(...)  (printf(__VA_ARGS__))
#else
#define VS_ENDPAUSE()
#define DEBUG_OUT(...)
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
//#define int int64

#ifndef INT8_MIN
#define INT8_MIN	(-127)
#endif
#ifndef INT8_MAX
#define INT8_MAX	( 128)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX	( 255)
#endif
#ifndef INT16_MIN
#define INT16_MIN	(-32768)
#endif
#ifndef INT16_MAX
#define INT16_MAX	( 32767)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX	( 65535)
#endif
#ifndef INT32_MIN
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#endif
#ifndef INT32_MAX
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#endif
#ifndef UINT32_MAX
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#endif
#ifndef INT64_MIN
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#endif
#ifndef INT64_MAX
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#ifndef UINT64_MAX
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int32 main(void)
{
    func();
    VS_ENDPAUSE();
    return 0;
}

//DEBUG_OUT("----\n");
#include <bits/stdc++.h>
void func(void)
{
    __int128 x, y;
    uint64 _x, _y;
    cin >> _x >> _y;

    x = _x;
    y = _y;
    double X = (double)x;
    double Y = (double)y;

    double log10_2 = (double)log10(2);
    double logyx = (double)log10(Y/X)/log10_2;
    uint16 n = (uint16)floor(logyx);

    if(x*(__int128)pow(2, n+1) <= y){
        cout << n + 2 << endl;
    }else if(x*(__int128)pow(2, n) <= y){
        cout << n + 1 << endl;
    }else{
        cout << n - 0 << endl;
    }
}



Measured memory_bytes: 512
use std::cmp;

fn main(){
  let n: u32 = read();

  let mut mv: u32 = dsum(1) + dsum(n-1);
  
  for i in 2 .. n / 2 + 1 {
    mv = cmp::min(mv, dsum(i) + dsum(n-i));
  }
  
  println!("{}", mv);
}

fn dsum(x: u32) -> u32 {
  let mut q :u32 = x / 10;
  let mut r :u32 = x % 10;
  let mut ans :u32 = r;

  while q > 0 {
    r = q % 10;
    ans += r;
    q /= 10;
  }
  ans
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}


Measured memory_bytes: 4352
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        int r = scanner.nextInt();
        int c = scanner.nextInt();

        int[][] table = new int[r+1][c+1];
        for(int i = 0; i < r; i++){
            int sum = 0;
            for(int j = 0; j < c; j++){
                table[i][j] = scanner.nextInt();
                sum += table[i][j];
            }
            table[i][c] = sum;
        }
        for(int i = 0; i < c+1; i++){
            int sum = 0;
            for(int j = 0; j < r; j++){
                sum += table[j][i];
            }
            table[r][i] = sum;
        }

        for(int i = 0; i < r+1; i++){
            for(int j = 0; j < c+1; j++){
                if(j != c)System.out.print(table[i][j]+" ");
                else System.out.println(table[i][j]);
            }
        }

    }
}



Measured memory_bytes: 42308
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=(1ull<<63)-1;
const int inf=(1ull<<31)-1;
int n,a[50],s=0,ans=0;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>a[i];
		s+=a[i];
	}
	for (int i=0;i<n;i++){
		s-=a[i];
		ans+=s*a[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import collections

n = int(input())
s = [input() for _ in range(n)]

c = collections.Counter(s)
c2 = c.most_common()

max_c = [c2[0][0]]
#print(len(c.values()))

for i in range(len(c.values())-1):
    if c2[i][1] == c2[i+1][1]:
        max_c.append(c2[i+1][0])
    else :
        break

max_c= sorted(max_c)

for i in max_c:
    print(i)


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

int main(void){
	int H,W;
	while(1){
		cin >> H >> W;
		if(H == 0 && W == 0) break;
		for(int i = 0;i < H;i++){
			for( int j = 0;j < W;j++){
				if((i + j) % 2 == 0 ){
						cout << "#";
				}else{
						cout << ".";
				}
			}
		cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
#define endl "\n"
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll n;
	cin>>n;
	ll x,y,z,ans=0;
	for(int a=1;a<=n;a++)
	{
		for(int b=1;b<=n;b++)
		{
			for(int c=1;c<=n;c++)
			{
				x=__gcd(a,__gcd(b,c));
				ans+=x;
			}
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3692
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
for i in range(n):
    ans += b[i]
for i in range(n-1):
    if a[i] +1 == a[i+1]:
        ans += c[a[i]-1]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define ll long long
#define cpp boost::multiprecision::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
const double PI = 3.1415926535897932384626433832795;
struct edge {
	int to;
	ll cost;
};
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
int main() {
	COME_LET_THE_GAMES_BEGIN();
	int N, Y;
	cin >> N >> Y;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= N - i; j++) {
			int k = N - i - j;
			if (10000 * i + 5000 * j + 1000 * k == Y) {
				cout << i << " " << j << " " << k << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifdef ztzshiwo
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int n,a[110],dp[110][2];
int main()
{
	file();
	read(n);
	For(i,1,n)read(a[i]);
	dp[0][0]=1;
	For(i,1,n)
	{
		dp[i][1]+=dp[i-1][1]*3;
		dp[i][0]+=dp[i-1][0]*(2-(a[i]&1));
		dp[i][1]+=dp[i-1][0]*(1+(a[i]&1));
	}
	printf("%d\n",dp[n][1]);
	return 0;
}


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

int main() {
  string s;
  int q;
  cin >> s >> q;
  bool rev = false;
  
  rep(i, q) {
    int query;
    cin >> query;
    if(query == 1) {
      rev = !rev;
    } else {
      int f;
      string c;
      cin >> f >> c;
      if(f == 1 && !rev || f == 2 && rev) s.insert(0, c);
      else s.insert(s.size(), c);
    }
    
//    cout << s << endl;
  }
  
  if(rev) reverse(s.begin(), s.end());
  
  cout << s << endl;
  
  return 0;
}


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

int main(){
    int n;
    cin>>n;
    for(int i=1;i<=9;i++){
      for(int k=1;k<=9;k++){
        if(i*k==n){
          cout<<"Yes";
          return 0;
        }
      }
    }
    cout<<"No";
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>  
using namespace std;
using ll = long long int;
using pll = pair<long long int,long long int>;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
ll l=1000000007;
string alphabet="abcdefghijklmnopqrstuvwxyz";
using graph = vector<vector<char>>;
double pi=3.14159265358979;

int main() {
  int n; cin>>n;
  int ac=0, wa=0, tle=0,re=0;
  rep(i,n){
    string  s; cin>>s;
    if(s=="AC"){ac++;}
    if(s=="WA"){wa++;}
    if(s=="TLE"){tle++;}
    if(s=="RE"){re++;}
  }
  cout<<"AC x "<<ac<<endl;
  cout<<"WA x "<<wa<<endl;
  cout<<"TLE x "<<tle<<endl;
  cout<<"RE x "<<re<<endl;
}



Measured memory_bytes: 3628
#include <iostream>
#include <vector>
using namespace std;
vector<int> v[55];
vector<pair<int,int> > e;
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n/2;i++)
	{
		v[i].push_back(i);
		v[i].push_back(n-n%2-i+1);
	}
	if (n%2)
	v[n/2+1].push_back(n);
	for (int i=1;i<=(n+1)/2;i++)
	{
		if (i==2 && n<=4)
		break;
		for (int j:v[i])
		{
			for (int k:v[i%((n+1)/2)+1])
			e.push_back({j,k});
		}
	}
	printf("%d\n",e.size());
	for (auto p:e)
	printf("%d %d\n",p.first,p.second);
}

Measured memory_bytes: 256
import os
import sys

import numpy as np


def solve(inp):
    k, q = inp[:2]
    ddd = inp[2:k + 2]
    nnn = inp[k + 2::3]
    xxx = inp[k + 3::3]
    mmm = inp[k + 4::3]
    buf = []
    for n, x, m in zip(nnn, xxx, mmm):
        eee = ddd % m
        acc = np.cumsum(eee)
        zero_acc = np.cumsum(eee == 0)
        loop, rem = divmod(n - 1, k)
        tot = x % m + acc[-1] * loop
        tot_zero = zero_acc[-1] * loop
        if rem > 0:
            tot += acc[rem - 1]
            tot_zero += zero_acc[rem - 1]
        dame = tot // m
        buf.append(n - 1 - dame - tot_zero)
    return buf


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC

    cc = CC('my_module')
    cc.export('solve', '(i8[:],)')(solve)
    cc.compile()
    exit()

if os.name == 'posix':
    # noinspection PyUnresolvedReferences
    from my_module import solve
else:
    from numba import njit

    solve = njit('(i8[:],)', cache=True)(solve)

inp = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=' ')
ans = solve(inp)
print('\n'.join(map(str, ans)))


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

const bool DEBUG = false;

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  int n2 = 1 << n;  // シフト演算子で2^nを作る
  vector<int> a(n2);
  for (size_t i = 0; i < n2; i++) cin >> a[i];
  sort(a.begin(), a.end());

  vector<int> s;  // 今の頂点集合．世代ごとに増えていく
  s.push_back(a.back());  // sの初期化．a.back()で末尾参照を取得 (最大値)
  a.back() = -1;  // 使用した要素は-1にすることにする．pop_back()で消さない
  for (size_t i = 0; i < n; i++) {  // n世代繰り返す
    vector<int> p = s;              // pに1世代前のデータをコピー
    sort(p.begin(), p.end());
    int ai = n2 - 1;
    while (p.size() > 0 && ai >= 0) {
      if (a[ai] == -1) {
        // すでに使用済みなら無視する
        --ai;
        continue;
      }
      if (a[ai] < p.back()) {
        // もしa[ai]がpの最大値よりも小さい (生成可能)なら
        s.push_back(a[ai]);  // 次世代にa[ai]を追加
        p.pop_back();        // 1世代前のpから候補を外す
        a[ai] = -1;          // a[ai]を使用済みに
      }
      --ai;
    }
    if (p.size() > 0) {
      // もし親として消化できてないノードがあるなら失敗
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3060
function Main(input) {
  input.trim();
  input = input.split(" ").map(Number);
  var sum = 3;
  input = input.sort((a, b) => b - a);
  for(var i=0;i<2;i++){
  if(input[i]==input[i+1]){
  sum--;
  }
  }
console.log(sum)
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int N = 10001, M = 9;
int n, m;
int a[M];
string dp[N];
bool done[N];
bool bad[N];

int msticks[] = {10000, 2, 5, 5, 4, 5, 6, 3, 7, 6};

string mymax(string& a, string& b) {
    int sza = a.length(), szb = b.length();
    if(sza > szb) return a;
    if(szb > sza) return b;
    if(a > b) return a;
    return b;
}

string solve(int rem) {
    if(done[rem]) return dp[rem];

    string ret = "";
    for(int i = 0; i < m; ++i) {
        int d = a[i], ms = msticks[d];
        if(rem - ms >= 0) {
            char c = d + '0';
            string cand = c + solve(rem - ms);
            if(bad[rem-ms]) continue;
            ret = mymax(ret, cand);
        }
    }
    done[rem] = true;
    if(ret.empty()) {
        bad[rem] = true;
    } else {
        dp[rem] = ret;
    }
    return ret;
}

int32_t main() {
    
    cin >> n >> m;
    for(int i = 0; i < m; ++i) {
        cin >> a[i];
    }

    done[0] = true;
    string ans = solve(n);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 43904
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>

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

using namespace std;

int main(void){
  ll n,m,k;
  cin >> n >> m >> k;
  ll a[n+1],b[m+1];
  a[0] = 0;
  b[0] = 0;
  rep(i,n) cin >> a[i+1];
  rep(i,n) a[i+1] += a[i];
  rep(i,m) cin >> b[i+1];
  rep(i,m) b[i+1] += b[i];
  /*  rep(i,n+1) cout << a[i] << " ";
  cout << endl;
  rep(i,m+1) cout << b[i] << " ";
  cout << endl;*/
  int cnt = m;
  int ans = 0;
  for(int i=0;i<n+1;i++){
    while(cnt != 0 && a[i]+b[cnt] > k )cnt--;
    if(a[i]+b[cnt] <= k && ans < i+cnt) ans = i+cnt;
  }

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


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

typedef unsigned long long int ull;
typedef long double ldb;
typedef long long int ll;

#define MOD1        1000000007
#define MOD2        998244353
#define PI          3.1415926535897932384626433832795
#define FILL(a, value) memset(a, value, sizeof(a))
#define BOOST       ios_base::sync_with_stdio(false); cin.tie(NULL)
#define what_is(x)  cerr << #x << " is " << x << endl;
#define ASSERT(left,operator,right) { if(!((left) operator (right))){ std::cerr << "ASSERT FAILED: " << #left << #operator << #right << " @ " << __FILE__ << " (" << __LINE__ << "). " << #left << "=" << (left) << "; " << #right << "=" << (right) << std::endl; } }

#define rep01(k,n)      for (ll i=k; i<n; i++)
#define rep02(k,n)      for (ll j=k; j<n; j++)
#define rep03(k,n)      for (ll k=k; k<n; k++)
#define rep11(k,n)      for (ll i=k; i<=n; i++)
#define rep12(k,n)      for (ll j=k; j<=n; j++)
#define rep13(k,n)      for (ll k=k; k<=n; k++)
#define repIT(c,it)     for(typeof(c.begin()) it = c.begin(); it != c.end(); ++it)
#define all(c)      c.begin(), c.end()

using namespace std;

const double pi = acos(-1.0);
const double epsilon = 1e-9;        // Add epsilon when casting double to int to avoid rounding pitfall issues, eg, 0.94*8178 in int
const int maxn = 1e6+10;


void solve()
{
    ll grid[3][3];
    for(int i = 0; i < 3; i++)
    {
        for(int j = 0; j < 3; j++)
            cin >> grid[i][j];
    }

    ll n;
    cin >> n;
    vector<ll> b(n);

    for(auto &el: b)
    {
        cin >> el;
        for(int i = 0; i < 3; i++)
        {
            for(int j = 0; j < 3; j++)
            {
                if( grid[i][j] == el)
                    grid[i][j] = -1;
            }
        }
    }


    ll f = 0;
    for(int i = 0; i < 3; i++)
    {
        ll fl = 0;
        for(int j = 0; j < 3; j++)
        {
            if(grid[i][j] != -1)
                fl = 1;
        }
        if(!fl)
            f = 1;
    }

    for(int i = 0; i < 3; i++)
    {
        ll fl = 0;
        for(int j = 0; j < 3; j++)
        {
            if(grid[j][i] != -1)
                fl = 1;
        }
        if(!fl)
            f = 1;
    }

    int fl = 0;
    for(int i = 0; i < 3; i++)
    {
        if(grid[i][i] != -1)
            fl = 1;
    }
    if(!fl) f = 1;
    fl = 0;
    for(int i = 0; i < 3; i++)
    {
        if(grid[2-i][i] != -1)
            fl = 1;
    }

    if(!fl) f = 1;

    if(f)
        cout << "Yes";
    else
        cout << "No";

    //cout << "\n";

    // for(int i = 0; i < 3; i++)
    // {
    //     for(int j = 0; j < 3; j++)
    //         cout << grid[i][j] << " ";
    //     cout << "\n";
    // }
}

int main()
{

    int t = 1;
    //cin >> t;
    while(t--)
        solve();

    cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=1000000007;
int mpow(int n,int m){
    int ret=1;
    while(m){
        if(m&1)ret=ret*n%mod;
        n=n*n%mod;
        m>>=1;
    }
    return ret;
}

int H,W,K;
char fld[1111][1111];

int bla[111],num[111],ev[111],eh[111],iv[111],ih[111];

tuple<int,int,int,int>f(int b,int n,int e,int i,int bb,int nn,int ee,int ii){
    int bbb,nnn,eee,iii;
    iii=(b*ii+i*ee)%mod;
    eee=e*ee%mod;
    nnn=((b*nn-i*ee)%mod+mod)%mod;
    bbb=b*bb%mod;
    return make_tuple(bbb,nnn,eee,iii);
}

signed main(){
    cin>>H>>W>>K;

    if(K<=1){
        cout<<1<<endl;
        return 0;
    }
    K--;
    rep(i,H)cin>>fld[i];

    rep(i,H)rep(j,W)if(fld[i][j]=='#')bla[0]++;

    rep(i,H)if(fld[i][0]=='#'&&fld[i][W-1]=='#')eh[0]++;
    rep(j,W)if(fld[0][j]=='#'&&fld[H-1][j]=='#')ev[0]++;

    rep(i,H)rep(j,W){
        if(i+1<H&&fld[i][j]=='#'&&fld[i+1][j]=='#')iv[0]++;
        if(j+1<W&&fld[i][j]=='#'&&fld[i][j+1]=='#')ih[0]++;
    }

    if(eh[0]&&ev[0]){
        cout<<1<<endl;
        return 0;
    }
    if(!eh[0]&&!ev[0]){
        cout<<mpow(bla[0],K)<<endl;
        return 0;
    }

    if(ev[0]==0){
        swap(ev[0],eh[0]);
        swap(iv[0],ih[0]);
    }

    num[0]=bla[0]-iv[0];


    for(int i=1;i<60;i++){
        tie(bla[i],num[i],ev[i],iv[i])=f(bla[i-1],num[i-1],ev[i-1],iv[i-1],bla[i-1],num[i-1],ev[i-1],iv[i-1]);
    }


    int ba=1,na=1,ea=1,ia=0;

    for(int i=0;i<60;i++)if(K>>i&1)tie(ba,na,ea,ia)=f(ba,na,ea,ia,bla[i],num[i],ev[i],iv[i]);


    cout<<na<<endl;
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main()
{
		 // #ifndef ONLINE_JUDGE
   //     // for getting input from input.txt
   //     freopen("input.txt", "r", stdin);
   //     // for writing output to output.txt
   //     freopen("output.txt", "w", stdout);
   //    #endif
	string s,ans;
	cin>>s;
	for(auto i : s){
		if(i == '0'){ ans.push_back('0'); }
		if(i == '1'){ ans.push_back('1'); }
		if(i == 'B' && (!ans.empty())){ ans.pop_back(); }
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
let calc_ a b s =
    match BatString.split_on_char '-' s with
    | [x; y] -> String.length x = a && String.length y = b
    | _ -> false

let calc a b s =
    let f v i c = v && (if i = a then c = '-' else c <> '-') in
    BatString.fold_lefti f true s

let main =
    let [a; b] = read_line () |> BatString.split_on_char ' ' |> List.map int_of_string in
    let s = read_line () in
    let v = (calc a b s) in
    print_endline (if v then "Yes" else "No")


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

using namespace std;

int main() {
	int n;
	cin >> n;
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			ans += (1LL) * i;
		}
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Schema;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var K = int.Parse(ReadLine());

        var constraintNumber = new int[10][] { new int[] { 0, 1 }, new int[] { 0, 1, 2 }, new int[] { 1, 2, 3 }, new int[] { 2, 3, 4 }, new int[] { 3, 4, 5 }, new int[] { 4, 5, 6 }, new int[] { 5, 6, 7 }, new int[] { 6, 7, 8 }, new int[] { 7, 8, 9 }, new int[] { 8, 9 }, };

        var memo = new List<long>[10, 11];

        for (int i = 0; i < memo.GetLength(0); i++)
        {
            for (int j = 0; j < memo.GetLength(1); j++)
            {
                memo[i, j] = new List<long>();
            }
        }

        IEnumerable<long> GetLunlunNumber(long first, long count)
        {
            if(memo[first, count].Count > 0)
            {
                foreach (var lunlun in memo[first, count])
                {
                    yield return lunlun;
                }

                yield break;
            }

            if(count == 1)
            {
                yield return first;
                yield break;
            }

            var firstDigit = (long)(first * Math.Pow(10, count - 1) + 0.001);

            foreach (var n in constraintNumber[first])
            {
                foreach (var _l in GetLunlunNumber(n, count - 1).ToList())
                {
                    var l = firstDigit + _l;
                    memo[first, count].Add(l);

                    yield return l;
                }
            }
        }

        var lunlunList = new List<long>();

        for (int count = 1; count <= 10; count++)
        {
            for (int first = 1; first <= 9; first++)
            {
                lunlunList.AddRange(GetLunlunNumber(first, count));
            }
        }

        WriteLine(lunlunList[K - 1]);
    }
}


Measured memory_bytes: 38792
// 最小全域木 ( プリム法 )
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

#include<queue>

using namespace std;

#define MAX_N 100
// 値の定義
const int INV = -1;
const int MAX_W = 2000;

// グラフ情報を保持する配列
int ary_graph[MAX_N + 1][MAX_N + 1];

// グラフを構成する頂点を保持するキュー
queue<int> Base_Queue;

int n = 0;

// プリム法で最小全域木を求める
int MinimumSpanningTree(void);

int main(void)
{
    int sum = 0;

    for(int i = 0; i < MAX_N + 1; i++)
    {
        for(int j = 0; j < MAX_N + 1; j++)
        {
            // 配列の初期化
            ary_graph[i][j] = INV;
        }
    }

    cin >> n;

    for(int i = 0; i < n; i++)
    {
        // グラフを構成する頂点の格納
        Base_Queue.push(i);

        for(int j = 0; j < n; j++)
        {
            // 隣接行列の設定
            cin >> ary_graph[i][j];
        }
    }

    // 頂点１から最小全域木を探索する
    sum = MinimumSpanningTree();

    // 結果の表示
    printf("%d\n", sum);

    return 0;
}

// 最小全域木を探索する関数
int MinimumSpanningTree(void)
{

    int q_size_1, q_size_2, min_val, min_ele, s, t, tmp;
    // 辺の和を保持する変数
    int sum = 0;

    // 最小全域木を構成する頂点を保持するキュー
    queue<int> Prim_Queue;

    // 検索する頂点の初期値の設定
    s = Base_Queue.front();
    Base_Queue.pop();
    Prim_Queue.push(s);

    while( !Base_Queue.empty() )
    {
        // ----------------------------------------------
        // Prim_Queueの頂点 から Base_Queueの頂点への辺の中で
        // 最小コストの辺を検索する方針で進める
        // ----------------------------------------------

        min_val = MAX_W;
        min_ele = INV;

        q_size_1 = Base_Queue.size();
        q_size_2 = Prim_Queue.size();

        for( int i = q_size_2; i > 0; i-- )
        {
            // --- s から t に向かう辺の重みを探索する ---
            s = Prim_Queue.front();
            Prim_Queue.pop();
            // Prim_Queue の要素が減らないように, 取り出したものを元に戻す
            Prim_Queue.push(s);

            for( int i = q_size_1; i > 0; i-- )
            {
                t = Base_Queue.front();
                Base_Queue.pop();

                if( ary_graph[s][t] != INV && min_val > ary_graph[s][t] )
                {
                    // 最小のコストを持つ辺を保存する
                    min_val = ary_graph[s][t];
                    min_ele = t;
                }

                // 取り出したものを, 一旦, 元に戻す
                Base_Queue.push(t);
            }
        }

        // 最小のコストを持つ辺の頂点を追加して
        // 最小全域木を構成する
        for(int i = 0; i < Base_Queue.size(); i++)
        {
            tmp = Base_Queue.front();
            Base_Queue.pop();

            if( tmp == min_ele )
            {
                // 最小コストの辺を持つ頂点を追加する
                Prim_Queue.push(tmp);
                break;
            }
            else
            {
                // 対象外なら元に戻す
                Base_Queue.push(tmp);
            }
        }

        // 辺の和を求める
        sum += min_val;
    }

    return sum;
}



Measured memory_bytes: 3264
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<String>().chars().collect::<Vec<_>>();
    if n[0].is_uppercase() {
        println!("A");
    } else {
        println!("a");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2052
import sys
sys.setrecursionlimit(10**7)
N,T,A = map(int,input().split()); INF = float("inf")
T-=1;A-=1 #0index
G = [[] for _ in range(N)]
for i in range(N-1):
  a,b = map(int,input().split())
  a-=1;b-=1 #0index
  G[a].append(b);G[b].append(a)

disT = [INF for _ in range(N)]; disT[T] = 0
disA = [INF for _ in range(N)]; disA[A] = 0

def dfs(v, L):
  for u in G[v]:
    if L[u] != INF:
      continue
    L[u] = L[v]+1
    dfs(u,L)
dfs(T,disT)
dfs(A,disA)
#print(disT)
#print(disA)
ans = 0
for i in range(N):
  if disT[i] < disA[i]:
    ans = max(ans,disA[i]-1)
print(ans)
    

Measured memory_bytes: 102092
import sys
import numpy as np
 
n = int(input())
aaa = list(map(int, sys.stdin))
MOD = 998244353
 
s = sum(aaa)
dp1 = np.zeros(s + 1, dtype=np.uint32)
dp2 = np.zeros(s + 1, dtype=np.uint32)
dp1[0] = 1
dp2[0] = 1
for a in aaa:
    dp1 = (dp1 * 2 + np.roll(dp1, a)) % MOD
    dp2 = (dp2 + np.roll(dp2, a)) % MOD
 
h = (s + 1) // 2
ans = (pow(3, n, MOD) - dp1[h:].sum() * 3) % MOD
if s % 2 == 0:
    ans = (ans + dp2[h] * 3) % MOD
print(int(ans))

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

using namespace std;

int main() {
	int r, c;
	int *a_table, *a_rsum;

	cin >> r >> c;
	a_table = new int[r*c];
	a_rsum = new int[c];

	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			if (i == 0) a_rsum[j] = 0;

			a_table[i*c + j] = 0;
			cin >> a_table[i*c + j];
			a_rsum[j] += a_table[i*c + j];
		}
	}

	int csum;

	for (int i = 0; i < r; i++) {
		cout << (csum = a_table[i*c]);

		for (int j = 1; j < c; j++) {
			cout << " " << a_table[i*c + j];
			csum += a_table[i*c + j];
		}

		cout << " " << csum << endl;
	}

	cout << (csum = a_rsum[0]);
	for (int j = 1; j < c; j++) {
		cout << " " << a_rsum[j];
		csum += a_rsum[j];
	}
	cout << " " << csum << endl;

	delete[] a_table;
	delete[] a_rsum;

	return 0;
}


Measured memory_bytes: 3120