akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  int N;
  cin >> N;

  int a[N];
  for (int i = 0; i < N; ++i)
    cin >> a[i];

  int gray = 0;
  int brown = 0;
  int green = 0;
  int cyan = 0;
  int blue = 0;
  int yellow = 0;
  int orange = 0;
  int red = 0;
  int higher = 0;
  for (int i = 0; i < N; ++i) {
    if (a[i] <= 399)
      gray = 1;
    else if (a[i] <= 799)
      brown = 1;
    else if (a[i] <= 1199)
      green = 1;
    else if (a[i] <= 1599)
      cyan = 1;
    else if (a[i] <= 1999)
      blue = 1;
    else if (a[i] <= 2399)
      yellow = 1;
    else if (a[i] <= 2799)
      orange = 1;
    else if (a[i] <= 3199)
      red = 1;
    else
      ++higher;
  }

  int ret = gray + brown + green + cyan + blue + yellow + orange + red;

  if (ret == 0 && higher > 0)
    cout << 1 << " " << higher << endl;
  else
    cout << ret << " " << ret + higher << endl;

  return 0;
}

Measured memory_bytes: 256
from sys import stdin
n = int(stdin.readline().rstrip())
def num(n):
    if n == 0:
        return ""
    if n%2 == 0:
        return num(n//(-2)) + "0"
    else:
        return num((n-1)//(-2)) + "1"
if n == 0:
    print(0)
    exit()
print(num(n))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <math.h>
#include <algorithm>
#include <deque>
#include <climits>

using namespace std;
#define ll long long
#define ve vector
#define umap unordered_map
#define iter iterator


int main() {
    int k, s;
    cin>>k>>s;
    int ans=0;
    for(int x=0;x<=k;x++) {
        for(int y=0;y<=k;y++) {
            int z=s-x-y;
            if(z>=0 && z<=k)ans++;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
template <class T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
template <class T>
using ordered_multiset = __gnu_pbds::tree<T, __gnu_pbds::null_type, less_equal<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

#define PI atan2(0, -1)
#define EPS 1e-9
#define INF 5e18
#define MOD 1000000007

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

int N, M;
long long K, A [200010], B [200010];

int main(){
    //freopen("sort.in", "r", stdin); freopen("sort.out", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10);
    cin >> N >> M >> K;
    int ret = 0, aidx = N-1, bidx = -1;
    long long asum = 0, bsum = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        asum += A[i];
    }
    while(asum > K){
        asum -= A[aidx];
        aidx--;
    }
    for(int i = 0; i < M; i++) cin >> B[i];
    while(bidx < M-1 && asum+bsum+B[bidx+1] <= K){
        bsum += B[bidx+1];
        bidx++;
    }
    ret = aidx+bidx+2;
    while(aidx > -1){
        asum -= A[aidx]; aidx--;
        while(bidx < M-1 && asum+bsum+B[bidx+1] <= K){
            bsum += B[bidx+1];
            bidx++;
        }
        if(asum+bsum <= K) ret = max(ret, aidx+bidx+2);
    }
    cout << ret << '\n';
    return 0;
}

/******************************
Kateba ii dake no hanashi darou
Success is only a victory away
- No Game No Life Opening
******************************/

Measured memory_bytes: 6772
s = input()
n = len(s)
mod = 998244353

rb_use = [[0]*(2*n+1)  for _ in range(2)]
r = 0
b = 0
for i in range(n):
    if(s[i]=='0'):
        r += 2
    elif(s[i]=='1'):
        r += 1
        b += 1
    else:
        b += 2
    rb_use[0][i+1] = rb_use[0][i]
    rb_use[1][i+1] = rb_use[1][i]
    if(r>0):
        rb_use[0][i+1] += 1
        r -= 1
    if(b>0):
        rb_use[1][i+1] += 1
        b -= 1

for i in range(n,2*n):
    rb_use[0][i+1] = rb_use[0][i]
    rb_use[1][i+1] = rb_use[1][i]
    if(r>0):
        rb_use[0][i+1] += 1
        r -= 1
    if(b>0):
        rb_use[1][i+1] += 1
        b -= 1

r_max = rb_use[0][-1]
b_max = rb_use[1][-1]

dp = [[0] * (b_max+1) for _ in range(r_max+1)]
dp[0][0] = 1

for i in range(r_max+1):
    for j in range(b_max+1):
        tot = i+j
        if(rb_use[0][tot] >= i)&(rb_use[1][tot] >= j):
            if(i==0)&(j==0):
                continue
            elif(i==0):
                dp[i][j] = dp[i][j-1]
            elif(j==0):
                dp[i][j] = dp[i-1][j]
            else:
                dp[i][j] = (dp[i][j-1] + dp[i-1][j])%mod

print(dp[-1][-1])

Measured memory_bytes: 97248
// 三井住友信託銀行プログラミングコンテスト2019-E
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る


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

    ll n;
    cin>>n;
    ll mod=pow(10,9)+7,ans=1;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    vector<int> back;
    ll g_num=0; //グループ数
    rep(i,n){
        if(a[i]==0){
            g_num++;
            back.e_b(0);
        }else{
            ll same_back=0;
            rep(j,g_num){
                if(back[j]==a[i]-1){
                    if(same_back==0) back[j]=a[i];
                    same_back++;
                }
            }
            ans*=same_back;
            ans%=mod;
        }
    }  
    ll num=3;
    for(int i=1;i<=g_num;i++){
        ans*=num;
        ans%=mod;
        num--;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4592
#include<stdio.h>
using namespace std;

int A[100000];

int partition(int p, int r) {
  int x = A[r];
  int i = p-1;
  for (int j=p; j<r; j++) {
    if (A[j]<=x) {
      i++;
      int tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  int tmp = A[i+1];
  A[i+1] = A[r];
  A[r] = tmp;
  return i+1;
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i=0; i<n; i++) {
    scanf("%d", &A[i]);
  }
  int idx = partition(0, n-1);
  for (int i=0; i<n; i++) {
    if (i>0) {
      printf(" ");
    }
    if (i==idx) {
      printf("[");
    }
    printf("%d", A[i]);
    if (i==idx) {
      printf("]");
    }
  }
  printf("\n");
}



Measured memory_bytes: 3032
#pragma GCC optimize("Ofast")
/*#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
                      
using namespace std;
                      
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
                      
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}

#define int long long
#define ghost signed
#define left left228
#define right right228
#define prev prev228
#define list list228

const int N = 100 * 1000 + 228;

int n;
int d[N], sz[N];
map<int, int> pos; 
vector<int> g[N];

bool cmp(int i, int j) {
	return d[i] > d[j];
}

int D[N], S[N];
int sumd = 0;
bool OK = 1;

void jfs(int v, int par = -1) {
	S[v] = 1;
	for (int to : g[v]) {
		if (to == par) continue;
		jfs(to, v);
		S[v] += S[to];
	}
}

void bfs(int a) {
	for (int i = 1; i <= n; ++i) D[i] = n * 100;
	D[a] = 0;
	vector<int> q;
	q.push_back(a);
	for (int i = 0; i < (int)q.size(); ++i) {
		int v = q[i];
		for (int to : g[v]) {
			if (D[v] + 1 < D[to]) {
				D[to] = D[v] + 1;
				q.push_back(to);
			}
		}
	}
	for (int i = 1; i <= n; ++i) sumd += D[i];
	jfs(1);
}

void dfs(int v, int par = -1) {
	if (v != 1) {
		sumd -= S[v];
		sumd += (n - S[v]);
	}
	if (sumd != d[v]) OK = 0;
	for (int to : g[v]){
		if (to == par) continue;
		dfs(to, v);
	}
	if (v != 1) {
		sumd += S[v];
		sumd -= (n - S[v]);
	}
}

bool check() {
	bfs(1);
	dfs(1);
	return OK;
}

ghost main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> d[i];
		pos[d[i]] = i;
	}
	vector<int> order;
	for (int i = 1; i <= n; ++i) order.push_back(i);
	for (int i = 1; i <= n; ++i) sz[i] = 1;
	sort(order.begin(), order.end(), cmp);
	vector< pair<int, int> > e;
	int last = order.back();
	for (int v : order) {
		if (v == last) break;
		int nd = d[v] + 2 * sz[v] - n;
		if (nd <= v) {
			cout << -1 << endl;
			return 0;
		}
		int par = pos[nd];
		if (par == 0) {
			cout << -1 << endl;
			return 0;
		}
		e.push_back(make_pair(par, v));
		g[par].push_back(v);
		g[v].push_back(par);
		sz[par] += sz[v];
	}
	if (!check()) {
		cout << -1 << endl;
		return 0;
	}
	for (auto p : e) cout << p.first << " " << p.second << '\n';
	return 0;
} // kek ;





Measured memory_bytes: 22004
/*
    Code written by Talant I.D.
*/
   
#include <bits/stdc++.h>
   
using namespace std;
   
typedef long long ll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tiii;
   
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod (int)1e9+7
#define eps (double)1e-9
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);
#define curMod 998244353

int main(){
		do_not_disturb
		int a, b;
		cin >> b >> a;
		for(int i = a-b+1; i <= a+b-1; i++){
			cout << i << ' ';
		}
		
    return 0;
} // What is to be written here?


Measured memory_bytes: 256
target_word = input()

BREAK_CLAUSE = "END_OF_TEXT"
total_occurrences = 0

while True:
    text = input()
    
    if text == BREAK_CLAUSE:
        print(total_occurrences)
        break 
    
    text = text.split(" ")
    cleaned_text = [word.lower() for word in text]
    
    total_occurrences += cleaned_text.count(target_word)



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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

void solve() {
  string s;
  cin >> s;
  s[3] = '8';
  cout << s << endl;
}

signed main() {
  solve();

  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int a, b, h;
        a = in.nextInt();
        b = in.nextInt();
        h = in.nextInt();
        System.out.println( ((a+b)*h)/2 );
    }
}

Measured memory_bytes: 21972
#pragma GCC optimize("-O3")
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
void solve();
signed main(){
#ifdef Sprinkle
   clock_t clock_start=clock();assert(freopen("test.txt","r",stdin));
#else
   ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#endif
   solve();
#ifdef Sprinkle
   cerr<<"Running Time: "<<((clock()-clock_start) *1.0 / CLOCKS_PER_SEC)<<"s\n";
#endif
}
#ifdef Sprinkle
void err(){cerr<<"\n";}template<typename T,typename...U>void err(const T&hd,const U&...tl){cerr<<hd<<(sizeof...(tl)?", ":"");err(tl...);}
#define debug(x...) cerr<<""#x" = ";err(x)
#else
#define debug(...) 0
#endif
void solve(){
    string s;
    int n;
    cin>>n;
    cin>>s;
    int ans = 1;
    for(int i=1;i<s.size();++i){
        if(s[i]!=s[i-1])ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
def main():
    mod = 10 ** 9 + 7
    X, Y = map(int, input().split(" "))
    if (2 * X - Y) % 3 == 0 and (2 * Y - X) % 3 == 0:
        s = (2 * X - Y) // 3
        t = (2 * Y - X) // 3
        if s < 0 or t < 0:
            print(0)
        else:
            s = s + t
            numerator = 1
            denominator = 1
            for i in range(s - t + 1, s + 1):
                numerator = (numerator * i) % mod
            for i in range(1, t + 1):
                denominator = (denominator * i) % mod
            print(numerator * pow(denominator, mod - 2, mod) % mod)
            # math.factorialはTLEになりそう?
    else:
        print(0)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
n = int(input())
H = list(map(int, input().split()))

if n == 1:
  print("Yes")
  exit()

for i in range(n-1,0,-1):
  if H[i-1]-H[i] > 1:
    print("No")
    exit()
  elif H[i-1] - H[i] == 1:
    H[i-1] -= 1
  else:
    continue
else:
  print("Yes")

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


int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  vector<int> q(n);
  rep(i,n) {
    cin >> p[i];
    q[i] = p[i];
  }
  sort(q.begin(),q.end());
  int count = 0;
  rep(i,n){
    if(p[i]!=q[i]) ++count;
  }
  if(count <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
typedef vector<int> VI;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)



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

	REP(i, k / 2) {
		if (a % 2 == 1) {
			a--;
		}
		b += a / 2;
		a = a / 2;

		if (b % 2 == 1) {
			b--;
		}
		a += b / 2;
		b = b / 2;
	}

	if (k % 2 == 1) {
		if (a % 2 == 1) {
			a--;
		}
		b += a / 2;
		a = a / 2;
	}

	cout << a << " " << b << endl;

	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

long long int fact[100001] = {};
long long int revfact[100001] = {};

long long int getcomb(int n, int r)
{
	return (fact[n] * ((revfact[r] * revfact[n - r]) % mod)) % mod;
}

long long int getpow(long long int n, int k)
{
	if(k == 0) return 1;
	long long int tmp = getpow(n, k / 2);
	if(k % 2 == 0) return (tmp * tmp) % mod;
	else return (((tmp * tmp) % mod) * n) % mod;
}

int main()
{
	int n, k;
	cin >> n >> k;
	long long int a[100010];
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	fact[0] = 1;
	revfact[0] = 1;
	for(int i = 1; i <= n; i++){
		fact[i] = (fact[i - 1] * i) % mod;
		revfact[i] = getpow(fact[i], mod - 2);
	}
	long long int ans = 0;
	for(int i = k; i <= n; i++){
		ans += ((a[i] % mod) * getcomb(i - 1, k - 1)) % mod;
		ans %= mod;
	}
	for(int i = 1; i <= n - k + 1; i++){
		ans -= ((a[i] % mod) * getcomb(n - i, k - 1)) % mod;
		ans += mod;
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
/*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1141&lang=jp*/

#include <iostream>

#define N (int)1e6

using namespace std;

int main()
{
	int a,d,n;
	bool not_p[N];
	
	not_p[0]=true;
	for(int i=1;i<N;i++){
		if(!not_p[i]){
			for(int j=2;j*(i+1)-1<N;j++){
				not_p[j*(i+1)-1]=true;
			}
		}
	}
	while(cin>>a>>d>>n && (0<a || 0<d || 0<n)){
		int i=0;
		int j=0;

		while(j<n && a+d*i<N){
			if(!not_p[a+d*i-1]){
				j++;
			}
			i++;
		}
		cout<<a+d*(i-1)<<endl;
	}
	return 0;
}

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

#undef DEBUG

#ifdef DEBUG
struct testdata{
    int N;
    int d[50];
    int a;
} td[] = {
    {3, {3, 1, 2}, 11},
    {7, {5, 0, 7, 8, 3, 3, 2}, 312},
};
#endif

void
solver(int n, int *d)
{
    int i, j;
    int a = 0;

    for (i=0; i<n-1; i++) {
        for (j=i+1; j<n; j++) {
            a += d[i]*d[j];
        }
    }
    printf("%d\n", a);
}

int
main(int argc, char *argv[])
{
    int i;
    int N;
    int d[100];
#ifdef DEBUG
    for (i=0; i<2; i++) {
        solver(td[i].N, td[i].d);
        printf("ans: %d\n", td[i].a);
    }
#else
    scanf("%d", &N);
    for (i=0; i<N; i++)
        scanf("%d", d+i);
    solver(N, d);
#endif

    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        char a = sc.next().charAt(0);
        char b = sc.next().charAt(0);
        char TopCoDeer = b;
        
       //a == 'H'の時は TopCoDeer = bとなるため、判定はa == 'D'のみでよい。
        if(a == 'D'){
            if(b == 'H'){
                TopCoDeer = 'D';
            }else{
                TopCoDeer = 'H';
            }
        }
        System.out.print(TopCoDeer);
    }
}


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

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  
  vector<int> ans(n, 0);
  for(int i = 0; i < n - 1; i++){
    for(int j = i + 1; j < n; j++){
      int k = min(j - i, abs(x - i - 1) + 1 + abs(y - j - 1));
      ans.at(k)++;
    }
  }
  
  for(int i = 1; i < n; i++) cout << ans.at(i) << endl;
}

Measured memory_bytes: 256
/* 実行時間1s制限の場合10^6 1,000,000 : 余裕をもって間に合う10^7
  10,000,000 : おそらく間に合う10^8 100,000,000 : 非常にシンプルな処理
  でないと厳しい
 */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // Greatest Common Divisor ユークリッドの互除法（aが長辺）
vector<pair<ll,int>> factorize(ll n) {            // a,bの公約数 = GCD(a, b)の約数
    vector<pair<ll,int>> res;
    for (ll i = 2; i*i <= n; i++) { // √nまで探せばよい
        if (n%i) continue;
        res.emplace_back(i, 0);     // 割り切れたら
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1); // この時点で1でなかったら、残りは素数.
    return res;
}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}         // Least Commont Multiple オーバーフローしないように先に割る
ll ceil(ll a, ll b) {return (a+b-1)/b;}

const ll INF = LONG_MAX;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(int argc, char* argv[])
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    // std::ifstream in(argv[1]);
    //std::cin.rdbuf(in.rdbuf());
    //std::ifstream in(string(argv[0]) + ".txt");
    std::ifstream in("in.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int r, g;
    cin >> r >> g;

    cout << 2*g - r;



    return 0;
}

/*
  - 1e9 : 10^9
  - container一般
    - 合計
      accumulate(a.begin(), a.end(), 0LL)  0LLはオーバーフロー用
  - vector
    vector<int> A(N, 0); // 0で初期化(省略可)
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
    - sort(struct)
        struct st_t {
            string name;
            int p;
            bool operator<(const st_t& another) const {
                if (name == another.name)
                {
                    return p > another.p;
                }
                return name < another.name;
            }
        };
        vector<st_t> st(n);
        sort(st.begin(), st.end());
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
    - pair<pair<string,int>,int> p[110];
      std::sort(p,p+a);
        こうすると、first.first -> first.second -> secondの順にソートされる
    - sort
      - sort(a.begin(), cb.end(), greater<pair<int, int>>());
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - priority_queue<int> q;
    - q.top()に最大値が入っている
  - string
    - loop
      for (char& c : s) {}
 */



Measured memory_bytes: 256
n,m=map(int,input('').split(' '))
a=input('').split(' ')
s=0
for b in range(n):
    a[b]=int(a[b])
    s=s+a[b]

ko=0
if s%(4*m)==0:
    ok=int(s/(4*m))
else:
    ok=int((s/(4*m)))+1

for b in range(n):
    if a[b]>=ok:
        ko=ko+1

if ko>=m:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w, h;
		int count = 0;

		while(true){
			w = sc.nextInt();
			h = sc.nextInt();
			if(w==0 && h==0) break;
			int[][] c = new int[h][w];

			for(int i=0; i<h; i++){
				for(int j=0; j<w; j++){
					c[i][j] = sc.nextInt();
				}
			}

			for(int i=0; i<h; i++){
				for(int j=0; j<w; j++){
					if(c[i][j]==1){
						search(c, i, j, w, h);
						count++;
					}
				}
			}

			System.out.println(count);

			count = 0;
		}
	}

	static void search(int[][] c, int i, int j, int w, int h){
		c[i][j] = 0;

		if(i>0){
			if(j>0){
				if(c[i-1][j-1]==1) search(c, i-1, j-1, w, h);
			}
			if(c[i-1][j]==1) search(c, i-1, j, w, h);
			if(j<w-1){
				if(c[i-1][j+1]==1) search(c, i-1, j+1, w, h);
			}
		}

		if(j>0){
			if(c[i][j-1]==1) search(c, i, j-1, w, h);
		}
		if(j<w-1){
			if(c[i][j+1]==1) search(c, i, j+1, w, h);
		}

		if(i<h-1){
			if(j>0){
				if(c[i+1][j-1]==1) search(c, i+1, j-1, w, h);
			}
			if(c[i+1][j]==1) search(c, i+1, j, w, h);
			if(j<w-1){
				if(c[i+1][j+1]==1) search(c, i+1, j+1, w, h);
			}
		}
	}
}

Measured memory_bytes: 45988
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto fi = new int[](45);
  fi[0] = fi[1] = 1;

  foreach (i; 2..n+1)
    fi[i] = fi[i-1] + fi[i-2];

  writeln(fi[n]);
}

Measured memory_bytes: 2456
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-7
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int32_t main() {
    fastio
    ull x;
    cin>>x;
    ull init = 100;
    int ans = 0;
    while(init<x) {
        init = init+init/100;
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <deque>
using namespace std;
int main()
{
    deque <char> d,p;
    string s,t;
    cin>>s>>t;
    int size1,size2,flag=-1;
    char x;
    size1=s.length();
    size2=t.length();
    for (int i=0;i<size1;i++){
        d.push_back(s[i]);
    }
    for (int k = 0; k < size2; k++) {
        p.push_back(t[k]);
    }
    for (int j=0;j<size1;j++){
        if (d==p) {
            flag=1;
        }
        else{
            x=d[size1-1];
            d.pop_back();
            d.push_front(x);
        }
    }
    if (flag==-1)
        cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define REP(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define INF 10000000
#define ll long long

using namespace std;

typedef pair<int, int> P;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int d[1001];
int a, b;

int main(){
	scanf("%d%d", &a, &b);

	d[0] = 0;
	rep(i, 999) d[i] = d[i-1] + i;

	int n = b - a;
	printf("%d", d[n] - b);

	return 0;
}

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

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << endl
#define ANS(a,b) int a;cin >> a;cout << b << endl
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define ipow(x,y) LL(pow(x,y))

//Debug
#define TEST cout << "OK" << endl

const double PI = M_PI;
const long long INF = int(10e9-1);
const long long MOD = int(10e9+7);

//Settings
const bool DO_BENCHMARK = false;
const int DOUBLE_ACCURACY = 15;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    void solve();
    if(DO_BENCHMARK){
        clock_t start = clock();
        solve();
        clock_t end = clock();
        const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
        cout << endl << time << "[ms]" << endl;
    }
    else{
        solve();
    }
}

void solve(){
    SGET(S);
    int a = 0;
    for(int i = 0;i < 4;i++){
        if(S[i] == '2')a++;
    }
    PRINT(a);
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,e,t,x[200000];
long long dp[200000];
int main()
{
	cin>>n>>e>>t;
	for(int i=1;i<=n;i++)cin>>x[i];
	for(long long i=1,j=0,buf=1ll<<40;i<=n;i++)
	{
		while(t<(x[i]-x[j+1])*2)
		{
			buf=min(buf,dp[j]-x[j]-x[j+1]*2);
			j++;
		}
		dp[i]=min(buf+x[i]*3ll,dp[j]+x[i]-x[j]+t);
		//for(int j=0;j<i;j++)dp[i]=min(dp[i],dp[j]+x[i]-x[j]+max(t,(x[i]-x[j+1])<<1));
	}
	cout<<dp[n]+e-x[n]<<endl;
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
ll S[20007];
int main()
{
    ll N;
    cin >> N;
    if(N<=2) cout << 0 << endl;
    else {
        ll ans  = 0;
        S[0] = 1;S[1] = 1;S[2] = 1;
        for(ll i=3;i<=N;i++)
        {
            S[i] = S[i-1]+S[i-3];
            S[i] %= MOD;
        } cout << S[N-3] << endl;
    }
}


Measured memory_bytes: 3624
# solution 3
import heapq
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
Q = []
s = []
heapq.heappush(Q, (-A[0]-B[0]-C[0], 0, 0, 0))
for n in range(K):
    q, i, j, k = heapq.heappop(Q)
    print(-q)
    if i < X-1 and [i+1, j, k] not in s:
            heapq.heappush(Q, (- A[i+1] - B[j] - C[k], i+1, j, k))
            s.append([i + 1, j, k])
    if j < Y-1 and [i, j+1, k] not in s:
            heapq.heappush(Q, (- A[i] - B[j+1] - C[k], i, j+1, k))
            s.append([i, j + 1, k])
    if k < Z-1 and [i, j, k+1] not in s:
            heapq.heappush(Q, (- A[i] - B[j] - C[k+1], i, j, k+1))
            s.append([i, j, k + 1])

Measured memory_bytes: 4592
n=int(input())
a=list(map(int,input().split()))
x=a[0]
y=sum(a[1:])
ans=abs(x-y)
for i in range(1,n-1):
  x+=a[i]
  y-=a[i]
  ans=min(ans,abs(x-y))
print(ans)

Measured memory_bytes: 24832
#include <iostream>
#include <iomanip>
#include <ios>
#include <string>
using namespace std;
int main(void){
  string s;
  cin >> s;
  
  int n = s.length();
  
  bool AC = false;
  
  for(int i=0;i<n - 1;i++){
    if(s[i] == 'A' && s[i + 1] == 'C')
      AC = true;
  }
  
  if(AC)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}


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

int main(){
	// おまじない
	cin.tie(0);
   	ios::sync_with_stdio(false);

	ll N,M,V,P;
    cin >> N >> M >> V >> P;
    ll A[N];
    for(int i=0;i < N;i++){
        cin >> A[i];
    }
    sort(A,A+N,greater<ll>());
    ll up_n;
    up_n = V-(P-1);
    if(up_n <1){
        up_n = 1;
    }
    ll border;
    border = A[P-1];
    ll ans=P-1;
    ll tmp;
    ll tmp2;
    ll up_sum;
    ll dif_sum = 0;
    ll a;
    ll ind = P-1;
    ll over_sum= A[P-1];
    for(int i=P;i<N;i++){
        if(A[i]+M < border){
            break;
        }
        if(N-i < up_n){
            tmp = up_n - (N-i);

            up_sum = tmp*M;
            if ((over_sum + up_sum) > (A[i]+M)*(i-(P-1)) ){
                break;
            }
        }
        over_sum += A[i];
        ans = i;
    }
    ans += 1;
    cout << ans << "\n";
}

Measured memory_bytes: 1024
n,m = map(int, input().split())
stud = [list(map(int, input().split())) for _ in range(n)]
goal = [list(map(int, input().split())) for _ in range(m)]
for x,y in stud:
    ansd = float("inf")
    for i in range(m):
        x2,y2 = goal[i][0],goal[i][1]
        d = abs(x-x2) + abs(y-y2)
        if d < ansd:
            ans = i+1
            ansd = d
    print(ans)

Measured memory_bytes: 3064
# coding: utf-8
while 1:
    a, op, b = input().split()
    if op == "+":
        ans = int(a) + int(b)
    elif op == "-":
        ans = int(a) - int(b)
    elif op == "*":
        ans = int(a) * int(b)
    elif op == "/":
        ans = int(a) // int(b)
    else:
        break
    print(ans)

Measured memory_bytes: 7620
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
using namespace std;
int points[1000];
int allp;
int main() {
	long long a = 0, b = 0, c[10] = { 0 }, d = 10000000000000000,e = 0;
	cin >> a;
	for (int i = 0; i < 5; i++) {
		cin >> c[i];
		d = min(d, c[i]);
	}
	if (a % d != 0) {
		b = (a / d) + 1;
	}
	else { b = a / d; }
	cout << b+4 << endl;
	return 0;
}

Measured memory_bytes: 256
scores = []
while True:
    a_score = [int(x) for x in input().split( )]
    if a_score[0] == a_score[1]  == a_score[2] == -1:
        break
    else:
        scores.append(a_score)
for s in scores:
    m,f,r = [int(x) for x in s]
    if m == -1 or f == -1:
        print('F')
    elif m + f >= 80:
        print('A')
    elif m + f >= 65:
        print('B')
    elif m + f >= 50 or r >= 50:
        print('C')
    elif m + f >= 30:
        print('D')
    else:
        print('F')



Measured memory_bytes: 5600
import java.util.*;
import java.io.*;
public class Main {
	static long mod = 1000000007;
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
		long k = Integer.parseInt(st.nextToken());
		ArrayList<Integer>[] g = new ArrayList[n];
		for(int i = 0; i < n; i++) g[i] = new ArrayList<>();
		for(int i = 0; i < n-1; i++){
			st = new StringTokenizer(br.readLine());
			int u = Integer.parseInt(st.nextToken())-1;
			int v = Integer.parseInt(st.nextToken())-1;
			g[u].add(v); g[v].add(u);
		}
		int[] count = new int[n];
		int[] count1 = new int[n];
		long[] ks = new long[n];
		boolean[] seen = new boolean[n];
		LinkedList<Integer> q = new LinkedList<>();
		seen[0] = true;
		q.add(0);
		while(!q.isEmpty()){
			int u = q.removeFirst();
			ks[u] = k - count[u];
			for(int v: g[u]){
				if(!seen[v]){
					count1[v]++;
					count1[u]++;
					count[v] = count1[u];
					seen[v] = true;
					q.add(v);
				}
			}
		}
		long res = 1;
		for(long p: ks) res = (res*p)%mod;
		System.out.println(res);
	}

}


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

int main() {
	int N, x = 0, ans = 0;
	string S;
	cin >> N >> S;

	for (int i = 0; i < N;i++) {
		if (S[i] == 'I') {
			x++;
		}
		else {
			x--;
		}

		ans = max({ x,ans });
	}


	cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Deque;
import java.util.LinkedList;
   
class Main {
    public static void main(String[] args) throws IOException {
        Deque<Integer> lnk=new LinkedList<Integer>();
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        for(int i=0;i<n;i++){
            String s=br.readLine();
                           
            if(s.equals("deleteFirst"))lnk.remove();
            else if(s.equals("deleteLast"))lnk.removeLast();
            else{ 
                if(s.startsWith("insert"))lnk.addFirst(Integer.parseInt(s.substring(7)));
            else if(s.startsWith("delete")) lnk.remove(Integer.parseInt(s.substring(7)));
            }  
        }StringBuilder stb=new StringBuilder(Integer.toString(lnk.poll()));
        for(Integer i:lnk)stb.append(" "+i);
        System.out.println(stb);}
     
    }

Measured memory_bytes: 137308
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n;
    cin >> n;
    cout << 180 * (n-2) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,c;
  cin>>n>>m>>c;
  vector<int> b(m);
  for(int i=0;i<m;i++){
   cin>>b.at(i); 
  }
  vector<vector<int>> a(n,vector<int>(m));
  for(int j=0;j<n;j++){
    for(int i=0;i<m;i++){
     cin>>a.at(j).at(i); 
    }
  }
  int ans=0;
    for(int j=0;j<n;j++){
      int cnts=0;
      for(int i=0;i<m;i++){
        cnts+=a.at(j).at(i)*b.at(i);
      }
      if(cnts+c>0)ans++;
    }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
int main(int argc, char const *argv[])
{
	int n,k;
	cin>>n>>k;
	if(k == 1)
	{
		printf("0\n");
	}
	else
	{
		printf("%d\n",n - k);
	}
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Apr  4 21:05:12 2020

@author: Kanaru Sato
"""

n,m = list(map(int, input().split()))
a = list(map(int, input().split()))
sum = 0

for i in range(len(a)):
    sum += a[i]
    
a.sort(reverse=True)

if a[m-1] < sum/(4*m):
    print("No")
else:
    print("Yes")

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

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i(0);i<n;i++) cin >> a[i];
    
    int pre = -999;
    for(int i(0);i<n;i++){
        if(pre <= a[i]-1){
            pre = a[i]-1;
        }else if(pre <= a[i]){
            pre = a[i];
        }else{
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 640
//omajinai c++ atcoder
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define itn int
typedef long long ll;
constexpr auto mod = 1000000007;
using namespace std;
int main() {
int n,m;
  cin>>n>>m;
  vector<double> a(n);
  double sum=0;
  double count=0;
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  rep(i,n){
    if(a[i]>=sum/(4*m)){
      count++;
    }
  }
  if(count>=m){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
}


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

typedef long long ll;

int dp[105][4][2];

int main(){
        string s;
        cin>>s;
        int K;
        cin>>K;
        int n=s.size();
        dp[0][0][0]=1;
        for(int i=0;i<n;i++){//iはn桁目
                for(int j=0;j<4;j++){//jは非０の数の個数
                        for(int k=0;k<2;k++){//kはそれまでの桁ですでに与えられた数以下であることが決まっている場合１、そうでない場合０

                                int nd=s[i]-'0';
                                for(int d=0;d<10;d++){
                                        int ni=i+1,nj=j,nk=k;
                                        if(d!=0)nj++;
                                        if(nj>K)continue;
                                        if(k==0){
                                                if(d>nd)continue;
                                                if(d<nd)nk=1;
                                        }
                                        dp[ni][nj][nk]+=dp[i][j][k];
                                }
                        }
                }

        }
        int ans=dp[n][K][0]+dp[n][K][1];
        cout<<ans<<endl;
        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<(n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
ll h,w,kk;
ll dp[111][10];
void bits (ll a,ll fix){
  string s="";while(a>0){s+=(char)'0'+a%2;a/=2;}
  for(int i=s.size();i<fix;i++)s+='0';
  reverse(s.begin(),s.end());cout<<s<<endl;
}


bool check(int j){
  for(int i=0;i<10;i++){
    if((j&(BITLE(i)|BITLE(i+1))) == (BITLE(i)|BITLE(i+1)))return false;
  }
  return true;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>h>>w>>kk;
  dp[0][0]=1;
  if(w==1){cout<<1<<endl;return 0;}
  for(int i=0;i<h;i++){
    for(int j=0;j<BITLE(w-1);j++){
      if(check(j)){
	//	bits(j,8);
	for(int k=0;k<w;k++){
	  if(k==0){
	    if(BITLE(k)&j){
	      dp[i+1][k+1]+=dp[i][k];
	      dp[i+1][k+1]%=MOD;
	    }else{
	      dp[i+1][k]+=dp[i][k];
	      dp[i+1][k]%=MOD;
	    }
	  }else{
	    if(BITLE(k)&j){
	      dp[i+1][k+1]+=dp[i][k];
	      dp[i+1][k+1]%=MOD;
	    }else if(BITLE(k-1)&j){
	      dp[i+1][k-1]+=dp[i][k];
	      dp[i+1][k-1]%=MOD;
	    }else{
	      dp[i+1][k]+=dp[i][k];
	      dp[i+1][k]%=MOD;
	    }
	  }
	}
      }
    }
  }
  //for(int i=0;i<w;i++)cout<<dp[h][i]<<endl;
  cout<<dp[h][kk-1]<<endl;
  return 0;
}


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

using ull = unsigned long long;
 
vector<ull> alist = {2, 325, 9375, 28178, 450775, 9780504, 1795265022};
 
// calculate (x + y) % m; overflow-safe
inline ull addmod(ull x, ull y, ull m) {
    x %= m;
    y %= m;
    return (x >= m - y? x - (m - y) : x + y);
}
 
// calculate (x * y) % m; overlow-safe
inline ull mulmod(ull x, ull y, ull m) {
    x %= m;
    y %= m;
    ull r = 0;
    while (y > 0) {
        if (y % 2 == 1)
            r = addmod(r, x, m);
        x = addmod(x, x, m);
        y /= 2;
    }
    return r;
}
 
// calculate x^y % m; overflow-safe
ull powmod(ull x, ull y, ull m) {
    x %= m;
    ull r = 1ULL;
    while (y > 0) {
        if (y % 2 == 1)
            r = mulmod(r, x, m);
        x = mulmod(x, x, m);
        y /= 2;
    }
    return r;
}
 
// true for probable prime, false for composite
inline bool miller_rabin(ull n, ull a) {
    ull d = n - 1;
    while (d % 2 == 0) {
        if (powmod(a, d, n) == n-1)
            return true;
        d /= 2;
    }
    ull tmp = powmod(a, d, n);
    return tmp == n-1 || tmp == 1;
}
 
bool is_prime(ull n) {
    if (n <= 1)
        return false;
    if (n <= 10000000000ULL) {
        for (ull i = 2; i*i <= n; i++)
            if (n % i == 0)
                return false;
        return true;
    }
    for (ull a : alist)
        if (!miller_rabin(n, a))
            return false;
    return true;
}

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

	int t,k;
	vector <int> v;

	for(int i=0;i<5;i++)
	{
		cin >> t;
		v.push_back(t);
	}

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

	int res = 1e9;
	do
	{
		int t = 0;
		for(int i=0;i<v.size();i++)
		{
			double x = (t*1.0)/10;
			x = ceil(x);
			t = (int)(10*x);
			t += v[i];
		}
		res = min(res,t);
	}while(next_permutation(v.begin(),v.end()));

	cout << res << '\n';
	
	return 0;
}


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    int n;
    cin >> n;
    vector<ll> v(n);
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        sum += v[i];
    }

    ll ans = 1e18;
    ll s = 0;
    for (int i = 0; i < n-1; i++) {
        s += v[i];
        ans = min(ans, abs(s - (sum - s)));
    }

    cout << ans << endl;

    return 0;
}

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

int t,n,k;
int main() {
	cin >> t;
	for(int i=0; i<t; ++i) {
		int s;
		int a[200000] = {0};
		int d[200000] = {0};
		cin >> n >> k;
		for(int l=0; l<n; ++l) {
			cin >> a[l];
		}
		s = a[n-1] - a[0];
		for(int l=0; l<n-1; ++l) {
			d[l] = a[l] - a[l+1];
		}
		sort(d,d+n-1);
		for(int l=0; l<k-1; ++l) {
			s += d[l];
		}
		cout << s << endl;
		s = 0;
	}
}

Measured memory_bytes: 2740
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <numeric>
#include <mutex>
#include <cmath>
#include <set>
#include <climits>

#define mod 1000000007
#define mp make_pair
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG

using namespace std;
using ll = long long;
using lli = long long int;
using pii = pair<int, int>;
 
 int main(){
	int N, count = 0, ans = 1000000000;
	cin >> N;
	vector<int> a(N);
	rep(i, N){
		cin >> a[i];
		while(a[i]%2==0){
			a[i] /= 2;
			count++;
		}
		ans = min(ans, count);
		count = 0;
	}
	cout << ans;
	return 0;
 }

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

use std::cmp::max;
fn main() {
    input!{
        n: usize,
        a: [i64;n]
    }
    let mut ans:i64 = 0;
    let mut mp = vec![];
    for i in 0..n {
        mp.push((a[i], i));
    }
    mp.sort_by_key(|k| -k.0);
    // // println!("{:?}", mp);
    // let mut vv:VecDeque<usize> = (0..n).collect();
    // // println!("{:?}", vv);

    // for i in 0..n {
    //     if mp[i].1 {
    //         ans += mp[i].0 * ((vv.pop_back().unwrap() - mp[i].1) as i64);
    //     }else{
    //         ans += mp[i].0 * ((mp[i].1 - vv.pop_front().unwrap()) as i64);
    //     }
    // }
    // println!("{}", ans);
    let mut dp:Vec<Vec<i64>> = vec![vec![0;n+1];n+1];
    for i in 0..n {
        for j in 0..n-i {
            // right
            dp[i][j+1] = max(dp[i][j+1], dp[i][j] + mp[i+j].0 * ((n-1-j) as i64 - mp[i+j].1 as i64));
            // left
            dp[i+1][j] = max(dp[i+1][j], dp[i][j] + mp[i+j].0 * (mp[i+j].1 as i64 - i as i64));
        }
    }
    for i in 0..n+1 {
        ans = max(ans, dp[i][n-i]);
    }
    println!("{}", ans);
}

Measured memory_bytes: 33564
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct node{
	int key;
	node *next, *prev;
};

node *nil;
void init()
{
	nil = (node *)malloc(sizeof(node));
	nil->next = nil;
	nil->prev = nil;
}

void insert(int key)
{
	node *x= (node *)malloc(sizeof(node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
	
} 

node* listsearch(int key)
{
	node *cur = nil->next;
	while((cur != nil)&&(cur->key != key))
	{
		cur = cur->next;
	}
	if(cur->key == key)
	{
		return cur;
	}
}

void deletenode(node *t)
{
	if(t==nil)return;
	t->next->prev = t->prev;
	t->prev->next = t->next;
	free(t);
}

void deletefirst()
{
	deletenode(nil->next);
}

void deletelast()
{
	deletenode(nil->prev);
}

void deletekey(int key)
{
	deletenode(listsearch(key));
}

void printlist()
{
	node *t = nil->next;
	while(t != nil)
	{
		if(t != nil->next)printf(" ");
		printf("%d",t->key);
		t = t->next;
	}
	printf("\n");
}

int main()
{
	int n,key;

	char com[20];
	
	scanf("%d", &n);
	
	init();
	
	for(int i=0; i<n; i++)
	{
		scanf("%s",com);
		if(strlen(com) == 6)
		{
			scanf("%d", &key);
		}
		
		if(com[0] == 'i')
		{
			insert(key);
		
		}
		else if(com[0] == 'd')
		{
			if(strlen(com) > 6)
			{
				if(com[6] == 'F')deletefirst();
			    else if(com[6] == 'L')deletelast();
			 } 
			
		   else 
		   {
		   	deletekey(key);
		   
		   }
		   
		}
	}
	
	printlist();
	
	return 0;
	
}


Measured memory_bytes: 33832