akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <queue>
#include <utility>

using namespace std;
typedef pair<int, int> P;
const int MAX_N = 400;

const int di[] = {1, 0, -1, 0};
const int dj[] = {0, 1, 0, -1};

bool color[MAX_N][MAX_N];
int H, W;

char ch[MAX_N + 1];

void input(){
    cin >> H >> W;
    for (int i=0; i<H; ++i) {
        scanf("%s", ch);
        for (int j=0; j<W; ++j) {
            color[i][j] = (ch[j] == '#');
        }
    }
}

bool isin_(int i, int j) {
    return i>=0 && i<H && j>=0 && j<W;
}

bool check_(int i, int j, int d) {
    int ni = i + di[d];
    int nj = j + dj[d];
    if(!isin_(ni, nj)) return false;
    if(color[i][j] == color[ni][nj]) return false;
    return true;
}

bool used[MAX_N][MAX_N];

long long solve(){
    long long ans = 0;
    long long b = 0, w = 0;
    for (int i=0; i<H; ++i) {
        for (int j=0; j<W; ++j) {
            if (used[i][j]) continue;
            b = 0;
            w = 0;
            queue<P> que;
            used[i][j] = true;
            que.push(P(i, j));
            while(!que.empty()) {
                P p = que.front();
                que.pop();
                int ci = p.first, cj = p.second;
                if(color[ci][cj]) b++;
                else w++;
                for(int d=0; d<4; ++d) {
                    if(!check_(ci, cj, d)) continue;
                    int ni = ci + di[d], nj = cj + dj[d];
                    if(used[ni][nj]) continue;
                    used[ni][nj] = true;
                    que.push(P(ni, nj));
                }
            }
            ans += b * w;
        }
    }
    return ans;
}

int main(){
    input();
    long long ans = solve();
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; i < t; ++j)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int main() {
  int N,W;
  cin >> N >> W;
  int weight[N];
  int value[N];
  rep(i,N) {
    cin >> weight[i] >> value[i];
  }
  ll dp[N][100010];
  rep(i,N){
    rep2(j,100010){
      dp[i][j] = INF;
    }
  }
  dp[0][0] = 0;
  dp[0][value[0]] = weight[0];
  srep(i,1,N) {
    rep2(j,100010) {
      if(dp[i-1][j] != INF ){
        dp[i][j] = min(dp[i-1][j],dp[i][j]);
      }
      if(j - value[i] > -1 && dp[i-1][j - value[i]] != INF) {
        dp[i][j] = min(dp[i-1][j - value[i]] + weight[i] ,dp[i][j]);
      }
      //cout << "i : " << i << " j : "  << j << "  dp : " << dp[i][j] << endl;
    }
  }
  int k = 100009;
  while(true){
    if(dp[N-1][k] <= W ){
      cout << k << endl;
      return 0;
    }
    k--;
  }
  
  return 0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

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

struct edge {
	int to,cost;
	edge(int t,int c):to(t),cost(c) {}
};

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

ll mypow(ll x,ll n,ll m) {	//xのn乗をmで割った余り
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

//-----------------------------------------------------------------------------

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

	string s;
	cin>>s;
	for(int i=s.size()/2;i>=0;i--) {
		bool flg=false;
		REP(j,i) {
			if(s[j]!=s[i+j]) flg=true;
		}
		if(flg) continue;
		if(s.size()%2==0&&i==s.size()/2) continue;
		cout<<i*2<<endl;
		return 0;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define int long long
const int INF = 1e18, MOD = 1e9 + 7;
int x, y, a, b, c, n;

signed main() {
    cin>>x>>y>>a>>b>>c;
    vector<pair<int, int>> v;
    for (int i = 0; i < a; i++) {
        cin>>n;
        v.push_back(make_pair(n, 1));
    }
    for (int i = 0; i < b; i++) {
        cin>>n;
        v.push_back(make_pair(n, 2));
    }
    for (int i = 0; i < c; i++) {
        cin>>n;
        v.push_back(make_pair(n, 0));
    }
    sort(v.rbegin(), v.rend());
    int cnt = 0;
    int ans = 0;
    for (auto p: v) {
        if (p.second == 0) cnt++, ans += p.first;
        if (p.second == 1 && x) x--, ans += p.first;
        if (p.second == 2 && y) y--, ans += p.first;
        if (x + y - cnt == 0) break;
        
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 10476
#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>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n;
    cin >> n;
    if(n == 0){
        cout << 0 << endl;
        return 0;
    }

    int i = 0;
    string s;
    while(n != 0){
        if(n % 2 != 0){
            s += '1';
            if(i % 2 == 0)
                -- n;
            else
                ++ n;
        }
        else{
            s += '0';
        }
        n /= 2;
        ++ i;
    }
    reverse(s.begin(), s.end());
    cout << s << endl;

    return 0;
}


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

#define N 200010 

using namespace std;

typedef long long ll;


int a[N], n;

map <ll, ll> MP;

bool check(int x) {
	MP.clear();
	for (int i = 2; i <= n; i ++ ) {
		if (a[i - 1] >= a[i]) {
			if (x == 1) {
				return false;
			}
			while (!MP.empty()) {
				ll mx = MP.rbegin() -> first;
				if (mx > a[i]) {
					MP.erase(mx);
				}
				else {
					break;
				}
			}

			int j = a[i];
			while (j > 0 && MP[j] + 1 == x) {
				MP.erase(j);
				j -- ;
			}
			if (!j) {
				return false;
			}
			MP[j] ++ ;
		}
	}
	return true;
}


int main() {
	scanf("%d",&n);
	for (int i = 1; i <= n; i ++ ) {
		scanf("%d",&a[i]);
	}

	int l = 1, r = n, ans = n;
	while (l <= r) {
		int mid = (l + r) >> 1;
		if (check(mid)) {
			ans = mid;
			r = mid - 1;
		}
		else {
			l = mid + 1;
		}
	}
	cout << ans << endl ;
	return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
INF = float("inf")
import sys

N,D = map(int,sys.stdin.readline().split())
XY = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
ret = 0
for x,y in XY:
    if x**2 + y**2 <= D**2:
        ret += 1
print(ret)


Measured memory_bytes: 36204
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    N, K = map(int, input().split())
    A_list = list(map(int, input().split()))
    visited_set = set()
    visited_list = []
    now_town = 1
    while now_town not in visited_set:
        visited_list.append(now_town)
        visited_set.add(now_town)
        now_town = A_list[now_town-1]
    remainder = visited_list.index(now_town)
    period = len(visited_list) - remainder
    answer = None
    if K <= remainder:
        answer = visited_list[K]
    else:
        answer = visited_list[(K-remainder)%period + remainder]
    print(answer)

if __name__ == "__main__":
    main()




Measured memory_bytes: 32220
import math
import sys
from itertools import permutations
input = sys.stdin.readline

arr=[0]*4
N=int(input())
for i in range(N):
    s=input()
    if s[-1]=="\n":
        s=s[:-1]
    if s=='AC':
        arr[0]+=1
    elif s=='WA':
        arr[1]+=1
    elif s=='TLE':
        arr[2]+=1
    elif s=='RE':
        arr[3]+=1

print("AC x",arr[0])
print("WA x",arr[1])
print("TLE x",arr[2])
print("RE x",arr[3])

Measured memory_bytes: 68200
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int W,H,N;
int xs[2][100*1000];
int ys[2][100*1000];
int main() {
	scanf("%d%d%d",&W,&H,&N);
	for(int i=0;i<N;i++){
		scanf("%d%d",xs[0]+i,ys[0]+i);
		xs[1][i]=xs[0][i];
		ys[1][i]=ys[0][i];
	}
	LL ret=1LL<<60;
	int rx=0,ry=0;
	for(int i=0;i<=(N+1)%2;i++){
		for(int j=0;j<=(N+1)%2;j++){
			nth_element(xs[1],xs[1]+(N+i-1)/2,xs[1]+N);
			int x=xs[1][(N+i-1)/2];
			nth_element(ys[1],ys[1]+(N+j-1)/2,ys[1]+N);
			int y=ys[1][(N+j-1)/2];
			LL m=0;
			LL sum=0;
			for(int i=0;i<N;i++){
				LL d=abs(xs[0][i]-x);
				d+=abs(ys[0][i]-y);
				m=max(m,d);
				sum+=2*d;
			}
			sum-=m;
			if(sum<ret){
				ret=sum;
				rx=x;
				ry=y;
			}
		}
	}
	printf("%lld\n%d %d\n",ret,rx,ry);
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

/* debugging */
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << ": " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<"| ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e5 + 10;
const int mod = 1e9 + 7;

int32_t main(){
    boost;

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt" , "r" , stdin); 
    // freopen("output.txt" , "w", stdout);
    // #endif
    
    //code
    int h , w , x , y;
    cin >> w >> h >> x >> y;

    long double mid_x = w/2.0;
    long double mid_y = h/2.0;

    long double ans = (w*h)/2.0;
    cout << ans << " ";

    // trace(mid_x,mid_y,ans);
    
    if( (x == mid_x and y == mid_y ) or (x == mid_y and y == mid_x))
    	cout << 1;
    else
    	cout << 0;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
long long int dp[10004][101][2];
string k;
long long int d,len;
long long int solve(long long int index,long long int rem,long long int check=1)
{
    if(index==len)return (rem==0);
    if(dp[index][rem][check]!=-1)return dp[index][rem][check];
    long long int bound=9,ans=0;
    if(check==1)bound=(k[index]-48);
    for(int i=0;i<=bound;i++)ans=(ans+solve(index+1,(rem+i)%d,check && (i==k[index]-48)))%mod;
    return dp[index][rem][check]=ans;
}
int main()
{
    long long int i,j,x,y,z;
    cin>>k;
    cin>>d;
    len=k.size();
    for(i=0;i<=10002;i++)for(j=0;j<=100;j++)for(int l=0;l<2;l++)dp[i][j][l]=-1;
    cout<<(solve(0,0)-1+mod)%mod;
}

Measured memory_bytes: 16896
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;


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



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

class Program
{
	//Main
	static void Main(string[] args)
	{
		//読み込む
		int K = int.Parse(Console.ReadLine());

		string[] S = Console.ReadLine().Split(' ');
		int A = int.Parse(S[0]);
		int B = int.Parse(S[1]);

		bool found = false;

		for(int i=A; i<=B; i++){
				if(found){
						break;
				}
				else if(i % K == 0){
						found = true;
				}
		}

		if(found){
				Console.WriteLine("OK");
		}
		else{
				Console.WriteLine("NG");
		}

	}
}



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

int main () {
  int K , S ;
  cin >> K >> S ;
  
  int answer = 0 ;
  
  for(int i = 0 ; i < K + 1 ; i++ ) {
    for(int j = 0 ; j < K + 1 ; j++ ) {
      int k = S - i - j ;
        if( k >= 0 && k <= K) answer++ ;
    }
  }
  cout << answer << endl ;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10

void bsort(int a[],int n)
{
	int i,j;
	for(i = 0 ; i < n-1 ; i++){
		for( j=n-1 ; j>i ; j--){
			if(a[j-1]<a[j]){
				int temp = a[j];
				a[j] = a[j-1];
				a[j-1] = temp;
			}
		}
	}
}

int main(void)
{
	int s[MAX];
	int i;
	
	for( i=0 ; i<MAX ; i++){
		scanf("%d",&s[i]);
	}
	
	bsort(s,MAX);
	
	for(i=0 ; i<3 ; i++){
		printf("%d\n",s[i]);
	}
}

Measured memory_bytes: 2588
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define trep(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
int v[6] = {500, 100, 50, 10, 5, 1};
int greed(int n)
{
    int count = 0;
    rep(i, 6)
    {
        int cc = n / v[i];
        n -= cc * v[i];
        count += cc;
    }
    return count;
}
int main()
{
    int n;
    while (scanf("%d%*c", &n))
    {
        if (n == 0)
        {
            break;
        }
        int ans = greed(1000-n);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3140
#include <iostream>
#include<string>
#include<algorithm>
#include<stdio.h>

using namespace std;

int main(){
    string s;
    cin>>s;
    
    string ans="yes";
    for(int i=0; i<s.size(); ++i){
        for(int j=i+1; j<s.size(); ++j){
            if(s[i]==s[j])ans="no";
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);

class Graph {
  protected:
    int vertex;

    Graph(int v) {
      vertex = v;
    }
};

struct Edge {
  int to;
  int cost;
};

class AdjacentListGraph : public Graph {
  protected:
    std::vector<std::vector<Edge> > list;
  public:
    AdjacentListGraph(int v): Graph(v) {
      list.resize(vertex);
    }

    virtual void push(int from, int to, int cost) = 0;
};

class DAG : public AdjacentListGraph {
  using AdjacentListGraph::AdjacentListGraph;

  private:
    std::vector<int> sorted;

  public:
    void topological_sort();

    void push(int from, int to, int cost);

    std::vector<int> get_sorted();

    bool has_closed_cycle();
};

void DAG::topological_sort() {
  std::vector<int> intoVertex(vertex, 0);
  std::queue<int> q;

  for (std::vector<Edge> vec: list) {
    for (Edge e: vec) {
      intoVertex[e.to]++;
    }
  }

  for (int i = 0; i < vertex; ++i) {
    if (intoVertex[i] == 0)
      q.push(i);
  }

  while (q.size() > 0) {
    int v = q.front();
    q.pop();
    sorted.emplace_back(v);
    for (Edge e: list[v]) {
      intoVertex[e.to]--;
      if (intoVertex[e.to] == 0)
        q.push(e.to);
    }
  }
}

void DAG::push(int from, int to, int cost = 1) {
  Edge e;
  e.to = to;
  e.cost = cost;
  list[from].push_back(e);
}

std::vector<int> DAG::get_sorted() {
  return sorted;
}

bool DAG::has_closed_cycle() {
  return (int)sorted.size() != vertex;
}

int main() {
  
  int v;
  int e;

  scanf("%d %d", &v, &e);

  DAG g = DAG(v);

  int from, to;

  for (int i = 0; i <  e; i++) {
    scanf("%d %d", &from, &to);
    g.push(from, to);
  }

  g.topological_sort();
  bool flag = g.has_closed_cycle();
  printf("%d\n", flag ? 1 : 0);
}



Measured memory_bytes: 3284
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=500005;
typedef pair<double,int> P;
#define fi first
#define se second
int n,L;
P Q[max_n];
int head,tail;
int main(){
    scanf("%d%d",&n,&L);
    head=1,tail=0;
    double ans=0;
    for(int i=1;i<=n;i++){
        double t;int v;scanf("%lf%d",&t,&v);
        int x=v;
        while(tail>=head){
            P& p=Q[head];
            if(p.se<=x){
                ans-=p.se*p.fi;
                x-=p.se;
                head++;
            }
            else{
                p.se-=x;
                ans-=x*p.fi;
                x=0;
                break;
            }
        }
        ans+=v*t;
        while(head<=tail&&Q[tail].fi>t){
            t=(Q[tail].fi*Q[tail].se+t*v)/(v+Q[tail].se);
            v+=Q[tail].se;
            tail--;
        }
        Q[++tail]=P(t,v);
        printf("%.10f\n",ans/L);
    }
    return 0;
}

Measured memory_bytes: 18304
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k, i, ans = 1e13, used;
    cin>>n>>k;
    vector<ll> a(n), f(n);
    for(i=0; i<n; i++) {
    	cin>>a[i];
    }
    for(i=0; i<n; i++) {
    	cin>>f[i];
    }
    sort(all(a));
    sort(all(f));
    reverse(all(f));
    ll l = 0, r = 1e13, mid;
    while(l <= r) {
    	mid = (l + r)/2;
    	used = 0;
    	for(i=0; i<n; i++) {
    		if(a[i]*f[i] > mid) {
    			used += a[i] - (mid/f[i]);
    		}
    	}
    	if(used <= k) {
    		ans = min(ans, mid);
    		r = mid - 1;
    	}
    	else {
    		l = mid + 1;
    	}
    }
    cout<<ans<<"\n";	
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i, j, k, m=1, p=1;
    string a, x="", y="";
    cin>>a;
    y+=a[0];
    for(i=1; i<a.size(); i++){
        x+=a[i];
        if(x!=y){
            y=x;
            x="";
            p++;
        }
    }
    cout<<p<<endl;
    return 0;
}



Measured memory_bytes: 640
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	a := nextInt()
	b := nextInt()
	if b < a {
		a--
	}
	fmt.Println(a)
}

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

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

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

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

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

type Pair struct {
	a, b int
}

type Pairs []Pair

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

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


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

typedef long long ll;
typedef long double ld;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vstr;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define asd cout << "ok" << endl;

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define trav(it, m) for(auto it = m.begin(); it it!= m.end(); it++)

const char nl = '\n';
const int MOD = 1e9 +7;
const ll INF = 1e19;
const ld PI = acos((ld)-1);
const int MX = 2e5 + 5;

int main(){

  ios_base::sync_with_stdio(0); cin.tie(0);
  int n; cin >> n;
  for(int i = 1; i <= 9; i++)
  {
    if(111*i >= n)
    {
      cout << 111*i << nl;
      return 0;
    }
  }







  return 0;
}



Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<set>
using namespace std;

long long K;
long long A[200001];
vector<long long> junkai, junkai2;
set<long long> roop;
long long roopnum;

void visit1(long long v){
    long long memo = roop.size();
    roop.insert(v);
    if(memo==roop.size()){
        roopnum = v;
        return;
    }
    junkai.push_back(v);
    visit1(A[v]);
}

int main(){
    long long N;
    cin >> N >> K;
    long long i;
    for(i=1; i<=N; i++){
        cin >> A[i];
    }
    junkai.push_back(1);
    roop.insert(1);
    visit1(A[1]);
    long long kiten;
    for(i=0; i<junkai.size(); i++){
        if(junkai[i]==roopnum){
            kiten = i;
            break;
        }
    }
    for(i=kiten; i<junkai.size(); i++){
        junkai2.push_back(junkai[i]);
    }
    if(K<kiten){
        cout << junkai[K] << endl;
    }else{
        K=K-kiten;
        cout << junkai2[K%junkai2.size()] << endl;
    }
    
    system("pause");
    return 0;
}

Measured memory_bytes: 26564
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 1e6 + 6;
int main()
{
    fastRead;
    int n , k;
    cin>>n>>k;
    vector<int>cnt(n+1);
    
    while(k--) {
        
        int tmp;
        cin>>tmp;
        while(tmp--) {
            int x;
            cin>>x;
            cnt[x]++;
        }
    }
    
    int ans = 0;
    for(int i =1; i <=n ; i++ ) {
        if(cnt[i] == 0 ) ans++;
    }
    cout<<ans<<'\n';
    return 0;
    
    
}

Measured memory_bytes: 3644
n, m = map(int, input().split())
a = [int(s) for s in input().split()]
limit = sum(a) / (m * 4)
a.sort(reverse=True)
for i in a[: m]:
    if i < limit:
        ans = 'No'
        break
    else:
        ans = 'Yes'
print(ans)

Measured memory_bytes: 9160
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	if (s.size() == 3)
	{
		cout << s.at(2) << s.at(1) << s.at(0) << endl;
	}
	else
	{
		cout << s << endl;
	}
	return 0;
}
/*
死のマウス
.　　あり許せん！
　　　∧＿＿∧
　|| （＃｀Д´ ） ||
　|| ( |　 　| | |||
　从| |　 　| |从从
￣) ⊂ノ￣￣!_つ￣て
　フヘ(　　　　ヽヘ(＼

*/

Measured memory_bytes: 256
console.log((args=>{
  const K = args.trim()|0;
  if (K%2===0||K%5===0) return '-1';
  let r = 7;
  for ( let i = 1;; i++ ) {
    if ( r%K===0 ) return i;
    r = (r*10+7)%K;
  }
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 32144
//ALDS_1_1_D.cpp
#include<iostream>
using namespace std;


int main() {
  int n;
  cin >> n;
  int R[n];
  int maxv = -2000000000;

  for (size_t i = 0; i < n; i++) {
    cin >> R[i];
  }

  int minv = R[0];

  for (size_t i = 1; i < n; i++) {
    if(maxv < R[i] - minv){
      maxv = R[i] - minv;
    }
    if (minv > R[i]) {
      minv = R[i];
    }
  }


  cout << maxv << endl;
}

Measured memory_bytes: 3872
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;

#define dbg(x) cerr << #x"=" << x << endl;
typedef long long LL;


int main(){
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(n*a, b) << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define tp tuple<int,int,int>
#define mtp make_tuple
using namespace std;

const int N=2e5+5;
int n,a[N];
map<int,int>cnt;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n;
    int res=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        res+=cnt[a[i]-i];
        cnt[-(a[i]+i)]++;
    }
    cout<<res;
}


Measured memory_bytes: 27840
/* -- 2408:Social -- */
#include	<iostream>
#include	<vector>
#include	<utility>
#include	<algorithm>

using namespace std;

typedef pair<int, int> Pii;
typedef pair<int, bool> Pib;
typedef vector< Pii > Vp_ii;
typedef vector< Pib > Vp_ib;
typedef vector< int > Vi;

int main(void) {
	int N, K, R, m, buff, fubb, c=0;
	Vi bunny, ship_count;
	Vp_ii q;
	Vp_ib ls;

	cin >> N >> K;
	for(int i=0; i<K; i++) {
		cin >> m;
		ship_count.push_back(m);
		for(int j=0; j<m; j++) {
			cin >> buff;
			bunny.push_back(buff);
		}
	}

	cin >> R;
	for(int i=0; i<R; i++) {
		cin >> buff >> fubb;
		q.push_back( Pii(buff, fubb) );
	}
	sort( q.begin(), q.end() );
	Vi::iterator it_a = ship_count.begin(), it_b = bunny.begin();
	while( it_a != ship_count.end() ) {
		ls.clear();
		for(int i=0; i < *it_a; i++, it_b++) { ls.push_back( Pib(*it_b, true) ); }
		sort( ls.begin(), ls.end() );
		Vp_ib::iterator it_c = ls.begin();
		while( it_c != ls.end() ) {
			Vp_ib::iterator it_d = it_c;
			while( it_d != ls.end() ) {
				Vp_ii::iterator it_e = q.begin();
				while( it_e != q.end() ) {
					if(it_c->first == it_e->first && it_d->first == it_e->second) {
						if(it_c->second) { c++; it_c->second = false;}
						if(it_d->second) { c++; it_d->second = false;}
					}
					it_e++;
				}
				it_d++;
			}
			it_c++;
		}
		it_a++;	
	}
	cout << c << endl;
}

Measured memory_bytes: 1248
//Code by a weak man who named tarjin, and he hopes the code can get more points.
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll a,b,c,d,ans=-1e18;
int main(void)
{
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	ans=max(ans,a*c);
	ans=max(ans,a*d);
	ans=max(ans,b*c);
	ans=max(ans,b*d);
	printf("%lld\n",ans);
	return 0;  
}

Measured memory_bytes: 3820
#include <stdio.h>
int main(void){
 int m,f,r;
 char g;
 for(;;){

scanf("%d %d %d",&m,&f,&r);

 g='B';
 
 if(m+f>=80)g='A';
 if(50<=m+f&&m+f<65)g='C';
 if(30<=m+f&&m+f<50&&r>=50)g='C';
 if(30<=m+f&&m+f<50&&r<50)g='D';
 if(m+f<30)g='F';
 if(m==-1||f==-1)g='F';
 if(m==-1&&f==-1&&r==-1)break;
 
 printf("%c\n", g);
 }
 return 0;
 }



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse
// struct Edge {
//   int to, id;
//   Edge(int a, int b): to(a), id(b) {}
// };

ll a[100010];


map<ll,int> num,ord;

ll ans[100010];

int main(int argc, char const *argv[])
{
	int n;cin>>n;

	priority_queue<ll> pq;

	rep(i,n) {
		cin>>a[i];
		if (!num.count(a[i])) {
			ord[a[i]]=i;
			num[a[i]]++;
			pq.push(a[i]);
		} else {
			num[a[i]]++;
		}
	}

	ll cur = pq.top();pq.pop();
	int cnt = num[cur];
	ll nxt;
	int left = ord[cur];
	bool end = false;

	while (1) {
		// cout<<cur<<endl;
		if (pq.empty()) {
			nxt = 0;
			end = true;
		} else {
			nxt = pq.top();pq.pop();
		}
		ans[left]+=(ll)cnt*(cur-nxt);
		cnt+=num[nxt];
		cur=nxt;
		left = min(left,ord[cur]);
		if (end) break;
	}

	rep(i,n) {
		cout<<ans[i]<<endl;
	}

	return 0;
}

Measured memory_bytes: 15860
#include <iostream>
#include <algorithm>

using namespace std;

void solve() {
    int n, w, h, xi, yi, ai;
    cin >> w >> h >> n;
    int ans;
    int xl_max, xr_min, yu_min, yl_max;
    xl_max = yl_max = 0;
    xr_min = yu_min = max(w,h);
    for (int i = 0; i < n ; ++i) {
        cin >> xi >> yi >> ai;
        switch (ai) {
    case 1:
            if (xi > xl_max)
                xl_max = xi;
            break;
    case 2:
            if (xi < xr_min)
                xr_min = xi;
            break;
    case 3:
            if (yi > yl_max)
                yl_max = yi;
            break;
    case 4:
            if (yi < yu_min)
                yu_min = yi;
            break;
        }
    }
    ans = ((xr_min - xl_max> 0) && (yu_min - yl_max > 0)) ? (xr_min - xl_max) * (yu_min - yl_max) : 0;
    cout << ans;

}

int main() {

    solve();
    return 0;
}


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

int main(){
    int a, b;
    int c, d;

    cin >> a >> b;
    cin >> c >> d;

    int y = (c+b-1) / b;
    int x = (a+d-1) / d;

    cout << (x < y ? "No" : "Yes") << endl;
}


Measured memory_bytes: 3604
a = [[0 for i in range(100)] for j in range(100)]
b = [[0 for i in range(100)] for j in range(100)]
n, m, l = map(int, input().split())
for i in range(n):
    a[i][:m] = map(int, input().split())
for i in range(m):
    b[i][:l] = map(int, input().split())
for i in range(n):
    for j in range(l):
        c = 0
        for k in range(m):
            c += a[i][k] * b[k][j]
        print(c, end='')
        if j < l - 1:
            print(' ', end='')
        else:
            print()

Measured memory_bytes: 8736
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
class IVENT{
private:
  vector< pair<int,int> > v;
public:
  IVENT(){}
  void Sort(){
    sort(v.begin(),v.end());
  }
  void makeSet(int h,int IN,int OUT){
    v.push_back(make_pair(OUT,-h));
    v.push_back(make_pair(IN,h));
  }
  bool ok(){
    bool judge = true;
    for(int i=0,l=v.size(),weight=0;i<l;i++){
      weight += v[i].second;
      if(weight > 150){
        judge = false;
        break;
      }
    }
    return judge;
  }
};
int main(){
  int n,m,a,b;
  while(cin >> n && n){
  IVENT IV;
  for(int i=0;i<n;i++){
    cin >> m >> a >> b;
    IV.makeSet(m,a,b);
  }
  IV.Sort();
  cout << (IV.ok() ? "OK" : "NG") << endl;
  }
}

Measured memory_bytes: 1196
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <bitset>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = Mint(2).pow(n);
  Mint pow(long long n) const {
    if (n==0) return Mint(1);
    Mint y = pow(n>>1); // pow(n/2)を計算する
    y *= y;
    if (n%2==1) y *= *this;
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return a.pow(mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    Mint one = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= (i + one);
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};

int main() {
  int N;
  std::cin >> N;
  std::vector<long long > A(N);
  for (int i=0; i<N; i++) {
    std::cin >> A[i];
  }
  long long ans = 0;
  long long max = 0;
  for (int i=0; i<N; i++) {
    if (A[i]<=max+1) {
      max = std::max(max, A[i]);
    } else {
      // printf("max=%lld, +=%lld\n", max, (A[i]+max)/(max+1) - 1);
      ans += (A[i]+max)/(max+1) - 1;
      max = std::max(max, (long long)1);
    }
  }
  std::cout << ans << std::endl;
  return 0;
}

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

int main(){
  int n;
  cin>>n;
  string s[200000],a;
  int sum=0;
  
  for(int i=0;i<n;i++){
    cin>>s[i];
  }
  sort(s,s+n);
  for(int i=1;i<n;i++){
    if(s[i]!=s[i-1]){
      sum++;
    }
  }
  cout<<sum+1<<endl;
    
  return 0;
}


Measured memory_bytes: 9876
def test():
    n,y=map(int,input().split())
    a,b,c=10000,5000,1000
    for i in range(n+1):
        for j in range(n+1):
            ans=a*i+b*j
            if y<ans:
                break
            if (y-ans)%c==0:
                k=(y-ans)//c
                if i+j+k==n:
                    return i,j,k
    return -1,-1,-1
one,two,three=test()
print(one,two,three)


Measured memory_bytes: 3060
package main

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

type sushi struct{ t, d int }
type sushis []sushi

func (s sushis) Len() int           { return len(s) }
func (s sushis) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sushis) Less(i, j int) bool { return s[i].d > s[j].d }

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	s := sushis(make([]sushi, n))
	for i := range s {
		sc.Scan()
		s[i].t, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		s[i].d, _ = strconv.Atoi(sc.Text())
	}

	sort.Sort(s)
	sumD := 0
	mt := make(map[int]bool, n)
	src := make([]sushi, 0, k)
	for i := 0; i < k; i++ {
		sumD += s[i].d
		if mt[s[i].t] {
			src = append(src, s[i])
			continue
		}
		mt[s[i].t] = true
	}
	ts := len(mt)

	dst := make([]sushi, 0, len(s)-k+1)
	for i := k; i < len(s); i++ {
		if !mt[s[i].t] {
			mt[s[i].t] = true
			dst = append(dst, s[i])
		}
	}

	ans := sumD + ts*ts
	for i := range src {
		if i >= len(dst) {
			break
		}
		sumD += -src[len(src)-i-1].d + dst[i].d
		ts++
		if v := sumD + ts*ts; v > ans {
			ans = v
		}
	}
	fmt.Println(ans)
}


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

#include <iostream>
#include <fstream>

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

#define TR(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define IN(c, x) ((c).find(x) != (c).end())   //O(log n)
#define IN_L(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define PLL pair<ll,ll>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define FOR(i, _begin, _end) for (__typeof(_end) end = _end, begin = _begin,  i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define REP(i, end) for (__typeof(end) i = 0, _len = (end); i < (_len); i += 1)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define MOD(x, m) ((((x) % (m)) + (m)) % (m))
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define READ ({int t;cin >> t;t;})
#define EB emplace_back
#define fcout cout << fixed << setprecision(12)
#define fcerr cerr << fixed << setprecision(12)
#define print(x) cout << (x) << endl

#ifdef DEBUG
#define ERR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); _err(cerr,_it, args); }
#define DBG(x) cerr << #x << " is " << x << endl;
#else
#define DBG(x) {};
#define ERR(args...) {};
#endif
void _err(std::ostream& cerr,istream_iterator<string> it) {cerr << endl;}
template<typename T, typename... Args>
void _err(std::ostream& cerr, istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << "  ";
    _err(cerr,++it, args...);
}

const double pi = 2 * acos(.0);
const int inf = 0x3f3f3f3f;
const ll mod = (ll) (1e9) + 7;
//const ll mod = (ll) 998244353 ;
const double eps = 1e-10;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}

template <typename T>
ostream& operator << (ostream& os, const vector<T> V) {
    for(auto v : V)os << v << " ";
    return os;
}

template <typename T>
ostream& operator << (ostream& os, const set<T> V) {
    for(auto v : V)os << v << " ";
    return os;
}

template <typename T>
ostream& operator << (ostream& os, const deque<T> V) {
    for(auto v : V)os << v << " ";
    return os;
}

template<class T>bool Chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool Chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

//#define int ll

class ATransfer {
public:

void solve(std::istream& cin, std::ostream& cout, std::ostream& cerr) {
    int a,b,c;
    cin >> a >> b >> c;
    cout << c - min(a-b, c) << endl;
}


};


#undef int
int main() {

	ATransfer solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
    std::ostringstream err;
	in.tie(0); ios::sync_with_stdio(0);
//	solver.solve(in, out);
    solver.solve(in, out,err);
	return 0;
}


Measured memory_bytes: 256
s = gets.chomp
len = s.size - 1
count = []
[0, 1].repeated_permutation(len) do |bits|
  output = s.dup
  bits.each_with_index do |bit, index|
    if bit == 1
      output.insert(index*2+1, '+')
    else bit == 0
      output.insert(index*2+1, ' ')
    end
  end
  count << output.gsub(' ', '')
end

puts count.inject(0){|memo, c| memo += eval(c)}

Measured memory_bytes: 4092
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>

template <class Integer>
auto boost_irange(Integer last) { return boost::irange(static_cast<Integer>(0), last); }
template <class Integer>
auto boost_irange(Integer first, Integer last) { return boost::irange(first, last); }

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << std::endl; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << val << ' ';
            return *this;
        }
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val << ' ';
        return {};
    }
};

int main()
{
    input in;
    output out;

    int N, M;
    in >> N, M;
    std::vector<int> price(N);
    in.read(price.begin(), N);
    std::sort(price.begin(), price.end());

    std::size_t it = N - 1;
    for (int i = 0; i < M; ++i) {
        price[it] /= 2;
        if (it != 0 && price[it] < price[it - 1]) {
            --it;
        }
        if (price[it] < price.back()) {
            std::sort(price.begin(), price.end());
            it = N - 1;
        }
    }

    out << std::accumulate(price.begin(), price.end(), 0L);

    return 0;
}


Measured memory_bytes: 640
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
LL a[N];
LL b[N];
int f[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	LL k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) cin >> f[i];
	sort(a + 1, a + n + 1);
	sort(f + 1, f + n + 1);
	reverse(f + 1, f + n + 1);
	LL l = 0, r = 1e12;
	LL ans = r;
	while (l <= r)
	{
		LL mid = (l + r) / 2;
		for (int i = 1; i <= n; i++) b[i] = mid / f[i];
		b[n + 1] = INF * INF;
		for (int i = n; i >= 1; i--)
		{
			b[i] = min(b[i], a[i]);
			b[i] = min(b[i], b[i + 1]);
		}
		LL tot = 0;
		for (int i = 1; i <= n; i++) tot += a[i] - b[i];
		if (tot <= k) ans = mid, r = mid - 1;
		else l = mid + 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

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

  ll ans = 0, white = 0;
  for(int i = S.size() - 1; i >= 0; i--){
    if(S[i] == 'W') white++;
    if(S[i] == 'B') ans += white;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
using namespace std;
using ll = long long;
#define int ll

signed main(){
	int x, k, d; cin >> x >> k >> d;

	if (x < 0) {
		int m = (-x) / d;

		if (k <= m) {
			cout << abs(x + k * d) << endl;
		}
		else {
			x = x + m * d;
			k -= m;

			if (k % 2 == 0) {
				cout << abs(x) << endl;
			}
			else {
				cout << abs(x+d) << endl;
			}
		}
	}
	else if (x > 0) {
		int m = x / d;

		if (k <= m) {
			cout << abs(x - k * d) << endl;
		}
		else {
			x = x - m * d;
			k -= m;

			if (k % 2 == 0) {
				cout << abs(x) << endl;
			}
			else {
				cout << abs(x-d) << endl;
			}
		}
	}
	else {
		if (k % 2 == 0) {
			cout << 0 << endl;
		}
		else {
			cout << abs(d) << endl;
		}
	}
}

Measured memory_bytes: 3612