akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
const long long INF = 1e18;
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

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


Measured memory_bytes: 256
n, m = map(int, input().split()) 
a = list(map(int, input().split()))
b = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [-1] * (n + 1)
dp[n] = 0

for i in range(n, -1, -1):
    for j in range(m):
        x = b[a[j]]
        if dp[i] != -1 and i - x >= 0:
            dp[i - x] = max(dp[i - x], 10 * dp[i] + a[j])
            
print(dp[0])

Measured memory_bytes: 78912
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    cout << n - k + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
n,m,k = map(int,input().split())
deskA = list(map(int,input().split()))
deskB = list(map(int,input().split()))
cumA = list(accumulate(deskA))
cumB = list(accumulate(deskB))
cumA = [0] + cumA
cumB = [0] + cumB
ans = 0
l = m
for i in range(n+1):
    tmp = k - cumA[i]
    if tmp<0:
        continue
    j = l
    tmp -= cumB[j]
    while tmp < 0:
        tmp += cumB[j]
        j -= 1
        tmp -= cumB[j]
    l = j
    ans = max(i+j,ans)
print(ans)

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

int main() {
    int n;
    while (cin >> n) {
        bool first = true;
        for (int i=1; i<=512; i<<=1) {
            if (n & i) {
                cout << (first ? "" : " ") << i;
                first = false;
            }
        }
        cout << endl;
    }
    return 0;
}

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

#define lop(n) for(int i=0; i<n; i++)
#define loop(j,n) for(int i=j; i<n; i++)

typedef long long ll;

using namespace std;

int main()
{
    string str;
    while(cin>>str)
    {
        if(str[0]=='0')
            return 0;
        int len = str.size();
        int sum = 0;
        lop(len)
            sum+=str[i]-48;

        cout<<sum<<endl;
    }

    return 0;
}




Measured memory_bytes: 3164
#include<bits/stdc++.h>
#define re register
#define int long long
using namespace std;
const int maxn=1e5+10;
int n,YZ,a[maxn],tree[maxn<<1],aa[maxn],l,r,mid;
int lowbit(int x){
    return x&(-x);
}
void add(int x){
    while(x<(maxn<<1)){
        ++tree[x];
        x+=lowbit(x);
    }
}
int query(int x){
    int ans=0;
    while(x){
        ans+=tree[x];
        x-=lowbit(x);
    }
    return ans;
}
bool check(int m){
    int cnt=0;
    memset(tree,0,sizeof(tree));
    for(re int i=1;i<=n;++i){
        if(a[i]<=m){
            aa[i]=1;
        }
        else{
            aa[i]=-1;
        }
    }
    aa[0]=0;
    for(re int i=1;i<=n;++i){
        aa[i]+=aa[i-1];
    }
    for(re int i=0;i<=n;++i){
        aa[i]+=maxn;
    }
    add(aa[0]);
    for(re int i=1;i<=n;++i){
        cnt+=query(aa[i]-1);
        add(aa[i]);
    }
    return cnt>=YZ;
}
signed main(){
    scanf("%lld",&n);
    YZ=n*(n+1)/4+1;
    for(re int i=1;i<=n;++i){
        scanf("%lld",&a[i]);
    }
    l=0,r=1e9;
    while(l<r){
        mid=(l+r)>>1;
        if(check(mid)){
            r=mid;
        }
        else{
            l=mid+1;
        }
    }
    printf("%lld\n",l);
    return 0;
}

Measured memory_bytes: 6948
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0LL);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

template <class T>
void VecRowShow(vector<T> vec) {
	rep(i, vec.size()) {
		if (i != vec.size() - 1) cout << vec[i] << " ";
		else cout << vec[i] << endl;
	}
}

unsigned gcd(unsigned a, unsigned b) {
	if (a < b) return gcd(b, a);
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}


ll PowMod(ll a, ll b) {
	if (b == 1) return a % MOD;
	if (b == 0) return 1;
	ll d = (ll)PowMod(a, b / 2);
	ll c = (d * d) % MOD;
	if (b % 2 == 0) {
		return c;
	}
	else {
		return (c * a) % MOD;
	}
}

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

	ll ans = 0;

	vector<ll> c(k + 1);
	for (ll x = k; x > 0; x--) {

		if (x == 50000) {
			ll zz = x;
		}

		//1~kのうちxの倍数のもの
		ll kx = k / x;
		ll xbn = PowMod(kx, n);

		//xの倍数に対してのc[y]を引いていく
		ll x2 = x;
		while (1) {
			x2 += x;
			if (x2 > k) {
				break;
			}
			xbn -= c[x2];
			if (xbn <= 0) xbn += MOD;
		}
		c[x] = xbn;
		ans += ((ll)c[x] * x) % MOD;
		ans = ans % MOD;
	}

	cout << ans << endl;

}




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

int main(){
  std::vector<std::string> a;

  int N,L;
  cin >> N;
  cin >> L;

  for(int i = 0;i < N;i++){
    string b;
    cin >> b;
    a.push_back(b);
  }

  sort(a.begin(), a.end());

  for(int i = 0;i < N;i++){
    std::cout << a[i];
  }
  std::cout << std::endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <numeric>
 
int const N = 1000001;
 
int spf[N], u[N], s[17], d, i, j, k;
char const* r = "pairwise";
 
int main() {
    while (++i < N)spf[i] = i;
    for (i = 2; i * i < N; i++)
        for (j = i * i; j < N; j += i)
            if (spf[j] == j)
                spf[j] = i;
    for (scanf("%*d"); ~scanf("%d", &j); k = 0) {
        d = std::gcd(d, j);
        for (; j > 1; j /= i) {
            s[k++] = i = spf[j];
            if (u[i]) r = "setwise";
        }
        while(k--)u[s[k]] = 1;
    }
    printf("%s coprime\n", d > 1 ? "not" : r);
    return 0;
}


Measured memory_bytes: 9540
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N = lread();
    auto S = sread();
    char c = S[0];
    long cnt = 1;
    foreach (i; 1 .. N)
        if (c != S[i])
        {
            c = S[i];
            cnt++;
        }
    writeln(cnt);
}


Measured memory_bytes: 2428
#include <stdio.h>
int main(void){
	int n=0,m=0,i=0;
	int t[100],k[100],s[100];

	while(1){
		scanf("%d %d %d",&t[i],&k[i],&s[i]);
		if((t[i] == -1) && (k[i] == -1))
			break;
		i++;
		n++;
	}
	i = 0;
	while(m != n){
		if((t[i]==-1) || (k[i]==-1)){
			printf("F\n");
			goto w;}
		if(t[i]+k[i]<30){
			printf("F\n");
			goto w;}
		if((30<=t[i]+k[i] && t[i]+k[i]<50) && s[i]<50)
			printf("D\n");
		if((30<=t[i]+k[i] && t[i]+k[i]<50) && s[i]>=50)
			printf("C\n");
		if((50<=t[i]+k[i] && t[i]+k[i]<65))
			printf("C\n");
		if((65<=t[i]+k[i]) && (t[i]+k[i]<80))
			printf("B\n");
		if(80<=t[i]+k[i])
			printf("A\n");
		w:
		i++;
		m++;
	}
	return 0;
}

Measured memory_bytes: 584
n = int(input())
alist = list(map(int,input().split()))

mod = 10**9 + 7
sum = alist[0]
ans = 0
for i in range(n-1):
    ans = (ans + sum*alist[i+1]) % mod
    sum = (sum + alist[i+1]) % mod

print(ans)

Measured memory_bytes: 31528
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    for( int i = 0; i< N; i++){
        string S;
        cin >> S;
        if( S == "Y" ){
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
}


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

int main(){
  int k1,k2,a,kek;
  string s1[101],s2[101];
  cin>>a;
  kek=0;
  k1=0;
  k2=0;
  for(int i=0;i<a;i++)cin>>s1[i];
  for(int i=0;i<a;i++)cin>>s2[i];
  for(int i=0;i<a;i++){
    if(kek==0){//テァツオツ静ヲツ楪愿」ツ?古・ツ?コテ」ツ?淌」ツつ?
      if(s1[i]=="kougekida"&&s2[i]=="kougekida"){//////////
	if(k1==k2){
	  k1=0;
	  k2=0;
	}else if(k1>k2){
	  kek++;
	  cout<<"Isono-kun"<<endl;
	} else if(k2>k1){
	  kek++;
	  cout<<"Nakajima-kun"<<endl;
	}
      }
      else if(s1[i]=="kougekida"&&s2[i]=="tameru"){///////
	kek++;
	if(k1!=0)cout<<"Isono-kun"<<endl;
	else cout<<"Nakajima-kun"<<endl;
      }
      else if(s1[i]=="kougekida"&&s2[i]=="mamoru"){//////
	if(k1==0){
	  kek++;
	  cout<<"Nakajima-kun"<<endl;
	}else if(k1==5){
	  kek++;
	  cout<<"Isono-kun"<<endl;
	}else k1=0;
      }
      else if(s1[i]=="tameru"&&s2[i]=="kougekida"){////////
	
	kek++;
	if(k2!=0)cout<<"Nakajima-kun"<<endl;
	else cout<<"Isono-kun"<<endl;
	
      }
      else if(s1[i]=="tameru"&&s2[i]=="tameru"){//////
	
	if(k1<5)k1++;
	if(k2<5)k2++;
	
      }
      else if(s1[i]=="tameru"&&s2[i]=="mamoru"){////
	if(k1<5)k1++;
      }
      else if(s1[i]=="mamoru"&&s2[i]=="kougekida"){///////
	if(k2==0){
	  kek++;
	  cout<<"Isono-kun"<<endl;
	}else if(k2==5){
	  kek++;
	  cout<<"Nakajima-kun"<<endl;
	}else k2=0;
      }
      else if(s1[i]=="mamoru"&&s2[i]=="tameru")if(k2<5)k2++;/////
    }
    //cout<<k1<<" "<<k2<<" "<<kek<<endl;///////////llll
  }
  if(kek==0)cout<<"Hikiwake-kun"<<endl;
  return 0;
}
  
  

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

int main(void){
   
   int A,B,C;
   
   scanf("%d %d %d",&A,&B,&C);
   
   if(A + B >= C - 1){
      printf("%d\n",B + C);
   }
   else {
      printf("%d\n",2*B + A + 1);
   }
   
   return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds; 
using namespace std;
#define int long long
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define mii map<int,int>
#define mp make_pair
#define pb push_back
#define rep(i,b) for(ll (i)=0;i<(b);i++)
#define all(c) (c).begin(), (c).end()
#define F first
#define S second
#define CLR(p) memset(p, 0, sizeof(p))
#define SET(p) memset(p, -1, sizeof(p))
#define DEBUG true
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
//typedef long long int ll;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
tree_order_statistics_node_update> new_data_set; 
const int MAX=200005;
#define MOD 1000000007
/*std::cout << std::fixed;
std::cout << std::setprecision(6);*/
//(a%mod-b%mod+mod)%mod



/************************************


 
*************************************/

vector<vector<ll>>v;
ll T=0;
ll cnt1=0,cnt0=0;
vector<ll>dep;
bool visited[MAX];
vector<ll>par;
vector<ll>tin,tout;
vector<ll>col;
ll f=0,k=1;
map<pll,ll>m;
ll dp1[MAX],dp2[MAX];
ll red,blue;
ll ans;
ll dp[MAX];

ll lca(ll u,ll v){
	while(u!=v){
		ll l1,l2;
		l1 = log2(u);
		l2 = log2(v);
		//cout<<l1<<"$$"<<l2<<endl;
		if(l1<l2)
			swap(u,v);
		u /=2;
	}
	return u;
}





signed main(){
	boost;
	int t=1;
	// cin>>t;
	while(t--){
		int n;
		cin>>n;
		int sum=0;
		for(int i=1;i<=n;i++){
			if(i%3!=0&&i%5!=0)
				sum+=i;
		}
		cout<<sum<<"\n";
	}

	return 0;
}

Measured memory_bytes: 3692
N = int(input())
tnow = 0
xnow = 0
ynow = 0
flag = 1
for i in range(N):
  t, x, y = map(int, input().split())
  cost = abs(x-xnow)+abs(y-ynow)
  if cost <= t - tnow and (t-tnow-cost)%2==0:
    tnow = t
    xnow = x
    ynow = y
    continue
  else:
    flag = 0
    break
if flag == 1:
  print('Yes')
else:
  print('No')
  
  

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl; 
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF =0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a,LL b){LL s=1;while(b>0){if(b&1)s=s*a%mod;a=a*a%mod;b>>=1;}return s;}
LL gcd(LL a,LL b) {return b?gcd(b,a%b):a;}
int dr[2][4] = {1,-1,0,0,0,0,-1,1};
typedef pair<int,int> P;
const int maxn = 1e5+10;
int A[maxn];
int main(void)
{
	int N;cin>>N;
	set<P> s;
	for(int i = 1;i <= N; ++i){
		cin>>A[i];
		auto it = s.lower_bound(P(A[i],0));
		if(it != s.begin()){
			it--;
			s.erase(it);
			
		}
		s.insert(P(A[i],i));
	}
	cout<<s.size()<<endl;
    

   return 0;
}

Measured memory_bytes: 5376
#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 eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

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

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

inline int topbit(unsigned long long x){
	return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
	return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
	return __builtin_parity(x);
}

int C[55][55];

int N,K,S,T;

int num[55];
int cnt[1<<18];
signed main(){
	rep(i,55){
		C[i][0]=C[i][i]=1;
		for(int j=1;j<i;j++)C[i][j]=C[i-1][j-1]+C[i-1][j];
	}
	cin>>N>>K>>S>>T;

	for(int i=1;i<=N;i++){
		for(int k=1;k<=K;k++)num[i]+=C[i][k];
	}

	swap(S,T);
	
	if((S&T)!=T){
		cout<<0<<endl;
		return 0;
	}

	vint A;
	rep(i,N){
		int a;cin>>a;
		if((a&T)!=T)continue;
		if((a&S)!=a)continue;
		int aa=0;
		rep(j,18){
			if(T>>j&1)continue;
			if(!(S>>j&1))continue;
			aa=aa*2+(a>>j&1);
		}
		A.pb(aa);
	}

	int B=0;
	rep(i,18){
		if(T>>i&1)continue;
		if(!(S>>i&1))continue;
		B++;
	}


	int ans=0;
	rep(i,1<<B){
		for(auto a:A){
			cnt[a&i]++;
		}
		int tmp=0;
		for(auto a:A){
			tmp+=num[cnt[a&i]];
			cnt[a&i]=0;
		}
		if(parity(i))ans-=tmp;
		else ans+=tmp;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5704
#include <stdio.h>
#include <math.h>

int main(){
    int N;
    double L;
    L = 0.0;
    scanf("%d", &N);
    int x[N], y[N];

    for (int i = 0; i <= N - 1;i++)
    {
        scanf("%d", &x[i]);
        scanf("%d", &y[i]);        
    }

    for (int i = 0; i <= N-1;i++)
    {
        for (int n = 0; n <= N - 1;n++)
        {
            L = L + sqrt((x[n] - x[i]) * (x[n] - x[i]) + (y[n] - y[i]) * (y[n] - y[i]));
        }
    }
    L = L / N;
    printf("%.10lf", L);
    return 0;
}

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

int main() {
    //input
    int n;
    cin >> n;
    int diff[n];
    int v[n];
    int c;
    for(int i=0;i<n;i++){
        cin >> v[i];
    }
    for(int i=0;i<n;i++){
        cin >> c;
        diff[i] = v[i] - c;
    }

    int sum = 0;
    for(int i=0;i<n;i++){
        sum += max(0,diff[i]);
    }
    cout << sum << endl;

    return 0;
}

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

#define ll long long

int main(){
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  if(k<=a)
    cout<<k<<endl;
  else if(k<=(a+b))
    cout<<a<<endl;
  else
    cout<<a-(k-a-b)<<endl;
  return 0;
} 


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100010
#define INF 10000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
    int n;
    IN(n);
    vector<int>a(n);
    REP(i,n){
        IN(a[i]);
    }
    vector<int>x(n);
    ll tmp=0;
    for(int i=0;i<=n-3;i+=2){
        tmp+=a[i];
    }
    tmp*=2;
    REP(i,n){
        tmp-=a[i];
    }
    x[n-1]=-tmp;
    for(int i=n-2;i>=0;i--){
        x[i]=2*a[i]-x[i+1];
    }
    REP(i,n){
        OUT(x[i]);
    }
	return 0;
}

Measured memory_bytes: 2048
// ProblemURL : https://atcoder.jp/contests/abc104/tasks/abc104_c
// ---------------------------------------------
package main

import "fmt"

var inf = 1 << 60

func smaller(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var n, targetScore int
	fmt.Scan(&n, &targetScore)
	type problem struct {
		point int
		count int
		bonus int
	}
	problems := make([]problem, n)
	for i := 0; i < n; i++ {
		var p, c int
		fmt.Scan(&p, &c)
		problems[i] = problem{
			point: (i + 1) * 100,
			count: p,
			bonus: c,
		}
	}
	ctSolvedMin := inf
	for i := 0; i < (1 << uint(n)); i++ {
		ctSolved := 0
		score := 0
		for j := 0; j < n; j++ {
			if i>>uint(j)&1 == 1 {
				ctSolved += problems[j].count
				score += problems[j].point * problems[j].count
				score += problems[j].bonus
			}
		}
		if score >= targetScore {
			ctSolvedMin = smaller(ctSolvedMin, ctSolved)
		} else {
			for j := n - 1; j >= 0; j-- {
				if i>>uint(j)&1 == 1 {
					continue
				}
				for h := 0; h < problems[j].count; h++ {
					ctSolved++
					score += problems[j].point
					if score >= targetScore {
						break
					}
				}
				if score >= targetScore {
					break
				}
			}
			ctSolvedMin = smaller(ctSolvedMin, ctSolved)
		}
	}
	fmt.Println(ctSolvedMin)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

int n;
string s;

bool ispalin(int l,int r){
	while(l < r){
		if(s[l - 1] != s[r - 1]) return false;
		l++;r--;
	}
	return true;
}

signed main(){
	cin >> s;
	n = s.length();
	isYes(ispalin(1,n) && ispalin(1,(n - 1) / 2) && ispalin((n + 3) / 2,n));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
const int maxn = 1e2 + 10 ;
vector < long long  > v ;
long long n , m , p[maxn] , t[maxn] ,  sum ;
int main()
{
	cin >> n ;
	for ( int i = 0 ; i< n ; i++) 
		cin >> t[i], sum += t[i]  ;
	cerr << " sum " << sum << endl;
	cin >> m ;
	for ( int i = 0; i< m ; i++)
	{
		int j , x ;
		cin >> j >> x ;
		j--;
		cerr << " J " << j << "  t[j] " << t[j] << " x " << x << " " ;
		long long ans = sum - t[j] + x ;
		cerr << "   ans " << ans << endl;
		v.push_back( ans ) ;
	}
	for ( int i = 0 ; i<v.size() ; i++)
		cout << v[i] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD (ll)1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, n, m) for (int i = (n), i < (m); i++)

ll gcd(ll a, ll b) {
  if (a == 0 || b == 0) return a + b;
  if (b > a) return gcd(b, a);
  return gcd(b, a % b);
}

char pp[10000000] = {};

int
main(int argc, char *argv[])
{
  ll a, b;
  scanf("%lld %lld", &a, &b);
  ll c = gcd(a, b);

  ll i = 2;
  
  int k = 0;
  ll d = c;
  while (i * i <= c) {
    if (pp[i] == 0) {
      if (c % i == 0) {
	while (d % i == 0) d /= i;
	k++;
      }
      ll j = 2;
      while (i * j * i * j<= c) {
	pp[i * j] = 1;
	j++;
      }
    }
    i++;
  }
  //printf("%lld\n", d);
  if (d == 1) printf("%d\n", k + 1);
  else if (k == 0) {
    if (c == 2) printf("2\n");
    else printf("2\n");
  }
  else printf("%d\n", k + 2);
  return 0;
}


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

const long long MOD = 1000000007;
const long long MAX = 2000000;

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

int main()
{
    string S, T, U;
    int A, B;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;
    if(S==U){
        cout << A-1;
        cout << " ";
        cout << B << endl;

    }else{
        cout << A;
        cout << " ";
        cout << B-1 << endl;

    }
}


Measured memory_bytes: 256
import java.util.Scanner;

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

			int n = sc.nextInt();
			int m = sc.nextInt();
			
			int hw = 0;
			for(int i = 0 ; i < m ; i++ ) {
				hw += sc.nextInt();
			}
			
			int left = n - hw;
			
			System.out.println(left >= 0 ? left : -1);
			
			
		}
	}

}

Measured memory_bytes: 46068
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define ll long long

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

#define inf std::numeric_limits<int>().max();

int main() {
	int n;
	cin >> n;
	cout.precision(10);
	vector<double> v(n);
	for(int i=0; i<n; i++) {
		cin >> v[i];
	}
	for(int i=0; i<n; i++) {
		v[i] = (1 / v[i]);
	}
	double ans = 0;
	for(int i=0; i<n; i++) {
		ans += v[i];
	}
	cout << (1/ans) << endl;
}


Measured memory_bytes: 256
//2018_1208_1

#include<stdio.h>

int main()
{
	int D;

	scanf("%d", &D);

	if (D == 25)
	{
		printf("Christmas\n");
	}

	if (D == 24)
	{
		printf("Christmas Eve\n");
	}

	if (D == 23)
	{
		printf("Christmas Eve Eve\n");
	}

	if (D == 22)
	{
		printf("Christmas Eve Eve Eve\n");
	}


	return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a[] = new int[n];
    
    for(int i = 0 ; i < n ; ++i){
      a[i] = sc.nextInt();
    }
    //後ろから
    for(int i = n-1 ; i >= 0 ; i-=2){
      System.out.print(a[i]+" ");
    }
    
    //前から
    if(n%2==1){
      //奇数
      for(int i = 1 ; i < n ; i+=2){
        System.out.print(a[i]+" ");       
      }
    }else{
      //偶数
      for(int i = 0 ; i < n ; i+=2){
        System.out.print(a[i]+" ");
      }

    }

  }
}

Measured memory_bytes: 62068
use proconio::input;
use proconio::marker::Usize1;

fn main() {
    input! {
        n: usize,
        k: usize,
        nodes: [(Usize1, Usize1); n - 1],
    }

    let mo = 10usize.pow(9) + 7;
    let mut list = vec![vec![]; n];
    for &node in &nodes {
            list[node.0].push(node.1);
            list[node.1].push(node.0);
    }

    let mut ans = k;
    if k < list[0].len() {
        println!("{}", 0);
        return;
    }
    for i in 1..=list[0].len() {
        ans *= k - i;
        ans %= mo;
    }
    //println!("ans {}", ans);

    for i in 1..n {
        let child = list[i].len() - 1;
        if k - 2 < child {
            println!("{}", 0);
            return;
        }
        for j in 0..child {
            ans *= k - 2 - j;
            ans %= mo;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 11124
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll n,k,ans=0;
  string s;
  cin>>s;
  cin>>k;
  n=s.size();
  ll f=1;
  for(ll i=0;i<n;i++){
    if(s[i]!=s[0])f=0;
  }
  if(f==1){
    ans+=(n*k)/2;
    cout<<ans<<endl;
    return 0;
  }
  string s2=s+s;
  for(ll i=0;i<n-1;i++){
    ll t=0;
    while(i<n-1&&s[i]==s[i+1]){
      t++;
      i++;
    }
    ans+=(t+1)/2;
  }
  ll i=1;
  ll t=1,t1=0;
  while(s[0]==s[i]){
    t++;
    i++;
  }
  i=n-1;
  while(s[0]==s[i]){
    t1++;
    i--;
  }
  ll aa=ans*k-(t/2+t1/2-(t+t1)/2)*(k-1);
  cout<<aa<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		
		if(B <= C || D <= A) {
			System.out.println(0);
		} else if(C < B && B <= D && A <= C) {
			System.out.println(B - C);
		} else if(A <= C && D < B) {
			System.out.println(D - C);
		} else if(C < A && A <= D && D <= B) {
			System.out.println(D - A);
		} else {
			System.out.println(B - A);
		}
				
	}
}


Measured memory_bytes: 21844
#include<iostream>
	#include<stdlib.h>
	#include<vector>
	#include<algorithm>
	#include<stdio.h>
	#include<string>
	#include<map>
	#include<math.h>
	#include<iomanip>
	#include<set>
	#include<limits.h>
	#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
	#define swap(a,b) a^=b;b^=a;a^=b;
	#define chmax(a,b) {if(a < b) a = b;}
	#define chmin(a,b) {if(a > b) a = b;}
	using namespace std;
	typedef long long ll;
	ll gcd(ll, ll);
	vector<bool> to_binary(int);
	int sum(vector<int>);
	int min(vector<int>);
	int max(vector<int>);
	ll nCr(ll n, ll r);

	const ll INF = 1LL << 60;

	typedef tuple<ll, ll> mtupl;

	bool mycomp(mtupl x, mtupl y) {
		return get<1>(x) < get<1>(y);
	}

	int main(void) {
		cin.tie(0);
		ios::sync_with_stdio(false);
		//Program Start	

		int N;
		cin >> N;

		vector<mtupl> AB(N);
		ll A, B;
		rep(i, N) {
			cin >> A >> B;
			AB[i] = make_pair(A, B);
		}

		sort(AB.begin(), AB.end(), mycomp);

		int time = 0;
		rep(i, N) {
			time += get<0>(AB[i]);
			if (time >get<1>(AB[i])) {
				cout << "No" << endl;
				goto ProgramEndPointLabel;
			}
		}
		cout << "Yes" << endl;

		/*
		ll N, W;
		cin >> N >> W;

		vector<ll> w(N), v(N);

		rep(i, N) {
			cin >> w[i] >> v[i];
		}

		vector<vector<ll>> dp(N + 1);
		rep(i, N + 1) dp[i].resize(W + 1);

		for (int i = 0; i < N; i++) {
			for (int weight = 0; weight <= W; weight++) {
				if (weight - w[i] < 0) {
					chmax(dp[i + 1][weight], dp[i][weight]);
				}
				else chmax(dp[i + 1][weight], dp[i][weight - w[i]] + v[i]);
			}
		}

		/*
		rep(i, N + 1) {
			rep(j, W + 1) {
				cout << to_string(dp[i][j]) + " ";
			}
			cout << endl;
		}*

		cout << dp[N][W] << endl;

		*/

	ProgramEndPointLabel:;

		//Program End
		system("pause");

		return 0;
	}

	ll nCr(ll n, ll r) {
		ll res = 1;
		for (int i = 0; i < r; i++) {
			res *= (n - i);
		}
		for (int i = 1; i <= r; i++) {
			res /= i;
		}
		return res;
	}

	int vsum(vector<int> v) {
		int res = 0;
		for (auto it = v.begin(); it != v.end(); it++)
			res += *it;
		return res;
	}
	int vmin(vector<int> v) {
		int min = INT32_MAX;
		for (auto it = v.begin(); it != v.end(); it++)
			min = std::min(min, *it);
		return min;
	}
	int vmax(vector<int> v) {
		int max = 0;
		for (auto it = v.begin(); it != v.end(); it++)
			max = std::max(max, *it);
		return max;
	}

	ll gcd(ll A, ll B) {
		int r = A % B;
		while (r != 0) {
			A = B;
			B = r;
			r = A % B;
		}

		return B;
	}

	vector<bool> to_binary(int x) {
		vector<bool> res;
		while (x != 0) {
			res.push_back(x % 2);
			x /= 2;
		}
		return res;
	}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    int cost[52][52];
    rep(i, 0, 51) rep(j, 0, 51) cost[i][j] = INF;
    rep(i, 0, 51) cost[i][i] = 0;
	rep(i, 0, 51){
		rep(j, 0, i){
			rep(k, 1, 51){
				if(i % k == j){
                    cost[i][j] = 1LL << k;
					break;
				}
            }
		}
    }
    rep(k, 0, 51){
        rep(i, 0, 51){
            rep(j, 0, 51){
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
            }
        }
    }
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) cin >> b[i];
    int ans = 0;
    rep(i, 0, n){
        if(cost[a[i]][b[i]] == INF){
            cout << -1 << endl;
            return 0;
        }
    }
    while(1){
        int now = 0;
        rep(i, 0, n){
            now |= cost[a[i]][b[i]];
        }
        int high = -1;
        repb(i, 50, 1){
            if(now & (1LL << i)){
                high = i;
                break;
            }
        }
        if(high == -1) break;
        ans |= 1LL << high;
        // cout << high << ' ' << ans << endl;
        rep(i, 0, 51){
            rep(j, 0, 51){
                if(cost[i][j] == INF) continue;
                // if(cost[i][j] & (1LL << high)) cost[i][j] ^= (1LL << high);
                if(i % high == j) cost[i][j] = 0;
            }
        }
        rep(k, 0, 51){
            rep(i, 0, 51){
                rep(j, 0, 51){
                    cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
                }
            }
        }
        // cout << high << " " << ans << endl;
        // for(int ii = 0; ii < a.size(); ii++){
        //     if(ii) cout << ' ';
        //     cout << a[ii];
        // }
        // cout << endl;        
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int T = 0;
    int times = 1;
    int ans = 0;
    rep(j, 16){
        rep(i, 9){
            if (T + times <= N){
                T += times;
                ans++;
            } else break;
        }
        times *= 10;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//CLOCKS_PER_SEC
#define se second
#define fi first
#define ll long long
#define Pii pair<int,int>
#define Pli pair<ll,int>
#define ull unsigned long long
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define fio ios::sync_with_stdio(false);cin.tie(0);
#define db double
#define mk make_pair
const double Pi=3.14159265;
const int N = 2e3+10;
const int M = 2e5+10;
const ull base=163;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const db eps=1e-8;
const db pi=acos(-1);
using namespace std;
ll c[N][N];
int main(){
    fio;
    c[0][0] = 1;
    for(int i = 1; i <= 2000; ++i){
        c[i][0] = 1;
        for(int j = 1; j <= 2000; ++j){
            c[i][j] = (c[i-1][j-1] + c[i-1][j])%mod;
        }
    }
    ll n, k;
    cin>>n >> k;
    for(int i = 1; i <= k; ++i){
        ll ans = 1LL*c[k-1][i-1] * c[(n-k+1)][i]%mod;
        //cout<<c[k-1][i-1]<<" "<<i<<" "<<c[n-k+1][i]<<endl;
        if(n-k+1 >= i){}
        else ans = 0;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 31616
<?php

class Inputs
{
    public static function d()
    {
        fscanf(STDIN, '%d', $a);
        return $a;
    }
    public static function line()
    {
        return fgets(STDIN);
    }
}

$n = Inputs::d();
$a = Inputs::line();

$as = explode(' ', $a);

$leave_count = 1;

foreach ($as as $brick) {
    if ($leave_count === intval($brick)) {
        $leave_count++;
    }
}

$break_count = count($as) - ($leave_count - 1);

echo (($break_count === count($as)) ? -1 : $break_count) . PHP_EOL;


Measured memory_bytes: 18936
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  if (s[0] == s[2])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
S=str(input())
S=S.translate(str.maketrans({'A': 'a', 'T': 'a', 'C': 'a','G': 'a'}))

if "a" in S:
    l=len(S)
    for i in range(1,l+1):
        b=S.count(str("a"*i))
        if b == 0:
            print(i-1)
            break
        if i==l:
            print(l)
else:
    print("0")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5+5;
typedef long long ll;

ll a[MAX_N];

int main()
{
	ll n, x, ans = 0;
	cin >> n >> x;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 1; i < n; i++)
	{
		if (a[i]+a[i-1] > x)
		{
			ans += a[i]+a[i-1]-x;
			a[i] = max(0ll, x-a[i-1]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
N, M = [int(x) for x in input().strip().split(" ")]

def dfs(v):
    pvs = set([v])
    path = [v]
    def _dfs(v, path):
        for u in d[v]:
            if u in pvs:
                for i, c in enumerate(path):
                    if c == u:
                        break
                return path[i+1:]  + [u]
            if u in vs:
                continue
            pvs.add(u)
            vs.add(u)
            loop = _dfs(u, path + [u])
            pvs.remove(u)
            if loop:
                return loop
        return False
    return _dfs(v, path)

vs = set()
def dfs_w(v, d):
    # dfs while版 
    pvs = set([])
    stack = [v]
    path = []
    while True:
        if len(stack) == 0:
            break
        v = stack.pop()
        if v < 0:
            pvs.remove(path[-1])
            path.pop()
        else:
            path.append(v)
            pvs.add(v)
            vs.add(v)
            for u in d[v]:
                if u in pvs:
                    for i, c in enumerate(path):
                        if c == u:
                            break
                    return path[i+1:]  + [u]
                if u in vs:
                    continue
                stack += [-v, u]
    return False

d = [set() for _ in range(N+1)]
for _ in range(M):
    a, b = [int(x) for x in input().strip().split(" ")]
    d[a].add(b)

for i in range(N):
    i += 1
    if i in vs:
        continue
    loop = dfs_w(i, d)
    if loop:
        break

if not loop:
    print(-1)
    import sys
    sys.exit()

v2i = [-1 for _ in range(N+1)]
for i, v in enumerate(loop):
    v2i[v] = i

nloop, pvs = [], set()
v = loop[0]
f = False
while True:
    nloop.append(v)
    pvs.add(v)
    max_i = max_i_l = -1
    for u in d[v]:
        if v2i[u] == -1:
            continue
        if v2i[v] > v2i[u] and u in pvs:
            f = True
            max_i_l = max(max_i_l, v2i[u])
        if v2i[u] > v2i[v]:
            max_i = max(max_i, v2i[u])
    if f:
        nloop.append(loop[max_i_l])
        break
    v = loop[max_i]

for i, x in enumerate(nloop):
    if x == nloop[-1]:
        break
nloop = nloop[i+1:]
print(len(nloop))
for v in nloop:
    print(v)


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

int main(){
	int a, b;
	cin >> a >> b;
	a = a+b;
	if(a >= 10) cout << "error" << endl;
	else cout << a << endl;
	
	return 0;
}

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

int main(){
    string S="";
    string s;
    cin>>s;
    rep(i,s.size()){
        if(s.at(i)=='0'){
            S+='0';
        }else if(s.at(i)=='1'){
            S+='1';
        }else if(s.at(i)=='B'){
            if(S==""){

            }else{
                S.erase(S.size()-1);
            }
        }else{}
    }
    cout<<S<<endl;
return 0;}
/*compile
g++ code.cpp
./a.out
run*/
/*
int f(int x){
    int y=int((x*x+4.0)/8.0);
    return y;
}
*/


Measured memory_bytes: 256
N,M=map(int, input().split())
E=[[] for _ in range(N+1)]
for _ in range(M):
    a,b=map(int,input().split())
    E[a].append(b)
    E[b].append(a)
for e1 in E[1]:
    for e2 in E[e1]:
        if e2==N:
            print('POSSIBLE')
            exit()
print('IMPOSSIBLE')

Measured memory_bytes: 38320
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  int ans=0;
  ans+=max(a,b);
  ans+=max(a,b)-1;
  if(a==b) ans++;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream> 
#include <cstdio> 
#include <cstdlib> 
#include <cstring> 
#include <cmath> 
#include <algorithm> 
#include <vector> 
using namespace std; 
const int MAX_N = 3e3 + 5; 
vector<int> G[MAX_N]; 
int N, a[MAX_N]; 
int f[MAX_N]; 
void dfs(int x, int fa) { 
	f[x] = 0; 
	for ( int v : G[x]) {
		if (v == fa || a[x] <= a[v]) continue; 
		dfs(v, x); 
		if (!f[v]) f[x] = 1; 
	} 
} 
int main () { 
	scanf("%d", &N); 
	for (int i = 1; i <= N; i++) scanf("%d", a + i); 
	for (int i = 1; i < N; i++) {
		int u, v; scanf("%d %d", &u, &v); 
		G[u].push_back(v), G[v].push_back(u); 
	} 
	for (int i = 1; i <= N; i++) { 
		dfs(i, 0); 
		if (f[i]) printf("%d ", i); 
	} 
	putchar('\n'); 
    return 0; 
} 

Measured memory_bytes: 512
# Python template 
from collections import defaultdict 
import sys
import math 

def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

s = input()

ans = 0

for i in s:
    ans = (ans+int(i))%9

if ans:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9600
public class Main {
	public static void  main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();

		//int d;
		//d = a/b;
		System.out.println(a/b);

		//int r;
		//r = a%b;
		System.out.println(a%b);

		double f = (double)a/b;
		System.out.printf("%f\n",f);
	}

}

Measured memory_bytes: 26408
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

ll l[300005];

// including i of the elements
ll lhsSum[100005];
ll rhsSum[100005];

int n;

void computeLHS() {
  priority_queue<ll> q;
  ll total = 0;
  for(int i = 0; i < n; i++) {
    total += l[i];
    q.push(-l[i]);
  }
  lhsSum[0] = total;
  for(int i = n; i < 2*n; i++) {
    total += l[i];
    q.push(-l[i]);
    total += q.top();
    q.pop();
    lhsSum[i-n+1] = total;
  }
}

void computeRHS() {
  priority_queue<ll> q;
  ll total = 0;
  for(int i = 3*n-1; i >= 2*n; i--) {
    total += l[i];
    q.push(l[i]);
  }
  rhsSum[0] = total;
  for(int i = 2*n-1; i >= n; i--) {
    total += l[i];
    q.push(l[i]);
    total -= q.top();
    q.pop();
    rhsSum[2*n-i] = total;
  }
}

int main() {
  scanf("%d", &n);
  for(int i = 0; i < 3*n; i++) {
    scanf("%lld", &l[i]);
  }
  computeLHS();
  computeRHS();
  ll ret = (ll)-1e18;
  for(int i = 0; i <= n; i++) {
    ret = max(ret, lhsSum[i] - rhsSum[n-i]);
  }
  printf("%lld\n", ret);
}


Measured memory_bytes: 5992
n=int(input())
h=list(map(int,input().split()))
ans=0
t_ans=0
b_h=h[0]
for i in h[1:]:
  if b_h>=i:
    t_ans+=1
  else:
    ans=max(ans,t_ans)
    t_ans=0
  b_h=i
ans=max(ans,t_ans)
print(ans)

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

using namespace std;

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define FOR(i,n) for (int i = 0; i < n; i++)
#define FORR(i,a,b) for (int i = a; i <= b; i++)
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ii> vii;

const int MX = 505;
int n, m = 0;
ll res[MX][MX], p[MX*2], mx = 0;

void pre () {
	for (int i = 2; m < 1000; i++) {
		bool f = 0;
		for (int j = 0; j < m; j++)
			f |= i % p[j] == 0;
		if (!f) p[m++] = i;
	}

	for (int i = 0; i < MX; i++)
		for (int j = 0; j < MX; j++)
			res[i][j] = 1;
}

int mv[] = {1, 0, -1, 0, 0, 1, 0, -1};

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

ll lcm (int i, int j) {
	__int128 a = 1;

	for (int l = 0; l < 4; l++) {
		int x = i + mv[l*2];
		int y = j + mv[l*2+1];

		if (x >= 0 && y >= 0 && x < n && y < n)
			a = a * res[x][y] / gcd(a, res[x][y]);
	}

	assert(0 < a && a <= 1e15);
	return a+1;
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	pre();

	cin >> n;

	if (n == 2) {
		cout << "4 7\n23 10" << endl;
		return 0;
	}

	int k = 0;
	for (int i = 0; i < n; i++, k++) 
		for (int j = 0; j < n; j++)
			if (0 <= i*2-j && i*2-j < n)
				res[i*2-j][j] *= p[k];

	for (int i = 0; 2 * i < n; i++, k++)
		for (int j = 0; j < n; j++)
			if (0 <= i*2+j && i*2+j < n)
				res[i*2+j][j] *= p[k];

	for (int i = 1; -2 * i + n - 1 >= 0; i++, k++)
		for (int j = 0; j < n; j++)
			if (0 <= -i*2+j && -i*2+j < n)
				res[-i*2+j][j] *= p[k];

	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (res[i][j] == 1)
				res[i][j] = lcm(i, j);

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++)
			cout << res[i][j] << " ";
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 5248
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var arrays = new int[n];

            foreach (var e in Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray())
            {
                arrays[e - 1] += 1;
            }

            for (var i = 0; i < n; i++)
            {
                Console.WriteLine(arrays[i]);
            }
        }
    }
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n;
  cin >> n;
  int ans = 0, y = 0;
  for (int i = 1; i <= n; i += 2) {
    y = 0;
    for (int j = 1; j <= i; j += 2)
      if (i % j == 0) y++;
    if (y == 8) ans++;
  }

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


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> as(n),bs(n);
  for(Int i=0;i<n;i++) cin>>as[i];
  for(Int i=0;i<n;i++) cin>>bs[i];

  for(Int i=0;i<n;i++)
    if(as[i]>bs[i]) drop(-1);

  using P = pair<Int, Int>;
  priority_queue<P> pq;
  for(Int i=0;i<n;i++)
    if(as[i]<bs[i]) pq.emplace(bs[i],i);

  Int ans=0;
  while(!pq.empty()){
    Int v=pq.top().second;
    Int w=pq.top().first;
    pq.pop();
    if(bs[v]!=w) continue;
    if(as[v]==bs[v]) continue;
    Int x=(v+n-1)%n;
    Int y=(v+n+1)%n;
    if(bs[x]>=bs[v]||bs[v]<=bs[y]) drop(-1);
    {
      Int num=(bs[v]-max({as[v],bs[x]+1,bs[y]+1}))/(bs[x]+bs[y]);
      ans+=num;
      bs[v]-=num*(bs[x]+bs[y]);
    }
    assert(bs[x]<bs[v]&&bs[v]>bs[y]);
    if(as[v]<bs[v]){
      ans++;
      bs[v]-=(bs[x]+bs[y]);
    }
    if(as[v]>bs[v]) drop(-1);
    if(as[v]<bs[v]) pq.emplace(bs[v],v);
    if(as[x]<bs[x]) pq.emplace(as[x],x);
    if(as[y]<bs[y]) pq.emplace(as[y],y);
  }
  for(Int i=0;i<n;i++)
    assert(as[i]==bs[i]);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 38244