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



int main() {
  int N;
  cin>>N;
  int count=0,ans=0,count2=0;
  for(int i=1;i<10;i++){
      for(int j=i;j<10;j++){
          if(i==j){
              if(i<=N){count++;}
              if(i*11<=N){count++;}
              if(i*101<=N){
                  rep(k,10){
                      if(i*101+10*k<=N){count++;}
                  }
              }
              if(i*1001<=N){
                  rep(k,100){
                      if(i*1001+10*k<=N){count++;}
                  }
              }
              if(i*10001<=N){
                  rep(k,1000){
                      if(i*10001+10*k<=N){count++;}
                  }
              }
              if(i*100001<=N){
                  rep(k,10000){
                      if(i*100001+10*k<=N){count++;}
                  }
              }
              ans+=count*count;
              count=0;
          }
          else{
              if(10*i+j<=N){count++;}
              if(100*i+j<=N){
                  rep(k,10){
                      if(100*i+j+10*k<=N){count++;}
                  }
              }
              if(1000*i+j<=N){
                  rep(k,100){
                      if(1000*i+j+10*k<=N){count++;}
                  }
              }
              if(10000*i+j<=N){
                  rep(k,1000){
                      if(10000*i+j+10*k<=N){count++;}
                  }
              }
              if(100000*i+j<=N){
                  rep(k,10000){
                      if(100000*i+j+10*k<=N){count++;}
                  }
              }
              if(10*j+i<=N){count2++;}
              if(100*j+i<=N){
                  rep(k,10){
                      if(100*j+i+10*k<=N){count2++;}
                  }
              }
              if(1000*j+i<=N){
                  rep(k,100){
                      if(1000*j+i+10*k<=N){count2++;}
                  }
              }
              if(10000*j+i<=N){
                  rep(k,1000){
                      if(10000*j+i+10*k<=N){count2++;}
                  }
              }
              if(100000*j+i<=N){
                  rep(k,10000){
                      if(100000*j+i+10*k<=N){count2++;}
                  }
              }
              ans+=count*count2*2;
              count=0;count2=0;
          }
      }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  int p[1000];
  for(int i=0;i<N;i++){
    cin>>p[i];
  }
  sort(p,p+N);
  int answer=0;
  for(int i=0;i<K;i++){
    answer+=p[i];
  }
  cout<<answer<<endl;
  
  return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll M, DC = 0, S = 0;
	cin >> M;
	for(int i = 0; i < M; ++i){
		ll d, c; cin >> d >> c;
		S += d*c; DC += c;
	}
	ll r = DC-1 + (S-1)/9;
	cout << r << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int N, X;
map<PII, int> mem;


int S(int L){
    return (1LL<<(L+2))-3;
}


int rec(int k = N, int x = X){
    if(mem.find({ k, x }) != end(mem)) return mem[{ k, x }];
    int& res = mem[{ k, x }];
    if(x == 0) return res = 0;
    if(k == 0) return res = 1;
    if(x <= 1+S(k-1)) return res = rec(k-1, x-1);
    if(x <= 1+S(k-1)+1) return res = rec(k-1, S(k-1))+1;
    return res = rec(k-1, S(k-1))+1+rec(k-1, x-(1+S(k-1)+1));
}


signed main(){
    cin >> N >> X;

    cout << rec() << endl;

    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int max(int a,int b);

int main(void)
{
	int a,b,sum=0,k=0;
	scanf("%d%d",&a,&b);
	k = max(a,b);

	sum = sum + k;

	if(k == a) a = a - 1;
	else if(k == b) b = b - 1;
	
	sum = sum + max(a,b);
	printf("%d",sum);
	return 0;
}

int max(int a,int b)
{
	if(a >= b)
	{
		return a;
	}
	else
	{
		return b; 
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
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-9;
const ll 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 << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int m, n; cin >> m >> n;
  vector<vector<double>> p(m, vector<double>(n));
  for(int i=0;i<m;++i) {
    for(int j=0;j<n;++j) {
      cin >> p[i][j];
    }
  }
  vector<vector<vector<double>>> dp(m, vector<vector<double>> (2, vector<double>(1<<m, 0.0)));
  for(int i=0;i<m;++i) {
    for(int k=0;k<(1<<m);++k) {
      dp[i][n%2][k] = 1;
    }
  }
  for(int j=n-1;j>=0;--j) {
    int nj = j % 2;
    for(int k=(1<<m)-1;k>=0;--k) {
      for(int i=0;i<m;++i) {
        if (!((k >> i) & 1)) {
          continue;
        }
        for (int l = 0; l < m; ++l) {
          if (!((k >> l) & 1)) dp[i][nj][k] = max(dp[i][nj][k], (1 - p[i][j]) * dp[l][nj][k | (1 << l)]);
        }
        dp[i][nj][k] += p[i][j] * dp[i][!nj][k];
      }
    }
    for(int i=0;i<m;++i) {
      for(int k=0;k<(1<<m);++k) {
        dp[i][!nj][k] = 0;
      }
    }
  }
  double ans = 0.0;
  for(int i=0;i<m;++i) {
    for(int k=0;k<(1<<m);++k) {
      ans = max(ans, dp[i][0][k]);
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 21236
#include <stdio.h>

int main(){
    int n, k, passed = 0;
    scanf("%d %d", &n, &k);
    int a[n];

    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        if (a[i] >= k){
            ++passed;
        }
    }
    printf("%d\n", passed);

    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
 
using namespace std;
 
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  long long ans;
  if (n <= k) {
    ans = n-1;
  } else {
    ans = 0;
    for (int i=0;i<n-1;i++) {
      ans += ans/(k-1) + 1;
   }
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 2728
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

const int N=3e5+5;

ld a[N];
int n,k;

int main()
{ios_base::sync_with_stdio(false);
cin>>n>>k;
rep(i,1,n)
{
	ld x,y;
	cin>>x;
	y=(x*(x+1))/2;
	a[i]=a[i-1]+y/x;
}
ld ans=0;
rep(i,k,n)
{
	ans=max(ans,a[i]-a[i-k]);
}
cout<<fixed<<setprecision(10)<<ans;
return 0;
}



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

void solve(int TestCase) {
    string s;
    cin >> s;
    
    bool rev = false;
    int q;
    cin >> q;
    deque<char> dq;
    for(auto x : s)
    {
        dq.push_back(x);
    }
    for(auto i = 0; i < q; ++i)
    {
        int t;
        cin >> t;
        if(t == 1)
            rev ^= 1;
        else {
            int f;
            cin >> f;
            char c;
            cin >> c;

            f--;
            if(rev)
                f ^= 1;
            if(f)
                dq.emplace_back(c);
            else
                dq.emplace_front(c);
        }
    }

    string ret;
    for(auto i = 0; i < dq.size(); ++i)
    {
        ret.push_back(dq[i]);
    }

    if(rev)
        reverse(ret.begin(), ret.end());
    cout << ret << endl;
}
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    int t = 1;
    //cin >> t;
    for(auto i = 1; i <= t; ++i) {
    //    cout << "Case #"<< i << ": ";
        solve(i);
    }
}

Measured memory_bytes: 1368
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Test1 {

    


    class ClassMain {

       
        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                //int n = int.Parse(line);
                //if (n == 0) { break; }
                int[] w = new int[10];
                int[] k = new int[10];
                w[0] = int.Parse(line);
                for (int i = 1; i < 10; i++) {
                    w[i] = int.Parse(Console.ReadLine());
                }
                for (int i = 0; i < 10; i++) {
                    k[i] = int.Parse(Console.ReadLine());
                }
                Array.Sort(w);
                Array.Sort(k);
                int sumw = w[9] + w[8] + w[7];
                int sumk = k[9] + k[8] + k[7];
                Console.WriteLine(sumw+" "+sumk);
                //break;
            }
        }

        
    }



    
}

Measured memory_bytes: 5740
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007


int main(){
    int N, K; cin >> N >> K;
    map<int, ll> M;
    for(int i=0; i<N; i++){
        int a; cin >> a;
        M[a]++;
    }

    vector<ll> V;
    for(auto m:M) V.push_back(m.second);
    sort(V.begin(), V.end());

    ll ret = 0;
    for(int i=0; i<(int)V.size()-K; i++)
        ret += V[i];

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


Measured memory_bytes: 14964
#stackのクラスを実装
class stack():
    def __init__(self):
        self.S = []
        self.maxlen= 1000000
        
    def push(self, x):
        if len(self.S) == self.maxlen:
            print('オーバーフロー')
        else:
            self.S.append(x)
        
    def pop(self):
        if len(self.S) == 0:
            print('アンダーフロー')
            return False
        else:
            return self.S.pop()
    
    def isEmpty(self):
        if len(self.S) == 0:
            return True
        else:
            return False
    
    def isFull(self):
        if len(self.S) == self.lenmax:
            return True
        else:
            return False
        
stk = stack()
rpn = input().split()

for i in range(len(rpn)):
    if rpn[i] == '+':
        y = stk.pop()
        x = stk.pop()
        stk.push(x+y)
    elif rpn[i] == '-':
        y = stk.pop()
        x = stk.pop()
        stk.push(x-y)
    elif rpn[i] == '*':
        y = stk.pop()
        x = stk.pop()
        stk.push(x*y)
    elif rpn[i] == '/':
        y = stk.pop()
        x = stk.pop()
        stk.push(x/y)
    else:
        stk.push(int(rpn[i]))
print(stk.pop())


Measured memory_bytes: 5612
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

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

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	char x, y;
	cin >> x >> y;
	if (x == y) {
		cout << "=" << endl;
	}
	else if (x > y) {
		cout << ">" << endl;
	}
	else {
		cout << "<" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
N = int(input())
pi = [0]*N
sum = 0
for i in range(N):
    pi[i] = int(input())
maxprice = max(pi)
for i in range(N):
    if pi[i] == maxprice:
        pi[i] /= 2
        break
for i in range(N):
    sum += pi[i]
print(int(sum))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;
const int MAX_N = 59;
const int MAX_S = 2509;

struct Edge {
  int to, a, b;
  Edge(int to, int a, int b) : to(to), a(a), b(b) {}
};

struct Data {
  int v, s;
  ll dist;
  Data(int v, int s, ll dist) : v(v), s(s), dist(dist) {}
  bool operator<(const Data& a) const {
    return dist > a.dist;
  }
};

vector<Edge> g[MAX_N];
ll dp[MAX_N][MAX_S+2];

int main() {
  int n, m, s;
  cin >> n >> m >> s;
  rep(i,n)rep(j,MAX_S+2) dp[i][j] = LLINF;
  rep(i,m) {
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    u--; v--;
    g[u].emplace_back(v, a, b);
    g[v].emplace_back(u, a, b);
  }
  vector<int> c(n), d(n);
  rep(i,n) cin >> c[i] >> d[i];
  s = min(s, MAX_S);

  priority_queue<Data> pq;
  auto push = [&](int v, int s, ll dist) {
    if(s < 0) return;
    if(dp[v][s] <= dist) return;
    dp[v][s] = dist;
    pq.emplace(v, s, dist);
  };
  push(0, s, 0);

  while (!pq.empty()) {
    Data dat = pq.top(); pq.pop();
    int v = dat.v;
    int s = dat.s;
    ll dist = dat.dist;
    {
      int ns = min(s+c[v], MAX_S);
      push(v, ns, dist+d[v]);
    }
    for (auto u : g[v]) {
      push(u.to, s-u.a, dist+u.b);
    }
  }

  rep2(i,1,n) {
    ll ans = LLINF;
    rep(j, MAX_S) {
      chmin(ans, dp[i][j]);
    }
    cout << ans << endl;
  }

  return(0);
}




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

using namespace std;
int main(){
    int N,A,B;
    cin >> N >> A >> B;
    int ans = 0;
    for(int i = 1;i < N+1;i++){
        int t = i,c = 0;
        for(int j = 0;j < 6;j++){
            if(t > 0){
                c += t % 10;
                t = t / 10;
            }
            else break;
        }
        
        if(A <= c && c <= B) ans += i;
    }
    cout << ans << endl;
}

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

const int N_MAX = 3000;
typedef unsigned long long ull;
ull c[N_MAX+1][N_MAX+1];
ull s[N_MAX+1][N_MAX+1];

unsigned int power2(unsigned int n, unsigned int m) {
	ull r = 1;
	ull t = 2;
	while(n > 0) {
		if(n & 1) r = (r * t) % m;
		t = (t * t) % m;
		n >>= 1;
	}
	return (unsigned int)r;
}

int main() {
	unsigned int n, m;
	cin >> n >> m;
	for(int i=0;i<=n;i++) c[i][0] = c[i][i] = 1;
	for(int i=1;i<=n;i++) for(int j=1;j<i;j++) {
		c[i][j] = (c[i-1][j-1] + c[i-1][j]) % m;
	}
	for(int i=0;i<=n;i++) s[i][0] = 1;
	for(int i=1;i<=n;i++) s[0][i] = 0;
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) {
		s[i][j] = ((j+1) * s[i-1][j] + s[i-1][j-1]) % m;
	}
	ull ans = 0;
	for(int i=0;i<=n;i++) {
		ull tmp = 0;
		for(int j=0;j<=i;j++) tmp = (tmp + s[i][j] * power2((n-i)*j, m)) % m;
		tmp = (tmp * power2(power2(n-i, m-1), m)) % m;
		tmp = (tmp * c[n][i]) % m;
		if(i % 2 == 1) tmp = m - tmp;
		ans = (ans + tmp) % m;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 140928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<tuple<ll, ll, ll>>>;

// MOD確認

int main(){
   /*ll A,C;
   long double B;
   cin >> A >> B;
   C = B * (ll)100;
   cout << (ll)(A * C)/100 << endl;
   return 0;*/
   ll N,n;
   cin >> N;
   n = N;
   ll ans = 0;
   vector<pair<ll,ll>> A;
   for(ll i = 2;i * i <= N;i++){
      ll cnt = 0;
      while(n % i == 0){
         cnt++;
         n /= i;
      }
      if(cnt != 0) A.emplace_back(i,cnt);
   }
   if(n != 1) A.emplace_back(n,1);
   rep(i,A.size()){
      //cout << A[i].first << ' ' << A[i].second << endl;
      FOR(j,1,100){
         if(A[i].second >= j){
            ans++;
            A[i].second -= j;
         }else break;
      }
   }
   cout << ans << endl;
}


Measured memory_bytes: 3632
def solve():
    n = int(input())
    b = list(map(int,input().split()))
    a = list(map(int,input().split()))
    ans = 0
    for i in range(n):
        if a[i]<=b[i]:
            ans+=a[i]
            b[i]-=a[i]
        else:
            if a[i]>=b[i]+b[i+1]:
                ans+=b[i]+b[i+1]
                b[i+1]=0
            else:
                ans+=a[i]
                b[i+1] = b[i]+b[i+1]-a[i]
    print(ans)
if __name__ == "__main__":
    solve()

Measured memory_bytes: 18624
import java.util.Scanner;

public class Main {
	public static void main(String[] ar)
	{
		Scanner sc = new Scanner(System.in);
		sc.useDelimiter(",");

		String a, b, c;

		a = sc.next();
		b = sc.next();
		c = sc.next();

		System.out.println(a + " " + b  + " "  + c);
	}
}


Measured memory_bytes: 21716
use std::io::BufRead;

pub struct StdinReader<R: BufRead> {
    pub buf_reader: R,
    pub buf: String,
}

impl<R: BufRead> StdinReader<R> {
    pub fn new(r: R) -> Self {
        StdinReader {
            buf_reader: r,
            buf: String::with_capacity(10000),
        }
    }
}

#[macro_export]
macro_rules! input {
    ($reader : expr, $t : ty) => { // one variable
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().parse().unwrap();
                reader.buf.clear();
                tmp_var
            },
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty) => { // 2 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0].clone(), tmp_var[1].clone())
            }
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty, $t2 : ty) => { // 3 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0].clone(), tmp_var[1].clone(), tmp_var[2].clone())
            }
        }
    };
    ($reader : expr, $t : ty; $size : expr) => { // Vector
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                tmp_var
            }
        }
    };
}

fn main() {
    solve_b();
}

fn solve_b() {
    let handle = std::io::stdin();
    let mut r = StdinReader::new(handle.lock());
    let n: usize = input!(r, usize);
    let hotels: Vec<usize> = input!(r, Vec<usize>; n);
    let mut maax = hotels[0];
    let mut total = 0;
    for h in hotels {
        if maax <= h {
            total += 1;
            maax = h;
        }
    }
    println!("{}", total);
}


Measured memory_bytes: 4352
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()

def factorization(n):
    def factor_sub(n, m):
        c = 0
        while n % m == 0:
            c += 1
            n /= m
        return c, n
    #
    buff = []
    c, m = factor_sub(n, 2)
    if c > 0: buff.append((2, c))
    c, m = factor_sub(m, 3)
    if c > 0: buff.append((3, c))
    x = 5
    while m >= x * x:
        c, m = factor_sub(m, x)
        if c > 0: buff.append((x, c))
        if x % 6 == 5:
            x += 2
        else:
            x += 4
    if m > 1: buff.append((m, 1))
    return buff

def main():
    n = II()
    d = collections.defaultdict(int)
    for i in range(1,n+1):
        for k,v in factorization(i):
            d[k] += v
    r = 1
    for c in d.values():
        r *= c+1
        r %= mod
    return r


print(main())


Measured memory_bytes: 7964
#include <bits/stdc++.h>
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;


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


  int a, b;
  cin >> a >> b;

  pr(max({a + b, a - b, a * b}));

  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))



int main(){
	int n,q;
	cin >> n >> q;
	vector<int> A(n+1);
	FOR(i,1,n+1)A[i] = i;
	FOR(i,0,q){
		string s,x,y;
		cin >> s;
		bool k = false;
		for(char c:s){
			if(c==','){
				k = true;
				continue;
			}
			if(not k){
				x += c;
			}else{
				y += c;
			}
		}
		int a,b;
		a = stoi(x);
		b = stoi(y);
		swap(A[a],A[b]);
	}
	FOR(i,1,n+1){
		cout << A[i] << endl;
	}
}



Measured memory_bytes: 3024
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

#define deg_to_rad(deg) (((deg)/360)*2*M_PI)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	double a, b, C; cin >> a >> b >> C;
	double h = b * sin(deg_to_rad(C));
	double a2 = a - b * cos(deg_to_rad(C));
	double c = sqrt(pow(h, 2) + pow(a2, 2));
	cout << a * h / 2 << " " << a + b + c << " " << h << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}



Measured memory_bytes: 3448
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}
 
using namespace std;                                                                                  
using namespace __gnu_pbds; 
mt19937 mrand(random_device{}()); 
const ll mod = 1e9 + 7;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
 
typedef pair < int , int > pii ;                                            
typedef pair < long long  , long long > pll ;

typedef tree<
pii,
null_type,
less<pii>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int N = 2e5 + 123;

int n, m, l;

int a[N];
int A,B;
int sf[N];
main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	string s;
	cin >> s;
	int n = sz(s);
	if(n == 1)
		ret(n);
	for(int i = 1; i <= n; i++)
		a[i] = s[i - 1] == '1';
	for(int i = n;i > 0;i--)
		sf[i] = sf[i + 1] + a[i];	
/*		
	100010001
	011101110
	000010001
	000001110
	000000001
*/
	int ok = 0;
	int ans = n;
	/*
	011111111110
	000000001111
	000000010000
	000000001111
	000100000000
	000011111111


	*/

	for(int i = 1; i < n; i++){
		if(a[i] != a[i + 1])
			ans = min(ans, max(i , n - i));		
	}
	ret(ans);
}
 


Measured memory_bytes: 2128
import sys
from collections import deque


def main():
    N, M, *AB = map(int, sys.stdin.buffer.read().split())
    
    g = [[] for _ in range(N + 1)]

    for A, B in zip(*[iter(AB)] * 2):
        g[A].append(B)
        g[B].append(A)

        #print("->", g)

    queue = deque([1])
    d = [None] * (N + 1)
    d[0] = 0
    d[1] = 0

    while queue:
        v = queue.popleft()
        for i in g[v]:
            if d[i] is None:
                #d[i] = d[v] + 1
                d[i] = v
                queue.append(i)

    if None in d:
        print("No")
    else:
        print("Yes")
        print("\n".join(map(str, d[2:])))


if __name__ == '__main__':
	main()

exit()


Measured memory_bytes: 46380
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long
#define pii pair<int,int>
#define pb(x) push_back(x)
#define lbound lower_bound
#define ubound upper_bound
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcountll(x)
#define heap_min priority_queue<int,vector<int>,greater<int>>
#define heap_max priority_queue<int>
#define precision(x) cout << setprecision(x) << fixed;
#define printv(v) for(auto p : v) cout << p << " ";
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout << a[i]; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;



int32_t main()
{
   fast;
   #ifndef ONLINE_JUDGE
   freopen("goodluckin.txt","r",stdin);
   freopen("goodluckout.txt","w",stdout);
   #endif
   string s;
   cin >> s;
   int n = s.size();
   if(s[n-1]!='s'){
    s+='s';
   }
   else{
    s+="es";
   }
   cout << s;
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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


// Mod int
const int mod = 1000000007;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
typedef vector<mint> vm;
typedef vector<vm> vvm;
//

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin >> n >> m;
  VI s(n), t(m);
  rep(i,n) cin >> s[i];
  rep(j,m) cin >> t[j];

  mint dp[n+1][m+1];
  rep(i,n+1)rep(j,m+1) dp[i][j] = 0;
  dp[0][0] = 1;
  // sをi番目まで見てtをj番目まで見たときに、
  // t[j]番目の文字を部分文字列に必ず使ってできる部分文字列の場合の数
  rep(i,n){
    //s[i]
    mint sum = 0;
    rep(j,m){
      sum += dp[i][j];
      dp[i+1][j] += dp[i][j];
      if(s[i] == t[j]) dp[i+1][j+1] += sum;
    }
    dp[i+1][m] += dp[i][m];
  }
  mint ans = 0;
  rep(j,m+1) ans +=  dp[n][j];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 31616
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))

int M,q;

//辺の情報を個別に持つタイプ
typedef struct edge{ll s,g,c;}E;
typedef struct graph{
	int vcnt,ecnt;
	E  e[200010];//適宜変える(ecnt)
	int id[100010];//適宜変える(vcnt)
}G;
G g;

int esort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}
void readgraph(){
	//適宜変える
	int n,m;
	scanf("%d%d%d%d",&n,&m,&M,&q);
	rep(i,0,m){
		ll x,y,c;
		scanf("%lld%lld%lld",&x,&y,&c);
		g.e[i].s=y;
		g.e[i].g=x;
		g.e[i].c=c;
	}
	g.vcnt=n+1;
	g.ecnt=m;
	qsort(g.e,g.ecnt,sizeof(E),esort);

	int p=0;
	rep(i,0,g.vcnt){
		while(p<g.ecnt&&g.e[p].s<i)p++;
		g.id[i]=p;
	}
	g.id[g.vcnt]=g.ecnt;//番兵
}


//プラキュー（二分ヒープ）（優先度変更ありバージョン）
ll heapN,heap[1<<20],heapinv[1<<20];
int PQhikaku(int i,int j);//jの方が優先度が高いならtrueを返す
void PQchange(int n);
void heap_utod(int n){
	if(2*n>heapN)return;
	int rflag=(2*n+1<=heapN)&&(PQhikaku(2*n,2*n+1));
	if(PQhikaku(n,2*n+rflag)){
		ll temp=heap[2*n+rflag];
		heap[2*n+rflag]=heap[n];
		heap[n]=temp;
		heapinv[heap[n]]=n;
		heapinv[heap[2*n+rflag]]=2*n+rflag;	
		heap_utod(2*n+rflag);
	}
}
void heap_dtou(int n){
	if(n==1||PQhikaku(n,n/2))return;
	ll temp=heap[n];
	heap[n]=heap[n/2];
	heap[n/2]=temp;
	heapinv[heap[n]]=n;
	heapinv[heap[n/2]]=n/2;
	heap_dtou(n/2);
}
ll PQpop(){
	ll rr=heap[1];
	heapinv[heap[1]]=0;
	heap[1]=heap[heapN--];
	heapinv[heap[1]]=1;
	heap_utod(1);
	return rr;
}
void PQpush(ll n){
	heap[++heapN]=n;
	heapinv[heap[heapN]]=heapN;
	heap_dtou(heapN);
}
//早い方のダイクストラ
//グラフと始点を引いて各点への最短距離・最短経路を返す
//プラキューが必要
//O((E+V)logV)
ll daikusutorappp[100010];
void daikusutora2(int r){
	rep(i,0,g.vcnt)daikusutorappp[i]=i%M==r?0:INF;
	rep(i,0,g.vcnt)PQpush(i);
	while(heapN){
		ll mv=PQpop();
		for(ll t=g.id[mv];t<g.ecnt&&g.e[t].s==mv;t++){
			if(daikusutorappp[g.e[t].g]>daikusutorappp[mv]+g.e[t].c){
				daikusutorappp[g.e[t].g]=daikusutorappp[mv]+g.e[t].c;
				PQchange(g.e[t].g);
			}
		}
	}
}
int PQhikaku(int i,int j){return daikusutorappp[heap[i]]>daikusutorappp[heap[j]];}
void PQchange(int n){if(heapinv[n])heap_dtou(heapinv[n]);}

ll dd[10][100010];
int main(){
	readgraph();
	rep(i,0,M){
		daikusutora2(i);
		rep(j,0,g.vcnt)dd[i][j]=daikusutorappp[j];
	}
	long long ans=0;
	while(q--){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		ll temp=0;
		rep(i,0,M){
			ll xx=dd[i][x];
			ll yy=dd[i][y];
			temp=max(temp,z-xx-yy);
		}
		ans+=temp;
	}
	printf("%lld\n",ans);
}


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

constexpr int MAX_SIZE = 201;
bool black[MAX_SIZE + 2][MAX_SIZE + 2];

constexpr array<int, 4> dx{1, -1, 0, 0};
constexpr array<int, 4> dy{0, 0, 1, -1};

typedef array<int, 5> counter;
map<counter, char> converter{
    {{{7, 5, 5, 5, 7}}, '0'},
    {{{1, 1, 1, 1, 1}}, '1'},
    {{{7, 4, 7, 1, 7}}, '2'},
    {{{7, 4, 7, 4, 7}}, '3'},
    {{{5, 5, 7, 4, 4}}, '4'},
    {{{7, 1, 7, 4, 7}}, '5'},
    {{{7, 1, 7, 5, 7}}, '6'},
    {{{7, 4, 4, 4, 4}}, '7'},
    {{{7, 5, 7, 5, 7}}, '8'},
    {{{7, 5, 7, 4, 7}}, '9'},
    {{{7, 2, 0, 0, 0}}, '+'},
    {{{7, 0, 0, 0, 0}}, '-'},
    {{{1, 0, 0, 0, 0}}, '*'}};

void dfs(int x, int y, int bx, int by, counter &cnt) {
    if(by <= y) cnt[y - by] += (1 << (x - bx));
    black[y][x] = false;

    for(int d = 0; d < dx.size(); ++d) {
        const int nx = x + dx[d];
        const int ny = y + dy[d];
        if(black[ny][nx]) dfs(nx, ny, bx, by, cnt);
    }
}

string lex() {
    string res = "";
    for(int x = 1; x <= MAX_SIZE; ++x) {
        for(int y = 1; y <= MAX_SIZE; ++y) {
            if(black[y][x]) {
                counter cnt;
                cnt.fill(0);
                dfs(x, y, x, y, cnt);
                res += converter.at(cnt);
            }
        }
    }
    return res;
}

int parse(const string &s, int l, int r) {
    for(int i = r - 1; i >= l; --i) {
        if(s[i] == '+') return parse(s, l, i) + parse(s, i + 1, r);
        if(s[i] == '-') return parse(s, l, i) - parse(s, i + 1, r);
    }
    for(int i = r - 1; i >= l; --i) {
        if(s[i] == '*') return parse(s, l, i) * parse(s, i + 1, r);
    }
    return stoi(s.substr(l, r - l));
}

int main() {
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        ++x1; ++y1; ++x2; ++y2;

        if(x1 > x2) {
			swap(x1, x2);
		}
        else if(y1 > y2) {
			swap(y1, y2);
		}

        for(int x = x1; x <= x2; ++x) {
            for(int y = y1; y <= y2; ++y) {
                black[y][x] = true;
            }
        }
    }

    const string expression = lex();
    cout << parse(expression, 0, expression.size()) << endl;

    return EXIT_SUCCESS;
}


Measured memory_bytes: 1232
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        int q = int.Parse(Console.ReadLine());
        for (int ctr = 0; ctr < q; ctr++)
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();
            //dp[i] := s[i]まで使った
            int[] dp = new int[s.Length];
            foreach (var c in t)
            {
                var curMax = 0;
                for (int i = 0; i < s.Length; i++)
                {
                    var cur = dp[i];
                    if (c == s[i]) dp[i] = curMax + 1;
                    curMax = Max(curMax, cur);
                }
            }
            Console.WriteLine(dp.Max());
        }
    }
}



Measured memory_bytes: 18260
//standard answer
#include<iostream>
#include<string>
using namespace std;

int main(){
  string str, com, p;
  int q, a, b;
  
  cin >> str >> q;
  for ( int t = 0; t < q; t++ ){
    cin >> com >> a >> b;
    if ( com == "print" ){
      cout << str.substr(a, b-a+1) << endl; //[a]~(b-a+1)個返す
    } else if ( com == "reverse" ){
      string tmp = str.substr(a, b-a+1);
      int n = tmp.size();
      for ( int i = 0; i < n; i++ ) str[i+a] = tmp[n-i-1];
    } else if ( com == "replace" ){
      cin >> p; //replaceはもう1文字列ある
      str = str.replace(a, b-a+1, p);
    }
  }
  
  return 0;
}


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

int main(){
	int n, alice = 0, bob = 0;
	vector<int> a(100);
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a.at(i);
	}
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	for(int i = 0; i < n; i++){
		if(i%2 == 0) alice+=a.at(i);
		else bob+=a.at(i);
	}
	cout << alice - bob << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

ll const INF = 1000000000000000000;
int const I_MAX = 2147483647;
ll const MOD = 1e9 + 7;
int const POW_MAX = 1e5;

// nCr
ll po[POW_MAX + 2];
ll mod_pow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}
ll mod_inv (ll x) {
  return mod_pow(x, MOD - 2) % MOD;
}
ll comb(int n, int r) {
  return (((po[n] * mod_inv(po[r])) % MOD) * mod_inv(po[n - r])) % MOD;
}
// greatest common divisor
ll gcd(ll a, ll b) {
  while (a % b != 0) {
    ll tmp = a;
    a = b;
    b = tmp % b;
  }
  return b;
}

int const N_MAX = 1e5;

int N, Q;
string S;
int cnts[N_MAX + 1];
int ls[N_MAX + 1], rs[N_MAX + 1];

int main() {
  scanf("%d %d", &N, &Q);
  cin >> S;
  rep(i, Q) scanf("%d %d", &ls[i], &rs[i]);

  bool bef_A = false;
  int cnt = 0;
  rep(i, N) {
    char c = S[i];
    if (c == 'A') {
      bef_A = true;
    } else if (c == 'C' && bef_A) {
      cnt++;
      bef_A = false;
    } else {
      bef_A = false;
    }
    cnts[i] = cnt;
  }
  rep(i, Q) {
    int l = ls[i] - 1;
    int r = rs[i] - 1;
    int l_sum;
    if (l == 0) {
      l_sum = 0;
    } else if (cnts[l - 1] == cnts[l]) {
      l_sum = cnts[l];
    } else {
      l_sum = cnts[l];
    }
    int r_sum = cnts[r];
    printf("%d\n", r_sum - l_sum);
  }
}


Measured memory_bytes: 2176
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#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>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll x,n;
    cin>>x>>n;
    vl v;
    int mark[205]={0};
    rep(i,n)
    {
        ll c;
        cin>>c;
        v.pb(c);
        mark[c]=1;
    }
    ll mini=200;
    ll ans=1;
    for(int i=0;i<=200;i++)
    {
        if(mark[i])
            continue;
        ll diff=abs(i-x);
        if(diff<mini)
        {
            ans=i;
            mini=diff;
        }
    }
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 15564
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    long long a, b;
    int n;
    cin >> a >> b >> n;

    long long ans = LLONG_MAX;
    for(int x=1; x<=n; ++x){
        for(int y=1; y<=n; ++y){
            if(b % y != 0)
                continue;
            long long a2 = b / y * x;
            ans = min(ans, abs(a - a2));
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3120
IDENTIFICATION DIVISION.
PROGRAM-ID. 144B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 N     PIC 9(3).
01 I     PIC 9(2).
01 F9    PIC X(3).
01 S     PIC 9(3).
01 A     PIC 9(1).
*>
PROCEDURE DIVISION.
  ACCEPT N.
*>
  MOVE 'No' TO F9.
  PERFORM VARYING I FROM 1 BY 1 
    UNTIL I > 9 OR F9 = 'Yes' 
    DIVIDE N BY I GIVING S REMAINDER A
    IF (A = 0) AND (S <= 9)
      MOVE 'Yes' TO F9
    END-IF
  END-PERFORM.
*>
  DISPLAY F9.
  STOP RUN.


Measured memory_bytes: 764
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	n := nextInt()
	a := nextInt()
	b := nextInt()
	m := n / (a + b)
	sum := m*a + min(a, n%(a+b))
	fmt.Println(sum)
}

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

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<algorithm>
#include<bitset>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
#define MAX (1<<16)

using namespace std;

int dp[32][MAX],n,c,beat[32],touch[32];

void compute()
{
  rep(i,32)rep(j,MAX)dp[i][j] = -inf;
  dp[0][0] = 0;
  int ans = 0;

  rep(phase,n)//フェーズ
    {
      rep(state,MAX)//beatがなる前の状態
	{
	  if(dp[phase][state] == -inf)continue;
	  ans = max(ans,dp[phase][state]);
	  rep(type,c)//タッチするタイプ
	    {
	      int nstate = (state | beat[phase]);
	      int erase = nstate & touch[type];
	      int cost = __builtin_popcount(erase);
	      erase = ((1<<16)-1) ^ erase;
	      nstate = nstate & erase;
	      dp[phase+1][nstate] = max(dp[phase+1][nstate],
					dp[phase][state] + cost);
	      ans = max(dp[phase+1][nstate],ans);
	    }
	}
    }

  cout << ans << endl;
}

int main()
{
  while(cin >> n >> c,n|c)
    {
      rep(i,n)
	{
	  int a = 0;
	  rep(j,16)
	    {
	      int b;
	      cin >> b;
	      if(b)a |= (1<<j); 
	    }
	  beat[i] = a;
	}

      rep(i,c)
	{
	  int b = 0;
	  rep(j,16)
	    {
	      int a;
	      cin >> a;
	      if(a)b |= (1<<j);
	    }
	  touch[i] = b; 
	}

      compute();

    }
  return 0;
}

Measured memory_bytes: 9356