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

int main(){
    string a;
    cin >> a;
    if (a[0] == a[1] && a[1] == a[2]){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
// ABC136.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	int ans = max(0,C - (A - B));

	cout << ans << endl;
}

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

using namespace std;

int main() {
  string S;
  cin >> S;

  for (int a = 0; a + 1 < S.length(); a++) {
    if (S[a] == S[a + 1]) {
      printf("%d %d\n", a + 1, a + 2);
      return 0;
    }
  }

  for (int a = 0; a + 2 < S.length(); a++) {
    if (S[a] == S[a + 2]) {
      printf("%d %d\n", a + 1, a + 3);
      return 0;
    }
  }

  printf("-1 -1\n");

  return 0;
}


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

using namespace std;
using ll = long long;

int main() {
#ifdef LOCAL
    freopen("in1.txt", "r", stdin);
    freopen("out1.txt", "w", stdout);
#endif


    int n;
    cin>>n;
    if(n>=30)puts("Yes");else puts("No");
    return 0;
}

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

#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 ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    ll N,M; cin >> N >> M;
    if(2*N > M) cout << M/2 << endl;
    else if(2*N<=M) cout << N + (M-2*N)/4 << endl;

    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAXN = 505*505;
struct Node{
    int pos,num;
    bool operator < (const Node &b)const
    {
        return pos<b.pos;
    }
}a[505];
int t[MAXN],n;
inline void fail()
{
    puts("No");
    exit(0);
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%d",&a[i].pos),a[i].num=i;
    sort(a+1,a+n+1);
    int p=1;
    for(int i=1;i<=n;++i){
        if(a[i].pos==a[i-1].pos)fail();
        int tmp=a[i].num-1;
        while(tmp--){while(t[p])++p;if(p>=a[i].pos)fail();t[p++]=a[i].num;}
        t[a[i].pos]=a[i].num;
    }
    p=n*n;
    for(int i=n;i>0;--i){
        int tmp=n-a[i].num;
        while(tmp--){while(t[p])--p;if(p<=a[i].pos)fail();t[p--]=a[i].num;}
    }
    puts("Yes");
    for(int i=1;i<=n*n;++i)printf("%d ",t[i]);
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  int N, X, Y; cin >> N >> X >> Y;
  unordered_set<int> ST;
  RNG(K, 1, N) {
    int cnt = 0;
    RNG(i, 1, N+1) {
      int distX = abs(X-i),
          distY = abs(Y-i),
          rgt = i + K,
          lft2 = Y-(K-distX-1),
          rgt2 = Y+(K-distX-1),
          lft3 = X-(K-distY-1),
          rgt3 = X+(K-distY-1);

      if (rgt <= N && distX+abs(rgt-Y)+1 >= K && distY+abs(rgt-X)+1 >= K) ST.insert(rgt);
      if (rgt2 > i && rgt2 > 0 && rgt2 <= N && abs(rgt2-i) >= K && K > distX) ST.insert(rgt2);
      if (lft2 > i && lft2 > 0 && lft2 <= N && abs(lft2-i) >= K && K > distX) ST.insert(lft2);
      if (rgt3 > i && rgt3 > 0 && rgt3 <= N && abs(rgt3-i) >= K && K > distY) ST.insert(rgt3);
      if (lft3 > i && lft3 > 0 && lft3 <= N && abs(lft3-i) >= K && K > distY) ST.insert(lft3);
      // for (const auto& v: ST) cout << "i: " << i << " v: " << v << endl;
      cnt += ST.size();
      ST.clear();
    }
    cout << cnt << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import math

def is_prime(n):
    if n <= 1:
        return False
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    for i in range(3, math.ceil(math.sqrt(n))+1, 2):
        if n % i == 0:
            return False
    return True


# 素数を表にする
primetable = [ 0 for i in range(100001) ]
for i in range(2, 100001):
    if is_prime(i):
        primetable[i] = 1

# 2017に似た数を表にする
like2017table = [ 0 for i in range(100001) ]
for i in range(2, 100001):
    if primetable[i] == 1 and \
        primetable[(i+1)//2] == 1:
        like2017table[i] = 1

# 累積和を計算する
cumsum = [ 0 for i in range(100001) ]
currentSum = 0
for i in range(2, 100001):
    currentSum += like2017table[i]
    cumsum[i] = currentSum

n = int(input())
queries = []
for _ in range(n):
    queries.append(list(map(int, input().split())))

for query in queries:
    begin = query[0]
    end = query[1]
    ans = cumsum[end] - cumsum[begin-1]
    print(ans)


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

int main(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll maxn=max(a*d,a*c);
	maxn=max(maxn, max(b*c,b*d));
	cout<<maxn;
	return 0;
} 

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

string s, t;
int S;
int T;

bool match(int k) {
    rep(i, T) {
        if(t[i] != s[i + k] && s[i + k] != '?') {
            return false;
        }
    }
    return true;
}

string construct (int k) {
    string ans = s;
    rep(i, T) {
        ans[k + i] = t[i];
    }
    rep(i, S) {
        if(ans[i] == '?') ans[i] = 'a';
    }
    return ans;
}

int main()
{
    cin >> s >> t;
    S = s.size();
    T = t.size();
    vector<string> ans;
    rep(k, S - T + 1) {
        if(match(k)) {
            ans.push_back(construct(k));
        }
    }
    sort(ans.begin(), ans.end());
    if(ans.size() == 0) {
        cout << "UNRESTORABLE" << endl;
    }
    else cout << ans[0] << endl;
    return 0;
}


Measured memory_bytes: 3596
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        char[] s = scanner.next().toCharArray();
        //feels like you need a stack
        int p1 = 0, p2 = 0;
        while(k > 0 && p2 < n) {
            while(p2 < n && s[p2] == s[p1]) p2++;
            while(p2< n && s[p2] != s[p1]) {
                if (s[p2] == 'R') s[p2] = 'L';
                else s[p2] = 'R';
                p2++;
            }
            p1 = p2;
            k--;
        }
        int ans = 0;
        for(int i = 0; i < n; i++) {
            if (s[i] == 'L' && i > 0 && s[i-1] == 'L') ans++;
            else if (s[i] == 'R' && i < n-1 && s[i+1] == 'R') ans++;
        }
        out.println(ans);
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 24532
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
typedef long long ll;
typedef unsigned un;
typedef std::string str;
typedef std::pair<ll,ll> pll;
ll read(){ll x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}return f*x;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
void umax(ll& a,ll t){if(t>a)a=t;}
void umin(ll& a,ll t){if(t<a)a=t;}
const ll INF=1ll<<58;
#define MAXN 200011
ll s[MAXN],cnt[MAXN],ans[MAXN];
int main()
{
	ll n=read(),query=read(),top=0;
	s[++top]=n;
	while(query--)
	{
		ll x=read();
		while(top&&s[top]>=x)--top;
		s[++top]=x;
	}
	cnt[top]=1;
	for(ll i=top;i>1;--i)
	{
		ll len=s[i]%s[i-1];
		while(len>s[1])
		{
			ll pos=std::upper_bound(s+1,s+top+1,len)-s-1;
			cnt[pos]+=cnt[i]*(len/s[pos]);
			len%=s[pos];
		}
		ans[len]+=cnt[i];
		cnt[i-1]+=cnt[i]*(s[i]/s[i-1]);
	}
	ans[s[1]]+=cnt[1];
	for(ll i=n-1;i;--i)ans[i]+=ans[i+1];
	for(ll i=1;i<=n;++i)printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 5560
#include <stdio.h>

/*---------------
 ???????????????????´????0~9999?????\??????
 a[0]??´???0
-----------------*/

#define N 18

// 0?????\?????????????????¨??????????????§?????????????????????
void print(int n[]){
	char unit[N][4] = {"",
		"Man", "Oku", "Cho", "Kei", "Gai", "Jo", "Jou", "Ko",
		"Kan", "Sei", "Sai", "Gok", "Ggs", "Asg", "Nyt", "Fks", "Mts"};
	for (int i=N-1; i>=0; i--){
		if (n[i]==0) continue;
		printf("%d%s",n[i],unit[i]);
	}
}

int main(void){
	int a[N]={0}, b[N]={0};
	int m, n;
	
	// ?´?????????¨????????????O(m)?§£???
	while (scanf("%d%d", &m, &n), m){
		for (int i=0; i<N; i++) a[i]=b[i]=0;
		a[0]=m;
		for (int i=0; i<n-1; i++){
			for (int j=0; j<N; j++){
				b[j] = a[j]*m;
			}
			for (int j=0; j<N; j++){
				int cry;
				cry = b[j]/10000;
				if (j<N-1) b[j+1] += cry;
				a[j] = b[j] % 10000;
			}
		}
		print(a);
		puts("");
	}
	
	return 0;
}

Measured memory_bytes: 1040
N,M = map(int,input().split())
L = [list(map(int,input().split())) for i in range(N)]

L = sorted(L,key=lambda x: x[0])

ans = 0

for i in range(len(L)) :
    if L[i][1] < M :
        M -= L[i][1]
        ans += L[i][0]*L[i][1]
    else :
        ans += L[i][0]*M
        break
print(ans)


Measured memory_bytes: 29792
MOD=998244353
N,S=map(int,input().split())
A=list(map(int,input().split()))

dp=[[0]*(S+10) for i in range(N+1)]
for i in range(N):
    for j in range(S+1):
        dp[i+1][j]=dp[i][j]
        dp[i+1][j]+=dp[i][j-A[i]] if j>=A[i] else 0
        dp[i+1][j]+=1 if (j==A[i] or j==0) else 0
        dp[i+1][j]%=MOD
ans=0
for i in range(1,N+1):
    ans=(ans+dp[i][S])%MOD
print(ans)

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

int main(){
  int n;
  cin>>n;
  char c;
  int x;
  cin>>c>>x;
  bool flag =true;
  if(c ==')'||n == 1){
    cout <<"NO"<<endl;
    return 0;
  }

  stack<int> st;
  st.push(x);
  for(int i = 1;i < n;i++){
    cin>>c>>x;
    int y = st.top();
    st.pop();
    if(c == '('){
      st.push(x + y);
    }else{
      int z = y - x;
      if(z < 0){
        flag =false;
        break;
      }else{
        st.push(z);
      }
    }
  }
  if(flag && st.top() >= 1){
    flag =false;
  }
  if(flag)cout <<"YES"<<endl;
  else cout <<"NO"<<endl;
  return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int dp[5005][5005];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  if(a+b <= 2*c) {
    int ans = (a+b)*min(x, y);
    if(x > y) ans += (x-y)*min(2*c, a);
    else ans += (y-x)*min(2*c, b);
    cout << ans << endl;
  } else {
    int ans = 2*c*min(x, y);
    if(x > y) ans += (x-y)*min(2*c, a);
    else ans += (y-x)*min(2*c, b);
    cout << ans << endl;
  }

  return 0;
}


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

answer=0

for n in range(1,N+1,2):
    count=0
    for i in range(1,int(pow(n,1/2))+1):
        if n%i==0:
            if n//i!=i:
                count+=2
            else:
                count+=1
    if count==8:
        answer+=1

print(answer)

Measured memory_bytes: 3188
#include <stdio.h>
#define LEN 10000

int main(void){
    int n;
    int a[LEN];
    int k;
    int c = 0;

    scanf("%d", &n);
    for(k = 0; k < n; k++){
        scanf("%d", &a[k]);
    }

    for(k = 1; k < n-1; k++){
        if(a[k-1] == a[k]){
            c++;
            if(a[k] == a[k+1]){
                if(a[k] != 1){
                    a[k]--;
                }else{
                    a[k]++;
                }
            }else{
                if(a[k+1] != 1){
                    a[k] = a[k+1] - 1;
                }else{
                    a[k] = 2;
                }
            }

        }
    }
    if(a[n-1] == a[n-2]){
        c++;
        if(a[n-1] != 1){
            a[n-1]--;
        }else{
            a[n-1]++;
        }
    }

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

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>

#define MAX 100005
#define NIL -1

struct Node {
  int p,l,r;
};

struct Node T[MAX];
int n,D[MAX];

void print(int u){
  int i,c;
  
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if(T[u].p==NIL)printf("root, ");
  else if(T[u].l==NIL) printf("leaf, ");
  else  printf("internal node, ");

  printf("[");

  for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
    if(i) printf(", ");
    printf("%d",c);
  }
 printf("]\n");
}

void rec(int u, int p){
  D[u]=p;
  if(T[u].r!=NIL)rec(T[u].r,p);
  if(T[u].l!=NIL)rec(T[u].l,p+1);
}


int main(){
  int i,j,d,v,c,l,r,n;

  scanf("%d",&n);
  
  for(i=0;i<n;i++)
    T[i].p=T[i].l=T[i].r=NIL;

  for(i=0;i<n;i++){
     scanf("%d",&v);
     scanf("%d",&d);
     for(j=0;j<d;j++){
       scanf("%d",&c);
       if(j==0) T[v].l=c;
       else T[l].r=c;
       l=c;
       T[c].p=v;
     }
  }
  
  for(i=0;i<n;i++)
    if(T[i].p==NIL)r=i;
  
  rec(r,0);
  
  for(i=0;i<n;i++) print(i);

  return 0;
}



Measured memory_bytes: 6420
#include <iostream>
#include <algorithm>
#include <set>

using namespace std;



int main() {
  int N,Y;
  int x = -1,y = -1,z = -1;  
  cin >> N >> Y;
  for(int i=0;i<=N;i++) {
    for(int j=0;j<=N;j++) {
      if(i+j>N){ continue; }
      int k = N - i - j;
      if(i*10000+j*5000+k*1000==Y) { x=i;y=j;z=k; goto end; }
    }
  }
  
end:
  
  cout << x << " " << y << " "  << z << endl;
}

Measured memory_bytes: 256
n = int(raw_input())
T,A = map(int, raw_input().split())

H = map(int, raw_input().split())

Htemp = []
for i in H:
	subs = abs(A - (T-i*0.006))
	Htemp.append(subs) 

print Htemp.index(min(Htemp))+1

Measured memory_bytes: 2692
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>

using namespace std;

int main(void){
	
	int a, b;

	cin >> a >> b;

	if (a > b)
		cout << "a > b" << endl;
	else if (a < b)
		cout << "a < b" << endl;
	else
		cout << "a == b" << endl;

	return 0;
}

Measured memory_bytes: 3076
#include <vector>
#include <functional>
#include <deque>
#include <stdexcept>

template<typename T, typename Container = ::std::vector<T>, typename Compare = ::std::greater<typename Container::value_type>>
class sliding_window {
    using iterator_type = typename Container::const_iterator;
    using value_compare = Compare;
    using value_type = T;
    using const_reference = const value_type &;

    iterator_type right_bound, left_bound, end;
    value_compare comp;
    size_t length;
    ::std::deque<value_type> val;

public:
    void push() {
        if (left_bound == end) {
            throw ::std::runtime_error("already reached to the end");
        }
        const auto &tmp = *left_bound;
        while (!val.empty() && comp(val.back(), tmp))val.pop_back();
        val.push_back(tmp);
        ++left_bound;
        ++length;
    }

    void pop() {
        if (right_bound == left_bound) {
            throw ::std::runtime_error("interval is empty");
        }
        const auto &tmp = *right_bound;
        if (tmp == val.front())val.pop_front();
        ++right_bound;
        --length;
    }

    sliding_window(iterator_type _begin, iterator_type _end, const Compare &_comp = Compare()) : length(0),
                                                                                                 right_bound(_begin),
                                                                                                 left_bound(_begin),
                                                                                                 end(_end), comp(_comp),
                                                                                                 val({}) {}

    const size_t size() const {
        return length;
    }

    const_reference top() const {
        return val.front();
    }

    void resize(size_t n) {
        if (n < length) {
            while (n < length) {
                pop();
            }
        } else {
            while (n > length) {
                push();
            }
        }
    }

    void forward() {
        if (left_bound != end)push();
        pop();
    }

};

#include <iostream>
#include <algorithm>

int main() {
    unsigned long long N, M, K;
    std::cin >> N >> M >> K;

    std::vector<unsigned long long> A(N), dp1(N), dp2(N);
    for (auto &i : A)std::cin >> i;

    std::copy(A.begin(), A.end(), dp1.begin());

    for (unsigned long long i = 1; i < K; ++i) {
        sliding_window<unsigned long long, std::vector<unsigned long long>, std::less<>> slidingWindow(
                dp1.begin(), dp1.end());
        std::transform(A.begin(), A.end(), dp2.begin(), [&i](auto a) { return a * (i + 1); });

        for (unsigned long long j = 0; j < N; ++j) {
            if (j >= i)dp2[j] += slidingWindow.top();
            slidingWindow.push();
            if (slidingWindow.size() > M)slidingWindow.pop();
        }

        std::swap(dp1, dp2);
    }

    std::cout << *std::max_element(dp1.begin(), dp1.end()) << std::endl;

    return 0;
}

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

int main() {
    int N; cin >> N;
    int fiveteen , five;
    if(N >= 500){
        for(int i = 0; 1 ; i++){
            if(N < 500*i){
                fiveteen =(i-1)*1000;
                N = N - (i-1)*500;
                break;
            }
        }
    }
    for(int i = 0;1 ; i++){
        if ( N < 5*i){
            five = (i - 1)*5;
            break;
        }
    }
    cout << five + fiveteen << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	long long int n;
	scanf("%lld", &n);
	if (n % 2 > 0)
		printf("0\n");
	else
	{
		long long int ans = 0, c = 5;
		n /= 2;
		while (n >= c)
		{
			ans += n / c;
			c *= 5;
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1724
function Main(input) {
  line = input.split(" ");
  X = parseInt(line[0], 10);
  A = parseInt(line[1], 10);
  
  if(X < A)	
    console.log(0);
  else
	console.log(10);
  
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 7372
a, b, c, k = list(map(int, input().split()))

suml = 0
while k > 0:
    if a > 0:
        tmpm = min(a, k)
        a -= tmpm
        k -= tmpm
        suml += tmpm
    elif b > 0:
        tmpm = min(b, k)
        b -= tmpm
        k -= tmpm
    else:
        tmpm = min(c, k)
        c -= tmpm
        k -= tmpm
        suml -= tmpm


print(suml)

Measured memory_bytes: 9196
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<cmath>
#include<typeinfo>

using namespace std;
#define rep(i,m,n) for(int i=m;i<n;++i)
#define llrep(i,m,n) for(ll i=m;i<n;++i)
#define inf 1000000000
#define llinf 1000000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

vector<int>v0, v1;

int main() {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	if (s[0] == '0') {
		v1.push_back(0);
	}
	int hoge = 1;
	rep(i, 1, n) {
		if (s[i] != s[i - 1]) {
			if (s[i - 1] == '0') {
				v0.push_back(hoge);
			}
			else {
				v1.push_back(hoge);
			}
			hoge = 1;
		}
		else {
			hoge++;
		}
	}
	if (s[n - 1] == '0') {
		v1.push_back(0);
		v0.push_back(hoge);
	}
	else {
		v1.push_back(hoge);
	}
	if (v0.size() < k) {
		cout << n << endl;
		return 0;
	}
	rep(i, 1, v0.size()) {
		v0[i] += v0[i - 1];
	}
	rep(i, 1, v1.size()) {
		v1[i] += v1[i - 1];
	}
	int ans = 0;
	v0.insert(v0.begin(), 0);
	v1.insert(v1.begin(), 0);
	rep(i, 0, v0.size() - k) {
		ans = max(ans, v1[k + i + 1] - v1[i] + v0[k + i] - v0[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())

#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], tt;

void dfs_visit(int u) {
    int v;
    color[u] = GRAY;
    d[u] = ++tt;
    for (v = 0; v < n; v++) {
        if (M[u][v] == 0) {
            continue;
        }
        if (color[v] == WHITE) {
            dfs_visit(v);
        }
    }
    color[u] = BLACK;
    f[u] = ++tt;
}

void dfs() {
    int u;
    for (u = 0; u < n; u++) {
        color[u] = WHITE;
    }
    tt = 0;
    for (u = 0; u < n; u++) {
        if (color[u] == WHITE) {
            dfs_visit(u);
        }
    }
    for (u = 0; u < n; u++) {
        printf("%d %d %d\n", u + 1, d[u], f[u]);
    }
}

int main() {
    int u, v, k, i, j;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            M[i][j] = 0;
        }
    }
    for (i = 0; i < n; i++) {
        scanf("%d %d", &u, &k);
        u--;
        for (j = 0; j < k; j++) {
            scanf("%d", &v);
            v--;
            M[u][v] = 1;
        }
    }
    dfs();
    return 0;
}


Measured memory_bytes: 3224
#include <iostream>

using namespace std;

int main()
{
   int W,H,x,y,r;
   cin>>W>>H>>x>>y>>r;
    if((x+r)>W || (x-r)<0 || (y+r)>H || (y-r)<0 || x<0 || y<0) cout<<"No";
    else cout<<"Yes";
   cout<<"\n";
    return 0;
}



Measured memory_bytes: 3096
#include<iostream>
#include<queue>
#include<map>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < (n) ; ++i )
bool same(string s){
  rep(i,s.size()-1) if(s[i] != s[i+1]) return false;
  return true;
}
char change(char a,char b){
  if(a != 'b' && b != 'b') return 'b';
  if(a != 'g' && b != 'g') return 'g';
  return 'r';
}
int bfs(string s){
  queue<string>que;
  que.push(s);
  map<string,int> used;
  used[s] = 0;
  while(!que.empty()){
    string s = que.front(); que.pop();
    if(same(s)) return used[s];
    rep(i,s.size()-1){
      if(s[i] != s[i+1]){
        string next = s;
        next[i] = next[i+1] = change(next[i],next[i+1]);
        if(!used[next]) que.push(next) , used[next] = used[s] + 1;
      }
    }
  }
  return -1;
}
int main(){
  string s;
  while(cin >> s , s != "0"){
    int ans = bfs(s);
    if(ans == -1) cout << "NA" << endl;
    else cout << ans << endl;
  }
}

Measured memory_bytes: 2888
#include<bits/stdc++.h>
#define ll long long
#define mo 1000000007
using namespace std;
int n,k;
int main(){
	scanf("%d%d",&n,&k);
	ll ans=0;
	for (int i=1;i<=n;i++){
		int times=n/i;
		ans+=n;
		ans-=times*min(i,k);
		ans-=min(k,n%i+1);
		ans+=(k!=0);
	}
	printf("%lld\n",ans);
}

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

int main(){
    int n;
    cin >> n;
    int x=0;
    if(0>=n && n>100){
        cout << "No" << endl;
    }

    else if(1<=n && n<=10){
        cout << "Yes" << endl;
    }
    else{
        for(int i=2; i<=9; i++){
            for(int j=2; j<=9; j++){
                if(n==i*j){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
        cout << "No" << endl;
        
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001;
typedef pair<int,int> P;
#define foreach(ix,a) for(auto& (ix) : (a)) 
int main(){
  //ios::sync_with_stdio(false);
  //cin.tie(nullptr);
  int h,w;

  cin>> h>> w;
  //cin>> sy>> sx;
  //cin>> gy>> gx;
  
  vector<string>ma;

  rep(i,h){
    string s;cin>>s;
    ma.push_back(s);
  }
  
  int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
  int ans =0;
  
  rep(sx,h)rep(sy,w){
    if(ma[sx][sy] == '#')continue;
    queue <P> que;
    vector<vector<int>> d(h,vector<int>(w,INF));
    auto update=[&](int i,int j,int x){
      if(d[i][j]!=INF)return;
      d[i][j]=x;
      que.push(P(i,j));
    };
    update(sx,sy,0);
    while(!que.empty()){
      int i = que.front().first;
      int j=que.front().second; que.pop();
      rep(a,4){
        int nx = i + dx[a],ny = j +dy[a];
        if(0>nx||0>ny||nx>=h||ny>=w)continue;
        if(ma[nx][ny]=='#')continue;
        update(nx,ny,d[i][j]+1);
      }
    }
  rep(i,h)rep(j,w){
    if(d[i][j]==INF)continue;
    ans = max(ans,d[i][j]);}
}
cout<<ans<<endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
const long long INF = numeric_limits<long long>::max();
int main() {
    ll X, Y;
    cin >> X >> Y;
    ll count = 1;
    ll value = X * 2;
    while (value <= Y) {
        count++;
        value *= 2;
    }
    cout << count << "\n";

    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  string s;
  cin >> s;

  int p = 0;
  for(int i = 0;i < s.size();i++) {
    if(s.at(i) == 'p') p++;
  }

 int n = s.size();
 if(n % 2 != 0) n--;
 cout << n / 2  - p<< endl;
}


Measured memory_bytes: 512
# AtCoder Beginner Contest 133
# C - Remainder Minimization 2019
L,R=map(int,input().split())

mod=2019
ans=20000

for i in range (L,min(R,L+mod)):
    for j in range (L+1,min(R+1,L+mod+1)):
        tempans=(i%mod)*(j%mod)
        tempans%=mod
        if tempans<ans:
            ans=tempans

print(ans)

Measured memory_bytes: 9124
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	void main() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();
		int[][] aa = new int[n][n];
		while (m-- > 0) {
			int i = sc.nextInt() - 1;
			int j = sc.nextInt() - 1;
			int c = sc.nextInt();
			if (c <= l)
				aa[i][j] = aa[j][i] = c;
		}
		int[][] kk_ = new int[n][n];
		int[][] rr_ = new int[n][n];
		boolean[] used = new boolean[n];
		for (int s = 0; s < n; s++) {
			int[] kk = kk_[s];
			int[] rr = rr_[s];
			for (int j = 0; j < n; j++)
				kk[j] = n;
			kk[s] = 0;
			rr[s] = l;
			Arrays.fill(used, false);
			while (true) {
				int i = -1;
				for (int j = 0; j < n; j++)
					if (!used[j] && (i == -1 || kk[i] > kk[j] || kk[i] == kk[j] && rr[i] < rr[j]))
						i = j;
				if (i == -1)
					break;
				used[i] = true;
				for (int j = 0, c; j < n; j++)
					if (!used[j] && (c = aa[i][j]) != 0) {
						int k = kk[i];
						int r = rr[i];
						if (r < c) {
							k++;
							r = l;
						}
						r -= c;
						if (kk[j] > k || kk[j] == k && rr[j] < r) {
							kk[j] = k;
							rr[j] = r;
						}
					}
			}
		}
		int q = sc.nextInt();
		while (q-- > 0) {
			int i = sc.nextInt() - 1;
			int j = sc.nextInt() - 1;
			int k = kk_[i][j];
			if (k == n)
				k = -1;
			println(k);
		}
	}
}


Measured memory_bytes: 60748
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
#define MAX_V 100100
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End



#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template



int main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(n);
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int sum = 0;
    rep(i,n) sum += a[i];
    cout << sum -*max_element(All(a)) + *max_element(All(a))/2 << nn;
    return 0;
}

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

int col[9] = { 1,400,800,1200,1600,2000,2400,2800,3200 };
bool memo[8];

int main() {
	int N;  cin >> N;
	int Nmax = 0, Nmin = 0;
	memset(memo, false, sizeof(memo));
	for (int i = 0; i < N; i++) {
		int a;  cin >> a;
		if (a >= col[8]) {
			Nmax++;
			continue;
		}
		for (int j = 0; j < 8; j++) {
			if (col[j] <= a && a < col[j + 1]) {
				memo[j] = true;
				break;
			}
		}
	}
	for (int i = 0; i < 8; i++) {
		if (memo[i]) {
			Nmax++;
			Nmin++;
		}
	}
	if (Nmin == 0) Nmin++;

	cout << Nmin << " " << Nmax << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<list>
#include<vector>
#include<cmath>
#include<cstdio>

using namespace std;

struct T {
	int i;
	int j;
	int n;
};

int main(void) {
	int h,w;
	cin >> h >> w;
	auto a = vector<vector<char>>(h);
	for (size_t i = 0; i < h; i++) {
		a[i] = vector<char>(w);
		for (size_t j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	}
	auto q = list<T>();
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				q.push_back({i, j, 0});
			}
		}
	}
	int cnt = 0;
	while (!q.empty())
	{
		auto t = q.front();
		cnt = cnt < t.n ? t.n : cnt;
		q.pop_front();
		if (0 <= t.i - 1 && a[t.i-1][t.j] == '.') {
			a[t.i-1][t.j] = '#';
			q.push_back({t.i-1, t.j, t.n + 1});
		}
		if (t.i + 1 < h && a[t.i+1][t.j] == '.') {
			a[t.i+1][t.j] = '#';
			q.push_back({t.i+1, t.j, t.n + 1});
		}
		if (0 <= t.j - 1 && a[t.i][t.j-1] == '.') {
			a[t.i][t.j-1] = '#';
			q.push_back({t.i, t.j-1, t.n + 1});
		}
		if (t.j + 1 < w && a[t.i][t.j+1] == '.') {
			a[t.i][t.j+1] = '#';
			q.push_back({t.i, t.j+1, t.n + 1});
		}
	}
	cout << cnt;
	
}


Measured memory_bytes: 48128
x, y = map(int, input().split())
g1 = [1, 3, 5, 7, 8, 10, 12]
g2 = [4, 6, 9, 11]
if(x in g1 and y in g1) or (x in g2 and y in g2):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9148
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn ttt(n: u32) -> u64 {
    let mut sum=0;
    for i in 0..n {
        sum += u64::pow(2, i);
    }
    sum
}

fn jj(mut j: i64, len: usize) -> Vec<i64>{
    let mut v = Vec::new();
    while j != 0 {
        v.push(j % 2);
        j /= 2;
    }
    while v.len() < len {
        v.push(0);
    }
    v
}

fn maxi(m: i64, n: i64) -> i64 {
    if m > n {
        return m
    } else {
        return n
    }
}

fn main() {
    input! {
        n: usize,
        v: [usize; n],
        c: [usize; n],
    }
    let till = ttt(n as u32);
    let mut max = -10000;
    for i in 0..till + 1 {
        let s = jj(i as i64, n);
        let mut vn = 0;
        let mut cn = 0;
        for j in 0..n {
            if s[j] == 1 {
                vn+=v[j];
                cn+=c[j];
            }
            max = maxi(max, vn as i64 - cn as i64);
        }
    }
    println!("{}", max);
}

Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <map>
#include <set>
using namespace std;

int main()
{
	string S;
	cin >> S;

	vector<int32_t> found(26, 0);
	for (size_t i = 0; i < S.size(); i++) {
		found[S[i] - 'a']++;
	}

	bool res = true;
	for (size_t i = 0; i < 26; i++) {
		if (found[i] > 1) {
			res = false;
			break;
		}
	}

	printf("%s\n", (res ? "yes" : "no"));

	return 0;
}

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

int main(){
	int n, t;
	int array[2][168] = {{},{}};
    cin >> n;
    for(int i = 2; i <= n; i++){
    	t = i;
    	int a = 2;
    	while ( t >= a * a ) {
        	if ( t % a == 0 ) {
        		for(int j = 0; j < 168; j++){
        			if(array[0][j] == 0){
        				array[0][j] = a;
        				array[1][j] += 1;
        				j = 168;
        			}else if(array[0][j] == a){
        				array[1][j] += 1;
        				j = 168;
        			}
        		}
            	t = t / a;
        	} else {
            	a ++;
        	}
    	}
    	for(int k = 0; k < 168; k++){
        	if(array[0][k] == 0){
        		array[0][k] = t;
        		array[1][k] += 1;
        		k = 168;
        	}else if(array[0][k] == t){
        		array[1][k] += 1;
        		k = 168;
        	}
        }
	}
	long long int answer = 1;
	for(int i = 0; i < 168; i++){
		//cout << array[1][i] << " ";
		answer = ( answer % 1000000007 ) * ( ( array[1][i] + 1 ) % 1000000007 ) % 1000000007;
	}
	cout << answer << endl;
}

Measured memory_bytes: 256
import sys
INF = 10 ** 9
MOD = 10 ** 9 + 7
from collections import deque
sys.setrecursionlimit(100000000)

fact2 = [0] * 1000011
def cnt2(n):
    if n%2 == 1:
        return 0
    else:
        fact2[n] = 1 + fact2[n//2]
        return fact2[n]

factorial = [0,0]
for i in range(2,1000010):
    factorial.append(factorial[-1] + cnt2(i))

def nck(n,k):
    return factorial[n] - factorial[k] - factorial[n - k]

def nxor(x,n):
    if n > 0:
        return 0
    else:
        return x


def main():
    n = int(input())
    a = [int(i) - 1 for i in list(input())]
    
    cumxor = 0
    amod = [i%2 for i in a]
    for i in range(n):
        cumxor ^= nxor(amod[i],nck(n - 1,i))
    
    if cumxor == 1:
        ans = 1
    else:
        if 1 in a:
            ans = 0
        else:
            cumxor = 0
            adiv = [i//2 for i in a]
            for i in range(n):
                cumxor ^= nxor(adiv[i],nck(n - 1,i))
            if cumxor == 0:
                ans = 0
            else:
                ans = 2
    
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 76124
N = int(input())
B = input().split(' ')
A = []
A.append(int(B[0]))
A.append(int(B[0]))
SUM_MAX = A[0]

for i in range(N - 2):
  if A[i + 1] > int(B[i + 1]):
    A[i + 1] = int(B[i + 1])
  A.append(int(B[i + 1]))
  SUM_MAX = SUM_MAX + A[i + 1]
  
SUM_MAX = SUM_MAX + A[N - 1]
print(SUM_MAX)
  

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(a==1) {
        cout<<"YES"<<endl;
        return 0;
    }
    for(int i=1;i<=100;i++)
    {
        if(a*i%b==c)
        {
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	int N;
	double x[10],ans=0;
	string u[10];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> u[i];
	}
	for (int i = 0; i < N; i++) {
		if (u[i] == "JPY") {
			ans += x[i];
		}
		else if (u[i] == "BTC") {
			ans += x[i] * 380000.0;

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

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  ll X, Y;
  cin >> X >> Y;

  ll n = (2 * X - Y)/3, m = (-X + 2 * Y)/3;

  if ( (X + Y) % 3 != 0 ) {
    cout << 0 << endl;
  }
  else {
    if (n < 0 || m < 0) {
      cout << 0 << endl;
    }
    else {
      combination comb = combination(n + m);
      mint maxv = comb(n+m, n);
      cout << maxv.x << endl;
    }
  }

  return 0;


}


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

typedef long long ll;
typedef long double ld; 
typedef double db; 
typedef string str; 

typedef pair<int, int> pi;
typedef pair<ll,ll> pl; 
typedef pair<ld,ld> pd; 

typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound 
#define ub upper_bound 

const int MOD = 998244353;
const ll INF = 1e18;
const int MX = 1000001;

int K;
queue<ll> q;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> K;
    for (int i = 1; i < 10; i++) q.push(i);
    
    for (int i = 0; i < K - 1; i++) {
        ll v = q.front(); q.pop();
        if (v % 10) q.push(10 * v + (v % 10) - 1);
        q.push(10 * v + (v % 10));
        if ((v % 10) != 9) q.push(10 * v + (v % 10) + 1);
    }
    
    cout << q.front();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  int same = 0;
  for (int i = 0; i < N - 1; i++){
    if (A[i] == A[i + 1]){
      same++;
    }
  }
  if (same % 2 == 0){
    cout << N - same << endl;
  } else {
    cout << N - same - 1 << endl;
  }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,A,B;
    cin >> N >> A >> B;
    print(min(B, A*N));
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define rep(i,n)  for(int i=0; i<n; i++)
using namespace std;
int main(void){
    int n, h;
    cin >> n >> h;
    int a[n], b[n];
    int max_a=0, at=-1;
    rep(i, n){
        cin >> a[i] >> b[i];
        if (a[i] > max_a){
            max_a = a[i];
            at = i;
        }
    }
    sort(b, b+n);
    int cnt = 0;
    for(int i = n-1; i >= 0; i--){
        if (b[i] < max_a) break;
        h -= b[i];
        cnt++;
        if (h <= 0) break;
    }
    if (h > 0) cnt += (h/max_a) + (not not (h%max_a));
    cout << cnt << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
const int max_num = 1e9;
int main()
{
    int a,b;
    cin >> a >> b;
    double k = (double)(a + b) / 2;
    if (k == (a+b)/2) cout << (a+b)/2 << endl;
    else cout << "IMPOSSIBLE" << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;

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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    bool res = is_pal(s, 0, n - 1) * is_pal(s, 0, (n - 3) / 2) * is_pal(s, (n + 1) / 2, n - 1);
    if (res) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
char g[300][300];
int main(){
    int n;
    while(cin>>n && n){
        for(int i=0;i<n;i++)cin>>g[i];
        int dx[]={1,1,1,0};
        int dy[]={-1,0,1,1};
        int ans=0;
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(g[i][j]=='1'){
                    for(int d=0;d<4;d++){
                        int ii, jj;
                        for(ii=i,jj=j; 0<=ii&&ii<n&&0<=jj&&jj<n && g[ii][jj]=='1'; ii+=dy[d],jj+=dx[d]);
                        ans=max({ans,abs(ii-i),abs(jj-j)});
                    }
                }
            }
        }
        cout<<ans<<endl;
    }
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int n;
int a[110];

int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}

	int la = -1;
	int ret = 0;
	int c = 0;

	rep(i, n) {
		if (la == -1) {
			la = a[i];
			c = 1;
		} else if (la == a[i]) {
			++c;
		} else {
			ret += (c + 1) / 2;
			c = 1;
			la = a[i];
		}
	}

	ret += (c + 1) / 2;
	cout << n - ret << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

    int count = 0;
    String s,t;

    s = sc.next();
    t = sc.next();

    for(int i = 0; i < 3; i++){
      if(s.charAt(i) == t.charAt(i)){
        count++;
      }
    }

    System.out.println(count);
  }
}


Measured memory_bytes: 21844