akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
N = int(input())
a = []
for _ in range(N):
  l, r = map(int, input().split())
  a.append((l, r))
a.sort(key = lambda x: x[1])
p = 0
for i in range(N):
  if p <= a[i][1] - a[i][0]: p += a[i][0]
  else:
    print("No")
    exit(0)
print("Yes")

Measured memory_bytes: 68188
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vl;
 
const int N = 1e5 + 123;
int n, a[N];
 
int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n;
	ll s = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		s += a[i];
	}
	if (n == 1) {
		if (a[1] == 1) {
			cout << "Second";
		}	else {
			cout << "First";
		}
		return 0;
	}
	if ((s - n) & 1) {
		cout << "First";
	}	else {
		int x = 0;
		while (true) {
			int cnt = 0;
			for (int i = 1; i <= n; i++) {
				if (a[i] == 1) {
					break;
				}
				cnt += a[i] & 1;
			}
			if (cnt != 1) {
				break;
			}
			int g = 0;
			for (int i = 1; i <= n; i++) {
				if (a[i] & 1) {
					a[i]--;
				}
				g = __gcd(g, a[i]);
			}
			int d = 0;
			for (int i = 1; i <= n; i++) {
				d ^= (a[i] - a[i] / g) & 1;
				a[i] /= g;
			}
			if (d == 0) {
				break;
			}
			x++;
		}
		if (x & 1) {
			cout << "First";
		}	else {
			cout << "Second";
		}
	}
}


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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

int N;
vector<string> S;
vector<vector<int>> g;

int main(){
  cin >> N;
  S.resize(2);
  REP(i, 2){
    cin >> S[i];
  }
  ll ans = 1;
  
  int head = 0, before ;
  if(S[0][0] == S[1][0]){
    ans *= 3;
    head++;
    before = 1;
  }
  else{
    ans *= 3*2;
    head+=2;
    before = 2;
  }
  for(; head < N; head++){
    if(S[0][head] == S[1][head]){
      if(before == 1){
        ans *= 2;
      }
      else{
        ans *= 1;
      }
      before = 1;
    }
    else{
      if(before == 2){
        ans *= 3;
      }
      else{
        ans *= 2;
      }
      before = 2;
      head++;
    }
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long ans;
const int mod = 1e9+7;
const int maxN = 100010;
long long fac[maxN], facInv[maxN], inv[maxN];
void initComb() {
    fac[0] = fac[1] = 1;
    facInv[0] = facInv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < maxN; ++i) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        facInv[i] = facInv[i - 1] * inv[i] % mod;
    }
}
long long comb(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * facInv[k] % mod * facInv[n - k] % mod;
}
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (auto & a : A) cin >> a;
    sort(A.begin(), A.end());
    initComb();
    long long tmp;
    for (int i = K-1; i < N; ++i) {
        if ((tmp = A[i]-A[N-i-1]) < 0) tmp += mod;
        if ((ans += comb(i, K-1) * tmp % mod) >= mod) ans -= mod;
#ifdef DEBUG
        printf("%d, %d, %lld\n", i, K-1, comb(i, K-1) * tmp % mod);
#endif
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 2944
#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>;

int main(){
	int x,y,z;
	cin >> x >> y >> z;
	int ans = (x - y - z - z) / (y + z) + 1;
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	private static Scanner sc;

	public static void main(String[] args) {
		sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = sc.nextLong();
		long count=0;
		long A=a/x;
		if(a%x==0) A=A-1;
		long B =b/x;
		count=B-A;
		System.out.println(count);

	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define N 1100005
using namespace std;

typedef long long ll;

ll n, ans, kac, a[N], pre[N], dp[N], fen[N], of[N];
vector < int > g[N];

ll fe(ll a, ll us){
	if(us <= 1)
		return (us)?a:1ll;
	ll t = fe(a, us/2);
	return (us&1)?(t*t%mod)*a%mod : t*t%mod;
}

void up(int x, int y){
	for(; x < N; x += x&-x)
		fen[x] += y;
}

int qu(int x){
	int ans = 0;
	for(; x > 0; x -= x&-x)
		ans += fen[x];
	return ans;
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%lld",&n);
	for(int i = 1; i <= n; i++){
		scanf("%lld",a + i);
		pre[i] = pre[i - 1]^a[i];
		g[pre[i]].pb(i);
		if(!pre[i])
			up(i, 1);
	}
	if(pre[n] != 0){
		ll sif = 1;
		ll bir = 0;
		for(int i = 1; i <= n; i++){
			if(pre[i] == pre[n])
				bir = (bir + sif)%mod;
			else if(pre[i] == 0)
				sif = (sif + bir)%mod;
		}
		printf("%lld\n", sif);
		return 0;
	}
	kac = (int)g[pre[n]].size();
	ans = (ans + fe(2, kac - 1))%mod;

	// cout << ans << endl;

	for(int i = 1; i < N; i++){
		if(g[i].empty())
			continue;
		int u = (int)g[i].size(), ek = 1;
		of[0] = dp[0] = 1;
		// cout << i << " " << u << endl << " -> " << g[i][0] << " ";
		for(int j = 1; j < u; j++){
			int ara = qu(g[i][j]) - qu(g[i][j - 1]);
			dp[j] = (dp[j - 1] - 1 + of[j - 1]*ara%mod + 1)%mod;
			of[j] = (of[j - 1] + dp[j])%mod;
			// cout << "(" << ara << ") " << g[i][j] << " - " << dp[j] << " ";
		}
		ans = (ans + of[u - 1])%mod;
		// cout << " = " << of[u - 1] << endl;
	}

	printf("%lld\n", ans);
	return 0;
}

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

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

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

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

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

class EGetEverything {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N, M;
        in>>N>>M;
        vc<int> A(M), cmask(M);
        REP(i, M){
            int b, mask = 0;
            in>>A[i]>>b;
            REP(j, b){
                int c;
                in>>c, c--;
                mask |= (1<<c);
            }
            cmask[i] = mask;
        }
        const int INF = ten(9);
        vc<int> dp(1<<N, INF);
        dp[0] = 0;
        REP(i, 1<<N){
            if(dp[i]==INF) continue;
            REP(j, M){
                chmin(dp[i|cmask[j]], dp[i]+A[j]);
            }
        }
        if(dp[(1<<N)-1]==INF) out<<"-1\n";
        else out<<dp[(1<<N)-1]<<'\n';
    }
};


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


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;

int main() {
	ll n;
	vector<ll> v[2];
	ll ans = 0;

	cin >> n;

	REP(i, 2) {
		REP(j, n) {
			ll a;
			cin >> a;
			v[i].push_back(a);
		}
	}

	REP(i, n) {
		ll now = 0;
		REP(j, i + 1) {
			now += v[0][j];
		}
		FOR(j, i, n) {
			now += v[1][j];
		}
		if (now > ans) {
			ans = now;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String args[]){
    	Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
      
        int[] A = new int[N];
        int[] a = new int[N];
        for(int i = 0; i < N; i++){
            A[i] = scanner.nextInt();
            a[i] = A[i];
        }
		
        int max_first = 0;
        int max_second = 0;
        int max_first_position = 0;
        
        /*
        * 1つ目の最大値の箇所のみ2つ目の最大値を出力。他は最大値を出力。
        * 2つ目の最大値 = 最大値　の可能性もある。
        */
      
        //最大値探索
        for(int i = 0; i < N; i++){
            if(A[i] > max_first){
                max_first = A[i];
                max_first_position = i;
            }
        }
      
        a[max_first_position] = 0;
        
        //2つ目の最大値探索
        for(int i = 0; i < N; i++){
            if(a[i] > max_second){
                max_second = a[i];
            }
        } 
      
        for(int i = 0; i < N; i++){  
            if(a[i] == 0){
                System.out.println(max_second);
            } else {
                System.out.println(max_first);
            }
        } 
    }
}

Measured memory_bytes: 93736
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, M = list(map(int,_in[0].split(' ')))  # type:list(int)
    a_b_arr = []
    for i in range(M):
        _ = list(map(int,_in[i+1].split(' ')))  # type:list(int)
        a_b_arr.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = [0] * N
    for a, b in a_b_arr:
        cnt[a-1] += 1
        cnt[b-1] += 1
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    for i in range(N):
        print(cnt[i])


Measured memory_bytes: 38256
/*ALDS1_1A*/

#include <iostream>
#define abs(a) (a<0?-(a):a)
#define square(x) ((x)*(x))
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define swap(a,b) ((a!=b)?(a+=b,b=a-b,a-=b):0)
#define This
#define True true
#define False false
#define null Null


using namespace std;

void insertionSort(int[],int);
int main()
{
	int n;	
	cin>>n;
	int num[n];
	for(int i=0;i<n;i++){
		cin>>num[i];
	}
	insertionSort(num,n);

	
}

void insertionSort(int num[],int N){
    for(int i=0;i<N-1;i++){
		    cout<<num[i]<<" ";
	    }
	cout<<num[N-1]<<endl;
    
	for(int i=1;i<N;i++){
        int v=num[i];
        int j=i-1;
        while(j>=0&&num[j]>v){
            num[j+1]=num[j];
            j--;
        }
        num[j+1]=v;

        for(int i=0;i<N-1;i++){
		    cout<<num[i]<<" ";
	    }
	    cout<<num[N-1]<<endl;
    }
	
}


Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BS binary_search
#define all(c) (c).begin(),(c).end()
#define sz(x) (int)(x).size()
#define get(a,t) get<a>(t)
#define EPS 0.000000001 //1e-9
using pii=pair<int,int>;
const int INF=1e18;

void dprint(string s) { cout << endl;}
void dprint() { cout << endl;}
template <class T, class... U> void dprint(string s, T t, U... u) 
{int w=s.find(','); cout <<"["<< s.substr(0,w) << ": " << t << "] " ; dprint(s.substr(w+1, sz(s)-w), u...);} 


#define DEBUG 
#ifdef DEBUG
#define dbg(X...) dprint(#X,X)
#else
#define dbg(X...); 
#endif
const int N=100005;

int32_t main()
{
    IOS;
    string s,t; cin>>s>>t;
    bool flg=true;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]!=t[i])
            flg=false;
    }
    if(flg)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout << #x << " = " << (x) << endl;

long long A[1<<20];
long long B[1<<20];
long long f[1<<20];

#define mod 1000000007
#define ll long long

ll power(ll a, ll b) {
	if (b == 0) return 1;
	ll pp = power(a, b/2);
	pp = (pp*pp) % mod;
	if(b%2 == 0) return pp;
	return (pp*a)%mod;
}

int main() {
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    int n;cin>>n;

	int s = -1, e = -1;

	for(int i = 1;i <= n+1;i++) {
		cin>>A[i];
		if(B[A[i]]) {
			s = B[A[i]];
			e = i;
			break;
		}
		B[A[i]] = i;
	} s--;e--;

	f[0] = f[1] = 1;
	for(int i = 2;i <= n+10;i++) f[i] = (i*f[i-1])%mod;

	ll x, y, z, u, v, w, i = e, j = s;
	for(int k = 1;k <= n+1;k++) {
		x = f[n+1];
		y = (f[k]*f[n+1-k])%mod;
		y = power(y, mod-2);
		x = (x*y)%mod;

		y = 0;
		if(k-1 <= n-i+j) {
			u = f[n-i+j];
			v = (f[k-1]*f[n-i+j-k+1])%mod;
			v = power(v, mod-2);
			y = (u*v)%mod;
		}

		cout<<(x-y+mod)%mod<<endl;
	}

    return 0;
}

Measured memory_bytes: 6144
fun main(args: Array<String>) {
    val input = readLine()?.split(" ") ?: return
    val age = input[0].toInt()
    val price = input[1].toInt()
    if (0 > age || age > 100) return
    if (price < 2 || price > 1000) return
    println(
        when {
            age <= 5 -> 0
            age in 6..12 -> {
                price / 2
            }
            age >= 13 -> {
                price
            }
            else -> 0
        }
    )
}

Measured memory_bytes: 37968
import sys

N = int(input())
judge = []
for i in range(N):
    W = input()
    if W in judge:
        print('No')
        sys.exit()
    else:
        if not judge:
            judge.append(W)
        else:
            if judge[-1][-1] != W[0]:
                print('No')
                sys.exit()
            else:
                judge.append(W)

print('Yes')

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define Max(x, y) (((x) > (y)) ? (x) : (y))
#define Min(x, y) (((x) < (y)) ? (x) : (y))
#define Abs(x) ((x) < 0 ? (-(x)) : (x))
#define int long long
const int maxn = 1e3 + 10;
inline int read()
{
    int f = 1, r = 0;
    char c = getchar();
    while (!isdigit(c)) {
        if (c == '-') {
            f = -1;
        }
        c = getchar();
    }
    while (isdigit(c)) {
        r = 10 * r + c - '0';
        c = getchar();
    }
    return f * r;
}
inline void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
inline void writesp(int x) { write(x), putchar(' '); }
inline void writeln(int x) { write(x), puts(""); }
int N;
char str[105];
signed main()
{
    N = read();
    scanf("%s", str + 1);
    int x = 0, ans = 0;
    for (ri i = 1; i <= N; ++i) {
        if (str[i] == 'I') {
            x++;
        } else {
            x--;
        }
        ans = Max(ans, x);
    }
    writeln(ans);
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
const int NICO = 86400;
const int YAZAWA = 10800;
int v[252521];

int main(){
  scanf("%d",&n);
  int sum = 0;
  REP(i,n){
    int a,b;
    scanf("%d%d",&a,&b);
    sum += a;
    sum %= NICO;
    v[sum] += 1;
    sum += b;
  }
  REP(i,NICO)v[i+NICO]=v[i];
  int l = 0, r = 0;
  int ans = 0;
  sum = 0;
  while(r<=YAZAWA)sum+=v[r++];
  REP(i,NICO){
    CHMAX(ans,sum);
    sum += v[r++]-v[l++];
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 896
/*
 
dunjen_master
 
*/
 
 
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;
 
const int MAX_N = int(1e6) + 10;
const long long int MOD=1e9+7;
const long long int INF=1e18;
 
typedef long long int ll;
typedef unsigned long long int llu;
 
 
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

inline ll mul(ll a,ll b){

    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll c=a*b;
    c=(c+MOD)%MOD;
    return c;
}
inline ll add(ll a,ll b){
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll ans=(a+b);
    ans=(ans+MOD)%MOD;
    return ans;
}
ll power(ll a,ll b,ll c=0){
    ll ans=1;
    while(b){
        if(b&1){
            ans=mul(ans,a);
        }
        a=mul(a,a);
        b=b/2;
    }
    return ans;
}
template<class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P){
    in >> P.first >> P.second;
    return in;
}
 
template<class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &P){
    out << "(" << P.first << ", " << P.second << ")";
    return out;
}
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
    for(auto &x: arr) in >> x;
    return in;
}
template<class T>
ostream &operator<<(ostream &out, const vector<T> &arr){
    for(auto &x: arr) out << x << ' '; cout << "\n";
    return out;
}
template<class T>
istream &operator>>(istream &in, deque<T> &arr){
    for(auto &x: arr) in >> x;
    return in;
}
template<class T>
ostream &operator<<(ostream &out, const deque<T> &arr){
    for(auto &x: arr) out << x << ' '; cout << "\n";
    return out;
}
mt19937 rnd(time(0));
 
inline ll gcd(ll a,ll b){
    while(b)a%=b,swap(a,b);
    return a;
}
  

 
#define all(x) (x).begin(),(x).end()

/* ordered_set A;
   A.insert(x);
   A.erase(x);
   A.order_of_key(x) // no of elements less than (<) x
   *A.find_by_order(k-1) // kth smallest element
*/


const int N=1e5+5;


int n;
bitset<4000005>bit[2];
int a[2005];
int sum=0;



int main(){
 

  
  

    cin>>n;
  
    for(int i=1;i<=n;i++){
    cin>>a[i];
    }
    int r=0; 
    bit[0][0]=1;
  
  
  
  for(int i=1;i<=n;i++){
    
    bit[r^1]=bit[r];
    bit[r^1]|=(bit[r]<<a[i]);r=r^1;
  
    sum+=a[i];
  }
  
  for(int i=(sum+1)/2;i<=sum;i++){
    if(bit[r][i]){
      cout<<i<<endl;
      return 0;
    }
  }
  
  return 0;
}

   

    


    


    
    
    
    
 
    


Measured memory_bytes: 2176
import java.util.Scanner

object Main {
  def solve(sc: => Scanner): Unit = {
    println((sc.nextInt, sc.nextInt) match {
      case (h, r) if -r > h => -1
      case (h, r) if h == -r => 0
      case _ => 1
    })
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 44984
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
string S,T;
  cin>>S>>T;
  ll N=S.size();
  ll ans=N;
  for(ll i=0;i<N;i++) {
if(S[i]==T[i]) {
ans--;
}
  }
  
  cout<<ans<<endl;
}
  


Measured memory_bytes: 3924
#include <iostream>
#include <vector>

using namespace std;

int color[100001];

vector<int> G[100001];
bool dfs(int edge, int c){
    //cout << edge << endl;
    //if(color[edge] != c && color[edge] != 0) return false;
    color[edge] = c;
    for(int i = 0; i < G[edge].size(); i++){
        if(color[G[edge][i]] == 0){
            if(!dfs(G[edge][i], -c)) return false;
        }else if(color[edge] == color[G[edge][i]]){
            return false;
        }
    }
    return true;
}

int main(){
    long M, N;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int A, B;
        cin >> A >> B;
        G[A].push_back(B); 
        G[B].push_back(A);
    }
    long ans;
    if(dfs(1, 1)){
        long num_p = 0, num_n = 0;
        long num_pn = 0;
        for(int i = 1; i <= N; i++){
            if(color[i] == 1)num_p++;
            else num_n++;
            for(int j = 0; j < G[i].size(); j++){
                if(color[i] != color[G[i][j]]){
                    num_pn++;
                }
            }
        }
        ans = num_p*num_n - num_pn/2;
        cout << ans << endl;
    }else{
        ans = (N*(N-1))/2 - M;
        cout << ans << endl;
    }
}

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

inline int re()
{
	char x=getchar();
	int k=1,y=0;
	while(x<'0'||x>'9')
	{if(x=='-') k=-1;x=getchar();}
	while(x>='0'&&x<='9')
	{y=(y<<3)+(y<<1)+x-'0';x=getchar();}
	return y*k;
}
void wr(int x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) wr(x/10);
	putchar(x%10+'0');
}
signed main()
{
	//freopen("lca.in","r",stdin);
	//freopen("lca.out","w",stdout);
	int x=re();
	for(int i=1;;i++)
	{
		if(!((360*i)%x))
		{
			wr((360*i)/x);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n, h, w;
	cin >> n >> h >> w;
	int ans = 0;
	REP(i, n){
		int a, b;
		cin >> a >> b;
		if (a >= h and b >= w) ans++;
	}

	cout << ans << endl;
}


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

using namespace std;


int main()
{
    const int INF = 1e9 + 5;
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k; cin >> n; cin >> k;
    vector<int> heights(n);
    for (int& x: heights){
        cin >> x;
    }
    vector<int> dp(n, INF);
    dp[0] = 0;
    for (int i = 0; i < n; i++){
        for (int j = i + 1; j <= i + k; j++){
            if (j < n){
                dp[j] = min(dp[j], dp[i] + abs(heights[i] - heights[j]));
            }
        }
    }
    cout << dp[n-1] << "\n";
}





Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 2e2+10;
const int MAXM = (int) 3e6+10;

///--------------------START-------------------------
int M,N,X;
int c[MAXN];
int a[MAXN][MAXN];
int b[MAXN];

void work(){
    scanf("%d%d%d",&N,&M,&X);
    for(int i=0;i<N;i++){
        scanf("%d",&c[i]);
        for(int j=1;j<=M;j++){
            scanf("%d",&a[i][j]);
        }
    }
    int ans=INF;
    for(int i=0;i<(1<<N);i++){
        memset(b,0,sizeof(b));
        int ok=1,tmpans=0;
//        printf("i = %d\n",i);
        for(int j=0;j<N;j++){
            if(i&(1<<j)){
                tmpans+=c[j];
//                printf("j = %d\n",j);
                for(int k=1;k<=M;k++){
                    b[k]+=a[j][k];
                }
            }
        }
//        for(int k=1;k<=M;k++){
//            printf("%d ",b[k]);
//        }
        for(int k=1;k<=M;k++)if(b[k]<X) ok=0;
//        printf("cost = %d, ok = %d\n",tmpans,ok);
//        printf("\n---\n");
        if(ok) ans=min(ans,tmpans);
    }
    printf("%d\n",ans==INF ? -1:ans);
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}









Measured memory_bytes: 3824
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [A, B] = input[0].map(Number);

  return (A - 1) * (B - 1);
};

console.log(main(read()));


Measured memory_bytes: 29568
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    debug("debug test\n");
    int n,m;int k;
    cin>>k>>n;
    int f,l;
    int p = 0;
    int ans = 0;
    rep(i, n){
        int a;cin>>a;
        if(i==0){f=a;p=a;}
        if(i==n-1)l=a;
        chmax(ans, a-p);
        p = a;
    }
    chmax(ans, k-(l-f));
    cout << k - ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<functional>

#define REP(i,n) for(int i=0;i<n;i++)
#define ll long long int

using namespace std;

int to_int(string s) {
  return atoi(s.c_str());
}

//vector<ll> a;

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

 // a.reserve(n);
  vector<int> a(300000);
  for(int i=0;i<n;i++) {
    cin >> a[i];
    a[i] -= i+1;
  }

  sort(a.begin(), a.begin()+n);
  long long  b;
  if(n%2 == 0) {
    b = a[n/2 -1];
  } else {
    b = a[(n-1)/2];
  }

  long long  r = 0;

  for(int i=0;i<n;i++) {
    r += abs(a[i] - b);
  }

  cout << r << endl;
return 0;
}


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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a[3], res=0;
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a+3);
	a[0]+=a[2]-a[1];
	res+=a[2]-a[1];
	a[1]=a[2];
	if((a[1]-a[0])%2==0) res+=(a[1]-a[0])/2;
	else{
		res++;
		a[1]++;
		res+=(a[1]-a[0])/2;
	}
	cout << res;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
string S,T;
  cin>>S>>T;
  int N=S.size();
  bool ans=false;
  for(int i=0;i<N;i++){
  int sum=0;
    for(int j=0;j<N;j++){
  if(S.at(j)==T.at((j+i)%N))
    sum++;
  } if(sum==N){
    ans=true; break;
    }
  }if(ans)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	long long a, b, k;

	scanf("%lld %lld %lld", &a, &b, &k);

	/* 高橋君のものから順に、k枚のクッキーを食べる */
	if (a >= k) /* 高橋君のクッキーだけを食べる場合 */
	{
		printf("%lld %lld\n", a - k, b);
	}
	else if (a + b >= k) /* 青木君のクッキーも食べる場合 */
	{
		printf("0 %lld\n", b + a - k);
		return 0;
	}
	else /* クッキーがすべてなくなる場合 */
	{
		printf("0 0\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int count=0;
		boolean flag=false;
		for (int i=0;i<n;i++){
			int a=in.nextInt();
			int b=in.nextInt();
			if (a==b) count ++;
			else count =0;
			if (count>=3) flag=true;
		}
		if (flag) System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 36128
W, H, N = map(int, raw_input().split())
xya = [map(int, raw_input().split()) for i in xrange(N)]
lx, hx = 0, W
ly, hy = 0, H
for x, y, a in xya:
    if a == 1: lx = max(lx, x)
    if a == 2: hx = min(hx, x) 
    if a == 3: ly = max(ly, y) 
    if a == 4: hy = min(hy, y) 
print max(0, hx - lx)*max(0, hy - ly)


Measured memory_bytes: 2568
#include<iostream>

using namespace std;

int main() {
  int h, w, minH, minW;
  cin>>h>>w;
  while(h>0 && w>0) {
    int diag = h*h+w*w;
    int calDiag = 151*151+151*151;

    for(int i=1; i<=150; i++) {
      for(int j=i+1; j<=150; j++) {

	if(diag == i*i+j*j) { // 下限
	  if(i*i+j*j == calDiag && h<i && i<minH) {
	    minH = i;
	    minW = j;
	  } 
	  else if(i*i+j*j<calDiag && h!=i && w!=j && h<i) { 
	    calDiag = diag;
	    minH = i;
	    minW = j;
	  }
	}
	else if(diag < i*i+j*j && (i*i+j*j<calDiag || (i*i+j*j==calDiag && i<minH))) { // 挟まれた場合 問題無し
	  calDiag = i*i+j*j;
	  minH = i;
	  minW = j;
	}

      }
    }
    cout<<minH<<" "<<minW<<endl;
    cin>>h>>w;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<math.h>
int gcm(int a, int b)
{
    int r = a % b;
    while (r > 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
int main()
{
    int n, xx;
    scanf("%d %d", &n, &xx);
    int i;
    int x[100005];
    for (i = 0; i < n; i++)
        scanf("%d", &x[i]);
    for (i = 0; i < n; i++)
        x[i] = abs(x[i] - xx);
    int ans = x[0];
    for (i = 1; i < n; i++)
        ans = gcm(ans, x[i]);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 512
#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>;

int main(){
    ll n,h;
    cin >> n >> h;
    ll bs=0;
    ll am=0;
    ll a,bb;
    vector <ll> b(n);
    rep(i,n){
        cin >> a >> b[i];
        am=max(am,a);
    }

    sort(b.begin(),b.end());
    ll ans,k;

    rep(i,n){
        if(am>=b[n-i-1]){
            ans=h/am;
            if(h%am!=0){
                ++ans;
            }
            ans+=i;
            h=-1;
            break;

        }
        else{
            h-=b[n-i-1];
            if(h<=0){
                ans=i+1;
                break;
            }
        }
    }

    if(h>0){
        ans=h/am;
            if(h%am!=0){
                ++ans;
            }
            ans+=n;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define INF 100000000000
 
using namespace std;
vector<ll> hold;
unordered_map<ll,ll> ma;
unordered_map<ll,ll> mar;
 
bool isCyclicUtil(ll v, bool visited[], bool *recStack, vector<ll> adj[], bool he) 
{ 
    if(mar[v] == 1)
        return 0;
    if(visited[v] == false) 
    { 
        visited[v] = true; 
        recStack[v] = true; 
        //list<ll>::iterator i; 
        for(auto i = adj[v].begin(); i != adj[v].end(); ++i) 
        { 
            if ( !visited[*i] && isCyclicUtil(*i, visited, recStack, adj,he) ) 
            {
                if(he)
                    hold.pb(v), ma[v] = 1;
                return true; 
            }
            else if (recStack[*i]) 
            {
                if(he)
                    hold.pb(v), ma[v] = 1;
                return true;
            }
        } 
  
    } 
    recStack[v] = false;   
    return false; 
} 
  
bool isCyclic(ll V, vector<ll> adj[],bool he) 
{ 
    bool *visited = new bool[V]; 
    bool *recStack = new bool[V]; 
    for(ll i = 0; i < V; i++) 
    { 
        visited[i] = false; 
        recStack[i] = false; 
    } 
    
    for(ll i = 0; i < V; i++) 
        if (isCyclicUtil(i, visited, recStack,adj,he)) 
            return true; 
  
    return false; 
} 
 
 
int main()
{
   FAST/**/
    
   ll n,m;
   cin>>n>>m;
   vector<ll> v[n];
   ll mat[n][n];
   memset(mat,0,sizeof(mat));
   
   for(ll i=0;i<m;i++)
   {
       ll a,b;
       cin>>a>>b;
       
       a--,b--;
       mat[a][b] = 1;
       v[a].pb(b);
       //v[b].pb(a);
   }
   
   bool pos = isCyclic(n,v,1);
   if(pos == 0)
   {
       cout<<-1;
       return 0;
   }
   
   vector<ll> g[n];
   
   for(ll i=0;i<hold.size();i++)
   {
        for(ll j=0;j<hold.size();j++)
        {
            if(mat[hold[i]][hold[j]])
                g[hold[i]].pb(hold[j]);
        }
   }
   
   ll cnt = 0;
   
   for(ll i=0;i<hold.size();i++)
   {
       //cout<<"ith is "<<hold[i] + 1<<"\n";
       mar[hold[i]] = 1;
       cnt++;
       bool temp = isCyclic(n,g,0);
       if(temp == 0)
            mar[hold[i]] = 0,cnt--;
   }
   
   ll ans = hold.size() - cnt;
   cout<<ans<<"\n";
   for(ll i=0;i<hold.size();i++)
   {
       if(mar[hold[i]] == 0)
            cout<<hold[i]+1<<"\n";
   }
       
   
   return 0;
}

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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

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

int main(){
    int n,m;
    cin >> n >> m;
    cout << (n*(n-1)/2 + m*(m-1)/2) << endl;
    return 0;
}

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> p(N);
  for(int i = 0; i < N; i++) cin >> p[i];
  sort(p.begin(),p.end());
  int sum = 0;
  for(int k = 0; k < K; k++) sum += p[k];
  cout << sum << endl;
}

Measured memory_bytes: 3612
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	edge(int _t) : t(_t) {}
};
bool use[100010];


vector<edge> te[100010];
vector<edge> fe[100010];
int t[64];
int d[100100];
int n;

void Solve() {
	ll n, a, b;
	cin >> n >> a >> b;
	ll mi = (n - 1) * a + b;
	ll ma = a + (n - 1) * b;
	cout << max(0LL,(ma - mi + 1)) << endl;
} 


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



Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

int main()
{
    int x,y,ans = 0;
    cin >> x >> y;
    if(x == 3){
        ans += 100000;
    }else if(x == 2){
        ans += 200000;
    }else if(x == 1){
        ans += 300000;
    }
    
    if(y == 3){
        ans += 100000;
    }else if(y == 2){
        ans += 200000;
    }else if(y == 1){
        ans += 300000;
    }
    
    if(x == 1 && y == 1)ans += 400000;
    cout << ans << endl;
    return 0;
}


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

using namespace std;


#define PI 3.14159265
#define int long long



main(){

	int a, b; cin >> a >> b;

	string s = "", t = "";

	for(int i = 0; i < a; i++){
		s.push_back('0' + b);
	}

	for(int i = 0; i < b; i++){
		t.push_back('0' + a);
	}
	

	cout << min(s, t) << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;

class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] n_m = br.readLine().split(" ");

		int n = Integer.parseInt(n_m[0]);

		int m = Integer.parseInt(n_m[1]);

		node[] v = new node[n];

		for (int i = 0; i < v.length; i++) {
			v[i] = new node();
		}

		for (int i = 0; i < m; i++) {

			String[] node_to = br.readLine().split(" ");

			int node = Integer.parseInt(node_to[0]);
			int to = Integer.parseInt(node_to[1]);

			v[node].graph.add(to);
			v[to].graph.add(node);

		}

		for (int i = 0; i < n; i++) {
			dfs(v, i);

		}

		int q = Integer.parseInt(br.readLine());

		StringBuilder sb = new StringBuilder();

		for (int i = 0; i < q; i++) {

			String[] nodenumbers = br.readLine().split(" ");

			int nownode = Integer.parseInt(nodenumbers[0]);

			int targetnode = Integer.parseInt(nodenumbers[1]);

			if (v[nownode].group == v[targetnode].group) {
				sb.append("yes");
			} else {
				sb.append("no");
			}
			sb.append("\n");
		}

		System.out.print(sb);

	}

	static Deque<Integer> dfs = new ArrayDeque<Integer>();

	static void dfs(node[] v, int startnode) {

		dfs.clear();
		dfs.push(startnode);

		while (!(dfs.isEmpty())) {

			int now_node = dfs.pop();

			if (v[now_node].group != -1) {
				continue;
			}

			v[now_node].group = startnode;

			for (int i = 0; i < v[now_node].graph.size(); i++) {
				int next_node = v[now_node].graph.get(i);

				dfs.push(next_node);

			}
		}

	}

	public static class node {

		int group;

		List<Integer> graph;

		public node() {
			this.group = -1;
			this.graph = new ArrayList<Integer>();
		}
	}

}

Measured memory_bytes: 76356
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int tmp = c-a+b;
		if(tmp < 0){
			System.out.println(0);
		}else{
			System.out.println(tmp);
		}
	}
}

Measured memory_bytes: 22996
#include <cstdlib>
#include <algorithm>
#include <array>
#include <iostream>


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

  int n;
  std::cin >> n;

  std::array<bool, 8> group;
  std::fill(std::begin(group), std::end(group), false);
  int cnt2 = 0;
  for (int i = 0; i < n; i++) {
    int a;
    std::cin >> a;
    auto idx = a / 400;
    if (idx < group.size()) {
      group[idx] = true;
    } else {
      cnt2++;
    }
  }
  auto cnt1 = std::count(std::cbegin(group), std::cend(group), true);
  if (cnt1 == 0) {
    auto min = 1;
    auto max = cnt2;
    std::cout << 1 << " " << max << std::endl;
  } else {
    auto min = cnt1;
    auto max = cnt1 + cnt2;
    std::cout << min << " " << max << std::endl;
  }

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr = ds.begin(); itr != ds.end(); ++itr)
#define mp make_pair
#define INF 2000000000
#define INFL 2000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;
typedef vector<Edge> vE;
typedef priority_queue<Edge, vector<Edge>, greater<Edge> > pqlE;


int main() {
	ll X, Y;
	cin >> X >> Y;
	if (abs(X - Y) <= 1) {
		cout << "Brown" << endl;
	}
	else {
		cout << "Alice" << endl;
	}


	return 0;
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define E 2.71828182845905
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define debug(x) cout<<#x<<" is "<<x<<endl;
#define PI 3.14159265
#define mem(x) memset(x,0,sizeof(x));
using namespace std;
  
void sol() {
	int n;
	cin>>n;
	ll a[n],b[n],c[n];
	rep(i,0,n)
	cin>>a[i]>>b[i]>>c[i];
	ll dp1[n],dp2[n],dp3[n];
	dp1[0]=a[0];
	dp2[0]=b[0];
	dp3[0]=c[0];
	rep(i,1,n)
	{
		dp1[i]=a[i]+max(dp2[i-1],dp3[i-1]);
		dp2[i]=b[i]+max(dp1[i-1],dp3[i-1]);
		dp3[i]=c[i]+max(dp2[i-1],dp1[i-1]);
	}
	cout<<max(dp1[n-1],max(dp2[n-1],dp3[n-1]));
}

int main() {
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
 	//cin>>t;
 	while(t--){	
	sol();
 }

}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, z = 0;
    cin >> n;
    for (int i = 1; i <= 9; i++) {
        int m = 1;
        for (int j = 0; j < i; j++) m *= 3;
        for (int j = 0; j < m; j++) {
            string s;
            int l = j;
            bool b[3] = {};
            for (int k = 0; k < i; k++) {
                if (l % 3 == 0) s += '3', b[0] = 1;
                else if (l % 3 == 1) s += '5', b[1] = 1;
                else s += '7', b[2] = 1;
                l /= 3;
            }
            int a = stoi(s);
            if (a <= n && b[0] && b[1] && b[2]) z++;
        }
    }
    cout << z;
}


Measured memory_bytes: 256
import sys,os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7

    N,M = LMIIS()
    prefectures = [[]*M for _ in range(N)]
    for i in range(M):
        p, y = LMIIS()
        prefectures[p-1].append((y,i))
    dbg(prefectures)
    for p in prefectures:
        p.sort()
    dbg(prefectures)
    cities = [0]*M
    for i,p in enumerate(prefectures):
        for j,(y,k) in enumerate(p):
            cities[k] = '{:06d}{:06d}'.format(i+1,j+1)
    for s in cities:
        print(s)

        
        


if __name__ == '__main__':
    main()

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

int main(){
  string a,b;
  cin >>a>>b;
  int c=a.size()-b.size(),d=b.size();
  
  int ans=10000;
  for(int i=0;i<=c;i++){
    int cnt=0;
    for(int j=i;j<i+d;j++){
      if(a[j]!=b[j-i]){
        cnt++;
      }
      if(j==i+d-1){
        ans=min(ans,cnt);
      }
    }
  }
  cout << ans <<endl;
}


Measured memory_bytes: 3556
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int prevQuery = 0;
        int low = 0;
        int high = n - 1;
        HashMap<Integer, String> map = new HashMap<>();
        for (int i = 0; i < 20; i++) {
            int query;
            if (i == 0) {
                query = low;
            } else if (i == 1) {
                String ret = sc.next();
                if (ret.equals("Vacant")) return;
                map.put(0, ret);
                query = high;
            } else {
                String ret = sc.next();
                if (ret.equals("Vacant")) return;
                map.put(prevQuery, ret);
                if ((prevQuery - low - 1) % 2 == 1) {
                    if (!map.get(low).equals(ret)) 
                        high = prevQuery;
                    else {
                        low = prevQuery;
                    }
                } else {
                    if (map.get(low).equals(ret)) {
                        high = prevQuery;
                    } else {
                        low = prevQuery;
                    }
                }
                query = (low + high) / 2;
            }
            prevQuery = query;
            System.out.println(query);
        }
    }
 }


Measured memory_bytes: 23200