akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	string s;
	int ans=0;
	cin >>s;
	int one=0;
	int zero=0;
	rep(i,s.size()){
		if(s[i]=='0'){
			zero++;
		}else{
			one++;
		}
	}
	cout<<2*min(zero,one)<<endl;
}
//1111
//8
//6

Measured memory_bytes: 512
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
A_list = list(map(int, input().split()))
ans = 0
SUM = sum(A_list)
for i in range(N):
    SUM -= A_list[i]
    if i != N -1:
        ans += A_list[i] * SUM
while ans >= 10 ** 21 + 7000000000000:
    ans -= 10 ** 21 + 7000000000000
while ans >= 10 ** 19 + 70000000000:
    ans -= 10 ** 19 + 70000000000
while ans >= 10 ** 17 + 700000000:
    ans -= 10 ** 17 + 700000000
while ans >= 10 ** 15 + 7000000:
    ans -= 10 ** 15 + 7000000
while ans >= 10 ** 13 + 70000:
    ans -= 10 ** 13 + 70000
while ans >= 10 ** 11 + 700:
    ans -= 10 ** 11 + 700
while ans >= 10 ** 9 + 7:
    ans -= 10 ** 9 + 7
print(ans)


Measured memory_bytes: 93672
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;
 
long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n,a[3];
string s[100001];
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>a[0]>>a[1]>>a[2];
	rep(i,n){
		cin>>s[i];
	}
	
	int d=0;
	if(a[0]==0)
	d++;
	if(a[1]==0)
	d++;
	if(a[2]==0)
	d++;
	if(d>2){
		cout<<"No";
		re 0;
	}
	vi ans;
	rep(i,n){
		int n1=s[i][0]-'A',n2=s[i][1]-'A';
		if(a[n1]==0&&a[n2]==0){
			cout<<"No";
			re 0;
		}
		if(a[n1]==a[n2]){
			if(a[n1]==1&&i<n-1){
				if(s[i+1][0]==(char)(n1+'A')||s[i+1][1]==(char)(n1+'A')){
					a[n1]++;
					a[n2]--;
					ans.pb(n1);
				}else{
					a[n1]--;
					a[n2]++;
					ans.pb(n2);
				}
			}else{
				a[n1]++;
				a[n2]--;
				ans.pb(n1);
			}
		}else{
			if(a[n1]>a[n2]){
				a[n1]--;
				a[n2]++;
				ans.pb(n2);
			}else{
				a[n2]--;
				a[n1]++;
				ans.pb(n1);
			}
		}
	}
	cout<<"Yes\n";
	rep(i,sz(ans)){
		cout<<(char)('A'+ans[i])<<"\n";
	}
	re 0;
}

Measured memory_bytes: 7076
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



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

	vector<ll> cnt(n+1);

	ll ans = 0;
	
	rep(i, n){
		int j = i+1; // j :[1:n]

		for(int k = j; k<=n; k = k+j) cnt[k]++;
		ans += j*cnt[j];


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


Measured memory_bytes: 81336
#include <iostream>
#include <vector>
#include <algorithm>

int main(void){
    using namespace std;
    int n;

    cin >> n;

    vector<int> b(n-1);

    for (int i = 0; i < n-1;i++)
        cin >> b[i];

    int ret = b[0];
    for (int i = 1; i < n - 1;i++){
        ret += min(b[i], b[i - 1]);
    }
    ret += b[n - 2];

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

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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#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)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main(){
    int n;
    cin >> n;
    VI av(100001, 0);
    int k;
    ll ans = 0;
    REP(i, n) {
        cin >> k;
        av[k]++;
        ans += k;
    }
    int q;
    cin >> q;
    REP(i, q) {
        int b, c;
        cin >> b >> c;
        ans += (c - b) * av[b];
        av[c] += av[b];
        av[b] = 0;
        cout << ans << en;
    }
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}


Measured memory_bytes: 3720
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>

// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std

Jehian Norman Saviero;

// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;

// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")

// MACROS FOR ATTRIBUTE
#define fi first
#define se second

// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) fill_n(x, sizeof(x)/sizeof(x[0]), y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))

// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scf(x) scanf("%f", &x)
#define scd(x) scanf("%lf", &x)
#define scld(x) scanf("%Lf", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

int main() {
	int N, A, B;
	sci(N), sci(A), sci(B);
	int MIN = INT_MAX;
	int MAX = INT_MIN;
	for (int i = 0; i <= min(A,B); ++i) {
		int NONE = N - ((A - i) + (B - i) + i);
		if (NONE >= 0) {
			MIN = min(MIN, i);
			MAX = max(MAX, i);
		}
	}
	printf("%d %d\n", MAX, MIN);
	return 0;
}

Measured memory_bytes: 256
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define pi pair<int,int> 
#define pii pair<pi,int>
#define ull unsigned long long
#define vi vector<int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
template <typename T>
void add(T &a, T b){
	a += b;
	if(a >= mod)a -= mod;
}
template <typename T>
void sub(T &a, T b){
	a -= b;
	if(a < 0)a += mod;
}
template <typename T>
void mul(T &a, T b){
	a *= b;
	if(a >= mod)a %= mod;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin>>n;
	vi v(n);
	map<int,int> mp;
	rep(i,n-1){
		cin>>v[i];
		mp[v[i]]++;
	}	
	repa(i,1,n+1){
		cout<<mp[i]<<"\n";
	}
	return 0;
}

Measured memory_bytes: 13548
#include <bits/stdc++.h>
#define lli long long int
#define ll long long
using namespace std;
int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli x;
    cin>>x;
    if(x>=30)
    cout<<"Yes"<<"\n";
    else
    cout<<"No"<<"\n";
 }

Measured memory_bytes: 3648
using System;
using System.Linq;

namespace Abc138
{
    public class QuestionC
    {
        public static void Main(string[] args)
        {
            // 整数の入力
            int n = int.Parse(Console.ReadLine());

            // スペース区切りの整数の入力
            string[] input = Console.ReadLine().Split(' ');

            //ソート
            var values = input.Select(i => int.Parse(i)).OrderBy(i => i);

            double result = values.ElementAt(0);
            for(int i = 1; i < values.Count(); i++)
            {
                result += values.ElementAt(i) * Math.Pow(2, i - 1);
            }
            result = result / Math.Pow(2, n - 1);

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13396
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <typeinfo>
#include <cmath>
using namespace std;

int getGCD(int a, int b){
    if(b == 0) return a;
    return getGCD(b, a%b);
}
int main()
{
    int N;
    std::cin >> N;
    std::vector<int> A(N);
    std::vector<int> copy_A(N);
    std::vector<int> GCD(N);
    std::vector<int> GCDlist_right(N);
    std::vector<int> GCDlist_left(N);
    for (int i = 0; i < N; ++i) std::cin >> A[i];
    GCDlist_left[0] = A[0];
    GCDlist_right[N-1] = A[N-1];
    
    for (int i = 1; i < N; ++i) GCDlist_left[i] = getGCD(A[i], GCDlist_left[i-1]);
    for (int i = N-2; i >= 0; --i) GCDlist_right[i] = getGCD(A[i], GCDlist_right[i+1]);
    GCD[0] = GCDlist_right[1];
    GCD[N-1] = GCDlist_left[N-2];
    for (int i = 1; i < N-1; ++i) GCD[i] = getGCD(GCDlist_right[i+1], GCDlist_left[i-1]);
    
    int max = *max_element(GCD.begin(), GCD.end());
    std::cout << max << "\n";
}

Measured memory_bytes: 2176
# coding: utf-8


def main():
    tax8, tax10 = map(int, input().split())

    rate8 = 0.08
    rate10 = 0.1
    value8 = tax8 / rate8
    value10 = tax10 / rate10
    price_min = int(min(value8, value10))
    price_max = int(max(value8, value10)) + 1

    for price in range(price_min, price_max + 1):
        if int(price * rate8) == tax8 and int(price * rate10) == tax10:
            print(price)
            return 0
   
    print('-1')

    return 0


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
a = gets.to_i
b = gets.to_i

if a == 1
   if b == 2
      puts 3
   else
      puts 2
   end
elsif a == 2
   if b == 1 
      puts 3
   else
      puts 1
   end
else
   if b == 1
      puts 2
   else
      puts 1
   end
end


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


  
int main() {
int N;cin>>N;
  
  vector<long long> lyuka(N+1);
  lyuka.at(0)=2;
  lyuka.at(1)=1;
  
  for(int i=2;i<=N;i++){
    lyuka.at(i)=lyuka.at(i-1)+lyuka.at(i-2);
  }

  cout<<lyuka.at(N)<<endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
ans = 0

"""
def c_i_j(n, i, j):
    counter = 0
    for num in range(1, n + 1):
        if int(str(num)[0]) == i and int(str(num)[-1]) == j:
            counter += 1
    return counter

for i in range(1, 10):
    for j in range(1, 10):
        ans += c_i_j(N, i, j) * c_i_j(N, j, i)

print(ans)
"""
table = list([0] * 10 for i in range(10))

for i in range(1, N + 1):
    table[int(str(i)[0])][int(str(i)[-1])] += 1

for i in range(1, 10):
    for j in range(1, 10):
        ans += table[i][j] * table[j][i]

print(ans)


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
int n, m, q;
ll res = 0;
int a[MAXN], b[MAXN], c[MAXN], d[MAXN];
ll calc(vector<int> &v) {
    ll r = 0;
    for (int i = 0; i < q; i++) {
        if (v[b[i]] - v[a[i]] == c[i]) r += d[i];
    }
    return r;
}
void backTracking(int indx, vector<int> &cur) {
    if (indx >= n) {
        res = max(res, calc(cur));
        return;
    }
    int last = cur.empty() ? 1 : cur.back();
    for (int i = last; i <= m; i++) {
        cur.push_back(i);
        backTracking(indx + 1, cur);
        cur.pop_back();
    }
}
int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m >> q;
    vector<int> cur;

    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }

    backTracking(0, cur);

    cout << res << endl;
    return 0;
}


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

using namespace std;

#define llong long long int
#define ldouble long double
#define ternary(condition, x, y) ((condition) ? x : y) 
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static int MOD = 1000000000 + 7;
const static llong INF = 1LL << 60;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    vector<vector<pair<int, llong> > > G(n);
    rep(i, m) {
        int a, b;
        llong c;
        cin >> a >> b >> c;
        G[a - 1].push_back(make_pair(b - 1, -c));
    }

    vector<llong> dist(n, INF);
    dist[0] = 0;
    bool exist_negative_loop = false;
    rep(i, n * 2 + 1) {
        rep(v, n) {
            rep(k, G[v].size()) {
                if (dist[v] != INF && dist[G[v][k].first] > dist[v] + G[v][k].second) {
                    dist[G[v][k].first] = dist[v] + G[v][k].second;
                    if (G[v][k].first == n - 1 && i == n * 2) exist_negative_loop = true;
                }
            }
        }
    }

    if (exist_negative_loop) cout << "inf" << endl;
    else cout << -dist[n - 1] << endl;


    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#include <iomanip>
#include <tuple>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;
#define mod 1000000007

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,k;
	cin >> n >> k;
	vector<ll> a(n);
	ll cnt[n] = {};
	rep(i,0,n) cin >> a[i];
	ll total = 0;
	rep(i,0,n){
		rep(j,0,n){
			if(a[i]>a[j]){
				cnt[i]++;
				if(i<j){
					total+=k;
					total%=mod;
				}
			}
		}
	}
	total %= mod;
	rep(i,0,n){
		total +=(ll)(cnt[i]) * (ll)((ll)(k-1)*k/2 % mod);
		total %= mod;
	}
	cout << total << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 2000

int main(){
  int n,q;
  int a[MAX],mi[MAX],s[MAX],b,c;
  int i,j;

  for(i=0;i<MAX;i++)s[i]=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    b=a[i];
    for(j=2000-b;j>0;j--){
      if(s[j]==1)s[j+b]=1;
      /* if(a[i]==j)s[j]=1;
	 sovle(a[i],a[j]);*/
    }
    s[b]=1;
  }
  
  /*for(i=0;i<MAX;i++)printf(" *%d:%d* ",i,s[i]);*/
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&mi[i]);
    c=mi[i];
    if(s[c]==1)printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 2108
#include <stdio.h>
 
int main(void)
{
  int N;
  int A[100002];
  scanf("%d",&N);
  int n,sum=0;
  for(n=1;n<=N;n++){
  	scanf("%d",&A[n]);
  	if(n>0){
  		sum+=abs(A[n]-A[n-1]);
  	}
  }
  A[0]=0;
  A[N+1]=0;
  sum+=abs(A[N]);
  
  
  
  for(n=0;n<N;n++){
  	if(A[n+1]-A[n]>0){
  		if(A[n+2]-A[n+1]<0){
  			int k;
  			if(A[n+2]-A[n]>0){
  				 k=sum-abs(A[n+1]-A[n])-abs(A[n+2]-A[n+1])+abs(A[n+2]-A[n]);
  			}else{
  				k=sum-2*abs(A[n+1]-A[n]);
  			}
  			printf("%d\n",k);
  		}else{
  			printf("%d\n",sum);
  		}
  	}else{
  		if(A[n+2]-A[n+1]<0){
  			printf("%d\n",sum);
  		}else{
  			int k;
  			if(A[n+2]-A[n]<0){
  				 k=sum-abs(A[n+1]-A[n])-abs(A[n+2]-A[n+1])+abs(A[n+2]-A[n]);
  			}else{
  				k=sum-2*abs(A[n+1]-A[n]);
  			}
  			printf("%d\n",k);
  		}
  	}
  }
  
   
  
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n,m;
  cin >> n >> m;
  string s;
  cin >> s;
  vl a(n+1,0);
  ll k=n,r=k;
  ll i=0;
  bool can=true;
  ll sum=0;
  while(sum<n){
    k -=m;
    while(k<0||s[k]=='1'){
      k++;
      if(k==r){
        can =false;
      }
    }
    if(!can){
      break;
    }
    a[i]=r-k;
    r=k;
    sum +=a[i];
    i++;
  }
  if(!can){
    cout << -1 << endl;
  }
  else{
    for(int i=n;i>=0;i--){
      if(a[i]!=0){
        cout << a[i] << " ";
      }
    }
  }
}

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

int main(){
	int N,D,X,A[100];
	cin >> N;
	cin >> D >> X;
	for (int i=0;i<N;i++){
		cin >> A[i];
	}
	int sum = 0;
	for (int j= 0;j<N;j++){
		sum += (D-1)/A[j];
	}
	cout << N+X+sum <<endl;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string;

long search(long n, long k, long cur)
{
    if (n == 0) { return cur; }
    long a = search(n-1, k, cur+k);
    long b = search(n-1, k, cur*2);

    return (a>b) ? b : a;
}

void main() {
    long n, k;

    scanf("%d %d", &n ,&k);

    writeln(search(n, k, 1));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 200010;
char s[maxn];
int nex[maxn][26];
int last[26];
int dp[maxn];
char ans[maxn];
int main(){
    scanf("%s",s+1);
    int n = strlen(s+1);
    for(int i = 0;i<26;i++){
        last[i] = maxn-1;
    }
    for(int i = n;i>0;i--){
        for(int j = 0;j<26;j++){
            nex[i][j]  = last[j];
        }
        last[s[i]-'a'] = i;
    }
    for(int j = 0;j<26;j++){
        nex[0][j]  = last[j];
    }
    memset(dp,0x3f,sizeof(dp));
    dp[maxn-1] = 0;
    for(int i = n;i>=0;i--){
        for(int j = 0;j<26;j++){
            dp[i] = min(dp[i],dp[nex[i][j]]+1);
        }
    }
    int p = 0;
    int tp = 0;
    while(1){
        for(int i = 0;i<26;i++){
            if(dp[p] == dp[nex[p][i]] + 1){
                ans[tp++] = i+'a';
                p = nex[p][i];
                break;
            }
        }
        if(p == maxn-1) break;
    }
    ans[tp] = 0;
    printf("%s\n",ans);
    return 0;
}

Measured memory_bytes: 21504
#include <stdio.h>
int main(void)
{
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x-r<0 || x+r>W || y-r<0 || y+r>H)puts("No");
    else if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H)puts("Yes");
    return 0;
}



Measured memory_bytes: 2108
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;
using Ki = vector<vector<int>>;
using Vi = vector<int>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(a,b)<<" "<<max((ll)0,a+b-n)<<endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>

using namespace std;

const int N = 1e5+7;
#define ll long long

int main(){
	int a,b;
	cin >> a >> b;
	if(a % b == 0) cout << 0;
	else cout << 1;
	return 0; 
} 

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void)
{
  int w[10];
  int k[10];
  for(int i=0;i<10;i++)
    {
      cin>>w[i];
    }
  for(int i=0;i<10;i++)
    {
      cin>>k[i];
    }
  for(int i=0;i<10;i++)
    {
      int max=w[i],x=i;
      for(int j=i;j<10;j++)
	{
	  if(w[j]>max)
	    {
	      max=w[j];
	      x=j;
	    }
	  
	}
int tmp=w[i];
	  w[i]=w[x];
	  w[x]=tmp;
    }
for(int i=0;i<10;i++)
    {
      int max=k[i],x=i;
      for(int j=i;j<10;j++)
	{
	  if(k[j]>max)
	    {
	      max=k[j];
	      x=j;
	    }
	  
	}
int tmp=k[i];
	  k[i]=k[x];
	  k[x]=tmp;
    }
 int sumw=0;
for(int i=0;i<3;i++)
    {
      sumw+=w[i];
    }
 int sumk=0;
for(int i=0;i<3;i++)
    {
      
      sumk+=k[i];
    }
 cout<<sumw<<" "<<sumk<<endl;
    
  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <utility>
#include <algorithm>

using namespace std;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

template<typename T> 
void show(T a){
  for(auto i : a){ cout << i << " "; }
  cout << endl;
}
template<typename T> 
void showmatrix(T a){
  for(auto j: a){for(auto i : j){ cout << i; }cout << endl;}
  cout << endl;
}
void check(int i = 0){
  cout << "checkpoint:[" << i << "]" << endl;
}


int main(int argc, char *argv[]){
  ios::sync_with_stdio(false);
  cin.tie(NULL);

  int n; cin >> n;
  double sum = 0.0;
  double x; string u;
  for(int i = 0; i < n; i++){
    cin >> x >> u;
    if(u == "JPY") sum += x;
    else sum += 380000 * x;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
h, w = map(int,input().split())
s = []
for i in range(h):s.append(list(input()))
dx = [-1, 0, 1, 0]
dy = [0, 1, 0,-1]
for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            flag=False
            for k in range(4):
                x = j+dx[k];y=i+dy[k]
                if 0 <= x and x <= w-1 and 0 <= y and y <= h-1:
                    if s[y][x]=="#":flag=True
            if not flag:
                print('No')
                exit()
print('Yes')

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>
#include<bitset>



using namespace std;

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

int n,m;
int x;
int c[12],mature[12],a[12][12];
int sum = 0;
int inf = 1000000000;
int ans=inf;

int main(){
    cin >> n >> m >> x;
    rep(i,n){
        cin >> c[i];
        rep(j,m){
            cin >> a[i][j];
            // cout << a[i][j] << " ";
        }
        // cout << endl;
    }
    rep(i,1<<n){
        sum = 0;
        rep(k,m) mature[k] = 0;
        // cout << bitset<8>(i) << endl;
        rep(j,n){
            // cout << bitset<8>(i>>j) << endl;
            if((i>>j) & 1){
                sum += c[j];
                rep(k,m){
                    mature[k] += a[j][k];
                    // cout << mature[k] << " " ;
                }
                // cout << endl;
                int flag = 1;
                rep(k,m) if(mature[k] < x) flag=0;
                if(flag) ans = min(sum,ans);
            }
        }
    }
    if(ans == inf) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <stdio.h>
#include <math.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
  int N;
  int a[100100];
  cin >> N;

  for(int i = 0; i < N; i++){
    cin >> a[i];
  }

  int state = 0;
  int res = 0;
  for(int i = 0; i < N; i++){
    if(state == 0 && a[i] != i+1) continue;
    else if(state == 0 && a[i] == i+1) state = 1;
    else{
      state = 0;
      res++;
    }
  }
  res += state;

  cout << res << endl;
  return 0;
}


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

int main(){
	int a,b,c,d;cin >> a >> b >> c >> d;
  	if(a+b>c+d)cout << "Left";
  	else if(a+b<c+d)cout << "Right";
  	else cout << "Balanced";
  	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3


def main():
    #N = map(int, open(0).read().split())
    t, x, y = 0, 0, 0
    N = int(input())

    flag = True

    for i in range(N):
        n_t, n_x, n_y = map(int, input().split())
        diff_d = abs(n_x - x) + abs(n_y - y)
        diff_t = abs(n_t - t)
        # print(diff)

        # 移動しないといけない距離に対して時間が足りない
        if diff_d > diff_t:
            flag = False

        # 移動はできるけど、ずれが発生する
        elif (diff_t - diff_d) % 2 == 1:
            flag = False
        else:
            t,x,y = n_t,n_x,n_y

    if flag == True:
        print('Yes')
    else:
        print('No')
main()


Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#define pb push_back
#define pii pair<int,int>
using namespace std;

int n,m,num,ima,flag;
vector<vector<int> > g;
vector<int> vis;
vector<int> res,tmp;
vector<pii> p;
void dfs(int doko){
  int i;
  //cout<<doko<<" ";
  tmp.pb(doko);
  vis[doko]=1;
  for(i=0;i<g[ima].size();i++){
    if(doko==g[ima][i]){
      num--;
      break;
    }
  }
  //cout<<"("<<doko<<" "<<num<<")";

  if(num==0){
    int num2;
    flag=1;
    for(int j=0;j<g[doko].size();j++){
      if(vis[g[doko][j]]==0) {flag=0;break;}
    }
  }

  if(flag==1){
    copy(tmp.begin(),tmp.end(),back_inserter(res));
    return;
  }
  for(i=0;i<g[doko].size();i++){
    if(vis[g[doko][i]]==0) dfs(g[doko][i]);
    if(num==0&&flag==1) return;
  }
  tmp.pop_back();
  vis[doko]=0;
  for(i=0;i<g[ima].size();i++){
    if(doko==g[ima][i]){
      num++;
      break;
    }
  }
}

int main(void){
  cin>>n>>m;
  int x,y,i,j;
  vis.resize(n+1);
  for(i=0;i<=n;i++){
    vector<int> b;
    g.pb(b);
    vis[i]=0;
  }
  for(i=0;i<m;i++){
    cin>>x>>y;
    g[x].pb(y);
    g[y].pb(x);
  }
  for(i=1;i<=n;i++){
    p.pb(pii(g[i].size(),i));
  }
  sort(p.begin(),p.end());

  flag=0;
  for(i=0;i<n;i++){
    num=g[p[i].second].size();
    ima=p[i].second;
    for(j=0;j<=n;j++){
      vis[j]=0;
    }
    dfs(p[i].second);
    //cout<<endl;
    if(flag==1) break;
  }
  
  cout<<res.size()<<endl;
  for(i=0;i<res.size();i++){
    cout<<res[i];
    if(i==res.size()-1)cout<<endl;
    else cout<<" ";
  }
  
  return 0;
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

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

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n;
    cin>>n;

    vector<int> a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));

    double gap = 1e9;
    int p,q=a[n-1];

    rep(i,n){
        if(chmin(gap,abs(q/2.0 - a[i]))){
            p=a[i];
        }
    }

    cout<<q<<" "<<p<<endl;

    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 640
def main():
	N,P = map(int,input().split())
	S = [int(s) for s in list(input().strip())][::-1]
	num = 0
	ans = 0
	if P == 2 or P == 5:
		for i in range(N):
			if S[i]%P == 0:
				ans += N-i
		print(ans)
		return
	L = [0]*P
	L[0]=1
	t = 0
	s = 1
	for z in S:
		t = (z*s+t)%P	
		L[t]+=1
		s=s*10%P
	for l in L:
		ans += l * (l - 1) // 2
	print(ans)

if __name__ == '__main__':
	main()


Measured memory_bytes: 6436
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define int long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;

signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	int n=read();
	if(n%2==1)
	{
		cout<<"0\n";
		return 0;
	}
	int ans=0;
	n/=2;
	while(n)
	{
		ans+=n/5;
		n/=5;
	}
	cout<<ans<<endl;
#ifdef __LOCAL__
	printf("Time Used : %d\n",clock());
#endif
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{    int A,B,C;
     cin>>A>>B>>C;
     if((A-B)<C)
     {
         cout<<(C-(A-B))<<endl;
     }
     else
     {
         cout<< 0<<endl;
     }




  return 0;
  }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))

#define ll long long

using namespace std;
using Graph = vector<vector<int> >;

int main() {
  int A, B; cin >> A >> B;

  int m = A+B;
  int n = A-B;
  int l = A*B;

  cout << max(m, max(n, l)) << endl;
    
}


Measured memory_bytes: 256
import java.io.*;
public class Main{
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try{
            String lineF = br.readLine();
            String []line = lineF.split(" ");
            int A = Integer.parseInt(line[0]);
            int B = Integer.parseInt(line[1]);
            int Ans  = A - 2*B;
            if(Ans >= 0){
                System.out.println(Ans);
            }else{
                System.out.println(0);
            }
        }catch(IOException e){
            e.printStackTrace();    
        }
    }
}

Measured memory_bytes: 23252
s=input()
flag=1
if s[0]!="A":
    flag=0
else:
    t= s[2:-1].replace("C","",1)
    u= s[2:-1].replace("C","",2)
    if s[2:-1]==t or t!=u:
        flag=0
    else:
        t = s.replace("A","",1).replace("C","",1)
        if t.lower()!=t:flag=0
print("AC" if flag else "WA")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using namespace std;

// #define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll mod = (1000000007LL);

inline ll poww(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if(b & 1) res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res;
}
inline pii operator+(pii A, pii B){
	return pii(A.f + B.f, A.s + B.s);
}
inline pii operator-(pii A, pii B){
	return pii(A.f - B.f, A.s - B.s);
}
inline ll mult(ll a, ll b){
	return (a * b) % mod;
}

ll gcd (ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

/*
	>Colocar (>DEFINE INT LONG LONG<) no inicio do template
	>mod = (1e9 + 7), por padrao (NAO ESQUECER DE ALTERAR)
	>NAO ESQUECER DEFINE INT LONG LONG
	> N = 1 ? 
*/

///CUIDADO COM MAXN
#define N 300050

int n, m, q, k, v[N], ans;

pii TT, w[N];

string s;

int L[N], R[N];
vector<pii> caras,caras2;
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n;
    for(int i = 1; i <= n; i++){
        cin>>v[i];
    }
    for(int i =1;i<=n; i += 2){
        L[v[i]] ++;
    }
    for(int i  =2; i <= n; i += 2){
        R[v[i]] ++;
    }
    for(int i = 1; i < N; i++){
        caras.pb({L[i], i});
        caras2.pb({R[i], i});
    }
    caras2.pb({0,200000001});
    caras.pb({0,200000002});
    sort(all(caras));
    sort(all(caras2));
    reverse(all(caras));
    reverse(all(caras2));
    int ans = 2000000000;
    for(int i = 0; i < min(2, sz(caras)); i++){
        for(int j = 0; j < min(2, sz(caras2)); j++){
            if(caras[i].s == caras2[j].s) continue;
            // cout<<caras[i].s<<" "<<caras2[j].f<<"\n"
            int cost = n-caras[i].f-caras2[j].f;
            ans=min(ans, cost);
        }
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 13920
def main():
    while True:
        n = int(input())
        if n == 0:
            exit()
        f = [s for s in input().split()]
        pm = 'd'
        cnt = 0
        for m in f:
            if m[1] == pm:
                cnt += 1
            pm = m[1]
        print(cnt)

if __name__ == '__main__':
    main()

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

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;

//少数点表示
//cout <<std::fixed << std::setprecision(14)

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int a,b,h,ans;
    cin >> a >> b >> h;
    ans=((a+b)*h)/2;
    cout << ans << endl;
}

Measured memory_bytes: 256
import heapq
import sys
input = sys.stdin.readline

INF = 10 ** 18

class Edge():
    def __init__(self, end, cost, time):
        self.end = end
        self.cost = cost
        self.time = time

dp = []
h = []

def push(t, v, x):
    if x < 0:
        return
    if dp[v][x] <= t:
        return
    dp[v][x] = t
    heapq.heappush(h, (t, v, x))

def dijkstra(n, G, cd, start, s, max_s):
    global dp
    dp = [[INF for j in range(max_s+1)] for i in range(n)] 
    push(0, start, s)

    while h:
        # 使っていない頂点のうち、現時点で最も到達短時間が短いものを選びvとする
        t, v, x = heapq.heappop(h)
        if dp[v][x] < t:
            continue
        # 両替
        if x < max_s:
            push(t+cd[v][1], v, min(x+cd[v][0], max_s))
        # vから到達可能な頂点について、到達時間が短くなれば更新
        for e in G[v]:
            push(t+e.time, e.end, x-e.cost)


n, m, s = map(int, input().split())
uvab = [list(map(int, input().split())) for _ in range(m)]
cd = [list(map(int, input().split())) for _ in range(n)]

es = [[] for i in range(n)]
max_s = 50 * (n-1)

for u, v, a, b in uvab:
    es[u-1].append(Edge(v-1,a,b))
    es[v-1].append(Edge(u-1,a,b))

dijkstra(n, es, cd, 0, min(max_s,s), max_s)

for i in range(1, n):
    print(min(dp[i]))


    

Measured memory_bytes: 23908
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<vector>
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(s[i]=='B'){
      if(ans.size()!=0){
        ans.pop_back();
      }
    }
  }
  for(int i=0;i<ans.size();i++){
    cout<<ans[i];
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main {

    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        try {
            String[] line = reader.readLine().split(" ");
            int a = Integer.parseInt(line[0]);
            int b = Integer.parseInt(line[1]);
            int c = Integer.parseInt(line[2]);
           
            int count = 0;
            for (int i = 1; i <= c; i++) {
                if (c % i == 0) {
                    int tmp = c / i;
                    
                    if (a <= tmp && tmp <= b) {
                        count++;
                    }
                }
            }

            System.out.println(count);
            
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}

Measured memory_bytes: 24280
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x, y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x, y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;
ll mode=pow(10,9)+7;
bool cmp(pair<long double ,int > x, pair<long double , int> y){ return x.F<y.F; }
const ll maxn=2*1e4+5;
ll __lcm(ll a, ll b){ return (a*b)/__gcd(a,b); }

int main(){ 
    
//    #ifndef ONLINE_JUDGE
//  	freopen("input.txt", "r", stdin);
//    #endif
    
    ios::sync_with_stdio(0);
    cin.tie(0);
	
	ll n;
	cin>>n;
	vpll v(n);
	for (int i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		v[i].F=x+y;
		v[i].S=x-y;
	}
	sort(v.begin(), v.end());
	ll ans=0;
	for (int i=1;i<n;i++){
		if (v[i].S<v[i-1].F){
			v[i].F=v[i-1].F;
			v[i].S=v[i-1].F;
			ans++;
		}
	}
	cout<<n-ans<<endl;
	
	return 0;
}

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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  for(int i = 0;i < n;i++){
    cin >> h.at(i);
  }
  sort(h.begin(),h.end());
  reverse(h.begin(),h.end());
  int min = h.at(0);
  for(int i = 0;i < n-k+1;i++){
    int ans = h.at(i) - h.at(i+k-1);
    if(ans < min){
      min = ans;
    }
  }
    cout << min << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (a); i < n; i++)
#define print(x) cout << x << endl;
using namespace std;
typedef long long ll;

ll mod = 1e9+7;

ll modpower(ll a, ll r) {
    ll x = 1;
    while(r > 0) {
        if (r & 1) x = x * a % mod;
        r >>= 1;
        a = a * a % mod;
    }
    return x;
}

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

vector<ll> fact;
vector<ll> invfact;

void set_fact(int n) {
    fact.resize(n+1, 1);
    invfact.resize(n+1, 1);
    for (int i = 2; i <= n; i++) {
        fact[i] = fact[i-1] * i % mod;
    }
    invfact[n] = modinv(fact[n]);
    for (int i = n-1; i >= 2; i--) {
        invfact[i] = invfact[i+1] * (i+1) % mod;
    }
    return;
}

ll comb(int n, int k) {
    if (k > n || k < 0) return 0;
    if (k == n || k == 0) return 1;
    return fact[n] * invfact[n-k] % mod * invfact[k] %mod;
}

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

    ll ans = 1;
    for (ll i = 1; i <= min(n-1, k); i++) {
        ans += comb(n, i) * comb(n-1, n-i-1) % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <cmath>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

static const int MAX = 100001;

/******* c++14 don't include *******/

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

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

int main(int argc, const char * argv[]) {
    // input from txt
    
    /////////
    //write//
    /////////
    
    ll n;
    ll mi = 0;
    cin >> n;
    rep(i, 5){
        ll a;
        cin >> a;
        if(!i)mi = a;
        mi = min(a, mi);
    }
    ll res = 0;
    res += n/mi+4;
    if(n%mi>0)res++;
    

    cout << res<< endl;

    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int 
#define ar array
#define pb push_back
#define fi(a,b) for(int i=a;i<(b);i++)
#define fj(a,b) for(int j=a;j<(b);j++)
#define fk(a,b) for(int k=a;k<(b);k++)
#define lb lower_bound
#define ub upper_bound
//hash base 177013


int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	//ll testcase;
	//cin>>testcase;
	//while(testcase--)
	{
		double d,t,s;
		cin>>d>>t>>s;
		double time=d/s;
		if(t-time>=0.00)
		{
			cout<<"Yes\n";
		}
		else
		{
			cout<<"No\n";
		}
	}
}


























Measured memory_bytes: 3756
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);

// ===

struct UnionFind {
    parent: Vec<usize>
}

impl UnionFind {
    fn new(n: usize) -> Self {
        let mut parent = vec![0; n];
        for i in 0..n {
            parent[i] = i;
        }
        UnionFind { parent: parent }
    }

    fn unite(&mut self, a: usize, b: usize) {
        let pa = self.find(a);
        let pb = self.find(b);
        if pa == pb {
            return;
        }
        self.parent[pa] = pb;
    }

    fn find(&mut self, u: usize) -> usize {
        if self.parent[u] == u {
            return u;
        }
        let mut pu = self.parent[u];
        pu = self.find(pu);
        self.parent[u] = pu;
        return pu
    }
}

fn main() {
    let (n, m): (usize, usize) = read();
    let p: Vec<usize> = readnc::<usize>().iter().map(|u| u-1).collect();

    let mut uf = UnionFind::new(n);
    for i in 0..m {
        let (a, b): (usize, usize) = read();
        uf.unite(a-1, b-1);
    }

    let mut id_positions = vec![0; n];
    for i in 0..n {
        id_positions[i] = uf.find(i);
    }

    let mut ans = 0;
    for i in 0..n {
        if uf.find(i) == id_positions[p[i]] {
            ans += 1;
        }
    }

    println!("{}", ans);
}



Measured memory_bytes: 6396
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;

const int maxn = 1e5 + 10;

int n;
ll arr[maxn], sum[maxn];

int main() {
	while(~scanf("%d", &n)) {
		for(int i = 1; i <= n; ++i) scanf("%lld", arr + i);
		sort(arr + 1, arr + 1 + n);
		for(int i = 1; i <= n; ++i) sum[i] = sum[i - 1] + arr[i];
		if(n & 1) {
			if(n == 3) {
				ll ans = max((arr[3] - arr[1] + arr[2] - arr[1]), (arr[3] - arr[1] + arr[3] - arr[2]));
				printf("%lld\n", ans);
			} else{
				ll ans1 = 2ll * ((sum[n] - sum[n / 2 + 1]) - (sum[n / 2 - 1])) - (arr[n / 2 + 1] + arr[n / 2]);
				ll ans2 = 2ll * ((sum[n] - sum[n / 2 + 2]) - (sum[n / 2])) + (arr[n / 2 + 2] + arr[n / 2 + 1]);
				printf("%lld\n", max(ans1, ans2));
			}
		} else {
			ll ans = 2ll * ((sum[n] - sum[n / 2 + 1]) - (sum[n /  2 - 1])) + (arr[n / 2 + 1] - arr[n / 2]);
			printf("%lld\n", ans); 
		}
	}
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
//#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
signed main() {
	string s; cin >> s;
	cout << (s[3] == s[2] && s[4] == s[5] ? "Yes\n" : "No\n");
}

Measured memory_bytes: 256