akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const ll mod = 998244353;

const int N = 303;
const int M = 90003;
ll dp[N][M][2][2];

ll mod_pow(ll x, ll n){
    ll ret = 1;
    while(n){
        if(n&1) (ret *= x) %= mod;
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

ll mod_inv(ll x){
    return mod_pow(x,mod-2);
}

int n;
int a[N];
int sa = 0;
// ll dfs(int d, int s, int x, int y){
//     if(dp[d][s][x][y]>=0) return dp[d][s][x][y];
//     if(d == n){
//         if(sa-s <= s){
//             return 3;
//         }
//         printf(" %d %d %d %d   %lld\n",d,s,x,y, 0);
//         return 0;
//     }

//     ll ret = dfs(d+1, s+a[d], x, y);
//     (ret += dfs(d+1, s, 1, y)) %= mod;
//     (ret += dfs(d+1, s, x, 1)) %= mod;

//     printf(" %d %d %d %d   %lld\n",d,s,x,y, ret);
//     return dp[d][s][x][y] = ret;
// }

const ll DIV = mod_inv(2);
int main(){
    cin >>n;
    rep(i,n){
        cin >>a[i];
        sa += a[i];
    }

    dp[0][0][0][0] = 1;
    rep(i,n)rep(j,M)rep(x,2)rep(y,2)if(dp[i][j][x][y]){
        int nx = j+a[i];
        if(nx < M) (dp[i+1][nx][x][y] += dp[i][j][x][y]) %= mod;

        (dp[i+1][j][x|1][y] += dp[i][j][x][y]) %= mod;
        (dp[i+1][j][x][y|1] += dp[i][j][x][y]) %= mod;
    }

    ll sub = 0;
    rep(i,M)rep(x,2)rep(y,2){
        if(sa-i <= i){
            if(sa-i==i && (x==0 || y==0)){
                sub += dp[n][i][x][y]*DIV;
            }
            else sub += dp[n][i][x][y];
            sub %= mod;
        }
    }
    sub *= 3;
    sub %= mod;
    // dbg(sub);

    ll ans = mod_pow(3,n) - sub + mod;
    ans %= mod;

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


Measured memory_bytes: 815360
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		long a = sc.nextInt();
		long b = sc.nextInt();
		long c = sc.nextInt();

		if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
			pr.println(0);
		} else {
			long min = Long.MAX_VALUE;
			min = Math.min(min, a * b);
			min = Math.min(min, b * c);
			min = Math.min(min, c * a);

			pr.println(min);
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 10060
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n); std::vector<i64> a(n + 1);
	for(int i = 0; i < n + 1; i++) scanf("%lld", &a[i]);
	
	i64 ans = 0;
	for(int i = 0; i < n; i++) {
		i64 b; scanf("%lld", &b);
		
		i64 tmp = std::min(a[i], b);
		b -= tmp; ans += tmp;
		tmp = std::min(a[i + 1], b);
		a[i + 1] -= tmp; ans += tmp;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rng(i,a,b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define repd(i, n) for(ll i = (ll)(n)-1;i>=0;--i)
#define rngd(i,b,a) for(ll i = (ll)(b);i>=a;--i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())



ll f(ll a,ll b){
  return max(to_string(a).length(),to_string(b).length());
}

int main() {
  ll ans=100;
  ll n;
  cin>>n;
  rng(i,1,(ll)(sqrt(n))+1){
    if(n%i==0){
      ans=min(ans,f(i,n/i));
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

struct Prime {
    vector<int> p_list;
    vector<bool> memo;

    Prime (int N) : memo(N+1, true) {
        init(N);
    }

    void init(int N){
        memo[0] = false;
        if(1 <= N) memo[1] = false;
        if(N < 2) return;

        int idx = 2;
        while(idx <= N) {
            if(memo[idx]){
                p_list.push_back(idx);
                LL x = 2;
                while(idx * x <= N) {
                    memo[idx*x] = false;
                    x++;
                }
            }

            idx += (idx == 2 ? 1 : 2);
        }
    }

    bool isPrime(int i) {
        return memo[i];
    }
};

void solve(long long Q, std::vector<long long> l, std::vector<long long> r){
    Prime prime(100000);
    VI memo(100001, 0);
    REP2(i, 3, 100000) {
        if(i % 2 == 0) continue;
        if(prime.isPrime(i) && prime.isPrime((i+1)/2)) memo[i]++;
    }

    REP(i, 100000) memo[i+1] += memo[i];

    REP(i, Q) {
        cout << memo[r[i]] - memo[l[i]-1] << endl;
    }
}

int main(){
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> l(Q);
    std::vector<long long> r(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&l[i]);
        scanf("%lld",&r[i]);
    }
    solve(Q, std::move(l), std::move(r));
    return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
// int facctorialMethod(int k){
//     int sum = 1;
//     for (int i = 1; i <= k; ++i)
//     {
//         sum *= i;
//     }
//     return sum;
// }
int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int C=0;
    while(a>0&&c>0){
        if(C%2==0){
            c -= b;
            if(c<=0)break;
        }
        else{
            a -= d;
            if(a <= 0)break;
        }
        C++;
    }
    if(C%2==0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3624
#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
#define dout(n) cout<<# n<<" = "<<n<<endl;
#define v1out(v) FOR(j,0,v.size()){cout<<v[j]; if(j!=(ll)v.size()-1)cout<<" ";else cout<<endl; }
#define v2out(v) FOR(i,0,v.size())v1out(v[i]);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> in(n);
    FOR(i,0,n)cin>>in[i];

    vector<ll> dp1(n/2,-1e17);
    vector<ll> dp2(n/2,-1e17);
    vector<ll> dp3(n/2,-1e17);
    dp1[0] = in[0];
    FOR(i,2,n){
        if(i+1>=n)break;
    //    cout<<"i1 = "<<i<<endl;
        dp1[i/2] = dp1[i/2-1] + in[i];
        i++;
    }
    dp2[0] = in[1];
    FOR(i,2,n){
        if(i+1>=n)break;
    //    cout<<"i2 = "<<i<<endl;
        dp2[i/2] = max(dp1[i/2-1],dp2[i/2-1]) + in[i+1];
        i++;
    }
    if(n>2)dp3[0] = in[2];
    FOR(i,2,n){
        if(i+2>=n)break;
    //    cout<<"i3 = "<<i<<endl;
        dp3[i/2] = max(dp1[i/2-1],max(dp2[i/2-1],dp3[i/2-1])) + in[i+2];
        i++;
    }

    ll ans = max(dp1[n/2-1],max(dp2[n/2-1],dp3[n/2-1]));
    cout<<ans<<endl;
    
    
}

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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

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

    int MAX=max({a,b,c});
    int sum=a+b+c;
    int sub=MAX*3-sum;

    if(sub%2==0)cout<<sub/2<<endl;
    else cout<<(sub+2-1)/2+1<<endl;

}


Measured memory_bytes: 256
#include<iostream>

#include<cmath>
#include<string>
#include <algorithm> 

using namespace std;

# define p(s) cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) cout << (j ? "Yes" : "No") << endl;

string lpad(string l,int s,int n){
    string temp = to_string(n);
    string res = "";
    int loop = s - temp.size();
    while(loop--) res+=l;

    return res+temp;
}

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

    int a = 10 - n/100;
    int b = 10 - (n%100)/10;
    int c = 10 - (n%10);

    p(a*100+b*10+c)
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll m,k;

int main(){
    cin >> m >> k;
    if((1 << m) <= k){
        cout << -1 << endl;
        return 0;
    }
    if(k == 0){
        rep(i,(1 << m)){
            if(i == 0)cout << i << " " << i;
            else cout << " " << i << " " << i;
        }
        cout << endl;
        return 0;
    }
    else{
        if(m == 1 && k == 1){
            cout << -1 << endl;
            return 0;
        }
        rep(i,(1 << m)){
            if(i != k)cout << i << " ";
        }
        cout << k << " ";
        for(ll i = (1 << m) - 1;i >= 0;i--){
            if(i != k)cout << i << " ";
        }
        cout << k << endl;
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

template<int_fast64_t MOD> struct modint{
    using i64=int_fast64_t;
    i64 a;
    modint(const i64 a_=0): a(a_){
        if(a>MOD) a%=MOD;
        else if(a<0) (a%=MOD)+=MOD;
    }
    modint inv(){
        i64 t=1, n=MOD-2, x=a;
        while(n){
            if(n&1) (t*=x)%=MOD;
            (x*=x)%=MOD;
            n>>=1;
        }
        modint ret(t);
        return ret;
    }
    bool operator==(const modint x) const{return a==x.a;}
    bool operator!=(const modint x) const{return a!=x.a;}
    modint operator+(const modint x) const{
        return modint(*this)+=x;
    }
    modint operator-(const modint x) const{
        return modint(*this)-=x;
    }
    modint operator*(const modint x) const{
        return modint(*this)*=x;
    }
    modint operator/(const modint x) const{
        return modint(*this)/=x;
    }
    modint operator^(const lint x) const{
        return modint(*this)^=x;
    }
    modint &operator+=(const modint &x){
        a+=x.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    modint &operator-=(const modint &x){
        a-=x.a;
        if(a<0) a+=MOD;
        return *this;
    }
    modint &operator*=(const modint &x){
        (a*=x.a)%=MOD;
        return *this;
    }
    modint &operator/=(modint x){
        (a*=x.inv().a)%=MOD;
        return *this;
    }
    modint &operator^=(lint n){
        i64 ret=1;
        while(n){
            if(n&1) (ret*=a)%=MOD;
            (a*=a)%=MOD;
            n>>=1;
        }
        a=ret;
        return *this;
    }
    modint operator-() const{
        return modint(0)-*this;
    }
    modint &operator++(){
        return *this+=1;
    }
    modint &operator--(){
        return *this-=1;
    }
    bool operator<(const modint x) const{
        return a<x.a;
    }
};

using mint=modint<1000000007>;

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    vector<bool> flag(n+10, false);
    rep(i, m){
        int a;
        scanf("%d", &a);
        flag[a] = true;
    }
    mint dp[n+10];
    dp[0] = 1;
    rep(i, n){
        if(!flag[i+1]) dp[i+1] += dp[i];
        if(!flag[i+2]) dp[i+2] += dp[i];
    }
    printf("%lld\n", dp[n]);
}

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

using namespace std;

const int mod = 1e9+7;
int add(int a, int b) {
	return a + b >= mod ? a + b - mod : a + b;
}
int mul(int a, int b) {
	return int(1LL * a * b % mod);
}
int fexp(int b, int e = mod - 2) {
	int ans = 1;
	while(e) {
		if(e & 1) ans = mul(ans, b);
		b = mul(b, b);
		e /= 2;
	}
	return ans;
}

const int N = 500005;

int n, k;

int cnt[N];
int fat[N], ifat[N];
int C(int i, int j) {
	if(j > i) return 0;
	return mul(mul(fat[i], ifat[j]), ifat[i-j]);
}

int main() {

	fat[0] = 1;
	for(int i = 1; i < N; i++) fat[i] = mul(i, fat[i - 1]);

	ifat[N-1] = fexp(fat[N-1]);

	for(int i = N - 2; i >= 0; i--) {
		ifat[i] = mul(i + 1, ifat[i + 1]);
	}

	scanf("%d %d", &n, &k);

	for(int i = 1; i <= k; i++) {
		for(int j = i; j <= k; j += i) {
			cnt[i]++;
		}
	}

	for(int i = 1; i <= k; i++) {
		cnt[i] = fexp(cnt[i], n);
	}

	for(int i = k; i >= 1; i--) {
		for(int j = i + i; j <= k; j += i) {
			cnt[i] = add(cnt[i], mod - cnt[j]);
		}
	}
	int ans = 0;

	for(int i = 1; i <= k; i++) {
		ans = add(ans, mul(i, cnt[i]));
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 8120
#include<iostream>
using namespace std;
int main()
{
    short int s1,s2,s3,n;
    cin >>n;
    s1=n/100;
    n%=100;
    s2=n/10;
    s3=n%10;
    cout<<s1+s2+s3<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main()
{
    int N, A, B;
    scanf("%d %d %d", &N, &A, &B);
    if (N * A < B)
    {
        printf("%d", N*A);
    }
    else 
    {
        printf("%d", B);
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <stdio.h>
#include <queue>
#include <stack>
#include <string.h>
#include <algorithm>
#include <math.h>
//#include <bits/stdc++.h>
#define ll long long
#define wtcl return
#define PI acos(-1)
#define MAXN 100005
using namespace std;
const ll mod = 1e9+7;
inline ll read()
{
	ll s = 0, f = 1;
	char ch = getchar();
	for(; ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = - 1;
	for(; ch >= '0' && ch <= '9'; ch = getchar()) s = ((s << 3ll) + (s << 1ll) + (ch ^ 48ll));
	return s * f ;
}
inline void out(ll x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) out(x/10);
	putchar(x%10+'0');
}
int num[200002];
int solve(int n)
{
	int res = n;
	while(n)
	{
		int t = n%10;
		res+=t;
		n /= 10;
	}
	return res;
}

void init()
{
	for(int i=0; i<=100000; i++)
		num[i] = 999999999;
	for(int i=1; i<=100000; i++)
	{
		int t = solve(i);
//		if(num[t] != 999999999)
//		{
//			cout<<i<<" "<<num[t]<<" "<<t<<endl;
//			system("pause");
//		}
		num[t] = min(i,num[t]);
	}
}
int main()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll f = 0;
	if(a%c != 0)
		f=1;
		//cout<<f<<"+++";
	ll k1 = (a/c+f)*c;   ///首项 k1, 公差c ，末项 z1 ；z1 = k1 + c * (n-1)
	ll z1 = (b/c) * c;

	//cout<<k1<<" "<<z1<<endl;
	f=0;
	if(a%d!=0)
		f=1;
	ll k2 = (a/d+f)*d;
	ll z2 = (b/d) * d;

	//cout<<k2<<" "<<z2<<endl;
	
	ll cd = c*d / __gcd(c,d);
	f=0;
	if(a%cd != 0)
		f=1;
	ll k3 = (a/cd + f)*cd;
	ll z3 = (b/cd) * cd;

	//cout<<k3<<" "<<z3<<endl;

	ll cs = (z1 - k1) / c+1;
	ll ds = (z2 - k2) / d+1;
	ll cds = (z3 - k3) / cd+1;

	//cout<<cs<<" "<<ds<<" "<<cds<<endl;

	ll ans = b - a + 1 - cs -ds + cds;
	cout<<ans<<endl;
	wtcl 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;

int main()
{
  ll N, A, B,C,ans=0;
  cin >> N;
  rep(i,N-1)
  {
    if(N%(i+1)==0)
    {
      ans += N / (i + 1) - 1;
    }
    else
    {
      ans += N / (i + 1);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
import bisect

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29

DIV = (10**9) + 7


def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def ncr(n, r, mod=DIV):
	r = min(r, n-r)
	ret = 1
	for i in range(1, r+1):
		ret = ret * (n-i+1) % mod
		ret = ret * mod_inv(i, mod) % mod
	return ret


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % mod) % mod
    return CONV()


def main():
    Arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
           1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    K = iRaw()
    print(Arr[K-1])
    return -1


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
public class Main {
	public static void main(String[] args)throws Exception{
		PrintWriter out = new PrintWriter(System.out);
		int A=nextInt();
		int B=nextInt();
		int C=nextInt();
		int K=nextInt();
		for(int i=0;i<K;i++){
			if(B<=A)
				B*=2;
			else
				if(B>=C)
					C*=2;
		}
		if(A<B&&B<C)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
	static boolean isOK(int index,String key,String[]a){
		if (a[index].compareTo(key)>=0) return true;
	    else return false;
	}
	static int binary_search(String key,String[] a) {
	    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	    int ok = (int)a.length; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	    while (Math.abs(ok - ng) > 1) {
	        int mid = (ok + ng) / 2;
	        if (isOK(mid,key,a)) ok = mid;
	        else ng = mid;
	    }
	    return ok;
	}
	//FastScanner
	static InputStream in = System.in;
	static  byte[] buffer = new byte[1024];
	static int length = 0, p = 0;
	public static boolean hasNextByte () {
		if (p < length) return true;
		else {
			p = 0;
			try {length = in.read(buffer);}
			catch (Exception e) {e.printStackTrace();}
			if (length == 0) return false;
		}
		return true;
	}
	public static int readByte () {
		if (hasNextByte() == true) return buffer[p++];
		return -1;
	}
	public static boolean isPrintable (int n) {return 33<=n&&n<=126;}
	public static void skip () {
		while (hasNextByte() && !isPrintable(buffer[p])) p++;
	}
	public static boolean hasNext () {skip(); return hasNextByte();}
	public static String next () {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int temp = readByte();
		while (isPrintable(temp)) {
			sb.appendCodePoint(temp);
			temp = readByte();
		}
		return sb.toString();
	}
	public static int nextInt () {return Math.toIntExact(nextLong());}
	public static int[] nextInts (int n) {
		int[] ar = new int[n];
		for (int i=0; i<n; i++) ar[i] = nextInt();
		return ar;
	}
	public static long nextLong () {
		if (!hasNext()) throw new NoSuchElementException();
		boolean minus = false;
		int temp = readByte();
		if (temp == '-') {
			minus = true;
			temp = readByte();
		}
		if (temp<'0' || '9'<temp) throw new NumberFormatException();
		long n = 0;
		while (isPrintable(temp)) {
			if ('0'<=temp && temp<='9') {
				n *= 10;
				n += temp - '0';
			}
			temp = readByte();
		}
		return minus? -n : n;
	}
}



Measured memory_bytes: 32536
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int h(string s){
	int ret = 0;
	int src = 1;
	for(int i=s.length()-1;i>=0;i--){
		ret += (s[i]>'9'?s[i]-'a'+10:s[i]-'0')*src;
		src *= 16;
	}
	return ret;
}

double f(string a,string b){	
	string tr,tg,tb;
	string tr2,tg2,tb2;
	tr = a.substr(1,2);
	tg = a.substr(3,2);
	tb = a.substr(5,2);
	tr2 = b.substr(1,2);
	tg2 = b.substr(3,2);
	tb2 = b.substr(5,2);
	return sqrt(
		(h(tr)-h(tr2))*(h(tr)-h(tr2)) +
		(h(tg)-h(tg2))*(h(tg)-h(tg2)) +
		(h(tb)-h(tb2))*(h(tb)-h(tb2))
	);
}
int main(){
	double MIN;
	string ret;
	
	string rgb;
	while(cin >> rgb && rgb[0] != '0'){
		MIN = (1<<21);
		if(MIN >     f(rgb,"#000000")){
			MIN = f(rgb,"#000000");
			ret = "black";
		}
		if(MIN >     f(rgb,"#0000ff")){
			MIN = f(rgb,"#0000ff");
			ret = "blue";
		}
		if(MIN >     f(rgb,"#00ff00")){
			MIN = f(rgb,"#00ff00");
			ret = "lime";
		}
		if(MIN >     f(rgb,"#00ffff")){
			MIN = f(rgb,"#00ffff");
			ret = "aqua";
		}
		if(MIN >     f(rgb,"#ff0000")){
			MIN = f(rgb,"#ff0000");
			ret = "red";
		}
		if(MIN >     f(rgb,"#ff00ff")){
			MIN = f(rgb,"#ff00ff");
			ret = "fuchsia";
		}
		if(MIN >     f(rgb,"#ffff00")){
			MIN = f(rgb,"#ffff00");
			ret = "yellow";
		}
		if(MIN >     f(rgb,"#ffffff")){
			MIN = f(rgb,"#ffffff");
			ret = "white";
		}
		cout << ret << endl;

	}
}

Measured memory_bytes: 908
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <tuple>
#include <iostream>
#include <deque>
#include <array>
#include <set>


int main() {
	int n, a, b, c, d; std::cin >> n >> a >> b >> c >> d;
	--a; --b; --c; --d;
	std::string s; std::cin >> s;
	bool has_non_blocking = false;
	for (auto i = a; i < c; ++i) {
		if (s[i] == '#' && s[i + 1] == '#') {
			std::cout << "No\n";
			return 0;
		}
	}
	for (auto i = b; i < d; ++i) {
		if (s[i] == '#' && s[i + 1] == '#') {
			std::cout << "No\n";
			return 0;
		}
	}
	bool hunuke_can_move = true;
	for (auto i = b; i <= d; ++i) {
		if (i + 1 < n) {
			if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
				has_non_blocking = true;
			}
		}
	}
	if (c < d || has_non_blocking) {
		std::cout << "Yes\n";
	}
	else {
		std::cout << "No\n";
	}
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const ll MOD = 1000000007;

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


int main() {
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    vector<ll> sum(n + 1);
    sum[0] = 0;
    for(int i = 1; i <= n; i++) {
        sum[i] += sum[i - 1] + i;
    }
    for(int i = k; i <= n + 1; i++) {
        if(n - i < 0) ans++;
        else ans += (sum[n] - sum[n - i]) - sum[i - 1] + 1; 
        ans %= MOD; 
    }

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

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

#define lli long long int
#define pb push_back
#define pii pair <int, int>
#define pll pair <lli, lli>
#define _F first
#define _S second
#define mset(x) memset(x, 0, sizeof(x))
#define fastio() ios_base::sync_with_stdio(0)

using namespace std;

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

	string S;
	cin >> S;

	int c = 0;
	int d = 0;

	for(int i=0; i<n; i++)
	{
		if(S[i] == ')')
		{
			if(c)
				c--;
			else
				d++;

		}
		else
		{
			c++;
		}
	}

	while(d--)
		cout << "(";

	cout << S;

	while(c--)
		cout << ")";

	return (0-0);	
}

Measured memory_bytes: 256
object Main extends App {
  import scala.io.StdIn._
  solve
  def solve: Unit = {
    val n = readLine.trim.toInt
    println(
      Array.tabulate(n){_ ⇒ readLine.trim}.foldLeft(Some(0, 0): Option[(Int, Int)]){
        case (Some((a, un)), "A") if a >= un ⇒ Some(a + 1, un)
        case (Some((a, un)), "Un") if a > un ⇒ Some(a, un + 1)
        case _ ⇒ None
      } match {
        case Some((a, un)) if a == un ⇒ "YES"
        case _ ⇒ "NO"
      }
    )
  }
  implicit class ScopeFunc[T](private val value: T) {
    def let[A](func:T ⇒ A): A = func(value)
    def also(func:T ⇒ Unit): T = {
      func(value)
      value
    }
  }
}




Measured memory_bytes: 43992
n = int(input())
a = list(map(int, input().split()))
result=0
flug = 0
if(len(a) == 1):
    print(1)
else:
    a.sort()
    dp = [True] * a[-1]
    flug = 1
    for j in range(n):
        if(dp[a[j]-1] == True):
            if(a[j] == a[j-1]):
                if(flug == 0):
                    result-=1
                    flug = 1
            else:
                result+=1
                flug = 0
                k = a[j] * 2
                while(k-1 < len(dp)):
                    dp[k-1] = False
                    k+=a[j]
                
    print(result)

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

const int p=998244353;
int n,f[10005][10005],sumr[5005];
char s[5005];

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++)sumr[i]=sumr[i-1]+'2'-s[i];
	f[0][0]=1;
	for(int i=1;i<=2*n;i++)
		for(int j=max(0,i-2*min(i,n)+sumr[min(i,n)]);j<=sumr[min(i,n)];j++)
			f[i][j]=(f[i-1][j-1]+f[i-1][j])%p;
	int ans=0;
	for(int i=0;i<=2*n;i++)ans=(ans+f[2*n][i])%p;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 156160
#include <bits/stdc++.h>
using namespace std;
int digit(long long a)
{
  int count=0;
  while(a>0)
  {
    a/=10;
    ++count;
  }
  return count;
}
   
int main()
{
  long long a;
  cin>>a;
  int ans=10;
  for(int i=1;(long long)i*i<=a;i++)
  {
    if(a%i==0)
    {
      int f=max(digit(i),digit(a/i));
      if(f<ans)ans=f;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;


int main () {

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

    int x, y;
    cin >> x >> y;
    if(2*c > a + b) {
        cout << 1ll*a*x + 1ll*b*y;
        return 0;
    }

    long long ans = 0;
    int minn = min(x, y);

    ans = minn * 2 * c;

    x -= minn;
    y -= minn;

    ans += x*min(2*c, a);
    ans += y*min(2*c, b);

    cout << ans;
    return 0;
}


Measured memory_bytes: 256
/* ITP1_6_C:Official House */
/* 20181122 AOJ */
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

int main(void) {
	int A[4][3][10] = {0};
	int b, f, r, v, n, i, j, k;

	i = 0;
	scanf("%d", &n);
	while((i++) < n) {
		scanf("%d %d %d %d", &b, &f, &r, &v);
		A[b-1][f-1][r-1] += v;
	}

	for(i = 0; i < 4; i++) {
		for(j = 0; j < 3; j++) {
			for(k = 0; k < 10; k++) {
				printf(" %d", A[i][j][k]);
			}
			printf("\n");
		}
		if(i < 3) {
			printf("####################\n");
		}
	}

	return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int U[101010],V[101010];
vector<int> E[101010];
map<pair<int,int>,int> M;
ll S[101010];
ll ret[101010];
int C[101010];
int D[101010];

int dfs(int cur,int pre,int d) {
	C[cur]=1;
	D[cur]=d;
	FORR(e,E[cur]) if(e!=pre) {
		C[cur]+=dfs(e,cur,d+1);
	}
	
	if(C[cur]!=N-C[cur] && pre!=-1) {
		ret[M[{cur,pre}]]=(S[cur]-S[pre])/(N-2*C[cur]);
	}
	return C[cur];
}

ll dfs2(int cur,int pre,ll sum) {
	ll tmp=sum;
	FORR(e,E[cur]) if(e!=pre) {
		tmp+=dfs2(e,cur,sum+ret[M[make_pair(cur,e)]]);
	}
	return tmp;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N-1) {
		cin>>U[i]>>V[i];
		U[i]--,V[i]--;
		E[U[i]].push_back(V[i]);
		E[V[i]].push_back(U[i]);
		M[{U[i],V[i]}]=M[{V[i],U[i]}]=i;
	}
	FOR(i,N) cin>>S[i];
	
	dfs(0,-1,0);
	
	FOR(i,N-1) {
		if(ret[i]==0) {
			ll tmp;
			if(D[U[i]]>D[V[i]]) {
				tmp=dfs2(U[i],-1,0);
				ret[i]=(S[U[i]]-tmp)/(N-C[U[i]]);
			}
			else {
				tmp=dfs2(V[i],-1,0);
				ret[i]=(S[V[i]]-tmp)/(N-C[V[i]]);
			}
			
		}
		cout<<ret[i]<<endl;
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 32896
#include <cstdio>
using namespace std;
#define LL long long
LL base=100;
int main()
{
	LL x;scanf("%lld",&x);int cnt=0;
	while(base<x){
		base=base+base*0.01;++cnt;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 1736
/******************************************
* AUTHOR : SOMU KUMAR *
* INSTITUTION : IIT BHUBANESWAR *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//code here...............//
int n;
cin>>n;
if(n>=30)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


  

long long power(long long a, long long b,long long mod) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %mod;
        a = a * a %mod;
        b >>= 1;
    }
    return res;
}

vector<vector<int> >adj;
int vis[100005];
void dfs(int ver)
{
    vis[ver]=1;
    for(auto i:adj[ver])
    {
        if(!vis[i])
            dfs(i);
    }
}

signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif      

    int n,m;
    cin>>n>>m;
    int x,y;
    adj.resize(n+1);
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            ans++;
            dfs(i);
        }
    }
    cout<<ans-1;

}

Measured memory_bytes: 10604
N, K = map(int, input().split())
A = list(map(int, input().split()))

def check(lst):
    for i in range(N):
        if lst[i] != N:
            return False
    return True

def move(lst):
    tmp = [0] * (N + 1)
    for i in range(N):
        a = lst[i]
        left = max(0, i - a)
        right = min(N, i + a + 1)
        tmp[left] += 1
        tmp[right] -= 1
    for i in range(N):
        tmp[i + 1] += tmp[i]
    return tmp

for i in range(K):
    A = move(A)
    if check(A):
        # print (i)
        break

print (*A[:-1])


Measured memory_bytes: 125168
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

const int INF = INT_MAX / 2;

int main()
{
    int n, x;
    cin >> n >> x;
    vector<int> d(n), c(n);
    for(int i=0; i<n; ++i)
        cin >> d[i] >> c[i];

    vector<int> dp(200000, INF);
    multimap<int, int> mm;
    dp[x] = 0;
    mm.insert(make_pair(0, x));
    while(!mm.empty()){
        int cost = mm.begin()->first;
        int pos = mm.begin()->second;
        mm.erase(mm.begin());
        if(dp[pos] < cost)
            continue;

        for(int i=0; i<n; ++i){
            int cost2 = cost + c[i];
            for(int j=0; j<2; ++j){
                int pos2 = abs(pos + d[i] * (1 - 2 * j));
                if(pos2 < 200000 && cost2 < dp[pos2]){
                    dp[pos2] = cost2;
                    mm.insert(make_pair(cost2, pos2));
                }
            }
        }
    }

    if(dp[0] < INF)
        cout << dp[0] << endl;
    else
        cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 12612
def main():
    a, b, m = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    discount = [list(map(int, input().split())) for _ in range(m)]

    ans = min(A) + min(B)

    for i in range(m):
        ticket = discount[i]
        tmp = A[ticket[0] - 1] + B[ticket[1] - 1] - ticket[2]
        if ans > tmp:
            ans = tmp

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 79852
import scala.io.StdIn.readLine

object Main extends App {

  readLine.trim.split(' ').map(_.toLong) match {
    case Array(a, b, c, d) =>
      val toB = b - b / c - b / d + b / lcm(c, d)
      val untilA = (a - 1) - (a - 1) / c - (a - 1) / d + (a - 1) / lcm(c, d)
      println(toB - untilA)
    case _ => ???
  }

  def lcm(a: Long, b: Long): Long = {
    a / gcd(a, b) * b
  }
  def gcd(a: Long, b: Long): Long = {
    b match {
      case 0 => a
      case _ => gcd(b, a % b)
    }
  }
}

Measured memory_bytes: 54668
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

dif = [0] * n

for i in range(n):
  dif[i] = v[i] - c[i]

for j in range(n):
  if dif[j] < 0:
    dif[j] = 0

print(sum(dif))

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

int main() {
  int N; cin >> N;
  vector<int> a(N); for (int i = 0; i < N; i++) cin >> a[i];
  
  int Alice = 0;
  int Bob = 0;
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  for (int i = 0; i < N/2; i++) {
      Alice += a[i*2];
      Bob += a[i*2+1];
  }
  if (N % 2 == 0) {
    cout << Alice - Bob << endl;
  } else {
    Alice += a[a.size()-1];
    cout << Alice - Bob << endl;
  }
}
    

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll A[100010];
int main()
{
	ll N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		//A[i] = 1000000000000000000;
	}
	for (int i = 0; i < N; i++) {
		if (A[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	ll ans = 1;
	double power = 1;
	for (int i = 0; i < N; i++) {
		ans *= A[i];
		power *= A[i];
		if (ans > 1000000000000000000 || ans != power) {
			cout << -1 << endl;
			return 0;
		}
	}
	if (ans > 1000000000000000000) cout << -1 << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 4332
#include<iostream>
using namespace std;
int main (){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if(x<0 || y<0) cout<<"No"<<endl; 
    else
    if((x+r)<=W && (y+r)<=H) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

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

using namespace std;

int n;
int h[200002], a[200002];
long long aib[200002];

void update (int x, long long val) {
  for (int i = x; i <= n; i += (i & (-i)))
    aib[i] = max(aib[i], val);
}

long long query (int x) {
  long long ans = 0;
  for (int i = x; i > 0; i -= (i & (-i)))
    ans = max(ans, aib[i]);
  return ans;
}

int main()
{
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> h[i];
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  for (int i = 1; i <= n; i++) {
    long long x = query(h[i]) + a[i];
    update(h[i], x);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    ans = max(ans, aib[i]);
  cout << ans;
  return 0;
}


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

#define f first
#define s second
#define ins insert
#define eb emplace_back
#define endl '\n'
#define ll long long
#define ld long double
#define vl vector<ll>
#define tc ll t; cin >> t; while (t--)
#define yes cout << "YES" << endl
#define no {cout << -1; return 0;}
#define sz(c) (ll) c.size()
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define trav(x,c) for(auto &x : c)
#define _for(i,a,n) for(ll i = a ; i < n ; ++i)
#define _rfor(i,a,n) for(ll i = n-1 ; i >= a ; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) trav(x,c) cout << x << " "; cout << endl;
#define godspeed ios::sync_with_stdio(0); cin.tie(0);

int main() {
    godspeed;
    ll n, m; cin >> n >> m;
    ll ans = 0;
    map<ll,ll> mp;

    ll x, y;
    while(m--) {
    	cin >> x >> y;

    	if(mp.count(x) && mp[x] != y) no;
    	if(n != 1 && x == 1 && y == 0) no;

    	mp[x] = y;
    }

    if(!mp.count(1) && n > 1) mp[1] = 1;
    else if(!mp.count(1)) mp[1] = 0;

    _for(i,1,n+1) cout << mp[i];

}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a) {if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(int a) {if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
void AorB(int a,string b,string c) {if(a){cout<<b<<endl;}else{cout<<c<<endl;}}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    int a,b;
    cin>>a>>b;
    if(a+b==15) cout<<"+"<<endl;
    else if(a*b==15) cout<<"*"<<endl;
    else cout<<"x"<<endl;
    return 0;
}



Measured memory_bytes: 256
def solve(string):
    n, k, *v = map(int, string.split())
    ans = 0
    for i in range(k + 1):
        for j in range(k - i + 1):
            base = sorted(v[:i] + v[max(n - k + i + j, i):])
            ans = max(ans, sum([b for l, b in enumerate(base) if b >= 0 or j <= l]))
    return str(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <functional>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {

  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<ll> A(X), B(Y), C(Z);
  REP(i, X) cin >> A[i];
  REP(i, Y) cin >> B[i];
  REP(i, Z) cin >> C[i];

  vector<ll> E;
  REP(i, X){
    REP(j, Y){
      E.push_back(A[i] + B[j]);
    }
  }

  sort(E.begin(), E.end(), greater<long long>());
  //REP(i, X*Y) cout << E[i] << " ";

  vector<ll> F;
  int kk = min(K, X * Y);
  REP(i, kk){
    REP(j, Z){
      F.push_back(E[i] + C[j]);
    }
  }
  sort(F.begin(), F.end(), greater<ll>());

  REP(i, K) cout << F[i] << endl;

  return 0;
}


Measured memory_bytes: 43240
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Integer> list = new ArrayList();
		int num = sc.nextInt();
		for (int i = 0; i < num; i++) {
			list.add(sc.nextInt());
		}
		Collections.sort(list);
		int sum_Alice = 0;
		int sum_Bob = 0;
		for (int i = 0; i < num; i++) {
			if (i % 2 == 0) {
				sum_Alice += list.get(list.size() - i - 1);
			} else {
				sum_Bob += list.get(list.size() - i - 1);
			}
		}
		System.out.println(sum_Alice-sum_Bob);
	}

}


Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

#define MOD 1000000007
 
const int dx_4[]={1,0,-1,0}, dy_4[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	ll n, a[300010];
	cin >> n;
	REP(i, 3*n) cin >> a[i];

	sort(a, a+3*n);

	ll ans = 0;
	for(int i = 3*n-2; i >= 3*n-2-2*(n-1); i -= 2){
		ans += a[i];
	}

	cout << ans << endl;
	rtn 0;
}

Measured memory_bytes: 2560
/*  Seventeen and we got a dream to have a family           */
/*  A house and everything in between                       */
/*  And then, oh, suddenly we turned twenty-three           */
/*  Now we got pressure for taking our life more seriously  */
/*  We got our dead-end jobs and got bills to pay           */
/*  Have old friends and know our enemies                   */
/*  Now I, I'm thinking back to when I was young            */
/*  Back to the day when I was falling in love              */
/*  He used to meet me on the Eastside                      */
/*  In the city where the sun don't set                     */

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set;
ll mod=1000000007;

int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
ll t=1;
//cin>>t;
while(t--)
{

ll n;
cin>>n;
ll a[n],i;

ll sw=0;
for(i=0;i<n;i++){
cin>>a[i];
if(a[i]==0)
sw=1;
}

ll ans=1;

if(sw==1)
{
   cout<<0<<endl;
   return 0;
}


for(i=0;i<n;i++)
{

  if( (1000000000000000000/ans)<a[i])
    {
        cout<<-1<<endl;
        return 0;
    }
   else
    ans*=a[i];

}

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













Measured memory_bytes: 4452
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  string s;cin>>s;
  vector<long long> a;
  if(s[0] == '0')a.push_back(0);
  int nw = 1;
  for(int i = 1; n > i; i++){
    if(s[i-1] != s[i]){
      a.push_back(nw);
      nw = 1;
    }else{
      nw++;
    }
  }
  a.push_back(nw);

  if(a.size()-1 <= k*2){
    cout << n << endl;
    return 0;
  }
  vector<long long> b;
  b.push_back(0);
  for(int i = 0; a.size() > i; i++){
    b.push_back(b[b.size()-1]+a[i]);
  }
  b.push_back(b[b.size()-1]);
  long long ans = -1;
  for(long long i = 0; b.size() >= k*2+1+i; i+=2){
    ans = max(ans,b[k*2+i+1]-b[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2676
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long K = sc.nextLong();
        int[] a = new int[N];
        int[] b = new int[N];
        Integer[] c = new Integer[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            c[i] = i;
        }
        Arrays.sort(c, (o1, o2) -> a[o1] - a[o2]);
        long ruikei = 0;
        for (int i = 0; i < N; i++) {
            ruikei += b[c[i]];
            if (ruikei >= K) {
                System.out.println(a[c[i]]);
                return;
            }
        }
    }
}


Measured memory_bytes: 91224
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;

int main() {
	cin >> N >> A;
	cout << N * N - A;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int n,m,cnt=0,o,p,aa[220000],cntl=0,ab[220000];
pair<int,int> pp[220000];
string s,ss[220000];
char c,cc[220000];
queue<int> que;
signed main(){
    cin>>n>>m>>o;
    for(int i=m;i<o+1;i++){
        if(i%n==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
}

Measured memory_bytes: 10520