akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define MAX 100000
#define NIL -1

typedef struct{
  int parent;
  int left;
  int right;
}Data;

Data T[MAX];

void Preorder(int id){
  if(id==NIL)return;

  printf(" %d",id);
  
  Preorder(T[id].left);
  Preorder(T[id].right);
};
void Inorder(int id){
  if(id==NIL)return;

  Inorder(T[id].left);
  printf(" %d",id);

  Inorder(T[id].right);
};
void Postorder(int id){
  if(id==NIL)return;

  Postorder(T[id].left);
  Postorder(T[id].right);

  printf(" %d",id);
};

int main(){
  int i,j,id,n,child,root;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){ //?????????
    T[i].parent = T[i].left = T[i].right = NIL;
  }
  
  for(i=0;i<n;i++){ //parent
    scanf("%d",&id);
    for(j=0; j<2; j++){
      scanf("%d",&child);
      if(j==0){
	T[id].left = child;
      }
      else {
	T[id].right = child;
      }
      T[child].parent = id;
    }
  }

  for(i=0;i<n;i++){
    if(T[i].parent==NIL)root=i;
  }
  
  printf("Preorder\n");
  Preorder(root);
  printf("\n");
  
  printf("Inorder\n");
  Inorder(root);
  printf("\n");
  
  printf("Postorder\n");
  Postorder(root);
  printf("\n");

  return 0;
}

Measured memory_bytes: 616
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
//#include "toollib.h"
//#include "puzzle.h"
#define INT_MAX 2147483647
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#pragma warning (disable:4018)
#pragma warning (disable:4244)
#pragma warning (disable:4996)

using namespace std;
typedef long long int lint;


//***** Main Program *****

int main() {
	int n, q;
	cin >> n;
	vector<int> S(n);
	Loop(i, n) cin >> S[i];
	cin >> q;
	vector<int> T(q);
	Loop(i, q) cin >> T[i];
	int ret = 0;
	Loop(i, q) {
		int left = 0;
		int right = n;
		while (left < right) {
			int mid = (left + right) / 2;
			if (T[i] == S[mid]) {
				ret++;
				break;
			}
			if (T[i] < S[mid]) right = mid;
			else left = mid + 1;
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3268
//bismillahir rahmanir rahim
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
int main(){
	ll n,x,t,ans=0,i;
	cin>>n>>x>>t;
	i=1;
	while(n>=0){
		n=n-x;
		ans=ans+t;
		i++;
		if(n<=0)break;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3588
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	t := [3]string{"Sunny", "Cloudy", "Rainy"}
	s := next()
	for i := 0; i < 3; i++ {
		if s == t[i] {
			fmt.Println(t[(i+1)%3])
		}
	}
}


Measured memory_bytes: 640
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        char[][] data = new char[h][w];
        for (int i = 0; i < h; i++) {
            String tmpStr = sc.next();
            data[i] = tmpStr.toCharArray();
        }

        for (int i = 0; i < h+2; i++) {
            for (int j = 0; j < w+2; j++) {
                if (i == 0 || i == h+1 || j == 0 || j == w+1) {
                    System.out.print('#');
                } else {
                    System.out.print(data[i-1][j-1]);
                }
            }
            System.out.println();
        }
    }
}


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

using namespace std;

const int ma[] = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
int a[10], m, n;
typedef pair<int, int> ii;
int f[10001][11];
ii trace[10001][11];

struct Comp {
	bool operator()(int i, int j) {
		return ma[i] < ma[j] || (ma[i] == ma[j] && i > j);
	}
} cmp;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= m; ++i)
		cin >> a[i];
	sort(a + 1, a + 1 + m);
	memset(f, -1, sizeof f);
	for (int i = 0; i <= m; ++i)
		f[0][i] = 0;
	for (int s = 1; s <= n; ++s)
		for (int j = 1; j <= m; ++j) {
			if (f[s][j - 1] != -1) {
				f[s][j] = f[s][j - 1];
				trace[s][j] = ii(s, j - 1);
			}
			if (s - ma[a[j]] >= 0 && f[s - ma[a[j]]][j] >= 0) {
				if (f[s][j] <= f[s - ma[a[j]]][j] + 1) {
					f[s][j] = f[s - ma[a[j]]][j] + 1;
					trace[s][j] = ii(s - ma[a[j]], j);
				}
			}
		}
	string ans;
	int j = 1;
	for (int t = 2; t <= m; ++t)
		if (f[n][t] >= f[n][j])
			j = t;
	while (n) {
		ii st = trace[n][j];
		if (f[n][j] == f[st.first][st.second] + 1)
			ans += to_string(a[j]);
		n = st.first;
		j = st.second;
	}
//	reverse(ans.begin(), ans.end());
	cout << ans;
	return 0;
}


Measured memory_bytes: 1536
n = int(input())
b_list = list(map(int, input().split()))

score = b_list[0] + b_list[n-2]

if n > 2:
	for val in range(n-2):
		c_list = [b_list[val], b_list[val+1]]
		score += min(c_list)
else:
	pass

print(score)

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

int main(){

int N, K;
cin >> N >> K;
ll sum=0;
for(ll k=K; k<=N+1; k++){
    ll l=(k-1)*k/2, r=(N-k+1+N)*k/2;
    sum += r-l+1;
}

cout << sum%1000000007 << endl;


}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define PI acos(-1)
#define eq(x,y) (fabs((x)-(y)) < eps)
#define debug(x) cerr<<x<<endl;
#define endl "\n"
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const int nmax=1e5+10;
const int eps=1e-8;


int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
    //cout.tie(NULL);
    int n;
    cin>>n;
    int m=n, c=0;

    while(m!=0)
    {
        m/=10;
        c++;
    }

    if(c%2==0)
        c--;

    if(c==1)
        cout<<min(n,9)<<endl;
    else if(c==3)
        cout<<min(n,999)-90<<endl;
    else if(c==5)
        cout<<min(n,99999)-9090<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
 

int main() {
    int a,b;
    cin >> a >> b;
    cout << a * b << endl;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int nmax=100005;
ll par[nmax];
ll size[nmax];
void init(int x){
  for(int i=0;i<x;i++){
    par[i]=i;
    size[i]=1;
  }
}
ll root(int x){
  if(par[x]==x){
    return x;
  }
  else{
    return par[x]=root(par[x]);
  }
}
void unite(int x,int y){
  x=root(x);
  y=root(y);
  if(x==y){
    return;
  }
  else{
    if(size[y]<size[x]){
      swap(x,y);
    }
    size[y]+=size[x];
    par[x]=y;
  }
}
ll siz(ll x){
  return size[root(x)];
}
int main(){
  ll n,m;
  cin >> n >> m;
  vector<ll> a(m),b(m);
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i];
    a[i]--,b[i]--;
  }
  init(n);
  vector<ll> ans(m+1);
  ans[m-1]=n*(n-1)/2;
  for(int i=m-2;i>=0;i--){
    if(root(a[i+1])==root(b[i+1])){
      ans[i]=ans[i+1];
    }
    else{
      ans[i]=ans[i+1]-siz(a[i+1])*siz(b[i+1]);
    }
    unite(a[i+1],b[i+1]);
  }
  for(int i=0;i<m;i++){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define u128 __int128
#define pb push_back

#define N 200010
#define MOD 1000000007


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
   cout.precision(10);

   string s, t;
   cin >> s >> t;
   int n1 = s.size(), n2 = t.size();
   set<int> g[26] = {};

   for (int i = 0; i < n1; ++i)
   {
      g[s[i] - 'a'].insert(i);
   }

   for (int i = 0; i < n2; ++i)
   {
      if(g[t[i] - 'a'].size() == 0)
      {
         cout << -1;
         return 0;
      }
   }
   ll last = *g[t[0]  - 'a'].begin(), k = 0;
   for (int i = 1; i < n2; ++i)
   {
      auto m = g[t[i] - 'a'].upper_bound(last);
      if(m == g[t[i] - 'a'].end())
      {
         k++;
         last = *g[t[i] - 'a'].begin();
      }
      else
         last = *m;

   }

   cout << k * n1 + last + 1;
   return 0;	
}

      // while(b)
      // {
      //    if(b & 1)
      //    {
      //       an = (an * a);
            
      //       if(an > 1e18) 
      //          an /= 1e18;
      //    }
      //    a = (a * a);
      //    if(a > 1e18)
      //       a /= 1e18;
      //    b >>= 1;
      // }


Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> P;

template <typename T> T gcd(T x, T y) { return( y ? gcd(y, x % y) : x); }
template <typename T> T lcm(T x, T y) { return( x / gcd(x, y) * y); }
template <typename T> void printVec(vector<T> &vec) {
  cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    cout << *it << " ";
  }
  cout << endl;
}
char data1[] = "abcdefghijklmnopqrstuvwxyz";
// 1000000000000001
int main() {
  ll n;

  cin >> n;
  ll x1;
  vector <int> d(16);
  int counter = 0;
  while (true) {
    n = n - 1;
    x1 = n / 26;
    // cout << "counter = " << counter << ", ";
    // cout << "x1 = " << x1 << endl;
    if (x1 > 0) {
      d[counter] = n % 26;
      counter = counter + 1;
      n = x1;
    } else {
      // d[counter] = n - n / 26 * 26;
      d[counter] = n % 26;
      counter = counter + 1;
      // d[counter + 1] = n / 26;
      break;
    }
  }
   // printVec(d);
  for (int i = counter - 1; i >= 0; i--) {
    cout << data1[d[i]];
  }
  cout << endl;
	return 0;
}


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

int par[100010];

int parent(int i){
  if(par[i]==i) return i;
  else{
    return par[i]=parent(par[i]);
  }
}

int main(){
  int N,M; cin >> N >> M;
  
  for(int i=0; i<N; i++) par[i]=i;

  for(int i=0; i<M; i++){
    int A,B; cin >> A >> B;
    A--; B--;
    int pa=parent(A), pb=parent(B);
    if(pa==pb) continue;
    else{
      if(pa>pb){
        par[pa]=pb;
      }else{
        par[pb]=pa;
      }
    }
  }
  
  set<int> S;
  for(int i=0; i<N; i++){
    S.insert(parent(par[i]));
  }
  cout << S.size()-1 << endl;
}

Measured memory_bytes: 7840
n=int(input())
a=0
w=0
t=0
r=0
for i in range(n):
    s=input()
    if s=="AC":
        a+=1
    elif s=="WA":
        w+=1
    elif s=="TLE":
        t+=1
    else:
        r+=1
print("AC","x",a)
print("WA","x",w)
print("TLE","x",t)
print("RE","x",r)


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

int main() {
    int n,m;
    cin >> n >> m;
    int x = -1,y = -1,z = -1;
    for(int i=0; i<=n; i++){
        for(int j=0; j<=n; j++){
            int k = n - i - j;
            if(k >= 0 && 10000*i + 5000*j + 1000*k == m){
                x = i; y = j; z = k;
                break;
            }
        }
    }
    cout << x << " " << y << " " << z << endl;
}

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

int A[100005], B[100005];

int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main() {
    int N, X;
    scanf("%d %d", &N, &X);
    A[0] = X;
    for (int i = 1; i <= N; i++) scanf("%d", &A[i]);
    sort(A, A+N+1);
    for (int i = 0; i < N; i++) B[i] = A[i+1] - A[i];
    int ans = B[0];
    for (int i = 1; i < N; i++) {
        ans = gcd(ans, B[i]);
    }
    printf("%d\n", ans);
    return 0;
}

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

using namespace std;

int main(){
    string s;
    int k;
    cin >> s;
    cin >> k;

    vector<string> data;

    for(int i = 0; i < s.size(); ++i){
        for(int j = 1; j <= k; ++j){
            if(i + j - 1 < s.size()){
                data.push_back(s.substr(i,j));
            }
        }
    }

    sort(data.begin(), data.end());

    unique(data.begin(),data.end());

    cout << data[k - 1] << endl;

    return 0;
}

Measured memory_bytes: 4336
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.TreeSet;
public class Main {
  public static void main(String[] args) {
    Main m = new Main();
    m.run();
  }
  private void run() {
    int n = 0;
    int[] a = new int[0];
    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
      n = Integer.parseInt(br.readLine());
      a = Arrays.stream(br.readLine().split("\\s+"))
        .mapToInt(Integer::parseInt).toArray();
    } catch (IOException e) {
      e.printStackTrace();
    }
    TreeSet<Integer> s = new TreeSet<>();
    s.add(0);
    s.add(n+1);
    int[] b = new int[n];
    for (int i=0;i<n;i++) b[a[i]-1] = i+1;
    long m = 0L;
    for (int i=0;i<n;i++) {
      s.add(b[i]);
      m += (long)(i+1)*(long)(b[i]-s.lower(b[i]))*(long)(s.higher(b[i])-b[i]);
    }
    System.out.println(m);
  }
}

Measured memory_bytes: 51804
/*
・うちしあわせぇっしあわせぇっ！！　しあわせみるくがでちゃううっ！！
・やっやあぁらめえっ、たっ…たまぁ…！！　タマタマはぁ…あはぅっ！！
　そっそこいじられると…く…なるぅ…ブリジットのちんぽみるくこくなっちゃうんでしゅぅッ！！
　んあっ！！　んあおっ！！　つっ強いよおぉたまもみつよいのおっ！！！
・あﾞあっでるっ…！！　たまみるくでるっ！！　でっでるうっブリジットのこくまろみるくぅ！！
　おしりほられて変態みるくがきちゃうのおぉっ！！！！！
・ブリジットぴょんぴょんすきっ、ぴょんぴょんちゅき～～っ！
　みっ見てぇっ！！　でるよぉ精子ッ、ブリジットのあかちゃん汁がでるよおおッッ！！
・ブリジットきもちいすぎてバンザイしちゃうぅっ　バンザイっ、ばんじゃいっばんじゃいﾞっ
　ぱゃんにﾞゃんじゃんじゃいぃぃっ！！
*/
#include <iostream>
#include <math.h>
#include <cstring>
using namespace std;
 
bool field[10][10000];
bool binary[10];
long flag;
int r,c,ans;
 
long FlagMake(void);
void Count(int area);
 
int main(void){
    cin >> r >> c;
    while(r!=0&&c!=0){
        for(long i=0;i<r;i++){
            for(long j=0;j<c;j++){
                cin >> field[i][j];
            }
        }
 
        ans=0;
        memset(binary,0,sizeof(binary));
 
        for(long i=0;i<pow(2,r);i++){
            if(i!=0){Count(0);}
            FlagMake();
            if(ans<flag)ans=flag;
        }
 
        cout << ans << endl;
 
        cin >> r >> c;
    }
}
 
long FlagMake(){
    int low,high;
     
    flag=0;
     
    for(long i=0;i<c;i++){
         
        low=0;high=0;
         
        for(int j=0;j<r;j++){
            if(binary[j]==1){
                if(field[j][i]==0){high++;}
                else{low++;}
            }
            else{
                if(field[j][i]==0){low++;}
                else{high++;}
            }
        }
        if(low>high){flag+=low;}
        else{flag+=high;}
    }
    return flag;
}
 
void Count(int area){
    if(binary[area]==0){binary[area]=1;}
    else{
        binary[area]=0;
        Count(area+1);
    }
}


Measured memory_bytes: 3356
#include <bits/stdc++.h>
using namespace std;
int n, m;

int main() {
	while(scanf("%d %d", &n, &m) != EOF) {
		int ans = 0;
		if(m % n == 0) ans = m / n;
		else {
			int t = m / n;
			for(int i = 1; i <= t; i++) {
				if(m % i == 0) ans = max(ans, i);
			}
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>

using namespace std;

int main() {
	int N, W;
	cin >> N >> W;
	map<int, long long> mp;
	vector<int> weight(N);
	vector<int> value(N);
	for (int i = 0; i < N; ++i) {
		cin >> weight[i] >> value[i];
	}
	vector<vector<long long>> dp(N + 1, vector<long long>(W + 1, 0));

	for (int i = 0; i < N ; ++i) {
		for (int sum_w = 0; sum_w <= W; ++sum_w) {
			if (sum_w + weight[i] <= W) {
				dp[i + 1][sum_w] = max(dp[i][sum_w], dp[i][sum_w + weight[i]] + value[i]);
			}
			else {
				dp[i + 1][sum_w] = dp[i][sum_w];
			}
			//cout << dp[i + 1][sum_w] << "\t";
		}
		//cout << endl;
	}

	cout << dp[N][0] << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

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

    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans1 = a * c;
    ll ans2 = b * d;
    ll ans3 = b * c;
    ll ans4 = a * d;

    ll largest= (ans1>ans2)?(ans1>ans3)?(ans1>ans4)?ans1:ans4:(ans3>ans4)?ans3:ans4:(ans2>ans3)?
            (ans2>ans4)?ans2:ans4:(ans3>ans4)?ans3:ans4;
    cout << largest << "\n";
}




















Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int a[10];
    for(int i = 0; i < 10; i++){
        cin >> a[i];
    }
    
    sort(a, a + 10,greater<int>());
    
    cout << a[0] << endl;
    cout << a[1] << endl;
    cout << a[2] << endl;

}

Measured memory_bytes: 1176
import bisect
import collections
import copy
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
MOD = 10**9+7

N,M,P = map(int,(input().split()))
line = []
for i in range(M):
    a,b,c = map(int,(input().split()))
    line.append([a-1,b-1,-c+P])

min_distance = [float("inf")]*N # min_distance[i] は始点から街iまでの最短距離
min_distance[0] = 0 # 始点から始点への最短距離は0とする

update = False
for _ in range(N):
    for s,g,d in line: # [s,g,d] = [道路の始点,道路の終点,道路の長さ] について、すべての道路を見る
        if min_distance[s] != float("inf") and min_distance[s] + d < min_distance[g]: # 最短経路が確立されている街から伸びる道路を通ることで、距離を短くできるならば、
            min_distance[g] = min_distance[s] + d # 最短距離を上書きする
            update = True
    if not update:
        break
else:
    for _ in range(N):
        for s,g,d in line: # [s,g,d] = [道路の始点,道路の終点,道路の長さ] について、すべての道路を見る
            if min_distance[s] != float("inf") and min_distance[s] + d < min_distance[g]: # 最短経路が確立されている街から伸びる道路を通ることで、距離を短くできるならば、
                min_distance[g] = -float("inf")
                if g == N-1:
                    print(-1)
                    exit()

print(max(-min_distance[N-1],0))

#print(min_distance)

Measured memory_bytes: 75920
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

int main(){
int n;
int i,j,k;

cin >> j;
vector<int> V(j);          //???????????????????¢????

for(i=0;i<j;i++){
    cin >> V[i];              //????´?????????\???
}

for(i=j-1;i>=0;i--){
  cout << V[i];         //?????????????????????????????¨???
if(i!=0){
  cout << ' ';
}
}
cout << endl;

return 0;

}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int a[200005];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, k;
    cin >> n >> k;
    for (int i=0; i<n; i++)
        cin >> a[i];

    int l = 1, r = 1e9;
    while (l < r) {
        int m = (l + r) / 2, cuts = 0;
        for (int i=0; i<n; i++) {
            cuts += (a[i] + m - 1) / m - 1;
            if (cuts > k)
                break;
        }
        if (cuts > k)
            l = m + 1;
        else
            r = m;
    }
    cout << l << "\n";

    return 0;
}


Measured memory_bytes: 4288
package main

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

func main() {
  n := NextInt()
  a := NextIntArray()
  sort.Ints(a)
  if a[n-1]-a[0] > 1 {
    fmt.Println("No")
    return
  }
  l,u := 0,n
  for u-l > 1 {
    m := (u+l)/2
    if a[m] == a[0] {
      l = m
    } else {
      u = m
    }
  }
  if (u == n && (2*a[0] <= n || a[0] == n-1)) ||
  (u != n && (u < a[u] && 2*(a[u]-u) <= n-u)) {
    fmt.Println("Yes")
  } else {
    fmt.Println("No")
  }
}

var reader = bufio.NewReaderSize(os.Stdin,1000000)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextInt() int {
  n,_ := strconv.Atoi(NextLine())
  return n
}
func NextIntArray() []int {
  s := strings.Split(NextLine()," ")
  a := make([]int,len(s))
  for i:=0;i<len(s);i++ { a[i],_ = strconv.Atoi(s[i]) }
  return a
}

Measured memory_bytes: 4864
#include<iostream>
#include<vector>
#include<sstream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

ll n,p;
string m;

int ctoi(char c){
  if('a'<=c && c<='z')return c-'a' + 36;
  if('A'<=c && c<='Z')return c-'A' + 10;
  return c-'0';
}

int main(){
  cin >> n;
  ll res = 0;
  rep(i,n){
    cin >> p >> m;
    ll val = 0;
    ll k = 1;
    for(int j=m.size()-1;j>=0;j--){
      val += k * ctoi(m[j]);
      k *= p;
    }
    res ^= val;
  }
  if(res==0)cout << "lose\n";
  else cout << "win\n";
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,ans=0;
  cin >> n;
  for(long long i=1;i<=sqrt(n);i++){
    if(i==n)break;
    if(n%i==0){
      long long m=n/i-1;
      if(n/m==n%m){
        ans+=m;
      }
      if(i*i!=n){
        m=i-1;
        if(m>0 and n/m==n%m){
          ans+=m;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int k; scanf("%d", &k);
	REP(i, k) printf("ACL");
}


Measured memory_bytes: 3792
import sys
def input(): return sys.stdin.readline().rstrip()

def gcd(m, n):
    if n == 0:
        return m
    else:
        return gcd(n, m % n)

def main():
    _ = int(input())
    A = tuple(map(int, input().split()))

    ans = A[0]
    for a in A[1:]:
        ans = gcd(ans, a)
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 14608
#![allow(unused_imports)]
#![allow(unused_variables)]
use proconio::input;
use proconio::marker::*;
use std::cmp::{min, max};
use std::collections::{HashSet, HashMap, BinaryHeap};

fn main() {
    input! {
        a: u32,
        b: u32,
        c: u32,
        d: u32,
    }
    let ans = if (c + b - 1) / b <= (a + d - 1) / d {"Yes"} else {"No"};
    println!("{}", ans);
}


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

int main()
{
    string a, b;
    cin >> a >> b;

    int x = stoi(a + b);
    int i = 1;
    while(i * i < x)
        ++ i;
    if(i * i == x)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	long long int x;
	cin >> x;
	long long int ans = x/500*1000+(x%500)/5*5;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n,x=map(int,input().split())
l=list(map(int,input().split()))
l=sorted([abs(i-x) for i in l],reverse=True)

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

if n!=1:
    p=gcd(l[0],l[1])
    for i in l[2:]:
        p=gcd(i,p)
else:
    p=l[0]
print(p)

Measured memory_bytes: 14252
N = int(input())
A = map(int, input().split())
var0 = 0
var1 = 0
var2 = 0

for a in A:
    if a % 4 == 0:
        var2 += 1
    elif a % 2 == 0:
        var1 += 1
    else:
        var0 += 1

var1 %= 2
ans = 'Yes' if var2 >= var1 + var0 - 1 else 'No'
print(ans)


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

typedef long long ll;
const int N = 310;
int n, m, res = 10000000, maxx, cnt[N], tmp, x, pos;
vector <int> a[N];
int main()
{
//    #define file "agc018"
//    freopen(file".inp" ,"r" ,stdin);
//    freopen(file".out" ,"w" ,stdout);
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n >> m;
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= m; ++j) {
            cin >> tmp;
            a[i].push_back(tmp);
        }
    }
    while (!a[1].empty()) {
//        for(int i = 1; i <= n; ++i) {
//            for(int j = 0; j < a[i].size(); ++j) {
//                cout << a[i][j] << " ";
//            }
//                cout << "\n";
//
//        }
//        cout << "\n";
        maxx = 0;
        for(int i = 1; i <= m; ++i) cnt[i] = 0;
        for(int i = 1; i <= n; ++i)
        {
            cnt[a[i][0]]++;
            maxx = max(cnt[a[i][0]], maxx);
        }
        for(int i = 1; i <= n; ++i)
            if (maxx == cnt[a[i][0]]) {
                    x = a[i][0];
                    break;
            }
//        cout << x << " " << maxx << "\n";
        for(int i = 1; i <= n; ++i)
        {
            for(int j = 0; j < a[i].size(); ++j)
                if (a[i][j] == x) {
                    pos = j;
                    break;
                }
//            cout << i << " " << pos << "\n";
            if (!a[i].empty()) a[i].erase(a[i].begin() + pos);
        }
        res = min(res, maxx);
    }
    cout << res;
    return 0;
//    vector<int> v;
//    for(int i = 1; i <= 4; ++i) v.push_back(i);
//    v.erase(v.begin() + 0);
//    for(int i = 0; i < v.size(); ++i) cout << v[i] << " ";
}
//10 7
//2 7 6 4 5 3 6
//1 4 1 4 6 7 3
//1 5 1 1 2 4 3
//7 1 4 2 5 3 3
//1 7 1 1 6 7 7
//6 7 5 4 4 7 2
//1 7 7 7 2 7 4
//1 5 4 5 2 5 1
//7 7 5 3 7 4 1
//1 5 6 3 2 6 7



Measured memory_bytes: 896
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll ss,s;
int main(){
	ll n;
	scanf("%lld",&n);
	rep(i,0,n){
		ll t;
		scanf("%lld",&t);
		s+=t;
		ss+=t*t;
	}
	printf("%lld",(s*s-ss)/2);
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int x = 'A' - 'a';
            string a = str[0][0].ToString().ToUpper();
            string b = str[1][0].ToString().ToUpper();
            string c = str[2][0].ToString().ToUpper();
            Console.WriteLine("{0}{1}{2}", a, b,c);
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#include<bits/stdc++.h>
using namespace std;
#define Jewel ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define M 10005
int main()
{
    Jewel;
    string s, t, c;
    int a, b;
    cin>>s>>t>>a>>b>>c;
    if(c==s)
        a--;
    else if(c==t)
        b--;
    cout<<a<<' '<<b<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001; // > 10^9
const int MOD = (int)1e9 + 7;
const ll INFLL = 1001001001001001001;  // > 10^18
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    int n,k; cin >>n>>k;
    vector<int> a(n); rep(i,n) cin >> a[i];

    sort(a.begin(), a.end(), greater<int>());

    int ng = n;
    int ok = -1;
    while (abs(ok-ng)>1) {
        int i = (ok+ng)/2;
        int mem = a[i];
        a.erase(a.begin()+i);
        vector<vector<bool> > dp(n, vector<bool>(k, false));
        dp[0][0] = true;
        for (int j = 0; j < n-1; j++) {
            for (int l = 0; l < k; l++) {
                dp[j+1][l] = (dp[j+1][l] || dp[j][l]);
                if (l - a[j] >= 0) {
                    dp[j+1][l] = (dp[j+1][l] || dp[j][l - a[j]]);
                } 
            }
        }
        bool ans = false;
        for (int l = 0; l < k; l++) {
            if (k - mem <= l) {
                ans = (ans || dp[n-1][l]);
            } 
        }
        if (ans) {
            ok = i;
        } else {
            ng = i;
        } 
        a.insert(a.begin()+i, mem);
    }

    cout << n - (ok+1) << endl;
    
    return 0;
}




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

const int MOD = 1e9 + 7;

int div_cnt(int a) {
  int cnt = 0;
  while (a % 100 == 0) {
    ++cnt;
    a /= 100;
  }
  return cnt;
}

int ModPow(int x, int n, int m){
  int res = 1;
  while (n > 0) {
    if (n % 2 == 0) {
      x = (x * x) % m;
      n /= 2;
    } else {
      res = (res * x) % m;
      --n;
    }
  }
  return res;
}

int main() {
  int d, n;
  cin >> d >> n;
  int x = 0;

  while (n > 0) {
    x += ModPow(100, d, MOD);
    if (div_cnt(x) == d) --n;
  }
  cout << x << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int a[1030];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	for(int i=1;i<=n;i++){
		printf("node %d: key = %d, ",i,a[i]);
		if(i!=1)printf("parent key = %d, ",a[i/2]);
		if(i*2<=n)printf("left key = %d, ",a[2*i]);
		if(i*2+1<=n)printf("right key = %d, ",a[2*i+1]);
		puts("");
	}
}


Measured memory_bytes: 2044
#include <stdbool.h>
#include <stdio.h>

int main()
{
	int n, m;
	int ns[100], ms[100];
	int ansn, ansm;
	int sumn, summ;
	while (true) {
		sumn = 0, summ = 0, ansn = 10000, ansm = 10000;
		scanf("%d%d", &n, &m);
		if (n == 0 && m == 0)
			break;

		for (int i = 0; i < n; i++) {
			scanf("%d", &ns[i]);
			sumn += ns[i];
		}
		for (int i = 0; i < m; i++) {
			scanf("%d", &ms[i]);
			summ += ms[i];
		}
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				if ((ns[i] - ms[j]) * 2 == sumn - summ && ns[i] + ms[j] < ansn + ansm)
					ansn = ns[i], ansm = ms[j];
		if (ansn + ansm < 10000)
			printf("%d %d\n", ansn, ansm);
		else
			printf("-1\n");
	}
	return 0;
}



Measured memory_bytes: 2032
package main

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

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	x := io.NextInt()
	ans := 0
	ans += x / 500 * 1000
	x %= 500
	ans += x / 5 * 5
	x %= 5
	io.Println(ans)
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


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

 #define PI 3.14159265358979323846264338327950L

 int main(void) {
 int a, b, h, m;
 scanf("%d%d%d%d", &a, &b, &h, &m);

long double rad = PI * 2 * (
 (long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long
double)m / 60.0);

 long double rsq = (long double)(a * a + b * b) - (long double)(2 * a *
b) * cosl(rad);

 printf("%20.20Lf\n", sqrtl(rsq));

 return 0;
 }

Measured memory_bytes: 2520
#include<bits/stdc++.h>
using namespace std;
int a,b,c,n,r;
string s;
int main(){
    cin>>n;
    cin>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='R')r++;
        if(s[i]=='B')b++;
    }
    if(r>b)cout<<"Yes"<<endl;
    if(r<=b)cout<<"No"<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[100000],b[100000],c[100000],cnt[100000],cnt2[100000];
int main(void){
	long long i,j,n,sum;
	cin>>n;
	for(i=0;i<n;i++) cin>>a[i];
	for(i=0;i<n;i++) cin>>b[i];
	for(i=0;i<n;i++) cin>>c[i];
	sort(a,a+n); sort(b,b+n); sort(c,c+n);
	for(i=0;i<n;i++) cnt[i]=0,cnt2[i]=0;;
	i=0; j=0; 
	while(1){
		if(i==n)break;
		if(a[j]<b[i]&&j<n){
			j++;
			cnt[i]++;
		}
		else {
			if(i!=0) cnt[i]=cnt[i]+cnt[i-1];
			i++;
		}
	}
//	for(i=0;i<n;i++) cout<<cnt[i]<<endl;
	i=0; j=0; 
	while(1){
		if(i==n)break;
		if(b[j]<c[i]&&j<n){
			cnt2[i]+=cnt[j];
			j++;
		}
		else {
			if(i!=0) cnt2[i]=cnt2[i]+cnt2[i-1];
			i++;
		}
	}
//	for(i=0;i<n;i++) cout<<cnt2[i]<<endl;
	sum=0;
	for(i=0;i<n;i++) sum+=cnt2[i];
	cout<<sum<<endl;
	return 0;
}

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

using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i < (n); --i)
#define all(x) (x).begin(), (x).end()
#define gsort(x, n) sort((x), (x + n) greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

signed main()
{
   cin.tie(nullptr);
   ios_base::sync_with_stdio(false);

   int h,w,cnt=0;
   cin>>h>>w;

   if(h == 1 || w == 1){
      cout<<1<<'\n';
      return 0;
   }
   if((h*w) % 2 == 0){
      cout<<(h*w)/2<<'\n';
   }else cout<<(h*w)/2+1<<'\n';
}

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

int main() {
  
  int n;
  cin >> n;
  
  vector<int> d(n);
  REP(i,n) {
    cin >> d[i];
  }
  
  int ans = 0;
  REP(i,n) {
    REP(j,n) {
      if(i != j) ans += d[i]*d[j];
    }
  }
  
  cout << ans/2 << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


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

    int n, k;
    cin >> n >> k;
    if(n == 1) cout << 0 << endl;
    else cout << n%k << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int A[1000000],n;

int binarysearch(int key){
    int left=0;
    int right=n;
    int mid;
    while(left<right){
        mid=(left+right)/2;
        if(key == A[mid])
            return 1;
        if(key > A[mid])
            left=mid+1;
        else 
            right=mid;
    }
    return 0;
}

int main(void){
    int i,q,k,sum=0;

    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&A[i]);

    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d",&k);
        if(binarysearch(k))
            sum++;
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 988
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define vi vector<ll>
#define vvi vector<vi>
#define Q queue<ll>
#define DQ deque<ll> 
#define pb push_back
#define pf push_front
#define popf pop_front
#define popb pop_back
#define mp make_pair
#define mt make_tuple
#define f first
#define s second
#define ub upper_bound
#define lb lower_bound
#define loop(x,y,z) for(ll i=x; i<=y; i+=z)
#define rloop(x,y,z) for(ll i=x; i>=y; i-=z)
#define all(x) x.begin(), x.end()
#define sum(x) accumulate(all(x),0LL)
#define minE(x) *min_element(all(x))
#define maxE(x) *max_element(all(x))
#define mem(a,b) memset(a,b,sizeof(a))
#define watch(x) cout<<(#x)<<" is "<<x
#define endl "\n"

ll gcd(ll a, ll b){
	return (!b)?a:gcd(b,a%b);
}

void display(vi &v,string c){
	for(auto x:v) cout<<x<<c;
}

int main(){
	IOS
	ll a,b,c;
	cin>>a>>b>>c;
	cout<<max(0LL,b+c-a);
	return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class ERedScarf {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        in>>N;
        vc<int> A(N), pref(N+1, 0), suff(N+1, 0);
        for(auto& a : A) in>>a;
        REP(i, N) pref[i+1] = pref[i] ^ A[i];
        for(int i=N-1;0<=i;--i) suff[i] = suff[i+1] ^ A[i];
        vc<int> ans(N);
        REP(i, N) ans[i] = pref[i] ^ suff[i+1];
        for(auto& a : ans) out<<a<<' ';
        out<<'\n';
    }
};


int main() {
	ERedScarf solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 6188
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;

int main(){

    int n; cin >> n;

    int a[n+1], a_sorted[n+1];
    for(int i=1; i<n+1; i++){
        cin >> a[i];
        a_sorted[i] = a[i];
    }

    sort(a_sorted+1, a_sorted+n+1, greater<int>());

    if(a_sorted[1] == a_sorted[2]){
        for(int i=1; i<n+1; i++){
            cout << a_sorted[1] << endl;
        }
    }
    else{
        for(int i=1; i<n+1; i++){
            if(a[i] == a_sorted[1]){
                cout << a_sorted[2] << endl;
            }
            else{
                cout << a_sorted[1] << endl;
            }
        }
    }

    return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (int i = j; i < (n); i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1e9;

int main(){

  int n;cin>>n;

  map<int,int>mp;

  rep(i,2,n+1){
    int d=i;
    rep(j,2,d+1){
      while(d%j==0){
        d/=j;
        mp[j]++;
      }
    }
  }

  ll ans=1;
  for(map<int,int>::iterator itr=mp.begin();itr!=mp.end();itr++){
    ans*=((itr->second)+1);
    ans%=mod;
  }

  out(ans);


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m;i>n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
   lli A,B,C,N,M,K,L,R,sum=0,num=0;
   long double ans;
   cin >> N >> M >> K;
   if(!K)ans=(double)(M-1)/N;
   else ans=(double)(M-1)*2*(N-K)/N/N;
   HpOut(ans);
}


Measured memory_bytes: 256
main(){
	int s[9000],n,m,t,f,i;
	while(scanf("%d%d",&n,&m),n)
		for(i=t=f=1;i<=n+m;i++){
			scanf("%d",&s[i]);
			if(i>n)
				if(t+=s[t+=s[i]],t>=n&f==1)
					printf("%d\n",i-n,f=0);
			
		}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
int main(){
    int n,r;
    cin>>n>>r;
    if (n<10)
    {
        /* code */
        cout<<r+100*(10-n)<<endl;
    }
    else
    {
        cout<<r<<endl;
    }
    


}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;

bool comp(P a, P b) {
	return a.second < b.second;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	string s;
	cin >> s;
	
	int a = 0, b = 0;
	rep(i, sz(s)) {
		if (s[i] == '1') a++;
		else if (s[i] == '0') b++;
	}

	out(min(a, b) * 2);

	return 0;
}

Measured memory_bytes: 512
fn main(){
    let ab: Vec<usize> = read_vec();
    let a = ab[0];
    let b = ab[1];
    if a > 12 {
        println!("{}", b);
    } else if a > 5 {
        println!("{}", b / 2);
    } else {
        println!("{}", 0);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

long long GCD(long long a, long long b) {
    if(b == 0)
        return a;
    else
        return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}
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;
}
int main() {
    int N;
    cin >> N;
    vector<pair<int, int>> ak(N);
    vector<pair<int, int>> ao(N);
    rep(i, 0, N) { cin >> ak[i].first >> ak[i].second; }
    rep(i, 0, N) { cin >> ao[i].first >> ao[i].second; }
    sort(ao.begin(), ao.end());
    int res = 0;
    rep(i, 0, N) {
        int maxy = -1;
        int maxj = -1;
        rep(j, 0, N) {
            if(ak[j].first < ao[i].first && ak[j].second < ao[i].second &&
               maxy < ak[j].second) {
                maxj = j;
                maxy = ak[j].second;
            }
        }
        if(maxj != -1) {
            ak[maxj].first = 1000;
            ak[maxj].second = 1000;
            res++;
        }
    }
    cout << res << endl;
}


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

int main() {

	int S, h, m, s;
	cin >> S;

	h = S / 3600;
	m = (S % 3600) / 60;
	s = S % 60;

	cout << h << ":" << m << ":" << s << endl;

	return 0;
}


/*計算の仕組み*/

  // h = S / 3600の計算
  // 時間 ＝ 全体の秒 ÷ 3600　例： 3748[秒] ÷ 3600[秒] 　
  // ※ 注意：小数は切り捨て　➡　整数の型で宣言しているから！！　よって1[時間]になる

  // m = (S % 3600) / 60の計算
  // 分 ＝ ( 全体の秒　％　3600 ）÷ 60 　例：( 3748[秒] ％ 3600[秒] ) ÷　60[秒]　
  // ※ 注意：％は余りを求める　3748[秒] ％ 3600[秒] ＝ 128[秒] となる後は60[秒]で割る　よって2[分]になる

  // s = S % 60の計算
  // 秒 ＝ 全体の秒　％　60  例：3748[秒] ％ 60[秒]　
  // ※ 注意：％は余りを求める　よって28[秒]になる


Measured memory_bytes: 3112
#include <iostream>

bool solve(int remain) {
    if (remain == 0) {
        return true;
    } else if (remain < 0) {
        return false;
    } else {
        return solve(remain-4) || solve(remain-7);
    }
}

int main() {
    int N;
    std::cin >> N;
    
    if (solve(N))
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;
}

Measured memory_bytes: 256