akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    ll h,n; cin >> h >> n;
    vl a(n),b(n);
    rep(i,n) cin >> a[i] >> b[i];
    vl dp(h+1,linf);
    dp[0] = 0;
    rep(i,h){
        rep(j,n){
            chmin(dp[min(h,i+a[j])], dp[i] + b[j]);
        }
    }
    cout << dp[h] << endl;
}

Measured memory_bytes: 384
/*
icpc??´?????????
2010??´ ??¢?????¢ A??????
*/
import java.util.HashSet;
import java.util.List;
import java.util.regex.Pattern;
import java.util.HashMap;
import java.io.*;
import java.util.LinkedHashSet;

class Main {
	public static void main(String[] args) {
		try {
			run();
		}catch(IOException e) {
			System.out.println(e);
		}
	}
	
	private static void run() throws IOException{
		int n;
		int input;
		String inst;
		String[] str;
		String boss = "boss";
		Pattern p = Pattern.compile("[:,.]+");
		
		HashSet<String> member = new HashSet<String>();
		HashSet<String> group = new HashSet<String>();
		HashMap<String,HashSet<String>> groupMap = new HashMap<String,HashSet<String>>();
		HashSet<String> inst_member;
		HashSet<String> key = new HashSet<String>();
		LinkedHashSet<String> tree = new LinkedHashSet<String>();
		HashSet<String> instant = new HashSet<String>();
		
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		while(true) {
			member.clear();
			group.clear();
			key.clear();
			tree.clear();
			groupMap.clear();
			n = Integer.parseInt(in.readLine()); //???????????£?????????
			if(n==0) break;
			
			for(int i=0;i<n;i++) {
				inst_member = new HashSet<String>();
				inst = in.readLine();
				
				str = p.split(inst,-1);
				
				group.add(str[0]);
				if(i==0) boss = str[0];
				
				for(int j=1;j<str.length-1;j++) {
					inst_member.add(str[j]);
				}
				groupMap.put(str[0],inst_member);
			}
			
			instant = groupMap.get(boss);
			for(String s : instant) {
				tree.add(s);
			}
			group.add(boss);
			
			String[] arr = new String[tree.size()];
			tree.toArray(arr);
			
			for(int i=0; i<arr.length; i++) {
				if(groupMap.containsKey(arr[i])) {
					instant = groupMap.get(arr[i]);
					for(String s : instant) {
						tree.add(s);
					}
					group.add(arr[i]);
				}
				if(arr.length != tree.size()) {
					arr = new String[tree.size()];
					tree.toArray(arr);
				}
			}
			
			tree.removeAll(group);
			System.out.println(""+tree.size());
		}
	}
}

Measured memory_bytes: 35788
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>

using namespace std;
typedef long long ll;
#define inf 0x3f3f3f3f

//std::ios::sync_with_stdio(0); std::cin.tie(0);
int main() {
	int a;
	cin >> a;
	cout << a + a * a + a * a * a << endl;

	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include<list>
#include<iomanip>
#include<cmath>
#include<queue>
#include <functional>
#include<stdio.h>
#include<assert.h>
#include<stack>
#include<sstream>
#include <cstdlib>
#include<map>
#include<algorithm>
#include<iostream>
#include<set>
#include<utility>
#include<memory.h>
#include<string>
#include<vector>
#include<numeric>
#include <unordered_map>
using namespace std;
#define ll  long long
#define pb push_back
#define fi(ss) freopen (ss,"r",stdin)
#define fo(ss) freopen (ss,"w",stdout)
#define sz(v)               ((int)((v).size()))
#define all(x)          (x).begin(),(x).end()
#define REP(i, v)       for(int i=0;i<sz(v);i++)
typedef pair<int,int> pii;
#define ios std::ios_base::sync_with_stdio(false);
using namespace std;
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>

const int N = 1000000;

int n;
char str[N + 1];
deque <int> letters[26];

int cnt[N];
bool present[N];

void add(int k, int v) {
    for(; k < n; k += ~k & k + 1) {
        cnt[k] += v;
    }
}

int respond(int k) {
    int ret = 0;
    for (; k >= 0; k -= ~k & k + 1) {
        ret += cnt[k];
    }
    return ret;
}

void erase(int i) {
    present[i] = false;
    add(i, -1);
}

int main() {
    scanf("%s", str);
    n = strlen(str);
    for (int i = 0; i < n; ++ i) {
        letters[(int)(str[i] -= 'a')].push_back(i);
    }
    int odd_count = 0;
    for (int i = 0; i < 26; ++ i) {
        odd_count += letters[i].size() & 1;
    }
    if (odd_count != (n & 1)) {
        puts("-1");
        return 0;
    }
    memset(present, true, sizeof(present));
    for (int i = 0; i < n; ++ i) {
        add(i, 1);
    }
    long long answer = 0;
    for (int l = 0, r = n - 1; l < r; ) {
        if (!present[l]) {
            l ++;
        } else if (!present[r]) {
            r --;
        } else {

            int left_cost = respond(n - 1) - respond(letters[(int)str[l]].back());
            int right_cost = respond(letters[(int)str[r]].front()) - 1;
            answer += std::min(left_cost, right_cost);
            int token = left_cost < right_cost ? str[l] : str[r];
            erase(letters[token].front());
            erase(letters[token].back());
            letters[token].pop_front();
            letters[token].pop_back();
        }
    }
    cout << answer << "\n";
    return 0;
}


Measured memory_bytes: 3072
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())


K=II()
S=input()

if len(S) <= K:
    print(S)
else:
    print(S[:K] + "...")


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}

template<typename T>
T gcd(T x, T y){
    if (x == 0 || y == 0) {
        return 0;
    }

    while (x != y){
        if (x > y) {
            x -= y;
        }else{
            y -= x;
        }
    }
    return x;
}

// }}}
/* vim:set foldmethod=marker: */

void solve(){
    int a,b;
    cin >> a >> b;

    cout << a*b - a - b + 1 << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


// map の key, value を全て抜き出す。
// for (auto itr = mp.begin(); itr != mp.end(); itr++) {
//     cout << "key" << itr->first << " value" << itr->second << endl;
// }

// 文字列の検索
// string s="abc";
// if (s.find('d') == string::npos){
//     cout << "find" << endl;
// }else{
//     cout << "not find" << endl;
// }


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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int h, w, n;
    cin >> h >> w >> n;

    int div = n / max(h, w);
    int rem = n % max(h, w);

    if (rem) cout << div + 1 << '\n';
    else cout << div << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
int A,B,C,D,E,N,M,x,y,cou=0,cou2,v[1000000],w[1000000],min_i,en=0;
    char S[10],W[10],s[10],X,Y;
   scanf("%c %c",&X,&Y);
   if(X=='H'){
       if(Y=='H'){
           printf("H");
       }else{
           printf("D");
       }
   }else{
       if(Y=='H'){
           printf("D");
       }else{
           printf("H");
       }
   }
    return 0;
}

Measured memory_bytes: 128
import copy
a=list(input())
b=int(input())
if len(a)==1:
  print(b//2)
else:
  c=copy.copy(a) 
  l=len(a)
  ans1=0
  ans2=0
  t=0
  for i in range(1,len(a)):
    if c[i]==c[i-1]:
      ans1+=1
      c[i]=str(i%10)
      if i==len(a)-1:
        t=2
  c=a*2
  if t==2:
    c[l-1]=str(1)
  for i in range(l,len(c)):
    if c[i]==c[i-1]:
      ans2+=1
      c[i]=str(i%10)
      if i==len(c)-1:
        t=1
  if b==1:
    print(ans1)
  elif t:
    if b%2==0:
      print((ans1+ans2)*b//2)
    else:
      print((ans1+ans2)*(b//2)+ans1)
  else:
    print(ans1+ans2*(b-1))



Measured memory_bytes: 3444
def main():
    n = int(input())
    S = [input() for _ in range(n)]
    dic = {}
    dic["AC"] = 0
    dic["WA"] = 0
    dic["TLE"] = 0
    dic["RE"] = 0
    for s in S:
        if s in dic:
            dic[s] += 1
        else:
            dic[s] = 1
    print(f"AC x {dic['AC']}")
    print(f"WA x {dic['WA']}")
    print(f"TLE x {dic['TLE']}")
    print(f"RE x {dic['RE']}")
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 82716
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, n) for(ll i=0;i<n;i++)
#define r(i, n) for(ll i=n-1;i>=0;i--)
#define forr(i, x, y) for(ll i=x;i<y;i++)
int main()
{
    ll n;
    cin>>n;
    if(n&1)
    cout<<"0"<<endl;
    else{
        ll temp=n/2;
        ll five=0;
        ll p=5;
        while(temp/p>0){
            five+=temp/p;
            p=p*5;
        }
        cout<<five<<endl;
    }
}

Measured memory_bytes: 256
using System;
public class Hello{
    public static void Main(){
        string[] input = Console.ReadLine().Split(' ');
        int A = int.Parse(input[0]);
        int B = int.Parse(input[1]);
        int C = int.Parse(input[2]);
        
        if(A <= C && C <= B){
            Console.WriteLine("Yes");
        }else{
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
typedef long double ld;
using ll=long long;
using namespace std;
const auto mod=1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  int n; cin >> n;
  double ans=0.0,a;
  rep(i,0,n){
    cin >> a;
    ans+=  1.0/a;
  } 
  ans = 1.0/ans;
  cout << ans << endl;
}

Measured memory_bytes: 384
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    cnt1=0
    cnt2=0
    cnt4=0
    for i in l:
        if i%2==1:
            cnt1+=1
        elif i%4==0:
            cnt4+=1
        else:
            cnt2+=1
    if cnt2==0 and cnt4+1>=cnt1:
        print('Yes')
    elif cnt2>0 and cnt4>=cnt1:
        print('Yes')
    else:
        print('No')
resolve()

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n, w;
	cin >> n >> w;

	vector<pair<int, int>> items(n);
	for (int i = 0; i < n; i++)
	{
		cin >> items[i].first >> items[i].second;
	}

	vector<long long> dp(w + 1);
	for (int i = 0; i < n; i++)
	{
		vector<long long > new_dp(w + 1);
		for (int curr_w = w; curr_w >= 0; curr_w--)
		{
			if (curr_w - items[i].first >= 0)
				new_dp[curr_w] = dp[curr_w - items[i].first] + items[i].second;
			new_dp[curr_w] = max(new_dp[curr_w], dp[curr_w]);
		}
		dp = new_dp;
	}
	cout << *max_element(dp.begin(), dp.end()) << "\n";
}

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

int main(){
    string s,t,u;
    int a,b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if (s == u){
        a = a - 1;
    }else{
        b = b - 1;
    }
    cout << a << " " << b << endl;
    return 0;

}

Measured memory_bytes: 256
//by Top1
#include <bits/stdc++.h>
     
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
 
const int inf = (1e9) + 1;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 111;
     
using namespace std;

int n, q, k, dp[101][maxn], pr[101][maxn], a[maxn];

int get(int x, int l, int r){
	if (l <= 0)
		return pr[x][r];
	return pr[x][r] - pr[x][l - 1];
}

void solve(){
	cin >> n >> k;

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

	dp[0][0] = 1;
	for(int i = 0; i <= k; i++)
		pr[0][i] = 1;

	for (int i = 1; i <= n; i++){
		for (int j = 0; j <= k; j++){
			dp[i][j] += (get(i - 1, j - a[i], j) + mod) % mod; //cerr << dp[i][j] << " ";
			//cout << get(i, j - a[i], j) << j - a[i] << " " << j << endl;
			//return;
		}
		//cout << endl;
		pr[i][0] = dp[i][0];
		for (int j = 1; j <= k; j++)
			pr[i][j] = (pr[i][j - 1] + dp[i][j]) % mod;
	}

	cout << dp[n][k];
}

main(){
    boost;
	    
	q = 1;

	while (q--){
		solve();
	}
}

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

int main(){
  int N, M;
  cin >> N >> M;
  vector<string> vec_str(M * 2);
  vector<int> vec_int(N);
  for(int i = 0; i < M * 2; i++) cin >> vec_str.at(i);
  for(int i = 0; i < vec_str.size(); i++) vec_int.at(atoi(vec_str.at(i).c_str()) - 1) += 1;
  for(int i = 0; i < vec_int.size(); i++) cout << vec_int.at(i) << endl;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
//#include <ttmath.h>
#define endl '\n'
#define modulo 1000000007
#define int long long
#pragma GCC optimize("-Ofast")
#define float double
#define PI 3.141592653589793238462643
#define sinDegrees(x) sin((x) * PI / 180.0)
#define tanDegrees(x) tan((x) * PI / 180.0)
#define atanDegrees(x) atan(x)* 180.0 / PI
using namespace std;
int power(int x, unsigned int y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return (power(x, y / 2) * power(x, y / 2));
    else
        return (x * power(x, y / 2) * power(x, y / 2));
}
/*#include "testlib.h"
int main(int argc, char* argv[])
{
iostream::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
registerGen(argc, argv, 1);
int n,k;
n=rnd.next(1,50);
k=rnd.next(1,n);
cout<<n<<' '<<k;
}*/
bool comp(pair<int,int>a,pair<int,int>b)
{
    if(a.first==b.first){
    return a.second>b.second;
    }
    return a.first>b.first;
}
int32_t main()
{
    //freopen("output.txt","w", stdout);
    iostream::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int counter=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size()/2;i++){
    if(s[i]!=s[s.size()-1-i])
    counter++;
    }
    cout<<counter;
    return 0;
}


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); 	
	const int mod = 1e9 + 7;
	string s;
	cin >> s;
	int n = s.length();
	vector<vector<long long>> dp(4, vector<long long>(n + 1, 0));
	dp[0][0] = 1;
	for(int i = 0; i < n ; i++) {
		for(int j = 0; j < 4; j++) {
			dp[j][i + 1] += (s[i] == '?' ? dp[j][i] * 3 : dp[j][i]);
			dp[j][i + 1] %= mod;
		}
		if(s[i] == '?') {
			for(int j = 1; j < 4; j++) {
				dp[j][i + 1] += dp[j - 1][i];
				dp[j][i + 1] %= mod;
			}
		}
		if(s[i] == 'A') {
			dp[1][i + 1] += dp[0][i];
			dp[1][i + 1] %= mod;
		}
		if(s[i] == 'B') {
			dp[2][i + 1] += dp[1][i];
			dp[2][i + 1] %= mod;
		} 
		if(s[i] == 'C') {
			dp[3][i + 1] += dp[2][i];
			dp[3][i + 1] %= mod;
		}
	}
	cout << dp[3][n] << endl;
	return 0;
}



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

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

    string s;
    cin >> s;
    bool res = true;
    if (s[0] != 'A') res = false;
    unsigned long c_pos = s.find('C');
    if (c_pos < 2 ||  s.size() - 1 == c_pos || c_pos == string::npos) res = false;
    for (int i = 0; i < s.size(); ++i) {
        if (i == 0 || i == c_pos) continue;
        if (s[i] < 'a' || 'z' < s[i]) res = false;
    }

    cout << (res? "AC" : "WA") << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define ff first
#define ss second
#define M 1000000007
#define MAXN 100100
using namespace std;
typedef pair<int,int> pii;
inline int mod(int n, int m){int ret = n%m; if(ret < 0) ret += m; return ret;}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }    else return mod(k*k,m);
}

int n;
pii aresta[MAXN];
vector<int> adj[MAXN];
int pai[MAXN];
map<pii,int> mapa;
int res=0;
void dfs(int v,int cpai){
	int cor=1;
	for(int i=0;i<(int)adj[v].size();i++){
		int u = adj[v][i];
		if(u==pai[v])continue;
		pai[u] = v;
		if(cor==cpai)cor++;
		dfs(u,cor);
		mapa[pii(min(u,v),max(u,v))] = cor;
		res = max(res,cor);
		cor++; 
	}
	
}

int32_t main(){
	fastio;
	cin>>n;
	for(int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
		aresta[i] = pii(min(a,b),max(a,b));
	}
	pai[1] = 0;
	dfs(1,-1);
	cout<<res<<endl;
	for(int i=0;i<n-1;i++){
		cout<<mapa[aresta[i]]<<endl;
	}
}

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

using namespace std;

#define MAX 11
#define INF (1<<29)

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

  while(cin >> n ,n){
    int G[MAX][MAX],m = 0;
    fill(G[0],G[MAX],INF);
    
    for(int i = 0 ; i < MAX ; i++){
      G[i][i] = 0;
    }
    for(int i = 0 ; i < n ; i++){
      cin >> a >> b >> c;
      G[a][b] = G[b][a] = c;
      m = max(m,max(a,b));
    }
  

    for(int k = 0 ; k <= m ; k++){
      for(int i = 0 ; i <= m ; i++){
	for(int j = 0 ; j <= m ; j++){
	  G[i][j] = min(G[i][j],G[i][k]+G[k][j]);
	}
      }
    }

    int min_ = INF,num;
    for(int i = 0 ; i <= m ; i++){
      int sum = 0;
      for(int j = 0 ; j <= m ; j++){
	sum += G[i][j];
      }
      if(min_ > sum){
	min_ = sum;
	num = i;
      }
    }
    cout << num << " " << min_ << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
struct node
{
	int x,l;
}a[100005];
int n,i,j,ans;
bool cmp(node a,node b)
{
	return a.x+a.l<b.x+b.l;
}
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;++i)
		scanf("%d%d",&a[i].x,&a[i].l);
	sort(a+1,a+1+n,cmp);
	for(i=1,j=-(1<<30);i<=n;++i)
	{
		if(a[i].x-a[i].l>=j)
			j=a[i].x+a[i].l,++ans;
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 896
#include <iostream>

int main()
{
    int r, D, x_2000;
    std::cin >> r >> D >> x_2000;

    int x = x_2000;
    for (int i = 0; i < 10; i++)
    {
        x = r * x - D;
        std::cout << x << std::endl;
    }

    return 0;
}


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

int main(){
	double v, t, y, h;
	while( cin >> v ){
		t = v / 9.8;
		y = 4.9 * t * t;
		for( h=1; y>5*h-5; h++ );
		cout << h << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <algorithm>

int n,x[200005],l,q,Next[200005][21];

int main()
{
    //freopen("in.txt","r",stdin);
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%d",&x[i]);
    scanf("%d%d",&l,&q);
    for(int i=n,j=n;i>=1;--i)
    {
        while(x[j]-x[i]>l)--j;
        Next[i][0]=j;
        for(int k=1;k<=20;++k)Next[i][k]=Next[Next[i][k-1]][k-1];
    }
    for(int a,b;q--;)
    {
        scanf("%d%d",&a,&b);
        if(a>b)std::swap(a,b);
        if(a==b){puts("0");continue;}
        int Ans=0;
        for(int i=20;i>=0;--i)
            if(Next[a][i]<b)
                Ans+=1<<i,a=Next[a][i];
        printf("%d\n",Ans+1);
    }
    return 0;
}

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

int s, ans = 0;

int main() {
  cin >> s;
  if(s / 100 >= 0 && s / 100 <= 99 && s % 100 >= 1 &&
     s % 100 <= 12)
    ++ans;
  if(s / 100 >= 1 && s / 100 <= 12 && s % 100 >= 0 &&
     s % 100 <= 99)
    ans += 2;
  if(ans == 3)
    cout << "AMBIGUOUS" << endl;
  else if(ans == 2)
    cout << "MMYY" << endl;
  else if(ans == 1)
    cout << "YYMM" << endl;
  else
    cout << "NA" << endl;
  return 0;
}

Measured memory_bytes: 256
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=9e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  set<char> se;
  for(int i=0; i<4; i++) {
    se.insert(s[i]);
  }
  sort(s.begin(),s.end());
  if(se.size()==2&&s[0]!=s[2]) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    long min, max, sum;
    String[] strArray = br.readLine().split(" ");
    long[] longArray = new long[n];
    for (int i = 0;i < n;i++) {
      longArray[i] = Long.parseLong(strArray[i]);
    }
    min = longArray[0];
    max = longArray[0];
    sum = longArray[0];
    for (int i = 1;i < n;i++) {
      min = Math.min(min,longArray[i]);
      max = Math.max(max,longArray[i]);
      sum += longArray[i];
    }
    System.out.println(min + " " + max + " " + sum);
  }
}

Measured memory_bytes: 28628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main{
    public static void main(String[] args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final StringBuilder sb = new StringBuilder();
        final int n = Integer.parseInt(br.readLine());
        final StringTokenizer in = new StringTokenizer(br.readLine(), " ");
        final int[] A = new int[n];
        for(int i = 0; i<n; i++)
            A[i] = Integer.parseInt(in.nextToken());
        final int x = partition(A, 0, n-1);
        for(int i = 0; i<x; i++)
            sb.append(A[i]).append(' ');
        sb.append('[').append(A[x]).append(']');
        for(int i = x+1; i<n; i++)
            sb.append(' ').append(A[i]);
        System.out.println(sb);
    }
    private static int partition(int[] A, int p, int r){
        final int x = A[r];
        int i = p;
        int t;
        for(int j = p; j<r; j++){
            if(A[j]<=x){
                t = A[i];
                A[i] = A[j];
                A[j] = t;
                i++;
            }
        }
        A[r] = A[i];
        A[i] = x;
        return i;
    }
}

Measured memory_bytes: 39312
a,b,c,k = map(int,input().split())
if k <= a :
    print(k)
else :
    m = min(k,a)
    k -= a

    if k <= b :
        print(a)
    else :
        n = min(k,b)
        k -= b
        l = k
        print(1*m+(-1)*l)

Measured memory_bytes: 9176
import Control.Applicative
import Control.Monad
import Data.List
import qualified Data.Map as M
import Text.Printf

readInts :: IO [Int]
readInts = map read . words <$> getLine

main :: IO ()
main = do
  getLine
  xs <- readInts
  putStrLn $ unwords $ map show $ solve xs

solve :: [Int] -> [Int]
solve = reverse



Measured memory_bytes: 4044
#include <stdio.h>

 
void maxH(int *node, int i, int g){
  int l, r, large, s;
  
  l = i*2;
  r = i*2+1;
    
  if(l <= g && node[l] > node[i]) large = l;
  else large = i;
  if(r <= g && node[r] > node[large])large = r;
 
  if(large != i){
    s = node[i];
    node[i] = node[large];
    node[large] = s;
    maxH(node, large, g);
  }
}
 
main(){
  int i, g;
  int node[500001];
 
  scanf("%d", &g);
 
  for(i=1;i<=g;i++) scanf("%d", &node[i]);
 
  for(i =g/2;i>0;i--) maxH(node,i,g);
 
 
  for(i=1;i<=g;i++) printf(" %d",node[i]);
 
  printf("\n");
  return 0; 
}

Measured memory_bytes: 2552
open System.IO
open System

let [| n; q; |] = stdin.ReadLine().Split() |> Array.map int
let s = stdin.ReadLine()
let lr = [| for _ in 1..q -> stdin.ReadLine().Split() |> Array.map int |]

let sw = new StreamWriter(Console.OpenStandardOutput())
sw.AutoFlush <- false
Console.SetOut(sw)

let appearanceArrayToRight =
    let sPair = s.ToCharArray() |> Array.pairwise 
    [|
        //最初の一文字
        yield 0
        let mutable app = 0
        for pair in sPair do
            if pair = ('A', 'C') then 
                app <- app + 1
            yield app
    |]

let getAppearance _begin _end =
    appearanceArrayToRight.[_end-1] - appearanceArrayToRight.[_begin-1]

lr
|> Array.map (fun [| l; r; |] -> getAppearance l r |> string)
|> Array.iter stdout.WriteLine

stdout.Flush()




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

using namespace std;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    if (N == 1 && M == 0) {
        cout << 0 << endl;
        return 0;
    }
    vector<char> num(N, 40);
    for (int i = 0; i < M; i++) {
        int s;
        char c;
        cin >> s >> c;
        s--;
        if (s == 0 && c == '0' && N >= 2) {
            cout << -1 << endl;
            return 0;
        }
        if (num[s] == 40) {
            num[s] = c;
        } else if (num[s] != c) {
            cout << -1 << endl;
            return 0;
        }
    }
    string ans = "";
    for (int i = 0; i < N; i++) {
        if (i == 0) {
            ans = num[i] == 40 ? '1' : num[i];
        } else {
            ans += num[i] == 40 ? '0' : num[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#include <math.h>
#define ll long long 
#define PI 3.14159265358979323846
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(x,n) for(ll x=1;x<(ll)n+1;x++)
using namespace std;

int main() {
	string N;
	cin >> N;
	if (N[N.length()-1] == 's') {
		cout << N;
		cout << "es" << endl;
	}
	else {
		cout << N;
		cout << 's' << endl;
	}
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <list>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    list<char> lst;
    for (int i = 0; i < s.size(); ++i) {
        lst.push_back(s[i]);
    }

    
    auto it = lst.begin();
    ++it;
    ++it;
    ++it;
    ++it;
    lst.insert(it, ' ');

    for (auto it = lst.begin(); it != lst.end(); ++it) {
        cout << *it;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<math.h>
#define ll long long int 
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);    
      
	ll n;
	cin>>n;
	ll a[n];
	ll i;
	ll p=1;
	ll s2=0;
	for(i=0;i<n;i++){
        a[i]=p;
		p++;
		s2=s2+a[i];
	}
	
	
    ll s=0;
    for(i=0;i<n;i++){

       if(a[i]%3==0&&a[i]%5==0){
	   	s=s+a[i]; 
       }
    
       else if(a[i]%3==0){
        s=s+a[i];
	   }
	  
       else if(a[i]%5==0) {
       s=s+a[i];	
	   }
      
	}
	  cout<<abs(s2-s)<<endl;
      return 0;
  
}

Measured memory_bytes: 11400
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <climits>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

#define fast_cin() ios_base::sync_with_stdio(false)

typedef long double ld;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

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

	for (int si = 0; si < N; ++si) {
		int s = si, t = 0;
		while(s < N) {
			if (S[s] != T[t]) {
				break;
			} else {
				++s; ++t;
			}
		}
		if (s == N) {
			cout << si + N << endl;
			return 0;
		}
	}
	cout << 2 * N << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

void solve() {
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i, n)cin >> h[i];
	int ma = 0;
	int cnt = 0;
	rep(i, n) {
		if (ma <= h[i])cnt++;
		ma = max(ma, h[i]);
	}
	cout << cnt << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


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

void fnInput(string& rsMaxNum)
{
  cin >> rsMaxNum;
}

int fnDgtDP(string sMaxNum)
{
  // dp[nPos][nSmall][nFlag] :=  nPos  : 上位 nPos 桁目まで決定
  //                             nSmall: small(数字を自由に選べる)か
  //                             nFlag : 上位 nPos 桁までで {3,5,7} を選択したかflag
  //                             ( 0:選択なし, 1: 3   選択, 2: 5   選択, 3: 3 5   選択, 
  //                               4: 7 選択 , 5: 3 7 選択, 6: 5 7 選択, 7: 3 5 7 選択 )
  //                             の条件を満たす数値の数
  int dp[11][2][8] = {};
  dp[0][0][0] = 1;

  int nLen = sMaxNum.size();

  for (int nPos = 0; nPos < nLen; ++nPos)
    for (int nSmall = 0; nSmall < 2; ++nSmall)
      for (int nFlag = 0; nFlag < 8; ++nFlag)
      {
        if (!dp[nPos][nSmall][nFlag]) continue;

        if (nSmall == 1)               // small ([0, 9] から数字を選べる)か
        {
          if (!nFlag)
            dp[nPos + 1][1][0]       += dp[nPos][1][0];                    // nothing

          dp[nPos + 1][1][nFlag | 1] += dp[nPos][1][nFlag];                // +3
          dp[nPos + 1][1][nFlag | 2] += dp[nPos][1][nFlag];                // +5
          dp[nPos + 1][1][nFlag | 4] += dp[nPos][1][nFlag];                // +7
        }
        else                           // not small ([0, nDgt] から数字を選べる)か
        {
          int nDgt = sMaxNum[nPos] - '0';

          if (!nFlag)    dp[nPos + 1][1][0]         += dp[nPos][0][0];     // nothing

          if (nDgt == 3) dp[nPos + 1][0][nFlag | 1] += dp[nPos][0][nFlag]; // +3
          if (3 < nDgt ) dp[nPos + 1][1][nFlag | 1] += dp[nPos][0][nFlag]; // +3
          if (nDgt == 5) dp[nPos + 1][0][nFlag | 2] += dp[nPos][0][nFlag]; // +5
          if (5 < nDgt ) dp[nPos + 1][1][nFlag | 2] += dp[nPos][0][nFlag]; // +5
          if (nDgt == 7) dp[nPos + 1][0][nFlag | 4] += dp[nPos][0][nFlag]; // +7
          if (7 < nDgt ) dp[nPos + 1][1][nFlag | 4] += dp[nPos][0][nFlag]; // +7
        }
      }
/*
  for (int nPos = 0; nPos <= nLen; ++nPos)
     for (int nSmall = 0; nSmall < 2; ++nSmall)
       for (int nFlag = 0; nFlag < 8; ++nFlag)
         if (dp[nPos][nSmall][nFlag])
         {
           cout << "dp[" << nPos << "][" << nSmall << "][" << nFlag << "] = (";
           cout << dp[nPos][nSmall][nFlag] << ")" << endl;
         }
*/
  return dp[nLen][0][7] + dp[nLen][1][7];
}

int main()
{
  string sMaxNum;

  fnInput(sMaxNum);
  cout << fnDgtDP(sMaxNum) << endl;
  
  return 0;
}

Measured memory_bytes: 3540
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

constexpr ll INF = 1e16;

#define rep(i, N) for(ll i=0; i<N; ++i)

ll max(ll a, ll b) {return a < b ? b : a; }
ll min(ll a, ll b) {return a > b ? b : a; }
double maxf(double a, double b) { return a < b ? b : a; }

int main() {
  int a, b, c, ans = 0, sum;
  cin>>a>>b>>c;



  while(true){
    if(a%2 != 0 || b%2 != 0 || c%2 != 0){
      break;
    }else{
      if(a == b && b == c){
        cout<<"-1"<<endl;
        exit(0);
      }else{
        sum = a + b + c;
        a = (sum - a)/2; b = (sum - b)/2; c = (sum - c)/2;
      }
    }
    ans++;
  }

  cout<<ans<<endl;

  return 0;
}


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

long long K;
vector<long long> vec;

int main(){
	cin >> K;
	
	long long num;
	if(K%50 == 0){
		num = K/50;
	}else{
		num = K/50;
		num++;
	}

	for(long long i = 0; i < 50; i++){
		vec.push_back(49 + num);
	}

	num = 50 * num - K;

	for(long long i = 0; i < num; i++){
		long long maxi = -1;
		long long maxipos = -1;
		for(long long pos = 0; pos < 50; pos++){
			if(vec[pos] > maxi){
				maxi = vec[pos];
				maxipos = pos;
			}
		}

		for(long long pos = 0; pos < 50; pos++){
			if(pos == maxipos){
				vec[pos] -= 50;
			}else{
				vec[pos]++;
			}
		}
	}

	cout << 50 << endl;
	for(long long i = 0; i < 50; i++){
		cout << vec[i];
		if(i != 49){
			cout << " ";
		}
	}
	cout << endl;
}



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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n),b(n);
	rep(i,n) scanf("%d",&a[i]);
	rep(i,n) scanf("%d",&b[i]);

	lint asum=0,bsum=0;
	rep(i,n){
		asum+=a[i];
		bsum+=b[i];
	}

	if(asum>bsum) return puts("No"),0;

	lint k1=0,k2=0;
	rep(i,n){
		if(a[i]>b[i]){
			k2+=a[i]-b[i];
		}
		else if(a[i]<b[i]){
			if((b[i]-a[i])%2==0){
				k1+=(b[i]-a[i])/2;
			}
			else{
				k1+=(b[i]-a[i]+1)/2;
				k2++;
			}
		}
	}

	lint m=bsum-asum;
	if(k1<=m && k2<=m && 2*(m-k1)==m-k2){
		puts("Yes");
	}
	else puts("No");

	return 0;
}


Measured memory_bytes: 3756
#include<iostream>
#include<stdlib.h>
#define N 1000000
using namespace std;
    
int main(){
    int a,h[N],max=-1,b=0;
    cin>>a;
    for(int i=0;i<a;i++){
        cin>>h[i];
    }
    for(int i=0;i<a;i++){
        if(h[i]>=h[i+1]){
            b++;
        }
        else{
            
            if(max<b){
                max=b;
                b=0;
            }
            b=0;
        }
    }
    if(max<b){
                max=b-1;
                b=0;
            }
    cout<<max<<endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
	int l, r;
	cin>>l>>r;
	map<int, int>m;
	int ok=1;
	while(l<=r)
	{
		m[l%2019]++;
		if(sz(m)==2019)break;
		l++;
	}
	int mn = INF;
	for(int i = 0; i < 2019; i++){
		if(m[i]){
			for(int j = i+1; j < 2019; j++){
				if(m[j])mn=min(mn, (i*j)%2019);
			}
		}
	}
	cout<<mn;
}
signed main(){
	speed;
	int t=1;
	//cin>>t;
	while(t--)solve();
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
const int N=500005;
typedef long long ll;

ll a[6],b[6];
const ll MOD=(ll)1e9+7;
ll qpow(ll x,ll y)
{
    ll ret=1;
    while(y)
    {
        if(y&1) ret=ret*x%MOD;
        x=x*x%MOD;
        y>>=1;
    }
    return ret;
}

ll fac[N];
ll C(ll n,ll m)
{
    return fac[n]*qpow(fac[m],MOD-2)%MOD*qpow(fac[n-m],MOD-2)%MOD;
}

void solve()
{
    ll n; scanf("%lld",&n);
    fac[0]=1; for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i%MOD;
    ll ans=0;
    for(int i=1;i*3<=n;i++)
    {
        ans=(ans+C(i-1+n-i*3,n-i*3))%MOD;
    }
    cout<<ans<<endl;
}

int main()
{
    int TTT=1; //scanf("%d",&TTT);
    while(TTT--){solve();}
    return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll a, b, c;
    cin >> a >> b >> c;
    cout << max(c-(a-b), 0LL) << endl;
    return 0;
}

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

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

  if (1 > n || n > 10000){
    cout << "No" << endl;
  }
  else if (0 > a || a > 1000){
    cout << "No" << endl;
  }
  else{
    b = n % 500;
    if (b > a){
      cout << "No" << endl;
    }
    else{
      cout << "Yes" << endl;
    }
  }
}

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

using namespace std;

#define int long long

vector<int> prime, pw;
int n, p, ans = 1;

inline void f(int n) {
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			prime.push_back(i);
			int res = 0;
			while (n % i == 0) {
				n /= i;
				res++;
			}
			pw.push_back(res);
		}
	}
	if (n != 1) {
		prime.push_back(n);
		pw.push_back(1);	
	}
}

int32_t main() {
	cin >> n >> p;
	f(p);
	for (int i = 0; i < prime.size(); i++) {
		for (int j = 0; j < pw[i] / n; j++)
			ans *= prime[i];
	}
	return cout << ans, 0;
}

Measured memory_bytes: 256
N = int(input())
A = sorted(map(int,input().split())) + [10**10]
B = sorted(map(int,input().split())) + [10**10+1]
C = sorted(map(int,input().split())) + [10**10+2]

j = 0
nB = [0]*(N+1)
for i in range(N):
    while B[i] >= C[j]:
        j += 1
    nB[i] = N-j

S = [0]*(N+1)
for i in range(N-1,-1,-1):
    S[i] = S[i+1] + nB[i]
ans = 0
j = 0
for i in range(N):
    while A[i] >= B[j]:
        j += 1
    ans += S[j]
print(ans)

Measured memory_bytes: 24332
#include <iostream>
#include<string>
#include<vector>
#include <algorithm>
using namespace std;
int main(void){
    int N;
    cin >> N;
    int p[N];
    for(int i = 0; i < N;i++){
        cin >> p[i];
    }
    
    int cont = 0;
    for(int i = 1; i < N-1;i++){
        if(p[i]>p[i+1]&&p[i]<p[i-1])cont++;
        else  if(p[i]<p[i+1]&&p[i]>p[i-1])cont++;
    }
    
    cout << cont << endl;
    
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,money;
  cin>>n>>money;
  
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n-i;j++){
      if(i*10000 + j*5000 + (n-i-j)*1000 == money){
	cout<<i<<' '<<j<<' '<<(n-i-j)<<endl;
	return(0);
      }
    }
  }
  cout<<-1<<' '<<-1<<' '<<-1<<endl;
  return(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f,oo = inf;
#define pi 3.14159265358979323846
#define IL inline
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define Rep(i,a,b) for(int i=(a);i<=(b);++i)
#define Dep(i,a,b) for(int i=(a);i>=(b);--i)
#define pc putchar
#define gc getchar
IL ll read(){
    ll x=0;char f=0;char c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return f?-x:x;
}
IL void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);pc(x%10+'0');}
IL void writeln(ll x){write(x);pc('\n');}
IL void wri(ll x){write(x),pc(' ');}
#define debug(x) printf(#x" = %d\n",x);
#define rd() read()
#define rdb() readdb()
#define mem(x,v) memset(x,v,sizeof(x))
#define pb push_back
#define mp make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define y1 ____y1
#define hash __hash
#define union _union
#define ramdom ((double)rand() / RAND_MAX)
#define x first
#define y second
const int maxn = 2005+233;
struct Edge{
	int to,nxt;
	Edge(){}
	Edge(int to,int nxt):to(to),nxt(nxt){}
}edge[maxn*2];
int first[maxn],nume;
void Addedge(int a,int b){
	edge[nume] = Edge(b,first[a]);
	first[a] = nume++;
}
int mxdep[maxn],wson[maxn],sz[maxn];
int dfn[maxn],dfx[maxn],n,k;
int dp_array[maxn];
int *f[maxn];
void init(int u,int fa){
	mxdep[u] = 0;wson[u] = 0;sz[u] = 1;
	for(int e=first[u];~e;e=edge[e].nxt){
		int v=edge[e].to;
		if(v == fa) continue;
		init(v,u);
		mxdep[u] = max(mxdep[u],mxdep[v] + 1);
		sz[u] += sz[v];
		if(!wson[u] || mxdep[v] > mxdep[wson[u]])
			wson[u] = v;
	}
}
void pre(int u,int fa){
	dfx[dfn[u] = ++*dfn] = u;
	f[u] = dp_array + dfn[u];
	if(wson[u]) pre(wson[u],u);
	for(int e=first[u];~e;e=edge[e].nxt){
		int v=edge[e].to;
		if(v==fa || v==wson[u]) continue;
		pre(v,u);
	}
}
int g[maxn],h[maxn],ans;
void dfs(int u,int fa){
	if(wson[u]) dfs(wson[u],u);
	f[u][0] = wson[u] ? sz[wson[u]] : 0;
//	printf("#8999 %d %d\n",u,mxdep[u]);
	int m = min(k,mxdep[u]);
//	Rep(i,0,m) wri(f[u][i]);puts("");
	for(int e=first[u];~e;e=edge[e].nxt){
		int v = edge[e].to;
		if(v==wson[u] || v==fa) continue;
		dfs(v,u);
		int len = min(k,mxdep[v] + 1);
		g[0] = sz[v];Rep(i,1,len) g[i] = f[v][i-1];
		Rep(i,0,len) h[i] = f[u][i];
//		puts("~~"); 
//		wri(g[0]),writeln(h[0]);

//		Rep(i,0,len) wri(g[i]);puts("");
//		Rep(i,0,len) wri(h[i]);puts("");
//		puts("~~~~~~~~~~~~");

		Rep(i,0,len) f[u][i] = min(g[i]+h[min(i,k-i)],g[min(i,k-i)] + h[i]);
		Rep(i,len+1,min(m,k-len-1)) f[u][i] += g[len];
		Rep(i,max(len+1,k-len),min(m,k)) f[u][i] += g[k-i];
		Rep(i,1,m) f[u][i] = min(f[u][i],f[u][i-1]);
	}
	ans = min(ans,n - sz[u] + f[u][min(k,m)]);
	//从root往上搞一格
}
int main(){
	mem(first,-1);nume = 0;
	n = read();k = read();ans = n;
	rep(i,1,n) {
		int x = read(),y = read();
		Addedge(x,y);
		Addedge(y,x);
	} init(1,0);
	*dfn = 0;
	pre(1,0);
	dfs(1,0);
	writeln(ans);
	return 0;
}


Measured memory_bytes: 3772
#include<string>
#include<iostream>
#include<vector>
using namespace std;

struct Item{
  string name;

  int cost;
};

struct recipe{
  vector<string> needs;
  string product;
};

int main() {
  int n;
  while(1){
    cin>>n;
    if(n==0)break;

    string name;
    int cost;
    vector<Item> itemlist;
    Item item;

    while(n--){
      cin>>name>>cost;
      item.name=name;
      item.cost=cost;
      itemlist.push_back(item);
    }

    cin>>n;

    int num;
    recipe r;
    vector<recipe> repices;

    while(n--){
      cin>>name>>num;
      r.product=name;
      r.needs.clear();

      while(num--){
	cin>>name;
	r.needs.push_back(name);
      }

      repices.push_back(r);
    }

    for(int p=0; p<repices.size(); p++){
      for(int i=0; i<repices.size(); i++){
	int t=0;

	for(int j=0; j< repices[i].needs.size(); j++){
	  for(int k=0; k<itemlist.size(); k++){
	    if(repices[i].needs[j] == itemlist[k].name) {
	      t+=itemlist[k].cost;
	    }
	  }
	}

	for(int j=0; j < itemlist.size(); j++)
	  if(repices[i].product == itemlist[j].name && t < itemlist[j].cost)
	    itemlist[j].cost = t,t=0;
      }
    }

    cin>>name;

    for(int j=0; j < itemlist.size(); j++){
      if(itemlist[j].name == name ) cout<<itemlist[j].cost<<endl;
    }

  }
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int ans=0;
		int difMax=0;
		for(int i=0;i<5;i++) {
			int a=sc.nextInt();
			int b=(a+9)/10*10;
			ans+=b;
			int dif=b-a;
			if(difMax<dif) {
				difMax=dif;
			}
		}

		System.out.println(ans-difMax);
	}
}

Measured memory_bytes: 23124
#include <iostream>

using namespace std;

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

    cin >> a >> b >> c;

    if(a < b){
        if(a < c && c < b){
            cout << "Yes" << endl;
            return 0;
        }
    }else{
        if(b < c && c < a){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define FOR(i, n, m) for(ll i = (ll)n; i < (ll)(m); i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define PRINT(x) std::cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dx[8] = {0,1,0,-1, 1, -1, 1, -1}, dy[8] = {1,0,-1,0,1,1,-1,-1};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) os << v[i] << " ";  
    return os; 
}

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}

int main()
{
  ll X, N;
  cin >> X >> N;
  set<ll> p;
  REP(i, N) {
    ll t;
    cin >> t;
    p.insert(t);
  }
  ll mi = INF;
  ll ans = 0;
  FOR(i, -200, 201) {
    if (abs(i - X) < mi && p.find(i) == p.end()) {
      mi = abs(i-X);
      ans = i;
    } 
  }
  PRINT(ans);
  return 0;
} 


Measured memory_bytes: 3620