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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	lnt N, A[200000]; cin >> N;
	REP(i, N) cin >> A[i];
	lnt mx = A[0];
	lnt ans = 0;
	REP(i, N){
		chmax(mx, A[i]);
		if(A[i] < mx){
			ans += (mx-A[i]);
		}
	}
	cout << ans << ln;
}

Measured memory_bytes: 5196
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>

#define ll long long

using namespace std;
int a, b, c, d;

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

    if ((a + b) < (c + d)) {
        cout << " Right";
    } else if ((a + b) > (c + d)) {
        cout << "Left";
    } else {
        cout << "Balanced";
    }
    
    return 0;
}

Measured memory_bytes: 256
/* https://atcoder.jp/contests/abc108/tasks/arc102_a */

#include <iostream>
#include <set>
#include <cmath>

unsigned long solve(const int N, const int K)
{
  int num_valid_number_rem_zero = 0;
  int num_valid_number_rem_halh_K = 0;
  for (int i = 1; i <= N; ++i) {
      num_valid_number_rem_zero += i%K == 0 ? 1 : 0;
    if (!(K%2))
      num_valid_number_rem_halh_K += i%K == K/2 ? 1 : 0;
  }
  return ulong(std::pow(num_valid_number_rem_zero, 3) + std::pow(num_valid_number_rem_halh_K, 3));
}

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

  std::cin >> N >> K;

  std::cout << solve(N, K) << std::endl;

  return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int k, x;
  cin >> k >> x;
  for (int i = x - k + 1; i < x + k; ++i) {
    if (i > x - k + 1) {
      cout << " ";
    }
    cout << i;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1e6+10;
ll v[N],Min[N][2],tag[N];
#define lc x<<1
#define rc x<<1|1
void update(int x){
	Min[x][0]=min(Min[lc][0],Min[rc][0]);
	Min[x][1]=min(Min[lc][1],Min[rc][1]);
}
void add(int x,ll d){
	tag[x]+=d;
	v[x]+=d;Min[x][0]+=d;Min[x][1]+=d;
}
void pushdown(int x){
	if (tag[x]){
		add(lc,tag[x]);
		add(rc,tag[x]);
		tag[x]=0;
	}
}
void build(int x,int l,int r){
	if (l==r){
		v[x]=1e16;
		Min[x][0]=v[x]-l;Min[x][1]=v[x]+l;
		return;
	}
	int mid=(l+r)>>1;
	build(lc,l,mid);
	build(rc,mid+1,r);
	update(x);
}
ll query(int x,int l,int r,int L,int R,int tp){
	if (l>=L&&r<=R) return Min[x][tp];
	pushdown(x);
	int mid=(l+r)>>1;ll ans=1e16;
	if (L<=mid) ans=min(ans,query(lc,l,mid,L,R,tp));
	if (R>mid) ans=min(ans,query(rc,mid+1,r,L,R,tp));
	return ans;
}
void change(int x,int l,int r,int p,ll val){
	if (l==r){
		v[x]=min(v[x],val);
		Min[x][0]=v[x]-l;Min[x][1]=v[x]+l;
		return;
	}
	pushdown(x);
	int mid=(l+r)>>1;
	if (p>mid) change(rc,mid+1,r,p,val);
		else change(lc,l,mid,p,val);
	update(x);
}
ll ans=1e16;
void dfs(int x,int l,int r){
	if (l==r) return void(ans=min(ans,v[x]));
	pushdown(x);
	int mid=(l+r)>>1;
	dfs(lc,l,mid);
	dfs(rc,mid+1,r);
}
int n,q,a,b,x[N];
int main()
{
	scanf("%d%d",&n,&q);q++;
	for (int i=0;i<=q;i++) scanf("%d",&x[i]);
	build(1,1,n);
	change(1,1,n,x[0],0);
	for (int i=2;i<=q;i++){
		ll val=min(query(1,1,n,1,x[i],0)+x[i],query(1,1,n,x[i],n,1)-x[i]);
		add(1,abs(x[i]-x[i-1]));
		change(1,1,n,x[i-1],val);
	}
	dfs(1,1,n);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 23424
import math
N, H = map(int, input().split())
A = [0]*N
B = [0]*N
for i in range(N):
  A[i], B[i] = map(int,input().split())
aa = sorted(A,key=lambda x: -x)
bb = sorted(B,key=lambda x: -x)
ans = 0
I = H
mh = max(aa)
for x in bb:
  if (x < mh):
    break
  I = I - x
  ans += 1
  if (I <= 0):
    break
if (I > 0):
  ans += math.ceil(I/max(aa))
print(ans)

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

int main(){
    string s;
    cin >> s;
    bool ok = true;
    rep(i,s.size()){
        if(i%2==0){
            if(s[i]!='R' && s[i]!='U' && s[i]!='D'){
                cout << "No" << endl;
                return 0;
            }
        }
        else{
            if(s[i]!='L' && s[i]!='U' && s[i]!='D'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;
const int maxn = 3005;
const int mod = 1e9+7;
void up(int &x,int y) { x+=y; if(x>=mod)x-=mod; }
int  f[maxn][maxn][2];
int n,m;
int main() {
	scanf("%d%d",&n,&m);
	f[0][0][1]=1;
	for(int i=1;i<=n;i++) f[0][i][0]=1;
	for(int i=1;i<=m;i++) {
		for(int j=0;j<=n;j++) {
			for(int k=0;k<=1;k++) {
				if(j) up(f[i][j][k|(j==1)],f[i-1][j][k]),up(f[i][j-1][k|(j==1)],f[i-1][j][k]);
				if(n-j) up(f[i][j+1][k],f[i-1][j][k]),up(f[i][j][k],f[i-1][j][k]);
			}
		}
	}
	int ans = 0;
	for(int i=0;i<=n;i++) up(ans,f[m][i][1]);
	printf("%d",ans);
}

Measured memory_bytes: 70656
#include <stdio.h>

int main(void){
	int N, K = 0;
	int current_num = 1;

	scanf("%d", &N);
	scanf("%d", &K);

	for(int i=0;i < N;i++){
		current_num = (current_num*2) < (current_num+K) ? (current_num*2) : (current_num+K); 
	}

	printf("%d\n", current_num);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define rep(i,x) for(ll i = 0;i<x;i++)
#define REP(i,x) for(ll i = 1;i<=x;i++)
#define mp make_pair
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;
typedef pair<ll,ll> P;
using graph = vector<vector<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;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
template<class T>
T gcd(T a,T b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
template<class T>
T lcm(T a,T b){
    return a / gcd(a,b) * b;
}

//素数判定O(sqrt(N))
template<class T>
inline bool isp(T n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; 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;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logm)
ll modpow(ll n,ll m,ll MOD){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}
ll mypow(ll n,ll m){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n);
        m >>= 1;
        n *= n;
    }
    return res;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll A,B;
    cin >> A >> B;
    ll res = 0;
    if(A % 2 == 0){
        if(B % 2 == 0){
            res = (B - A) / 2 % 2;
            res ^= B;
        }
        else{
            res = (B - A + 1) / 2 % 2;
        }
    }
    else{
        if(B % 2 == 0){
            res = (B - A) / 2 % 2;
            res ^= A;res ^= B;
        }
        else{
            res = (B - A) / 2 % 2;
            res ^= A;
        }
    }
    cout << res << "\n";
}

Measured memory_bytes: 3648
#include <cstdio>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;
const ll MOD = 1000000007;

int nX, nY;
ll xs[100000+10];
ll ys[100000+10];

ll bs[100000+10];

int main(void) {
  int nX, nY;
  scanf("%d%d", &nX, &nY);
  REP(i, nX) {
    scanf("%lld", &xs[i]);
  }
  REP(i, nY) {
    scanf("%lld", &ys[i]);
  }
  ll hoge = 0;
  REP(j, nY-1) {
    hoge = (hoge + (ys[j+1]-ys[j])%MOD*(j+1)%MOD*(nY-j-1)%MOD) % MOD;
  }
  ll res = 0;
  REP(i, nX-1) {
    res = (res + hoge*(xs[i+1]-xs[i])%MOD*(i+1)%MOD*(nX-i-1)%MOD) % MOD;
  }
  printf("%lld\n", res);
  
  return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int k, n;
    cin >> k >> n;
    vector <int> a(n);
    cin >> a;
    int ans = 0;
    forn (i, 1, n)
        chkmax(ans, a[i] - a[i - 1]);
    chkmax(ans, a[0] + k - a[n - 1]);
    cout << k - ans;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
    int n, i, j, k, l;
    int C[101][101];

    scanf("%d", &n);

    for(i = 1; i <= n; i++){
        for(j = 1; j <= n; j++){
            C[i][j] = 0;
        }
    }    

    for(i = 1; i <= n; i++){
        scanf("%d%d", &k, &l);
        for(j = 0; j < l; j++){
            scanf("%d", &k);
            C[i][k] = 1;
        } 
    }

    for(i = 1; i <= n; i++){
        for(j = 1; j <= n-1; j++){
            if(C[i][j] == 1) printf("1 ");
            else printf("0 ");
        }
        if(C[i][j] == 1) printf("1\n");
         else printf("0\n");
    }

    return 0;
}


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

using namespace std;

int main(){
  int h,w;
  cin >> h >> w;
  string ans[2*h];
  int counter = 0;
  for(int i=0; i<h; i++){
    string c;
    cin >> c;
    ans[counter] = c;
    ans[counter+1] = c;
    counter += 2;
  }
  for(int i=0; i<2*h; i++){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 256
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long

typedef long long int64;
typedef vector<int> VI64;
typedef vector<pair<int,int>> VII64;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;

int32_t main()
{
	IOS;
	int T=1;
	//cin>>T;
	while(T--)
	{
		int n,u,v,i,j;
		cin>>n>>u>>v;
		int dis[n+1][n+1];
		for(i=1;i<=n;i++)
		{
			for(j=1;j<=n;j++)
			{
				dis[i][j]=abs(j-i);
			}
		}
		dis[u][v]=1;
		dis[v][u]=1;
		int pr[n+1]={0};
		for(i=1;i<=n;i++)
		{
			for(j=1;j<=n;j++)
			{
				int &ans=dis[i][j];
				ans=min({ans,dis[i][u]+1+dis[v][j],dis[i][v]+1+dis[u][j]});
				if(j>i)
				{
					pr[ans]++;
				}
			}
		}
		for(i=1;i<n;i++)
			cout<<pr[i]<<endl;

	}

	return 0;
}

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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};


class Eratosthenes {
public:
    vector<bool> prime;

    Eratosthenes(ll size) {
        size = max((int) sqrt(size) + 1, 101010);
        prime.resize(size, 1);
        prime[0] = 0;
        prime[1] = 0;
        for (size_t i = 2; i * i <= size; ++i)
            if (prime[i]) {
                for (size_t j = 2; i * j <= size; ++j)prime[i * j] = false;
            }
    }
};


class Combination {
    vector<ll> fac; //n!(mod M)
    vector<ll> ifac; //k!^{M-2} (mod M)
public:
    Combination(ll size) {
        fac.resize(size);
        ifac.resize(size);
        fac[0] = 1;
        ifac[0] = 1;
        for (ll i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * (i + 1) % MOD;
            ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
        }
    }

    ll mpow(ll x, ll n) {
        ll ans = 1;
        while (n != 0) {
            if (n & 1) ans = ans * x % MOD;
            x = x * x % MOD;
            n = n >> 1;
        }
        return ans;
    }

    ll comb(ll a, ll b) {
        if (a == 0 && b == 0)return 1;
        if (a < b || a < 0)return 0;
        ll tmp = ifac[a - b] * ifac[b] % MOD;
        return tmp * fac[a] % MOD;
    }
};


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

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll N, M, K;

int main() {
    cin >> N >> M >> K;
    REP(i, N + 1) {
        REP(j, M + 1) {
            if (j * (N - i) + i * (M - j) == K) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	long solve() throws IOException {

		long ans = 0;
		int n = ni();
		int a[] = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();

		if (a[0] != 0)
			return -1;

		for (int i = 1; i < n; i++)
			if (a[i] - a[i - 1] > 1)
				return -1;

		for (int i = n - 1; i >= 0; i--) {
			ans += a[i];
			if (a[i] > 0) {
				while (i > 0 && a[i] - a[i - 1] == 1)
					i--;
			}
		}

		return ans;
	}

	String ns() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine(), " ");
		}
		return tok.nextToken();
	}

	int ni() throws IOException {
		return Integer.parseInt(ns());
	}

	long nl() throws IOException {
		return Long.parseLong(ns());
	}

	double nd() throws IOException {
		return Double.parseDouble(ns());
	}

	String[] nsa(int n) throws IOException {
		String[] res = new String[n];
		for (int i = 0; i < n; i++) {
			res[i] = ns();
		}
		return res;
	}

	int[] nia(int n) throws IOException {
		int[] res = new int[n];
		for (int i = 0; i < n; i++) {
			res[i] = ni();
		}
		return res;
	}

	long[] nla(int n) throws IOException {
		long[] res = new long[n];
		for (int i = 0; i < n; i++) {
			res[i] = nl();
		}
		return res;
	}

	public static void main(String[] args) throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		tok = new StringTokenizer("");
		Main main = new Main();
		out.println(main.solve());
		out.close();
	}
}

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

using namespace std;

constexpr double INF = 1e18;

class Graph{
    struct Edge{
        int from, to;
        double cost;
        int limit;
        Edge(int u,int v,double c,int l){
            from=u;
            to=v;
            cost=c;
            limit=l;
        }
        bool operator < (const Edge &right)const{
            return cost > right.cost;
        }
    };
    vector<vector<Edge>> g;

public:
    Graph(int n){
        g.resize(n);
    }
    void addEdge(int u, int v, double c, int l){
        g[u].emplace_back(u, v, c, l);
    }
    void dijkstra(int, vector<vector<vector<double>>>&);
};

inline void Graph::dijkstra(int s, vector<vector<vector<double>>> &dist){
    const int V=g.size();
    priority_queue<Edge> pq;
    for(int i=0;i<V;++i)dist[s][1][i]=0;
    for(pq.emplace(-2,s,0.0,0);!pq.empty();){
        Edge e=pq.top();pq.pop();
        for(auto ge:g[e.to]){
            if(e.from==ge.to)continue;
            for(int i=-1;i<=1;++i){
                if(e.limit+i<=0 || e.limit+i>ge.limit){
                    continue;
                }
                if(dist[ge.to][e.limit+i][ge.from] > e.cost+(ge.cost/(e.limit+i))){
                    dist[ge.to][e.limit+i][ge.from]=e.cost+(ge.cost/(e.limit+i));
                    pq.emplace(ge.from,ge.to,dist[ge.to][e.limit+i][ge.from],e.limit+i);
                }
            }
        }
    }
}

int main(){
    int n, m;
    while(cin>>n>>m,n){
        Graph g(n);
        int src,dst;
        cin>>src>>dst;
        for(int i=0;i<m;++i){
            int u,v,d,c;
            cin>>u>>v>>d>>c;
            g.addEdge(u-1,v-1,(double)d,c);
            g.addEdge(v-1,u-1,(double)d,c);
        }
        vector<vector<vector<double>>>dist(n,vector<vector<double>>(31,vector<double>(n,INF)));
        g.dijkstra(src-1, dist);
        cout<<fixed;
        double ans=INF;
        for(int i=0;i<n;++i){
            ans=min(ans,dist[dst-1][1][i]);
        }
        cout<<fixed;
        if(ans==INF)cout<<"unreachable"<<endl;
        else cout<<setprecision(6)<<ans<<endl;
    }
}


Measured memory_bytes: 4024
//g++  7.4.0

#include <bits/stdc++.h>
using namespace std;
int main()
{
   int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int dp[n],x=0;
    dp[0]=0;
    for(int i=1;i<n;i++) 
    {
        if(i==1)
        {
            dp[i]=abs(a[i-1]-a[i]);
        }
        else
        {
            dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));
            //cout<<i<<" "<<min(abs(a[i-1]-a[i]),abs(a[i-2]-a[i])<<endl;
        }
    }
    for(int i=0;i<n;i++)
    {
        //cout<<dp[i]<<endl;
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 4376
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int cost = Integer.parseInt(sc.next());
    int dislikeN = Integer.parseInt(sc.next());
    int[] dislikeArray = new int[dislikeN];
    for(int i=0; i<dislikeN; i++){
      dislikeArray[i] = Integer.parseInt(sc.next());
    }
    
    int pay = cost;
    int count = 0;
    int safety = 0;
    while(true){
      for(int i=0; i<dislikeN; i++){
        if(judge(dislikeArray[i], pay)){
          count++;
          if(count == dislikeN){
            System.out.println(pay);
            safety++;
            break;
          }
        }
      }
      if(safety != 0){
        break;
      }
      pay++;
      count = 0;
    }
  }
  
  private static boolean judge(int check, int n){
    while(true){
      if(n%10 == check){
        return false;
      }
      n = n/10;
      if(n == 0){
        return true;
      }
    }
  }
}

Measured memory_bytes: 23892
a, b, k = map(int, raw_input().split())
for i in range(0, k):
	if(i%2 == 0):
		if(a%2 != 0):
			a -= 1
		b += (a/2)
		a -= (a/2)
	else:
		if(b%2 != 0):
			b -= 1
		a += (b/2)
		b -= (b/2)
print(str(a)+" "+str(b))

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF INT_MAX/3
#define mod 1000000007

#define MAX_V 2010

struct edge{ int to,cap,rev; };
vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];

void init(int V){
  rep(i,V)G[i].clear();
}

void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,(int)G[to].size()});
  G[to].push_back((edge){from,0,(int)G[from].size()-1});
}

void bfs(int s){
  memset(level,-1,sizeof(level));
  queue<int> que;
  level[s]=0;
  que.push(s);
  while(!que.empty()){
    int v=que.front(); que.pop();
    for(int i=0;i<(int)G[v].size();i++){
      edge &e=G[v][i];
      if(e.cap>0&&level[e.to]<0){
        level[e.to]=level[v]+1;
        que.push(e.to);
      }
    }
  }
}

int dfs(int v,int t,int f){
  if(v==t)return f;
  for(int &i=iter[v];i<(int)G[v].size();i++){
    edge &e=G[v][i];
    if(e.cap>0&&level[v]<level[e.to]){
      int d=dfs(e.to,t,min(f,e.cap));
      if(d>0){
        e.cap-=d;
        G[e.to][e.rev].cap+=d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t){
  int flow=0;
  while(1){
    bfs(s);
    if(level[t]<0)return flow;
    memset(iter,0,sizeof(iter));
    int f;
    while((f=dfs(s,t,INF))>0){
      flow+=f;
    }
  }
}

int N,M,L;
ll d[101][101];
ll p[1001],t[1001];

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

  while(1){
    cin>>N>>M>>L;
    if(N==0)break;
    rep(i,N)rep(j,N)d[i][j]=(i==j?0:1e16);
    rep(i,M){
      ll a,b,c;
      cin>>a>>b>>c;
      d[a][b]=d[b][a]=c;
    }
    rep(k,N)rep(i,N)rep(j,N)minch(d[i][j],d[i][k]+d[k][j]);
    int source=2*L,sink=2*L+1;
    rep(i,L){
      cin>>p[i]>>t[i];
    }
    init(2*L+2);
    rep(i,L)rep(j,L){
      if(i==j)continue;
      if(t[i]+d[p[i]][p[j]]<=t[j])add_edge(i,j+L,1);
    }
    rep(i,L){
      add_edge(source,i,1);
      add_edge(i+L,sink,1);
    }
    cout<<L-max_flow(source,sink)<<endl;
  }

  return 0;
}



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

int N;
vector<pair<int, int>> Q;
int R[500 * 500];

int main() {
  cin >> N;
  for(int i = 1; i <= N; ++i) {
    int x; cin >> x; --x; Q.push_back(make_pair(x, i));
  }
  sort(Q.begin(), Q.end());
  int h = 0;
  for(int q = 0; q < N; ++q) {
    int x = Q[q].first, i = Q[q].second;
    R[x] = i;
    int d = 0;
    while(d < i - 1) {
      if(!R[h]) { R[h] = i; ++d; }
      ++h;
      if(h > x) { cout << "No" << endl; return 0; }
    }
  }
  h = N * N - 1;
  for(int q = N - 1; q >= 0; --q) {
    int x = Q[q].first, i = Q[q].second;
    int d = 0;
    while(d < N - i) {
      if(!R[h]) { R[h] = i; ++d; }
      --h;
      if(h < x) { cout << "No" << endl; return 0; }
    }
  }
  cout << "Yes" << endl;
  for(int i = 0; i < N * N; ++i) cout << (i == 0 ? "" : " ") << R[i];
  cout << endl;
  return 0;
}


Measured memory_bytes: 2176
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define endl "\n"
#define all(v) ((v).begin()),((v).end())
#define allr(v)	     ((v).rbegin()), ((v).rend())
#define sz(v) ((int)(v).size())
#define clr(v, d)        memset(v, d, sizeof(v))
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
int dx[]{ 0,0,1,-1,-1,1,1 ,-1 };
int dy[]{ -1,1,0,0 ,1,1,-1,-1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
}
//////
const int N = 2e3 + 10, mod = 1e9+7;
///////////
template<class Int>
Int gcd(Int a, Int b)
{
	return (b == 0 ? a : gcd(b, a%b));
}
template<class Int>
Int lcm(Int a, Int b)
{
	return a / gcd(a, b)*b;
}
int main()
{
	cout << setprecision(8) << fixed;
	IO
	//	file();
	///////////
	int n;
	cin >> n;
	map<int, int>mp;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		mp[x]++;
	}
	int cnt = 0;
	for (auto v : mp) {
		if (v.second > v.first)
			cnt += v.second - v.first;
		else if (v.second < v.first)
			cnt += v.second;
	}
	cout << cnt << endl;
		
}

Measured memory_bytes: 4736
import sys
n, m = map(int, input().split())
a, b = [], []

for _ in range(n):
    a.append(input())
for _ in range(m):
    b.append(input())

for i in range(0, n-m+1):
    for j in range(0, n-m+1):
        for k in range(m*m):
            if a[i+k//m][j+k%m] != b[k//m][k%m]:
                break
            elif k == m*m-1:
                print('Yes')
                sys.exit()
print('No')


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

int main(){
  int n;
  cin >> n;
  vector<int64_t> vec(100, 0);
  
  vec.at(0) = 2;
  vec.at(1) = 1;
  
  for(int i=2; i<n+1; i++){
    vec.at(i) = vec.at(i-1) + vec.at(i-2);
  }
  
  cout << vec.at(n) << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n,t,e;
  cin>>n>>t>>e;
  vector<Int> x(n);
  for(Int i=0;i<n;i++) cin>>x[i];
  Int a=t-e,b=t+e;
  for(Int i=0;i<n;i++){
    Int tmp=0;
    while(tmp<a) tmp+=x[i];
    if(a<=tmp&&tmp<=b){
      cout<<i+1<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}



Measured memory_bytes: 3104
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N; cin >> N;
  vector<ll> a(N); vector<ll> b(N);
  rep(i,N) cin >> a[i] >> b[i];

  SORT(a); SORT(b);
  ll ans = 0;
  // 奇数の時は簡単、それぞれの真ん中の点の時の間の数の個数
  if(N % 2 == 1){
    ll d = a[N / 2];
    ll u = b[N / 2];
    ans = u - d + 1;
    if(ans < 0) ans = 0;
  }
  else{
    ll dd = a[N / 2 - 1];
    ll du = a[N / 2];
    ll ud = b[N / 2 - 1];
    ll uu = b[N / 2];
    ll nd = (dd + du);
    ll nu = (uu + ud);
    ans = nu - nd + 1;
    if(ans < 0) ans = 0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 6428
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int x, y;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> x >> y;
    if(y % 2 == 0 && 2 * x <= y && y <= 4 * x) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef signed long long ll;
typedef vector<int> vec;
const int TP = 26;

ll compute_score(int D, vector<int>& C, vector<vector<int>>& S, vector<int>& sol) {
    vector<int> last(TP, 0);
    ll score = 0;
    for (int i = 0; i < D; i++) {
        int j = sol[i];
        last[j] = i + 1;
        int tmp = 0;
        for (int k = 0; k < TP; k++)
            tmp -= C[k] * (i + 1 - last[k]);
        cout << i << " " << S[i][j] << " " << tmp << endl;
        score += S[i][j] + tmp;
    }
    return score;
}

void compute_greedy(int D, vector<vector<int>>& S, vector<int>* sol) {
    ll score = 0;
    for (int i = 0; i < D; i++) {
        auto itp = std::max_element(S[i].begin(), S[i].end());
        int di = itp - S[i].begin();
        int maxsdi = *itp;
        (*sol)[i] = di;
    }
}

void compute_greedy_with_pen(int D, vector<int>& C, vector<vector<int>>& S, vector<int>* sol) {
    vector<int> last(TP, 0);
    int gamma = 5;
    ll score = 0;
    for (int i = 0; i < D; i++) {

        vector<ll> scores(TP, 0);
        for (int k = 0; k < TP; k++) {
            scores[k] = S[i][k] + gamma * (i + 1 - last[k]) * C[k];
        }

        auto itp = std::max_element(scores.begin(), scores.end());
        int di = itp - scores.begin();
        last[di] = i + 1;
        int maxsdi = *itp;
        (*sol)[i] = di;
    }
}

int main() {
    int D; cin >> D;
    vector<int> C(TP, 0);
    for (int i = 0; i < TP; i++) cin >> C[i];
    vector<vector<int>> S(D, vector<int>(TP, 0));
    for (int i = 0; i < D; i++)
        for (int j = 0; j < TP; j++)
            cin >> S[i][j];

    // greedy解
    vector<int> sol(D, 0);
    compute_greedy_with_pen(D, C, S, &sol);
    for (auto v : sol) { cout << (v + 1) << endl; }
    // cout << compute_score(D, C, S, sol) << endl;
}

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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashSet;
fn main() {
    input! {
        abc: [i64; 3],
        k : usize,
    }
    let mut abc = abc;
    abc.sort();
    abc[2] = (0..k).fold(abc[2], |acm, _| 2 * acm);

    println!("{}", abc.iter().sum::<i64>());
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int h1,h2,m1,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int last,stt;
    last = h2*60+m2;
    stt = h1*60+m1;
    cout << last - k - stt << endl;
    return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll k,n;
    cin>>k>>n;
    ll arr[n];
    for(ll i=0;i<n;i++)
    cin>>arr[i];
    ll ans=0;
    //sort(arr,arr+n);
    ll check=(k-arr[n-1])+(arr[0]-0);
    for(ll i=1;i<n;i++){
        if(arr[i]-arr[i-1]>check)
        check=arr[i]-arr[i-1];
    }
    
    ans=k-check;
    cout<<ans;
	return 0;
}

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

bool is_prime(int x)
{
    for (int i = 2; i * i < x; i++)
    {
        if (x % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    int X;

    cin >> X;

    int x = X;

    while (!is_prime(x))
    {
        x++;
    }
    
    cout << x << endl;
    return 0;
}


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


int main() {
  int n;
  cin >> n;
  
  vector<int> d(n);
  rep(i,n) cin >> d[i];
  
  sort (d.begin(),d.end());
  int ans;
  if (d[n/2] == d[n/2-1]){
    ans = 0;
  }
  else {
    ans = d[n/2] - d[n/2-1] ;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<double> a(n);
  for (int i = 0; i < n; i++) {
    double x;
    cin >> x;
    a[i] = 1/x;
  }
  double ans = 0;
  for (int i = 0; i < n; i++) {
    ans += a[i];
  }
  ans = 1/ans;
  printf("%.16lf\n", ans);
  return 0;
}

Measured memory_bytes: 256
import java.util.*


fun calculate(n: Int, weight: Int, w: LongArray, v: LongArray): Long {
    val dp = Array(n + 1) { LongArray(weight + 1) { -1 } }

    fun go(n: Int, weight: Int): Long {
        if (dp[n][weight] != -1L) return dp[n][weight]

        val result = if (n == 0 || weight == 0) {
            0
        } else if (w[n - 1] > weight) {
            go(n - 1, weight)
        } else {
            val no = go(n - 1, weight)
            val yes = v[n - 1] + go(n - 1, (weight - w[n - 1]).toInt())

            Math.max(no, yes)
        }

        dp[n][weight] = result
        return result
    }

    return go(n, weight)
}

fun main(args: Array<String>) {
    val result = with(Scanner(System.`in`)) {
        val n = nextInt()
        val W = nextInt()

        val w = mutableListOf<Long>()
        val v = mutableListOf<Long>()

        for (i in 0 until n) {
            w.add(nextLong())
            v.add(nextLong())
        }

        calculate(n = n, weight = W, w = w.toLongArray(), v = v.toLongArray())
    }

    println(result)

}

Measured memory_bytes: 148328
#include<stdio.h>
int main(void){
  int n;
  scanf("%d",&n);
  long a[n+1],b[n];
  for(int i=0;i<n+1;i++){
    scanf("%ld",&a[i]);
  }
       
   for(int i=0;i<n;i++){
    scanf("%lld",&b[i]);
  }
  long count=0;
  for(int i=0;i<n;i++){//333
    if(a[i]>0&&a[i+1]>0){//どっちも生き残ってる時 //22
    if(b[i]>=a[i]+a[i+1]) {//どっちも倒せる時
      count+=a[i]+a[i+1]; 
      a[i+1]=0;
      a[i]=0;
    }
     else if(a[i]<=b[i]){//iだけ倒せる時
       //printf("%d番目を撃破\n",i+1);
       count+=a[i];
       a[i+1]-=b[i]-a[i]; //残ったポイントをi+1へ注ぐ
       count+=b[i]-a[i];
    }
      else count+=b[i];
    }//22
     else if(a[i]<=0){//i+1だけ生き残ってる時  //44
        if(b[i]>=a[i+1]){
		count+=a[i+1];
          a[i+1]=0;
        }
        else{ count+=b[i];
             a[i+1]-=b[i];
            }
      }//44
                     
  }//333
  printf("%ld",count);
  return 0;
  }

Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18
#define PI 3.1415926535

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


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

int main(){
   int N,X; cin >> N >> X;
   vector<int> x(N+1);
   rep(i,N){
     cin >> x[i];
   }
   x[N] = X;
   sort(x.begin(),x.end());
   vector<int> x2(N);
   rep(i,N){
     x2[i] = x[i+1]-x[i];
   }
   rep(i,N-1){
     ll m = GCD(x2[i+1],x2[i]);
     x2[i+1] = m;
   }
   cout << x2[N-1] << endl;
}
   

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApp14
{
    class Program
    {
        static void Main(string[] args)
        {
            var solver = new Solver();
            solver.Calc();
        }
    }

    public class Solver
    {
        public class TXY
        {
            public int T;
            public int X;
            public int Y;
        }

        public void Calc()
        {
            var HA = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

            Console.WriteLine(Math.Ceiling((double)HA[0] / HA[1]));
        }
    }
}

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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

// bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
//     return arg1.first > arg2.first;
// }

vector<ll> ans(2e5+5, 0);
vector<vector<int>> g(2e5+5);
vector<int> color(2e5+5, 0);

void dfs(int p) {
    for(auto u:g.at(p)) {
        if(color.at(u)) continue;
        color.at(u) = 1;
        ans.at(u) += ans.at(p);
        dfs(u);
    }
}

int main(void) {
    int n, q;
    cin >> n >> q;

    int a, b;
    for(int in=0;in<n-1;in++) {
        cin >> a >> b; a--; b--;
        g.at(a).push_back(b);
        g.at(b).push_back(a);
    }

    ll p, x;
    for(int iq=0;iq<q;iq++) {
        cin >> p >> x; p--;
        ans.at(p) += x;
    }

    color.at(0) = 1;
    dfs(0);

    for(int in=0;in<n;in++) {
        cout << ans.at(in) << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 26096
import heapq

N, M = map(int, input().strip().split())

A = {}

for i in range(N):
  a, b = map(int, input().strip().split())
  if a not in A: A[a] = []
  A[a].append(b)

total = 0
days = []
for i in range(1, M + 1):
  if i in A:
    for a in A[i]:
      heapq.heappush(days, -a)
  if len(days) > 0:
    total += - heapq.heappop(days)

print(total)


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "YES" << '\n'; exit(0); }
inline void no() { cout << "NO" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x >= y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x <= y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int n, k;
  cin >> n >> k;
  if (n + 1 >= k * 2) yes(); no();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define PI 3.1415926535897932384
int main()
{
	double a,b,h,m,s,ans;
	cin>>a>>b>>h>>m;
	s=fabs((PI/6*h+PI/360*m)-(PI/30*m));
	ans=a*a+b*b-2*a*b*cos(s);
	ans=sqrt(ans);
	cout<<fixed<<setprecision(10)<<ans;
	return 0;
}

Measured memory_bytes: 4088
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(x) cout << fixed << setprecision(x);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

int main(){
  ll n; cin >> n; vl ai(n+1); vl bi(n); ll sum = 0;
  rep(i,n+1){ ll x; cin >> x; ai[i] = x; }
  rep(i,n){ ll x; cin >> x; bi[i] = x; } 
  
  for(ll i=0; i < n; i++){
    if(ai[i] >= bi[i]){
      sum += bi[i];
      ai[i] -= bi[i];
      bi[i] = 0;
    }
    else{
      sum += ai[i];
      bi[i] -= ai[i]; 
      ai[i] = 0; 
      if(ai[i+1] >= bi[i]){
        sum += bi[i];
        ai[i+1] -= bi[i];
        bi[i] = 0;
      }
      else{
        sum += ai[i+1];
        bi[i] -= ai[i+1];
        ai[i+1] = 0;
      }
    }
    
  }
  
  
  cout << sum << endl;
}
    

Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>  // std::unique
#include <cmath>
using namespace std;

using ll = long long;
constexpr auto PrimeBigNum10_9_7 = 1000000007;

// 素数判定
template <typename T>
bool IsPrimeNumber(T value) {

	for (int i = 2; i * i <= value; ++i) {
		if ((value % i) == 0) {
			return true;
		}
	}
	return false;
}

// 桁数判定
template <typename T>
T GetFigureLength(T value) {
	T figure = 1;
	while (value >= 10) {
		value /= 10;
		++figure;
	}
	return figure;
}

// 素因数分解結果
template <typename T>
map<T, T> GetPrimeFactorize(T value) {

	map<T, T> res;

	for (T i = 2; i * i <= value; ++i) {
		if ((value%i) != 0)	continue;

		T count = 0;
		while ((value % i) == 0) {
			value /= i;
			++count;
		}

		res[i] = count;
	}

	if (value != 1) {
		res[value] = 1;
	}
	return res;
}

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

	map<ll, ll> answers;

	ll resultCount = 0;

	for (int i = 0; i < n; ++i) {
		ll a;
		cin >> a;

		resultCount += answers[i - a];
		answers[i + a]++;
	}
	



	auto output = resultCount;
	cout << output;

	return 0;
}


Measured memory_bytes: 26196
#include<iostream>
#include<queue>
#include<map>
#include<unordered_map>

using namespace std;

int main(){
    int n,k;
    cin >> n>>k;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a,a+n);
    long long int ans=0;
    for(int i=0;i<k;i++){
        ans+=a[i];
    }
    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL gcd(LL a,LL b){return b==0?a:gcd(b,a%b);}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL N,M,a[100010];
int main()
{
    cin >> N >> M;
    LL g = 1,ok = 1;
    for(int i = 1;i<=N;++i)
    {
        cin >>a[i];
        a[i]/=2;
        if(i==1) g=a[i];
        else g =lcm(g,a[i]);
        if(g>M) ok = 0;
    }
    for(int i = 1;i<=N;++i)
    {
        if(g/a[i]%2==0)
        {
            ok = 0;
            break;
        }
    }
    if(!ok)
    {
        cout << 0 << endl;
        return 0;
    }
    LL ans = 0;
    LL b = M/g;
    ans = b/2;
    if(b&1) ans++;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define  DESC std::greater<int>() //sort 3rd arg


int main()
{
	const ll MAX = 1e5 + 1;



	ll n;
	cin >> n;
	vector<ll>a(MAX);
	REP(i, n) {
		ll tmp;
		cin >> tmp;
		a[tmp]++;
	}
	ll tot = 0;
	for (ll j = 1; j < MAX; j++) {
		tot += a[j] * j;
	}

	ll q;
	cin >> q;



	REP(i, q) {
		int b, c;
		cin >> b >> c;

		//変わり得る部分を一度totから引く
		tot -= b * a[b];
		tot -= c * a[c];

		//置き換えの実行
		a[c] += a[b];
		a[b] = 0;

		//変更分合計を変える <-　ここがポイント
		tot += b * a[b];
		tot += c * a[c];
		
		cout << tot << endl;
	}



	return 0;
}



Measured memory_bytes: 4044
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<typeinfo>
#include<complex>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)
const long double PI = (acos(-1));

int main() {

	int n;
	cin >> n;

	n %= 10;

	if (n == 3) cout << "bon" << endl;
	else if (n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
	else cout << "hon" << endl;

	return 0;
}

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


public class Main {
    static long mod = 1000000000+7;
    static long n,a,b,k;
    public static void main(String[] args) throws Exception{
        Scanner sc = new Scanner(System.in);
        //BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        //String[] buf = reader.readLine().split(" ");
        String s = sc.next();
        int a = Integer.parseInt(s.substring(0,2));
        int b = Integer.parseInt(s.substring(2,4));
        boolean YYMM = false, MMYY = false;
        if(a<=12&&a>=1) MMYY = true;
        if(b<=12&&b>=1) YYMM = true;
        String ans;
        if(YYMM&&MMYY) ans = "AMBIGUOUS";
        else if(YYMM&&(!MMYY)) ans = "YYMM";
        else if((!YYMM)&&(MMYY)) ans = "MMYY";
        else ans = "NA";
        System.out.println(ans);
    }

}



Measured memory_bytes: 25044
#include<iostream>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
int main()
{
    ll n, x=1, y=1, z=1;
    cin >> n;
    for(int i=1;i<=n;i++)
    {
        x*=10,y*=9,z*=8;
        x%=MOD,y%=MOD,z%=MOD;
    }
    x -= y;
    x = (x+MOD)%MOD;
    x -= y;
    x = (x+MOD)%MOD;
    x +=z;
    x %= MOD;
    x = (x+MOD)%MOD;
    cout << x << endl;
}

Measured memory_bytes: 3160