akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define mod 1000000007
#define inf 9999999999999999ll
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    vb ac(n,false);
    vi pen(n,0);
    for(ll i=0;i<m;i++)
    {
        ll x;
        string s;
        cin>>x>>s;
        x--;
        if(s=="AC")
        {
            ac[x]=true;
        }
        else
        {
            if(ac[x]==false)
            {
                pen[x]++;
            }
        }
    }
    ll a1=0,a2=0;
    for(ll i=0;i<n;i++)
    {
        if(ac[i])
        {
            a1++;
            a2+=pen[i];
        }
    }
    cout<<a1<<" "<<a2<<endl;
}



Measured memory_bytes: 1024
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int p = a;
		int k = 0;
		int result = 0;
		
		while(p>=1) {
			k++;
			p /= 10;
		}
		if(k%2==1) {
			k--;
			result += a - Math.pow(10, k)+1;
		}
		while(k>0) {
			if(k%2==1) {
				result += Math.pow(10, k) - Math.pow(10, k-1);
			}
          k--;
		}
      System.out.println(result);
	}
}

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

long long N, K;
long long a[200005];
long long b[200005];
//     val   ,  pos
map<long long, vector<long long> > memo;

int bit[200005];

void add(int a, int w){
	for(int x = a; x <= 200004; x += x & -x){
		bit[x] += w;
	}
}

int sum(int a){
	int ret = 0;
	for(int x = a; x > 0; x -= x & -x){
		ret += bit[x];
	}
	return ret;
}


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

	long long sumi = 0;
	for(long long i = 0; i < N; i++){
		memo[sumi - i * K].push_back(i);
		//b[i] = sumi - i * K;
		sumi += a[i];
	}
	//b[N] = sumi - N * K;
	memo[sumi - N * K].push_back(N);

	for(auto me: memo){
		vector<long long> pos = me.second;
		for(long long i = 0; i < pos.size(); i++){
			ans += sum(pos[i]+1);
			add(pos[i]+1, 1);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 24448
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
class Dice {
	int num[6];
public:
	Dice(int a,int b,int c,int d,int e,int f) {
		num[0] = a; num[1] = b; num[2] = c;
		num[3] = d; num[4] = e; num[5] = f;
	}

	void rotate(char c) {
		assert(c == 'N' || c == 'S' || c == 'E' || c == 'W');
		int memo = num[0];
		if (c == 'N') {
			num[0] = num[1];
			num[1] = num[5];
			num[5] = num[4];
			num[4] = memo;
		}
		else if (c == 'S') {
			num[0] = num[4];
			num[4] = num[5];
			num[5] = num[1];
			num[1] = memo;
		}
		else if (c == 'E') {
			num[0] = num[3];
			num[3] = num[5];
			num[5] = num[2];
			num[2] = memo;
		}
		else {
			num[0] = num[2];
			num[2] = num[5];
			num[5] = num[3];
			num[3] = memo;
		}
	}

	int getNum(int index) { return num[index]; }
};
int a[6], q, x, y;
string s;
signed main() {
	rep(i, 6)cin >> a[i];
	Dice dice(a[0], a[1], a[2], a[3], a[4], a[5]);
	cin >> q;
	rep(i, q) {
		cin >> x >> y;
		while (true) {
			char c;
			int m = rand() % 2;
			if (m == 0)c = 'N';
			else if (m == 1)c = 'E';
			dice.rotate(c);
			if (dice.getNum(0) == x && dice.getNum(1) == y) {
				cout << dice.getNum(2) << endl;
				break;
			}
		}
	}
}


Measured memory_bytes: 3148
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mpr make_pair
#define fi first
#define se second
using ll=long long int;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){
	ll n;
	cin>>n;
	vector<ll>a(n);
	map<int,int>mp;
	rep(i,n){
		cin>>a[i];
		mp[a[i]]++;
	}
	sort(a.begin(),a.end());
	if(a[0]==0&&a[n-1]==0){
		cout<<"Yes\n";
		return 0;
	}
	if(n%3==0){
		if(mp.size()==2){
			if(mp[0]==n/3&&mp[a[n/3]]==n/3*2){
				cout<<"Yes\n";
				return 0;
			}
		}
		if(mp.size()==3){
			if(((a[0]^a[n/3]^a[n/3*2])==0)&&(mp[a[0]]==mp[a[n/3]]&&mp[a[n/3]]==mp[a[n/3*2]])){
				cout<<"Yes\n";
				return 0;
			}
		}
	}
	cout<<"No\n";
	return 0;
}



Measured memory_bytes: 4480
#include <cstdio>
#include <cmath>
#include <cstring>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <set>
#include <functional>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
int main() {
	vector<P> V;
	int N;
	scanf("%d",&N);
	for(int i=0;i<N;i++) {
		int h,m;
		scanf("%d %d",&h,&m);
		V.push_back(P(h,m));
	}
	int M;
	scanf("%d",&M);
	for(int i=0;i<M;i++) {
		int h,m;
		scanf("%d %d",&h,&m);
		V.push_back(P(h,m));
	}
	sort(V.begin(),V.end());
	V.erase(unique(V.begin(),V.end()),V.end());
	for(int i=0;i<V.size();i++) {
		printf("%d:%02d",V[i].first,V[i].second);
		printf("%c",i==V.size()-1?'\n':' ');
	}
}

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

long bfs(long d,long X,vector<long> &P,vector<long> &L){
    if(d==0) return X;
    
    if(X==2*L.at(d-1)+3) return P.at(d);
    if(L.at(d-1)+2<=X && X<=2*L.at(d-1)+2) return P.at(d-1)+1+bfs(d-1,X-L.at(d-1)-2,P,L);
    if(1<=X && X<=L.at(d-1)+1) return bfs(d-1,X-1,P,L);
    return 0;
}
int main(){
    long N,X;
    cin>>N>>X;
    vector<long> P(N+1),L(N+1);
    P.at(0)=1;
    L.at(0)=1;
    for(int i=0;i<N;i++){
        P.at(i+1)=2*P.at(i)+1;
        L.at(i+1)=2*L.at(i)+3;
    }
    
    cout<<bfs(N,X,P,L)<<endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, M) = listOfInt()
    val A = listOfInt().sortedDescending()
    val U = arrayListOf(0, 2, 5, 5, 4, 5, 6, 3, 7, 6)
    val V = A.map { U[it] }
    val dp = Array<String?>(10001) { null }; dp[0] = ""
    for (n in 1 .. N) {
        for (m in 0 until M) {
            val t = n - V[m]
            if (t >= 0 && dp[t] != null) {
                if (dp[n] == null) dp[n] = ""
                if (dp[n]!!.length <= dp[t]!!.length) {
                    dp[n] = dp[t] + A[m]
                }
            }
        }
    }
    val ans = dp[N]!!.split("").sortedDescending()
    println(ans.joinToString(""))
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
using tp = tuple<ll, ll, ll>;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll)1e9 + 7;
constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

//グラフ関連
struct Edge {
    ll to, cap, rev;
    Edge(ll _to, ll _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n;
    cin >> n;
    ll con = 0;
    ll ans = 0;
    REP(i, n) {
        ll d1, d2;
        cin >> d1 >> d2;
        if(d1 != d2)
            con = 0;
        else
            con++;
        chmax(ans, con);
    }
    if(ans >= 3)
        cout << "Yes" << en;
    else
        cout << "No" << en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    while(t--)*/
    solve();

    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 100005
using namespace std;
using P = pair<int,int>;
int n,m,ans[M];
vector<P> e[M];
void dfs(int cur,int fa) {
    for (auto i:e[cur]) if (i.first != fa) {
        if (i.second%2 == 1) ans[i.first] = 3-ans[cur];
        else ans[i.first] = ans[cur];
        dfs(i.first, cur);
    }
}
int main()
{
    while (~scanf("%d", &n)) {
        MSET(ans, 0);
        REP(i,1,n) e[i].clear();
        REP(i,1,n-1) {
            int x,y,z;
            scanf("%d %d %d",&x,&y,&z);
            e[x].push_back( make_pair(y,z) );
            e[y].push_back( make_pair(x,z) );
        }

        ans[1] = 1;
        dfs(1, -1);
        REP(i,1,n) printf("%d\n", ans[i]-1);
    }
    return 0;
}


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

using namespace std;

#define ff first
#define ss second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<long long, long long> pl;

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const double EPS = 1e-6;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	string s; cin >> s;
	if (s == "Sunny") {
		cout << "Cloudy\n";
	}
	else if (s == "Cloudy") {
		cout << "Rainy\n";
	}
	else {
		cout << "Sunny\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
struct edge{
	int f,t,c;
	edge(){}
	edge(int ff,int tt ,int cc){
		f=ff;
		t=tt;
		c=cc;
	}
	bool operator<(const edge &e)const{
		return c<e.c;
	}
};

int n,m;
bool used[1001];
edge e[10001];
int par[1001];
int rank[1001];

void init(int v){
	for(int i=0;i<v;i++){
		par[i]=i;
		rank[i]=0;
	}
}


int find(int x){
	if(x==par[x])return x;
	return par[x]=find(par[x]);
}

void unite(int a,int b){
	a=find(a);
	b=find(b);
	if(rank[a]<rank[b]){
		par[a]=b;
	}else{
		par[b]=a;
		if(rank[a]==rank[b])rank[a]++;
	}
}

bool same(int a,int b){
	return find(par[a])==find(par[b]);
}


int main(void){
	while(1){
		scanf("%d %d",&n,&m);
		if(n+m==0)break;
		for(int i=0;i<m;i++){
			scanf("%d %d %d",&e[i].f,&e[i].t,&e[i].c);
			e[i].f--;
			e[i].t--;
		}
		sort(e,e+m);
		init(n);
		int cnt=0,res=0;
		for(int i=0;i<m;i++){
			if(!same(e[i].f,e[i].t)){
				unite(e[i].f,e[i].t);
				cnt++;
				if(cnt==n/2)res=e[i].c;
			}
		}
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<cmath>
#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 rFOR(i, a, b) for(int i=b-1; i>=a; i--)
#define MAX 10000
using namespace std;

struct distance{
  int d;
  int p;
/*
  bool operator<(const distance& left, const distance& right){
    return left.p == right.p ? left.d < right.d : left.p < left.p;
  }

*/
};


int main(void){
  while(true){
    int n, m; cin >> n >> m;
    if(n+m == 0)  break;
    int ans = 0;
    vector<struct distance> inns;
    rep(i, n){
      struct distance inn;
      cin >> inn.d >> inn.p;
      inns.push_back(inn);
    }
  //  sort(inns.begin(), inn.end());

    int i,j;
    struct distance tmp;
    for(i=0;i<n;i++){
      for(j=i;j<n;j++){
        if(inns[i].p>inns[j].p){
          tmp=inns[i];
          inns[i]=inns[j];
          inns[j]=tmp;
        }
      }
    }

    rrep(i, n){
      if(m > 0){
        if(m >= inns[i].d){
          m -= inns[i].d;
        }else{
          ans += ((inns[i].d - m)*inns[i].p);
          m = 0;
        }
      }else{
        ans += inns[i].d*inns[i].p;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3288
import java.util.Scanner

object Main extends App {

  val sc = new Scanner(System.in)

  val n = sc.nextInt()
  val ar = (1 to n).map(_ => sc.nextLong())

  println(solve(ar, true))

  def solve(ar: Seq[Long], isFirst: Boolean): String = {
    if (determined(ar)) winner(isFirst)
    else if (determined2(ar)) winner(!isFirst)
    else {
      val newAr = ar.map(l => if (l % 2 == 1) l - 1 else l)
      val gcd = gcdForArr(newAr)
      solve(newAr.map(_ / gcd), !isFirst)
    }
  }

  def winner(isFirst: Boolean): String = if (isFirst) "First" else "Second"

  def determined(ar: Seq[Long]) = {
    (ar.sum - n) % 2 == 1
  }

  def determined2(ar: Seq[Long]) = {
    ar.count(_ % 2 == 1) > 1 || ar.contains(1)
  }

  def gcdForArr(arr: Seq[Long]): Long =
    arr.reduce((acc, h) => gcd(acc, h))

  def gcd(a: Long, b: Long): Long = {
    if (a % b == 0) b else gcd(b, a % b)
  }
}

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

int main()
{
ll n ;
cin >> n ;
vector<ll> a(n);
rep(i, n){
  cin >> a[i];
}
ll c=0;
rep(i,n)c^=a[i];
rep(i,n)cout << (c^a[i]) << " ";
cout  << endl;



return 0;
}

Measured memory_bytes: 4840
def m():
    N = int(input())
    S = [input() for _ in range(N)]
    A = B = C = 0
    ans = 0
    for s in S:
        ans += s.count('AB')
    for s in S:
        if s[0] == 'B' and s[-1] == 'A':
            C += 1
        elif s[0] == 'B':
            B += 1
        elif s[-1] == 'A':
            A += 1
        else:
            pass
    if C == 0:
        return ans + min(A, B)
    ans += C - 1

    if A > 0:
        A -= 1
        ans += 1
    if B > 0:
        B -= 1
        ans += 1
    ans += min(A,B)
    return ans


print(m())


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

using namespace std;

using int64 = long long;

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

  // For float output:
  cout << fixed << setprecision(10);

  int n;
  cin >> n;
  vector<double> xs(n);
  for (int i = 0; i < n; i++) cin >> xs[i];

  double sum = 0;
  for (double x : xs) sum += 1.0 / x;
  cout << 1.0 / sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define vi vector<int>
    #define pii pair<int,int>
    #define vp  vector<pii>
    #define fi first
    #define se second
    #define mp make_pair
    #define pb push_back
    #define ls l,mid,rt<<1
    #define rs mid+1,r,rt<<1|1
    #define de(x) cout<< #x<<" = "<<x<<endl
    #define dd(x) cout<< #x<<" = "<<x<<" "
    #define sf scanf
    #define pf printf
    #define all(x) (x).begin(),(x).end()
    #define SZ(x) ((int)(x).size())
    #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--)
    typedef long long ll;
    typedef unsigned long long ull;
    //typedef __int128 INT128;
    //INT128 read(){
    //    INT128 x=0,f=1;
    //    char ch=getchar();
    //    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    //    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    //    return x*f;
    //}
    //void write(INT128 x){
    //    if(x<0){putchar('-');x=-x;}
    //    if(x<10){putchar(x+'0'); return;}
    //    write(x/10);putchar(x%10+'0');
    //}
    typedef long double ld;
    const int INF=0x3f3f3f3f;
    const double eps=1e-8;
    const double PI=acos(-1.0);
    const int MAXN=1e5+5;
    const int MAXM=2e6+5;
    const int MOD=1e9+7;
    int sgn(double x){if(fabs(x)<eps)return 0;if(x<0)return -1;else return 1;}
    ll pw(ll a,ll n,ll mod){ll ret=1;while(n){if(n&1)ret=ret*a%mod;a=a*a%mod;n>>=1;}return ret;}
    ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
    ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
    void inc(ll &a,ll b){a+=b;if(a>=MOD)a-=MOD;}
    void dec(ll &a,ll b){a-=b;if(a<0)a+=MOD;}
    int mul(int x, int y){ll z=1ll*x*y;return z-z/MOD*MOD;}
    //head
     
    int n,ta,tb,pos_a[MAXN],pos_b[MAXN],pos[MAXN];
    string s,ans,dp[MAXN];
    int main(){
        cin>>n>>s; ta=tb=0;
        rep(i,0,2*n){
            if(s[i]=='a')pos_a[++ta]=i,pos[i]=ta;
            else pos_b[++tb]=i,pos[i]=tb;
        }
        per(i,1,n+1){
            if(pos_a[i]<pos_b[i]){
                int k=i;
                rep(j,pos_a[i]+1,pos_b[i])k=max(k,pos[j]);
                dp[i]="ab"+dp[k+1];
            }else{
                int k=i;
                while(k<n&&pos_b[k+1]<pos_a[k])k++;
                rep(j,pos_b[i],2*n)if(pos[j]>=i&&pos[j]<=k)dp[i]+=s[j];
                //de(k);
                dp[i]+=dp[k+1];
            }
            //dd(i); de(dp[i]);
            dp[i]=max(dp[i],dp[i+1]);
            ans=max(ans,dp[i]);
        }
        cout<<ans<<endl;
    }


Measured memory_bytes: 15360
// AOJ 2896: Test
// 2019.2.19 bal4u
 
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i, N, M, a, ans;

	scanf("%d%d", &N, &M);
	ans = 0;
	for (i = 0; i < M; i++) {
		scanf("%d", &a);
		if (a > M) ans++;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,ans=0;
  cin>>n>>k;
  vector<int> a(100),d(100),e(101,0);
  for(int i=0;i<k;i++){
    cin>>d[i];
    for(int j=0;j<d[i];j++){
      scanf("%d",&a[j]);
      e[a[j]]++;
    }
  }for(int i=1;i<=n;i++){
    if(e[i]==0){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3700
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	ss := []string{"", "SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"}
	S := nextString()

	for i := 0; i < len(ss); i++ {
		if ss[i] == S {
			fmt.Println(i)
			return
		}
	}

	fmt.Println()
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


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

#define mp make_pair
#define pb push_back
#define f first
#define s second 
#define sz(s) (int)s.size()
#define int long long	
#define all(s) s.begin(), s.end()
#define forn(i, x, y) for(int i = x; i <= y; i++)
#define forev(i, y, x) for(int i = y; i >= x; i--)

using namespace std;

const int maxn = (int)3e5 + 100;
const int mod = (int)1e9 + 7;
const int P = (int)1e6 + 7;
const int inf = (int)1e9 + 7;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef long double ld;

int n, k, a[maxn], s;
main () {
	cin >> n >> k;
	forn(i, 1, n) cin >> a[i], s += a[i];
	vi d;
	forn(i, 1, sqrt(s)){
		if(s % i == 0)
			d.pb(i), d.pb(s / i);
	}
	sort(all(d));
	reverse(all(d));
	for(auto x : d){
		if(s % x) continue;
		int step = 0;
		vi v;
		forn(i, 1, n){
			if(a[i] % x == 0) continue;
			v.pb(a[i] % x);
		}
		sort(all(v));
		int l = 0, r = sz(v) - 1, s1 = 0, s2 = 0;
		while(l <= r){
			
			if(s1 <= s2){
				s1 += v[l];
				step += v[l];
				l++;
			}else{
				s2 += x - v[r];
				step += x - v[r];
				r--;
			}
		}
		if(s1 != s2) continue;
		if(step <= 2 * k){
			cout << x;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000

int main(){
  ll s;
  cin >> s;
  ll ans = 0;
  while(s >=500){
    s -= 500;
    ans += 1000;
  }
  while(s >= 5){
    s -= 5;
    ans += 5;
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b;
	
	scanf("%d %d",&a,&b);
	
	if((-1000<=a)&&(b<=1000)){
		if(a<b){
			printf("a < b\n");
		}else if(a>b){
			printf("a > b\n");
		}else{
			printf("a == b\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include <iostream>

using namespace std;

int main() {
	int K, A, B;
	cin >> K >> A >> B;
	if (A % K == 0) {
		cout << "OK" << endl;
	}
	else {
		int hoge = A / K;
		int baisuu = K * (hoge + 1);
		//cout << hoge << endl;
		//cout << baisuu << endl;
		if (baisuu <= B) {
			cout << "OK" << endl;
		}
		else {
			cout << "NG" << endl;
		}
	}
}

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

#define int int64_t
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

const double EPS = 1e-9;

signed main() {
	int n;
	while (cin >> n && n) {
		int x; cin >> x;
		int ans = n;
		n = n - x;
		if (n < x) swap(n, x);
		while (x != 0) {
			ans += n / x * 2 * x;
			int tmp = n % x;
			n = x;
			x = tmp;
		}
		ans -= n;
		cout << ans << endl;
	}
	system("pause");
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=1000000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> divisor(ll x){vector<ll> div;
	for(ll i=1;i*i<=x;i++){if(x%i==0){div.pb(i);if(i*i!=x)div.pb(x/i);}}
	sort(div.bg,div.ed);return div;}


int main(){
	ll A,B,C; cin>>A>>B>>C;
	cout<<min(C,A+B+1)+B;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static String decode (String code) {
		char[] alp = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
		char[] c = code.toCharArray();
		for (int i = 0; i <= 25; i++) {
			for (int j = 0; j < c.length; j++) {
				if (97 <= c[j] && c[j] <= 122)
					c[j] = alp[(c[j] - 97 + 1) % 26];
			}
			String res = String.valueOf(c);
			if (res.indexOf("the") != -1 || res.indexOf("this") != -1 || res.indexOf("that") != -1)
				return res;
		}
		return code;
	}

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while (sc.hasNextLine()) {
			String code = sc.nextLine();
			System.out.println(decode(code));
		}

	}

}

Measured memory_bytes: 18136
#include<bits/stdc++.h>
using namespace std;
int n;set<string> d;string s,t;
int main(){
  cin>>n;
  while(n--){
    cin>>s>>t;
    if(s[0]=='f')cout<<(d.find(t)!=d.end()?"yes":"no")<<endl;
    else d.insert(t);
  }
}



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

int main(){
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  int res = 0;
  for(int i = 0; i <= a; ++i){
    for(int j = 0; j <= b; ++j){
      for(int k = 0; k <= c; ++k){
        int total = 500*i + 100*j + 50*k;
        if(total == x) ++res;
      }
    }
  }
  
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <string>
#include <stdlib.h>
#include <algorithm>

using namespace std;
 
int ascSort(const void* v1, const void* v2) {
    const int _v1 = *((const int*)v1);
    const int _v2 = *((const int*)v2);
 
    if ( _v1 < _v2 ) {
        return 1;
    } else if ( _v1 > _v2 ) {
        return -1;
    } else {
        return 0;
    }
}
int main() {
	int n,i,swap,count=0;
	int p[100005];
	cin >> n;
	for(i=0;i<n;i++){
		cin >> p[i];
	}
	for(i=0;i<n;i++){
		if(p[i]==i+1){
			swap = p[i+1];
			p[i+1] = p[i];
			p[i] = swap;
			count += 1;
		}
	}
	cout << count << endl;
	return 0;
}

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

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

    int a,b;
    // 引数の受け取り
    //
    cin >> a;
    int d = a / 10;
    int e = a - d*10 ;
if (e==(a/100)){
    cout << "Yes" << endl;

}else{
    cout << "No" << endl;

}

    // 出力
    return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
//
#define int long long
#define ALL(x) (x).begin(), (x).end()
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))
// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((a) >> (b)) & 1
#define bitcount(a) __builtin_popcountll((a))
//
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;
//
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
//
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int N, C;
int D[1010][1010], c[1010][1010];
int sum[5][35]; // sum[i][c]:=
                // (x+i)%3==iを満たすマスを,全てcに変更したときの総コスト

signed main() {
  cin >> N >> C;
  for (int i = 1; i <= C; i++) {
    for (int j = 1; j <= C; j++) {
      cin >> D[i][j];
    }
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      cin >> c[i][j];
    }
  }

  m0(sum);

  for (int co = 1; co <= C; co++) {

    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= N; j++) {
        int temp = (i + j) % 3;
        sum[temp][co] += D[c[i][j]][co];
      }
    }
  }

  int ans = INF;
  for (int i = 1; i <= C; i++) {
    for (int j = 1; j <= C; j++) {
      for (int k = 1; k <= C; k++) {
        if (i == j || j == k || k == i) {
          continue;
        }

        int temp = sum[0][i] + sum[1][j] + sum[2][k];
        chmin(ans, temp);
      }
    }
  }

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


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int dfs(int n, int m, int now, int cnt, const vector<bitset<500>> &v, bitset<500> bs) {
  if(now == n) {
    if(bs.count() == 0) {
      return cnt;
    } else {
      return 0;
    }
  } else {
    int tmp1 = dfs(n, m, now+1, cnt+1, v, bs ^ v[now]);
    int tmp2 = dfs(n, m, now+1, cnt, v, bs);
    return max(tmp1, tmp2);
  }
}
void input(int sz, vector<bitset<500>> &v) {
  for(int i=0;i<sz;++i) {
    string tmp; cin >> tmp;
    v[i] = bitset<500>(tmp);
  }
}
void solve1(int n, int m) {
  vector<bitset<500>> v(n);
  input(n, v);
  cout << dfs(n, m, 0, 0, v, bitset<500>()) << endl;
}
void solve2(int n, int m) {
  vector<bitset<500>> v1(n);
  input(n, v1);
  vector<ll> v2(n);
  for(int i=0;i<n;++i) {
    v2[i] = static_cast<ll>(v1[i].to_ullong());
  }
  vector<map<ll, int>> dp(n+1);
  dp[0][0] = 0;
  for(int i=0;i<n;++i) {
    for(auto &e: dp[i]) {
      ll bs = e.first;
      int cnt = e.second;
      dp[i+1][bs] = max(dp[i+1][bs], cnt);
      dp[i+1][bs ^ v2[i]] = max(dp[i+1][bs ^ v2[i]], cnt + 1);
    }
  }
  cout << dp[n][0] << endl;
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  while(1) {
    int n, m; cin >> n >> m;
    if(n == 0) break;
    if(n < m) {
      solve1(n, m);
    } else {
      solve2(n, m);
    }
  }
}



Measured memory_bytes: 175124
H, W = list(map(int, input().split()))

def nasu(a, b, c):
  return max(a, b, c) - min(a, b, c)

mi = H * W
for i in range(1, H):
  x = W * i
  y = W * ((H - i) // 2)
  z = H * W - x - y
  mi = min(mi, nasu(x, y, z))
  y = (H - i) * (W // 2)
  z = H * W - x - y
  mi = min(mi, nasu(x, y, z))

for i in range(1, W):
  x = H * i
  y = H * ((W - i) // 2)
  z = H * W - x - y
  mi = min(mi, nasu(x, y, z))
  y = (W - i) * (H // 2)
  z = H * W - x - y
  mi = min(mi, nasu(x, y, z))
  
print(mi)

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

int main()
{
	int d, w;
	while (cin >> d >> w, d | w) {
		vector<vector<int>> e(d, vector<int>(w));
		for (int i = 0; i < d; i++) {
			for (int j = 0; j < w; j++) {
				cin >> e[i][j];
			}
		}
		int res = 0;
		for (int i = 0; i < d; i++) {
			for (int j = i + 3; j <= d; j++) {
				for (int k = 0; k < w; k++) {
					for (int l = k + 3; l <= w; l++) {
						int ma = 0, mi = 10;
						for (int x = i; x < j; x++) {
							for (int y = k; y < l; y++) {
								if (x == i || x == j - 1 || y == k || y == l - 1) {
									mi = min(mi, e[x][y]);
								}
								else {
									ma = max(ma, e[x][y]);
								}
							}
						}
						if (ma < mi) {
							int sum = 0;
							for (int x = i + 1; x < j - 1; x++) {
								for (int y = k + 1; y < l - 1; y++) {
									sum += mi - e[x][y];
								}
							}
							res = max(res, sum);
						}
					}
				}
			}
		}
		cout << res << endl;
	}
	return 0;
}



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

int main() {
  int N;
  int i;
  cin >> N >> i;
  cout << N-i +1;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){

	int a,b,c,d,e,ave;

	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&e);

	if ( a < 40){
		a = 40;
	}
	if ( b < 40){
		b = 40;
	}
	if ( c < 40){
		c = 40;
	}
	if ( d < 40){
		d = 40;
	}
	if ( e < 40){
		e = 40;
	}
	
	ave= (a+b+c+d+e)/5;

	printf("%d\n",ave);
	

	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

struct Edge{
    // 始点, 終点, 重み, 最大量
    long long src, dst, weight, capacity;
    Edge(): src(0), dst(0), weight(0), capacity(0) {}
    Edge(long long s, long long d, long long w): src(s), dst(d), weight(w) {}
    Edge(long long s, long long d, long long w, long long c): src(s), dst(d), weight(w), capacity(c) {}
};

class Graph{
public:
    long long size;
    vector<vector<Edge>> node;
    Graph(long long n): size(n), node(n) {}
    // 無向辺の追加
    void addEdge(long long s, long long d, long long w = 1){
        node[s].emplace_back(s, d, w);
        node[d].emplace_back(d, s, w);
    }
    // 有向辺の追加
    void addArc(long long s, long long d, long long w = 1){
        node[s].emplace_back(s, d, w);
    }
    // ノードの追加
    void addNode(){
        size++;
        node.emplace_back();
    }
};

// Warshall-Floyd; 全点間対最短路（ワーシャル-フロイド法）[O(n^3)]
vector<vector<long long>> WarshallFloyd(const Graph &g){
    const long long WeightINF = numeric_limits<long long>::max()/2-1;
    vector<vector<long long>> d(g.size, vector<long long>(g.size, WeightINF));
    for(long long v=0; v<g.size; v++){
        for(auto &edge: g.node[v]) d[edge.src][edge.dst] = edge.weight;
        d[v][v] = 0;
    }
    for(long long i=0; i<g.size; i++){
        for(long long j=0; j<g.size; j++){
            for(long long k=0; k<g.size; k++){
                if(d[j][i] != WeightINF && d[i][k] != WeightINF) d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
            }
        }
    }
    return d;
}

int main(){
    Init();

    // 初期値の入力
    ll n, m, r;
    cin >> n >> m >> r;
    Graph g(n);

    // 訪問箇所の入力（昇順に整列）
    vi city(r);
    rep(i, r){
        cin >> city[i];
        city[i]--;
    }
    sort(all(city));

    // グラフの作成（0-based）
    rep(i, m){
        ll a, b, c; cin >> a >> b >> c;
        a--; b--;
        g.addEdge(a, b, c);
    }

    // 全点間対最短路
    auto wf = WarshallFloyd(g);

    // 全探索
    ll ans = INFLL;
    do{
        // cityの順でした場合のコストを計算
        ll sum = 0;
        for(ll i=0; i<r-1; i++) sum += wf[city[i]][city[i+1]];
        chmin(ans, sum);
    } while(next_permutation(all(city)));
    cout << ans << endl;
}

Measured memory_bytes: 5328
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    int count1=0;
    for(int i=1;i<=N;i+=2){
        int count2=0;
        for(int j=1;j<=200;j++){
            if(i%j==0) count2++;
        }
        if(count2==8) count1++;
    }
    cout << count1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define for_(i,n) for(int i=0;i<n;++i)
#define for_1(i,n) for(int i=1;i<=n;++i)
const int mod= 1e9 +7;
const int inf=1e7;
int n;

int add_self(int &y, int x)
{
    y+=x;
    if(y>=mod)
    y-=mod;
    return y;
}

int mul(int x, int y)
{
    return (x*y)%mod;
}
main()
{  
int k;
cin>>n>>k;
vector<vector<int>> a(n+1, vector<int>(n+1));
vector<int> b(n+1);
for(int i=1;i<=n;++i)
{
    for(int j=1;j<=n;++j)
    {
        cin>>a[i][j];
        if(a[i][j]) {b[j]++;} 
    }
    
}




//c=b*a^k for a^k use matrix exponentiation
//int res[n+1][n+1];//= identity matrix;
vector<vector<int>> res(n+1, vector<int>(n+1));
for_1(i,n)
for_1(j,n)
{
    if(i==j) res[i][j]=1;
    else res[i][j]=0;
}
int x= k-1;
while(x>0)
{   vector<vector<int>> temp(n+1, vector<int>(n+1));
    //for_1(i,n) for_1(j,n) temp[i][j]=0;
    if(x&1) 
    {
        for_1(i,n) for_1(j,n)
        {   temp[i][j]=0;
            for_1(k,n)  add_self(temp[i][j],mul(res[i][k],a[k][j]));
            
        }
    
        res=temp;
    }
    
    for_1(i,n) for_1(j,n) 
    {   temp[i][j]=0; 
        for_1(k,n) add_self(temp[i][j],mul(a[i][k],a[k][j]));
        
    }
    
    a=temp;
    x=x/2;
}
vector<int> c(n+1);
for_1(i,1) for_1(j,n) for_1(k,n) c[j]= add_self(c[j],mul(b[k],res[k][j]));

int ans=0;
for_(i,n)
{ 
    add_self(ans,c[i+1]);
 
}

cout<<ans<<endl;
}























/*
typedef struct structure{
    int x,y;
} pt;
pt p0;
bool cmp(pt a, pt b)
{
    return cw(p0,a,b);
}
bool cw(pt a, pt b, pt c){
    return ((c.y-a.y)*(b.x-a.x)-(b.y-a.y)*(c.x-a.x))>=0
}



convex_hull(vector<pt>& points)
{
   // sort(points.begin(),points.end, cmp);// sorted according to y cordinate
    p0=points[0];
    sort(points.begin(),points.end, cmp);
    vector<pt> convexHull;
    stack<pt> temp;
    convexHull.push_back(points[0]);
    
    temp.push(points[0]);temp.push(points[1]);//temp.push(points[2]);
    pt top,top0;
    for(int it=2;it<points.size();++it)
    {   
        top=temp.top(); temp.pop(); top0=temp.top();
        pt next=points[it];
        if(cw(top0,top,next))
        {
            convexHull.push_back(top);
            temp.push(top);
            top0=top;
            top=next;
        }
        else
        {
          temp.push(next);  
        }
        
    }
    
}*/












Measured memory_bytes: 256
k, s = map(int, input().split())


def calc_xyz(target, limit):
    cnt = 0
    for x in range(min(limit, target) + 1):
        yz_sum = target - x
        for y in range(min(limit, yz_sum) + 1):
            if 0 <= target - x - y <= limit:
                cnt += 1
    return cnt


print(calc_xyz(s, k))


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

void solve(){
    string s; cin >> s;
    string ans;
    for(int i = 0; i < s.size(); ++i){
        if(s[i] == '0'){
            ans += '0';
        } else if(s[i] == '1') {
            ans += '1';
        } else {
            if(!ans.empty()){
                ans.erase(ans.size()-1, 1);
            }
        }
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005


int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);

        int n,a,b;
        cin >> n >> a >> b;
        int c=min(n*a,b);
        cout << c << '\n';
        
        

}

Measured memory_bytes: 256
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("IMPOSSIBLE"),0;
#define mod 1000000007
#define N 600055
//#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,f[N],vis[N],siz[N],x,cur[N];
int nedge,Next[N*2],head[N],to[N*2];
#define V to[i]
void add(int a,int b){
	Next[++nedge]=head[a];head[a]=nedge;to[nedge]=b;
}
void add_ne(int a,int b){add(a,b);add(b,a);}
inline int ch(int x){
	return x+((x&1)?1:-1);
}
void dfs(int x){
	x=x;
	for(int &i=cur[x];i;i=Next[i]){
		if (vis[i]) continue;
		vis[i]=1;vis[ch(i)]=1;
		if (V==x+n) f[x]=-1;
		if (V==x-n) f[V]=1;
		dfs(V);
	}
}
signed main(){
	n=read();
	F(i,1,n*2){
		x=read();x=(x==-1)?0:x;
		if (x&&i>n) x+=n;
		add_ne(i,x);siz[x]++;
	}
	F(i,1,n) if ((siz[i]+siz[i+n])%2==1) ret;
	F(i,1,n) if (siz[i]%2==0) add_ne(i,i+n);
	f[0]=-1;F(i,0,n*2) cur[i]=head[i];
	dfs(0);
	//F(i,1,n) if (siz[i]%2==1) f[i]=0;
	puts("POSSIBLE");
	F(i,1,n) wri(f[i]);
	return 0;
}

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

using namespace std;

#define ll long long
#define ld long double
#define ff first
#define ss second
#define rsz resize
#define ins insert 
#define mp make_pair
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define ft front() 
#define bk back()
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define deb(x) cout<<#x<<" "<<x<<'\n';
#define rep(i,a,b) for (int i = (a); i < (b); ++i)

const ll mod = 1e9+7; // 998244353;
const ll inf = 1e18; 
const ld pie = acos((ld)-1);

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

long long binpow(long long a, long long b) {
    long long res = 1;
    a%=mod;
    while (b > 0) {
        if (b & 1)
            res = res * a%mod;
        a = a * a%mod;
        b >>= 1;
    }
    return res;
}

int main(){
    
	ll n;
	scanf("%lld",&n);
	ll a1 = binpow(10,n);//total possible sequences
	ll a2 = binpow(9,n);//9 not present || 0 not present
	ll a3 = binpow(8,n);//0 and 9 both not present
	ll ans = (a1-2*a2+a3)%mod;//inclusion and exclusion
	if(ans<0ll){
		ans+=mod;
	}
	printf("%lld\n",ans);
	return 0;

	/*STUFF TO LOOK:	
		1. Check the constraints
		2. Corner cases(n==0||n==1)
		3. Variables in loops
		4. Make sure two ints aren’t multiplied to get a long long
		5. Don't use scanf or printf while using ios_base
		6. using the local variable of the same name when global variable was required to be used
	*/
}


Measured memory_bytes: 3832
//https://atcoder.jp/contests/abc159/tasks/abc159_b
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
#if LOCAL&01
  std::ifstream in("./test/sample-2.in");
  //std::ifstream in("./input.txt");
  std::cin.rdbuf(in.rdbuf());
#else
  cin.tie(0);
  ios::sync_with_stdio(false);
#endif
  string S; cin>>S;
  auto len=S.length();

  bool ans=true;
  //eはふくまない
  auto check_kaibun = [&](ll s, const ll e)->bool{
    for(ll i=s;i<e;++i){
      ll pt=e-i-1;
      if(i>=pt||pt<0) break;
      if (S.at(i)!=S.at(pt)) {
        dump(false);
        return false;
      }
    }
    dump(true);
    return true;
  };

  ans &= check_kaibun(0,S.length());
  ans &= check_kaibun(0,(len-1)/2);
  ans &= check_kaibun(len+3/2-1,len);
  cout<<(ans?"Yes":"No")<<endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MOD 1000000007
typedef long long  ll;

using namespace std;

int ans, cnt;

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

	int X,N;
	cin >> X >> N;

	map<int,int> p;
	rep(i, N) {
		int t;
		cin >> t;
		p[t]++;
	}

	int index = 0;
	while (1) {
		if (!p.count(X - index)) {
			ans = X - index;
			break;
		}
		else if(!p.count(X + index)){
			ans = X + index;
			break;
		}
		index++;
	}

	// cout << fixed << setprecision(15);
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int W, H, x, y;

int main(){
	cin >> W >> H >> x >> y;
	printf("%.16f ", (double)W * (double)H / 2.0);
	if(W == x * 2 && H == y * 2){
		cout << 1 << endl;
	}else{
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  
   int N;
   cin>>N;
   
    int x=N%10;
    

   if(x==2  ||  x== 4 ||   x== 5 ||  x==7  ||  x==9)
     cout<<"hon";
    else if(x==0 ||  x==6 || x==1 ||  x==8)
      cout<<"pon";
      else
        cout<<"bon";

   return 0;
}

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

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    vector<int> a(n);
    for (int &i: a) scanf("%d", &i);
    vector<int> dp(k+1, false);
    dp[0] = false;
    sort(a.begin(), a.end());
    for (int i=0; i<=k; i++) {
        if (!dp[i]) {
            for (int j: a) {
                if (j+i<=k) dp[j+i] = true;
            }
        }
    }
    string message = dp[k]==true?"First":"Second";
    cout << message << endl;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt(), G = sc.nextInt();
		int nums[][] = new int[D][2];
		for(int i=0;i<D;i++) {
			int p = sc.nextInt(), c = sc.nextInt();
			nums[i][0] = p; nums[i][1]=c;
		}
		sc.close();
		
		int ans = Integer.MAX_VALUE / 2;
		//bit全探索
		for(int bit = 0; bit<(1<<D); bit++) {
			int score = 0;
			int cnt = 0;
			for(int i=0;i<D;i++) {
				if((bit>>i & 1)==1) {
					int num = nums[i][0] , bonus = nums[i][1];
					cnt += num;
					score += (i+1)*100 * num; 
					score += bonus; //bonus
				}
			}
			
			int maxD = 0;
			for(int j=D-1;j>=0;j--) {
				if((bit>>j & 1)!=1 && nums[j][0]>0) {
					maxD = j;
					break;
				}
			}
			int num = nums[maxD][0];
			while(G>score) {
				score += (maxD + 1)*100;
				num --;
				cnt ++ ;
				if(num == 0) break;
			}
			if(G>score)continue;
			ans = Math.min(ans, cnt);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
ll gcd(ll a,ll b){
  if(b==0) return a;
  return gcd(b,a%b);
}
ll lcm(ll a,ll b){
  return a*b/gcd(a,b);
}
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }
const int MOD = 1e9+7;

int main() {
  int n,m;
  cin >> n >> m;
  vector<int>p(m+1);
  vector<string>s(m+1);
  rep1(i,m)cin >> p[i] >> s[i];
  vector<int>ac(n+1,0);
  vector<int>wa(n+1,0);
  rep1(i,m){
    if(ac[p[i]]==0){
      if(s[i]=="AC"){
        ac[p[i]]++;
      }
      else if(s[i]=="WA")wa[p[i]]++;  
    }
  }
  int ansac=0;
  int answa=0;
  rep1(i,n){
    if(ac[i]){
      ansac++;
      answa+=wa[i];
    }  
  }
  cout << ansac << endl;
  cout << answa << endl;
}

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



using namespace std;

int main(){

   long long N,K,X,Y;

   cin>>N;
   cin>>K;
   cin>>X;
   cin>>Y;

   if(N<K){
    cout<<N*X;
   }
   else{

   cout<<(K*X)+(N-K)*Y;

   }



   return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int x,y,i,z;

  scanf("%d%d",&x,&y);

  if(x<y){
    z=x;
    x=y;
    y=z;
  }

  while(y>0){
    z= x%y;
    x=y;
    y=z;
  }
    
    


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




Measured memory_bytes: 2144