akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    int a, b, c, x, y;
    long int cost=0;
    cin >> a >> b >> c >> x >> y;
    if(a + b >= 2 * c)
    {
        if (x >= y)
        {
            cost += 2 * c * y;
            x -= y; y = 0;
            if(a >= 2 * c)
            {
                cost += 2 * c * x;
            }
            else if(a < 2 * c)
            {
                cost += a * x;
            }
        }
        else if (y > x)
        {
            cost += 2 * c * x;
            y -= x; x = 0;
            if(b >= 2 * c)
            {
                cost += 2 * c * y;
            }
            else if(b < 2 * c)
            {
                cost += b * y;
            }
        }
    }
    else if (a + b < 2 * c)
    {
        cost += a * x + b * y;
    }
    cout << cost << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

long long mod = 1000000007LL;

long long dfs(vector <vector <int> > &edges, int v, int p, int c, long long k)
{
    int children = edges[v].size() - ((p >= 0) ? 1 : 0);
    long long ret = max(k - c, 0LL);
    long long used = 1LL + ((p >= 0) ? 1 : 0);
    for (int i = 0; i < edges[v].size(); i++) {
        if (edges[v][i] != p) {
            ret = (ret * dfs(edges, edges[v][i], v, used, k)) % mod;
            used += 1;
        }
    }
    return ret;
}

int main()
{
    long long MOD = 1000000007LL;
    int n, k;
    cin >> n >> k;
    vector <vector <int> > edges(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        edges[a - 1].push_back(b - 1);
        edges[b - 1].push_back(a - 1);
    }

    long long ret = dfs(edges, 0, -1, 0, k);
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 12800
#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 F[2100010];

ll Mul(ll a, ll b) {
	return ((a % mod) * (b % mod)) % mod;
}

void fact(void) {
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= 2100000; i++) {
		F[i] = Mul(i, F[i - 1]);
	}
}
ll square(ll x) {
	return (x * x) % mod;
}

ll power(ll x, ll y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

ll Div(ll a, ll b) {
	return Mul(a, power(b, mod - 2));
}
ll p(ll n, ll r) {
	if (n < r || n < 0 || r < 0) return 0;
	return Div(F[n], F[n - r]);
}

ll C(ll n, ll r) {
	if (n < r || n < 0 || r < 0) return 0;
	ll ret;
	ret = Div(F[n], Mul(F[n - r], F[r]));
	return ret;
}

ll H(ll n, ll r) {
	if (n == 0 && r == 0) return 1;
	return C(n + r - 1, r);
}

int main()
{
	fact();
	int N, M;
	cin >> N >> M;
	ll ans = 1;
	map<int, int> mp;
	set<int> st;
	int j = 2;
	while (M > 1 && j <= 100000) {
		while (M % j == 0) {
			M /= j;
			mp[j]++;
			st.insert(j);
		}
		j++;
	}
	if (M > 1) {
		mp[M]++;
		st.insert(M);
	}
	for (auto itr = st.begin(); itr != st.end(); itr++) {
		int num = *itr;
		ans = (ans * C(mp[num] + N - 1,mp[num] )) % mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 20044
n,m = gets.split.map &:to_i
h = gets.split.map &:to_i
ab = Array.new(m){ gets.split.map(&:to_i).map{ _1 - 1 } }
g = Array.new(n){ [] }

ab.each do |i,j|
  g[i] << j
  g[j] << i
end

ans = 0
g.each_with_index do |vs,i|
  if vs.empty?
    ans += 1
  elsif vs.all?{|j| h[i] > h[j]}
    ans += 1
  end
end

puts ans

Measured memory_bytes: 27192
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;

    vector<int >cnt(10, 0);

    int c = 0;
    int s = -1;
    bool f = false;
    REP(i, 4) {
        if (s != N % 10) {
            s = N % 10;
            c = 1;
        } else {
            c++;
        }
        N /= 10;

        if (c >= 3) {
            f = true;
        }
    }

    if (f) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
#define NIL -1
const int MOD = 1e9+7;
const int INF = 1 << 29;

ll f(int n){
    if(n==1)return 1;
    return f(n-1)%MOD*n%MOD;
}
int main(){
    int n,m;cin>>n>>m;
    if(abs(n-m)>1){
        cout<<0<<endl;return 0;
    }
        ll ans=f(n)*f(m)%MOD;
        if(n-m==0)ans=ans*2%MOD;
        cout<<ans<<endl;
        return 0;
    

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define ios       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define forn(i,a,n) for (ll i = a; i < (ll)(n); i++)
#define fon(i,n) for (ll i = (ll)n-1; i >=0; i--)
#define vi          vector<ll>
#define vii vector<pair<ll,ll>>
#define all(a)      (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ciin(v) forn(i,0,v.size()) cin>>v[i]
#define coutt(v) forn(i,0,v.size()) cout<<v[i]<<" "
using namespace std;
int main(){
    ios
    ll test;
    test=1;
    // cin>>test;
    while(test--){
        ll n;
        cin>>n;
        vi v(n+1),dp(n+1);
        forn(i,1,n+1) cin>>v[i];
        dp[2]=abs(v[2]-v[1]);
        forn(i,3,n+1){
            dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
        }
        cout<<dp[n];
     
      
       
  }}  


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;


int main(){

    long long n,k;
    cin>>n>>k;
    double s[n+1];
    s[0]=0;
    rep(i,n){
        double p;
        cin>>p;
        s[i+1]=s[i]+(p+1)/2;
    }
    double MAX=0;
    for(int i=0;i+k<=n;i++){
        MAX=max(MAX,s[k+i]-s[i]);
    }
    //double ans=(MAX/k;
    printf("%.7f",MAX);

    return 0;

}
/*


*/


Measured memory_bytes: 1792
def kosu(kitei, aaa, tuika):
    global now_ret
    ret = 0
    n=len(kitei)
    ret2=0
    kitei.append(aaa)
    n+=1
    for i in range(n):
        if kitei[i]:
            ret2 += 1
            x = 0
            while (2**(x+1)) <= kitei[i]:
                x += 1
            for y in range(i+1, n, 1):
                if kitei[y] & (2 ** x):
                    kitei[y] ^= kitei[i]
    
    if now_ret==ret2:
        return 1
    else:
        if tuika==1:
            now_ret+=1
        return 0
 
 
def solve(n, alist, s):
    kitei=[0]
    answer=0
    for i in range(n):
        teban=s[n-i-1]
        now=alist[n-i-1]
        if teban=='0':
            if kosu(kitei, now, 1)>0:
                pass
            else:
                kitei.append(now)
        else:
            if kosu(kitei, now, 0)>0:
                pass
            else:
                answer=1
        #print(kitei)
    return answer
 
t=int(input())
for i in range(t):
    now_ret=0
    n=int(input())
    alist = list(map(int, input().split()))
    s=input()
    print(solve(n, alist, s))

Measured memory_bytes: 69112
A, B, C = map(int, input().split())
K = int(input())

while A >= B:
    K -= 1
    B *= 2
    if K < 0:
        print('No')
        exit()
while B >= C:
    K -= 1
    C *= 2
    if K < 0:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 9176
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  for (int i = 100; i >= 1; --i) {
    if (a % i == 0 && b % i == 0) {
      if (--k == 0) {
        printf("%d\n", i);
        break;
      }
    }
  }
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int n;cin>>n;
    if(n>=64) cout<<64<<endl;
    else if(n>=32) cout<<32<<endl;
    else if(n>=16) cout<<16<<endl;
    else if(n>=8) cout<<8<<endl;
    else if(n>=4) cout<<4<<endl;
    else if(n>=2) cout<<2<<endl;
    else  cout<<1<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int t,x;
  cin >> t >> x;
  cout << fixed << setprecision(10) << (double)t / x << endl;
  return 0;
}



Measured memory_bytes: 256
import numpy as np
N = int(input())
seat = np.zeros(1000000, dtype=int)
L, R = np.array([input().split() for _ in range(N)], dtype=int).T

np.add.at(seat, L, 1)
np.add.at(seat, R+1, -1)
np.cumsum(seat, out=seat)
print(seat.sum())

Measured memory_bytes: 20308
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
	long long n, m;
	long long a[1005];
	double sum=0;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	sum = sum / (4 * m);
	int l = 0;
	for (int i = 0; i < n; i++)
	{
		if (a[i] >= sum)
		{
			l++;
		}
	}
	if (l >= m)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
function Main(input) {
	var sign = ["+", "-"];
	var num = input.toString().split("");
	for( var i=0; i < 8; i++ ){
	var str = num[0] + sign[((i&4)!=0)+0] + num[1] + sign[((i&2)!=0)+0] + num[2] + sign[((i&1)!=0)+0] + num[3];
	if ( eval(str) == 7 ){
		console.log(str+"=7");
		break;
	}
	}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {

    long long MinValue =  1000000;
    long long MaxValue = -1000000;
    long long sum = 0;
    long long a = 0;
    int n = 0;

    cin >> n;

    for ( int i = 0; i < n; i++ ) {
        cin >> a;
        if ( a < MinValue ) MinValue = a;
        if ( a > MaxValue ) MaxValue = a;
        sum += a;
    }

    cout << MinValue << " " << MaxValue << " " << sum << endl;

    return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main( void )
{
	int e;
	while(cin >> e, e) {
		bool hit = false;
		int answer = 1000001, sq_y = (int)(sqrt((double)e) + 1);
		for(int z=100; z > -1 && !hit; --z) {
			int sum_z = z * z * z;
			if(sum_z == e) { answer = min(answer, z); continue; }
			else if(sum_z > e) continue;
			for(int y=0; y < sq_y; ++y) {
				int sum_zy = sum_z + y * y;
				if(sum_zy == e) { answer = min(answer, z + y); break; }
				else if(sum_zy > e) break;
				else {
					answer = min(answer, (z + y + e - sum_zy));
				}
			}
		}
		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 868
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define N_MAX 100
#define M_MAX 1000
#define INF 10000000
#define SMAP(a, b) ((a)!=(b))&&((a)^=((b)^=((a)^= (b))))

typedef unsigned long long ull;

int d[M_MAX];
int n, m;

int i, j, k;

char s[N_MAX + 1], t[N_MAX + 1];

int e[M_MAX][2];

void deb(){
	return;
}

void solve(){
	i = n;
	for (;;) {
		if (!strncmp(s + n - i, t, i)) break;
		i--;
	}
	printf("%d\n", 2 * n - i);
	return;
}

int main (void) {
	scanf("%d", &n);
	scanf("%s%s", s, t);

	solve();
	return 0;
}




Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
using namespace std;
using ll = unsigned long long;
using p = pair<int, int>;

int main()
{
    int L, R, d;

    cin >> L >> R >> d;

    int cnt = 0;
    rep(i, L, R + 1)
    {
        if (i % d == 0)
        {
            ++cnt;
        }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3616
import sys

n,a,b,c = map(int,input().split())
s_list = [input() for _ in range(n)]
print_list = []


for i,s in enumerate(s_list):
    if s == 'AB':
        if a == 0 and b == 0:  
            print('No')
            sys.exit()
        else:
            if a > b:
                print_list.append('B')
                a -= 1
                b += 1
            elif b > a:
                print_list.append('A')
                a += 1
                b -= 1
            else:
                if c == 0:
                    if i < len(s_list)-1 and s_list[i+1] == 'AC':
                        print_list.append('A')
                        a += 1
                        b -= 1
                    else:
                        print_list.append('B')
                        a -= 1
                        b += 1
                else:
                    print_list.append('B')
                    a -= 1
                    b += 1


    elif s == 'BC':
        if c == 0 and b == 0:  
            print('No')
            sys.exit()
        else:
            if c > b:
                print_list.append('B')
                c -= 1
                b += 1
            elif b > c:
                print_list.append('C')
                c += 1
                b -= 1
            else:
                if a == 0:
                    if i < len(s_list)-1 and s_list[i+1] == 'AB':
                        print_list.append('B')
                        c -= 1
                        b += 1
                    else:
                        print_list.append('C')
                        c += 1
                        b -= 1
                else:
                    print_list.append('B')
                    c -= 1
                    b += 1

    elif s == 'AC':
        if a == 0 and c == 0:  
            print('No')
            sys.exit()
        else:
            if a > c:
                print_list.append('C')
                a -= 1
                c += 1
            elif c > a:
                print_list.append('A')
                a += 1
                c -= 1

            else:
                if b == 0:
                    if i < len(s_list)-1 and s_list[i+1] == 'AB':
                        print_list.append('A')
                        c -= 1
                        a += 1
                    else:
                        print_list.append('C')
                        c += 1
                        a -= 1
                else:
                    print_list.append('C')
                    c += 1
                    a -= 1

print('Yes')
for p in print_list:
    print(p)

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

int main() {
    int N, M; cin >> N >> M;
    int c[M];

    for (int i = 0; i < M; ++i) cin >> c[i];

    // initialize Dp table
    int T[M][N+1];
    for (int i = 0; i < M; ++i) T[i][0] = 0;
    for (int j = 1; j < N+1; ++j) T[0][j] = j / c[0];
    
    for (int i = 1; i < M; ++i) {
        for (int j = 1; j < N+1; ++j) {
            if (j < c[i]) {
                T[i][j] = T[i-1][j];
                continue;
            }

            T[i][j] = min(T[i-1][j], T[i][j-c[i]]+1);
        }
    }
  
    cout << T[M-1][N] << endl;
  
    return 0;
}





Measured memory_bytes: 6996
def main():
    n, k = map(int, input().strip().split())
    d = []
    a = []

    for i in range(k):
        tmp_d = int(input())
        tmp_a = list(map(int, input().strip().split()))
        d.append(tmp_d)
        a.append(tmp_a)

    flg = [False] * n

    for i in range(k):
        for j in range(d[i]):
            flg[a[i][j]-1] = True

    print(flg.count(False))

main()


Measured memory_bytes: 9232
#! /usr/bin/env ruby

input = STDIN.read.split("\n").map{|i| i.to_i}

input.shift
input.sort!

first = input.shift
arr = [first]

while input.length > 0
  fst = input.first
  lst = input.last

  afst = arr.first
  alst = arr.last

  diffs = [afst - fst, afst - lst, alst - fst, alst - lst].map{|i| i.abs}
  max_index = diffs.index(diffs.max)

  if max_index == 0 then
    arr.unshift(input.shift)
  elsif max_index == 1
    arr.unshift(input.pop)
  elsif max_index == 2
    arr.push(input.shift)
  elsif max_index == 3
    arr.push(input.pop)
  end
end

s = 0
for i in 0..(arr.length - 2)
  s = s + (arr[i] - arr[i+1]).abs
end

puts s


Measured memory_bytes: 14696
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int n;
    long long ans = 0;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    int b = 0;
    for(int i=0;i<n;i++){
        if(b > 0 && a[i] > 0){
            b--;
            a[i]--;
            ans++;
        } 
        ans += a[i]/2;
        b = a[i]%2;
    }
    cout << ans << endl;
}


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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define _P(...) (void)fprintf(stderr, __VA_ARGS__)

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

vector<vector<pii>> r(10);

const int INF = 1<<28;
VI dijkstra(int s ){
	priority_queue< pii, vector<pii>, greater<pii> > que;
	vector<int> d(10, INF); 
	d[1] = 0; 
	que.push(pii(0, 1));  //cost, from
	while(!que.empty()){
		int cost, v; tie(cost, v) = que.top();
		que.pop();
		//if(d[v] < cost) continue;
		for(const auto& rp : r[v]){ 
			int rct, rto; tie(rto, rct) = rp;
			if(d[rto] > d[v] + rct){
				d[rto] = d[v] + rct;
				que.push(pii(d[rto], rto));
			}
		}
	}
	return d;
}


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

	int h,w; cin >>h >>w;
	vector<VI> ba(h, VI(w));
	rep(i,10) rep(j,10){
		int v;
		cin >> v;
		//r[i].emplace_back(j, v);
		r[j].emplace_back(i, v);
	}
	rep(i,h) rep(j,w) cin>>ba[i][j];
	
	auto rc = dijkstra(1);
	ll ans =0;
	rep(i, h) rep(j,w) if(ba[i][j] != -1 ){
		ans += rc[ba[i][j]];
	}
	cout << ans <<"\n";
	return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
#define ll long long
#define mod 1000000007
using namespace std;
ll a[500010];
ll x[1 << 21],n;
ll dp[1<<21][3];
ll man[500010];
int main()
{
	scanf("%lld", &n);
	for (int i = 1; i <= n; i++)
		scanf("%lld", &a[i]);
	ll sum = 0;
	ll prev = 0;
	for (int i = 1; i <= n; i++) {
		sum ^= a[i];
		if (sum) {
			dp[sum][0] = (1 + man[i - 1] * dp[sum][1] - dp[sum][2] + mod) % mod;
			dp[sum][1] = (dp[sum][1] + dp[sum][0]) % mod;
			dp[sum][2] = (dp[sum][2] + dp[sum][0] * man[i - 1]) % mod;
		}
		else
			man[i] = 1;
		man[i] += man[i - 1];
	}
	if (sum)
		printf("%lld", dp[sum][0]);
	else
	{
		ll dap = 1;
		for (int i = 1; i <= man[n] - 1; i++) {
			dap *= 2;
			dap %= mod;
		}
		for (int i = 1; i < (1 << 20); i++)
		{
			dap += dp[i][1];
			dap %= mod;
		}
		printf("%lld\n", dap);
	}
}

Measured memory_bytes: 36736
from math import gcd
n, k = map(int, input().split())
a = list(set(map(int, input().split())))
a.sort(); b = a[0]
for i in range(1, len(a)): b = gcd(b, a[i])
if len(a) == 1:
    print("POSSIBLE") if k == a[0] else print("IMPOSSIBLE")
else:
    print("POSSIBLE") if k <= a[-1] and k%b == 0 else print("IMPOSSIBLE")

Measured memory_bytes: 25200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
    int H, W, h, w; cin >> H >> W >> h >> w;

    cout << (H - h) * (W - w) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
#define all(x) x.begin(), x.end()
#define fi first
#define se second
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+7;

int main() {
    Int a, b, k;
    cin >> a >> b >> k;
    Int sub = min(a, k);
    a -= sub;
    k -= sub;
    if (a == 0) {
        b = max((Int)0, b - k);
    }
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val x = readLine()!!.toList()

    val map = hashMapOf<Char, Int>()

    for (c in x) {
        val now = map.getOrElse(c) {0}
        map.put(c, now + 1)
    }

    if (map.keys.size == 2 && map.values.all { it == 2 }) {
        println("Yes")
    } else {
        println("No")
    }
}

Measured memory_bytes: 33908
#include <iostream>
#include <vector>
#include <string>

int main(){
    int N,K;
    std::cin>>N>>K;
    int n = (N+1)/2;
    if(n>=K){
      std::cout<<"YES"<<std::endl;
    }else{
      std::cout<<"NO"<<std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char str[1024];
char str2[1024];
int main()
{
	int len,i,t=0,tt=0;
	scanf("%d\n",&len);
	scanf("%s",str);
	scanf("%s",str2);
	for(i=0;i<len*2;i++)
	{
		if(i%2==0)
		{
			printf("%c",str[t]);
			t++;
		}
		else
		{
			printf("%c",str2[tt]);
			tt++;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import sys
for line in sys.stdin:
	l = list(map(int, line.split(',')))
	v1, v2 = l[10], l[11]
	sumlen = sum(l[:10])
	x = v1 * sumlen / (v1 + v2)
	temp_len = 0
	for i in range(10):
		temp_len += l[i]
		if x <= temp_len:
			print(i + 1)
			break

Measured memory_bytes: 7556
//#define India

#ifndef India
#include <bits/stdc++.h>
#else
#include "total.h"
#endif
#define fori(n) for(long long i=0;i<n;i++)
#define forr(i,x,y) for(long long i=x;i<y;i++)
#define forj(n) for(long long j=0;j<n;j++)
#define ll long long
#define d7 1000000007
#define en cout<<"\n";

using namespace std;

ll x=-1,kk=-1;
bool jpo=false;
void dfs(ll s, vector<bool> &v, vector<ll> &pr, vector<ll> adj[]){
    if(v[s]) return;
    v[s]=true;
    //cout<<s+1<<" ";
    for(auto u: adj[s]){
        if(!v[u]){
            pr[u]=s;
            //cout<<u<<" ";
            dfs(u,v,pr,adj);}
        else{
            if(!jpo&&pr[s]!=u){jpo=true;x=u;kk=s;}
        }
    }
}
ll binomialCoeff(ll n, ll k){
   ll C[n + 1][k + 1];ll i, j;
   for (i = 0; i <= n; i++){
       for (j = 0; j <= min(i, k); j++){
           if (j == 0 || j == i){C[i][j] = 1;}
           else{C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);}}}
   return C[n][k];
}
void bfs(vector<ll> &dis, vector<ll> adj[], ll s, vector<ll> &parent){
    dis[s]=0;
    //parent[s]=-1;
    queue<ll> q;
    q.push(s);
    while(!q.empty()){
        ll z=q.front();
        //cout<<z<<" ";
        q.pop();
        for(auto v:adj[z]){
            if(dis[v]==0){
            q.push(v);
            dis[v]=dis[z]+1;
                parent[v]=z;
            }
        }
    }
}

ll modexp(ll x, ll n,ll m){
    if(n==0) return 1%m;
    ll u=modexp(x,n/2,m);
    u=(u*u)%m;
    if(n%2==1) u=(u*x)%m;
    return u;
}

ll modinv(ll x, ll mod) { return modexp(x, mod - 2, mod); }
const int Nx=1e6+5;
ll fact[Nx];
void factorial(){fact[0]=1;
    for(int i=1;i<Nx;i++)
    {
        fact[i]=(fact[i-1]*i)%d7;
    }
    return ;}
ll binomial(ll a,ll b,ll mod){
    return ((fact[a]*modinv(fact[b],mod))%mod*modinv(fact[a-b],mod))%mod;}

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

tuple<ll,ll,ll,ll> expA(tuple<ll,ll,ll,ll> v, ll n){
    if(n==0){return {1,0,1,0};}
    if(n==1){return v;}
        ll x1,y1,z1,w1;
        ll x2,y2,z2,w2;
        tie(x1,y1,z1,w1) = expA(v, n/2);
        x2=(x1*x1+y1*z1)%d7;
        y2=(x1*y1+y1*w1)%d7;
        z2=(z1*x1+w1*z1)%d7;
        w2=(z1*y1+w1*w1)%d7;
    if(n%2==0){
        return {x2,y2,z2,w2};
    }
    else{
        return {x2+z2,y2+w2,x2,y2};
    }
}

//ll st[200010][30];
//ll loge2[200001];
//void logify(){
//loge2[1] = 0;
//for (ll i = 2; i <= 200001; i++)
//    loge2[i] = loge2[i/2] + 1;
//}

int main(){
    
    
    ll n;
    cin>>n;
    ll m;
    cin>>m;
    ll aa[m];
    fori(m) cin>>aa[i];
    ll sum=0;
    fori(m){sum+=aa[i];}
    if(sum>n){cout<<-1;}
    else{cout<<n-sum;}
    
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n;
  cin >> n;
  int64_t ans = 0;
  for(int64_t i=0;i<n+1;i++){
    if(i%3!=0&&i%5!=0){
      ans += i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
import math
n = int(input())
c = n


def is_prime(n):
    for i in range(2, int(math.sqrt(n)+1)):
        if n % i == 0:
            return False
    return True


while True:
    if is_prime(c):
        print(c)
        exit(0)
    else:
        c+=1


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N,M;
    int A[314][314];
    cin >> N >> M;
    REP(i,N){
        REP(j,M){
            cin >> A[i][j];
            A[i][j]--;
            A[i][j+1]=311;
        }
    }
    int Ans=N;
    bool E[314];
    int now[314]={};
    REP(j,M){
        //計測
        int F[314];
        REP(i,N){
            F[i]=A[i][now[i]];
        }
        
        //削除決定
        int G[314]={};
        REP(i,N){
            G[F[i]]++;
        }
        int h=0;
        REP(i,M){
            if(!E[i] && G[h]<G[i]){
                h=i;
            }
        }
        //削除
        //REP(i,N){cout << F[i] << " ";}cout << endl;cout << G[h] << endl;
        Ans=min(Ans,G[h]);
        E[h]=true;
        REP(i,N){
            while(1){
                if(E[A[i][now[i]]]==true){
                    now[i]++;
                }else{
                    break;
                }
            }
        }
    }
    cout << Ans << endl;
    
  return 0;
}



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

int n, m, a;

int main() {
	cin >> n >> m >> a;
	for (int i = 0; i <= n; ++i)
		for (int j = 0; j <= m; ++j) {
			if (m*i + n*j - 2*i*j == a) {
				cout << "Yes\n";
				return 0;
			}
		}

	cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
A,B,K=map(int,input().split())

for i in range(K):
  if i%2==0:
    if A%2==1:
      A -=1
    B += A//2
    A = A//2
    
  else:
    if B%2==1:
      B -=1
    A += B//2
    B = B//2
    
print(A,B)

Measured memory_bytes: 9132
#include<stdio.h>
#include<stdlib.h>

int main()
{
  int i,H;

  scanf("%d",&H);

  int a[H+1];

  for(i=1; i<=H; i++)
    scanf("%d",&a[i]);

  if(H <= 1){
    printf("node %d: key = %d, ",1,a[1]);
    exit(0);
  }
  printf("node %d: key = %d, ",1,a[1]);
  if(H >= 2)
    printf("left key = %d, ",a[2]);
  if(H >= 3)
    printf("right key = %d, ",a[3]);
  printf("\n");
  
  for(i=2; i<=H; i++){
    printf("node %d: key = %d, parent key = %d, ",i,a[i],a[i/2]);
    if(i*2 <= H)
      printf("left key = %d, ",a[i*2]);
    if(i*2+1 <= H)
      printf("right key = %d, ",a[i*2+1]);
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2032
#include <stdio.h>
#include <cstdio>
#include <string>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{

	long long int Q, H, S, D, N;

	scanf("%lld%lld%lld%lld%lld", &Q, &H, &S, &D, &N);


	long long int calc[4];

	calc[0] = Q;
	calc[1] = H;
	calc[2] = S;
	calc[3] = D;
	N *= 4;

	long long int ans = 0;

	if (N >= 8)
	{
		long long int buf = N / 8;

		ans += buf * std::min(std::min(calc[0] * 8, calc[1] * 4), std::min(calc[2] * 2, calc[3]));

		N %= 8;

	}



	if (N >= 4)
	{
		long long int buf = N / 4;

		ans += buf * std::min(std::min(calc[0] * 4, calc[1] * 2), calc[2]);

		N %= 4;

	}
	if (N >= 2)
	{
		long long int buf = N / 2;

		ans += buf * std::min(calc[0] * 2, calc[1]);

		N %= 2;

	}

	ans += N * calc[0];

	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

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

using namespace std;

int main()
{
    int a, b;
    string  s;  cin >> a >> b >> s;

    bool numcheck1 = true, numcheck2 =true;
    rep(i, a){
        if(s[i] < '0' || '9' < s[i]){
            numcheck1 = false;
            break;
        }
    }
    rep(i, b){
        if(s[a + 1 + i] < '0' || '9' < s[a + i]){
            numcheck2 = false;
            break;
        }
    }

    if(numcheck1 && numcheck2 && s[a] == '-'){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int n, m, x, a = 0, b = 0;
	cin >> n >> m >> x;
	for (int i = 0; i < m; i++) {
		int j;
		cin >> j;
		if (j < x) {
			a++;
		} else {
			b++;
		}
	}
	cout << min(a, b) << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:isize,
    b:isize,
    c:isize,
    }
    println!("{}",if a+b+c-max(a,max(b,c))==max(a,max(b,c)){"Yes"}else{"No"})
}

Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,q,hidari,migi,ans;
  cin>>n>>q;
  string str;
  cin>>str;
  vector<int> vec(n);
  for(int i=0; i<n; i++){
    if(i==0){
      vec.at(i)=0;
    }
    else{
      if(str.at(i)=='C'&&str.at(i-1)=='A'){
        vec.at(i)=vec.at(i-1)+1;
      }
      else{
        vec.at(i)=vec.at(i-1);
      }
    }
  }
  for(int i=0; i<q; i++){
    cin>>hidari>>migi;
    ans=vec.at(migi-1)-vec.at(hidari-1);
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;

  vector <int> n(4);

  for (int i = 0;i < 4;i++) {
    n[i] = (int)(s[i]-'0');
  }

  if (n[0] == n[1] || n[1] == n[2] || n[2] == n[3]) {
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<utility>

using namespace std;

long long a, n, m, _m, ylim, tmp, cnt = 0, ans = 0;

int main(){
	cin >> a >> n >> m;
	_m = m;
	long long x1 = 0, x2 = -1;
	while(_m){
		x1 += (_m % 10);
		_m /= 10;
	}
	_m = m;
	while(_m){
		if(_m / 10) x2 += 9;
		else x2 += _m;
		_m /= 10;
	}
	ylim = max(x1, x2);
	for(long long y = 1; y <= ylim; y++){
		tmp = y + a;
		long long t = tmp;
		for(int i = 1; i < n; i++){
			tmp *= t;
		}
		if(tmp > m)continue;
		long long _t = tmp;
		cnt = 0;
		while(_t){
			cnt += (_t % 10);
			_t /= 10;
		}
		if(cnt == y)ans++;
	}
	cout << ans << endl;
	return 0;
}


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

#define mod 1000000007
#define maxn 200005

typedef pair<ll, ll> P;

bool cmp(P p1, P p2) { return p1.first == p2.first ? p1.second > p2.second : p1.first < p2.first; }

ll n, x, d;
map<int, vector<P>> mp;

int main()
{
    cin >> n >> x >> d;
    if (d == 0)
    {
        cout << ((x == 0) ? 1 : n + 1) << endl;
        return 0;
    }
    if (d < 0)
        x = -x, d = -d;
    for (ll i = 0; i <= n; i++)
    {
        ll gp = i * x % d;
        ll l = i * x + i * (i - 1) / 2 * d;
        ll r = i * x + (i * n - i * (i + 1) / 2) * d;
        mp[gp].push_back(P((l - gp) / d, (r - gp) / d));
    }
    ll ans = 0;
    for (auto iter = mp.begin(); iter != mp.end(); iter++)
    {
        vector<P> &v = iter->second;
        if (v.empty())
            continue;
        sort(v.begin(), v.end(), cmp);
        ll l = v[0].first;
        ll r = v[0].second;
        for (int j = 1; j <= v.size(); j++)
        {
            if (j == v.size())
            {
                ans += (r - l + 1);
                break;
            }
            if (v[j].first > r)
            {
                ans += (r - l + 1);
                l = v[j].first;
                r = v[j].second;
            }
            else
                r = max(r, v[j].second);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 22144
#include<stdio.h>
int main(void)
{
	int t,n,d[4],cnt=0;
	while(cnt!=4){
	scanf("%d %d",&t,&n);
	if(t==1)
	d[cnt]=6000*n;
	else if(t==2)
	d[cnt]=4000*n;
	else if(t==3)
	d[cnt]=3000*n;
	else
	d[cnt]=2000*n;
	cnt++;
	}
	cnt=0;
	while(cnt!=4){
	printf("%d\n",d[cnt]);
	cnt++;
	}
	return 0;
}

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

const int MAX_N = 1e5;
int par[MAX_N];     //親
int rnk[MAX_N];    //木の深さ
//par[x] == xであるとき、xは木の根である

//n要素で初期化
void init(int n) {
    for(int i = 0; i < n; ++i) {
        par[i] = i;
        rnk[i] = 0;
    }
}

//木の根を求める
int find(int x) {
    if(par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

//xとyの属する集合を併合
void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(rnk[x] < rnk[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if(rnk[x] == rnk[y]) rnk[x]++;
    }
}

//xとyが同じ集合に属するか否か
bool same(int x, int y) {
    return find(x) == find(y);
}

int main()
{
    init(14);
    unite(1, 3);
    unite(3, 5);
    unite(5, 7);
    unite(7, 8);
    unite(8, 10);
    unite(10, 12);
    unite(4, 6);
    unite(6, 9);
    unite(9, 11);
    
    int x, y;
    cin >> x >> y;
    if(same(x, y)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

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

long long max(long long a, long long b){
    if (a > b) return a;
    else return b;
}

int main(void){
    // Your code here!
   int N;
   cin >> N;
   long long A[N];
   for(int i = 0; i < N; i++) cin >> A[i];
   
   long long dpl[N+1];
   long long dpr[N+1];
   
   dpl[0] = A[0];
   dpr[0] = A[N-1];
   for(int i = 0; i < N; i++){
       dpl[i+1] = gcd(dpl[i], A[i]);
   }
   
   for(int i = 0; i < N; i++){
       dpr[i+1] = gcd(dpr[i], A[N-1-i]);
   }
   

   int maxv = 0;
   for(int i = 2; i <= N-1; i++){
       maxv = max(maxv, gcd(dpl[i-1], dpr[N-i]));
   }
   
   maxv = max(maxv, dpr[N-1]);
   maxv = max(maxv, dpl[N-1]);
   maxv = max(maxv, dpl[N]);

   cout << maxv << endl;
}


Measured memory_bytes: 2560
//BUGSBUNNY
//IIT ROORKEE

#include<bits/stdc++.h>
using namespace std; 
#define int long long
#define ll long long
#define double long double
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define vl vector<long long>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vb vector<bool>
#define pb push_back
#define pob pop_back
#define gcd __gcd
#define mp make_pair
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
// #define mod 1000000007
#define mod 1000000000 
// #define mod 998244353
#define rep(i,n) for (ll i = 0; i < n; i++)
#define repp(i,a,b) for(ll i = a ; i<b ; i++)
#define reppr(i,a,b) for(ll i = a-1 ; i>=b ; i--)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " << 
#define setprec(x) cout << fixed << setprecision(x);
#define reve(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()

//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }

//modInverse
    int modInverse(int a) 
    { 
       return powmod(a,mod-2); 
    }

//Binomial Coefficients
    // int fact[200010], factinv[200010];
    // int nCr(int n , int r)
    // {
    //     return ((fact[n] * modInverse(fact[n-r]) % mod * modInverse(fact[r]))%mod) ;
    // }


void solve();

signed main()
{
    //-------------------------------------------------------------------------------
        
        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
        clock_t clk = clock();

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

        // fact[0] = 1 , factinv[0] = 1;
        // repp(i,1,200010)
        // {
        //     fact[i] = (fact[i-1] * i)%mod;
        //     factinv[i] = (factinv[i-1] * modInverse(i))%mod;
        // }
        
    //-------------------------------------------------------------------------------
        int t = 1;
        // cin >> t;
        while(t--)
            solve();
        clk = clock() - clk;
        cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;
    //-------------------------------------------------------------------------------
}

void solve()
{
    int n , m ;
    cin >> n >> m ;
    int a[n] , count = 0 , sum = 0;
    rep(i,n)
    {
        cin >> a[i];
        sum+=a[i];
    }
    rep(i,n)
        if((4*m*a[i])>=sum)
            count++;
    cout << ((count>=m)?"Yes":"No");

}

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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	long long N;
  cin >> N;
  map<long long,long long> num;
  froop1(0,N){
	int n;
    cin >> n;
    if(num.count(n)){
		num[n]++;
    }else{
      num[n] = 1;
    }
  }
  long long count = 0;
  for(pair<long long,long long> p : num){
   long long p1 = p.first,p2 = p.second;
    if(p1 > p2){
      count += p2;
    }else if(p1 < p2){
      count += p2 - p1;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 9476
#include <bits/stdc++.h>
#define MAX 100005
#define MOD 1000000007
#define INF 1e9
#define mp make_pair
using namespace std;

typedef long long ll;
int arr[MAX];
vector<int> diff;

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    int n, k;

    cin>>k>>n;

    for(int i = 0; i < n; i++){
        cin>>arr[i];
    }

    if(k >= n){
        cout<<0<<endl;
        return 0;
    }
    sort(arr, arr + n);

    int sum = arr[n-1] - arr[0];
    for(int i = 1; i < n; i++){
        diff.push_back(arr[i] - arr[i-1]);
    }

    sort(diff.begin(), diff.end());
    reverse(diff.begin(), diff.end());

    for(int i = 0; i < k - 1; i++){
        sum -= diff[i];
    }

    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
#define LL long long
#define Max 1000005
#define Mod 1e9+7
#define INF 0x3f3f3f3f
using namespace std;
LL a[Max],b[Max],book[Max];
LL ca,cb;
bool cmp(int a,int b)
{
	return a>b;
}
int main()
{
    LL n;
    memset(b,0,sizeof(b));
    memset(book,0,sizeof(book));
	cin>>n;
    for(LL i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i+=2)
	{
		b[a[i]]++;
		if(ca<b[a[i]])
		{
			ca=b[a[i]];
			cb=a[i];
		}
	}
	for(LL i=1;i<n;i+=2)
	{
		if(cb!=a[i])
		book[a[i]]++;
	}
	sort(b,b+Max,cmp);
	sort(book,book+Max,cmp);
	LL ans=n-b[0]-book[0];
	memset(b,0,sizeof(b));
    memset(book,0,sizeof(book));
	for(int i=1;i<n;i+=2)
	{
		b[a[i]]++;
		if(ca<b[a[i]])
		{
			ca=b[a[i]];
			cb=a[i];
		}
	}
	for(LL i=0;i<n;i+=2)
	{
		if(cb!=a[i])
		book[a[i]]++;
	}
	sort(b,b+Max,cmp);
	sort(book,book+Max,cmp);
	LL ans1=n-b[0]-book[0];
	cout<<min(ans,ans1)<<endl;
    return 0;
}


Measured memory_bytes: 18688
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long w, h, x, y;
  cin >> w >> h >> x >> y;
  printf("%.6f ", (double)w * h / 2);
  cout << (x * 2 == w && y * 2 == h ? 1 : 0) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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();
        if (c >= a && c <= b)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>

using namespace std;
int main(int argc, const char * argv[]) {
    
    string s;
    int n;
    cin >> n >> s;

    int m=__INT_MAX__;
    vector<int> bc(n+1,0);
    for(int i = 0; i < n; i++)
    {
        bc[i+1] = bc[i];
        if (s[i]=='#') bc[i+1]++;
    }

    for(int i = 0; i <= n; i++)
    {
        m = min(m, (bc[i] + n - (bc[n] - bc[i] ) - i));
    }
    

    cout << m << endl;
    return 0;
}

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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;

#ifdef HOME
#define db(x) { cerr << #x << " = " << x << endl; }
#define db2(x, y) { cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl; }
#define db3(x, y, z) { cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")" << endl; }
#define dbv(a) { cerr << #a << " = "; for (auto xxx: a) cerr << xxx  << " "; cerr << endl; }
#else
#define db(x) ;
#define db3(x, y, z) ;
#define db2(x, y) ;
#define dbv(a) ;
#endif

#define sz(a)  (int)(a).size()
#define all(a) (a).begin(),a.end()
#define pw(x)  (1LL << (x))


class B {
public:
    void solve(std::istream &in, std::ostream &out) {
        ios_base::sync_with_stdio(0);
        in.tie(0);

        int n, m, k;
        in >> n >> m >> k;
        int x, y;
        in >> x >> y;
        x--;
        y--;
        string s, t;
        in >> s >> t;


        string res = "YES";
        int mnx = -1, mxx = n;
        int mny = -1, mxy = m;
        for (int i = k - 1; i >= 0; i--) {
            if (t[i] == 'U') {
                mxx = min(n, mxx + 1);
            } else if (t[i] == 'D') {
                mnx = max(-1, mnx - 1);
            } else if (t[i] == 'L') {
                mxy = min(m, mxy + 1);
            } else if (t[i] == 'R') {
                mny = max(-1, mny - 1);
            } else
                assert(0);

            if (s[i] == 'U') {
                mnx = min(n - 1, mnx + 1);
            } else if (s[i] == 'D') {
                mxx = max(0, mxx - 1);
            } else if (s[i] == 'L') {
                mny = min(m - 1, mny + 1);
            } else if (s[i] == 'R') {
                mxy = max(0, mxy - 1);
            } else
                assert(0);

            if (mnx == n - 1 || mxx == 0 || mny == m - 1 || mxy == 0) res = "NO";
        }
//        db2(mnx, mxx);
//        db2(mny, mxy);
        if (x <= mnx || x >= mxx || y <= mny || y >= mxy) res = "NO";
        out << res << endl;
    }
};


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


Measured memory_bytes: 920
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int W = scan.nextInt();
    int H = scan.nextInt();
    int x = scan.nextInt();
    int y = scan.nextInt();
    int r = scan.nextInt();

    if (0 <= x + (-r) && 0 <= y + (-r) && x + r <= W && y + r <= H) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 26376
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl;
#define rep(i,n) for(ll i = 0;i < n;++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0);

const ll INF = 1e9+7;

// 各桁の和
template<typename T>
T digit(T num){
  T sum = 0;
  while(num){
    sum += num % 10;
    num /= 10;
  }
  return sum;
}


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; 
}

int main(){
  int N;cin>>N;
  vector<ll> T(N);rep(i,N)cin>>T[i];
  ll ans = 1;
  rep(i,N){
    ans = lcm(max(ans,T[i]),min(ans,T[i]));
  }
  print(ans)
  return 0;
}


Measured memory_bytes: 256
x = int(input())

if x == 2:
    print(2)
    exit()

flag = True
x -= 1
while flag:
    x += 1
    i = 2
    while flag:
        if x % i == 0:
            break
        elif i ** 2 >= x:
            flag = False
        else:
            i += 1
print(x)

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
#include <set>
const int MOD = 998244353;
typedef long long ll;
using namespace std;

ll modfact[200001];

ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

ll modinv(ll a) {
    return modpow(a, MOD - 2);
}

ll nCr(ll n, ll r){
	if (r == 0) return 1;
	if (n < r){
		return 0;
	}
	return (modfact[n]*modinv(modfact[r])%MOD)*modinv(modfact[n-r])%MOD;
}

ll nPr(ll n, ll r){
	if (n < r){
		return 0;
	}
	return modfact[n]*modinv(modfact[n-r])%MOD;
}

int main(){
	int n, m, k;
	cin >> n >> m >> k;
	modfact[0] = 1;
	for (int i = 1; i <= 200000; i++){
		modfact[i] = i*modfact[i-1]%MOD;
	}
	ll ans = 0;
	for (int i = 0; i <= k; i++){
		ans += (m*modpow(m-1, n-i-1)%MOD)*nCr(n-1, i)%MOD;
	}
	cout << ans%MOD << endl;
	return 0;
}


Measured memory_bytes: 5196