akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include<bitset>
#include<stdio.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF = 100000000;

bool isOK(int a[],int index,int key){
    if(a[index] >= key){
        return true;
    }else{
        return false;
    }
}

int binary_search(int a[],int n,int key){
    int left = -1;
    int right = n;

    while(right-left>1){
        int mid = left + (right - left)/2;
        if(isOK(a,mid,key)){
            right = mid;
        }else{
            left = mid;
        }
    }
    return right;
}

int factrial(int n){
    if(n==0){
        return 1;
    }else{
        return n*factrial(n-1);
    }
}

int main(void){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    bool flag = true;

    if(abs(b-a)>d){
        flag = false;
    }
    if(abs(b-c)>d){
        flag = false;
    }
    if(abs(c-a)<=d){
        flag = true;
    }

    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
bool cmp(double a,double b)
{
    return a>b;
}
int f(double x)
{
    int h;
    h=x;
    if(h==x)return h;
    else return h+1;
}
int main()
{
    int n,i,k;
    double h[200005];
    long long result;
    while(scanf("%d%d",&n,&k)!=EOF)
    {
        for(i=0;i<n;i++)
            scanf("%lf",&h[i]);
        sort(h,h+n,cmp);
        result=0;
        for(i=k;i<n;i++)
        {
            result+=f(h[i]);
        }
        printf("%lld\n",result);
    }
}


Measured memory_bytes: 1664
#include <stdio.h>

int main(void)
{
	int N,sum,M=0;
	scanf("%d",&N);
	int a[N],b[N],i,j;
	for(i = 1 ; i <= N; i++)
	{
		scanf("%d",&a[i]);
	}
	for(i = 1; i <= N; i++) b[i] = 0;
	for(i = N; i >= 1;i--)
	{
		sum = 0;
		for(j = i; j <= N; j=j+i)
		{
			sum = sum + b[j];
		}
		if((sum%2==0&&a[i]==1)||(sum%2==1&&a[i]==0))
		{
			M++;
			b[i] = 1;
		}
	}
	printf("%d\n",M);
	for(i = 1; i <= N; i++)
	{
		if(b[i] == 1)
		{
			printf("%d ",i);
		}
	}
	return 0;
}



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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int n, k;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i, n) { cin >> h[i]; }

  sort(h.begin(), h.end());
  ll ans = 1000000005; 
  rep(i, n-k+1) {
    ans = min(ans, h[i+k-1] - h[i]);
  }
  cout << ans << endl;
  return 0;
}


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

ll N, M;
vector<ll> E[100000];
ll dp[100000], ans[100000];

void dfs(ll v, ll p) {
  dp[v] = 1;
  for (ll u : E[v]) if (u != p) {
    dfs(u, v);
    dp[v] = (dp[v] * (dp[u] + 1) % M) % M;
  }
}

void dfs2(ll v, ll p, ll x) {
  ans[v] = (dp[v] * x) % M;

  vector<ll> l, r;
  l.push_back(1);
  for (ll u : E[v]) {
    ll w = u != p ? dp[u] + 1 : 1;
    l.push_back(w);
    r.push_back(w);
  }
  r.push_back(1);
  REP(i, 1, l.size()) l[i] = (l[i] * l[i - 1]) % M;
  for (ll i = (ll) r.size() - 2; i >= 0; i--) r[i] = (r[i] * r[i + 1]) % M;

  REP(i, 0, E[v].size()) if (E[v][i] != p) {
    dfs2(E[v][i], v, (x * (l[i] * r[i + 1] % M) % M + 1) % M);
  }
}

int main(void) {
  cin >> N >> M;
  REP(i, 0, N - 1) {
    ll x, y; cin >> x >> y; x--; y--;
    E[x].push_back(y);
    E[y].push_back(x);
  }

  dfs(0, -1);
  dfs2(0, -1, 1);

  REP(i, 0, N) cout << ans[i] << endl;
}

Measured memory_bytes: 26496
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
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; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
#define pll pair<ll,ll>
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n+1);
    rep(i,0,n)cin>>a[i];
    if(k>=4*log2(n))rep(i,0,n)cout<<n<<" ";
    else{
        rep(j,1,k+1){
            vector<ll> b(n+5,0);
            rep(i,0,n){
                ll l=max((ll)0,i-a[i]);
                ll r=min(n-1,i+a[i]);
                b[l]++;
                if(r<n)b[r+1]--;
            }
            rep(i,0,n)b[i+1]+=b[i];
            a=b;
            if(j==k)rep(i,0,n)cout<<b[i]<<" ";
        }
    }
}



Measured memory_bytes: 8044
N = int(input().rstrip())
As = {}
answer = 0
for a in [int(x) for x in input().rstrip().split()]:
    answer += a
    if a in As.keys():
        As[a] += 1
    else:
        As[a] = 1
# print(As)
Q = int(input().rstrip())
d = {}
for i in range(Q):
    b, c = map(int, input().rstrip().split())
    d[i] = {'b': b, 'c': c}
# print(d)
for i in sorted(d.keys()):
    if d[i]['b'] in As.keys():
        diff = d[i]['c'] - d[i]['b']
        diff_num = As.pop(d[i]['b'])
        if d[i]['c'] in As.keys():
            As[d[i]['c']] += diff_num
        else:
            As[d[i]['c']] = diff_num
        answer += (diff * diff_num)
    print(answer)


Measured memory_bytes: 54944
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool> vecbool;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<string> vecstr;
typedef vector<vecint> vec2int;
typedef vector<vecbool> vec2bool;
int dx[4]{-1, +1, 0, 0};
int dy[4]{0, 0, -1, +1};
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
int main() {
  init();
  int n, m;
  cin >> n >> m;
  vecint a(n, 0);
  int sum = 0;
  REP(i, n) {
    cin >> a[i];
    sum += a[i];
  }
  sort(all(a), greater<int>());
  bool ok = true;
  REP(i, m) {
    if (4 * m * a[i] < sum) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int k = in.nextInt();
		in.close();
		int[] mod = new int[k];
		int INF = 100000;
		for(int i=0;i<k;i++) {
			mod[i] = INF;
		}
		List<int[]> list = new LinkedList<>();
		int[] start = {1,1};
		list.add(0, start);
		while(mod[0]==INF) {
			int[] x = list.remove(0);
			mod[x[0]] = x[1];
			if(mod[(x[0]*10)%k]>mod[x[0]]) {
				int[] tmp = {(x[0]*10)%k,mod[x[0]]};
				list.add(0,tmp);
			}
			if(mod[(x[0]+1)%k]>mod[x[0]]+1) {
				int[] tmp = {(x[0]+1)%k,mod[x[0]]+1};
				list.add(list.size(),tmp);
			}
		}
		System.out.println(mod[0]);
		
	}
}

Measured memory_bytes: 43504
n,a,b = map(int,input().split())
hls = [int(input()) for i in range(n)]
l = 0
r = 10**15
while l<r:
  x = (l+r)//2
  cnt = 0
  for hp in hls:
    if hp-x*b>0:
      cnt += (hp-x*b+(a-b)-1)//(a-b)
  if cnt>x:
    l = x+1
  elif cnt<x:
    r = x
  else:
    ans = x
    break
if l == r:
  ans = l
print(ans)

Measured memory_bytes: 7072
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pi acos(-1)
#define mod 1000000007
#define show(x, y); cout << x << " " << y << endl;
using namespace std;

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

    int n;
    cin >> n;
    ld p[n], dp[n][n+1];
    memset(dp, 0, sizeof dp);
    for(int i = 0; i < n; i++){
        cin >> p[i];
        for(int j = 0; j <= i+1; j++){
            if(i == 0){
                if(j == 0){
                    dp[i][j] = 1 - p[i];
                }else{
                    dp[i][j] = p[i];
                }
            }else{
                dp[i][j] = dp[i-1][j] * (1 - p[i]);
                if(j > 0){
                    dp[i][j] += (dp[i-1][j-1] * p[i]);
                }
            }
        }
    }
    ld ans = 0;
    for(int i = (n+1)/2; i <= n; i++){
        ans += dp[n-1][i];
    }
    cout << setprecision(10) << fixed << ans;
    return 0;
}


Measured memory_bytes: 140928
#include <bits/stdc++.h>
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
#define check cout<<"?\n";
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

signed main(){
    io();
    int n; cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; ++i){
        int num = (int)(floor(log2(i)/log2(10)));
        if(num % 2 == 0){
            ++ans;
        }
    }
    return cout << ans << '\n', 0;
}

Measured memory_bytes: 3744
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N;
vi X, Y;
vll arms;
vi U, V;

int main() {
    cin >> N;
    X.resize(N);
    Y.resize(N);
    rep(i, N) cin >> X[i] >> Y[i];

    int parity = abs(X[0] + Y[0]) % 2;
    rep(i, N) {
        if (abs(X[i] + Y[i]) % 2 != parity) {
            write(-1);
            return 0;
        }
    }

    for (int i = 31; i >= 0; --i) arms.push_back((ll)1 << i);
    if (parity == 0) arms.push_back(1);

    write(arms.size());
    rep(i, arms.size() - 1) cout << arms[i] << " ";
    write(arms.back());

    rep(i, N) {
        int u = X[i] + Y[i];
        int v = X[i] - Y[i];

        string ans(arms.size(), '.');

        rep(j, arms.size()) {
            if (u >= 0) {
                u -= arms[j];
                if (v >= 0) {
                    ans[j] = 'R';
                    v -= arms[j];
                }
                else {
                    ans[j] = 'U';
                    v += arms[j];
                }
            }
            else {
                u += arms[j];
                if (v >= 0) {
                    ans[j] = 'D';
                    v -= arms[j];
                }
                else {
                    ans[j] = 'L';
                    v += arms[j];
                }
            }
        }

        //if (u != 0 || v != 0) write("wrong");
        write(ans);
    }
}

Measured memory_bytes: 256
import math

def get_input():
    return int(input())

def isprime(x):
  if x == 2:
    return True

  if x < 2 or x % 2 == 0:
    return False

  for i in range(3, math.ceil(math.sqrt(x)) + 1, 2):
    if x % i == 0:
      return False

  return True

n = get_input()
results = 0
for _ in range(n):
    a = get_input()
    if isprime(a):
        results += 1

print(results)



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

int d[6][6] = {
	//A  B  X  Y  Z  W
	{ 2, 2, 0, 1, 2, 2 },
	{ 2, 2, 1, 0, 2, 2 },
	{ 2, 2, 2, 2, 1, 2 },
	{ 2, 2, 0, 2, 2, 2 },
	{ 2, 1, 2, 2, 2, 0 },
	{ 2, 0, 2, 1, 2, 2 },
};

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

	string s;
	while(cin >> s, s != "#") {
		int dp[110][6] = { 0 };
		dp[0][0] = 1;
		for(int i = 0; i < s.size(); i++) {
			for(int j = 0; j < 6; j++) {
				if(!dp[i][j]) continue;
				for(int k = 0; k < 6; k++) {
					if(s[i] - '0' == d[j][k]) {
						dp[i + 1][k] = 1;
					}
				}
			}
		}

		if(dp[s.size()][1]) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
//typedef
typedef long long ll;
typedef vector<string> vs;
//define
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//debug
#define dump(x)  cout << #x << = << (x) << endl;


int main() {
  int n,s;
  cin >> n;
  vector<int> a(n),b(n),c(n-1);
  FOR(i,0,n){
    cin >> a.at(i) ;
  }
  FOR(i,0,n){
    cin >> b.at(i) ;
  }
  FOR(i,0,n-1){
    cin >> c.at(i);
  }
  FOR(i,0,n){
    s += b.at(a.at(i) - 1);
  }
  FOR(i,1,n){
    if(a.at(i-1) == a.at(i) - 1){
      s += c.at(a.at(i-1)-1);
    }
  }
  cout << s << endl;
  
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
//#define int long long
#define rep(i, l, r) for(int i = l; i <= r; ++ i)

int read()
{
	char cc = getchar(); int cn(0), flus(1);
	while(cc > '9' || cc < '0') {if(cc == '-') flus = -flus; cc = getchar();}
	while(cc >= '0' && cc <= '9') {cn = cn * 10 + cc - 48; cc = getchar();}
	return cn * flus;
}
 
inline int max(int a, int b)
{
	return (a > b) ? a : b;
}
 
const int MAXN = 3e5 + 10;

struct node
{
	int x, y;
} a[MAXN];

int x, y, m;
int sumx[MAXN], sumy[MAXN];
bool fx[MAXN], fy[MAXN], ok(1);

signed main()
{ 
	int cnt1(0), cnt2(0), cnt3(0);
	x = read(), y = read(), m = read();
	rep(i, 1, m) a[i].x = read(), a[i].y = read(), sumx[a[i].x] ++, sumy[a[i].y] ++;
	int maxx(0), maxy(0);
	rep(i, 1, x) maxx = max(maxx, sumx[i]);
	rep(i, 1, y) maxy = max(maxy, sumy[i]);
	rep(i, 1, x) fx[i] = (sumx[i] == maxx) ? 1 : 0, cnt1 += fx[i];
	rep(i, 1, y) fy[i] = (sumy[i] == maxy) ? 1 : 0, cnt2 += fy[i];
	rep(i, 1, m) 
	{
		if(fx[a[i].x] && fy[a[i].y]) 
		{
			cnt3 ++;
		}
	}	
	int ans(0);
//	printf("cnt1 = %d cnt2 = %d cnt3 = %d \n", cnt1, cnt2, cnt3);
	if(cnt1 * cnt2 == cnt3) ok = 0;
	if(!ok) ans = maxx + maxy - 1;
	else ans = maxx + maxy;
	printf("%d\n", ans);
	return 0;
} 

Measured memory_bytes: 9076
#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 r, g, b;
  cin >> r >> g >> b;
  int s = 100*r + 10*g + b;
  if (s%4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(((a==b) && (b!= c))||((b==c) && (c!=a))||((c==a)&&(a!=b)))
    printf("Yes");
  else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void)
{
    int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a <= b && b <= c){
      printf("%d %d %d\n",a,b,c);
  }
    
   else if(a <= c && c <= b){
      printf("%d %d %d\n",a,c,b);
  }

  else if(b <= a && a <= c){
      printf("%d %d %d\n",b,a,c);
  }

  else if(b <= c && c <= a){
      printf("%d %d %d\n",b,c,a);
  }

   else if(c <= a && a <= b){
      printf("%d %d %d\n",c,a,b);
  }

   else if(c <= b && b <= a){
      printf("%d %d %d\n",c,b,a);
  }
    return 0;
}


Measured memory_bytes: 2024
#include<stdio.h>
int n, F[45];

int fibonacci(int n){
  if(n == 0 || n == 1)    return F[n] = 1;
  if(F[n] != -1)         return F[n];
  return F[n] = fibonacci(n - 2) + fibonacci(n - 1);
}

int main(){
  int i;
  for(i = 0; i < 45; i++)
    F[i] = -1;

  scanf("%d", &n);
  printf("%d\n", fibonacci(n));
  
  return 0;
}

Measured memory_bytes: 596
import numpy as np

N = int(input())
hs = list(map(int, input().split()))
hs = [0] + hs

# init
dp = np.zeros(N + 1).astype(int)
dp[2] = abs(hs[2] - hs[1])
# loop
if N > 2:
    for i in range(3, N + 1):
        dp[i] = min(
            dp[i-2] + abs(hs[i] - hs[i-2]),
            dp[i-1] + abs(hs[i] - hs[i-1]))

# output
print(dp[N])

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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

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

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[b]+=siz[a];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
signed main(){
	int n,ma,mb;
	cin>>n>>ma>>mb;
	int dp[2][410][410];
	rep(i,2){
		rep(j,410){
			rep(k,410){
				dp[i][j][k]=INF;
			}
		}
	}
	dp[0][0][0]=0;
	for(int kk=0;kk<n;kk++){
		int k=(kk+1)%2;
		int a,b,c;
		cin>>a>>b>>c;
		int l=kk%2;
		rep(i,410){
			rep(j,410){
				dp[k][i][j]=dp[l][i][j];
			}
		}
		rep(i,410){
			rep(j,410){
				if(dp[l][i][j]!=INF&&dp[k][i+a][j+b]>dp[l][i][j]+c){
					dp[k][i+a][j+b]=dp[l][i][j]+c;
				}
			}
		}
	}
	int c=1;
	int re=INF;
	while(1){
		if(ma*c>=410||mb*c>=410){
			break;
		}
		chmin(re,dp[n%2][ma*c][mb*c]);
		c++;
	}
	if(re==INF)cout<<-1<<endl;
	else cout<<re<<endl;
}

Measured memory_bytes: 2816
#include <iostream>
using namespace std;
int a[110];
int main()
{   
    int l, i, n,s=0,max=1000000;
    cin >> n;
    for (i = 0;i < n;i++) {
        cin >> a[i];
    }
    for ( i = 1; i < 100; i++)
    {
        s = 0;
        for (int j = 0; j < 100; j++){
            if(a[j]>0)
            s += (a[j] - i) * (a[j] - i);
        }
      //  cout << s << endl;
        if (s <= max) {
            max = s;
            //cout << s<<endl;
        }
    }
    
    cout << max;
    return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#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>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
#include<stdio.h>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

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

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

int main(){
    int N;
    cin >> N;
    int ans=1;
    int num=0;
    int init=1;
    while(init*2<=N){
        init*=2;
        ans=init;
    }
    cout << ans;
    }

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

using namespace std;
int main(){
    int N, M, t;
    long long sum = 0;

    cin>>N;
    cin>>M;

    for(int i =0; i<M; i++){
        cin>>t;
        sum+=t;
    }

    if(N-sum<0){
        cout<<-1<<"\n";
    }
    else{
        cout<<N-sum<<"\n";
    }

    return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define lim1 10000000
#define lim2 22500000
using namespace std;
typedef long long LL;
int f[lim2+10];
const LL mod = 1e9+7;
void init() {
    int l = 1, r = 10;
    for (int k = 1; k <= 7; ++k) {
        for (int i = l; i < r; ++i) f[i] = k;
        l = r; r *= 10;
    }
    for (int i = lim1; i <= lim2; ++i) f[i] = 8;
}
LL poww(LL a, LL b) {
    LL ret = 1;
    while (b) {
        if (b & 1) (ret *= a) %= mod;
        (a *= a) %= mod;
        b >>= 1;
    }
    return ret;
}
LL count1(LL x) {
    int l = 1, r = 1, ret = 0; LL sum = 0;
    while (true) {
        while (r <= lim2 && sum < x) sum += f[r++];
        if (sum < x) break;
        if (sum == x) (ret += 1) %= mod;
        sum -= f[l++];
        if (l == lim1) break;
    }
    return ret;
}
LL count2(LL x) {
    LL upp = x/8,
        ret = upp;
    for (int t = 1; t <= upp; ++t) {
        if (x % t == 0) {
            int len = x / t;
            LL sub = 9 * poww(10, len-1) % mod;
            (sub += mod - t) %= mod;
            (ret += sub) %= mod;
        }
    }
    return ret;
}
int main() {
//    freopen("in.txt", "r", stdin);
    init();
    LL n;
    scanf("%lld", &n);
    LL ans1 = count1(n), ans2 = count2(n);
    printf("%lld\n", (ans1+ans2)%mod);
    return 0;
}


Measured memory_bytes: 88192
#include "bits/stdc++.h"
#include<cassert>
#pragma warning(disable:4996)
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MRE assert(0)
const int mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<P, int>PP;
int dp[305][305][305];
string s; int K, n;
void DP() {
	rep(k, K + 1) {
		rep(i, n) {//幅
			for (int j = 0; j + i < n; j++) {//[j,j+i]
				if (j) {
					dp[j - 1][j + i][k] = max(dp[j - 1][j + i][k], dp[j][j + i][k]);
				}
				if (j + i < n - 1) {
					dp[j][j + i + 1][k] = max(dp[j][j + i + 1][k], dp[j][j + i][k]);
				}
				if (j&&j + i < n - 1) {
					if (s[j - 1] == s[j + i + 1]) {
						dp[j - 1][j + i + 1][k] = max(dp[j - 1][j + i + 1][k], dp[j][j + i][k] + 2);
					}
					else if (k != K) {
						dp[j - 1][j + i + 1][k + 1] = max(dp[j - 1][j + i + 1][k + 1], dp[j][j + i][k] + 2);
					}
				}
			}
		}
	}
}

signed main() {
	cin >> s; cin >> K; n = s.size();
	rep(i, n)dp[i][i][0] = 1;
	DP();
	int res = 0,res2=0;
	rep(i, n)rep(j, n)rep(k, K + 1)res = max(res, dp[i][j][k]);
	rep(i, n)rep(j, n)rep(k, K + 1)dp[i][j][k] = 0;
	rep(i, n-1) {
		for (int j = i + 1; j < n; j++) {
			if (s[i] == s[j])dp[i][j][0] = 2;
			else dp[i][j][1] = 2;
		}
	}
	DP();
	rep(i, n)rep(j, n)rep(k, K + 1)res2 = max(res2, dp[i][j][k]);
	cout <<max(res,res2)<< endl;
}

Measured memory_bytes: 219392
#include <stdio.h>

int main(){
    int height[10], idx;
    for(idx = 0; idx < 10; ++idx){
        scanf("%d", &height[idx]);
    }

    sort(height, 10);

    for(idx = 0; idx < 3; ++idx){
        printf("%d\n", height[idx]);
    }
    return 0;
}

void sort(int* height, int length){
    int idx;
    for(idx = 0; idx < length - 1; ++idx){
        if(height[idx] < height[idx + 1]){
            height[idx      ] = height[idx] ^ height[idx + 1];
            height[idx + 1] = height[idx] ^ height[idx + 1];
            height[idx      ] = height[idx] ^ height[idx + 1];
        }
    }
    if(length > 2){
        sort(height, length - 1);
    }
}

Measured memory_bytes: 0
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var line1 = ReadInts();
        var line2 = ReadInts();
        var K = line1[1];
        var result = line2.OrderBy(n => n).Take(K).Sum();
        Console.WriteLine(result);
    }

    private static string Read() => Console.ReadLine();
    private static char[] ReadChars() => Array.ConvertAll(Read().Split(), a => a[0]);
    private static int ReadInt() => int.Parse(Read());
    private static long ReadLong() => long.Parse(Read());
    private static double ReadDouble() => double.Parse(Read());
    private static int[] ReadInts() => Array.ConvertAll(Read().Split(), int.Parse);
    private static long[] ReadLongs() => Array.ConvertAll(Read().Split(), long.Parse);
    private static double[] ReadDoubles() => Array.ConvertAll(Read().Split(), double.Parse);
}

Measured memory_bytes: 28584
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;

int main(int argc, char** argv) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if (argc == 2 && atoi(argv[1]) == 123456789)
        freopen("d:\\code\\cpp\\stdin", "r", stdin);

    string s;
    cin >> s;

    bool sat = true;
    sat &= (s[0] == 'A');

    int pos = -1;
    for(int i=2; i<s.length()-1; i++) {
        if (s[i] == 'C') {
            if (pos == -1)
                pos = i;
            else {
                sat = false;
                break;
            }
        }
    }
    if (pos==-1)
        sat = false;

    for(int i=1; i<s.length(); i++)
        if ((s[i]>'z' || s[i]<'a') && i!=pos){
            sat = false;
            break;
        }

    if (sat)
        cout << "AC";
    else
        cout << "WA";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int nmax=40,abmax=10,inf = 1000000;

int a[nmax],b[nmax],c[nmax];
int dp[nmax+1][nmax*abmax+1][nmax*abmax+1];

int main(void){
	int n,ma,mb;
	cin >> n >> ma >> mb;
 
	for(int i=0;i<n;++i){
		cin >> a[i] >> b[i] >> c[i];
	}

	for(int i = 0; i <= n; ++i){
		for(int ca = 0; ca <= nmax*abmax; ++ca){
			for(int cb = 0; cb <= nmax*abmax; ++cb){
				dp[i][ca][cb]=inf;
			}
		}
	}
 
	dp[0][0][0]=0;
 
	for(int i = 0; i < n; ++i){
		for(int ca = 0; ca <= nmax*abmax; ++ca){
			for(int cb = 0; cb <= nmax*abmax; ++cb){
				if(dp[i][ca][cb]==inf) continue;
				dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb]);
				dp[i+1][ca+a[i]][cb+b[i]]=min(dp[i+1][ca+a[i]][cb+b[i]],dp[i][ca][cb]+c[i]);
			}
		}
	}

	int ans=inf;
	for(int ca = 1; ca <= nmax*abmax; ++ca){
		for(int cb = 1; cb <= nmax*abmax; ++cb){
			if(ca*mb==cb*ma) ans=min(ans,dp[n][ca][cb]);
		}
	} 
	
	if(ans==inf) ans=-1;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 25984
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>*/
#include <bits/stdc++.h>

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;
double PI = 4*atan(1);

ll K;
vector<ll> ans;

void rev() {
	sort(ans.begin(),ans.end());
	ans[0] += 50;
	FOR(i,1,50) ans[i] -= 1;
}

int main() {
	cin >> K;
	cout << "50\n";
	
	ll numop = K/50;
	F0R(i,50) ans.pb(numop+49);
	K -= 50*numop;
	F0R(i,K) rev();
	F0R(i,50) cout << ans[i] << " ";
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>//printf("%.*f\n",*********);
#include<vector>//s.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char('a'=32+'A')
                //to_string,string,substr
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(a,n) rep(i,n)cin>>a[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

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

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int KETA(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}

bool KIBN(string s) {
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - 1 - i])return false;
	}
	return true;
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	rapid_pleaseAC_fast;

	string s, t = "CODEFESTIVAL2016";
	cin >> s;
	int cnt = 0;

	rep(i, s.size()) {
		if (s[i] != t[i]) {
			cnt++;
		}
	}
	cout << cnt << rt;

	please AC;
}
//参考：---

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int A, B, C, n;
  scanf("%d %d %d", &A, &B, &C);
  if (A>=B){
    if (A>=C){
      n = 10 * A + B + C;
    }
    else {
      n = 10 * C + A + B;
    }
  }
  else {
    if (B>=C){
      n = 10 * B + C + A;
    }
    else {
      n = 10 * C + A + B;
    }
  }
  printf("%d", n);
  return 0;
}

Measured memory_bytes: 128
//author Eterna
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
#include<cmath>
#include<climits>
#include<deque>
#include<functional>
#include<complex>
#include<numeric>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define Pi acos(-1.0)
#define ABS(x) ((x) >= 0 ? (x) : (-(x)))
#define pb(x) push_back(x)
#define lowbit(x) (x & -x)
#define FRIN freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\in.txt", "r", stdin)
#define FROUT freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\out.txt", "w", stdout)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int maxn = 2e5;
const int INF = 0x7fffffff;
const int mod = 1e9 + 7;
const double eps = 1e-7;
inline int read_int() {
	char c;
	int ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
inline ll read_ll() {
	char c;
	ll ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
using namespace std;
struct node {
	bool operator < (const node& rhs)const {
		return l == rhs.l ? r > rhs.r : l < rhs.l;
	}
	int l, r;
}p[maxn + 5];
priority_queue<int, vector<int>, greater<int> > q, _q;
int n, m, res;
int main()
{
	res = n = read_int(), m = read_int();
	for (int i = 1; i <= n; i++)  p[i].l = read_int(), p[i].r = read_int();
	sort(p + 1, p + 1 + n);
	for (int i = 1; i <= n; i++)if (p[i].l == q.size()) q.push(p[i].r), _q.push(q.top()), q.pop(); else q.push(p[i].r), res--;
	for (int i = q.size() + 1; i <= m && !_q.empty(); i++) if (_q.top() <= i) _q.pop(), res--;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3320
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;
int main(){
	int n,m;
	cin>>n>>m;
	vector<string>s(n);
	for(int i=0;i<n;i++)
		cin>>s[i];
	// A vector table to store the dp values
	// A vector containing n vectors of size m
	vector<vector<int>>dp(n,vector<int>(m,0));
	// If there is only 1 block then there is only 1 path
	dp[0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(s[i][j] == '#')
				continue;
			if(i==0 && j==0)
				continue;
			if(i==0)
				dp[i][j]=dp[i][j-1];
			else if(j==0)
				dp[i][j]=dp[i-1][j];
			else
				dp[i][j]=(dp[i][j]%MOD + dp[i-1][j]%MOD + dp[i][j-1]%MOD)%MOD;
		}
	}
	cout<<dp[n-1][m-1];
	return 0;
}

Measured memory_bytes: 9464
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var N = GetInt();
            var A = GetIntArray();
            long ans = 0;
            var B = Enumerable.Range(1, N).Select(s => A[s - 1] - s).OrderBy(s=>s).ToArray();
            ans = B.Select(s => ans += Math.Abs(s - B[N / 2])).Last();

            Console.Write(ans);
        }



        static public string GetStr() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 36904
#include <stdio.h>
#include <math.h>

int main(void)
{
	double angle[12] = {0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330};
	double h, m, ang;
	int n;
	
	scanf("%d", &n);
	
	while (n-- != 0){
		scanf("%lf%*c%lf", &h, &m);
		
		h = angle[(int)h] + m / 2;
		m *= 6;
		
		ang = fabs(h - m) >= 180 ? fabs(360.0 - fabs(h - m)) :fabs(h - m) ;
		
		if (0 <= ang && ang < 30){
			printf("alert\n");
		}
		else if (90 <= ang && ang <= 180){
			printf("safe\n");
		}
		else {
			printf("warning\n");
		}
		
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
 
  int n;
  cin>>n;
  if(n==1){
    cout("Hello World");
  }else{
    int a,b;cin>>a>>b;
    cout(a+b);
  }
  
  return 0;
}

Measured memory_bytes: 125568
import Control.Applicative
import Control.Monad
import Data.List
import Text.Printf

main :: IO ()
main = go 1

go :: Int -> IO ()
go i = do
  x <- readLn :: IO Int
  when (x /= 0) $ do
    printf "Case %d: %d\n" i x
    go (i + 1)



Measured memory_bytes: 4172
#include <stdio.h>

int main(void)
{
  int sec;
  int min;
  int hour;
			 
  sec = 0;
  min = 0;
  hour = 0;
			  
  scanf("%d", &sec);
					   
  if(sec >= 60) {
    min = sec / 60;
    sec = sec % 60;
  }
  if(min >= 60){
    hour = min / 60;
    min = min % 60;
  }

  printf("%d:%d:%d\n", hour, min, sec);
												 
  return 0;
}

Measured memory_bytes: 1024
def f;gets.split.map &:to_i;end
while(n,m=f)[0]>0
l=(0..2).map{(i=f)[0]=-1;i}
r=[0,1].map{|x|a,b,c=t=l.map(&:dup);(0..m).find{|d|!(b[1]||a[1]&&c[1])||![t[x][-1]>t[z=y=x+1][-1]&&(x,y=y,x),(t[x].push t[y].pop),x=2-z]}||1e8}.min
p r<1e8?r:-1
end

Measured memory_bytes: 6124
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
  int N, ans=0;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }  
  vector<int> B(N);
  for(int i=0;i<N;i++){
    cin >> B[i];
    ans = ans + B[i];
  }  
  vector<int> C(N-1);
  for(int i=0;i<N-1;i++){
    cin >> C[i];
  }  
  
  for(int j=0;j<N-1;j++){
    if(A[j] + 1 == A[j+1]){
      ans = ans + C[A[j]-1];
    }  
  }  
  cout << ans << endl;

  return 0;
}

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

using namespace std;

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

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

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

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n, v[30], c[30];
	cin>>n;
	REP(i, n){
		cin>>v[i];
	}
	REP(i, n){
		cin>>c[i];
	}
	int ans=0;
	REP(i, 1<<n){
		int x=0, y=0;
		REP(j, n){
			if(i>>j&1){
				x+=v[j];
				y+=c[j];
			}
		}
		CHMAX(ans, x-y);
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <limits>
#include <iomanip>

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

inline int ctoi(char c) {
    return (int)(c -'0');
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    rep(i, s.size()) {
        int a = s[i] - 'A';
        a = (a + n) % 26;
        cout << char('A' + a);
    }
    cout << endl;
    return 0;
}


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

typedef long long ll;

using namespace std;

#define PI acos(-1.0)

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

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    double a,b,h,m;
    cin >> a >> b >> h >> m;

    h = h * 30 + m * 0.5;
    m = m * 6;

    double diff = abs(m - h);
    double x = (PI * diff) / 180;
    double res = sqrt(a * a + b * b - 2 * a * b * (cos(x)));

    cout << setprecision(12) << fixed << res << endl;

}

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

int main()
{
	int N, K, R, S, P;
	char T[100001];
	scanf("%d %d", &N, &K);
	scanf("%d %d %d", &R, &S, &P);
	scanf("%s", T);
	
	int i, j, ans = 0;
	for (i = 0; i < K; i++) {
		if (T[i] == 'r') {
			ans += P;
			T[i] = 'P';
		} else if (T[i] == 's') {
			ans += R;
			T[i] = 'R';
		} else {
			ans += S;
			T[i] = 'S';
		}
	}
	for (; i < N; i++) {
		if (T[i] == 'r' && T[i-K] != 'P') {
			ans += P;
			T[i] = 'P';
		} else if (T[i] == 's' && T[i-K] != 'R') {
			ans += R;
			T[i] = 'R';
		} else if (T[i] == 'p' && T[i-K] != 'S') {
			ans += S;
			T[i] = 'S';
		}
	}
	
	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}

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

int64_t gcd(int64_t a,int64_t b){
  int64_t r=max(a,b)%min(a,b);
  if(r==0){
    return min(a,b);
  }
  return gcd(min(a,b),r);
}

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

int main(){
  int64_t a,b;
  cin >> a >> b;
  cout << lcm(a,b) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n;
    cin >> n;
    vector<ll> len(3);
    for(int i = 0; i < 3; ++i)  cin >> len[i];
    vector<ll> l(n);
    int limit = 1;
    for(int i = 0; i < n; ++i){
        cin >> l[i];
        limit *= 4;
    }

    ll res = 1e+15;
    for(int i = 0; i < limit; ++i){
        int foo = i;
        int id = 0;
        vector<vector<ll>> hoge(4);
        while(id < n){
            hoge[foo % 4].push_back(l[id++]);
            foo /= 4;
        }
        if(hoge[0].size() == 0 || hoge[1].size() == 0 || hoge[2].size() == 0)   continue;
        
        ll score = 0;
        for(int s = 0; s < 3; ++s){
            ll sum = accumulate(hoge[s].begin(), hoge[s].end(), 0ll);
            score += 10ll * (hoge[s].size() - 1);
            score += abs(sum - len[s]);
        }
        chmin(res, score);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
N,M = [int(i) for i in input().split()]
a = {str(i):[] for i in range(1,N+1)}
AC,WA = 0,0
for i in range(M):
    P,S = [x for x in input().split()]
    a[P].append(S)
for i in a:
    if 'AC' not in a[i]:
        continue
    for x in a[i]:
        if x == 'AC':
            AC+=1
            break
        WA +=1
print(AC,WA)

Measured memory_bytes: 31244