akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	ll A, B, K;
	cin >> A >> B >> K;
	ll tmp = K;
	K = max(0ll, K - A);
	A = max(0ll , A - tmp);
	B = max(0ll, B - K);
	cout << A << " " << B << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mood;
		}
		x = x * x % mood;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, x[10], y[10];
vector<int> vec;
long double ans;
int cnt;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}
	for (int i = 0; i < n; i++)vec.push_back(i);
	do {
		cnt++;
		for (int i = 1; i < n; i++) {
			ans += sqrt((x[vec[i]] - x[vec[i - 1]])*(x[vec[i]] - x[vec[i - 1]]) + (y[vec[i]] - y[vec[i - 1]])*(y[vec[i]] - y[vec[i - 1]]));
		}
	} while (next_permutation(all(vec)));
	printf("%.10Lf", ans / cnt);
}

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

int main()
{
    int n;
    cin >> n;
    vector<double> t(n), v(n);
    for(auto& ti:t) cin >> ti;
    for(auto& vi:v) cin >> vi;

    vector<double> y0(n+1,0);
    double st = 0;
    rep(i,n) {
        y0[i] = v[i] + st;
        st += t[i];
    }
    y0[n] = st;

    double d = 0;
    double cv = 0;
    double ct = 0;
    double dt = 0.5;

    rep(i,n) {
        double min_y0 = 1e9;
        rep2(j,i+1,n+1) 
            min_y0 = min(min_y0, y0[j]);

        rep(j,t[i]*2) {            
            ct += dt;
            double limit = min(v[i], min_y0-ct);
            double pv = cv;
            cv = min(cv+dt, limit);
            d += (pv + cv) * dt / 2;
        }
    }

    cout << fixed << setprecision(12) << d << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1e9 + 7;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
/*ll fact_[200000];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1;
		for (int i = 1; i < 200000; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
		}
	}
	if (x < y) return 0;
	return mod_pow(fact_[x], mod, mod) *
		mod_pow(fact_[x - y], mod - 2, mod) % mod *
		mod_pow(fact_[y], mod - 2, mod) % mod;
}//xCy*/
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int t1, t2, a1, a2, b1, b2;
signed main() {
	cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
	if (t1 * a1 + t2 * a2 == t1 * b1 + t2 * b2) {
		cout << "infinity\n";
		return 0;
	}
	int ans = 0;
	int k = t1 * a1 - t1 * b1;
	int r = t1 * a1 + t2 * a2 - t1 * b1 - t2 * b2;
	if ((k > 0) != (r > 0)) {
		ans++;
		k = abs(k); r = abs(r);
		ans += 2 * (k / r);
		if (k % r == 0) {
			ans--;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

template<class Ty>
using passive_queue = priority_queue<Ty, vector<Ty>, greater<Ty>>;

struct Problem {

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

	void Solve() {
		/*

		UL K; cin >> K;
		UL T[201] = {};

		for (UL i = 1; i <= K; i++) {
			for (UL j = 1; j <= K; j++) {
				T[gcd(i, j)]++;
			}
		}


		ULL ans = 0;
		for (UL i = 1; i <= K; i++) {
			for (UL j = 1; j <= K; j++) {
				ans += T[i] * gcd(i, j);
			}
		}

		cout << ans << endl;*/


		UL N; cin >> N;
		string S; cin >> S;

		ULL ans = 0;

		rep(q, 2) {
			rep(t, 3) {

				UL R[4001] = {};
				UL B[4001] = {};
				rep(i, N) {
					R[i + 1] = R[i];
					if (S[i] == 'R') R[i + 1]++;
					B[N - i - 1] = B[N - i];
					if (S[N - i - 1] == 'B') B[N - i - 1]++;
				}
				rep(i, N) {
					if (S[i] == 'G') {
						ans += R[i] * B[i];
					}
				}

				rep(i, N) {
					if (S[i] == 'R') S[i] = 'B';
					else if (S[i] == 'B') S[i] = 'G';
					else S[i] = 'R';
				}
			}
			reverse(S.begin(), S.end());
		}

		rep(i, N) {
			rep(j, min(i, N - i - 1)) {
				if (S[i] != S[i - j - 1]) if (S[i] != S[i + j + 1]) if (S[i - j - 1] != S[i + j + 1])
					ans--;
			}
		}

		cout << ans << endl;

	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 3668
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	string s, ans;
	int n, i, j, k, x;
	cin >> n >> s;

	for (i = 0; i < s.length(); i++) {
		x = s[i] - 'A';
		x = (x + n) % 26;
		s[i] = 'A' + x;
	}

	cout << s << "\n";


	return 0;
}



Measured memory_bytes: 888
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    double a[n];
    rep(i, n) cin >> a[i];
    double ans = 0;
    rep(i, n) ans += 1.0 / a[i];
    ans = 1.0 / ans;
    printf("%f\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;



int main() {
    ios_base::sync_with_stdio(false); 

    int n;
    cin >> n;
    vector<int> a,b; 
    int in;
    rep(i,n) {
        cin >> in;
        if (i%2==0) a.push_back(in);
        else b.push_back(in);
    }
    int n1=a.size(),n2=b.size();
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    vector<pair<int,int>> aa,bb;
    int cnt=1;
    rep(i,n1-1) {
        if (a[i]==a[i+1]) ++cnt;
        else {
            aa.push_back(make_pair(cnt,a[i]));
            cnt=1;
        }
    }
    aa.push_back(make_pair(cnt,a[n1-1]));
    aa.push_back(make_pair(0,0));
    cnt=1;
    rep(i,n2-1) {
        if (b[i]==b[i+1]) ++cnt;
        else {
            bb.push_back(make_pair(cnt,b[i]));
            cnt=1;
        }
    }
    bb.push_back(make_pair(cnt,b[n1-1]));
    bb.push_back(make_pair(0,0));
    sort(aa.begin(),aa.end(),greater<>());
    sort(bb.begin(),bb.end(),greater<>());
    int ans=0;
    rep(i,2) {
        rep(j,2) {
            if (aa[i].second!=bb[j].second) {
                ans=max(ans,aa[i].first+bb[j].first);
            }
        }
    }

    cout << n-ans << endl;

    return 0;
}

Measured memory_bytes: 1784
import qualified Data.Map as M
import Control.Monad
import Control.Applicative

part _ n | n <= 0 = [0]
part [] _ = []
part (x:xs) n =  part xs n ++ (map (x+) $ part xs (n-1))

main = do
  [n, s] <- getInts
  if (n == 0 && s == 0) then return ()
  else do
    print $ length $ filter (== s) $ part [0..9] n
    main

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

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s,t;
	cin >> s >> t;
	long long a,b;
	cin >> a >> b;
	string ss;
	cin >> ss;
	
	if(ss==s) a--;
	else b--;
	cout << a << " " << b << "\n";
	
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
from operator import itemgetter

def main():
    W,H = map(int,input().split())
    l = []
    for _ in range(W):
        p = int(input())
        l.append((p,0))
    for _ in range(H):
        p = int(input())
        l.append((p,1))
        
    l.sort(key=itemgetter(0))
    a,b = W+1,H+1
    ans = 0
    for d,now in l:
        if now == 0:
            ans += d*b
            a -= 1
        else:
            ans += d*a
            b -= 1
    
    print(ans)

if __name__ == "__main__":
    main()


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

using namespace std;

int main() {
  int N;
  cin >> N;
  unordered_map<string, uint64_t> cache;
  for (int i = 0; i < N; ++i) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    ++cache[s];
  }
  uint64_t result = 0;
  for (auto it = cache.begin(); it != cache.end(); ++it) {
    auto cnt = it->second;
    result += (cnt - 1) * cnt / 2;
  }
  cout << result << endl;
}


Measured memory_bytes: 10660
#include<vector>
#include<map>
#include<algorithm>
#include<set>
#include<iostream>
#include<string>
#include<set>
#include<queue>
#include<random>
#include<unordered_set>

using namespace std;

/*

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

tree<pair<long long, long long>, null_type, less<pair<long long, long long>>, rb_tree_tag, tree_order_statistics_node_update> st;

*/
/*

st.find_by_order();
st.order_of_key();

*/

#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

#define pb push_back
#define ld long double
#define int long long

mt19937 rnd(51);


//после этой задачи, ты должен написать Фенвика

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    int dp[n + 1][m + 1], v[n + 1][m + 1];
    for (int i = 0; i <= n; i++){
        for (int j = 0; j <= m; j++){
            dp[i][j] = v[i][j] = 0;
        }
    }
    for (int i = 0; i < k; i++){
        int l, r, val;
        cin >> l >> r >> val;
        v[l][r] = val;
    }
    for (int i = 1; i <= n; i++){
        vector<int> mx(4);
        for (int j = 1; j <= m; j++){
            mx[0] = max(mx[0], dp[i - 1][j]);
            if (v[i][j] != 0){
                for (int k = 3; k > 0; k--){
                    mx[k] = max(mx[k], mx[k - 1] + v[i][j]);
                }
            }
            dp[i][j] = max(dp[i][j - 1], max({mx[0], mx[1], mx[2], mx[3]}));
        }
    }
    cout << dp[n][m];
    return 0;
}


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

int main()
{
	int num, sequence,MOD1=0,MOD2=0,MOD4=0;
	cin >> num;
	for (int i = 0; i < num; i++)
	{
		cin >> sequence;
		if (sequence % 4 == 0) MOD4++;
		else if (sequence % 2 == 0) MOD2++;
		else MOD1++;
	} 
	if (MOD1>MOD4 + 1 || (MOD1 == MOD4 + 1 && MOD2 != 0)) 
		cout<<"No"<<endl;
	else 
		cout<<"Yes"<<endl;
	
	return 0;
}


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

string grid[1001];
ll dp[1001][1001];
const ll mod = 1000000007;

int main() {
    int H, W;
    cin >> H >> W;
    rep(i, H) {
        cin >> grid[i];
    }
    dp[0][0] = 1;
    rep(i, H) rep(j, W) {
        if (grid[i][j] == '#')
            continue;
        if (grid[i + 1][j] != '#') {
            dp[i + 1][j] += dp[i][j];
            dp[i + 1][j] %= mod;
        }
        if (grid[i][j + 1] != '#') {
            dp[i][j + 1] += dp[i][j];
            dp[i][j + 1] %= mod;
        }
    }
    cout << dp[H - 1][W - 1] << endl;
}

Measured memory_bytes: 13344
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) begin(v), end(v)
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,b) FOR(i,0,b)

const int mod = 1e9+7;


string s,t;
signed main(){
  cin>>s>>t;
  if(s=="D"){
    if(t=="H"){
      cout<<"D"<<endl;
    }else{
      cout<<"H"<<endl;
    }
  }else{
    if(t=="H"){
      cout<<"H"<<endl;
    }else{
      cout<<"D"<<endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int n,m;
    cin >> n >> m;
    vi a(n,1);
    vector<bool> che(n,0);
    che[0] = true;
    rep(i,m){
        int x,y;
        cin >> x >> y;
        x--;y--;
        if(che[x]){
            che[y] = true;
            if(a[x]==1) che[x] = false;
        }
        a[x]--;
        a[y]++;
    }
    ll ans = 0;
    rep(i,n) if(che[i]){
        ans++;
    }
    cout << ans << endl;
}

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

int main()
{
    int A, B, C, D, E;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> D;
    cin >> E;
    int times[5] = {A, B, C, D, E}, r[5], sum;
    for (int i = 0; i < 5; i++) {
        if (times[i] % 10 == 0) {
            r[i] = 10;
        }
        else {
            r[i] = times[i] % 10;
        }
    }
    int index_min = 0;
    for (int i = 1; i < 5; i++) {
        if (r[index_min] > r[i]) {
            index_min = i;
        }
    }
    for (int i = 0; i < 5; i++) {
        if (i == index_min) {
            sum += times[i];
        }
        else {
            if (r[i] == 10) {
                sum += times[i];
            }
            else {
                sum += ((times[i] / 10) + 1) * 10;
            }
        }
    }
    cout << sum << endl;
    return 0;
}


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

int main(){
    int N;
    double T,A;
    cin >> N >> T >> A;
    int H_index = -1;
    double Opt = 10000;
    for (int i = 0; i < N; i++)
    {
        double H;
        cin >> H;
        if(abs(A - (T - H * 0.006)) < Opt){
            Opt = abs(A - (T - H * 0.006));
            H_index = i+1;
        }
    }
    cout << H_index << endl;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int n;
    cin >> n;

    cout << n * n * n << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int n,a,b;
    while(~scanf("%d",&n))
    {
        if(n==1)
        {
            printf("Hello World\n");
        }
        else
        {
            scanf("%d%d",&a,&b);
            printf("%d\n",a+b);
        }
    }

  return 0;
}


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

bool chk(vector<int> data, int n, int m){
    bool ret = true;

    for (int i = 0; i < n; i++){
        if (data.at(i) % m != 0){
            ret = false;
            break;
        }
    }
    return ret;
}

int retmod(vector<int> data, int n, int m){
    int mod = 1 << 29;
    for (int i = 0; i < n; i++){
        if (mod > data.at(i) % m && data.at(i) % m != 0){
            mod = data.at(i) % m;
        }
    }
    return mod;
}

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

    vector<int> data(n);
    for (int i = 0; i < n; i++){
        cin >> data.at(i);
    }

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

    int m = data.at(0);
    while(!chk(data, n, m)){
        m = retmod(data, n, m);
    }

    cout << m << endl;
}

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

#include <iostream>
#include <fstream>

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


class BRobotArms {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        ll x, l;
        in >> n;
        vector<pair<ll, ll>> xl;
        rep(i, n){
            in >> x >> l;
            xl.push_back(make_pair(x + l, x - l));
        }

        sort(all(xl));

        ll now = xl[0].first;
        ll res = 1;
        reps(i, 1, n-1){
            if(now <= xl[i].second){
                res++;
                now = xl[i].first;
            }
        }

        out << res << endl;
	}
};


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


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
int main() {
 	int n, k;
  	cin >> n >> k;
  	int a[n];
  	for (int i = 0; i < n; i++)
      	cin >> a[i];
  	sort(a,a+n);
  	int ans = INT_MAX;
  	for (int i = 0; i < n - k + 1; i++)
      ans = min(ans, a[i+k-1] - a[i]);
  	cout << ans << endl;
}

Measured memory_bytes: 768
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█
 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long lo;
typedef pair< lo,lo > PII;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(lo i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
 
const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;
 
lo n,m,b[li],a[li],k,flag,t,vis[li];
lo cev;
map<lo,lo> fa;
set<lo>st;
string s;
//~ map<int,int> fa;
PII p[li];
vector<lo> v;
 
inline lo dsu(lo x){
	if(x==fa[x])return x;
	return fa[x]=dsu(fa[x]);
}
 
int main(void){
	scanf("%lld %lld",&n,&m);
	for(int i=0;i<=n+100;i++){
		st.insert(i);
	}
	st.insert(inf);
	FOR{
		scanf("%lld %lld",&p[i].se,&p[i].fi);
	}
	sort(p+1,p+n+1);
	reverse(p+1,p+n+1);
	//~ lo gun=0,bas=inf;
	FOR{
		//~ if(vis[m-p[i].se]==1)continue;
		//~ if(vis[m-p[i].se]==0 && m-p[i].se>=0){
			//~ vis[m-p[i].se]=1;
			//~ st.erase(m-p[i].se);
			//~ cev+=p[i].fi;
			//~ continue;
		//~ }
		if(m-p[i].se<0)continue;
		auto it=st.upper_bound(m-p[i].se);
		if(it==st.begin())continue;
		it--;
		st.erase(*it);
		cev+=p[i].fi;
	}
	printf("%lld\n",cev);
	return 0;
}


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



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

    int a[n+5];
    int ans[n+5];

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

        ans[a[i]]=i;
    }

    rep(i,n){

        cout << ans[i] << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD=1000000007;

int main() {
    ll N; cin>>N;
    map<ll,ll> L;
    map<ll,ll> R;
    for(ll i=0;i<N;i++){
        ll A; cin>>A;
        L[i+A]++;
        R[i-A]++;
    }
    ll ans=0;
    for(ll i=1;i<2*N;i++){
        ans+=L[i]*R[i];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 68552
// ref. https://juppy.hatenablog.com/entry/2019/03/18/Educational_DP_Contest%28EDPC%29_G~K_Python_%E7%AB%B6%E6%8A%80%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0_Atcoder#EDPC--L

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

const ll N = 3005;
// dp[i][j] .. X value when start from [i,j].
ll dp[N][N];
ll a[N];
ll n;

// [i, j]
ll rec(ll i, ll j) {
  if (i > j) { return 0; } // no elements are left.
  if (dp[i][j] >= 0) { return dp[i][j]; }
  if ((j-i+1)%2 == n%2) { // first one
    ll left  = rec(i+1, j) + a[i];
    ll right = rec(i, j-1) + a[j];
    return dp[i][j] = max(left, right);
  } else {
    ll left  = rec(i+1, j);
    ll right = rec(i, j-1);
    return dp[i][j] = min(left, right);
  }
}

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  cin >> n;
  ll s = 0;
  rep(i, n) {
    cin >> a[i];
    s += a[i];
  }
  memset(dp, -1, sizeof(dp));
  ll X = rec(0, n-1);
  ll ans = 2*X - s;
  cout << ans << endl;
}


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

int main()
{
    // input
    int S;
    cin >> S;

    // 1h = 3600s
    // 1m = 60s
    // 余りって、division_remainder っていうらしい

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

    // output
    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
}



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

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

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <map>
#include <cstdio>
#include <set>
#include <algorithm>
#include <functional>
#include <string>

using namespace std;

using i64 = long long;

const int N = 200010;

i64 n, a[N], b[N], d[N];

int main() {
	cin >> n;
	i64 sum_a = 0, sum_b = 0;
	for (int i = 0; i < n; i++) scanf("%lld", a + i), sum_a += a[i];
	for (int i = 0; i < n; i++) scanf("%lld", b + i), sum_b += b[i];
	if (sum_a < sum_b) {
		puts("-1");
		exit(0);
	}

	i64 ans = 0, tot = 0;
	for (int i = 0; i < n; i++) {
		d[i] = a[i] - b[i];
		if (d[i] < 0) {
			ans++;
			tot += -d[i];
		}
	}
	if (ans == 0) {
		puts("0");
		exit(0);
	}
	i64 tmp = 0;
	sort(d, d + n);
	for (int i = n - 1; i >= 0; i--) {
		tmp += d[i];
		ans++;
		if (tmp > tot) break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sd second
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll w,h,x,y;
    cin>>w>>h>>x>>y;
    cout<<(double)w*h/2<<" "<<(2*x==w&&2*y==h);

}

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


int MOD=1000000007;

int main(void){
    int cou=0;
    string S,T;
    cin >> S >> T;
    if(S[0]==T[0]) cou+=1;
    if(S[1]==T[1]) cou+=1;
    if(S[2]==T[2]) cou+=1;
    cout << cou << endl;

    


}


Measured memory_bytes: 256
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

use std::cmp;

fn main() {
    let n = get!(usize);
    let k = get!(i32);
    let mut i = 1;
    for _ in 0..n {
        i = cmp::min(i+k, i*2);
    }
    println!("{}", i);
}

Measured memory_bytes: 2108
//#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#include <numeric>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << x << "\n"
using namespace std;
using point = pair< int,int >;
using ll = long long;

int main() {
    ll a, b , c, d;
    cin >> a >> b >> c >> d;

    OUT((b - a + 1) - (b / c - (a - 1) / c) - (b / d - (a - 1) / d) + (b / (c / __gcd(c, d) * d) - (a - 1) / (c / __gcd(c, d) * d)));
    return 0;
}



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

#define ll long long
#define vec vector<ll>
#define sortv(a); sort(a.begin(), a.end());
#define rev(a); reverse(a.begin(), a.end());
#define FOR(i,a,b) for (ll i = (ll)(a); i < (b); i++)
#define ROF(i,a,b) for (ll i = (ll)(b)-1; i >= (a); i--)

ll MOD = 1000000007;
ll INF = 1LL << 60;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	ll k;cin>>k;
	deque<ll> dq;
	FOR(i,1,10) dq.push_back(i);
	ll x=1;
	while(k>0) {
		k--;
		x=dq.front();
		dq.pop_front();
		if (x%10!=0) {
			dq.push_back(10*x+(x%10)-1);
		}
		dq.push_back(10*x+(x%10));
		if (x%10!=9) {
			dq.push_back(10*x+(x%10)+1);
		}
	}
	cout<<x;
}

Measured memory_bytes: 1792
#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 <math.h> // sqrt
#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 <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int H, W;
vi dy = {1, -1, 0, 0};
vi dx = {0, 0, 1, -1};

int bfs (vector<vector<char>> &data, int y, int x) {
    vector<vi> dist(H, vi(W, -1));
    queue<pair<int, int>> que;
    int ans = 0;
    que.push({y, x});
    dist[y][x] = 0;
    while(!que.empty()) {
        int y = que.front().first, x = que.front().second;
        ans = max(ans, dist[y][x]);
        que.pop();
        for (int i = 0; i < 4; i++) {
            int nx = x + dx[i], ny = y + dy[i];
            if (ny < 0 || ny >= H || nx < 0 || nx >= W) {
                continue;
            }
            if (data[ny][nx] == '#') {
                continue;
            }
            if (dist[ny][nx] == -1) {
                dist[ny][nx] = dist[y][x] + 1;
                que.push({ny, nx});
            }
        }
    }
    return ans;
}

int main() {
    cin >> H >> W;
    vector<vector<char>> data(H, vector<char>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> data[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (data[i][j] == '#') {
                continue;
            }
            ans = max(ans, bfs(data, i, j));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;

int main(){
    ll N, H;
    cin >> N >> H;
    vector<ll> a(N,0),b(N,0);
    rep(i,N) cin >> a[i] >> b[i];

    sort(all(a),greater<ll>());
    sort(all(b),greater<ll>());
    
    ll ans = 0;
    rep(i, N){
        if(H <= 0 || b[i] <= a[0]){
            ans = i - 1;
            break;
        } 
        H -= b[i];
        ans = i;
    }
    
    if(H > 0){
        ans += H / a[0];
        H -= a[0] * (H / a[0]);
    }

    if(H > 0) ans++;

    cout << ans + 1 << endl;
}


Measured memory_bytes: 4820
from collections import defaultdict

N = int(input())

numList = defaultdict(int)

for _ in range(N):
    num = int(input())

    if numList[num] == 0:
        numList[num] = 1
    else:
        numList[num] = 0

ans = sum([c for _, c in numList.items()])
print(ans)

Measured memory_bytes: 15452
from itertools import groupby

s = input()
k = int(input())
r = len(s) * k // 2
a = [sum(1 for _ in g) & 1 for _, g in groupby(s)]
if len(a) > 1:
  r -= sum(a) * k // 2
  if s[0] == s[-1] and a[0] & a[-1]:
    r += k - 1
print(r)


Measured memory_bytes: 3060
#include <cstdio>
int gcd(int x, int y) {return((y)?gcd(y,x%y):x);}
int main() {
    int a, b;
    scanf("%d%d", &a, &b);
    if(gcd(a, b) < b) printf("%d\n", a); else printf("-1\n");
}

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

int f(int x, int k){
	int n=1;
	for(int i=0 ; i < k ; i++ ) n *= 10;
	return ((x / n) % 10) * (n / 100);
}

int main(){
	int n, s;
	cin >> n;
	for(int i=0 ; i < n ; i++ ){
		cin >> s;
		cout << "Case " << (i+1) << ":" << endl;
		for(int j=0 ; j < 10 ; j++ ){
			s = s * s;
			s = f(s, 2) + f(s, 3) + f(s, 4) + f(s, 5);
			cout << s << endl;
		}
	}
}

Measured memory_bytes: 1160
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
    }
    for i in 1..50000 {
        let acc = ((i as f64) * 1.08).floor() as usize;
        if acc == n {
            return println!("{}", i)
        }
    }
    println!(":(");
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
template<class T> inline void chmax(T& a, T b) {if (a<b) a=b; }
inline void print() { cout << endl; }
template <class Head, class... Tail> inline void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...);}
template <class T> inline void print(vector<T>& vec) { for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " "; } cout << endl;}
template <class T> inline void print(vector<vector<T>>& df) { for (auto& vec : df) { print(vec); }}
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;


int main() { 
    int N; cin >> N;
    int res = 0;
    for(int i=1; i<=N; i++) {
        if(i%2==0) continue;
        int ct = 0;
        for(int j = 1; j<=i; j++) {
            if(i%j==0) {
                ct++;
            }
        }
        if(ct == 8) {
            res++;
        }
    }
    print(res);
    
    return 0;
}

Measured memory_bytes: 256
h, w, a, b = map(int, input().split())
mod = 10 ** 9 + 7
MAX_N = 2 * 10 ** 5
factorial = [1] * MAX_N
#事前に階上テーブルを用意
def calc_factorial():
    for i in range(1, MAX_N):
        factorial[i] = i * factorial[i - 1] % mod

def comb(n, k):
    a = factorial[n] % mod
    b = (factorial[k] * factorial[n - k]) % mod
    b_ = pow(b, mod - 2, mod)
    return (a * b_) % mod


# 階乗を用意
calc_factorial()
all = comb(h + w - 2, h - 1)
sub = 0
for j in range(1, b + 1):
    sub += comb(h - a - 1 + j - 1, j - 1) * comb(a - 1 + w - j, w - j)
    sub = sub % mod
if all - sub <= 0:
    print(all - sub + mod)
else:
    print(all - sub)

Measured memory_bytes: 10868
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
string s;
using MIte = multimap<int, int>::iterator;

int main() {
	int N, L;
	cin >> N >> L;

	int PieN = (2 * L + N - 1) * N / 2;

	if (L >= 0) {
		cout << PieN - L << endl;
	}
	else if (L + N - 1 <= 0) {
		cout << PieN - (L + N - 1) << endl;
	}
	else {
			cout << PieN << endl;
	}
		
	return 0;
}

Measured memory_bytes: 256
import math
def solve():
    N, H = map(int, input().split())
    A = []
    B = []
    
    for i in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
    a_max = max(A)

    throwable_b = []
    for i in range(N):
        if a_max < B[i]:
            throwable_b.append(B[i])
    
    throwable_b.sort(reverse=True)

    ans = 0
    for b in throwable_b:
        H -= b
        ans += 1

        if H <= 0:
            print(ans)
            return
    
    ans += math.ceil(H/a_max)
    print(ans)
    
if __name__ == '__main__':
    solve()

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

// 素因数分解
map<ll, ll> prime_factor(ll n) {
    map<ll, ll> res;
    for (ll i=2;i*i<=n;++i) {
        while (n%i == 0) {
            ++res[i];
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

int main() {
    ll N, P;
    cin >> N >> P;
    if (N == 1) {
        cout << P << endl;
        return 0;
    }
    map<ll, ll> tmp = prime_factor(P);
    ll ans = 1;
    for (auto& t : tmp) {
        //cerr << t.first << "-> " << t.second << endl;
        if (t.second >= N) {
            ll tmp = t.second/N;
            ans *= powl(t.first, tmp);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
N, K = map(int, input().split())
X = list(map(int, input().split()))
r = -10**18
for i in range(-1, N):
#    print(i)
    for j in range(i+1, N+1):
        A, B = X[:i+1], X[j:]
        if i+1+N-j > K:
            continue
        C = sorted(A+B)[::-1]
#        print(A, B, i+1, N-j, i, j)
        for _ in range(K-(i+1+N-j)):
            if not C:
                break
            c = C.pop()
            if c > 0:
                C.append(c)
                break
        r = max(r, sum(C))
print(r)


Measured memory_bytes: 41196
#include<bits/stdc++.h>
using namespace std;
int main(){
int x,a,b;
  cin>>x>>a>>b;
  int d1=abs(a-x);
  int d2=abs(b-x);
  if(d1<=d2)
    cout<<'A'<<endl;
  else
    cout<<'B'<<endl;
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>    
using namespace std;
#define ll long long 
#define pi pair<ll,ll>
#define pd pair<ld,ld>
#define pb push_back
#define inf 1e16
#define mod 998244353
#define en '\n'
#define ld long double
#define ff first
#define ss second
#define ull unsigned long long 
ll pw(ll b, ll r, ll md){
	ll ans = 1;
	while(r){
		if(r&1)ans = (ans*b)%md;
		b = (b*b)%md;
		r>>=1;
	}
	return ans;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n;cin>>n;
	cout<<((n/500)*1000)+(((n%500)/5)*5)<<endl;
	return 0 ; 
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stack>
#include<cstdio>
#include<queue>
#define PI 3.1415927
using namespace std;
int main() {
	int a, b;
	while (cin >> a >> b) {
		int i = 1;
		int c = a + b;
		while (c / 10 > 0) {
			i++;
			c /= 10;
		}
		cout << i << endl;
	}
}


Measured memory_bytes: 3076
#include<stdio.h>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;

static const int INFTY = (1<<29);

int main() {
  int N;
  scanf("%d", &N);
  int C[12];
  C[0] = 1;
  C[1] = 6;
  for (int i=1 ; i<6 ; i++) {
    C[i*2] = C[(i-1)*2]*9;
    C[i*2+1] = C[(i-1)*2+1]*6;
  }
  int T[N+1];
  for (int i=0 ; i<=N ; i++) T[i] = INFTY;
  T[0] = 0;
  for (int i=0 ; i<12 ; i++) {
        for (int j=0 ; j+C[i] <= N ; j++) {
                T[j+C[i]] = min(T[j+C[i]], T[j]+1);
        }
  }
  printf("%d\n", T[N]);
}

Measured memory_bytes: 512
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n; string s; cin >> n >> s;
  int l = s.size();
  for(int i; i<l; i++){
    s.at(i) = s.at(i)-'A';
    s.at(i) = (s.at(i)+n)%26;
    s.at(i) = s.at(i)+'A';
  }
  cout << s << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication68
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int[] b = new int[4];
            int ans=0;
            for(int c =0;c<a;c++)
            {
                while (true)
                {
                    string d = Console.ReadLine();
                    if (d[0] == 'O')
                        b[3] += 1;
                    if (b[3] == 3)
                    {
                        b[0] = b[1] = b[2] = b[3] = 0;
                        break;
                    }
                    if (d.Length == 7)
                    {
                        ans += b[0] + b[2] + b[1] + 1;
                        b[0] = b[1] = b[2] = 0;
                    }
                    if (d.Length == 3 && d[0] == 'H')
                    {
                        if (b[2] == 1)
                        {
                            ans += 1;
                            b[2] = 0;
                        }
                        if (b[1] == 1)
                        {
                            b[2] = 1;
                            b[1] = 0;
                        }
                        if (b[0] == 1)
                        {
                            b[1] = 1;
                            b[0] = 0;
                        }
                        b[0] = 1;
                    }
                }
                Console.WriteLine(ans);
                ans=0;
            }   
        }
    }
}

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

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

int main() {
  char fir,sec,ch;
  char a='A',b='B',c='C';
  while(cin>>fir>>ch>>sec){
    if(a==fir && b==sec) swap(a,b);
    else if(b==fir && c==sec) swap(b,c);
    else if(c==fir && a==sec) swap(c,a);
    else if(b==fir && a==sec) swap(a,b);
    else if(c==fir && b==sec) swap(b,c);
    else if(a==fir && c==sec) swap(c,a);
  }
  cout << a << endl;
  
  return 0;
}

Measured memory_bytes: 1132
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  rep(i,4) cout << S[i];
  cout << " ";
  REP(i,4,S.length()) cout << S[i];
  cout << endl;
  return 0;
}


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

using namespace std;

#define MAXN 100005

int a[MAXN],b[MAXN];

int main(void)
{
    int A,B,M;
    cin>>A>>B>>M;
    int mina = MAXN, minb = MAXN;
    for(int i=1;i<=A;++i) {
        cin>>a[i];
        if(a[i]<mina) mina = a[i];
    }
    for(int i=1;i<=B;++i) {
        cin>>b[i];
        if(b[i]<minb) minb = b[i];
    }
    int res = mina+minb;
    while (M--)
    {
        int x,y,c;
        cin>>x>>y>>c;
        res = min(res,a[x]+b[y]-c);
    }
    cout<<res<<endl;
    return 0;
}

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

int main() {
  int A,B ;
  cin >>A>>B ;
  int X = min(A, B); // min関数
  int Y = max(A, B);
  if(Y-X>1){
    cout << Y+Y-1 << endl;
  }else{
    cout << Y + X << endl;
  }
}

Measured memory_bytes: 256