akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

const int MAXN=1e7+1;

int spf[MAXN]; 

void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
        spf[i] = i; 

    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    {
        if (spf[i] == i) 
        {
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 

int main()
{
	sieve();
	
	int n;
	cin>>n;
	
	long long DP[n+1];
	
	long long ans=1;
	DP[1]=1;
	
	for(int i=2;i<=n;i++)
	{
		int sp=spf[i];
		int temp=i;
		
		long long cnt=0;
		
		while(temp%sp==0)
		{
			cnt++;
			temp/=sp;
		}
		
		DP[i]=DP[temp]*(cnt+1);
		
		//cout<<DP[i]<<endl;
		ans+=i*DP[i];
	}

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

Measured memory_bytes: 120788
from bisect import bisect_left, bisect_right, insort_left
import sys
readlines = sys.stdin.readline
def main():

	n = int(input())
	s = list(input())
	q = int(input())

	d = {}
	flag = {}
	for i in list('abcdefghijklmnopqrstuvwxyz'):
		d.setdefault(i, []).append(-1)
		flag.setdefault(i, []).append(-1)
	for i in range(n):
		d.setdefault(s[i], []).append(i)
	for i in range(q):
		q1,q2,q3 = map(str,input().split())
		if q1 == '1':
			q2 = int(q2) - 1
			if s[q2] != q3:
				insort_left(flag[s[q2]],q2)
				insort_left(d[q3],q2)
				s[q2] = q3
		else:
			ans = 0
			q2 = int(q2) - 1
			q3 = int(q3) - 1
			if q2 == q3:
				print(1)
				continue
			for string,l in d.items():
				res = 0
				if d[string] != [-1]:
					left = bisect_left(l,q2)
					right = bisect_right(l,q3)
				else:
					left = 0
					right = 0
				if string in flag:
					left2 = bisect_left(flag[string],q2)
					right2 = bisect_right(flag[string],q3)
				else:
					left2 = 0
					right2 = 0
				if left != right:
					if right - left > right2 - left2:
						res = 1
				ans += res
				#print(string,l,res)
			print(ans)
if __name__ == '__main__':
	main()

Measured memory_bytes: 29320
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    l = []

    for a in A:
        if a % 2 == 0:
            c = 0
            while a % 2 == 0:
                a //= 2
                c += 1
            l.append(c)
        else:
            l.append(0)

    return min(l)

print(solve())


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>

const int NUM_CHAR = 'z' - 'a' + 1;

inline constexpr int charToIndex(char c) {
	return c - 'a';
}

int main() {
	std::string s, t;
	std::cin >> s;
	std::cin >> t;

	// nextIndex[i][charToIndex(c)]: sのi番目から見て、次のcまでの距離
	std::vector<std::vector<int>> nextDistance(s.length(), std::vector<int>(NUM_CHAR, -1));
	for(char c = 'a'; c <= 'z'; c++) {
		// 最初に c が現れるインデックスから逆向きに一周する。
		int distance = 0;
		const int pos = s.find(c);
		if(pos == s.npos) {
			continue;
		}
		const int start = (pos + s.length() - 1) % s.length();
		int i = start;
		while(true) {
			distance++;
			nextDistance[i][charToIndex(c)] = distance;
			if(s[i] == c) {
				distance = 0;
			}

			i = (i + s.length() - 1) % s.length();
			if(i == start) {
				break;
			}
		}
	}

	long long result = 0;
	int index = s.length() - 1;
	for(const char &c : t) {
		const int distance = nextDistance[index][charToIndex(c)];
		if(distance == -1) {
			std::cout << -1 << std::endl;
			return 0;
		}

		result += distance;
		index = (index + distance) % s.length();
	}

	std::cout << result << std::endl;

	return 0;
}


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

int main(){
    int N, M;
    cin >> N >> M;
    
    vector<int> cnt(100002, 0);
    vector<int> mod(M, 0);
    vector<int> p(M, 0);
    
    vector<int> X(N);
    for (int i = 0; i < N; i++) {
        int n;
        cin >> n;
        X[i] = n;
        mod[n%M]++;
        if (cnt[n] == 1) {
            cnt[n]--;
            p[n%M]++;
        }else{
            cnt[n]++;
        }
    }
    
    int ans = 0;
    ans += mod[0] / 2;
    if (M % 2 == 0) ans += mod[M/2] / 2;
    
    for (int i = 1; i <= (M-1)/2; i++) {
        int j = M - i;
        int t = max(mod[i] - p[i] * 2, mod[j] - p[j] * 2);
        t = min(t, min(mod[i], mod[j]));
        int u = min((mod[i] - t) / 2, p[i]);
        int v = min((mod[j] - t) / 2, p[j]);
        ans += t+u+v;
    }
    cout << ans << endl;
}

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

int main(){
	int N, K;
	int num = 1;
	cin >> N >> K;
	for(int i = 0 ; i < N; i++){
		if (K > num){
			num = num*2;
		}
		else num+=K;	
	}
	cout <<num << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<stdlib.h>
using namespace std;
int f(string s, int  i);
int  main()
{
	int n, i, j, ans = 0;
		int temp;
	string s;
	cin >> n;
	cin >> s;
	for (int i = 1; i < n; i++)
	{
		temp = f(s, i);
		ans = max(ans, temp);
	}
	printf("%d", ans);
	return 0;
}
int f(string s, int i)
{
	string s1 = s.substr(0, i);
	string s2 = s.substr(i);
	char x = 'a';
	int n1[26], n2[26], ans = 0;
	memset(n1, 0, sizeof(n1));
	memset(n2, 0, sizeof(n2));
	for (int j = 0; j < 26; j++)
	{
		n1[j] = count(s1.begin( ), s1.end( ), x);
		n2[j] = count(s2.begin( ),s2.end( ), x);
		x++;
	}
	for (int j = 0; j < 26; j++)
	{
		if (n1[j] > 0 && n2[j] > 0)
			ans++;
	}
	return ans;
}

Measured memory_bytes: 256
"use strict"
function main(arg) {
      



       if((arg.trim().split("\n")[0].substring(2,3) == arg.trim().split("\n")[0].substring(3,4)) &&  (arg.trim().split("\n")[0].substring(4,5) == arg.trim().split("\n")[0].substring(5,6)) ){
            console.log('Yes');

       }else{
               console.log('No');
       }


}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include <iostream>
#include <vector>

inline bool isgu(
    const std::string& s,
    size_t l
) {
    for (size_t i = 0; i < l / 2; i++) {
        if (s[i] != s[l /2 + i]) {
            return false;
        }
    }
    return true;
}

int main() {
    std::string s;
    std::cin >> s;
    for (size_t i = s.size() - 2; i > 0; i -= 2)
    {
        if (isgu(s, i)) {
            std::cout << i << std::endl;
            break;
        }
    }
    return 0;
}

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

int main() {
	int n; scanf("%d", &n);
	int arr[n];
	for (int i=0; i<n; i++) scanf("%d", &arr[i]);
	int dp[n+1][2];
	dp[0][0]=1, dp[0][1]=1;
	for (int i=0; i<n; i++) {
		if (i==0 || arr[i]>=arr[i-1]) {
			dp[i+1][1]=dp[i][1];
		}
		else dp[i+1][1]=min(dp[i][1]+1,dp[i][0]+1);
		if (i==0 || arr[i]<=arr[i-1]) {
			dp[i+1][0]=dp[i][0];
		}
		else dp[i+1][0]=min(dp[i][1]+1,dp[i][0]+1);
		//printf("%d %d\n", dp[i+1][0], dp[i+1][1]);
	}
	printf("%d\n", min(dp[n][0],dp[n][1]));
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pair<ll, ll> > vp;

#define pb push_back
#define rep(i, a, n) for(ll i = (a); i < (n); i++)
#define dep(i, a, n) for(ll i = (a); i >= (n); i--)
#define vin(n, d) rep(i, 0, n) cin >> d[i]
#define out(n) cout << (n) << endl

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
ll h,w,ans;
ll k(ll a,ll b){rep(i,1,a)ans=min(ans,max(i*b,(b/2+(b%2==0?0:1))*(a-i))-min(i*b,(b/2)*(a-i)));}
int main(){cin>>h>>w,ans=h%3==0||w%3==0?0:min(h,w),k(h,w),k(w,h),out(ans);}


Measured memory_bytes: 256
def resolve():
    '''
    code here
    '''
    S = input()

    res = 0
    temp = 0
    for item in S:
        if item == 'R':
            temp += 1
        else:
            temp = 0

        res = max(res, temp)

    print(res)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 8968
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def main():
    N, M, *A = map(int, read().split())
    A = list(set(A))
    B = A.copy()

    while not any(b % 2 for b in B):
        B = [b // 2 for b in B]

    if not all(b % 2 for b in B):
        print(0)
        return

    semi_lcm = 1
    for a in A:
        semi_lcm = lcm(semi_lcm, a // 2)
        if semi_lcm > M:
            print(0)
            return

    print((M // semi_lcm + 1) // 2)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 14308
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first < y.first;});
#define FRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first > y.first;});
#define SSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second < y.second;});
#define SRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second > y.second;});
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define DEBUG true
#define $(x) {if (DEBUG) {cout << #x << " = " << (x) << endl;}}


int main() {
    LL N;
    cin >> N;
    VI A(N), B(N);
    REP(i, N) {
        cin >> A[i] >> B[i];
    }

    LL ans = 0, offset = 0;
    for(LL i = N - 1; i >= 0; --i) {
        LL a = A[i] + offset;
        if (a == 0) continue;
        LL diff = B[i] * (LL)ceil((double)a / B[i]) - a;
        ans += diff;
        offset += diff;
    }
    cout << ans << endl;
	
    return 0;
}


Measured memory_bytes: 1792
h, w, k = map(int, input().split())
l = []
ans = []
for i in range(h):
  lll = [0 for x in range(w)]
  ans.append(lll)
for i in range(h):
  ll = list(input())
  l.append(ll)
res = 0
fl = False
for i in range(h):
  res2 = 0
  if not "#" in l[i]:
    if i == 0:
      fl = True
      
    else:
      ans[i] = ans [i-1]
      
  else:
    res += 1
    for j in range(w):
      if l[i][j] == "#":
        res2 += 1
        if res2 >= 2:
          res += 1
        ans[i][j] = res     
      else:
        ans[i][j] = res
if fl:
  ffff = 1
  for i in range(h):
    if "#" in l[i]:
      ffff = i
      break
  for i in reversed(range(1, ffff+1)):
    ans[i-1] = ans[i]
for i in range(h):
  print(' '.join(map(str, ans[i])))

Measured memory_bytes: 7924
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265359
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
ll power(ll x, ll y, ll p)
{ 
    ll res = 1;  
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	ll i1 = 0;
	ll i2 = 0;
	while (n--) {
		cout << s[i1++] << t[i2++];
	}    
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
n,m = map(int,input().split())
INF = m
ans = INF
# どうしてTLE？？O(root(m))で10**4だからOKでは？ m ** 1/2だとm /2 になる
for i in range(1,int(m**(1/2)) + 1):
    if m % i == 0:
        # i,m//iのうち、n 以上でmaxなものをansに入れる
        if i >= n: ans = min(ans,i)
        if m//i >= n: ans = min(ans,m//i)
print(m//ans)

Measured memory_bytes: 38708
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int K;
  cin>>K;
  queue<string> que;
  que.push("1");
  que.push("2");
  que.push("3");
  que.push("4");
  que.push("5");
  que.push("6");
  que.push("7");
  que.push("8");
  que.push("9");
  string ans;
  for(int i=0;i<K;++i) {
    ans = que.front();que.pop();
    if(ans[ans.size()-1]=='0') {
      ans.push_back('0');
      que.push(ans);
      ans.pop_back();
      ans.push_back('1');
      que.push(ans);
      ans.pop_back();
    }
    else if(ans[ans.size()-1]=='9') {
      ans.push_back('8');
      que.push(ans);
      ans.pop_back();
      ans.push_back('9');
      que.push(ans);
      ans.pop_back();
    }
    else {
      ans.push_back(ans[ans.size()-1]-1);
      que.push(ans);
      ans.pop_back();
      ans.push_back(ans[ans.size()-1]);
      que.push(ans);
      ans.pop_back();
      ans.push_back(ans[ans.size()-1]+1);
      que.push(ans);
      ans.pop_back();
    }
  }
  cout<<ans<<endl;
}



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

int main()
{
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int cnt = 0;

    for (int i = 0; i < A + 1; i++)
    {
        for (int j = 0; j < B + 1; j++)
        {
            for (int k = 0; k < C + 1; k++)
            {
                if ((500 * i + 100 * j + 50 * k) == X)
                {
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
}

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

int main(){
  int A, B;
  cin >> A >> B;
  int plu, min, mul;
  plu = A + B;
  min = A - B;
  mul = A * B;
  if((plu >= min) && (plu >= mul)){
    cout << plu;
  } else if((min >= plu) && (min >= mul)){
    cout << min;
  } else {
    cout << mul;
  }
}

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

int main(void)
{
	double x, y, h;
	double s;
	
	while (1){
		scanf("%lf %lf", &x, &h);
		
		if (x + h == 0){
			break;
		}
		
		
		y = sqrt(h * h + x / 2 * x / 2);
		s = (x * x) + x * y * 2;
		
		printf("%f\n", s);
		
	}
	
	return (0);
}

Measured memory_bytes: 644
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		double r;
		
		Scanner scan = new Scanner(System.in);
		
		r = scan.nextDouble();
		
		System.out.printf("%f " , r * r * Math.PI);
		System.out.printf("%f" , r * 2 * Math.PI);
		
	}

}


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

using namespace std;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    if (n == 1) cout << "Hello World\n";
    else {
        int a, b;
        cin >> a >> b;
        cout << (a+b) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1, 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
template <class T> int digits_number(T x) {
    string str = to_string(x);
    return (T)str.size();
}
template <class T> vector<T> divisor(T N) {
    vector<T> ans;
    if (N == 1) {
        ans.emplace_back(1);
        return ans;
    }
    if (N <= 0) {
        return ans;
    }
    for (long long i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ans.emplace_back(i);
            if (i != 1 && i * i != N) {
                ans.emplace_back(N / i);
            }
        }
    }
    ans.emplace_back(N);
    return ans;
}

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

    ll N;
    cin >> N;

    ll ans = INF64;

    auto div = divisor(N);
    for (auto &&i : div) {
        ll x   = N / i;
        ll dig = max(digits_number(x), digits_number(i));
        chmin(ans, dig);
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 256
n=int(input())
c=0
r=0
for i in range(1,8):
    r+=n//(2**i)
if r>=74:
    c+=1
d=2
q=0
p=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]
e=0
f=0
a=0
h=0
for j in range(15):
    q=0
    for i in range(1,7):
        q+=n//(p[j]**i)
    if q>=24:
        e+=1
        f+=1
        a+=1
        h+=1
    elif q>=14:
        f+=1
        a+=1
        h+=1
    elif q>=4:
        h+=1
        a+=1
    elif q>=2:
        h+=1
c+=e*(h-1)+f*(a-1)+(a*(a-1)//2)*(h-2)
print(c)

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

typedef long long ll;
// typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
const double pi = 3.141592653589793238;


int main() {
  int N; cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++) cin >> a.at(i);

  int sw;
  int be = 0;

  int cnt = 0;
  for(int i = 0; i < N-1; i++) {
    if(a.at(i+1) - a.at(i) > 0) sw = 1;
    else if(a.at(i+1) - a.at(i) < 0) sw = -1;
    else if(a.at(i+1) - a.at(i) == 0) {
      sw = be;
      continue;
    }

    // cout << "be:" << be << ", sw:" << sw << endl;
    if(i == 0) {be = sw; continue;}
    if(sw + be != 0) {
      be = sw;
    } else {
      cnt++;
      be = 0;
    }
  }

  cout << cnt+1 << endl;

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string ab;
    cin>>ab;
    for(int i=0;i<ab.size();i++)
    {
        if(ab[i]=='1')
            ab[i]='9';
        else if(ab[i]=='9')
            ab[i]='1';
    }
    cout<<ab<<endl;
    return 0;
}


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

int main(){
  int n,m;
  cin>>n>>m;

  vector <string> ans;
  vector <int> num;
  int pre=1e9;

  for(int i=0;i<n;i++){
    string a,b;
    int h1,m1,h2,m2;
    scanf("%d:%d",&h1,&m1);
    cin>>a;
    scanf("%d:%d",&h2,&m2);
    cin>>b;
    int res=h1*60+m1-(pre);
    if(res>=m) ans.push_back(a),num.push_back(res);
    pre=h2*60+m2;
  }

  cout <<ans.size()<<endl;
  for(int i=0;i<ans.size();i++) cout <<ans[i]<<" "<<num[i]<<endl;
  return 0;
}

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

using namespace std;

static long long count_patty (int level, long long n_eat) {
    /* level-1 のバーガーの層数とパティの枚数 */
    long long n_layer = (1LL << (level+1)) - 3;
    long long n_patty = (1LL << level) - 1;

    if ( level == 0 )
        return 1;

    if ( n_eat <= 1 )
        return 0;
    else if ( n_eat <= n_layer + 1 )
        return count_patty(level-1, n_eat-1);
    else if ( n_eat == n_layer + 2 )
        return 1 + n_patty;
    else if ( n_eat <= n_layer * 2 + 2 ) {
        return 1 + n_patty + count_patty(level-1, n_eat-n_layer-2);
    }
    return 1 + 2 * n_patty;
}

int main (void) {
    long long N, X;
    cin >> N >> X;

    long long ans = count_patty(N, X);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <algorithm>
#include <cstdio>
#include <tuple>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_reverse(i, n) for (int i = (n)-1; (i) >= 0; --(i))
#define whole(x) begin(x), end(x)
using ll = long long;
using namespace std;
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }

constexpr ll inf = ll(1e18)+9;
int main() {
    // input
    int n; scanf("%d", &n);
    vector<pair<int, int> > hps(n);
    repeat (i, n) {
        int h, p; scanf("%d%d", &h, &p);
        hps[i] = { h, p };
    }
    // solve
    sort(whole(hps), [&](pair<int, int> hp1, pair<int, int> hp2) {
        return hp1.first + hp1.second < hp2.first + hp2.second;
    });
    vector<ll> dp(n + 1, inf);
    dp[0] = 0;
    for (auto hp : hps) {
        int h, p; tie(h, p) = hp;
        repeat_reverse (j, n) {
            if (dp[j] <= h) {
                setmin(dp[j + 1], dp[j] + p);
            }
        }
    }
    int result = 0;
    repeat (i, n + 1) {
        if (dp[i] < inf) {
            result = i;
        }
    }
    // output
    printf("%d\n", result);
    return 0;
}

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

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define eof !cin.eof()
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define ull unsigned long long
#define ll long long
#define ld long double
#define sz(a) a.size()
#define all(s) s.begin(), s.end()
#define rall(s, n) s, s + n
#define x first
#define y second
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ii pair <int, int>
#define iii pair <int, ii>
#define vi vector <int>
#define vit vector <int> :: iterator
#define vlt vector <ll> :: iterator
#define vl vector <ll> 
#define vii vector <ii>
#define viii vector <iii>
#define vd vector <double>
#define vull vector <ull>
#define vc vector <char>
#define vs vector <string>
#define vvi vector <vector <int>>
#define vvl vector <vector <ll>>
#define EPS 1e-10
#define INF 1000000000
#define mod 1000000007
#define reset(a, nilai) memset(a, nilai, sizeof(a))
#define minof min_element
#define maxof max_element
using namespace std;

int n, k;
int main () {
	IOS;
	
	scanf("%d%d", &n, &k);
	vi h(n), dp(n, INF);
	for (int i = 0; i < n; i++) {
		scanf("%d", &h[i]);
	}
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j <= i + k; j++) {
			if (j < n) {
				dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
			}
		}
	}
	printf("%d\n", dp[n - 1]);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N, K;
int cnt[2000][2000][2];
int sum[2000][2000][2];

int main () {
  fill(&cnt[0][0][0], &cnt[0][0][0]+2000*2000*2, 0);
  cin >> N >> K;
  int white = 0;
  for (auto i = 0; i < N; ++i) {
    int x, y;
    char c;
    cin >> x >> y >> c;
    bool color = (c == 'W');
    int area = ((x/K) + (y/K))%2;
    x %= K;
    y %= K;
    if (color) {
      white++;
      cnt[x + K * area][y][0]++;
      cnt[x + K * (1-area)][y + K][0]++;
    } else {
      cnt[x + K * area][y][1]++;      
      cnt[x + K * (1-area)][y + K][1]++;      
    }
  }
#if DEBUG == 1
  for (auto k = 0; k < 2; ++k) {
    cerr << "k = " << k << endl;
    for (auto i = 0; i < 2 * K; ++i) {
      for (auto j = 0; j < 2 * K; ++j) {
        cerr << cnt[i][j][k] << " ";
      }
      cerr << endl;
    }    
  }  
#endif
  for (auto k = 0; k < 2; ++k) {
    for (auto i = 0; i < 2 * K; ++i) {
      for (auto j = 0; j < 2 * K; ++j) {
        sum[i][j][k] = cnt[i][j][k];
      }
    }
    for (auto i = 0; i < 2 * K; ++i) {
      for (auto j = 0; j < 2 * K-1; ++j) {
        sum[i][j+1][k] += sum[i][j][k];
      }
    }
    for (auto j = 0; j < 2 * K; ++j) {
      for (auto i = 0; i < 2 * K-1; ++i) {
        sum[i+1][j][k] += sum[i][j][k];
      }
    }
  }
#if DEBUG == 1
  for (auto k = 0; k < 2; ++k) {
    cerr << "k = " << k << endl;
    for (auto i = 0; i < 2 * K; ++i) {
      for (auto j = 0; j < 2 * K; ++j) {
        cerr << sum[i][j][k] << " ";
      }
      cerr << endl;
    }    
  }  
#endif
  int ans = 0;
  for (auto i = 0; i < K; ++i) {
    for (auto j = 0; j < K; ++j) {
      int x = i + K;
      int y = j + K;
      int w = sum[x][y][0] - sum[i][y][0] - sum[x][j][0] + sum[i][j][0];
      int b = sum[x][y][1] - sum[i][y][1] - sum[x][j][1] + sum[i][j][1];
#if DEBUG == 1
      cerr << "(" << x << ", " << y << ") = ("
           << w << ", " << b << ")" << endl;
#endif
      int c = white - w + b;
      c = max(N-c, c);
      ans = max(ans, c);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 62720
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long ll;
const ll maxn=5e5+5;
ll cnt[maxn];
ll a[maxn];
ll pos[maxn];
ll ans[maxn];
ll res=0;
ll read() {
	ll res = 0;
	char c = getchar();
	while(!isdigit(c)) c = getchar();
	while(isdigit(c)) res = (res << 1) + (res << 3) + c - 48, c = getchar();
	return res;
}
void printi(ll x) {
	if(x / 10) printi(x / 10);
	putchar(x % 10 + '0');
}
struct Q
{
    ll l,r,k;
} QQ[maxn];
bool cmp(Q a,Q b)
{
    return pos[a.l]==pos[b.l]?a.r<b.r:pos[a.l]<pos[b.l];
}
void Sub(ll i)
{
    cnt[a[i]]--;
    if(!cnt[a[i]])
        res--;
}
void Add(ll i)
{
    cnt[a[i]]++;
    if(cnt[a[i]]==1)
        res++;
}
int main()
{
    ll n,q;
    n=read();
    q=read();
    ll siz=sqrt(n);
    for(ll i=1; i<=n; i++)
    {
        a[i]=read();
        pos[i]=i/siz;
    }
    for(ll i=0; i<q; i++)
    {
        QQ[i].l=read();
        QQ[i].r=read();
        QQ[i].k=i;
    }
    sort(QQ,QQ+q,cmp);
    ll l=1,r=0;
    for(ll i=0; i<q; i++)
    {
        while(l<QQ[i].l)
            Sub(l++);
        while(l>QQ[i].l)
            Add(--l);
        while(r<QQ[i].r)
            Add(++r);
        while(r>QQ[i].r)
            Sub(r--);
        ans[QQ[i].k]=res;
    }
    for(ll i=0; i<q; i++)
    {
        printf("%lld\n",ans[i]);
    }
    return 0;
}


Measured memory_bytes: 31152
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define ushi int
#define tapu main
#define nichia (
#define kunn void
#define wara )

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/

int main(){

	int a, b;
	scanf("%d", &a);
	printf("%d\n", (a / 2) * (a - a / 2));

	Please AC;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var sp = input.split("\n");
for( var i = 0; sp[i] !== "0 0"; i++ ) {
  var x = sp[i].split(" ").map(Number);
  if( x[0] < x[1] ) {
    console.log( x[0] + " " + x[1] );
  } else {
    console.log( x[1] + " " + x[0] );
  }
}

Measured memory_bytes: 19140
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;
int n,x;
int main() {
    cin >> n;
    int ans = 0;
    forn(i, n) {
        cin >> x;
        while (x % 2 == 0) {
            x /= 2;
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define rer(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int inf = 1000000000;
const int mod = 1000000007;
const double EPS = 1e-9;
const int dx[] = { -1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

int n, p;

int main() {
	// cin.tie(0); // tie
	// ios::sync_with_stdio(false); // sync
	while (cin >> n >> p, n || p) {
		int tmp = p;
		vector<int> a(n, 0);
		for (int i = 0; i < n; ++i) {
			if (p != 0) {
				a[i]++;
				p--;
				if (p == 0 && a[i] == tmp) {
					cout << i << endl;
					break;
				}
			} else {
				p = a[i];
				a[i] = 0;
			}
			if (i == n - 1) i = -1;
		}
	}
	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <math.h>
#include <complex>
using ll = long long;
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
int const MOD = 1e9 + 7;

using ci = pair<char, int>; //文字 深さ
using ii = pair<int, int>;  //数字 深さ

int main(void)
{
    int H;
    while (cin >> H, H)
    {
        int field[100][100];
        rep(i, 100) rep(j, 100) field[i][j] = 0;
        for (int i = 0; i < H; ++i)
        {
            for (int j = 0; j < 5; ++j)
            {
                cin >> field[i][j];
            }
        }

        int ans = 0;
        bool ok = true;
        while (ok)
        {
            ok = false;

            for (int i = 0; i < H; ++i)
            {
                int j = 0, cnt = 0;
                while (j != 5)
                {
                    if (field[i][j] == 0)
                    {
                        j++;
                        continue;
                    }
                    if (field[i][j] == field[i][j + 1] && j < 4)
                    {
                        cnt++;
                    }
                    else if (field[i][j] != field[i][j + 1] || j == 4)
                    {
                        cnt++;
                        if (cnt >= 3)
                        {
                            ans += cnt * field[i][j];
                            for (int k = cnt - 1; k >= 0; --k)
                            {
                                field[i][j - k] = 0;
                            }
                            ok = true;
                        }
                        cnt = 0;
                    }
                    j++;
                }
            }
            bool check = true;
            while (check)
            {
                check = false;
                for (int i = H - 1; i >= 1; --i)
                {
                    for (int j = 0; j < 5; ++j)
                    {
                        if (field[i][j] == 0 && field[i - 1][j] != 0)
                        {
                            swap(field[i][j], field[i - 1][j]);
                            check = true;
                        }
                    }
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3116
N = int(input())
A = list(map(int, input().split()))
def xored(a, b):
  y = 0
  base = 1
  while a != 0 or b != 0:
    y += ((a + b) % 2) * base
    base *= 2
    a //= 2
    b //= 2
  return y

if max(A) == 0:
  print("Yes")
else:
  if N % 3 != 0:
    print("No")
  else:
    D = {}
    for i in A:
      if i in D:
        D[i] += 1
      else:
        D[i] = 1
    if len(D) > 3:
      print("No")
    else:
      if len(D) == 3 and min(D[i] for i in D) == max(D[i] for i in D):
        L = [i for i in D]
        if xored(L[0], L[1]) == L[2]:
          print("Yes")
        else:
          print("No")
      elif len(D) == 2:
        if 0 not in D:
          print("No")
        else:
          if D[0] >= N // 3:
            print("Yes")
          else:
            print("No")
      else:
        print("No")

Measured memory_bytes: 14704
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

const MAX: usize = 1000000;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let mut A: Vec<usize> = sc.vec(N);
    A.sort();
    if A[0] == 1 {
        if N >= 2 && A[1] == 1 {
            println!("0");
        } else {
            println!("1")
        }
        return;
    }
    let mut extra = HashSet::new();
    for i in 0..N {
        let a = A[i];
        for j in (a*2..=A[N-1]).step_by(a) {
            extra.insert(j);
        }
    }
    let mut cur = 0;
    while cur < N {
        let ai = A[cur];
        let mut cnt = 0;
        while cur < N && ai == A[cur] {
            cur += 1;
            cnt += 1;
        }
        if cnt != 1 {
            extra.insert(ai);
        }
    }
    let mut ans = 0;
    for i in 0..N {
        if !extra.contains(&A[i]) {
            ans += 1;
        }
    }
    println!("{}", ans);
}


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

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

  int Nlen= S.size();
  string treadmill= T+ T;

  bool enable= false;
  for(int i=0; i<Nlen; i++){
    if(S==treadmill.substr(i, Nlen)){
      enable= true;
      break;
    }
  }

  string ans= (enable) ? "Yes"
                       : "No";
  cout << ans << endl;
}

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

int main()
{
    int N;
    cin >> N;
    int64_t L[87];
    L[0] = 2LL;
    L[1] = 1LL;
    for (int i = 2; i <= N; ++i)
    {
        L[i] = L[i - 1] + L[i - 2];
    }
    cout << L[N] << endl;
}

Measured memory_bytes: 3620
"""
配列の値を書き換える＝＝削除すると同義
削除する値を一つ決め、それを区切りに右と左の配列に分け、GCDを求める
更に左右のGCDをマージしGCDを求め、最大値が答え
"""
import functools, fractions

N = int(input())
A = list(map(int, input().split()))
L = [0]*(N+1)
R = [0]*(N+1)

for i in range(N):
  L[i+1] = fractions.gcd(L[i], A[i])

for i in range(N-1, 0, -1):
  R[i] = fractions.gcd(R[i+1], A[i])
  
ans = 0
for i in range(N):
  l = L[i]
  r = R[i+1]
  ans = max(ans, fractions.gcd(l, r))
print(ans)  

Measured memory_bytes: 16156
using System;
using System.Collections.Generic;
using System.Linq;

namespace ProgramingStydying
{
    class Program
    {
        static void Main(string[] args)
        {
            var whn = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var w = whn[0];
            var h = whn[1];
            var n = whn[2];

            var x1 = new List<int>();
            var x2 = new List<int>();
            var y1 = new List<int>();
            var y2 = new List<int>();

            x1.Add(0);
            x2.Add(w);
            y1.Add(0);
            y2.Add(h);

            for (int i = 0; i < n; i++)
            {
                var xya = Console.ReadLine().Split().Select(int.Parse).ToArray();
                var x = xya[0];
                var y = xya[1];
                var a = xya[2];

                if(a == 1)
                {
                    x1.Add(x);
                }
                if (a == 2)
                {
                    x2.Add(x);
                }
                if (a == 3)
                {
                    y1.Add(y);
                }
                if (a == 4)
                {
                    y2.Add(y);
                }
            }
            var xMin = x1.Max();
            var xMax = x2.Min();
            var yMin = y1.Max();
            var yMax = y2.Min();

            var area = 0;
            
            if(xMin < xMax && yMin < yMax)
            {
                area = (xMax - xMin) * (yMax - yMin);
            }

            Console.WriteLine(area);
        }
    }
}

Measured memory_bytes: 28180
N=gets.to_i
A=gets.split.map &:to_i
gr=[0,A[0]]
A[1,N-1].each{|a|gr << gr[-1].gcd(a)}
gl=[0,A[-1]]
A[0,N-1].reverse.each{|a|gl << gl[-1].gcd(a)}
p (1..N).map{|i|gr[i-1].gcd(gl[N-i])}.max

Measured memory_bytes: 11780
#include <bits/stdc++.h>
#define FOR(i, l, r) for (int i = l; i <= r; ++i)
#define ROF(i, l, r) for (int i = l; i >= r; --i)
#define ll long long
using namespace std;

int n, k, a[100010];
ll sum;

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

    cin >>k >>n;
    FOR(i, 1, n) cin >>a[i];
    FOR(i, 1, n) sum += a[i];
    cout <<(sum > k ? -1 : k - sum);
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
 
#define ll long long 
#define mkp make_pair 
#define fi first 
#define se second
#define pb push_back 
#define pf push_front 
#define ppb pop_back 
#define ppf pop_front
# define skorost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 

using namespace std ;
 
int z , o , ans ;
 
int main(){ skorost ;

	int n , a , b ;

	cin >> n >> a >> b ;

	int k = n - a ;

	if( k <= b ){

		cout << b - k ;

	}

	else {

		cout << 0 ;

	}
 
}

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

int main()
{
    int x, y;
    cin >> x >> y;
    int g[13] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    if (g[x] == g[y]) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll maxn=2e5+1;
ll round(ll i)
{
	double val=i*1.08;
	ll v=val;
	/*double diff=val-v;
	if(diff>=0.5) diff=1;
	else diff=0;
	v=v+diff;*/
	return v;
}
void solve()
{
	ll N;
	cin>>N;
	for(ll i=1;i<=N;i++)
	{
		if(round(i)==N)
		{
			cout<<i<<"\n";
			return;
		}
	}
	cout<<":(\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T=1,p=0;
	//cin>>T;
	do
	{
		solve();
		p++;
	}while(p<T);
	return 0;
}



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

int main(){
    int n;
    cin >> n;
    for (int i = 1; i <= 9; i++){
        if (n % i == 0 && 1 <= n / i && n / i <= 9) cout << "Yes" << endl, exit(0);
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt(), m= sc.nextInt();
    int[] map = new int[n];
    for(int i=0; i<m; i++){
      int a =sc.nextInt(), b=sc.nextInt();
      for(int j=0; j<n; j++){
        if(j==(a-1) || j==(b-1)){
          map[j]+=1;
        }
      }
    }
    for(int num : map){
      System.out.println(num);
    }
  }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    for (int i = 0; i < S.size(); i++)
    {
        cout << 'x';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <sstream>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<ctime>
#include<cmath>
#include<map>
#include<stack>
#include<random>
#include<queue>
#include<list>
#include<math.h>
#include<complex>
using namespace std;
#define ll long long int
#define ld long double
#define key pair<ld,ld>
#define ii pair<int,int>
#define si set<int>
#define vii vector<pair<int,int> >
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vvi vector<vector<int> >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define nu 100001
#define mul(x,y) ((ll)(x)*(y))%mod
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(i, n) for (int i = 0; i < int(n); i++)
const ll INF=1000000000000;
const ll mod=1000000007;

ll  MOD(ll  a,ll  b)
{
    if(a>b)
        return a-b;
    else
        return b-a;
}
ll  max3(ll  a,ll  b,ll c)
{
    return max(c,max(a,b));
}
ll min3(ll a,ll  b,ll  c)
{
    return min(a,min(b,c));
}
ll  power(ll  x,ll  y )
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x);//%mod;
        y = y>>1;
        x = (x*x);//%mod;
    }
    return res;//%mod;
}
ll  power1(ll  x,ll  y )
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x)%mod;
        y = y>>1;
        x = (x*x)%mod;
    }
    return res%mod;
}
ll logg(ll  a)
{
    ll  x=0;
    while(a>1)
    {
        x++;
        a/=2;
    }
    return x;
}
ll  gcd(ll  a,ll   b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
ll abso(ll x)
{
    if(x<0)
    {
        return -x;
    }
    return x;
}
ll ceiling (ll  a,ll  b)
{
    if(a%b==0)
    {
        return a/b;
    }
    else
    {
        return a/b+1;
    }
}
ll modinv(ll x)
{
    return power1(x,mod-2);
}
int n;
vll a;
ll dp[3001][3001];
ll solve(int i,int j)
{
    if(dp[i][j]!=-1)
    {
        return dp[i][j];
    }
    else
    {
        if(i>j||i<0||i>=n||j<0||j>=n)
        {
            return 0;
        }
        else
        {
            if(i==j)
            {
                dp[i][j]=a[i];
                return a[i];
            }
            else
            {
                dp[i][j]=max(min(solve(i+2,j)+a[i]-a[i+1],solve(i+1,j-1)+a[i]-a[j]),min(solve(i,j-2)+a[j]-a[j-1],solve(i+1,j-1)+a[j]-a[i]));
                return dp[i][j];
            }
        }
    }
}
int main()
{
    cin>>n;
    a.resize(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<3001;i++)
    {
        for(int j=0;j<3001;j++)
        {
            dp[i][j]=-1;
        }
    }
    solve(0,n-1);
    cout<<dp[0][n-1];
}


Measured memory_bytes: 70784
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication9
{
    class Program
    {
        static void Main(string[] args)
        {
            String str = Console.ReadLine();
            int x = int.Parse(str);
            int i=0;
            while (x != 0)
            {
                i++;
                Console.WriteLine("Case " + i + ": "+ x);
                str = Console.ReadLine();
                x = int.Parse(str);
              
            }
        
        
         

        }
    }
}

Measured memory_bytes: 5816
#include <bits/stdc++.h>
using namespace std;
using ii = pair<int,int>;
using ll = long long;

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  int n,maxi=-1; cin >> n;
  ll ans = 0;

  for (int i = 0; i < n; ++i) {
    int x; cin >> x;
    if (x < maxi) {
      ans += abs(x-maxi);
    }
    maxi = max(maxi, x);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll N = 0, M = 0,ans = 0;
  cin >> N >> M;
  vector<ll>A(N);
  rep(i,N){
    cin >> A[i];
  }
  sort(A.begin(), A.end()); //小さい順
  rep(i,M){
    ans += A[i];
  }
  cout << ans;
}

Measured memory_bytes: 3600
#include<stdio.h>
int main(void)
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if(a>b){
		printf("a > b\n");
	}
	if(a<b){
		printf("a < b\n");
	}
	if(a==b){
		printf("a == b\n");
	}
	return 0;
}

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

using namespace std;

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

    int N, T;
    cin >> N >> T;
    vector<int> sum(100010, 0);
    while (N--)
    {
        int l, r;
        cin >> l >> r;
        sum[l]++;
        sum[r]--;
    }
    int ret = sum[0];
    for (int i = 1; i <= T; i++)
    {
        sum[i] += sum[i - 1];
        ret = max(ret, sum[i]);
    }
    cout << ret << endl;
}



Measured memory_bytes: 3372