akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define LL       long long
#define DS       pair<int, int>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        cout << "x";
    }
    puts("");
    return 0;
}


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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> vec(n);
  rep(i, n)
    cin >> vec[i];
  sort(vec.begin(), vec.end());

  int ans = 0;
  rep(i, k)
    ans += vec[i];
  cout << ans << endl;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#include <limits>
#include <iomanip>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    vector<int> s(N);
    ll total=0;
    for(int i=0;i<N;i++){
        cin >> s[i];
        total +=s[i];
    }

    int min=0;

    bool frg= false;
    for(int i=0;i<N;i++){
        if((s[i] % 10)!=0){
            min=s[i];
            frg = true;
            break;
        }
    }
    if(frg){
        for(int i=0;i<N;i++){
            if(((s[i]%10)!=0)&&(min > s[i])){
                min = s[i];
            }
        }
    }

    if((total%10)!=0){
        cout << total <<endl;
    }
    else{
        if(frg){
            cout << total - min << endl;
        }
        else{
            cout << 0 << endl;
        }
    }
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int a, b, c;

int main() {
	cin >> a >> b >> c;
	if (b-a == c-b) cout << "YES" << ln;
	else cout << "NO" << ln;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define F first
#define S second
#define ll long long
#define pb push_back
#define mp make_pair
#define Fr(i,a,b) for(int i=a;i<=b;i++)
#define RF(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<ll,int>
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define vpii vector<pii>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a,b,c;
 	cin>>a>>b>>c;
  	cout<<max(0,(c-a+b))<<endl;

    return 0;
} 

Measured memory_bytes: 256
// 5/4
// 過去問ガリガリ

#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>;
using Graph = vector<vector<int>>;

int main() {
    int N, K;
    cin >> N >> K;

    int ans = 0;
    
    while (N) {
        N /= K;
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
void main() {
	auto A = ri, B = ri;
	auto v = [A, B].sort().array;
	if(v == [1, 2]) writeln(3);
	else if(v == [1, 3]) writeln(2);
	else writeln(1);
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
	char a[11];
	scanf("%s",a+1);
	int a_len=strlen(a+1);
	if(a_len%2==1)
	{
		printf("No\n");
		return 0;
	}
	for(int i=1;i<=a_len;i++)
		if(i%2)
		{
			if(a[i]!='h')
			{
				printf("No\n");
				return 0;
			}
		}
		else
			if(a[i]!='i')
			{
				printf("No\n");
				return 0;
			}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  long long a,b;
  cin>>a>>b;
  if((a+b)%2==0)
  {
    cout<<(a+b)/2<<endl;
  }
  else
  {
    cout<<"IMPOSSIBLE"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,N;
  string ans="Yes";
  cin >> H >> N;
  for(int i=0; i<N; i++){
  	int A;
    cin >> A;
    H-=A;
    if(H<0)break;
  }
  if(H>0)ans="No";
  cout << ans << endl;
}

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

// #define  part ..
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end() 
#define mod 1000000007
#define maxx 200006
#define ll long long 
#define quick    ios_base::sync_with_stdio(NULL),cin.tie(0);
#define listll vector< long long > 
#define listi vector< int> 
#define pii   pair<int , int> 
#define pll pair<long long , long long > 
#define minheap priority_queue<long long , vector< long long >, greater<long long > >
#define rep(i,a,b) for(int i=a;i<b;i++)
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

// end of #define 

// define globals ...


//write function from here ...



int Main(){


int n;
cin>>n;
double d ;;
cin>>d;
int cnt=0;
for(int i=0;i<n;i++)
{
	double a,b;
	cin>>a>>b;
	double dis = sqrt(a*a+b*b);
	if(dis<=d)
	{
		cnt++;
	}
}

		
		cout<<cnt<<endl;



return 0;

}

















int main(){
 quick;
int t =1; 
//cin>>t;
while(t-- )
 Main();

 return 0;


}


Measured memory_bytes: 3860
N = int(input())

S = []

for _ in range(N):
	s = input()
	S.append(s)

S.sort()

A = [1]

for i in range(N):
	if i == 0:
		continue
	else:
		if S[i] == S[i-1]:
			A.append(A[i-1] + 1)
		else:
			A.append(1)

M = 0

for i in range(N):
	if A[i] > M:
		M = A[i]

for i in range(N):
	if A[i] == M:
		print(S[i])


Measured memory_bytes: 83672
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
 
const int maxn = 2e5 + 20;
 
int n;
string s, t;
int ans = 0, ss = s.size(), tt = t.size(), boz;

bool cmp (string s, string t)
{
	return s + t > t + s;
}
	
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> s >> t;
	ss = s.size(), tt = t.size();
	if (cmp (s, t))
		swap (s, t), swap (ss, tt);
 
	for (int i = 0; i * ss <= n; i++)
		if ( (n - i * ss) % tt == 0)
			ans = i, boz = (boz == -1 ? i : boz);
	string res1, res2;
	
	for (int i = 0; i < ans; i++)
		cout << s;	
	n -= ss * ans;
	for (int i = 0; i * tt < n; i++)
		cout << t;
	cout << endl;
	return 0;
}

Measured memory_bytes: 1684
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#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 FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll n, s[310000], r[310000][70], ans;
int main() {
	cin >> n;
	REP(i, n)cin >> s[i];
	REPR(i, n - 1) {
		REP(j, 70) r[i][j] += r[i + 1][j];
		ll now = s[i], pos = 0;
		while (now > 0) {
			if(now % 2 == 1) r[i][pos]++;
			now /= 2;
			pos++;
		}
	}
	REP(i, n) {
		REP(j, 61) {
			if ((1ll << j) & s[i]) ans += (1ll << j) % MOD * (n - i - 1 - r[i + 1][j]) % MOD;
			else ans += (1ll << j) % MOD * r[i + 1][j] % MOD;
			ans %= MOD;
		}
	}
	cout << ans << endl;
}


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

typedef long long ll;

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

    int k, x;
    cin>>k>>x;

    int a = max(-1000000, x-k+1);
    int b = min (1000000, x+k-1);

    for (int i=a;i<=b;++i) cout<<i<<" ";
    cout<<endl;
    
    return 0;
}

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

enum Type {
	R, IN, L
};

typedef struct Tree {
	int id, deg, dep, hei;
	Tree *p = NULL;
	Tree *l = NULL;
	Tree *r = NULL;
	Tree *s = NULL;
	Type type;

	bool operator<(const Tree &right) {
		return id < right.id;
	}
} Tree;

Tree tree[32];

string conv(Type t) {
	switch (t) {
	case R:return "root"; break;
	case IN:return "internal node"; break;
	case L:return "leaf"; break;
	default:break;
	}
	return "";
}

int rec1(Tree *par, int d = 0) {
	int r,md = d;
	par->dep = d;
	if (par->l != NULL) {
		par->type = IN;
		r = rec1(par->l, d + 1);
		if (r > md) md = r;
		if (par->r != NULL) {
			r = rec1(par->r, d + 1);
			if (r > md) md = r;
			par->deg = 2;
		}
		else {
			par->deg = 1;
		}
	}
	else if (par->r != NULL) {
		par->type = IN;
		r = rec1(par->r, d + 1);
		if (r > md) md = r;
		par->deg = 1;
	}
	else {
		par->type = L;
		par->deg = 0;
	}
	if ((par->hei = md - par->dep) == md) {
		par->type = R;
	}
	return md;
}

int main(){
	int n, id, l, r;
	int tc = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> id >> l >> r;
		tree[id].id = id;
		if(l >= 0)
			tree[id].l = &tree[l];
		if (r >= 0)
			tree[id].r = &tree[r];
	}
	for (int i = 0; i < n; i++) {
		if (tree[i].l != NULL) {
			tree[i].l->p = &tree[i];
			if (tree[i].r != NULL) {
				tree[i].l->s = tree[i].r;
				tree[i].r->s = tree[i].l;
			}
		}
		if (tree[i].r != NULL) {
			tree[i].r->p = &tree[i];
		}
	}
	for (int i = 0; i < n; i++) {
		if (tree[i].p == NULL) {
			rec1(&tree[i]);
			break;
		}
	}
	for (int i = 0; i < n; i++) {
		cout << "node " << tree[i].id << ": parent = " << (tree[i].p != NULL ? tree[i].p->id : -1) << ", sibling = " << (tree[i].s != NULL ? tree[i].s->id : -1)
			<< ", degree = " << tree[i].deg << ", depth = " << tree[i].dep << ", height = " << tree[i].hei << ", " << conv(tree[i].type) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3176
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a[21][200010];
ll d[21][200010];
ll dp[200010];
ll x[200010];
int main()
{
	ll n;
	scanf("%lld", &n);
	for(ll i = 1; i <= n; ++ i)
		scanf("%lld", &x[i]);
	for(ll i = 1; i <= n; ++ i)
		for(ll j = 0; j <= 20; ++ j)
			a[j][i] = x[i] >> j & 1;
	for(ll i = 1; i <= n; ++ i)
		for(ll j = 0; j <= 20; ++ j)
			if(a[j][i] == 1)
				d[j][i + 1] = i;
			else
				d[j][i + 1] = d[j][i];
	memset(dp, 127, sizeof(dp));
	for(ll i = 1; i <= n; ++ i)
		for(ll j = 0; j <= 20; ++ j)
			if(a[j][i] == 1)
				dp[i] = min(dp[i], i - d[j][i]);
			else
				dp[i] = min(dp[i], i - d[j][d[j][i]]);
	ll Ans = 0;
	for(ll i = 1; i <= n; ++ i)
		Ans += dp[i];
	printf("%lld", Ans);
	return 0;
}

Measured memory_bytes: 68992
#include<bits/stdc++.h>
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repr(i,n) for(lint i=(lint)(n);i>0;--i)
#define reps(i,a,b) for(lint i=a;i<=(lint)(b);i++)
typedef long long lint;
typedef long double ld;
using namespace std;

int main(){
	lint N;
    cin >> N;
    string *u = new string[N];
    ld *x = new ld[N];
    rep(i,N) cin >> x[i] >> u[i];
    ld sum = 0.0;
    rep(i,N) {
        if(u[i]==string("JPY")) sum+=x[i];
        if(u[i]==string("BTC")) sum+=x[i]*380000.0;
    }
    cout << sum << endl;
	return 0;
}


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

int main()
{
    int N, AC=0, WA=0, TLE=0, RE=0;
    cin >> N;
    string entr;
    if (N<=0 || N>100000){return 0;}
    for (int i=0; i<N ; i++){
        cin >> entr;
        if (entr == "AC") {
            AC ++;
        }
        if (entr == "WA"){
            WA++;
        }
        if (entr == "TLE"){
            TLE++;
        }
        if (entr == "RE"){
            RE++;
        }
    }
    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;
    return 0;
}


Measured memory_bytes: 3596
import java.util.*;

/**
 * Main
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int k[] = new int[N];
		Boolean allZero = false;
		int count = 0;

		for (int i = 0; i < N; i++) {
			k[i] = sc.nextInt();
		}

		while (!allZero) {
			allZero = true;
			int now = 0;
			int subcount = 0;
			while (now < N) {
				if (k[now] > 0) {
					k[now] -= 1;
					subcount++;
					allZero = false;
				} else if (k[now] <= 0 && subcount == 0) {
				} else {
					count++;
					subcount = 0;
				}
				now++;
			}
			if (subcount != 0) {
				count++;
			}
		}

		sc.close();
		System.out.println(count);
	}
};



Measured memory_bytes: 36080
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int C[VMAX+1];
void CountingSort(short*,short*,int);

int main(){
  int i,j,n;
  unsigned short *A,*B;

  scanf("%d",&n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=0;i<n;i++){
    scanf("%d",&A[i+1]);
  }
  CountingSort(A,B,n);
  for(i=1;i<=n;i++){
    printf("%d",B[i]);
    if(i != n)printf(" ");
  }
  printf("\n");
  return 0;
}

void CountingSort(short A[],short B[],int n){
  int i,j;
  for(i=0;i<=VMAX;i++){
    C[i] = 0;
  }
  for(j=1;j<=n;j++){
    C[A[j]]++;
  }
  for(i=1;i<=VMAX;i++){
    C[i] = C[i] + C[i-1];
  }
  for(j=n;j>=1;j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}



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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

struct UF {
    vector<ll> par;
    vector<ll> siz;

    UF(ll N) : par(N), siz(N, 1LL) {
        rep (i, N) {
            par[i] = i;
        }
    }

    void init(ll N) {
        par.resize(N);
        siz.assign(N, 1LL);
        rep (i, N) {
            par[i] = i;
        }
    }

    ll root(ll x) {
        if (par[x] == x) {
            return x;
        }
        return par[x] = root(par[x]);
    }

    bool unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) {
            return false;
        }
        if (siz[x] < siz[y]) {
            swap(x, y);
        }
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool same(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, M;
    cin >> N >> M;

    vector<ll> A(M), B(M);
    rep (i, M) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }

    vector<ll> ans(M);
    ans[M-1] = N*(N-1)/2;

    UF uf(N);
    for (ll i = M-1; i > 0; i--) {
        if (!uf.same(A[i], B[i])) {
            ans[i-1] = ans[i] - uf.size(A[i])*uf.size(B[i]);
            uf.unite(A[i], B[i]);
        } else {
            ans[i-1] = ans[i];
        }
    }

    rep (i, M) {
        cout << ans[i] << endl;
    }
    return 0;
}

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

int main() {
  int A,B;
  cin >> A >> B;

  int X = 0;
  
  for(int i = A; i <= B; i++){

    //debug
//    cout << i << endl;
    
    //5桁目と1桁目が一緒の場合
	if (i / 10000 == i % 10){
     //4桁目と2桁目が一緒の場合
     if (((i % 10000)/1000) == ((i % 100)/10)){
		++X;
        //debug
//        cout << i << endl;

     
     }      
    }
  }
    
  cout << X << endl;
}


Measured memory_bytes: 3620
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
#include<iomanip>

using namespace std;

using vec3d = vector<vector<vector<double>>>;
vec3d dp;
int n;

double recv(int i, int j, int k) {
    // DDD(i, j, k);
    if (dp[i][j][k] >= 0) return dp[i][j][k];
    double ans = 0;
    if (i > 0) ans += recv(i - 1, j, k) * i;
    if (j > 0) ans += recv(i + 1, j - 1, k) * j;
    if (k > 0) ans += recv(i, j + 1, k - 1) * k;
    ans += n;
    ans /= i + j + k;
    dp[i][j][k] = ans;
    return ans;
}


int main()
{
    cin >> n;
    dp = vec3d(n + 1, vector<vector<double>>(n + 1, vector<double>(n + 1, -1)));
    dp[0][0][0] = 0;
    int cnt[] = {0, 0, 0, 0};
    REP(i, n) {
        int ai;
        cin >> ai;
        cnt[ai]++;
    }
    cout << fixed << setprecision(10) << recv(cnt[1], cnt[2], cnt[3]) << endl;
}


Measured memory_bytes: 219008
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int f(int x) {
    int ct = 0;
    while (x % 2 == 0) {
        x >>= 1;
        ct++;
    }
    return ct;
}

int main() {
    int n; cin >> n;
    vint a(n);
    int ans = inf;
    rep(i,n) {
        int x; cin >> x;
        ans = min(ans,f(x));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int f(ll n) {
	int ret = 0;
	while(n > 0) n /= 10, ret++;
	return ret;
}

int main(){
	ll a;
	cin >> a;
	int ans = 1e9;
	for(int i = 1; (ll)i*i <= a; i++) {
		int tmp = 0;
		if(a % i != 0) continue;
		tmp = max(f(i), f(a/i));
		ans = min(ans, tmp);
	}
	cout << ans <<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string a;
  int f=0;
  cin >> a;
  for(int i=0;i<a.size();i++){
    if(f==0&&a[i]=='C'){
      f=1;
    }
    else if(f==1&&a[i]=='F'){
      f=2;
      break;
    }
    
  }
  if(f==2)cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 384
import sys
input=sys.stdin.readline
n,W=map(int,input().split())
w_1,v=map(int,input().split())
w_list=[[] for i in range(4)]
w_list[0].append(v)
for i in range(n-1):
    w,v=map(int,input().split())
    w_list[w-w_1].append(v)
w_cum=[[] for i in range(4)]
for i in range(4):
    w_list[i].sort(reverse=True)
    Sum=0
    w=w_1+i
    for j in range(len(w_list[i])):
        w_cum[i].append((Sum,w*j))
        Sum+=w_list[i][j]
    w_cum[i].append((Sum,w*len(w_list[i])))
a,b,c,d=len(w_cum[0]),len(w_cum[1]),len(w_cum[2]),len(w_cum[3])
ans=0
for h in range(a):
    for i in range(b):
        for j in range(c):
            for k in range(d):
                weight=w_cum[0][h][1]+w_cum[1][i][1]+w_cum[2][j][1]+w_cum[3][k][1]
                if weight<=W:
                    temp=w_cum[0][h][0]+w_cum[1][i][0]+w_cum[2][j][0]+w_cum[3][k][0]
                    ans=max(ans,temp)
print(ans)
                
        








Measured memory_bytes: 43116
n,m=map(int,input().split())
l=[]
for _ in range(m):
    l.append(list(map(int,input().split())))
a=[0]*(n+1)
a[1]=1
c=[1]*(n+1)
for i in range(m):
    c[l[i][0]]-=1
    c[l[i][1]]+=1
    if a[l[i][0]]:
        a[l[i][1]]=1
    if c[l[i][0]]==0:
        a[l[i][0]]=0
print(a.count(1))

Measured memory_bytes: 28836
#include <stdio.h>
#include <math.h>
double menseki(double x1,double y1,double x2,double y2,double x3,double y3){
    double a,b,c,z;
    a=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    b=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
    c=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
    z=(a+b+c)/2;
    return sqrt(z*(z-a)*(z-b)*(z-c));
    }
    
    int main(void){
        double x1,y1,x2,y2,x3,y3;
        double s=0;
        scanf("%lf,%lf",&x1,&y1);
        scanf("%lf,%lf",&x2,&y2);
        while (scanf("%lf,%lf",&x3,&y3)==2) {
        s+=menseki(x1,y1,x2,y2,x3,y3);
        x2=x3;
        y2=y3;
        }
        printf("%.6lf\n", s);
        return 0;
 }


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

using namespace std;
typedef long long LL;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i,N) cin >> A[i];
  int ans=A[0];
  rep(i,N-1) ans=__gcd(ans,A[i+1]);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (int)n;i++)
#define repb(i,n) for(int i = (int)n;i >= 0;i--)
#define reps(i,m,n) for(int i = (int)m;i < (int)n;i++)
#define repsb(i,m,n) for(int i = (int)m;i >= (int)n;i--)
#define SORT(v,n) sort(v,v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
#define ll long long int
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1;} return 0;}
using namespace std;
int main(int argc, char const *argv[]) {
    int n,ac=0,uc=0;
    bool f = true;
    cin >> n;
    string s;
    rep(i,n){
        cin >> s;
        if(s=="A")
            ac++;
        else
            uc++;
        if(ac<uc){
            f = false;
        }
    }
    if(ac==uc&&f){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

    return 0;
}



Measured memory_bytes: 3140
# 入力：祀られている石の個数
n = gets.to_i

# 入力：祀られている石の色（赤：R、白：W)
ary=gets.chomp.split("").map(&:to_s);

# 仕切りがどの石より左側にあるとき、仕切りより右にある赤い石の総数
right_r = ary.count('R')

# この初期状態のとき、仕切りより左に白い石はない（尚、赤い石もない）
left_w = 0

# 答えの候補を記録する配列
ans = []

# 仕切りが左端にあるときの、答えの候補を配列ansに記録する
ans[0] = right_r

# 仕切りを石１つ分ずつ右にずらす
n.times do |i|
  # 仕切りがまたいだ石の色に応じて、right_r, left_wの値を更新する
  if ary[i] == 'R'
    # 赤い石が仕切りの左に移ってしまう場合
    right_r -= 1
  else
    # 白い石が仕切りの左に来る場合
    left_w += 1
  end
  # 答えの候補を配列ansに記録する
  ans[i+1] = [right_r, left_w].max
end

# 答えの候補のうち最小のものを出力
puts ans.min

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

string cmp(string a, string b) {
    if (sz(a) < sz(b)) return "LESS";
    if (sz(b) < sz(a)) return "GREATER";
    if (a == b) return "EQUAL";
    if (a < b) return "LESS";
    if (b < a) return "GREATER";
    return "-1";
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    string A,B; cin >> A >> B;

    cout << cmp(A,B) << "\n";

}



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

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

    int n, m;
    cin >> n >> m;

    vector<vector<int>> g(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int res = 0;
    vector<int> order(n);
    rep(i, n) order[i] = i;


    do{
        if(order[0] != 0) break;
        bool flg = true;
        rep(i, n-1){
            bool found = false;
            for(int nv: g[order[i]]){
                if(nv == order[i+1]) found = true;
            }
            if(!found) flg = false;
        }

        if(flg) ++res;
    } while(next_permutation(order.begin(), order.end()));

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int n,m,s[10],c[10],a[10],mn=1,mx=1;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i) scanf("%d%d",&s[i],&c[i]);
	for(int i=1;i<n;++i) mn*=10;
	mx=mn*10;
	if(n==1) mn=0;
//	printf("%d %d\n",mn,mx);
	for(int i=mn;i<mx;++i) {
		int tmp=i;
		for(int j=1;j<=n;++j) a[n-j+1]=tmp%10,tmp/=10;
//		printf("%d\n",i);
		bool flag=true;
		for(int j=1;j<=m;++j)
			if(a[s[j]]!=c[j]) {
				flag=false;
				break;
			}
		if(flag) {
			printf("%d",i);
			return 0;
		}
	}
	printf("-1");
	return 0;
}

Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;

const long long MOD = 1000000007;

int main(){
    string S;
    cin >> S;
    if(S.at(S.size() - 1) == 's'){
        S += "es";
        cout << S << endl;
        return 0;
    }
    else S += 's';
    cout << S << endl;
}

Measured memory_bytes: 3580
N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
A.sort()
A.reverse()
total = 0
Flag = True
for i in A:
    total += i
for i in range(M):
    if A[i]*4*M < total:
        Flag = False
if Flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

typedef double ld;
typedef long long ll;
typedef pair<int,int> pii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

int main(){ _

	int x;
	cin >> x;

	cout << (x < 1200 ? "ABC" : "ARC") << endl;

	return 0;
}


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


int main() {
    int a,b,c,d,e,k;
    cin>>a>>b>>c>>d>>e>>k;
    cout << (e-a>k?":(":"Yay!") <<endl;
}


Measured memory_bytes: 256
using System;


namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            double PI = 3.14159265358979323846264338327950;
            string x = Console.ReadLine();
            //y[]はchar
            //切り分け
            string[] y = x.Split();
            //int型に直す
            double a = int.Parse(y[0]);
            double b = int.Parse(y[1]);
            double h = int.Parse(y[2]);
            double m = int.Parse(y[3]);

            double hh, mm;
            double kakudo;
            double rad;
            double c, cc;

            hh = 30 * h + m / 2;
            mm = 6 * m;

            if (Math.Abs(hh-mm) >=  180)
            {
                kakudo = 360 - Math.Abs(hh-mm);
            }
            else {
                kakudo = Math.Abs(hh-mm);
            }
            rad = kakudo * PI / 180;          
            
            //Console.WriteLine(kakudo);
            //Console.WriteLine(rad);

            cc = b * b + a * a - 2 * a * b * Math.Cos(rad);
            c = Math.Sqrt(cc);

            string text = c.ToString("F20");
            Console.WriteLine(text);
        }
    }
}

Measured memory_bytes: 18808
//Solution by Tima
#include <bits/stdc++.h>

#define f first
#define s second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define vi vector <int>
#define ld long double
#define pii pair<int, int>
#define y1 sda
using namespace std;    
const int N = int(3e5) + 12, mod = int(1e9)  + 7; 

char s[N];
int n;
 
int main () {
	scanf("%s",s + 1);
	n = strlen(s + 1);
	int ans = 0;
	string last = "";
	int i = 1;
	while(i <= n){
		string cur = "";
		cur += s[i];
		if(cur != last){
			i++;
			ans++;
		}
		else{
			if(i + 1 <= n){
				cur += s[i + 1];
				i += 2;
				ans++;
			}
			else i++;
		}
		last = cur;
	}
	cout << ans;
 
return 0;
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll L,R;
  cin >> L >> R;
  VLL x;
  for(ll i=L; i < min((L+2019LL*3),R+1LL); i+=1LL){
    x.push_back((i%2019LL));
  }
  sort(x.begin(),x.end());
  ll ans = 1e9;
  rep(i,x.size()){
    FOR(j,i+1,x.size()){
      ans = min((x[i]*x[j])%2019,ans);
    }
  }
  cout << ans  << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    ll sum = 0;
    for (int i = 1; i <= N; i++) {
        string s = to_string(i);
        ll t = 0;
        for (int j = 0; j < (int)s.size(); j++) {
            t += (ll)(s[j] - '0');
        }
        if (A <= t && t <= B) sum += i;
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
INF = 10**10

def merge(A, l, mid, r):
    a1 = A[l:mid] + [[None, INF]]
    a2 = A[mid:r] + [[None, INF]]
    i = j = 0
    for k in range(l, r):
        if a1[i][1] <= a2[j][1]:
            A[k] = a1[i]
            i += 1
        else:
            A[k] = a2[j]
            j += 1

def merge_sort(A, l, r):
    if l + 1 >= r:
        return
    mid = (l + r) // 2
    
    merge_sort(A, l, mid)
    merge_sort(A, mid, r)
    
    merge(A, l, mid, r)
    
    
def quick_sort(A, l, r):
    if l < r:
        #mid = (l + r) // 2
        mid = r
        pivot = A[mid][1]
        A[mid], A[r] = A[r], A[mid]
        i = 0
        for j in range(l, r):
            if A[j][1] <= pivot:
                A[l+i], A[j] = A[j], A[l+i]
                i += 1
        A[l+i], A[r] = A[r], A[l+i]
        
        quick_sort(A, l, l+i-1)
        quick_sort(A, l+i+1, r)

n = int(input())
cards = [input().split() for _ in range(n)]

for card in cards:
    card[1] = int(card[1])

confirm_cards  = cards[:]

quick_sort(cards, 0, n - 1)
merge_sort(confirm_cards, 0, n)

if cards == confirm_cards:
    print('Stable')
else:
    print('Not stable')
    
for card in cards:
    print(*card)

#print('-----')
#for card in confirm_cards:
#    print(*card)
    
        


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

int main() {
    int n, i, num = 0;
    string a;
    cin >> n;

    for(i = 0; i < n; i++) {
        cin >> a;
        if(a == "Y") 
            num = 1; 
    }   

    if(num)
        cout << "Four" << endl;
    else
        cout << "Three" << endl;
}

Measured memory_bytes: 256
ABCD = gets.chomp

str = ''
(2 ** 3).times do |bit|
  sum = ABCD[0].to_i
  3.times do |i|
    num = ABCD[i + 1].to_i
    if bit[i] == 0
      num *= -1
    end
    sum += num
  end
  if sum == 7
    3.times do |i|
      str += "#{ABCD[i]}"
      if bit[i] == 0
        str += '-'
      else
        str += '+'
      end
    end
    str += "#{ABCD[3]}=7"
    break
  end
end
puts str


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <tuple>
#include <map>
#include <iomanip>
#include <math.h>
using namespace std;
typedef long long ll;
 
bool vis[100010];
int d[100010];
int mx, val;
vector<int> G[100010];

void dfs_deep(int k, int dep) {
    vis[k] = 1;
    d[k] = dep;
    for (auto& i : G[k]) {
        if (!vis[i]) dfs_deep(i, dep + 1);
    }
    mx = max(mx, dep);
}
void dfs_deep2(int k, int dep, int ok_depth) {
    vis[k] = 1;
    mx = max(mx, d[k]);
    bool ii = 1;
    for (auto& i : G[k]) {
        if (!vis[i] && d[i] >= ok_depth) {
            dfs_deep2(i, dep + 1, ok_depth);
            ii = 0;
        }
    }
    //if (!ii | dep != ok_depth) mx = max(mx, dep);
}

void check(int de, int at, int ok) {
    if (at == ok) {
        val = de;
        return;
    }
    for (auto& i : G[de]) {
        if (d[i] == at - 1) check(i, at - 1, ok);
    }
}


int main() {
    int n, t, a;
    cin >> n >> t >> a;
    t--;  a--;
    for (int i = 0 ; i< n - 1; i++) {
        int x, y;
        cin >> x >> y;
        G[--x].push_back(--y);
        G[y].push_back(x);
        vis[i] = 0;
    }
    vis[n - 1] = 0;
    //cout << "ok" << endl;
    
    dfs_deep(a, 0);
    /*
    for (int i = 0; i < n; i++) cout << d[i];
    cout << endl;*/
    int ok_depth = d[t] - (d[t] - 1) / 2;
    check(t, d[t], ok_depth);
    int ok_v = val;
    for (int i = 0; i < n; i++) {
        if (ok_depth > d[i]) vis[i] = 1;
        else vis[i] = 0;
    }
    //cout << ok_depth << endl;

    /*for (int i = 0; i < n; i++) cout << vis[i];
    cout << endl;*/
    mx = 0;
    dfs_deep2(ok_v, ok_depth, ok_depth);

    /*for (int i = 0; i < n; i++) cout << d[i];
    cout << endl;*/

    cout << mx - 1 << endl;
    
}

Measured memory_bytes: 10112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc116_c.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  set<int> c;
  vector<int> h(N);
  rep(i, N) {
    int _h;
    cin >> _h;
    h[i] = _h;
    c.insert(_h);
  }

  bool ok = false;
  int min = 0;
  int _max = -1;
  ll ans = 0;
  auto jt = c.begin();
  bool fin = false;

  while (!fin) {
    fin = true;
    int tmp = *jt - min;
    min = *jt;
    jt++;

    bool del = false;
    rep(i, N) {
      if (h[i] != 0) {
        if (!del) {
          ans += tmp;
          del = true;
        }
        h[i] -= tmp;
      } else {
        del = false;
      }
      fin &= h[i] == 0;
    }
  }

  cout << ans << endl;
}

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

int main(){
    cout<<fixed<<setprecision(12);
    double a,b,C;
    cin>>a>>b>>C;
    double PI=acos(-1.0);
    C=C/180.0*PI;
    cout<<a*b*sin(C)/2.0 <<endl;
    double cc=a*a+b*b-2*a*b*cos(C);
    cout<< a+b+sqrt(cc) <<endl;
    cout<<b*sin(C)<<endl;
    return 0;
}


Measured memory_bytes: 3472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
ll a[200];
int main() {
    ll x;
    cin >> x;
    for (ll i = 1; i <= 150; i++) {
        a[i] = i * i * i * i * i;
    }
    for (int i = 0; i <= 150; i++) {
        for (int j = 0; j <= 150; j++) {
            if (a[i] - a[j] == x) {
                cout << i << " " << j << endl;
                return 0;
            }
            if (a[i] + a[j] == x) {
                cout << i << " " << -j << endl;
                return 0;
            }
            if (-a[i] - a[j] == x) {
                cout << -i << " " << j << endl;
                return 0;
            }
            if (-a[i] + a[j] == x) {
                cout << -i << " " << -j << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main()
{
    int a, b, c, ans;
    while (cin >> a >> b >> c)
    {
        ans = b;
        if (a + b < c)
            ans += a + b + 1;
        else if (a + b == c)
            ans += a + b;
        else
            ans += c;
        cout << ans << endl;
    }
    return 0;
}


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

int main()
{
	int n, m;
	cin >> n >> m;
	for(int i = m - n + 1; i <= m + n - 1; i++){
		if(i == m - n + 1)
			printf("%d", i);
		else
			printf(" %d", i);
	}
	return 0;
}

Measured memory_bytes: 256
//Created by Young Charlie
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, m; cin>>n>>m;
	cout<<(n % 3 == 0 || m % 3 == 0 || ((n + m) % 3 == 0) ? "Possible\n" : "Impossible\n");
}


Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
static string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
static int v = int.Parse(input[0]);
static int e = int.Parse(input[1]);
static bool[] checkedVertex = new bool[v];//頂点が確認済みか？
static List<int> answers = new List<int>();
static List<int>[] nextList = new List<int>[v];
static List<int>[] nextListB = new List<int>[v];
static int[] inDegree = new int[v];//入次数


	static void Main()
	{
    
    for(int i = 0; i < v; i++) 
    {
      nextList[i] = new List<int>();//リストの宣言が必要
      nextListB[i] = new List<int>();
    }

    for(int i = 0; i < e; i++)
    {
      string[] inputa = Console.ReadLine().Split(' ');
      int b = int.Parse(inputa[0])-1;
      int c = int.Parse(inputa[1])-1;
      nextList[b].Add(c);//隣接リストの作成
      nextListB[c].Add(b);
    }

    TopologicalSort();

    long answer = 0;
    long[] dp = new long[v+1];

    int[] vertexNums = new int[v];//各頂点が0,1,...番目
    for(int i = 0; i < v; i++)
    {
      vertexNums[answers[i]] = i+1;
      //Console.WriteLine(answers[i]+"a");
    }

    for(int i = 2; i <= v; i++)
    {
      for(int j = 0; j < nextListB[answers[i-1]].Count; j++)
      {
        dp[i] = Math.Max(dp[i], dp[vertexNums[nextListB[answers[i-1]][j]]] + 1);
        //Console.WriteLine(nextListB[answers[i-1]][j]+"k");
        
        answer = Math.Max(answer, dp[i]);
      }
      //Console.WriteLine(dp[i]+"b");
    }

    Console.WriteLine(answer);
	}

  static void TopologicalSort()//トポロジカルソート
  {
    for(int i = 0; i < v; i++) inDegree[i] = 0;//初期化
    
    for(int i = 0; i < v; i++)
    {
      for(int j = 0; j < nextList[i].Count(); j++)
      {
        inDegree[nextList[i][j]]++;//入次数の計算
      }
    }

    for(int i = 0; i < v; i++)
    {
      if(inDegree[i] == 0 && !(checkedVertex[i])) BFS(i);
    }
  }

  static void BFS(int startVertex)//幅優先探索
  {
    Queue<int> que = new Queue<int>();
    que.Enqueue(startVertex);//追加
    checkedVertex[startVertex] = true;
    while(que.Count > 0)
    {
      int poppedMemo = que.Peek();//一番上を見る
      que.Dequeue();//取り出し
      answers.Add(poppedMemo);//追加
      for(int i = 0; i < nextList[poppedMemo].Count(); i++)
      {
        int aimVertex = nextList[poppedMemo][i];
        inDegree[aimVertex]--;
        if(inDegree[aimVertex] == 0 && !(checkedVertex[aimVertex]))
        {
          checkedVertex[aimVertex] = true;
          que.Enqueue(aimVertex);
        }
      }
    }
  }
  
}

Measured memory_bytes: 38676
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0, i##_len=(n); i < i##_len; i++)
int main() {
    ull l, r; cin >> l >> r;
    constexpr ll pdiv = 1e9+7;
    constexpr int b = 63;
    vector<vector<vector<vector<ll>>>> dp(b+1, vector<vector<vector<ll>>>(2, vector<vector<ll>>(2, vector<ll>(2, 0))));
    dp[0][1][1][0] = 1;
    ull x[3] = {0, 0, 1};
    ull y[3] = {0, 1, 1};
    REP(i, b) {
        ull li = l >> (b-1-i) & 1;
        ull ri = r >> (b-1-i) & 1;
        REP(j, 2) REP(k, 2) REP(m, 2) REP(w, 3) {
            ull xi = x[w], yi = y[w];
            ull j2 = j, k2 = k;
            if (j) {
                if (li < xi) {
                    j2 = 0;
                } else if (xi < li) {
                    continue;
                }
            }
            if (k) {
                if (yi < ri) {
                    k2 = 0;
                } else if (ri < yi) {
                    continue;
                }
            }
            if (!m && xi == 0 && yi == 1) continue;
            (dp[i+1][j2][k2][m | (xi & yi)] += dp[i][j][k][m]) %= pdiv;
        }
    }

    ll ans = 0;
    REP(j, 2) REP(k, 2) REP(m, 2) {
        (ans += dp[b][j][k][m]) %= pdiv;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n, i, min, max;
  long sum;
  scanf("%d", &n);
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d", &a[i]);
  }
  min = a[0];
  max = a[0];
  sum = a[0];
  for(i=1;i<n;i++){
    if(min>a[i]){
      min = a[i];
    }else if(max<a[i]){
      max = a[i];
    }
    sum += a[i];
  }
  printf("%d %d %ld\n", min, max, sum);
  return 0;
}

Measured memory_bytes: 1836
#include <iostream> 
#include <iomanip> 
#include <vector> 
#include <algorithm> 
#include <numeric> 
#include <functional> 
#include <cmath> 
#include <queue> 
#include <stack> 

#define Ford(i,a,b) for (int i=(a);i<(b);i++) 
#define For(i,n) repd(i,0,n) 
typedef long long ll; 

using namespace std;

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


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
long long sum[2][510][510];
long long g[510][510];
long long rect(int t,int r1,int c1,int r2,int c2){
	if(r1>r2||c1>c2)return 0;
	return sum[t][r2+1][c2+1]-sum[t][r1][c2+1]-sum[t][r2+1][c1]+sum[t][r1][c1];
}
long long dp[510][510];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		for(int j=0;j<a;j++){
			if(i==j)continue;
			scanf("%lld",&g[i][j]);
			if(i<j){
				sum[0][i+1][j+1]+=g[i][j];
			}else{
				sum[1][j+1][i+1]+=g[i][j];
			}
		}
	}
	for(int i=0;i<2;i++){
		for(int j=0;j<=a;j++){
			for(int k=0;k<=a;k++){
				sum[i][j][k+1]+=sum[i][j][k];
			}
		}
		for(int j=0;j<=a;j++){
			for(int k=0;k<=a;k++){
				sum[i][j+1][k]+=sum[i][j][k];
			}
		}
	}
	for(int i=0;i<510;i++)for(int j=0;j<510;j++)
		dp[i][j]=inf;
	for(int i=0;i<a;i++){
		dp[i][a]=rect(0,0,0,i,i);
	}
	for(int i=0;i<a;i++){
		for(int j=0;j<i;j++){
			for(int k=i+1;k<a;k++){
				long long tmp=dp[i][j];
				tmp+=rect(0,i+1,i+1,k,k);
				tmp+=rect(1,0,i+1,j,k);
				dp[k][i]=min(dp[k][i],tmp);
			}
		}
		// i, a
		for(int k=i+1;k<a;k++){
			long long tmp=dp[i][a];
			tmp+=rect(0,i+1,i+1,k,k);
			dp[k][i]=min(dp[k][i],tmp);
		}
	}
	long long ret=inf;
	for(int i=0;i<a;i++){
		for(int j=0;j<i;j++){
			long long tmp=dp[i][j];
			tmp+=rect(0,i+1,i+1,a-1,a-1);
			tmp+=rect(1,0,i+1,j,a-1);
			ret=min(ret,tmp);
		}
	}
	for(int i=0;i<a;i++){
		long long tmp=dp[i][a];
		tmp+=rect(0,i+1,i+1,a-1,a-1);
		ret=min(ret,tmp);
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 8320