akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

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

		n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			int start = sc.nextInt();
			int goal  = sc.nextInt();

			if (start <= 5 && goal <= 5) {
				String s = "";
				int k = start;
				while (true) {
					System.out.print(s + k);
					s = " ";
					k += (k < goal) ? 1 : -1;
					if (k == goal) {
						break;
					}
				}
				System.out.println(s + k);
			} else if (6 <= start && 6 <= goal) {
				if (start < goal) {
					String s = "";
					for (int j = start; j <= goal; j++) {
						System.out.print(s + j);
						s = " ";
					}
					System.out.println();
				} else {
					String s = "";
					for (int j = start; j <= 9; j++) {
						System.out.print(s + j);
						s = " ";
					}
					System.out.print(" 5 4 3 2 1 0 1 2 3 4 5");
					for (int j = 6; j <= goal; j++) {
						System.out.print(s + j);
						s = " ";
					}
					System.out.println();
				}
			} else if (start < goal) {
				String s = "";
				for (int j = start; j <= goal; j++) {
					System.out.print(s + j);
					s = " ";
				}
				System.out.println();
			} else {
				String s = "";
				for (int j = start; j <= 9; j++) {
					System.out.print(s + j);
					s = " ";
				}
				for (int j = 5; goal <= j; j--) {
					System.out.print(s + j);
				}
				System.out.println();
			}
		}
	}
}

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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
			cin.tie(0);							     \
			cout.tie(0);
#define sz(arr) ll(arr.size())

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18 + 9;
const double PI = 4.0 * atan(1.0);

ll powmod(ll a, ll b, const ll MOD) { ll res = 1; a %= MOD; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % MOD; a = a * a % MOD; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
ll div_floor(ll a, ll b) { return a / b - (((a ^ b) < 0) and a % b); }
ll div_ceil(ll a, ll b) { return a / b + (((a ^ b) >= 0) and a % b); }
ll kCn(ll k, ll n, ll f[]) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }


int main() {
	//#ifndef ONLINE_JUDGE
	//	(void)freopen("input.txt", "r", stdin);
	//	(void)freopen("output.txt", "w", stdout);
	//#endif // !ONLINE_JUDGE
	fastio;

	
	string s;
	cin >> s;
	if (s == "ABC")
		cout << "ARC";
	else
		cout << "ABC";


	return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline void read(T &x){
	short f=1;x=0;char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<3)+(x<<1)+(ch^48);
		ch=getchar();
	}
	x*=f;
}
int main(){
	map<int,int>m;
	int n,ans=0;
	read(n);
	for(int i=1;i<=n;i++){
		int x;read(x);
		m[x]++;
	}
	for(map<int,int>::iterator ii=m.begin();ii!=m.end();ii++){
		if(ii->first < ii->second)ans+=ii->second - ii->first;
		else if(ii->first > ii->second)ans+=ii->second;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4736
/*================================================
# ~  file:A.cpp
# ~~ date:2020-03-09
# ~~~author: SoMnus_L
#        |everybody finds love,in the end|
#   人の運命か,人の希望は悲しみにつづられているね
=================================================*/

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define ll long long
const int N=1e6+10;
using namespace std;
typedef pair<int,int>PII;

int n;
int main(){
 ios::sync_with_stdio(false);
   cin>>n;
   cout<<(n-1)/2+1<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
    string s;
    cin>>s;
    string target[4] = {"dream","dreamer","erase","eraser"};

    reverse(s.begin(),s.end());
    rep(i,4)reverse(target[i].begin(),target[i].end());

    while(true){
        if(s.substr(0,5) == target[0]){
            s.erase(s.begin(),s.begin()+5);
        }
        else if(s.substr(0,7) == target[1]){
            s.erase(s.begin(),s.begin()+7);
        }
        else if(s.substr(0,5) == target[2]){
            s.erase(s.begin(),s.begin()+5);
        }
        else if(s.substr(0,6) == target[3]){
            s.erase(s.begin(),s.begin()+6);
        }
        else{
            if(s == "")cout<<"YES";
            else cout<<"NO";
            return 0;
        }
    }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6;
bool isred[maxn]={false};
int ball_num[maxn];
int main(){
	isred[1]=true;
	fill(ball_num,ball_num+maxn,1);
	int N,M,x,y;
	scanf("%d%d",&N,&M);
	while(M--){
		scanf("%d%d",&x,&y);
		ball_num[x]--;ball_num[y]++;
		if(isred[x]==true)	isred[y]=true;
		if(ball_num[x]==0)	isred[x]=false;
	}
	int sum=0;
	for(int i=1;i<=N;i++){
		//printf("%d:%d %d\n",i,ball_num[i],isred[i]);
		if(isred[i]==true)	sum++;
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C;
        C = N*A;
        if(C<B){
            System.out.println(C);
        }
        else{
            System.out.println(B);
        }

    }
}


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

int main() {
    ios::sync_with_stdio(false);
    int n, m, a[11] = {}, b[11] = {}, d[11][1003] = {};
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> a[i] >> b[i];
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= 1000; j++) {
            for (int k = 0; k <= a[i]; k++) if (k <= j) {
                if (k == a[i]) d[i][j] = max(d[i][j], d[i - 1][j - k] + i * k * 100 + b[i]);
                else d[i][j] = max(d[i][j], d[i - 1][j - k] + i * k * 100);
            }
        }
    }
    for (int i = 0; i <= 1000; i++) if (d[n][i] >= m) {
        cout << i;
        return 0;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn (int)(1e5+2)
#define i64 long long
#define INF (i64)(1<<60)
#define pii pair<i64,i64>
#define all(x) x.begin(),x.end()
#define LB(x,v) lower_bound(all(x), v) - x.begin()
#define fread() freopen("in.txt", "r", stdin);
using namespace std;

i64 cost[102][maxn] , W;
int w[maxn], v[maxn], n;

void init(int n){
    memset(cost, -1, sizeof(cost));
}

/*  i : ith item
    W : weight taken so far
*/
i64 solve(int i, i64 Capacity){

    if(Capacity < 0) return -INF;
    if(i >= n or Capacity == 0) return 0;

    if(cost[i][Capacity] != -1) return cost[i][Capacity];

    i64 take = 0, dont_take = solve(i+1, Capacity);
    if(Capacity >= w[i]) take = v[i] + solve(i+1, Capacity - w[i]);
    
    return cost[i][Capacity] = max(take, dont_take);
}

int main() {

    while(scanf("%d %lld",&n, &W)==2){
        init(n);
        
        for(int i=0;i<n;i++) scanf("%d %d",&w[i], &v[i]);

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

Measured memory_bytes: 80000
#include <bits/stdc++.h>
using namespace std;
int main() {
	while(1) {
		int t, d, l;
		cin >> t >> d >> l;
		if((t == 0)&&(d == 0)&&(l == 0)) {
			break;
		} else {
			int ans = 0, head = 0, tail = 0;
			for(int i = 1; i <= t; i++) {
				int x;
				cin >> x;

				if(l <= x) {
					if(head == 0) head = i;
					tail = i + d;
				}
				if(tail == i) {
					ans += tail - head;
					head = 0;
					tail = 0;
				}
			}
			if(head != 0) ans += t - head;

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

Measured memory_bytes: 3068
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);


int main()
{
    IOS();
    ll n,m;
    cin>>n>>m;
    if(n>m)swap(n,m);
    if(n==1&&m==1)cout<<1;
    else if(n==1)cout<<m-2;
    else cout<<(n-2)*(m-2)<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int MAX = 1000000007;

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

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

int main() {
    int n;
    cin >> n;
    long long a[n];
    if(n==1){
        cin >> a[0];
        cout << a[0] << endl;
        return 0;
    }
    cin >> a[0] >> a[1];
    long long ans=lcm(a[0], a[1]);
    for(int i=2;i<n;i++){
        cin >> a[i];
        ans = lcm(ans, a[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

M = 10**9+7 # 出力の制限
N = 2*10**6+4 # 必要なテーブルサイズ

g1 = [None] * (N+1) # 元テーブル
g2 = [None] * (N+1) #逆元テーブル
inverse = [None] * (N+1) #逆元テーブル計算用テーブル
g1[0] = g1[1] = g2[0] = g2[1] = 1
inverse[0], inverse[1] = [0, 1] 

for i in range( 2, N + 1 ):
    g1[i] = ( g1[i-1] * i ) % M 
    inverse[i] = ( -inverse[M % i] * (M//i) ) % M # ai+b==0 mod M <=> i==-b*a^(-1) <=> i^(-1)==-b^(-1)*aより
    g2[i] = (g2[i-1] * inverse[i]) % M 

def cmb(n, r, M):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return (g1[n] * g2[r] * g2[n-r]) % M

ans = 0
r1,c1,r2,c2 = map(int, input().split())
for c in range(c1, c2+1):
    ans += cmb(r2+c, r2, M) - cmb(r1-1+c, r1-1, M)
for r in range(r1, r2+1):
    ans += cmb(c2+r, c2, M) - cmb(c1-1+r, c1-1, M)
    
# for r in range(r1+1, r2+1):
#     val = cmb(r+c1, r, M)
#     ans += val * (c2-c1) * (r2-r+1)
#     ans += val
#     ans %= M
# ans += cmb(r1+c1, r1, M)
# for c in range(c1+1, c2+1):
#     val = cmb(r1+c, c, M)
#     ans += val * (r2-r1) * (c2-c+1)
#     ans += val
#     ans %= M
print(ans%M)

Measured memory_bytes: 277256
/*
 * author :Sadik Hassan
 *
*/
#include "bits/stdc++.h"
using namespace std;
#define ll            long long
#define nl            "\n"
#define pb            push_back
#define fi            first
#define se            second
#define PI            (acos(-1.0))
#define repp(i,a,n)   for(int i=a;i<n;i++)
#define rep(i,n)      for(int i=0;i<n;i++)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
#define w(t)          int t;cin>>t;while(t--)
#define TSFL(s)       transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSFH(s)       transform(s.begin(),s.end(),s.begin(),::tolower);
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
typedef vector<int> vi;
typedef vector<ll> vii;
typedef set<int> si;
typedef set<ll> sii;
/*---------------------------------------------------------------------*/

const int N = 2e5+10;
const int INF = (int)1e9+5;

int main()
{
    _SAD()
    ll x;
    cin>>x;
    for(ll i=-1000;i<=1000;i++)
    {
        for(ll j=-1000;j<=1000;j++)
        {
            if(pow(i,5)-pow(j,5)==x)
            {
                cout<<i<<" "<<j<<nl;return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3996
#include<bits/stdc++.h>
#include<string>
using namespace std;
int pal(string s){
string m=s;
reverse(m.begin(),m.end());
return (m==s)?1:0;
}
int main(){
int a,b,c,d,t,e,n,i,j,l;
string s;
cin>>s;
l=s.size();
if(pal(s)){
    string x,y;
    a=(l-1)/2;
    x=s.substr(0,a);
    b=(l+3)/2-1;
    y=s.substr(b,a);
    if(pal(x) && pal(y))cout<<"Yes\n";
    else cout<<"No\n";
}
else cout<<"No\n";


}




Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>
#include<string.h>

int main(void){

    int i,len;
    char str[1201] ;


    fgets(str,1201,stdin);
    len =strlen(str);

    for(i = 0; i < len; i++){
        if(!isupper(str[i])){
            str[i] = toupper(str[i]);
        }else{
            str[i] = tolower(str[i]);
        }
    }

    fputs(str,stdout);
    
    return 0;
    }

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

int main(){
        long n, q;
        scanf("%ld %ld", &n, &q);
        vector<vector<long>> link(n);
        for(long i=0; i<n-1; i++){
                long a, b;
                scanf("%ld %ld", &a, &b);
                link[a-1].push_back(b-1);
                link[b-1].push_back(a-1);
        }

        vector<long> weight(n);
        for(long w: weight) w=0;
        vector<bool> used(n);
        for(bool u: used) u=false;

        for(int i=0; i<q; i++){
                long p, x;
                scanf("%ld %ld", &p, &x);
                weight[p-1] += x;
        }

        queue<long> que;
        que.push(0);
        while(!que.empty()){
                long m = que.front();
                que.pop();

                used[m] = true;
                for(long v:link[m]){
                        if(!used[v]){
                                weight[v] += weight[m];
                                que.push(v);
                        }
                }
        }


        for(long i=0; i<n; i++) printf("%ld\n", weight[i]);

        return 0;
}

Measured memory_bytes: 17904
import collections
N=int(input())
a=list(map(int, input().split()))
a.sort(reverse=True)
piv1=a[len(a)-1]    #最小
piv2=a[0]            #最大
#print(a)
max=0
c=collections.Counter(a)
value=list(c.values())
key=list(c.keys())
for i in range(piv1,piv2+1):
    #print(c[i],c[i+1],c[i+2])
    if max<c[i]+c[i+1]+c[i+2]:
        max=c[i]+c[i+1]+c[i+2]
print(max)

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;
    
    string all = "";
    REP(i, 2*N) {
        if (i%2 == 0) {
            all += S[i/2];
        } else {
            all += T[i/2];
        }
    }
    cout << all << endl;
}

signed main() {
    solve();
}


Measured memory_bytes: 256
#素因数分解
def soinsu_bunkai(m):
    pf={}

    for i in range(2,int(m**0.5)+1):
        while m%i==0:
            pf[i]=pf.get(i,0)+1
            m//=i
    if m>1:
        pf[m]=1
    return pf

# 組み合わせの総数 p=10**9+7 で割ったあまりを求める Satoooh Blog 2020/02/27 4分 
"""n<10**7 , p は素数"""
def cmb(n, r, p):

    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p



# 初期入力
from collections import Counter
import sys
input = sys.stdin.readline  #文字列では使わない
mod =10**9 +7
p =mod
N,M = map(int, input().split())
a =soinsu_bunkai(M)
ans =1

n = 10 ** 6  # n は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

#mod p における n の逆元の計算
for i in range(2, n + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

for i in a.values():
    x =cmb(N +i -1,i,mod)
    ans *=x
print(ans %mod)

Measured memory_bytes: 128212
#include<cstdio>
#define N 100005
#define ll long long
inline void chk(ll &x,ll y){if(y<x)x=y;}
int n,W,w[105],v[105];
ll dp[105][N];
int main(){
	scanf("%d%d",&n,&W);
	for(int i=0;i<n;++i)scanf("%d%d",&w[i],&v[i]);
	for(int i=0;i<=n;++i)for(int j=0;j<N;++j)dp[i][j]=1e18;
	dp[0][0]=0;
	for(int i=0;i<n;++i)for(int j=0;j<N;++j){
		if(j+v[i]<N)chk(dp[i+1][j+v[i]],dp[i][j]+w[i]);
		chk(dp[i+1][j],dp[i][j]);
	}
	int ans=0;
	for(int j=0;j<N;++j)if(dp[n][j]<=W)ans=j;
	printf("%d\n",ans);
	return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    char x, y;
    cin >> x >> y;
    if (x < y) cout << "<" << endl;
    else if (x > y) cout << ">" << endl;
    else cout << "=" << endl;
    return 0;
}

Measured memory_bytes: 256
// Mon Aug 24 16:24:09 IST 2020        
#include <bits/stdc++.h>        
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(ii,a,b)       for(int ii = (int)a ; ii < (int)b  ; ii++ )
#define scan(any)          for(auto &i:any) cin>>i;
#define debug(x)           cerr << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define int64              long long   
#define all(x)             (x).begin(),(x).end() 
#define ff                 first
#define ss                 second
#define pppp               pair <int,int> 
#define flushOff           fflush(stdout) 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
using namespace std ;    
// policy based   
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
 
const int MOD1 = 1e9+7;
const int MOD2 = 1e9+9;
const double pi = 3.141592653589793238;
const int INF = 2e9+7; 
// const int N = 2e5+7;
struct compare{
    bool operator()(pair <int,int> A, pair <int,int> B){
        if(A.first == B.first)
            return A.second > B.second;
        return A.first > B.first;
    }
}; 
void print(vector <int>v){
    for(int t : v){
        cout << t << ' ';
    }
    cout << '\n';
}
int tests(){  
    int N,M,X;
    cin >> N >> M >> X;
    vector <vector <int>> vec(N, vector <int> (M));
    vector <int> cost(N);
    forn(i,0,N)
        {
            cin >> cost[i];
            for(auto &t : vec[i])
                cin >> t;
        } 
    int ans  = INF;
    forn(i,0,(1<<N)){
        vector <int> level(M);
        int price = 0;
        forn(j,0,N)
            if(i&(1<<j)){
                price += cost[j];
                forn(k,0,M)
                    level[k] += vec[j][k];
            }
        bool ok = true;
        forn(k,0,M)
            ok &= level[k] >= X;
        if(ok)
            ans = min(ans,price);
    }
    if(ans == INF)
        ans = -1;
    cout << ans << '\n';
    return 0;
}    
int main(){
    I__O ;      
    int cases = 1 ;  
    // cin >> cases ;
    while(cases--)
        tests(); 
    return 0 ; 
}
 

Measured memory_bytes: 3656
N,K=map(int,input().split())
h=list(map(int,input().split()))

cost=[-1 for _ in range(N)]


for i in range(N):
    if i==0:
        cost[i]=0
    else:
        siten=max(i-K,0)
        min_cost=10**12
        for j in range(siten,i):
            m=cost[j]+abs(h[j]-h[i])
            if m<min_cost:
                min_cost=m
        cost[i]=min_cost

print(int(cost[N-1]))

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

int main(){
  int n;
  cin >> n;
  
  if(n == 1){
    cout << 1 << endl;
  }
  if(n == 2 || n == 3){
    cout << 2 << endl;
  }
  if(n >= 4 && n <= 7){
    cout << 4 << endl;
  }
  if(n >= 8 && n <= 15){
    cout << 8 << endl;
  }
  if(n >= 16 && n <= 31){
    cout << 16 << endl;
  }
  if(n >= 32 && n <= 63){
    cout << 32 << endl;
  }
  if(n >= 64){
    cout << 64 << endl;
  }
}

Measured memory_bytes: 3608
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int a, b, d, r;
	cin >> a >> b;
	d = a / b;
	r = a % b;
	double f = (double)a / b;
	printf("%d %d %.9f\n", d, r, f);
	return 0;
}



Measured memory_bytes: 3224
class cumulative_sum:
    def __init__(self,A):
        N = len(A)
        self.S = [0]*(N+1)
        for i in range(N):
            self.S[i+1] = self.S[i] + A[i]
    def get(self,i,j=None):
        if j==None:j=len(self.S)-1
        if j<=i:return 0
        return self.S[j]-self.S[i]

N,M,V,P = map(int,input().split())
*A, = map(int,input().split())
A.sort()

S = cumulative_sum(A)

def check(i):
    s = max(0,S.get(i+1,N-P+1))
    res = max(M*(V-P-i),0)
    if A[i]+M<A[N-P]: return False
    return ((A[i]+M)*max(0,N-P-i))>=s+res

ans = sum(check(i) for i in range(N))
print(ans)

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

int main(){
  double W, H, x, y;
  cin >> W >> H >> x >> y;
  int malt = 0;
  if (W==2*x && H==2*y) malt = 1;
  double area = (W * H) / 2;
  cout << area << " "<< malt << endl;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	long double n, k;
	cin >> n >> k;
	long double ans = 0;
	for (int i = 1; i <= n; i++){
		if (i >= k){
			ans += 1.0 / n;
			continue;
		}
		ans += (1.0 / n) * (1.0 / (long double)(1 << (int)(ceil(log2(ceil((k) / (double)(i)))))));
		//if (i <= 10){
			// cout << i << ' ' << ans << '\n';
		// }
	}
	// cout << (1.0 / n) * (1.0 / (long double)(1 << (int)(ceil(log2(ceil((k + 1) / (double)(5))))))) << endl;
	cout << setprecision(20) << ans;
}

Measured memory_bytes: 512
toInt :: String -> Int
toInt = read :: String -> Int

existsCraneAndTurtleCombination :: Int -> Int -> Bool
existsCraneAndTurtleCombination x y = length [(a, b) | a <- [0..x], b <- [0..x], a + b == x, 2*a + 4*b == y] > 0

main = do
  [x, y] <- map toInt . words <$> getLine
  putStrLn $ if existsCraneAndTurtleCombination x y then "Yes" else "No"


Measured memory_bytes: 3736
#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; }
const ll IMF = 1LL << 60;
int main() {
  int N, K;
  cin >> N;
  
  ll a[N][3];

  for(int i = 0; i < N; i++) {
    for(int j = 0; j < 3; j++) {
      cin >> a[i][j];
    }
  }
  ll dp[N][3] = {0};
  for(int i = 0; i < 3; i++) {
    dp[0][i] = a[0][i];
  }
  for(int i = 0; i < N - 1; i++) {
    for(int j = 0; j < 3; j++) {
      for(int k = 0; k < 3; k++) {
        if(j == k) continue;
        else
        chmax(dp[i + 1][k], dp[i][j] + a[i + 1][k]);
      }
    }
  }
  cout << max({dp[N - 1][0], dp[N - 1][1], dp[N - 1][2]});

  return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define LINEMAX 100002

int main(int argc, char *argv[]){

	char line[LINEMAX];

	fgets(line, sizeof(line), stdin);

	char *fromHead = line;
	char *fromTail = &line[strlen(line)-2];
	int   sunukeCnt = 0;

	//printf("fromHead is %c\n", *fromHead);
	//printf("fromTail is %c\n", *fromTail);

	while(1){

		if(fromTail == fromHead || (fromTail+1) == fromHead){
			break;
		}

		if(*fromHead == *fromTail){
			fromHead++;
			fromTail--;
			continue;
		}

		if(*fromHead == 'x'){
			sunukeCnt++;
			fromHead++;
			continue;
		}

		if(*fromTail == 'x'){
			sunukeCnt++;
			fromTail--;
			continue;
		}

		sunukeCnt = -1;
		break;
	}

	printf("%d\n", sunukeCnt);
	return 0;
}

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

int nxt[20][100000], rev[20][100000];

void construct(vector<int> &v, int l, int c[20][100000]){
    int n = v.size();
    for(int i = 0; i+1 < n; i++){
        c[0][i] = upper_bound(v.begin(),v.end(),v[i]+l)-v.begin()-1;
    }
    c[0][n-1] = -1;
    for(int k = 0; k+1 < 20; k++){
        for(int i = 0; i < n; i++){
            if(c[k][i] < 0)  c[k+1][i] = -1;
            else             c[k+1][i] = c[k][c[k][i]];
        }
    }
}

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    for(int i = 0; i < n; i++)  cin >> x[i];
    vector<int> y(n);
    for(int i = 0; i < n; i++)  y[i] = 1e9-x[n-1-i];
    int l;
    cin >> l;
    construct(x, l, nxt);
    construct(y, l, rev);
    auto f = [&](int a, int b, int c[20][100000])->int{
        int ret = 0, tmp = a;
        for(int k = 19; k >= 0; k--){
            int to = c[k][tmp];
            if(to >= 0 && to < b){
                tmp = to;
                ret += 1<<k;
            }
        }
        return ret+1;
    };
    int q;
    cin >> q;
    while(q--){
        int a, b;
        cin >> a >> b;
        a--, b--;
        if(a > b)   swap(a,b);
        cout << f(a, b, nxt) << endl;
    }
    return 0;
}

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

const int inf = (1<<29);
int n,m,r;
int ar[10]={};
bool vis[10]={};
int dist[210][210]={};
int a,b,c,res;
void dfs(int idx,int pa,int sum){
	if (idx==r+1){
		res=min(res,sum);
		return;
	}
	for (int i=1;i<=r;i++){
		if (vis[i])
			continue;
		vis[i]=true;
		dfs(idx+1,i,sum+dist[ar[i]][ar[pa]]);
		vis[i]=false;
	}
}
int main() {
	
	scanf("%d%d%d",&n,&m,&r);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			if (i!=j)
				dist[i][j]=inf;
	for (int i=1;i<=r;i++)
		scanf("%d",&ar[i]);
	for (int i=1;i<=m;i++){
		scanf("%d%d%d",&a,&b,&c);
		if (c<dist[a][b])
			dist[a][b]=dist[b][a]=c;
	}
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			for (int k=1;k<=n;k++)
				if (dist[i][j]+dist[i][k]<dist[j][k])
					dist[j][k]=dist[i][j]+dist[i][k];
	res=inf;
	dfs(1,0,0);
	printf("%d",res);
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main()
{
	double ax,ay,bx,by,cx,cy,dx,dy;
	while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&ax,&ay,&bx,&by,&cx,&cy,&dx,&dy)==8)
		printf("%s\n",(bx-ax)*(dx-cx)+(by-ay)*(dy-cy)==0?"YES":"NO");
	return 0;
}

Measured memory_bytes: 612
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
ll h,a;
//ld ;
// string s,t;
// char c;

int main() {
  cin >> h >> a;
  cout << ceil((double)h/(double)a) << endl;
}

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

using namespace std;
typedef long long ll;

int main(){
    ll n,a,b,c,d,e;
    cin>>n>>a>>b>>c>>d>>e;

    ll mini = min({a,b,c,d,e});
    if(n%mini==0)
        cout<<n/mini+4;
    else
        cout<<n/mini+5;
}


Measured memory_bytes: 256
n,k = map(int,input().split())

a = []
d = []
for i in range(k):
  d.append(input())
  a+=(map(int,input().split()))
set_a = set(a)
count = 0
for i in range(1,n+1):
  if i in set_a:
    continue
  else:
    count+=1
print(count)

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

using namespace std;
using ll = long long;


int a[55];
ll mem[55][5555];
int n;

ll dp(int i , int sum){
    if(i == n){
        if(sum == 0)return 1;
        return 0;
    }

    ll &ret = mem[i][sum+2500];
    if(ret != -1)return ret;

    return ret = dp(i + 1 , sum + a[i]) + dp(i + 1 , sum);
}

main(){
    int A;
    scanf("%d %d" , &n , &A);

    for(int i = 0 ; i < n ; i ++){
        scanf("%d" , &a[i]);
        a[i] -= A;
    }

    memset(mem , -1 , sizeof mem);
    printf("%lld\n" , dp(0 , 0) - 1);

    return 0;
}


Measured memory_bytes: 2688
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<unordered_map>
#define int long long
const int inf=1145141919810893;
const int mod=1000000007;
using namespace std;
template<class T>bool chmin(T &a,const T &b){
	if(a>b){
		a=b;
		return true;
	}
	return false;
}
template<class T>void debug(T *a,int l,int r,const char *name){
	for(int i=l;i<r;i++)
		cout<<name<<"["<<i<<"]="<<a[i]<<endl;
}
int p[500];
signed main(){
	int i,j;
	string s;
	cin>>s;
	if(s.size()==1){
		cout<<"YES"<<endl;
		return 0;
	}
	if(s.size()==2){
		if(s[0]!=s[1])
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
		return 0;
	}
	int p[3]={};
	for(auto c:s)
		p[c-'a']++;
	sort(p,p+3);
	p[2]-=p[0];
	p[1]-=p[0];
	if(p[2]<=1&&p[1]<=1)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 512
function Main(input){
    input = input.split(" ");
    tmp = parseInt(input[0]) + parseInt(input[1]) + parseInt(input[2]);
    if(tmp > 21){
     console.log("bust");   
    }else{
     console.log("win");
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

class GoHome
{
private:
	int x;
public:
	GoHome(){
		cin >> x;
	}

	void exec(){
		int ans = 1;
		int sum = 0;
		while(sum < x){
			sum += ans;
			ans++;
		}
		cout << ans - 1 << endl;
	}

};

int main(){
	GoHome gh = GoHome();
	gh.exec();

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define vul vector<ull>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi2d vector<vi >
#define vl2d vector<vl >
#define vpll vector<pll >

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rz resize
#define fr(i,n) for(i=0;i<(n);i++)
#define frr(i,n) for(i=(n-1);i>=0;i--)
#define fre(i,n) for(i=0;i<=(n);i++)
#define frre(i,n) for (i=(n);i>=0;i--)
#define frab(i,a,b) for(i=(a);i<(b);i++)
#define freab(i,a,b) for(i=(a);i<=(b);i++)
#define frrab(i,a,b) for(i=(b-1);i>=a;i--)
#define frreab(i,b,a) for(i=(b);i>=a;i--)

#define sz(a) int((a).size())
#define mset(a,b) (memset(a,b,sizeof(a)))
#define max3(a,b,c) (max((a),max((b),(c))))
#define min3(a,b,c) (min((c),min((a),(b))))
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
vector <ll> sprime;
vector<char> prime (1000000, true);
void sieve(ll n)
{
  //O(nloglogn) time
  sprime.pb(0);
  prime[0] = prime[1] = false;
  ll cnt = 0;
  for (ll i = 2; i <= n; ++i)
  {
    if (prime[i])
    {
      cnt++;
      sprime.pb(i);
      for (ll j = 2 * i; j <= n; j += i)
        prime[j] = false;
    }
  }
}
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll fastpowMOD(ll a, ll p, ll MOD) { if (p == 0) return 1; ll z = fastpowMOD(a, p / 2, MOD); z = (z * z) % MOD; if (p % 2) z = (z * a) % MOD; return z; }
ll fastpow(ll a, ll p) { if (p == 0) return 1; ll z = fastpow(a, p / 2); z = (z * z); if (p % 2) z = (z * a); return z; }

#define mod 1000000007
#define inf LLONG_MAX
#define minf LLONG_MIN
#define pi 3.14
#define ex 2.71

//*********************************************///
const int N = 1e5 + 5;
int i,j;
ld dp[3005][3005];
ld h[3005],t[3005];
void solve()
{
  int n;
  cin>>n;
  freab(i,1,n)
  {
    cin>>h[i];
    t[i]=1-h[i];
  }
  dp[0][0]=1;
  freab(i,1,n)
  {
    //dp[i][i]=dp[i-1][i-1]*h[i];
    dp[i][0]=dp[i-1][0]*t[i];
  }
  freab(i,1,n)
  {
    freab(j,1,i)
    {
      dp[i][j]=dp[i-1][j-1]*h[i]+dp[i-1][j]*t[i];
    }
  }
  ld sum=0;
  frreab(i,n,n/2+1)
  {
    sum+=dp[n][i];
  }

  cout << fixed << setprecision(12) << sum<<endl;
}

int main()
{
  fast;
  int z;
  //cin>>z;
  z=1;
  while(z--)
  {
    solve();
  }
  return 0;
}


Measured memory_bytes: 140416
use std::io::Read;
use std::cmp::min;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let a: Vec<isize> = (0..n)
        .map(|_| iterator.next().unwrap().parse().unwrap())
        .collect();

    let mut min_cost = 1_000_000_000;
    for i in -100..101 {
        let mut cost = 0;
        for j in 0..n {
            cost += (a[j] - i).abs().pow(2);
        }
        min_cost = min(min_cost, cost);
    }

    return format!("{}", min_cost);
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;
 
 
int main(int argc, char* argv[])
{
    long n,a,b;
    scanf("%ld %ld %ld", &n, &a, &b);   

    printf("%ld\n", MIN(a*n,b) );
 
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int home[N];
  for (int i = 0; i < N; i++) {
    cin >> home[i];
  }
  
  int min = 1000000;
  
  for (int p = 1; p < 201; p++) {
    int sum = 0;
    for (int i = 0; i < N; i++) {
      sum += (home[i] - p) * (home[i] - p);
    }
    
    if (sum < min) {
      min = sum;
    }
  }
  
  cout << min << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int a[(int)1e5];

char go(int turn)
{


}


int main()
{
  int n;
  scanf("%d", &n);
  for (int i=0; i<n; i++) 
  {
    scanf("%d", &a[i]);
    if (a[i]%2 == 1) 
    {
      printf("first\n");
      return 0;
    }
  }
  printf("second\n");
  return 0;

  /*
  if(go(1))
  {
    printf("first\n");
  }else printf("second\n");
  */

  if (n ==1 )
  {
    if ( a[0]%2 == 0) printf("second\n");
    else printf("first\n");
  }
  else printf("first\n");

}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define maxn 200+1       
using namespace std;
int n,a[10002],ans;      
int main()
{
    scanf("%d",&n);
    int md=n<<1;                
    for(int i=1;i<=md;++i)
    {
        scanf("%d",&a[i]);
    }
    sort(a+1,a+1+md);           
    for(int i=1;i<=md;i+=2)
    { 
        ans+=a[i];           
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        double sum = 0;
        double tmp;
        for(int i=0;i<n;i++){
            tmp = 1.0/Integer.parseInt(sc.next());
            sum+=tmp;
        }
        System.out.println(1.0/sum);
        sc.close();
    }
}

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

 long long cimi(long long x,int n){
 	long long result=1;
 	for(int i=1;i<=n;i++)
 		result*=x;
 	return result;
 }

int main(){
	long long n;
	cin>>n;
	for(long long i=-150;i<150;i++)
		for(long long j=-150;j<150;j++){
			if(cimi(i,5)-cimi(j,5)==n){
				cout<<i<<" "<<j<<endl;
				return 0;
			}
			
		}
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iterator>

using namespace std;

bool checker[2000000];

int main(){
	int n, a, b;
	while(true){
		cin >> n >> a >> b;
		if(n == 0 && a == 0 && b == 0){
			break;
		}
		for(int i = 0; i <= n; i++){
			checker[i] = false;
		}
		checker[0] = true;
		for(int i = 1; i <= n; i++){
			if(i - a >= 0){
				if(checker[i - a]){
					checker[i] = true;
					continue;
				}
			}
			if(i - b >= 0){
				if(checker[i - b]){
					checker[i] = true;
					continue;
				}
			}
		}
		int count = 0;
		for(int i = 0; i <= n; i++){
			if(!checker[i]){
				count++;
			}
		}
		printf("%d\n", count);
	}
	return 0;
}

Measured memory_bytes: 2120
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#define pb push_back
#define mp make_pair
using namespace std;

long long a, b, c;
long long k;


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

   cin >> a >> b >> c;
   cin >> k;

   if(k == 0)
   {
       cout << a - b << endl;
       return 0;
   }

   if(k == 1)
   {
       cout << b - a << endl;
       return 0;
   }

   if(k % 2 == 0)
   {
       cout << a - b << endl;
   }
   else
   {
       cout << b - a << endl;
   }

   return 0;



   return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var b = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();
            var result = b[0] + b[n - 2];

            for (var i = 0; i < n - 2; i++)
            {
                result += Math.Min(b[i], b[i + 1]);
            }

            Console.WriteLine(result);
        }

    }
}

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

int main(){
  int n;
  cin >> n;
  double a[n];
  rep(i,n){
    cin >> a[i];
  }
  double pre;
  rep(i,n) pre += (double)1/a[i];
  double ans;
  ans = (double)1/pre;
  cout << ans << endl;
  return 0;
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  vector<int> v(n);
  REP (i, n) {
    scanf("%d", &v[i]);
  }

  int cnt = 0;
  FOR (i, 1, n) {
    if (v[i] == v[i - 1]) {
      cnt++;
      v[i] = 1000 + i;
    }
  }

  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF = 1e9;

int main() {
  // dp
  int H, N;
  cin >> H >> N;
  vector<int> dp(H+1, INF);
  dp[0] = 0;
  rep(_, N) {
    int A, B;
    cin >> A >> B;
    for (int i = 0; i < H; i++) {
      int next = min(i+A, H);
      dp[next] = min(dp[next], dp[i] + B);
    }
  }
  cout << dp[H] << '\n';
  return 0;
}

Measured memory_bytes: 3668
#include <stdio.h>

int main(void)
{
    int d;

    while (scanf("%d", &d) != EOF) {
        int sum = 0;
        int i;

        for (i = 0; i < 600; i += d) {
            sum += d * i * i;
        }

        printf("%d\n", sum);
    }

    return 0;
}

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

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

	int count = 0;
	for (int i = 0; i < n-2; ++i) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
			++count;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1<<29;
const long double pi = 3.14159265358979323846;
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; }

// ****************************************CODE***************************************//


int n;
ll h[100010];
ll dp[100010];

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

    for(int i = 0; i < 100010; i++) dp[i] = inf;

    dp[0] = 0;

    for(int i = 1; i < n; i++){
        dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if(i>1) dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }

    cout << dp[n-1] << endl;
}

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

#define INF INT_MAX/2
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;

vector<ull>two(52);

ull func(ull N,ll X){
   if(X <= 0) return 0;
   else if(X <= two[N+1]-2) return func(N-1,X-1); 
   else return func(N-1,X-two[N+1]+1)+two[N];
} 

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

   two[0] = 1;
   for(int i=1;i<=51;i++)two[i] = 2*two[i-1];

   ull N,X;
   cin>>N>>X;
   cout<<func(N,X)<<endl;
   return 0; 
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
  int n,k,sum;
  cin >> n >> k;
  for (int i = 0; i < n; i ++){
    int a;
    cin >> a;
    if (k - a > a){
      sum += a;
    }else{
      sum += k - a;
    }
  }
  cout << sum * 2 << endl;
}

Measured memory_bytes: 256
i=int(input())
a=[0, \
1	, \
9	, \
30	, \
76	, \
141	, \
267	, \
400	, \
624	, \
885	, \
1249	, \
1590	, \
2208	, \
2689	, \
3411	, \
4248	, \
5248	, \
6081	, \
7485	, \
8530	, \
10248	, \
11889	, \
13687	, \
15228	, \
17988	, \
20053	, \
22569	, \
25242	, \
28588	, \
31053	, \
35463	, \
38284	, \
42540	, \
46581	, \
50893	, \
55362	, \
61824	, \
65857	, \
71247	, \
76884	, \
84388	, \
89349	, \
97881	, \
103342	, \
111528	, \
120141	, \
128047	, \
134580	, \
146316	, \
154177	, \
164817	, \
174438	, \
185836	, \
194157	, \
207927	, \
218812	, \
233268	, \
245277	, \
257857	, \
268182	, \
288216	, \
299257	, \
313635	, \
330204	, \
347836	, \
362973	, \
383709	, \
397042	, \
416448	, \
434025	, \
456967	, \
471948	, \
499740	, \
515581	, \
536073	, \
559758	, \
583960	, \
604833	, \
633651	, \
652216	, \
683712	, \
709065	, \
734233	, \
754734	, \
793188	, \
818917	, \
846603	, \
874512	, \
909496	, \
933081	, \
977145	, \
1006126	, \
1041504	, \
1073385	, \
1106467	, \
1138536	, \
1187112	, \
1215145	, \
1255101	, \
1295142	, \
1342852	, \
1373253	, \
1422195	, \
1453816	, \
1502376	, \
1553361	, \
1595437	, \
1629570	, \
1691292	, \
1726717	, \
1782111	, \
1827492	, \
1887772	, \
1925853	, \
1986837	, \
2033674	, \
2089776	, \
2145333	, \
2197483	, \
2246640	, \
2332104	, \
2379085	, \
2434833	, \
2490534	, \
2554600	, \
2609625	, \
2693919	, \
2742052	, \
2813988	, \
2875245	, \
2952085	, \
3003306	, \
3096024	, \
3157249	, \
3224511	, \
3306240	, \
3388576	, \
3444609	, \
3533637	, \
3591322	, \
3693924	, \
3767085	, \
3842623	, \
3912324	, \
4027884	, \
4102093	, \
4181949	, \
4270422	, \
4361548	, \
4427853	, \
4548003	, \
4616104	, \
4718640	, \
4812789	, \
4918561	, \
5003286	, \
5131848	, \
5205481	, \
5299011	, \
5392008	, \
5521384	, \
5610705	, \
5739009	, \
5818390	, \
5930196	, \
6052893	, \
6156139	, \
6239472	, \
6402720	, \
6493681	, \
6623853	, \
6741078	, \
6864016	, \
6953457	, \
7094451	, \
7215016	, \
7359936	, \
7475145	, \
7593865	, \
7689630	, \
7886244	, \
7984165	, \
8130747	, \
8253888	, \
8403448	, \
8523897	, \
8684853	, \
8802826	, \
8949612	, \
9105537	, \
9267595	, \
9376656	, \
9574704	, \
9686065	, \
9827097	, \
9997134	, \
10174780	, \
10290813	, \
10493367	, \
10611772	, \
10813692]
print(a[i])

Measured memory_bytes: 9316
fun main(args: Array<String>) {
    val s = readLine()!!
    val map = mutableMapOf<Char, Int>()
    for (c in s) {
        if (map.containsKey(c)) {
            map[c] = map[c]!! + 1
        } else {
            map[c] = 1
        }
    }
    println(if (map.values.all { it == 2 }) "Yes" else "No")
}


Measured memory_bytes: 33652
#include<bits/stdc++.h>
using namespace std;
int n,k,ans;
const int N=2005;
const int mo=1e9+7;
int f[N][N],sum[N][N];
void upd(int &x,int y){
	(x+=y)>=mo?x-=mo:233;
}
int main(){
	scanf("%d%d",&n,&k);
	f[n+1][0]=1;
	for (int i=n+1;i>=0;i--)
		for (int j=n+1;j>=0;j--){
			if (i==1&&j==n-k) ans=sum[i+1][j];
			upd(f[i][j],f[i][j+1]);
			upd(f[i][j],sum[i+1][j]);
			sum[i][j]=(j?sum[i+1][j-1]:0);
			upd(sum[i][j],f[i][j]);
		}
	for (int i=1;i<=n-k-1;i++)
		ans=1ll*ans*2%mo;
	printf("%d",ans);
}

Measured memory_bytes: 31616
//-- In the name of ALLAH --
// We're nothing and you're everything.
// Ya Ali!
#include<bits/stdc++.h>
using namespace std;

#define      pai              acos(-1)
#define      ff               first
#define      ss               second
#define      ll               long long
#define      pb               push_back
#define      mp               make_pair
#define      pll              pair<ll,ll>
#define      sz(a)            (ll)a.size()
#define      endl             "\n"
#define      gcd(a, b)        __gcd(a, b)
#define      lcm(a, b)        ((a)*((b)/gcd(a,b))
#define      all(vec)         vec.begin(),vec.end()
#define      ms(a, b)         memset(a,b,sizeof(a))
#define      TEST_CASE(t)     for(int zz=1;zz<=t;zz++)
#define      PRINT_CASE       printf("Case %d: ",zz)
#define      fii              freopen("input.txt","r",stdin);
#define      foo              freopen("output.txt","w",stdout);
#define      FAST             ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

const ll M   = 1e9+7;
const ll mxn = 1e5+7;


int  main()
{
    ll i,j,k,a,b,c,d,n,m,t,x,y,z,u,v;
    cin>>n>>m;
    vector<ll>vec(n);
    for(auto &a:vec)
    {
        cin>>a;
    }
    sort(all(vec));
    ll sum=0;
    for(i=0;i<m;i++)
    {
        sum+=vec[i];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3612