akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;


int main()
{
    string S;
    cin >> S;
    cout << (S <= "2019/04/30" ? "Heisei" : "TBD") << endl;
}


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

int main(){
    int n;cin>>n;
    vector<ll> a(n);rep(i,n)cin>>a[i];
    int ans = 0;
    while(1){
        for(auto i=a.begin();i!=a.end();i++){
            if(*i%2==1){co(ans);return 0;}
            else*i/=2;
        }
        ans++;
    }
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
counts = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if (500*a + 100*b + 50*c) == X:
                counts += 1
print(counts)

Measured memory_bytes: 9072
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long k = sc.nextLong();
		long d = sc.nextLong();
		sc.close();

		x = Math.abs(x);
		if (x / d >= k) {
			System.out.println(x - k * d);
		} else {
			long k2 = x / d;
			long x2 = x - k2 * d;
			long k3 = k - k2;
			k3 %= 2;
			x2 -= k3 * d;
			System.out.println(Math.abs(x2));
		}
	}
}


Measured memory_bytes: 35612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;
typedef long double ld;
#define pi 3.14159265358979

template<class T, class U>
bool contain(const std::basic_string<T>& s, const U& v)
{
	return s.find(v) != std::basic_string<T>::npos;
}

int  main()
{
	int n; cin >> n;
	vector <string> s(n);
	int min_len = INT_MAX;
	int m = 0;
	rep(i, n)
	{
		cin >> s[i];
		if (s[i].size() < min_len)
		{
			min_len = s[i].size();
			m = i;
		}
	}
	priority_queue <char, vector<char>, greater<char>> pq;
	rep(i, s[m].size())
	{
		int cnt = 0;
		for (int j = 0; j < n; j++)
		{
			if (contain(s[j], s[m][i]))
			{
				cnt++;
				int e = 0;
				if (j != m)
				{
					rep(k, s[j].size())
					{
						if(s[j][k] == s[m][i])
						{
							e = k; break;
						}
					}
					s[j].erase(e, 1);
				}
			}
		}
		if (cnt == n)
		{
			pq.push(s[m][i]);
		}
	}
	while (!pq.empty())
	{
		cout << pq.top();
		pq.pop();
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;
#define int long long
const int N = (int) 0, mod = (int) 0;

int32_t main() {
	int n, m;
	cin >> n >> m;
	int res = 1e18;
	for (int turn = 0; turn <= 1; ++turn) {
		swap(n, m);
		res = min(res, (n % 3) == 0 ? 0 : m);
		for (int j = 1; j <= n - 1; ++j) {
			int mx = j * m, mn = j * m;
			mx = max(mx, (n - j) * (m / 2 + (m % 2)));
			mn = min(mn, (n - j) * (m / 2));
			res = min(res, mx - mn);
		}
	}
	cout << res << endl;
}



Measured memory_bytes: 768
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main (String [] args) throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        //--------------------------START CODING HERE-----------------------------

        String  line= f.readLine();

        int DA = Integer.parseInt(line);

        System.out.print((int)(Math.pow(DA,3)+Math.pow(DA,2)+Math.pow(DA,1)));

        out.close();
    }
}

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

int x[100001], R = 1;
vector<int> tr[100001];

inline void no() { printf("NO\n"), exit(0); }

ll go(int v = R, int p = 0){
	if (tr[v].size() == 1)return x[v];
	ll s = 0, mx = 0;
	f(i, 0, tr[v].size()){
		int u = tr[v][i];
		if (u == p)continue;
		ll z = go(u, v);
		s += z;
		mx = max(mx, z);
	}
	if (s < x[v])no();
	ll need = s - x[v] << 1;
	if (x[v] < need >> 1)no();
	ll bad = max(0ll, mx - (s - mx));
	if (s - bad < need)no();
	return s - need;
}

int main(){
	int n;
	scanf("%d", &n);
	f(i, 1, n + 1)scanf("%d", x + i);
	f(i, 1, n){
		int a, b;
		scanf("%d%d", &a, &b);
		tr[a].push_back(b);
		tr[b].push_back(a);
	}
	f(i, 1, n + 1)if (tr[i].size() > 1) { R = i; break; }
	if (n != 2) { if (go())no(); }
	else if (x[1] != x[2])no();
	printf("YES\n");
}


Measured memory_bytes: 12800
#include <stdio.h>
int main(void){
    int a;
    scanf("%d", &a);
    if(a < 105){
        printf("0\n");
    }else if(a < 135){
        printf("1\n");
    }else if(a < 165){
        printf("2\n");
    }else if(a < 189){
        printf("3\n");
    }else if(a < 195){
        printf("4\n");
    }else{
        printf("5\n");
    }

}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, ll> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int mod = 1e+9 + 7;
const int INF = 1e+9;

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

ll lcm(ll a, ll b){
    return a * b / gcd(a, b);
}

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

    int a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,n,sum=0;
    cin>>a>>b>>c>>n;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            if((n-i*500-j*100>=0)&&(n-i*500-j*100<=c*50)){
                sum++;
            }
        }
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] A = new int[N];
        List<Integer> numList = new ArrayList<>();

        for(int i=0; i<N; i++){
            int input = sc.nextInt();
            A[i] = input;
            numList.add(input);
        }

        numList.sort(Comparator.reverseOrder());

        int max1 = numList.get(0);
        int max2 = numList.get(1);

        for(int i=0; i<N; i++){
            int result;
            if(A[i] != max1) {
                result = max1;
            }else{
                result = max2;
            }

            System.out.println(result);
        }

    }
}


Measured memory_bytes: 98272
#include <bits/stdc++.h>
#include <iomanip>	// fixed setprecision
#include <numeric>	// accumulate
using namespace std;
using ll = long long;
using ld = long double;

int main() {
	cout << fixed << setprecision(10);	// https://qiita.com/a4rcvv/items/05febcf410c51009a29a

	int n, k;
	cin >> n >> k;

	int w = n;
	int d = 0;
	while (w > 0)
	{
		w /= k;
		n -= w;
		++d;
	}

	cout << d << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>



using namespace std;



int main(void){
    int N;
    scanf("%d",&N);
    int sosu[25]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
    int kosu[25]={};
    for(int i=0;i<25;i++)kosu[i]++;
    for(int i=0;i<25;i++){
        for(int j=1;j<=N;j++){
            int k=j;
            while(k%sosu[i]==0){
                k/=sosu[i];
                kosu[i]++;
            }
        }
    }
    int sanijo=0;
    int goijo=0;
    int jugoijo=0;
    int nijugoijo=0;
    int nanajugoijo=0;
    for(int i=0;i<25;i++){
        if(kosu[i]>=3)sanijo++;
        if(kosu[i]>=5)goijo++;
        if(kosu[i]>=15)jugoijo++;
        if(kosu[i]>=25)nijugoijo++;
        if(kosu[i]>=75)nanajugoijo++;
    }
    int ans=0;
    ans+=goijo * (goijo-1) * (sanijo - 2)/2;
    ans+= jugoijo * (goijo-1);
    ans+= nijugoijo * (sanijo-1);
    ans+= nanajugoijo;
    printf("%d\n",ans);
    //printf("%d%d%d%d%d",sanijo,goijo,jugoijo,nijugoijo,nanajugoijo);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int cnt_digits(ll N)
{
  int digits=0;
  while(N>0)
  {
    N/=10;
    digits++;
  }
  return digits;
}

int main()
{
  ll N;
  cin >> N;
  int ans = cnt_digits(N);
  for(ll i=1ll; i*i<=N; ++i)
  {
    if(N%i != 0) continue;
    const ll b = N/i;
    
    int cur = max(cnt_digits(i), cnt_digits(b));
    if(ans>cur)
    {
      ans = cur;
    }
  }
  cout << ans << endl;
  return 0;
}
      
    

Measured memory_bytes: 3528
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll h,w;
ll direction2[4][2]={{1,0},{0,1},{0,-1},{-1,0}};
bool valid(int a,int b)
{
    if(a>=1&&a<=h&&b>=1&&b<=w)return true;
    else return false;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n;
    ll l1[n+1];
    for(int i=1;i<=n;i++){
        cin>>l1[i];
    }
    sort(l1+1,l1+n+1);
    cout<<l1[n]-l1[1];
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end



int main(){
    int a[4]; rep(i,0,4)scanf("%d",&a[i]);
    printf("%d\n",a[0]!=a[2]);
    return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

struct SegmentTree{
    SegmentTree(int n){
        size = 1;
        while(size < n){
            size *= 2;
        }
        for(int i=1;i<2*size;++i){
            data[i] = D;
        }
    }
    void propagate(int k){
        if(data2[k] != 0){
            data[k] += data2[k];
            if(k < size){
                data2[k*2] += data2[k] / 2;
                data2[k*2+1] += data2[k] / 2;
            }
            data2[k] = 0;
        }
    }
    void update(ll x, int l, int r){
        _update(1, 0, size, x, l, r);
    }
    inline void _update(int k, int a, int b, ll x, int l, int r){
        propagate(k);

        if(b <= l || r <= a){return;}
        if(l <= a && b <= r){
            data2[k] = x * (b - a);
            propagate(k);
        }else{
            int mid = (a + b) / 2;
            _update(k * 2, a, mid, x, l, r);
            _update(k * 2 + 1, mid, b, x, l, r);
            data[k] = data[k*2] + data[k*2+1];
        }
    }
    ll sum(int l, int r){
        return _sum(1, 0, size, l, r);
    }
    inline ll _sum(int k, int a, int b, int l, int r){
        propagate(k);

        if(b <= l || r <= a){return D;}
        if(l <= a && b <= r){return data[k];}
        int mid = (a + b) / 2;
        ll vl = _sum(k * 2, a, mid, l, r),
            vr = _sum(k * 2 + 1, mid, b, l, r);
        return vl + vr;
    }
    
    int size;
    ll data[400100], data2[400100];
    const ll D = 0;
};

int N, Q;
SegmentTree segtree(100000);

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

    std::cin >> N >> Q;

    for(int i=0;i<Q;++i){
        int type, s, t;

        std::cin >> type >> s >> t;

        if(type == 0){
            ll x;
            std::cin >> x;

            segtree.update(x, s, t + 1);
        }else{
            std::cout << segtree.sum(s, t + 1) << std::endl;
        }
    }
}



Measured memory_bytes: 6808
import sys
from collections import defaultdict
from collections import deque
import numpy as np
import heapq
from heapq import heappop, heappush
from fractions import Fraction

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)


def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0


def modinv(a, m):
    g, x, y = xgcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m


N = int(input())
X = list(map(int, input().split()))
MOD = 10**9+7

MAXN = N+5
fac = [1, 1] + [0] * MAXN
inv = [0, 1] + [0] * MAXN


for i in range(2, N):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = modinv(i, MOD)


c = 0
t = 0
f = fac[N-1]

for i in range(0, N-1):
    x = X[i+1] - X[i]
    c += f * inv[i+1]
    c %= MOD
    t += c * x
    t %= MOD

print(t)


Measured memory_bytes: 26824
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<long long> a(n);
    
    for (int i=0; i<n; i++) cin >> a[i];
    
    long long ans = 0;
    long long prev_max = 0;
    for (int i=0; i<n; i++){
        if(prev_max > a[i]){
            ans += prev_max - a[i];
        }else{
            prev_max = a[i];
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 4816
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=(a),_ed=(b);i<=_ed;++i)
#define DREP(i,a,b) for(int i=(a),_ed=(b);i>=_ed;--i)
typedef long long ll;
inline int read(){
    register int x=0,f=1;register char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
    while(isdigit(ch)){x=x*10+(ch^'0');ch=getchar();}
    return f?x:-x;
}

const int N=1e4+5,mod=998244353;
int n,f[N][N],p,q,fac[N],ifc[N];
char A[N],B[N];
inline int power(int b,int n){int ans=1;for(;n;n>>=1,b=1ll*b*b%mod)if(n&1)ans=1ll*ans*b%mod;return ans;}
inline void inc(int &x,int y){x=x+y<mod?x+y:x+y-mod;}
inline int C(int n,int m){return (n<0||m<0||n<m)?0:1ll*fac[n]*ifc[m]%mod*ifc[n-m]%mod;}

int main(){
    //freopen("in.in","r",stdin);
    scanf("%s",A+1);scanf("%s",B+1);
    n=strlen(A+1);
    REP(i,fac[0]=1,N-1)fac[i]=1ll*fac[i-1]*i%mod;
    ifc[N-1]=power(fac[N-1],mod-2);
    DREP(i,N-2,0)ifc[i]=1ll*ifc[i+1]*(i+1)%mod;
    REP(i,1,n)p+=(A[i]=='1'&&B[i]=='1'),q+=(A[i]=='1'||B[i]=='1');
    q-=p;q>>=1;
    REP(j,0,q)f[0][j]=1ll*fac[j]*fac[j]%mod;
    REP(i,1,p)REP(j,1,q){
	if(j)inc(f[i][j],1ll*f[i][j-1]*j%mod*j%mod);
	inc(f[i][j],1ll*f[i-1][j]*i%mod*j%mod);
    }
    int ans=0;
    REP(i,0,p)inc(ans,1ll*f[p-i][q]*C(p,i)%mod*fac[i]%mod*fac[i]%mod*C(p+q,i)%mod);
    printf("%d\n",ans);
    return 0;
}


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

int main()
{
    int A, B;
    cin >> A >> B;
    if (A % 2 == 1 && B % 2 == 1)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define X 1000000007

long long ans=1;
void solve(long long a,long long b){
    if(b<=1){
        for(int i=0;i<b;i++){
            ans*=a;
            if(ans>=X) ans=ans%X;
        }
    }
    else{
        if(b%2==1){
            ans *= a;
            b--;
        }
        a=a*a;
        if(ans>=X) ans=ans%X;
        if(a>=X) a=a%X;
        solve(a,b/2);

    }
}

int main(){
    long long a,b;
    cin>>a>>b;
    solve(a,b);
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
#define ll long long
#define ld long double
const int N = 2e5 + 5, mod = 1e9 + 7;
const ld pi = acos(-1);

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll a, b, h, m;
    cin >> a >> b >> h >> m;
    ld theta_a = ((ld)h + m / 60.0) / 12.0 * (2 * pi);
    ld theta_b = (ld)m / 60.0 * (2 * pi);
    ld theta = 0;
    if (theta_a > theta_b)
        theta = theta_a - theta_b;
    else theta = theta_b - theta_a;
    if (theta > pi ) theta = 2 * pi - theta;
    cout <<fixed << setprecision(9) <<  sqrt(a * a + b * b - 2 * a * b * cos(theta));
    return 0;
}


Measured memory_bytes: 4156
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <tuple>
#include <queue>
#include <bitset>
#include <unordered_map>
#include <tuple>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sys/time.h>

using namespace std;

void solve(long long A, long long B, long long C){
  long long ret = 0;
  ret += B;
  ret += min(C, B);
  C -= B;
  if (C <= 0) {
    std::cout << ret << std::endl;
    return;
  }
  ret += min(C, A);
  C -= A;
  if (C <= 0) {
    std::cout << ret << std::endl;
    return;
  } else {
    ret += 1;
    std::cout << ret << std::endl;
    return;
  }
}

int main(){
  long long B;
  long long C;
  long long A;
  scanf("%lld",&A);
  scanf("%lld",&B);
  scanf("%lld",&C);
  solve(A, B, C);
  return 0;
}


Measured memory_bytes: 256
a,b,c=map(int,input().split())
k=int(input())
if c>a/(2**k):
	for x in range(k+1):
		if b>a/(2**x):
			break
	else:
		print("No")
	y=k-x

	if c*(2**(y-x))>b:
		print("Yes")
		
	else: print("No")
else:
		print("No")

Measured memory_bytes: 62400
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll c=0,i;
    string ch,sh;
    cin>>ch>>sh;
    for(i=0;i<ch.length();i++){
        if(ch[i]!=sh[i])c++;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 3912
import java.util.*;
import java.io.*;
import java.math.*;

class Main {
	final static long MOD = 1000000007;
	public static void main(String args[]) throws Exception {
		double p = nextInt();
		double d = p/3.0;
		System.out.printf("%.10f\n",d*d*d);
	}

	static boolean isPal(String n, int l, int u) {
		while(l<u) {
			if(n.charAt(l)!=n.charAt(u))
				return false;
			l++;
			u--;
		}
		return true;
	}

	static int nextInt()throws IOException{
		InputStream in = System.in;
		int ans=0;
		boolean flag=true;
		byte b=0;
		boolean neg=false;
		while ((b>47 && b<58) || flag){
			if(b==45)
				neg=true;
			if(b>=48 && b<58){
				ans=ans*10+(b-48);
				flag=false;
			}
			b=(byte)in.read();
		}
		if(neg)
			return -ans;
		return ans;
	}

	static long nextLong()throws IOException{
		InputStream in=System.in;
		long ans=0;
		boolean flag=true;
		byte b=0;
		while ((b>47 && b<58) || flag){
			if(b>=48 && b<58){
				ans=ans*10+(b-48);
				flag=false;
			}
			b=(byte)in.read();
		}
		return ans;
	}
	static String next()throws Exception{
		StringBuilder sb=new StringBuilder(1<<16);
		InputStream in=System.in;
		byte b=0;
		do{
			if(!isWhiteSpace(b))
				sb.append((char)b);
			b=(byte)in.read();
		}while(!isWhiteSpace(b) || sb.length()==0);
		return sb.toString();
	}
	static boolean isWhiteSpace(byte b){
		char ch=(char)b;
		return ch=='\0' || ch==' ' || ch=='\n';
	}
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef vector<pii> vpii;
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
    tree_order_statistics_node_update> ost;

const int N=210000;
const ll P=1e9+7;
const ll INFTY=1e18;

vll b[N];
ll f[N], invf[N];

ll pw(ll x, ll n) {
    ll ans=1;
    while(n) {
        if(n&1) ans=ans*x%P, n--;
        x=x*x%P, n/=2;
    }
    return ans;
}

int main() {
    ll i, j, k, m, n, x, y, c, w, ans;
    scanf("%lld%lld%lld", &n, &x, &y);
    f[0]=invf[0]=1;
    for(i=1; i<=n; i++) {
        f[i]=f[i-1]*i%P;
        invf[i]=pw(f[i], P-2);
    }
    for(i=0; i<n; i++) {
        scanf("%lld%lld", &c, &w);
        b[c-1].pb(w);
        b[i].pb(INFTY);
    }
    for(i=0; i<n; i++) sort(all(b[i]));
    sort(b, b+n, [](vll &v1, vll &v2) {
        return v1[0]<v2[0];
    });
    for(k=n-1; k>0 && b[k][0]+b[0][0]>y; k--);
    if(k>0) k++;
    ans=1;
    for(m=i=0; i<k; i++) {
        for(j=1; ; j++) {
            c=(i==0);
            if(b[i][j]+b[i][0]>x && b[i][j]+b[c][0]>y)
                break;
        }
        m+=j;
        ans=ans*invf[j]%P;
    }
    ans=ans*f[m]%P;
    printf("%lld\n", ans);
    return 0;
}

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

#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f( const char* name , Arg1&& arg1 ) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f( const char* na , Arg1&& arg1 , Args&&... args ) {
        const char* c = strchr( na + 1 , ',' );
        cerr.write( na , c - na ) << " : " << arg1 << " , ";
        __f( c + 1 , args... );
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;

int main( ) {
        IO;
        #ifdef LOCAL
            //freopen( "input.txt" , "r" , stdin );
        #endif // LOCAL
        int n;
        cin >> n;
        vector <int> a( n + 1 );
        for( int i = 1; i <= n; i++ ) cin >> a[i];
        LL sum = 0;
        for( int i = 1; i <= n; i++ ) {
                for( int j = i + 1; j <= n; j++ ) {
                    sum += a[i] * a[j];
                }
        }
        cout << sum << endl;
        return 0;
}










Measured memory_bytes: 256
import itertools

N, K=map(int, input().split())
p=list(map(int, input().split()))
acup=list(itertools.accumulate(map(lambda x:(x+1)/2, p)))
ans=acup[K-1]
for i in range(K, N):
    ans=max(ans, acup[i]-acup[i-K])
print(ans)

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

int main(){
  
  int n;
  cin >> n;
  
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin >> h.at(i);
  }
  
  int x=0;
  int ans=0;
  
  for(int j=0;j<n-1;j++){
    if(h.at(j)>=h.at(j+1)){
      x++;
      ans=max(ans,x);
    }else{
      x=0;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n);i++)
#define rep1(i,n) for(int i=1; i<(n); i++)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int a,b;
    cin >> a >> b;
    cout << max({2*a-1, a+b, 2*b-1}) << endl;
}

Measured memory_bytes: 256
n,m,q=map(int, input().split())
abcd=[list(map(int, input().split())) for i in range(q)]
from itertools import combinations_with_replacement
data=list(range(1,m+1))
prep=combinations_with_replacement(data, n)
ans=0
for p in prep:
    tmp=0
    p=sorted(list(p))
    for i in range(q):
        if p[abcd[i][1]-1]-p[abcd[i][0]-1]==abcd[i][2]:
            tmp+=abcd[i][3]
    ans=max(ans,tmp)
print(ans)


Measured memory_bytes: 68476
#![allow(
  non_snake_case,
  unused_variables,
  unused_assignments,
  unused_mut,
  unused_imports,
  unused_macros,
  dead_code
)]
use proconio::fastout;
use proconio::input;
use proconio::marker::*;
use std::cmp::*;
use std::collections::*;
//use std::collections::VecDeque;
macro_rules! debug {
  ($($a:expr),* $(,)*) => {
      #[cfg(debug_assertions)]
      eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
  };
}
#[fastout]
fn main() {
  input! {
    N:usize,
    XY:[(i64,i64);N]
  }
  // 傾き-1の線分の距離が最大になるケースと傾き1の線分のケースで考える。
  let mut v1 = vec![0; N];
  let mut v2 = vec![0; N];
  // 傾き1のケース
  let mut minV1 = 2000000000;
  let mut maxV1 = -2000000000;
  let mut minV2 = 2000000000;
  let mut maxV2 = -2000000000;
  for i in 0..N {
    v1[i] = XY[i].0 + XY[i].1;
    v2[i] = XY[i].0 - XY[i].1;
    minV1 = min(minV1, v1[i]);
    minV2 = min(minV2, v2[i]);
    maxV1 = max(maxV1, v1[i]);
    maxV2 = max(maxV2, v2[i]);
  }
  let mut ans = max(maxV1 - minV1, maxV2 - minV2);
  println!("{}", ans);
}


Measured memory_bytes: 12128
import math
import collections

N = int(input())
a = math.factorial(N)
b = []
while a % 2 == 0:
    b.append(2)
    a//=2
f = 3
while f*f <= a:
    if a % f ==0:
        b.append(f)
        a //= f
    else:
        f += 2
if a != 1:
    b.append(a)

c = collections.Counter(b)
ans = 1
for j,k in c.items():
    ans *= (k+1)
print(ans%(10**9+7))

Measured memory_bytes: 9344
#include <iostream>

using namespace std;


int main() {
    int a, b;
    char op;

    while (1) {
        cin >> a >> op >> b;

        switch (op) {
            case '+':
                cout << a + b << endl;
                break;
            case '-':
                cout << a - b << endl;
                break;
            case '*':
                cout << a * b << endl;
                break;
            case '/':
                cout << a / b << endl;
                break;
            default:
                goto BREAK;
        }
    }
    BREAK:
    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue> 
using namespace std;
#define INF 0x3f3f3f3f
char p[110][110];
int n,m,k;
int main()
{
	while(~scanf("%d%d",&n,&m))
	{
		getchar();
		for(int i=0;i<=105;i++)
			for(int j=0;j<=105;j++)
				p[i][j]='#';
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)
			{
				char c=getchar();
				p[i][j]=c;
			}
				
			getchar();
			//cout<<p[i]<<endl;
		}
		
		for(int i=0;i<=n+1;i++)
		{
			for(int j=0;j<=m+1;j++)
			printf("%c",p[i][j]);
			cout<<endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
typedef struct Data{
    long long b,c;
}data;
int cmp(const void *a,const void *b){
  long long *A = (long long *)a;
  long long *B = (long long *)b;
  if (*A > *B) return 1;
  if (*A < *B) return -1;
  return 0;
}
int cmpb(const void *a,const void *b){
  long long A = ((data *)b)->c;
  long long B = ((data *)a)->c;
  if (A > B) return 1;
  if (A < B) return -1;
  return 0;
}
int main(){
    long long n,m,i,j;
    scanf("%lld%lld",&n,&m);
    long long a[n],sum=0;
    data num[m];
    for(i=0;i<n;i++) scanf("%lld ",&a[i]);
    qsort(a,n,sizeof(long long),cmp);
    for(i=0;i<m;i++) scanf("%lld %lld",&num[i].b,&num[i].c);
    qsort(num,m,sizeof(data),cmpb);
    i=0;
    for(j=0;j<m;j++){
            while(num[j].b>0){
                if(a[i]<num[j].c){
                    sum+=num[j].c;
                    num[j].b--;
                    i++;
                }
                else break;
            }
    }
    for(;i<n;i++)sum+=a[i];
    printf("%lld",sum);
}

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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int n, x; cin >> n >> x;
  vector<int> l(n);
  for(int i=0;i<n;++i) {
    cin >> l[i];
  }

  int d = 0;
  int cnt = 1;
  for(int i=0;i<n;++i) {
    if(d + l[i] <= x) {
      cnt++;
      d += l[i];
    } else {
      break;
    }
  }
  cout << cnt << endl;
}


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

int main(){
int N,M;
cin >> N >> M;
int popItems = 0;
int A[N];
for(int i=0; i<N; i++){
    cin >> A[i];
}
int sum = A[0];
for(int j=1; j<N; j++){
    sum = sum + A[j];
}
int t;
if(sum%(4*M) == 0){
    t = sum/(4*M);
}
else t = sum/(4*M) + 1;
for(int k=0; k<N; k++){
    if(A[k] >= t){
        popItems+=1;
    }
}
if(popItems >= M){
    cout << "Yes";
}
else cout << "No";
return 0;
}


Measured memory_bytes: 256
use std::cmp;

fn main(){
  let nw: Vec<usize> = read_vec();
  let n = nw[0];
  let w = nw[1];

  let mut wv: Vec<Vec<usize>> = vec![vec![0;2];n];
  let mut dp: Vec<usize> = vec![0;w+1];

  for i in 0 .. n {
    wv[i] = read_vec();
  }

  for i in 0 .. n {
    for j in (0 .. w+1).rev() {
      if j >= wv[i][0] {
        dp[j] = cmp::max(dp[j], dp[j - wv[i][0]] + wv[i][1]);
      }
    }
  }
  
  println!("{}", dp[w]);
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a,b,c,d,e,f;
    cin>>a>>b;
    c=0;
    while(c<=1000){
        d=c*0.08;
        e=c*0.1;
        if(d==a&&e==b){
            break;
        }
        c++;
    }
    if(c==1001){
        c=-1;
    }
    cout<<c<<endl;

}

Measured memory_bytes: 256
n,x,y=map(int,input().split())
x-=1
y-=1
d=[[0]*n for i in range(n)]
for i in range(n):
    for j in range(i+1,n):
        d[i][j]=min(j-i,abs(x-i)+abs(y-j)+1)
        
# for i in d:
#     print(i)
ans=[0]*(n+1)
for i in range(n):
    for j in range(n):
        ans[d[i][j]]+=1
for i in range(1,n):
    print(ans[i])

Measured memory_bytes: 78812
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define repc(i, s, t) for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(ios_base::fixed);
    cout.precision(12);

    constexpr int LOG = 65;

    var(i64, N, K);
    auto table = makeV(0, LOG, N);
    rep(i, 0, N) {
        read(table[0][i]);
        --table[0][i];
    }

    for (int k = 0; (k + 1) < LOG; ++k) {
        for (int v = 0; v < N; ++v) {
            if (table[k][v] == -1) continue;
            table[k + 1][v] = table[k][table[k][v]];
        }
    }

    const auto climb = [&](int v, i64 k) {
        int i = 0;
        while (k > 0) {
            if (k & 1) v = table[i][v];
            ++i;
            k >>= 1;
        }
        return v;
    };

    print(climb(0, K) + 1);

    return 0;
}


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

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

    if(N%2 != 0){
        cout << "No" << endl;
        return 0;
    }

    rep(i, N/2){
        if (S[i] != S[i+N/2]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n, q;
    std::cin >> n >> q;
    enum { time, type, val };
    std::vector<std::tuple<int, int, int>> ev;
    for (int i = 0; i < n; i++) {
        int s, t, x;
        std::cin >> s >> t >> x;
        ev.emplace_back(s - x, 1, x);
        ev.emplace_back(t - x, 0, x);
    }
    std::sort(ev.begin(), ev.end());
    auto it = ev.begin();
    std::set<int> s;
    for (int i = 0; i < q; i++) {
        int d;
        std::cin >> d;
        while (it != ev.end() && std::get<time>(*it) <= d) {
            int v = std::get<val>(*it);
            if (std::get<type>(*it)) s.insert(v);
            else s.erase(v);
            it++;
        }
        std::cout << (s.empty() ? -1 : *s.begin()) << std::endl;
    }

    return 0;
}


Measured memory_bytes: 15340
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    int n,m,x;
    cin>>n>>m>>x;
    vector<int> c(n);
    vector<vector<int>> a(n,vector<int>(m));
    for(int i=0; i<n; i++){
        cin>>c[i];
        for(int j=0; j<m; j++){
            cin>>a[i][j];
        }
    }
    ll ans=1e15;
    bool find=false;
    for(ll mask=1; mask<(1<<n); mask++){
        ll tmp=0;
        vector<int> sum(m);
        for(int i=0; i<n; i++){
            if(mask&(1<<i)){
                tmp+=c[i];
                for(int j=0; j<m; j++){
                    sum[j]+=a[i][j];
                }
            }
        }
        bool ok=true;
        for(int i=0; i<m; i++){
            if(sum[i]<x) ok=false;
        }
        if(ok){
            ans=min(ans,tmp);
            find=true;
        }
    }
    if(find){
        cout<<ans<<endl;
    }else{
        cout<<-1<<endl;
    }
}

Measured memory_bytes: 3604
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>

using namespace std;

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

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

const int Maxn = 100010;

ll a[Maxn];
int n;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += a[i] / 2;
        a[i] %= 2;
        if (a[i] > 0 && a[i + 1] > 0) {
            ++ans;
            --a[i];
            --a[i + 1];
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
N, M, X, Y = list(map(int, input().split()))
x = [0 for i in range(N)]
y = [0 for i in range(M)]
x = list(map(int, input().split()))
y = list(map(int, input().split()))
max_x = max(x)
min_y = min(y)
r = [i for i in range(max_x+1, min_y+1)]
count = 1
flag = False
while(True):
  if X + count in r:
    flag = True
    break
  else:
    if X + count == Y:
      break
    count += 1
if flag:
  print("No War")
else:
  print("War")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a, b) << " " << max(0L, a+b-n) << endl;
  
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = List=[list(map(int,input().split())) for i in range(n)]

a.sort(key=lambda x:x[0])
a.sort(key=lambda x:x[1])

suma = 0
flg = 1
for i in range(n):
    if a[i][1] >= a[i][0]+suma:
        suma = suma + a[i][0]
    else:
        flg = 0
        break  

if flg == 0:
  print('No')
else:
  print('Yes')


Measured memory_bytes: 53616
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int A = scan.nextInt();
        int B = scan.nextInt();

        if(A <= B*2)
            os.println(0);
        else
            os.println(A-B*2);
    }
}

Measured memory_bytes: 22604
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}



//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;
int main(){
 int N;cin>>N;
  vector< tuple<string,int,int > > t(N);
  rep(i,N){
   string s;int p;cin>>s>>p;
    t[i]= make_tuple(s,100-p,i+1);
  } 
  sort(all(t));
  rep(i,N){
    cout<<get<2>(t[i])<<endl;
  }
}







Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




int main() {
    
    string s;
    cin >> s;
    map<char, int> mp;
    rep(i, sz(s)) mp[s[i]]++;
    
    int ans = 0;
    // 変更の必要ない
    if ((mp['9'] == sz(s) - 1 && s[0] != '9') || mp['9'] == sz(s)) {
        rep(i, sz(s)) ans += s[i] - '0';
    } else {
        ans =  (sz(s) - 1) * 9 + s[0] - '0' - 1;
    }
    out(ans);
    
}




Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#define maxn 55
using namespace std;
long long ans=0;
long long dp[maxn][maxn*maxn];
int n,a,num[maxn],sum[maxn];
int main()
{
    while(~scanf("%d%d",&n,&a))
    {
        dp[0][0]=1;
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&num[i]);
            sum[i]+=sum[i-1]+num[i];
        }
        for(int k=1;k<=n;k++)
            for(int i=k;i>=1;i--)
                for(int j=num[k];j<=sum[k];j++)
                    dp[i][j]+=dp[i-1][j-num[k]];
        for(int i=1;i<=n;i++) ans+=dp[i][i*a];
        printf("%lld\n",ans);
    }

    return 0;
}


Measured memory_bytes: 1408
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<vector<int>> A(2, vector<int>(n, 0));
    for (int i = 0; i < 2; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> A[i][j];
        }
    }

    for (int i = 0; i < 2; ++i) {
        for (int j = 0; j + 1 < n; ++j) {
            A[i][j + 1] += A[i][j];
        }
    }

    int res = 0;

    for (int i = 0; i < n; ++i) {
        int ans = A[0][i];
        ans += A[1][n - 1] - (i - 1 >= 0 ? A[1][i - 1] : 0);

        res = max(res, ans);
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>

const long long int MOD = 1e9+7;

int main(){
  
  // read problem
  long long int N, tmp;
  scanf("%lld", &N);
  
  std::vector<std::vector<long long int> > a(N);
  for(long long int i = 0; i < N; i++){
    for(long long int j = 0; j < N; j++){
      scanf("%lld", &tmp);
      a[i].push_back(tmp);
    }
  }
  
  // solve problem
  long long int n_S;
  std::vector<long long int> dp(1<<N);
  dp[0] = 1;
  std::vector<long long int> member_S;
  
  for(long long int S = 0; S < (1<<N); S++){
    // count number of members
    n_S = 0;
    for(long long int i = 0; i < N; i++){
      if((S & (1<<i)) != 0){
        n_S++;
      }
    }
    // calculate dp[S]
    for(long long int i = 0; i < N; i++){
      if((S & (1<<i)) != 0){
        dp[S] += a[n_S-1][i] * dp[S^(1<<i)];
        dp[S] = (dp[S]+MOD)%MOD;
      }
    }
  }
  
  std::cerr << "Answer:" << std::endl;
  std::cout << dp[(1<<N)-1] << std::endl;

  return 0;
}


Measured memory_bytes: 16640