akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <map>
#include <set>
#include <numeric>
#include <queue>

using namespace std;

const int INF = 1e9 + 7;

int grandy(int r, int v,  vector <int> &gr, vector <vector <pair <int, int> > > &data){
    if (gr[r] != INF)
        return gr[r];
    int s = 0;
    for (auto elem : data[r]){
        if (elem.first == v)
            continue;
        if (gr[elem.first] == INF)
            gr[elem.first] = grandy(elem.first, r, gr, data);
        s = s ^ (gr[elem.first] + 1);
    }
    gr[r] = s;
    return gr[r];
}

int ffind(int n, int m, int v, vector <int> &gr, vector <vector <pair <int, int> > > &data){
    for (auto elem : data[n]){
        if (elem.first == v)
            continue;
        //cerr << n + 1 << " " << gr[n] << " " << m << " "  << elem.first + 1 << " " << gr[elem.first] + 1 << endl;
        //cerr << (gr[n] ^ m ^ (gr[elem.first] + 1))<< endl;
        if ((gr[n] ^ m ^ (gr[elem.first] + 1)) == 0)
            return elem.second;
        int x = ffind(elem.first, (gr[n] ^ m ^ (gr[elem.first] + 1)) - 1, n, gr, data);
        if (x != -1)
            return x;
    }
    return -1;
}

int main(){
    int n, r = 1;
    cin >> n;
    r--;
    vector <vector <pair <int, int> > > data(n);
    
    for (int i = 0; i < n - 1; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        data[a].push_back({b, i + 1});
        data[b].push_back({a, i + 1});
    }
    
    vector <int> gr(n, INF);
    int x = grandy(r, r, gr, data);
    
    /*for (int i = 0; i < n; i++)
     cerr << gr[i] << " ";
     cerr << endl;*/
    
    if (gr[r] == 0){
        cout << "Bob";
        return 0;
    }
    
    cout << "Alice" << endl;
    
    return 0;
}


Measured memory_bytes: 15488
#include <stdio.h>
#include<math.h>
#define MAX 100005

int i,j,n;
int A[MAX], B[MAX], C[10000];

int parti(int a[], int p, int r){
	int x, temp;
	x = a[r];
	i = p-1;
	for (j = p; j < r; j++){
		if (a[j] <= x){
			i++;
			temp = a[i]; 
			a[i] = a[j];
			a[j] = temp;
		}
	}	
	temp = a[i+1];
	a[i+1] = a[r];
	a[r] = temp;
	return i+1;
}

int main(void){
	int partition;
	scanf("%d ", &n);
	for(i=0; i<n; i++)
		scanf("%d ", &A[i]);
	
	partition = parti(A,0,n-1);
	
	for (i=0; i<n; i++){
		if (i<n-1){
			if (i==partition)
				printf("[%d] ", A[i]);
			else printf("%d ", A[i]);
		}
		else {
			if (i==partition)
				printf("[%d]\n", A[i]);
			else printf("%d\n", A[i]);
		}
	}
	
	return 0;
}


Measured memory_bytes: 2128
#include <bits/stdc++.h>
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define INF 1e9
using namespace std;
typedef long long ll;
static const ll MOD = 1000000007LL;

signed main() {
  // std::ifstream in ("input.txt"); std::cin.rdbuf(in.rdbuf());
  int r;
  cin >> r;
  cout << 3 * pow(r, 2) << endl;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  int min_m = 1001;
  int count = 0;
  
  for (int ii=0; ii<N; ++ii) {
    int m;
    cin >> m;

    if (m < min_m)
      min_m = m;

    X -= m;
    count++;
  }

  count += X/min_m;

  std::cout << count << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

// typedef
typedef long long ll;
typedef unsigned long ul;
// #define int long long

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // 値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)  // 直後の要素をパディング
#define space_pad(num) setfill(' ') << std::right << setw(num)  // 直後の要素をパディング

// func declaration
template <class T> void print2DVec(vector< vector<T> >&);
template <class T> void calcVec(vector<T>&, int, char);
int char_to_int(const char);

// const
const int INF = 10000000;

/*MEMO
・辞書順
abc < abcd, atcoder < atlas
・イテレータ
std::vector<int>::iterator とタイプするのは面倒なので、
 通常は型推論の auto を使用する。
 auto iter = max_element(ALL(vec));
・2次元配列
vector<vector<int>> vec = {{1, 2, 3}, {4, 5, 6}}
・20×10の配列
vector<vector<int>> vec(20, vector<int>(10, 0));
・(n, m)の多次元配列
vector< vector<int> > vec(n, vector<int>(m, 0))  // 0で初期化
*/

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

    // input
    string str;
    cin >> str;
    
    // calculation
    int sum = 0;
    if (str[0] == '1') sum++;
    if (str[1] == '1') sum++;
    if (str[2] == '1') sum++;
    cout << sum << "\n";
    
    return 0;
}


// function
template <class T> void print2DVec(vector< vector<T> >& vec) {
    REP(i, vec.size()) {
        REP(j, vec.front().size()) {
            cout << vec.at(i).at(j);
        }
        cout << endl;
    }
}

template <class T> void calcVec(vector<T> &vec, int num, char ch) {
    // vec全体への演算
    switch (ch) {
        case '+':
            REP(i, vec.size()) vec.at(i) += num; break;
        case '-':
            REP(i, vec.size()) vec.at(i) -= num; break;
        case '*':
            REP(i, vec.size()) vec.at(i) *= num; break;
        case '/':
            REP(i, vec.size()) vec.at(i) /= num; break;
        case '%':
            REP(i, vec.size()) vec.at(i) %= num; break;
        default:
            cout << "Incorrect Operator" << endl;
    }
}

int char_to_int(const char c) {
    if('0' <= c && c <= '9') return (c - '0');
    return -1;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a,b,c,i;
	scanf("%d %d",&a,&b);
	for(i = 0;i < b;i++)
	{
		scanf("%d",&c);
		a -= c;
	}
	if(a < 0)
		printf("-1");
	else
		printf("%d\n",a);
	return 0;
}



Measured memory_bytes: 1736
import sys
from statistics import *
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

a, b, k = na()
ct = 0
li = []
for i in range(a, a + k):
    if i <= b:
        li.append(i)
for i in range(b - k + 1, b+1):
    if i >= a:
        li.append(i)
print(*(sorted(list(set(li)))))

Measured memory_bytes: 5404
#include"bits/stdc++.h"
using namespace std;
#define rep(i, N) for(int i=0; i<N; ++i)
using ul = unsigned long;
using ll = long long;

int main() {
    int N;
    cin >> N;
    int n = N;
    int b;
    int num = 1;
    bool flag = false;
    rep(i, N) {
        cin >> b;
        if (b == num) {
            num++;
            n--;
            flag = true;
        }
    }
    if (flag) cout << n << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define REP(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int
main(int argc, char *argv[])
{
  int n; ll k;
  scanf("%d %lld", &n, &k);

  ll ans = k;
  for(int i = 1; i < n; i++){
    ans *= k - 1;
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <limits>
using namespace std;
typedef long long ll;
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define FOREACH(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
 
template<class T> struct BellmanFord {
  struct Edge {
    int from,to;
    T cost;
    Edge (int f, int t, T c) : from(f), to(t), cost(c) {}
  };
  const T INF = numeric_limits<T>::max() / 2;
  vector< vector<T> > d;
  vector<Edge> edge;
  BellmanFord (int n) : d(2,vector<T>(n)) {}
  void add_directed_edge(int from, int to, T cost) {
    edge.push_back(Edge(from,to,cost));
  }
  void init(int s) {
    for (int i=0; i<d[0].size(); i++) d[0][i] = INF;
    d[0][s] = 0;
    for (int k=0; k<2; k++) {
      for (int j=0; j<d[0].size(); j++) {
        for (int i=0; i<edge.size(); i++) {
          Edge e = edge[i];
          if (d[k][e.from] != INF && d[k][e.to] > d[k][e.from] + e.cost) {
            d[k][e.to] = d[k][e.from] + e.cost;
          }
        }
      }
      if (k == 0) d[1] = d[0];
    }
  }
  bool find_negative_loop(int v) { 
    return d[0][v] != d[1][v]; 
  }
  T dist(int v) { 
    return d[0][v]; 
  }
};

int main() {

  int V,E,r;
  cin >> V >> E >> r;

  BellmanFord<int> inst(1010);

  REP(i,E) {
    int from,to,c;
    cin >> from >> to >> c;
    inst.add_directed_edge(from,to,c);
  }

  inst.init(r);
  REP(i,V) {
    if(inst.find_negative_loop(i)) {
      cout << "NEGATIVE CYCLE" << endl;
      return 0;
    }
  }

  REP(i,V) {
    if(inst.dist(i) == inst.INF) cout << "INF" << endl;
    else cout << inst.dist(i) << endl;
  }

  return 0;
}

Measured memory_bytes: 3192
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
long long int a = 0, b = 0, c = 0,d=0,e=0, ans = 0, x = 0, y = 0, z = 0, n = 0, m = 0, maxy = 0, mini = 9999, counter = 0, endp = 0, checker = 0;

std::vector <long long int> vec{}, vecsec{}, vecth{};
long long int iremono[100001], koware[100001];
long long int iremono2[100001], check[100001],xpo[10000001],ypo[10000001],hei[1000001];
std::vector<std::string>kinds{}, kaku{};
char maze[1000][1000];
int sx, sy;
int gx, gy;
pair<long long int, long long int>pairs[101],pointkaku[10000000];
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
bool okada = false, okada2 = false;
std::string output, output2, input, input2;
char re;
int starta, startb, enda, endb,ab;


unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int kaizyo(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}

int H, W;//はんい
bool qw = false, er = false, ty = false,ui=false;
int main() {
	cin >> a >>b;
cout<<a%b<<endl;
}


Measured memory_bytes: 2304
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};

int N;


int main() {
	cin >> N;
	vll a(N);
	rep(i, N) {
		cin >> a[i];
	}
	ll ans = 0;
	while (true) {
		ll num = 0;
		rep(i, N) {
			if (a[i] > N - 1) {
				ll n = a[i] / N;
				num += n;
				a[i] = (a[i] % N) - n;
			}
		}
		rep(i, N) {
			a[i] += num;
		}
		ans += num;
		bool flag = true;
		rep(i, N) {
			if(a[i] > N - 1)flag = false;
		}
		if (flag)break;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<"!"<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi p(n);
  for(auto &a:p){cin>>a;a--;}
  vi a(n);
  vi b(n);
  for(int i=0;i<n;i++){
    a[i]=20001*i+1;
    b[n-i-1]=20001*i+1;
  }
  ll now=0;
  for(int i=0;i<n;i++){
    if(i==0){
      now=a[p[i]]+b[p[i]];
    }else{
      ll po=p[i];
      //cout<<now<<" "<<a[po]+b[po]<<endl;
      if(now>=a[po]+b[po]){
	ll sa=now-a[po]-b[po]+1;
	ll hoge=min(20000LL,sa);
	a[po]+=hoge;
	sa-=hoge;
	hoge=min(20000LL,sa);
	b[po]+=hoge;
	sa-=hoge;
	now=a[po]+b[po];
      }
    }
  }
  for(auto A:a)cout<<A<<" ";
  cout<<endl;
  for(auto A:b)cout<<A<<" ";
  cout<<endl;
  return 0;
}


Measured memory_bytes: 1152
#include <iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a;
    cin>>b;
    cin>>c;
    int min=a+b;
    if (min>b+c)
        min=b+c;
    if(min>c+a)
        min=c+a;
    cout<<min;
    }
    



Measured memory_bytes: 256
n, m = map(int, input().split())

a = [list(input()) for _ in range(n)]
b = [list(input()) for _ in range(m)]

import sys

for r in range(n - m + 1):
  for c in range(n - m + 1):
    for x in range(m):
      if a[r+x][c:c+m] != b[x][:]:
        break
    else:
      print("Yes")
      sys.exit()

print("No")
      

Measured memory_bytes: 3060
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld %lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;
/*ios_base::sync_with_stdio(false);cin.tie(0);*/

int main ( ){
    ios_base::sync_with_stdio(false);cin.tie(0);
    ll a,b;
    cin >>a>> b;

    if(a<10&&b<10){
        cout << a*b;
    }    else{
        cout <<-1;
    }

    return 0;
}

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n"
#define rep(i,n) for(int i=0; i<(n); ++i)

typedef pair<int, int> P;
typedef pair<string, int> Psi;


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

	int r,d,x;cin>>r>>d>>x;

	rep(i,10){

		 x = r*x-d;

		 writeln(x);

	}


}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Linq;

namespace at_coder
{
#if TEST
    [TestClass]
#endif
    public class Test_162_c
    {

#if TEST
        public static void Test_Main()
#else
        public static void Main()
#endif
        {
            int k = ReadInt();

            long l = 0;
            for (int a = 1; a <= k; a++)
            {
                for (int b = 1; b <= k; b++)
                {
                    for (int c = 1; c <= k; c++)
                    {
                        int s = gcd(a, b, c);
                        l += s;
                    }
                }
            }

            Write(l.ToString());
        }


        public static int gcd(int a, int b, int c)
        {
            int x = gcd(a, b);
            int y = gcd(b, c);
            return gcd(x, y);
        }

        public static int gcd(int m, int n)
        {
            if (m < n) return gcd(n, m);
            if (n == 0) return m;
            return gcd(n, m % n);
        }
        static void swap(ref int a, ref int b)
        {
            int t = a; a = b; b = t;
        }

        private static void Write(string s)
        {
            Console.WriteLine(s);
        }

        private static int[] ReadIntArray()
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int[] ar = new int[ss.Length];
            for (int i = 0; i < ss.Length; i++)
            {
                ar[i] = int.Parse(ss[i]);
            }
            return ar;
        }
        private static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static void ReadInt(out int a, out int b)
        {
            var ar = ReadIntArray();
            a = ar[0];
            b = ar[1];
        }
        private static void ReadInt(out int a, out int b, out int c)
        {
            var ar = ReadIntArray();
            a = ar[0];
            b = ar[1];
            c = ar[2];
        }
        private static string ReadString()
        {
            return Console.ReadLine();
        }
        private static string[] ReadStringArray()
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            return ss;
        }
#if !TEST
    }
}
#endif


Measured memory_bytes: 27544
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

/*
二部探索で最適値を探索する。[lo, hi] の間に最適値があるとする。
maximize の場合、lo は必ず OK となる値で、
minimize の場合、hi は必ず OK となる値とする。
 */
ll binary_search(
    ll lo, ll hi, function<bool(ll)> is_ok,
    bool is_maximize
){
    while(lo < hi){
        const ll mid = (lo + hi) / 2;
        if(is_maximize){
            if(is_ok(mid)){
                lo = mid;
            }else{
                hi = mid - 1;
            }
        }else{
            if(is_ok(mid)){
                hi = mid;
            }else{
                lo = mid + 1;
            }
        }
    }
    return lo;
}

int main(){
    ll n, k;
    cin >> n >> k;

    vector<ll> a(n);
    REP(i, n){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());

    vector<ll> f(n);
    REP(i, n){
        cin >> f.at(i);
    }
    sort(f.begin(), f.end(), greater<ll>());

    ll ans = binary_search(
        0,
        *max_element(a.begin(), a.end()) * *max_element(f.begin(), f.end()),
        [&](ll mid) -> bool{
            ll tmp = 0;
            REP(i, n){
                const ll fi2 = mid / f.at(i);
                tmp += max(0LL, a.at(i) - fi2);
            }
            return (tmp <= k);
        },
        false
    );
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;

#define ul unsigned long long
#define ll long long 

int main()
{
  int a[9];
  for (int i=0;i<9;i++) cin>>a[i];
  int n;
  cin>>n;
  int b;
  for (int k=0;k<n;k++) {
    cin>>b;
    for (int i = 0; i < 9; i++)
        if (a[i]==b) a[i]=0;
  }

  int bis[8][3] = {{0, 1, 2},
                   {3, 4, 5},
                   {6, 7, 8},
                   {0, 3, 6},
                   {1, 4, 7},
                   {2, 5, 8},
                   {0, 4, 8},
                   {2, 4, 6}};
  string res="No";
  for (int k = 0; k < 8; k++)
  {
    int cj=0;
    for (int i=0;i<3;i++) cj=a[bis[k][i]]>0?1:cj;
    if (cj==0) {
      res="Yes";
      break;
    }
  }

  cout << res<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> vec(n-1);
    for(int i=0;i<n-1;i++){
        cin >> vec[i];
    }
    long long count=0;
    count += vec[0];
    for(int i=0;i<n-2;i++){
        count += min(vec[i],vec[i+1]);
    }
    count += vec[n-2];
    cout<<count<<endl;
}

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

#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define fst first
#define snd second

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    int n = SZ(s);
    vector<int> lpos, rpos;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'L')
            lpos.PB(i);
        else
            rpos.PB(i);
    }
    vector<int> ans(n);
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'R')
        {
            int r = *lower_bound(ALL(lpos), i);
            if ((r - i) % 2 == 0)
                ans[r]++;
            else
                ans[r - 1]++;
        }
        else
        {
            int l = *prev(upper_bound(ALL(rpos), i));
            if ((i - l) % 2 == 0)
                ans[l]++;
            else
                ans[l + 1]++;
        }
    }
    for (auto x : ans)
    {
        cout << x << " ";
    }
    return 0;
}

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

typedef long long ll;

int a[1010];

int main() {
	int n, i, j;
	cin >> n;
	for(i = 1; i <= n; ++i)
		cin >>a[i];
	int ans = 0;
	sort(a+1, a+n+1);
	a[n+1]=a[n];
	for(i=1; i <=n; ++i) {
		ans+=(a[i+1]-a[i]);
		// cout << ans << endl;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

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

    ll n,a,b;cin>>n>>a>>b;
    if(abs(a-b)%2==0){
        cout<<abs(a-b)/2<<endl;
    }else{
        //どっちかが端で休む必要がある
        if(a>b) swap(a,b);
        ll disa=a-1,disb=n-b;
        ll ans=0;
        if(disa<disb){
            ans+=disa;
            b-=disa;b--;ans++;
            a=1;
            ans+=abs(a-b)/2;
        }else{
            ans+=disb;
            b=n;
            a+=disb;a++;ans++;
            ans+=abs(a-b)/2;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    vector<int> cnt(1, 1);
    REP(i, 1, n) {
        if(a[i] == a[i-1]) cnt.back() += 1;
        else cnt.push_back(1);
    }
    sort(rall(cnt));
    int ans = 0;
    REP(i, k, cnt.size()) ans += cnt[i];
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n,l;cin>>n>>l;
  string sn[n];rep(i,n)cin>>sn[i];
  sort(sn,sn+n);
  rep(i,n)cout<<sn[i];
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author AEoui
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int curT = 0;
            int curX = 0;
            int curY = 0;

            for (int i = 0; i < n; ++i) {
                int t = in.nextInt();
                int x = in.nextInt();
                int y = in.nextInt();

                int minD = Math.abs(x - curX) + Math.abs(y - curY);
                if (minD > (t - curT)) {
                    out.println("No");
                    return;
                } else {
                    if (minD % 2 != (t - curT) % 2) {
                        out.println("No");
                        return;
                    }
                }

                curT = t;
                curX = x;
                curY = y;
            }

            out.println("Yes");
        }

    }
}



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

int main() {
	int a,b;
	cin >> a >> b;
	if(a*b%2==0) cout << "Even" << endl;
	else cout << "Odd" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#define SIZE 50001
using namespace std;

int main(){
    bool is_prime[50001];

    is_prime[0] = is_prime[1] = false;
    for(int i=2;i<50001;i++)
        is_prime[i] = true;

    for(int i=2;i*i<50001;i++){
        if(is_prime[i]){
            for(int j=i*i;j<50001;j+=i){
                is_prime[j] = false;
            }
        }
    }


    int n,ans(0);
    while(1){
        cin >> n;
        if(n==0)   break;
        ans = 0;
        for(int i=0;i<=n/2;i++){
            if(is_prime[i]&&is_prime[n-i]){
                    ans++;
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define MOD 100000007LL
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef string::const_iterator State;
int res=-5000;
string str;
bool over;

int expression(State &begin);

int ope[101];

bool ex_good(){
	int cc=0;
	memset(ope,0,sizeof(ope));
	for(int i=0;i<str.size();i++){
		if(str[i]==')'){
			if(cc==0)return false;
			if(!(isdigit(str[i-1]) || str[i-1]==')'))return false;
			if(ope[cc]==0)return false;
			ope[cc]=0;
			cc--;
		}
		if(str[i]=='('){
			cc++;
			if(i==0)continue;
			if(isdigit(str[i-1]) || str[i-1]==')')return false;
		}
		if(isdigit(str[i])){
			if(i==0)continue;
			if(str[i-1]==')')return false;
		}
		if(str[i]=='+' || str[i]=='-' || str[i]=='*'){
			if(i==0 || i==str.size()-1)return false;
			if(!(isdigit(str[i-1]) || str[i-1]==')'))return false;
			if(!(isdigit(str[i+1]) || str[i+1]=='('))return false;
			ope[cc]++;
		}
	}
	if(cc>0)return false;
	return true;
}

int number(State &begin){
	int ret=0;
	while(isdigit(*begin)){
		ret*=2;
		ret+=*begin-'0';
		begin++;
		if(ret>=1024)over=true;
	}
	return ret;
}

int factor(State &begin){
	if(*begin=='('){
		begin++;
		int ret=expression(begin);
		begin++;
		return ret;
	}else{
		return number(begin);
	}
}

int term(State &begin){
	int ret=factor(begin);
	while(1){
		if(*begin=='*'){
			begin++;
			ret*=factor(begin);
			if(ret>=1024)over=true;
		}else break;
	}
	return ret;
}

int expression(State &begin){
	int ret=term(begin);
	while(1){
		if(*begin=='+'){
			begin++;
			ret+=term(begin);
			if(ret>=1024)over=true;
		}else if(*begin=='-'){
			begin++;
			ret-=term(begin);
			if(ret<0)over=true;
		}else break;
	}
	return ret;
}

void dfs(int v){
	if(v==str.size()){
		State s=str.begin();
		if(!ex_good())return;
		over=false;
		int val=expression(s);
		if(!over && v<1024)res=max(res,val);
	}else{
		if(str[v]!='.'){
			dfs(v+1);
		}else{
			str[v]='0';
			dfs(v+1);
			str[v]='1';
			dfs(v+1);
			str[v]='+';
			dfs(v+1);
			str[v]='-';
			dfs(v+1);
			str[v]='*';
			dfs(v+1);
			str[v]='(';
			dfs(v+1);
			str[v]=')';
			dfs(v+1);
			str[v]='.';
		}
	}
}

int main(void){
	cin >> str;
	dfs(0);
	printf("%d\n",res==-5000?-1:res);
	return 0;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

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

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

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

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

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


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, T;
  vector<P> w;

  cin >> N >> T;
  rep(i, N){
    ll a, b;
    cin >> a >> b;
    w.push_back({a, b});
  }

  sort(ALL(w), [](P a, P b){return a.first < b.first;});

  ll ans=1e5;
  rep(i, N){
    if(w[i].second<=T){
      cout << w[i].first;
      return 0;
    }
  }
  cout <<"TLE";

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(){
  int n, m;
  map<string, int> mp;

  cin >> n;
  for (int i; i<n; i++) {
    string a;
    cin >> a;
    mp[a]+=1;
  }

  cin >> m;
  for (int i=0; i<m; i++) {
    string a;
    cin >> a;
    mp[a]-=1;
  }

  int max=0;
  for (auto itr=mp.begin(); itr!=mp.end(); itr++) {
    if (itr->second>max) max=itr->second;
  }

  printf("%d\n", max);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}




int main() {
	int n; cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	int maxx = h[0];
	int count = 0;

	for (int i = 0; i < n; i++) {
		if (h[i] >= maxx) {
			count++;
			maxx = h[i];
		}
	}

	cout << count << endl;

	return 0;
}

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

#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

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

template <class T, T M>
class modulo {
public:
    T data;

    modulo(T data = 0) : data(data % M) {
    }

    modulo operator+(const modulo &x) const {
        return modulo(data + x.data);
    }

    modulo operator-(const modulo &x) const {
        return modulo(data + (M - x.data));
    }

    modulo operator*(const modulo &x) const {
        return modulo(data * x.data);
    }

    modulo operator/(const modulo &x) const {
        return modulo(data * x.inv().data);
    }

    modulo operator+=(const modulo &x) {
        data = (data + x.data) % M;
    }

    modulo operator-=(const modulo &x) {
        data = (data + (M - x.data)) % M;
    }

    modulo operator*=(const modulo &x) {
        data = (data * x.data) % M;
    }

    modulo operator/=(const modulo &x) {
        data = (data * x.inv().data) % M;
    }

    modulo inv() const {
        return _pow(M - 2);
    }

    template <class Integer>
    modulo operator^(Integer n) const {
        if (n >= 0) {
            return _pow(n);
        } else {
            return _pow(M - 1 - (-n) % (M - 1));
        }
    }

    friend std::ostream& operator<<(std::ostream &os, const modulo &x) {
        os << x.data;
        return os;
    }

private:
    template <class NonNegativeInteger>
    modulo _pow(NonNegativeInteger n) const {
        modulo result(1);
        modulo x(*this);
        while (n) {
            if (n & 1) {
                result *= x;
            }
            x *= x;
            n >>= 1;
        }
        return result;
    }
};

using mod = modulo<ll, MOD>;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    sort(all(A));

    vector<mod> factorial(N + 1), inv_factorial(N + 1);
    factorial[0] = 1;
    for (int i = 1; i <= N; ++i) {
        factorial[i] = mod(i) * factorial[i - 1];
    }
    inv_factorial[N] = factorial[N].inv();
    for (int i = N; i > 0; --i) {
        inv_factorial[i - 1] = mod(i) * inv_factorial[i];
    }
    auto combination = [&](int N, int k) -> mod {
        if (0 <= k && k <= N) {
            return factorial[N] * inv_factorial[k] * inv_factorial[N - k];
        } else {
            return 0;
        }
    };

    mod result = 0;
    REP(i, N) {
        result += combination(i, K - 1) * A[i];
    }
    REP(i, N) {
        result -= combination(N - 1 - i, K - 1) * A[i];
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 2176
import sys
input = sys.stdin.readline
def main():
    n = int(input())
    ab = [list(map(int,input().split())) for i in range(n)]
    ab.sort(key=lambda x: x[1])
    ab2 = sorted(ab)
    if n%2 == 0:
        a = ab2[n//2-1][0]
        b = ab[n//2-1][1]
        c = ab2[n//2][0]
        d = ab[n//2][1]
        # print(a,b,c,d)
        print((b-a+1)+(d-c))
    else:
        a = ab2[n//2-1][0]
        b = ab[n//2-1][1]
        c = ab2[n//2][0]
        d = ab[n//2][1]
        e = ab2[n//2+1][0]
        f = ab[n//2+1][1]
        
        # l = c
        # r = d
        # print(ab)
        # print(a,b,c,d,e,f)
        # if l < b:
        #     l = b
        # if l > e:
        #     l = e
        # if r > e:
        #     r = e
        #     # print(r)
        # if r < b:
        #     r = b
        # # print(r,l)
        # # print(r-l+1)
        ll = [a,c,e]
        rl = [b,d,f]
        ll.sort()
        rl.sort()
        print(rl[1] - ll[1] +1 )
        # print(ab)
        # print(ab2)



if __name__ == '__main__':
    main()



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

MOD = 10**9+7

# WARN: Require mod number m is prime number
class ModComb:
    # For nCr mod m
    def __init__(self, n_max, m):
        self._n_max = n_max
        self._m = m
        self._mod_facts = [1] * (n_max+1)       # list of n! mod m
        self._mod_inv_facts = [1] * (n_max+1)   # list of inverse r! mod m

        if not m >= 3:
            raise ValueError('Require mod number m >= 3')

        # Calc n! mod m
        for i in range(2, n_max+1):
            self._mod_facts[i] = self._mod_facts[i-1] * i % m

        # Calc inverse r! mod m
        self._mod_inv_facts[n_max] = pow(self._mod_facts[n_max], m-2, m)
        for i in range(n_max-1, 1, -1):
            self._mod_inv_facts[i] = self._mod_inv_facts[i+1] * (i+1) % m

    def calc(self, n, r):
        # Return nCr mod m
        if n > self._n_max:
            raise Exception('n is larger than n_max')

        if r == 0:
            return 1

        m = self._m
        return self._mod_facts[n] * self._mod_inv_facts[r] * self._mod_inv_facts[n-r] % m

modcomb = ModComb(N*M-2, MOD)
p = modcomb.calc(N*M-2, K-2)

ans = 0
for i in range(N):
    for j in range(M):
        if i == 0 and j == 0:
            continue
        d = i+j
        cnt = (N-i) * (M-j)
        if i != 0 and j != 0:
            cnt *= 2
        ans += d * cnt % MOD
ans = ans * p % MOD

print(ans)


Measured memory_bytes: 18804
# 初期入力
a_list = [input().split() for i in range(3)]
N = int(input())
call_num = [input() for i in range(N)]

bingo =""
# 横がそろっているか
bingo = "No"
yoko = [i for i in a_list if set(i) & set(call_num) ==set(i)]
if 0 < len(yoko):
    bingo ="Yes"

# 縦がそろっているか
a_tate =[]
for i,v in enumerate(a_list):
    ta =[]
    for j in range(3):
        ta.append(a_list[j][i])
    a_tate.append(ta)

tate =""
for i in a_tate:
    if len(set(i) & set(call_num) ) ==3 :
        tate +="ss"
if 0 < len(tate):
    bingo ="Yes"

# 斜め
a_naname_1 = set([a_list[0][0],a_list[1][1],a_list[2][2] ])
a_naname_2 = set([a_list[0][2],a_list[1][1],a_list[2][0] ])
if a_naname_1 & set(call_num) == a_naname_1:
    bingo = "Yes"
if a_naname_2 & set(call_num) == a_naname_2:
    bingo = "Yes"
print(bingo)

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a);i>(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1000000000;
const LL MOD = 1000000007;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

int main() {
  int N;
  LL ans=0;
  cin >> N;
  VI A(N+1), B(N);
  REP(i,N+1) {
    cin >> A.at(i);
  }
  REP(i,N) {
    cin >> B.at(i);
  }
  REP(i,N) {
    if(A.at(i) < B.at(i)) {
      ans+=A.at(i);
      B.at(i) -= A.at(i);
      A.at(i)=0;
    }
    else {
      ans+=B.at(i);
      A.at(i) -= B.at(i);
      B.at(i)=0;
    }
    if(A.at(i+1) < B.at(i)) {
      ans += A.at(i+1);
      B.at(i) -= A.at(i+1);
      A.at(i+1)=0;
    }
    else {
      ans+=B.at(i);
      A.at(i+1) -= B.at(i);
      B.at(i)=0;
    }
  }
  cout << ans << endl;
  return 0;
}
      

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  vector<char> ans;
  
  for(int i=0;i<s.size();i++){
    if(s[i]=='0'){
      ans.push_back('0');
    }
    else if(s[i]=='1'){
      ans.push_back('1');
    }
    else if(ans.size()!=0){
      ans.erase(ans.end()-1);
    }
    
  }
  for(auto& c:ans){
    cout<<c;
  }
}

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

int main(){
    int S, h, m, s;
    cin >> S;
    h = S / 3600;
    m = (S % 3600) / 60;
    s = (S % 3600) % 60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}



Measured memory_bytes: 3096
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			var e = new List<Tuple<int, int>>(n * n);
			for (int i = 1; i <= n; i++) {
				for (int j = i + 1; j <= n; j++) {
					if (n % 2 == 0) {
						if (j == n - i + 1) {
							continue;
						}
					} else {
						if (j == n - i) {
							continue;
						}
					}

					e.Add(new Tuple<int, int>(i, j));
				}
			}

			var sb = new StringBuilder();
			int m = e.Count;
			sb.AppendLine(m.ToString());
			for (int i = 0; i < m; i++) {
				sb.AppendLine($"{e[i].Item1} {e[i].Item2}");
			}

			Console.Write(sb.ToString());
		}
	}
}

Measured memory_bytes: 13268
x,k,d = map(int,input().split())
x = abs(x)
import numpy as np
if x / d > k:
    print(x - k*d)
    
else:
    if (k - x//d) % 2 == 0:
        print(np.mod(x,d))
        
    else:
        print(abs(np.mod(x,d) - d))

Measured memory_bytes: 27056
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<31-1;
const int MOD = 1000000007;

string H = "MARCH";

void solve(void){
    int N;
    cin >> N;
    map <char, ll> mp;
    rep(N, i) {
        string S; cin >> S;
        mp[S[0]]++;
    }
    ll ans = 0LL;
    vector <int> w = {0,0,1,1,1};
    do {
        ll tmp = 1LL;
        rep(5, i) {
            if (w[i]) tmp *= mp[H[i]];
        }
        ans += tmp;
    } while(next_permutation(all(w)));
    cout << ans << endl;
}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int a, b, c, d, e, f, g, h, i;
	cin >> a >> b >> c >> d >> e >> f >> g >> h >> i;
	if (a - d == b - e&&a - d == c - f) {
		if (a - g == b - h&&a - g == c - i) {
			if (a - b == d - e&&a - b == g - h) {
				if (a - c == d - f&&a - c == g - i) {
					cout << "Yes\n";
				}
				else cout << "No\n";
			}
			else cout << "No\n";
		}
		else cout << "No\n";
	}
	else cout << "No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int N;cin>>N;
    cout<<((N<=999)?"ABC":"ABD")<<endl;
}

Measured memory_bytes: 3644