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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define ins insert
#define X first
#define Y second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define files(name) fin(name".in"); fout(name".out")
#define fi(st,n) for (int i = (st); i <= (int)(n); ++i)
#define fj(st,n) for (int j = (st); j <= (int)(n); ++j)
#define fk(st,n) for (int k = (st); k <= (int)(n); ++k)
#define fq(st,n) for (int q = (st); q <= (int)(n); ++q)
#define fw(st,n) for (int w = (st); w <= (int)(n); ++w)
#define ff(i, st, n) for (int (i) = (st); (i) <= (int)(n); ++(i))
#define ei(st,n) for (int i = (st); i >= (int)(n); --i)
#define ej(st,n) for (int j = (st); j >= (int)(n); --j)
#define ek(st,n) for (int k = (st); k >= (int)(n); --k)
#define ef(i, st, n) for (int (i) = (st); (i) >= (int)(n); --(i))
#define ri(st,n) for (int i = (st); i < (int)(n); ++i)
#define rj(st,n) for (int j = (st); j < (int)(n); ++j)
#define rk(st,n) for (int k = (st); k < (int)(n); ++k)
#define rq(st,n) for (int q = (st); q < (int)(n); ++q)
#define rf(i, st, n) for (int (i) = (st); (i) < (int)(n); ++(i))
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define y1 dsklmlvmd

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const dbl eps = (dbl) 1e-8;
const int mod = (int) 1e9 + 7;
const int maxn = (int) 1e5 + 5;
//const dbl M_PI = (dbl)2 * (dbl)acos(0);

//cout<<fixed<<setprecision(10);
//srand(time(0));

ll X, Y, Z, n, a[maxn], b[maxn], c[maxn];
pair <ll, ll> d[maxn];
set <pair <ll, ll> > qx, qy, qxz, qyz;
ll o, ans;

int main()
{
//    fin("t.in");
    sync;
    cin >> X >> Y >> Z;
    n = X + Y + Z;
    fi(1, n)
    {
    	cin >> a[i] >> b[i] >> c[i];
    	d[i] = mp(a[i] - b[i], i);
    }
    sort(d + 1, d + n + 1);
    qx.clear();
    qy.clear();
    qxz.clear();
    qyz.clear();
    o = 0;
    fi(1, Y)
    {
    	int j = d[i].Y;
    	qy.ins(mp(b[j] - c[j], j));
    	o += b[j];
    }
    fi(Y + 1, n)
    {
    	int j = d[i].Y;
    	qx.ins(mp(a[j] - c[j], j));
    	o += a[j];
    }
    while (qx.size() > X)
    {
    	int j = qx.begin()->Y;
    	qx.erase(qx.begin());
    	qxz.ins(mp(c[j] - a[j], j));
    	o -= a[j];
    	o += c[j];
    }
    ans = o;
    fi(Y + 1, n - X)
    {
//    	cout << i << endl;
    	int j = d[i].Y;
    	if (qxz.count(mp(c[j] - a[j], j)))
    	{
    		qxz.erase(mp(c[j] - a[j], j));
    		o -= c[j];
    		o += b[j];
    		qy.ins(mp(b[j] - c[j], j));
    		int k = qy.begin()->Y;
    		qy.erase(qy.begin());
    		o -= b[k];
    		o += c[k];
    	}
    	else
    	{
    		o -= a[j];
    		int l = qxz.begin()->Y;
    		qxz.erase(qxz.begin());
    		o -= c[l];
    		o += a[l];


    		o += b[j];
    		qy.ins(mp(b[j] - c[j], j));
    		int k = qy.begin()->Y;
    		qy.erase(qy.begin());
    		o -= b[k];
    		o += c[k];
    		qyz.ins(mp(c[k] - b[k], k));
    	}
    	ans = max(ans, o);
    }

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

Measured memory_bytes: 10496
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/

/////////////////////////////////
bitset<4000005> dp;


int main(){
    int n;cin>>n;int sum=0;
    int a[n];for(int i=0;i<=n-1;i++){cin>>a[i];sum+=a[i];}
    dp.set(0);
    dp[0]=1;
    for(int i=0;i<=n-1;i++){
        dp|=dp<<a[i];
    }
    for(int j=(sum+1)/2;;j++){
        if(dp[j]){
            cout<<j<<endl;
            return 0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 1664
// 　　＿＿
// 　／　<＠ﾌ
//  ｜(ﾉﾉハ))
//  ﾉ从ﾟヮﾟ从
// 　ﾉ｜ｿﾉГ|つ author:hotarunx
// 〈_ﾉ^^^ヽ|
// 　~~tｧtｧ~
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

bool isProductOverflow(long long a, long long b) {
    long long prod = a * b;

    return (prod / b != a);
}

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

    int x, k, d;
    cin >> x >> k >> d;
    x = abs(x);

    int ans = 0;

    // 座標0以下に移動することができる
    if (k >= x / d) {
        const int kk = k - x / d;
        const int xx = x - d * (x / d);

        if (kk % 2) {
            ans = d - xx;
        } else {
            ans = xx;
        }
    } else {
        ans = x - k * d;
    }

    cout << abs(ans) << endl;
}


Measured memory_bytes: 3652
N=int(input())
p=list(map(int,input().split()))

ans=0
for i in range(N-1):
    if p[i]==i+1:
        tp0=p[i]
        tp1=p[i+1]
        p[i]=tp1
        p[i+1]=tp0
        ans+=1
if p[-1]==N:
    ans+=1
print(ans)

Measured memory_bytes: 14008
#pragma GCC optimize(2,3,"Ofast","unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define in inline
namespace fast_io
{
    char buf[1<<12],*p1=buf,*p2=buf,sr[1<<23],z[23],nc;int C=-1,Z=0,Bi=0,ny;
    in char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
    in int read()
    {
        int x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;Bi=1;if(nc<0)return nc;
        x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48),Bi++;return x*ny;
    }
    in db gf() {int a=read(),y=ny,b=(nc!='.')?0:read();return (b?a+(db)b/pow(10,Bi)*y:a);}
    in int gs(char *s) {char c,*t=s;while(c=gc(),c<=32);*s++=c;while(c=gc(),c>32)*s++=c;return s-t;}
    in void ot() {fwrite(sr,1,C+1,stdout);C=-1;}
    in void flush() {if(C>1<<22) ot();}
    template <typename T>
    in void write(T x,char t)
    {
        int y=0;if(x<0)y=1,x=-x;while(z[++Z]=x%10+48,x/=10);
        if(y)z[++Z]='-';while(sr[++C]=z[Z],--Z);sr[++C]=t;flush();
    }
    in void write(char *s) {int l=strlen(s);for(int i=0;i<l;i++)sr[++C]=*s++;sr[++C]='\n';flush();}
};
using namespace fast_io;
const int N=6e2+5,p=1e9+7;
int n,m,s[N],f[N][N],g[N],h[N][N],to[N],ans;
in void M(int &x) {x-=p;x+=x>>31&p;}
int main()
{
	n=read()<<1,m=read();g[0]=1;for(int i=2;i<=n;i+=2) g[i]=(i-1ll)*g[i-2]%p;
	for(int i=1,u,v;i<=m;i++) s[u=read()]=s[v=read()]=1,to[u]=v,to[v]=u;
	for(int i=1;i<=n;i++) s[i]+=s[i-1];
	for(int i=1;i<=n;i++) for(int j=i;j<=n;j++) h[i][j]=j-i+1-s[j]+s[i-1];
	for(int i=1;i<n;i++) for(int j=i+1;j<=n;j+=2)
	{
		int op=0;for(int k=i;k<=j;k++) op|=to[k]&&(to[k]<i||to[k]>j);
		if(op) continue;f[i][j]=g[h[i][j]];
		for(int k=i+1;k<j;k+=2) M(f[i][j]+=p-1ll*f[i][k]*g[h[k+1][j]]%p);
	}
	for(int i=1;i<n;i++) for(int j=i+1;j<=n;j+=2) M(ans+=1ll*f[i][j]*g[h[1][i-1]+h[j+1][n]]%p);
	write(ans,'\n');
	return ot(),0;
}
//Author: disangan233

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

// #include <atcoder/all>

#include <boost/operators.hpp>

class modint : private boost::operators<modint>, private boost::equivalent<modint> {
  modint(const long long x, const bool y)
      : x(x) {}

 public:
  static long long M;
  long long x;
  modint(const long long x = 0)
      : x((x % M + M) % M) {}
  modint operator-() const { return modint(x ? M - x : 0, true); }
  modint& operator+=(const modint& b) { return ((x += b.x) >= M ? x -= M : 0), *this; }
  modint& operator++() { return (++x >= M ? x -= M : 0), *this; }
  modint& operator-=(const modint& b) { return ((x -= b.x) < 0 ? x += M : 0), *this; }
  modint& operator--() { return (--x < 0 ? x += M : 0), *this; }
  modint& operator*=(const modint& b) { return x = x * b.x % M, *this; }
  modint& operator/=(const modint& b) { return *this *= b.pow(-1); }
  modint pow(long long b) const {
    long long r = 1, a = x;
    b = (b % (M - 1) + (M - 1)) % (M - 1);
    while (b) {
      if (b & 1) r = r * a % M;
      b = b >> 1;
      a = a * a % M;
    }
    return modint(r, true);
  }
  friend bool operator<(const modint& a, const modint& b) { return a.x < b.x; }
  friend std::istream& operator>>(std::istream& s, modint& a) { return s >> a.x, a = a.x, s; }
  friend std::ostream& operator<<(std::ostream& s, const modint& a) { return s << a.x; }
};
long long modint::M = 1e9 + 7;

// #LIB#

using namespace std;
// using namespace atcoder;
using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#ifdef ONLINE_JUDGE
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');
#endif

// // using mint = static_modint<1000000007>;

modint dp[10000];
bool seen[10000];
modint ans(int x) {
  if (x < 0) return 0;
  if (x == 0) return 1;
  if (seen[x]) return dp[x];
  modint re;
  repr(i, 3, x + 1) re += ans(x - i);
  seen[x] = true;
  return dp[x] = re;
}
int main() {
  ll s;
  cin >> s;
  cout << ans(s) << endl;
}


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

#define int long long
const int mod = 1e9 + 7;
int power(int x, int y) {
    int res = 1;
    while (y) {
        if (y & 1) res = res * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return res;
}

signed main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n;
    cin >> n;
    if (n <= 1) {
        cout << 0 << '\n';
        return 0;
    }
    int ans = ((power(10, n) - 2 * power(9, n) + power(8, n)) % mod + mod) % mod;
    cout << ans << '\n';
    return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    string S, T;
    cin >> S >> T;

    map<char, char> sa, ta;

    bool flag = true;
    REP(i, S.size()){
        char s = S[i];
        char t = T[i];

        if(sa.count(s)){
            if(sa[s] != t) flag = false;
        }
        if(ta.count(t)){
            if(ta[t] != s) flag = false;
        }
        sa[s] = t;
        ta[t] = s;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	long long N;
	scanf("%lld",&N);
	vector<ll> r, g, b;
	std::string S;
	std::cin >> S;
	for (ll i = 0; i < N; ++i)
	{
		switch (S[i]) {
			case 'R':
				r.push_back(i);
				break;
			case 'G':
				g.push_back(i);
				break;
			case 'B':
				b.push_back(i);
				break;
		}
	}

	ll sum = 0;
	for (ll i = 0; i < N; ++i)
	{
		for (ll j = i + 1; j < N; ++j)
		{
			if (S[i] == S[j])	continue;
			if (S[i] != 'R' && S[j] != 'R')
			{
				auto it = lower_bound(r.begin(), r.end(), j + 1);
				sum += r.end() - it;
				it = lower_bound(r.begin(), r.end(), j + (j - i));
				if (it != r.end() && *it == j + (j - i))
				{
					--sum;
				}
			}
			else if (S[i] != 'G' && S[j] != 'G')
			{
				auto it = lower_bound(g.begin(), g.end(), j + 1);
				sum += g.end() - it;
				it = lower_bound(g.begin(), g.end(), j + (j - i));
				if (it != g.end() && *it == j + (j - i))
				{
					--sum;
				}
			}
			else
			{
				auto it = lower_bound(b.begin(), b.end(), j + 1);
				sum += b.end() - it;
				it = lower_bound(b.begin(), b.end(), j + (j - i));
				if (it != b.end() && *it == j + (j - i))
				{
					--sum;
				}
			}
		}
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 3744
#include <stdio.h>
int main(void){
    int n,i,x,cnt=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&x);
        if(x!=i+1) cnt++;
        if(cnt==3){
            printf("NO");
            return 0;
        }
    }
    printf("YES");
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>

int main(void)
{
	char tbl[256];
	char W[12], T[1002];
	char *eot = "END_OF_TEXT";
	int i, n = 0;

	for (i  = 0; i < 256; i++) {
		tbl[i] = i;
	}
	for (i = 0; i <= 26; i++) {
		tbl['a' + i] = 'A' + i;
	}
	scanf("%s", W);
	for (i = 0; W[i] != '\0'; i++) {
		W[i] = tbl[W[i]];
	}
	for (;;) {
		scanf("%s", T);
		if (strcmp(T, eot) == 0) {
			break;
		}
		for (i = 0; T[i] != '\0'; i++) {
			T[i] = tbl[T[i]];
		}
		if (strcmp(T, W) == 0) {
			n++;
		}
	}
	printf("%d\n", n);

	return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <iomanip>
#include <vector>

int main (){
  long long int n, a, sum, max, low;
  max = -1000000;
  low = 1000000;
  sum = 0;
  std::cin >> n;
  for (int i = 0; i < n; i++) {
    std::cin >> a;
    sum = sum + a;
    if (max < a){
      max = a;
    }
    if (low > a){
      low = a;
    }
  }
  std::cout << low << " " << max << " " << sum << std::endl;
}


Measured memory_bytes: 3096
#C
N = int(input())
A,B = map(int,input().split())
C = int(input())
T = [int(input()) for i in range(N)]
T.sort(reverse=True)

cal = C
cost = A
for t in T:
    if cal/cost < (cal+t)/(cost+B):
        cal+=t
        cost+=B
    else:
        break
        
print(cal//cost)





Measured memory_bytes: 5604
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math

mod = 10**9+7



n = int(input())
a = [int(i) for i in input().split()]


# 階乗 & 逆元計算
factorial = [1]
inverse = [1]
for i in range(1, n+2):
    factorial.append(factorial[-1] * i % mod)
    inverse.append(pow(factorial[-1], mod-2, mod))

def combinations_count(n,r):
    if n-r < 0:
        return 0
    return factorial[n]*inverse[r]*inverse[n-r]%mod

A = copy.deepcopy(a)
A.sort()
for i in range(n+1):
    if A[i] == A[i+1]:
        double = A[i]
        break

cnt = 0
for i in range(n+1):
    if a[i] == double:
        if cnt == 0:
            l = i+1
            cnt += 1
        else:
            r = i+1
# print(l,r)
for k in range(1,n+2):
    # print(n+1,k,l+n-r,k-1)
    ans = (combinations_count(n+1,k)-combinations_count((l+n-r),(k-1)))%mod
    print(ans)


Measured memory_bytes: 19840
import itertools
import math
s = [int(input()) for i in range(5)]
mn = 644
for i in itertools.permutations(s):
	v = 0
	for k, j in enumerate(i):
		if k != 4:
			v += math.ceil(j/10)*10
		else:
			v += j
	mn = min(mn, v)
print (mn)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int F[100];
int main(){
    int N, M;
    cin >> N >> M;
    REP(i,N){
        int k;
        cin >> k;
        REP(j,k){
            int a;
            cin >> a;
            a--;
            F[a]++;
        }
    }

    ll ans = 0;
    REP(i, M){
        int f = F[i];
        if(f == N)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
d = {}
for i in range(N):
  s = input()
  if s not in d.keys():
    d[s] = 1
  else:
    d[s] += 1
a = max(d.values())
d = sorted(d.items(), key=lambda x: x[1])
l = []
for i, j in d:
  if j == a:
    l.append(i)
l = sorted(l)
for i in range(len(l)):
  print(l[i])

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define INF 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;

int main(){
    int N,ans;
    cin >> N;
    
    
    
    cout << N*2*3.141592;
    cout << endl;
    return 0;
}


Measured memory_bytes: 3788
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans=0

for i in range(a+1):
    for j in range(b+1):
        y=(x-500*i-100*j)//50
        if (x-500*i-100*j)% 50 ==0 and y>=0 and y<=c:
            ans += 1

print(ans)

Measured memory_bytes: 3064
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
using namespace std;

int main() {
	int N, a, b;
	cin >> N;
	if (N == 1) {
		cout << "Hello World" << endl;
	}
	else{
		cin >> a >> b;
	cout << a + b << endl;
	}
		
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int H[111], N, ans=0;
int main(){
  int ii;
  rd(N);
  {
    int PiIOrLma;
    for(PiIOrLma=0;PiIOrLma<N;PiIOrLma++){
      rd(H[PiIOrLma]);
    }
  }
  for(ii=0;ii<100;ii++){
    int i;
    for(i=0;i<100;i++){
      ans += H[i]-- > 0 && H[i+1] <= 0;
    }
  }
  wt_L(ans);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20180208-1

// --- original code ---
// int N;
// int H[111];
// int ans = 0;
// {
//     rd(N, H(N));
//     REP(ii, 100){
//         REP(i, 100){
//             ans += H[i]-- > 0 && H[i+1] <= 0;
//         }
//     }
//     wt(ans);
// }

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
using namespace std;

int main() {
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(n*a,b) << endl;

    return 0;
}

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

typedef long long ll;
typedef pair<string, string> pss;

ll n, ans;
string s;
map<pss, int> cnt;

int main() {
	cin >> n >> s;
	for (int i = 0; i < (1 << n); i++) {
		string a = "", b = "";
		for (int j = 0; j < n; j++)
			if(i & (1 << j))
				a.push_back(s[j]);
			else
				b.push_back(s[j]);
		reverse(b.begin(), b.end());
		cnt[pss(a, b)]++;
	}
	
	for (int i = 0; i < (1 << n); i++) {
		string a = "", b = "";
		for (int j = 0; j < n; j++)
			if(i & (1 << j))
				a.push_back(s[n + j]);
			else
				b.push_back(s[n + j]);
		reverse(b.begin(), b.end());
		ans += cnt[pss(b, a)];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 87040
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define LL long long
using namespace std;
int n,m,s[101][101],p[101],ans;

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		cin>>s[i][0];
		for(int j=1;j<=s[i][0];j++) cin>>s[i][j],s[i][j]--;
	}
	for(int i=1;i<=m;i++) cin>>p[i];
	for(int i=0;i<=pow(2,n)-1;i++)
	{
		int sum=0;
		for(int j=1;j<=m;j++)
		{
			int tot=0;
			for(int k=1;k<=s[j][0];k++)
			{
				if(i&1<<s[j][k]) tot++;
			}
			if(tot%2==p[j]) sum++;
		}
		if(sum==m) ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
from collections import deque
from bisect import bisect_left as bile

def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    sys.setrecursionlimit(10**6)
    n = int(input())
    arr = list(map(int, input().split()))
    adj = [[] for _ in range(n)]
    for i in range(n-1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        adj[a].append(b)
        adj[b].append(a)

    ans = [0]*n
    inf = 1e18
    dp = [inf]*(n+10)
    parent = [-1]*n
    def dfs(s):
        idx = bile(dp, arr[s])
        tmp = dp[idx]
        dp[idx] = arr[s]
        ans[s] = bile(dp, inf)

        for v in adj[s]:
            if v == parent[s]:
                continue
            parent[v] = s
            dfs(v)
        dp[idx] = tmp
        return ans
        
    ans = dfs(0)
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()

Measured memory_bytes: 286132
#include<bits/stdc++.h>
#define SZ(a) ((int) a.size())
using namespace std;
typedef long long ll;
const int N=55,M=22;
const ll inf=1e18;

int n,c[N];
ll f[N][M][2],ans=inf;
string s[N];

ll dp(int x,int y,int d) {//x????,y???,d???(??)
    if(y==SZ(s[x])) return 0;
    if(~f[x][y][d]) return f[x][y][d];
    ll &v=f[x][y][d];
     v=inf;
	bool flag=1;
	if(!d) {for(int j=y,k=SZ(s[x])-1;j<k;j++,k--) if(s[x][j]!=s[x][k]) {flag=0; break;}}
	else {for(int j=y,k=0;j>k;j--,k++) if(s[x][j]!=s[x][k]) {flag=0; break;}}
	if(flag) return v=0;
    for(int i=1,j,k;i<=n;i++) {//???????????
        flag=1;
        if(!d) {
            for(j=y,k=SZ(s[i])-1;j<SZ(s[x])&&k>=0;j++,k--)
                if(s[x][j]!=s[i][k]) {flag=0; break;}
            if(flag) {
                if(k<0) v=min(v,c[i]+dp(x,j,0));
                else v=min(v,c[i]+dp(i,k,1));
            }
        }
        else {
            for(j=y,k=0;j>=0&&k<SZ(s[i]);j--,k++)
                if(s[x][j]!=s[i][k]) {flag=0; break;}
            if(flag) {
                if(j<0) v=min(v,c[i]+dp(i,k,0));
                else v=min(v,c[i]+dp(x,j,1));
            }
        }
    }
    return v;
}

int main() {
    scanf("%d",&n); memset(f,-1,sizeof(f));
    for(int i=1;i<=n;i++) cin>>s[i]>>c[i];
    for(int i=1;i<=n;i++) 
		ans=min(ans,c[i]+dp(i,0,0));
    printf("%lld\n",ans==inf?-1:ans);return 0;
}



Measured memory_bytes: 3844
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main (void)
{
 int a[100],n,ans = 0;

  cin >> n;

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

  sort(a,a+n);

  for(int j = 1;j <= n;j++){
    if(j % 2 == 1){
      ans += a[n - j];
    }
    else{
      ans -= a[n - j];
    }
  }
  
  cout << ans << endl;

  return 0;
}





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

const int Maxn = 303;
const int mod = 998244353;

string S;
int k;
int dp[Maxn][Maxn][Maxn];
int res;

int main()
{
    cin >> S >> k;
    int lst = -1;
    int cur = 0;
    dp[cur][0][0] = 1;
    for (int i = 0; i < S.length(); i++) if (S[i] == '0') {
        int ones = i - 1 - lst;
        for (int j = 0; j < Maxn; j++)
            for (int l = 0; l < Maxn; l++) if (dp[cur][j][l])
                for (int t = 0; t <= S.length(); t++) {
                    int lv = max(0, ones - t);
                    if (lv > j) continue;
                    int add = max(0, t - ones);
                    if (j - lv + add >= Maxn || l + add >= Maxn) continue;
                    dp[cur + 1][j - lv + add][l + add] = (dp[cur + 1][j - lv + add][l + add] + dp[cur][j][l]) % mod;
                }
        lst = i; cur++;
    }
    int ones = int(S.length()) - 1 - lst;
    for (int j = 0; j <= ones; j++)
        for (int l = 0; l < Maxn && l <= k; l++)
            res = (res + dp[cur][j][l]) % mod;
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 110832
n = int(input())

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
      
print(num2alpha(n).lower())

Measured memory_bytes: 9164
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <array>

using namespace std;

typedef long long ll;

array<array<ll, 4001>, 4001> table;

void reg(ll x, ll y, ll size)
{
  if (max<ll>(0, y) < min<ll>(y + size, 2 * size) && 
	  max<ll>(0, x) < min<ll>(x + size, size))
  {
	table[max<ll>(0, y)][max<ll>(0, x)] += 1;
	table[max<ll>(0, y)][min<ll>(x + size, size)] -= 1;
	table[min<ll>(y + size, 2 * size)][max<ll>(0, x)] -= 1;
	table[min<ll>(y + size, 2 * size)][min<ll>(x + size, size)] += 1;
  }
}

int main()
{
  for (auto &v : table) fill(v.begin(), v.end(), 0);
  
  ll n, k;
  cin >> n >> k;

  vector<tuple<ll, ll, char>> vs;
  
  for (int i = 0; i < n; i++)
  {
	ll x, y;
	char ch;
	cin >> x >> y >> ch;
	x %= (2 * k);
	y %= (2 * k);

	if (x >= k && y >= k)
	{
	  x -= k;
	  y -= k;
	}

	if (x >= k && y < k)
	{
	  x -= k;
	  y += k;
	}
	
	if (ch == 'W')
	{
	  if (x > 0 && y > 0)
	  {
		reg(x, y - 2 * k, k);
		reg(x - k, y - k, k);
		reg(x, y, k);
		reg(x - k, y + k, k);
	  }
	  else if(x > 0 && y == 0)
	  {
		reg(x, y, k);
		reg(x - k, y + k, k);
	  }
	  else if(x == 0 && y > 0)
	  {
		reg(x, y - 2 * k, k);
		reg(x, y, k);
	  }
	  else 
	  {
		reg(x, y, k);
	  }
	}
	else
	{
	  if (x > 0 && y > 0)
	  {
		reg(x - k, y - 2 * k, k);
		reg(x, y - k, k);
		reg(x - k, y, k);
		reg(x, y + k, k);
	  }
	  else if (x > 0 && y == 0)
	  {
		reg(x - k, y, k);
		reg(x, y + k, k);
	  }
	  else if (x == 0 && y > 0)
	  {
		reg(x, y - k, k);
		reg(x, y + k, k);
	  }
	  else if(y == 0 && x == 0)
	  {
		reg(x, y + k, k);
	  }
	}
  }

  for (int y = 0; y < 2 * k; y++)
  {
	for (int x = 1; x <= k; x++)
	{
	  table[y][x] += table[y][x - 1];
	}
  }

  for (int y = 1; y <= 2 * k; y++)
  {
	for (int x = 0; x < k; x++)
	{
	  table[y][x] += table[y - 1][x];
	}
  }

  ll max_val = 0;
  for (int y = 0; y < 2 * k; y++)
  {
	for (int x = 0; x < k; x++)
	{
	  max_val = max<ll>(max_val, table[y][x]);
	}	
  }
  cout << max_val << endl;
}  


Measured memory_bytes: 125312
#include<iostream>

using namespace std;

long long solve(long long x,long long n)
{
    long long ans;
    if(n%x == 0)
        return n*2-x;
    ans = n/x*x*2+solve(n%x,x);
    return ans;
}

int main()
{
    long long n,x;
    long long ans;
    cin >> n >> x;
    ans = solve(x,n-x) + n;
    cout << ans << endl;
    return 0;
}

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

signed main(){
	int m=0,a=0,r=0,c=0,h=0;
	int can_num=0;
	int n;
	cin>>n;
	string s[n];
	for(int i=0;i<n;i++){
		cin>>s[i];
		if(s[i][0]=='M')m++;
		if(s[i][0]=='A')a++;
		if(s[i][0]=='R')r++;
		if(s[i][0]=='C')c++;
		if(s[i][0]=='H')h++;
	}
	if(m!=0)can_num++;
	if(a!=0)can_num++;
	if(r!=0)can_num++;
	if(c!=0)can_num++;
	if(h!=0)can_num++;

	//cout<<can_num<<endl;
	int march[5];

	march[0]=m;
	march[1]=a;
	march[2]=r;
	march[3]=c;
	march[4]=h;
	int ans=0;
	if(can_num<3){
		cout<<0<<endl;
		return 0;
	}
	else if(can_num==3){
		int tmp=1;
		for(int i=0;i<5;i++){
			if(march[i]!=0){
				tmp *= march[i];
			}
		}
		ans = tmp;
	}else if(can_num==4){
		int tmp=1,cnt=0;
		for(int i=0;i<5;i++){
			if(march[i]==0)continue;
			tmp=1;
			for(int j=0;j<5;j++){
				if(i==j)continue;
				if(march[i]==0||march[j]==0)continue;
				tmp *= march[j];
				cnt++;
				if(cnt==3)break;
			}
			ans += tmp;
			cnt=0;
		//	cout<<i<<" "<<tmp<<endl;
		}

	}else if(can_num==5){
		int tmp=1,cnt=0;
		for(int i=0;i<5;i++){
			for(int j=i;j<5;j++){
				tmp=1;
				if(i==j)continue;
				for(int k=0;k<5;k++){
					if(i==k||j==k)continue;
					tmp *= march[k];
					cnt++;
					if(cnt==3)break;
				}
				ans += tmp;
				cnt=0;
			}
			//cout<<i<<" "<<tmp<<endl;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 6144
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    N = II()
    ans = ''
    while N > 0:
        ans = chr(ord('a')+((N-1)%26)) + ans
        N = (N-1) // 26
    print(ans) 

    # s = 'zzzz'
    # tmp = 0
    # for c in s:
    #     tmp *= 26
    #     tmp += ord(c) - ord('a') +1
    # print(tmp)
        

    
main()

Measured memory_bytes: 65128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};

int main(){
  ll N,K,k=0;
  cin>>N>>K;
  vector<pair<ll,ll>> p(N);
  for(ll i=0;i<N;i++) cin>>p[i].first>>p[i].second;
  sort(p.begin(),p.end());
  for(ll i=0;i<N;i++){
    if(k<=K&&K<=k+p[i].second){
      cout<<p[i].first<<endl;
      return 0;
    }else k+=p[i].second;
  }
}


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

int main() {
  
  int N;
  cin >> N;
  long long sum = 0;
  vector<int> A(N);
  for(int i = 0;i < N;i++) {
    cin >> A.at(i);
    sum += A.at(i);
  }
  
  sort(A.begin(),A.end());

  int num = 1;
  for(int i = N-1;i >= 0;i--) {
    sum -= A.at(i);
    if(A.at(i) <= sum * 2) num++;
    else break;
  }

  cout << num << endl;

}




Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(r) r.begin(),r.end()
using namespace std;
typedef int64_t ll;
typedef vector<ll> vll;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll n, m;
        in >> n;
        vll d(n);
        for (int i = 0; i < n; i++) {
            in >> d[i];
        }
        sort(all(d));
        reverse(all(d));
        in >> m;
        vll t(m);
        for (int i = 0; i < m; i++) {
            in >> t[i];
        }
        sort(all(t));
        reverse(all(t));
        ll cnt = 0;
        for (int i = 0, j = 0; i < m; i++) {
            for (; j < n; j++) {
                if (t[i] == d[j]) {
                    cnt++;
                    j++;
                    break;
                }
            }
        }
        out << (cnt == m ? "YES" : "NO") << '\n';
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
int f(int a){

}
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    str s[10];
    rep(i,0,n){
        cin>>s[i];
    }
    int a[10][10];
    rep(i,0,10)rep(j,0,10)a[i][j]=0;
    int k=0;
    rep(i,0,n){
        rep(j,k,m){
            if(s[i][j]=='#'){
                a[i][j]=1;
                rep(l,j,m){
                    if(s[i][l]!='#'){
                        break;
                    }else{
                        a[i][l]=1;
                        k=j;
                    }
                }
            }
        }
    }
    bool y=false;
    rep(i,0,n){
        rep(j,0,m){
            if(s[i][j]=='#'&&a[i][j]==0){
                y=true;
            }
        }
    }
    if(!y){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#define DEBUG 0
/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 2019-6-29 21:05:07
 * Powered by Visual Studio Code
 */
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <functional>
#include <random>
#include <chrono>
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
using ll = long long;
void Yes()
{
  cout << "Yes" << endl;
  exit(0);
}
void No()
{
  cout << "No" << endl;
  exit(0);
}
const int MAX_SIZE = 1000010;
class mint
{
public:
  static ll MOD;
  ll x;
  mint() : x(0) {}
  mint(ll x) : x(x % MOD) {}
  mint operator-() const { return x ? MOD - x : 0; }
  mint &operator+=(const mint &a)
  {
    if ((x += a.x) >= MOD)
    {
      x -= MOD;
    }
    return *this;
  }
  mint &operator-=(const mint &a) { return *this += -a; }
  mint &operator*=(const mint &a)
  {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint &operator/=(const mint &a) { return (*this *= power(MOD - 2)); }
  mint operator+(const mint &a) const { return mint(*this) += a; }
  mint operator-(const mint &a) const { return mint(*this) -= a; }
  mint operator*(const mint &a) const { return mint(*this) *= a; }
  mint operator/(const mint &a) const { return mint(*this) /= a; }
  bool operator<(const mint &a) const { return x < a.x; }
  bool operator==(const mint &a) const { return x == a.x; }
  const mint power(ll N)
  {
    if (N == 0)
    {
      return 1;
    }
    else if (N % 2 == 1)
    {
      return *this * power(N - 1);
    }
    else
    {
      mint half = power(N / 2);
      return half * half;
    }
  }
};
ll mint::MOD = 1e9 + 7;
istream &operator>>(istream &stream, mint &a) { return stream >> a.x; }
ostream &operator<<(ostream &stream, const mint &a) { return stream << a.x; }
mint inv[MAX_SIZE];
mint fact[MAX_SIZE];
mint factinv[MAX_SIZE];
void init()
{
  inv[1] = 1;
  for (int i = 2; i < MAX_SIZE; i++)
  {
    inv[i] = (-inv[mint::MOD % i]) * (mint::MOD / i);
  }
  fact[0] = factinv[0] = 1;
  for (int i = 1; i < MAX_SIZE; i++)
  {
    fact[i] = mint(i) * fact[i - 1];
    factinv[i] = inv[i] * factinv[i - 1];
  }
}
mint choose(int n, int k)
{
  if (n >= 0 && k >= 0 && n - k >= 0)
  {
    return fact[n] * factinv[k] * factinv[n - k];
  }
  return 0;
}
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
// const double epsilon = 1e-10;
// const ll infty = 1000000000000000LL;
// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

int N;
int d[100010];

int main()
{
  // init();
  cin >> N;
  for (auto i = 0; i < N; i++)
  {
    cin >> d[i];
  }
  sort(d, d + N);
  cout << d[N / 2] - d[N / 2 - 1] << endl;
}

Measured memory_bytes: 24064
using Kujikatsu002.Questions;
using Kujikatsu002.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

namespace Kujikatsu002.Questions
{
    /// <summary>
    /// https://atcoder.jp/contests/caddi2018b/tasks/caddi2018b_b
    /// </summary>
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var nhw = inputStream.ReadIntArray();
            var n = nhw[0];
            long h = nhw[1];
            long w = nhw[2];

            long count = 0;

            for (int i = 0; i < n; i++)
            {
                var ab = inputStream.ReadIntArray();
                long a = ab[0];
                long b = ab[1];
                if (a / h >= 1 && b / w >= 1)
                {
                    count++;
                }
            }

            yield return count;
        }
    }
}


namespace Kujikatsu002
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Kujikatsu002.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Kujikatsu002.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
#include <iostream>

using namespace std;

int wh[1500001];
int ww[1500001];

int main() {
	int n, m;

	while (cin >> n >> m && (n > 0 && m > 0)) {
		int h[1500], w[1500];

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

		fill_n(wh, 1500001, 0);
		fill_n(ww, 1500001, 0);

		for (int i = 0; i < n; i++) {
			int temp = 0;
			for (int j = i; j < n; j++) {
				temp += h[j];
				wh[temp]++;
			}
		}

		for (int i = 0; i < m; i++) {
			int temp = 0;
			for (int j = i; j < m; j++) {
				temp += w[j];
				ww[temp]++;
			}
		}

		int count = 0;

		for (int i = 0; i < 1500001; i++) {
			count += (wh[i] * ww[i]);
		}

		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 12888
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(12)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<vector<pair<int ,int> > > v(n);
    queue<int> q;
    bool maki=true;
    int u1[n],u2[n],w[n];
    int ans[n];
    bool niko[n];
    for(int i=0;i<n;i++){
        niko[i]=false;
    }
    for(int i=0;i<n-1;i++){
        cin>>u1[i]>>u2[i]>>w[i];
        v[u1[i]-1].pb(make_pair(u2[i]-1,w[i]));
        v[u2[i]-1].pb(make_pair(u1[i]-1,w[i]));
        if(w[i]%2){
            maki=false;
        }
    }
    if(maki){
        for(int i=0;i<n;i++){
            cout << 0<<endl;
        }
        return 0;
    }
    q.push(0);
    niko[0]=true;
    ans[0]=0;
    while(!q.empty()){
        int umi=q.front();
        q.pop();
        int honoka=v[umi].size();
        for(int i=0;i<honoka;i++){
            if(niko[v[umi][i].first]==false){
                niko[v[umi][i].first]=true;
                if(v[umi][i].second%2==0){
                    ans[v[umi][i].first]=(ans[umi]==0)?0:1;
                }
                else{
                    ans[v[umi][i].first]=(ans[umi]==0)?1:0;
                }
                q.push(v[umi][i].first);
            }
        }
    }
    for(int i=0;i<n;i++){
        cout << ans[i]<<endl;
    }
    return 0;
}



Measured memory_bytes: 8064
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
using namespace std;
int main() {
	int N,K;
	int ans = 0;
	cin >> N>>K;
	vector<int> a(N);
	//vector<int> b(N);
	for (int i = 0; i < N; i++)cin >> a.at(i);
	for (int i = 0; i < N; i++) {
		if (a.at(i) >= K)ans++;
	}
	cout << ans << endl;
	
		return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1e9+7;
struct mint {
  typedef long long ll;
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  
  mint ans = 1;
  rep(i, N) ans *= (i+1);
  std::cout << ans.x << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cxxabi.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using psi=pair<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
template<class T>void geti(T&a){for(auto&_:a)cin>>_;}
template<class T>void getii(T&a){for(auto&_:a)geti(_);}
void put(string d){cout<<endl;}template<class H,class...T>void put(string d,H&&h,T&&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__)
#define dclt(t,...) t __VA_ARGS__;get(__VA_ARGS__)

template<class T>string bitstr(T x){return typeid(T)==typeid(int)?bitset<32>(x).to_string('_','#'):bitset<64>(x).to_string();}
template<class T>int bitcnt(T x){return typeid(T)==typeid(int)?__builtin_popcount(x):__builtin_popcountll(x);}
template<class T>int bitdig(T x){return x?typeid(T)==typeid(int)?32-__builtin_clz(x):64-__builtin_clzll(x):0;}
template<class T>int bitpow(T x){return x?typeid(T)==typeid(int)?__builtin_ctz(x):__builtin_ctzll(x):0;}


int main(){
    dcl(n,a);
    if(n%500<=a)cout<<"Yes"<<endl; else cout<<"No"<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      cout << '\n';
  }
  return s;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  string S;
  cin >> S;

  string C = "CODEFESTIVAL2016";
  int ans = 0;
  rep(i, len(S)) {
    if (S[i] != C[i])
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256