akhauriyash/Code-Regression huggingface dataset:
#ifndef LOCAL
#pragma GCC optimize ("O3")
#endif
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define mor > muu & operator << (
#define R22(r) sim > typename \
  enable_if<1 r sizeof dud<c>(0), muu&>::type operator<<(c g) {
sim > struct rge { c b, e; };
sim > rge<c> range(c h, c n) { return {h, n}; }
sim > auto dud(c* r) -> decltype(cerr << *r);
sim > char dud(...);
struct muu {
#ifdef LOCAL
stringstream a;
~muu() { cerr << a.str() << endl; }
R22(<) a << boolalpha << g; ris; }
R22(==) ris << range(begin(g), end(g)); }
sim, class b mor pair < b, c > r) { ris << "(" << r.first << ", " << r.second << ")"; }
sim mor rge<c> u) {
  a << "[";
  for (c i = u.b; i != u.e; ++i)
    *this << ", " + 2 * (i == u.b) << *i;
  ris << "]";
}
#else
sim mor const c&) { ris; }
#endif
muu & operator()() { ris; }
};
#define imie(r...) "[" #r ": " << (r) << "] "
#define imask(r...) "[" #r ": " << bitset<8 * sizeof(r)>(r) << "] "
#define arr(a, i) "[" #a imie(i) ": " << a[i] << "] "
#define arr2(a, i, j) "[" #a imie(i) imie(j) ": " << a[i][j] << "] "
#define debug (muu() << __FUNCTION__ << "#" << __LINE__ << ": ")

const int mod = 1e9 + 7;
int n, m;
const int N = 1e3 + 7;
char tab[N][N];
int dp[N][N];

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; ++i) scanf("%s", tab[i] + 1);
    dp[n][m] = 1;
    for (int i = n; i > 0; --i) {
        for (int j = m; j > 0; --j) {
            if (tab[i][j] == '.') {
                dp[i][j] += (dp[i + 1][j] + dp[i][j + 1]) % mod;
            }
        }
    }
    printf("%d\n", dp[1][1]);
    return 0;
}


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

using namespace std;

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

  vector<int> vs(n);

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

  sort(vs.begin(), vs.end());
  vs.erase(unique(vs.begin(), vs.end()), vs.end());

  int dup = n - vs.size();

  if(dup % 2 == 0) {
	cout << n - dup << endl;
  } else {
	cout << n - dup - 1 << endl;
  }  
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>

using namespace std;

#define x first
#define y second

int getArea(int x1, int y1, int x2, int y2, int x3, int y3) {
    return abs((x1-x2)*(y3-y2)-(x3-x2)*(y1-y2));
}

int main() {
    ios::sync_with_stdio(false);

    int n;
    while (cin >> n, n) {
        map<int, bool> has;

        vector<pair<int,int> > co(n);
        for (int i=0; i<n; ++i) {
            cin >> co[i].x >> co[i].y;
            has[co[i].x+10000*co[i].y] = true;
        }

        int area = 0, mxhyp = 0;
        for (int i=0; i<(int)co.size(); ++i) {
            for (int j=i+1; j<(int)co.size(); ++j) {
                int dx = co[j].x - co[i].x;
                int dy = co[j].y - co[i].y;
                if (mxhyp < dx * dx + dy * dy) {
                    int x3 = co[j].x - dy;
                    int y3 = co[j].y + dx;
                    int x4 = co[i].x - dy;
                    int y4 = co[i].y + dx;
                    if (has.count(x3+10000*y3) && has.count(x4+10000*y4)) {
                        area = max(area, getArea(co[i].x, co[i].y, co[j].x, co[j].y, x3, y3));
                        mxhyp = dx * dx + dy * dy;
                    }
                }
            }
        }
        cout << area << endl;
    }
    return 0;
}

Measured memory_bytes: 1372
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<deque>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<tuple>
#include<map>
#include<memory>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<double> VD;
typedef pair<int, int> P1;
typedef long long int ll;

//number
#define INF 1e9
#define NUM 1000000007

//itr
#define all(x) begin(x),end(x)

//repeat
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define RREPS(i,x) for(int i=((int)(x));i>=0;i--)

//max,min
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

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

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	retur5n a * (b / g);
}*/

int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}

//grid template
int x[] = { -1, 0, 1, 0 };
int y[] = { 0,-1,0,1 };
int xx[] = { -1,-1,1,1 };
int yy[] = { 1,-1,1,-1 };

int main() {
	double a, b, t;
	cin >> a >> b >> t;

	int ans = 0;
	for (int i = a; i < t + 0.5; i += a) {
		ans += b;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define drep(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define MAGICLINE ios_base::sync_with_stdio(0)
#define pb push_back
#define mp make_pair
#define se second
#define fs first
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, int> PLI;
typedef priority_queue<int> PQI;
typedef priority_queue<LL> PQL;
typedef priority_queue<PLI,
                       vector<PLI>,
                       greater<PLI> > dijQ;

const int MN = 100002;
const LL INF = 1e18 + 3;
LL T[MN][2];
int val[MN], weigh[MN];

void prefill(int m){
  rep(i, 1, m){
    T[i][0] = INF;
    T[i][1] = INF;
  }
}

void Move(int m){
  rep(i, 0, m){
    T[i][0] = min(T[i][0], T[i][1]);
    T[i][1] = INF;
  }
}

int main(){
  MAGICLINE;
  int n, m; scanf("%d %d", &n, &m);
  prefill(MN);
  rep(i, 1, n+1) scanf("%d %d", &weigh[i], &val[i]);
  rep(j, 1, n+1){
    rep(i, 1, MN)
      if(T[i-val[j]][0] + weigh[j] <= m)
        T[i][1] = min(T[i][1], T[i-val[j]][0] + weigh[j]);
    Move(MN);
  }

  int ans = -1;
  rep(i, 0, MN)
    if(T[i][0] != INF) ans = i;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <numeric>
#include <stdio.h>
#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
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

int main() {
	ll N,K;
	cin >> N>>K;
	vector<ll> h(N);
	vector<ll> co(N+K+1000);
	rep(i, N + K + 1000) {
		co.at(i) = 9999999999;
	}
	for (int i = 0; i <N; i++) {
		cin >> h.at(i);
	}
	co.at(0) = 0;
	for (int i = 0; i < N; i++) {
		for(int j=1;j<=K&&i+j<N;j++)
		co.at(i+j) = min(co.at(i + j),co.at(i)+abs(h.at(i+j)-h.at(i)));
	}
	cout << co.at(N - 1) << endl;
}


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

int main() {
  long long N;
  cin >> N;
  
  vector<long long> A(N);
  for (long long &l:A) cin >> l;
  
  long long step=0;
  long long gap;
  for (long long i=1;i<N;i++) {
    gap = max(0ll,A.at(i-1)-A.at(i));
    if (gap > 0) {
      step += gap;
      A.at(i) += gap;
    }
  }
  cout << step << endl;
}

Measured memory_bytes: 4840
#include <iostream>

int main(){
   int a[7] = {1,3,5,7,8,10,12};
   int b[4] = {4,6,9,11};

   int x, y;
   std::cin >> x >> y;

   int gx = 2;
   int gy = 2;
   for(int i=0; i<7; ++i){
      if(x==a[i]) gx = 0;
      if(y==a[i]) gy = 0;
   }
   for(int i=0; i<4; ++i){
      if(x==b[i]) gx = 1;
      if(y==b[i]) gy = 1;
   }
   if(gx==gy) std::cout << "Yes" << std::endl;
   else std::cout << "No" << std::endl;

   return 0;
   
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define M (i*10+q[j])
#define pa pair<int,int>
/*#define F first
#define S second*/
typedef long long ll;
#define X first
#define Y second

int main()
{
    int n;
    int count=0;
    cin>>n;
    int *a=new int [n];
    rep(i,n)
    cin>>a[i];
    for(int i=1; i<n-1; i++)
    {
        if((a[i]<a[i-1]&&a[i]>a[i+1])||(a[i]>a[i-1]&&a[i]<a[i+1]))
            count++;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 256
S = list(input())
def f(S):
    N = S.count("B")
    k = N
    i = len(S)-1
    res = 0
    while i >= 1:
        if S[i] == "B":
            k -= 1
        else:
            res += k
        i -= 1
    return res
print(f(S), flush=True)

Measured memory_bytes: 4840
# コード整理

import sys
from operator import itemgetter

input = sys.stdin.readline

#################
# 定数
#################
TIME = 0
VAL = 1

##################
# 入力処理
##################
N, T = [int(a) for a in input().split()]
time_value = [(-1, -1)] + [tuple(int(a) for a in input().split()) for _ in range(N)]

# Sort the array in the increasing order of value
time_value.sort(key = itemgetter(VAL))

###########################
# 動的計画法（Knapsack problem）のテーブル埋め
# 時間の最大値は T - 1
##########################
dp = [[-1] * T for _ in range(N + 1)] # (N+1)行 x T列 2次元リスト

for t in range(0, T):
    dp[0][t] = 0

for n in range(1, N + 1):
    dp[n][0] = 0
    for t in range(1, T):
        if time_value[n][TIME] > t:
            dp[n][t] = dp[n - 1][t]
        else:
            dp[n][t] = max(dp[n - 1][t],
                             time_value[n][VAL] + dp[n - 1][t - time_value[n][TIME]])

##########################
# DPテーブルを用いて問題を解く
##########################

# t = T - 1に食べ始める料理が N, N-1, N-2, ..., 2, 1それぞれの場合で
# 美味しさの最大値を出し、更にその最大値を取る

# 最後に食べる料理がNの場合
val_acum = time_value[N][VAL]
t = T - 1  # N以外の料理を食べるのに使える時間
max_val = val_acum + dp[N - 1][t]

for n in range(N - 1, 0, -1):  # 最後に食べる料理が n = N-1, N-2, ..., 2, 1の場合
    val_acum += time_value[n][VAL] # 料理 N, N-1, ..., nの美味しさ合計
    t -= time_value[n + 1][TIME] # その他の料理 1, 2, ..., n-1を食べるのに使える時間
    if t < 0:
        break
    else:
        max_val = max(max_val, val_acum + dp[n - 1][t])

print(max_val)


Measured memory_bytes: 114012
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <bitset>
#include <cmath>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

ll dp[100][2];
int main(){
    int n; ll k;
    cin >> n >> k;
    ll a[n];
    rep(i,n) cin >> a[i];
    rep(i,100){
        dp[i][0]=-1;
        dp[i][1]=-1;
    }
    dp[50][0]=0;
    for(int d=49;d>=0;d--){
        ll mask = 1LL<<d;
        int num = 0;
        rep(i,n) if(a[i]&mask) num++;
        if(k&mask){//Xの下からd桁目が１
            if(dp[d+1][0]>=0){
                chmax(dp[d][0],dp[d+1][0]+mask*(n-num));
                chmax(dp[d][1],dp[d+1][0]+mask*num);
            }
            if(dp[d+1][1]>=0) chmax(dp[d][1],dp[d+1][1]+mask*max(num,n-num));
        }else{
            if(dp[d+1][0]>=0) chmax(dp[d][0],dp[d+1][0]+mask*num);
            if(dp[d+1][1]>=0) chmax(dp[d][1],dp[d+1][1]+mask*max(num,n-num));
        }
    }
    ll ans = max(dp[0][0],dp[0][1]);
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<l_l,ll> lll;
typedef vector<string> vs;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
string s,t;
const ll mod1=1000000007,mod2=1000000009;
const ll base1=1007,base2=1009;
int main(){
    cin>>s>>t;
    ll n=sz(s);
    ll m=sz(t);
    vl hash(n+1),p(n+1);
    p[0]=1;
    hash[0]=0;
    ll thash=0;
    for(int i=0;i<n;i++){
        hash[i+1]=(hash[i]*base1+s[i])%mod1;
        p[i+1]=(p[i]*base1)%mod1;
    }
    for(int i=0;i<m;i++){
        thash=(thash*base1+t[i])%mod1;
    }
    vl ans;
    for(int i=1;i<=n;i++){
        if(i-m<0)continue;
        //cout<<i<<endl;
        ll res=(hash[i]-hash[i-m]*p[m])%mod1;
        if(res<0)res+=mod1;
        if(res==thash)ans.pb(i-m);
    }
    for(auto p:ans)cout<<p<<endl;
    return 0;
}


Measured memory_bytes: 28348
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#include<ctype.h>
#define MOD 10000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define revrep(i,n) for(ll i=n;i>0;i--)

typedef long long ll;

ll fac[100001], inv[100001];

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

ll mylcm(ll a, ll b) { return a / mygcd(a, b) * b; }

ll mymax(ll a, ll b) { return (a > b) ? a : b; }

ll mymin(ll a, ll b) { return (a < b) ? a : b; }

int myasc(const void* a, const void* b) { return *(ll*)a - *(ll*)b; }

int mydsc(const void* a, const void* b) { return *(ll*)b - *(ll*)a; }

ll mypow(ll a, ll b) {
	ll x;
	if (b == 0) return 1;
	else if (b % 2 == 1) return a * mypow(a, b - 1) % MOD;
	x = mypow(a, b / 2);
	return x * x % MOD;
}

ll mycomb(ll a, ll b) {
	if (a < b || a < 0 || b < 0)return 0;
	return fac[a] * inv[a - b] * inv[b] % MOD;
}

int main() {
	bool flag=false;
	ll a, b, c, k;
	scanf("%lld%lld%lld", &a,&b,&c);
	scanf("%lld", &k);
	for (int i = 0; i <= k; i++) {
		if (b * pow(2, i) > a && c * pow(2, k - i) > b*pow(2,i)) flag = true;
	}
	if (flag) printf("Yes");
	else printf("No");

	return 0;
}

Measured memory_bytes: 2316
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define mp make_pair
#define All(v) v.begin(),v.end()
#define mod 1000000007
#define pi 3.14159265358979323
using namespace std;
ll fact[100004];

int main()
{
    fact[0] = 1;
    for(int i=1;i<=100000;i++)
        fact[i] = (fact[i-1]*i)%mod;

    int x,y;
    cin >> x >> y;
    if(x == y)
    {
        cout << ((2 * fact[x])%mod * fact[y])%mod;
    }
    else if(abs(x-y) == 1)
    {
        cout << (fact[x]*fact[y])%mod;
    }
    else
        cout << 0 << endl;


    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
int main(void){
    int n,s[1000],i;
    double ex1,ex2,b;
    while(scanf("%d",&n),n){
                ex1=ex2=0;
        for(i=0;i<n;i++){
            scanf("%d",&s[i]);
            ex1+=s[i]*s[i];
            ex2+=s[i];
        }
        b=sqrt((ex1/n)-pow(ex2/n,2));
        printf("%.8f\n",b);
    }
    return 0;
}


Measured memory_bytes: 1928
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF = 0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a, LL b) {LL s = 1; while (b > 0) {if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1;} return s;}
LL gcd(LL a, LL b) {return b ? gcd(b, a % b) : a;}
int dr[2][4] = {1, -1, 0, 0, 0, 0, -1, 1};
typedef pair<int, int> P;
int main(void)
{
	int cnt = 0;
	int m, d;
	cin >> m >> d;
	for (int i = 1; i <= m; ++i) {
		for (int j = 1; j <= d; ++j) {
			int a = j % 10;
			int b = j / 10;
			if (a < 2) continue;
			if (b < 2) continue;
			if (a * b == i) ++cnt;
		}
	}
	cout << cnt << endl;

	return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> A(H+1, vector<char>(W+1));
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> A.at(i).at(j);
      if(A.at(i).at(j)=='#'){
        A.at(i).at(W)='#';
        A.at(H).at(j)='#';
      }
    }
  }
  
  for(int i=0; i<H; i++){
    if(A.at(i).at(W)!='#'){
      continue;
    }
    for(int j=0; j<W; j++){
      if(A.at(H).at(j)!='#'){
        continue;
      }
      cout << A.at(i).at(j);
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math


def run():
    k = int(input()) + 1
    x = 0
    for a in range(1, k):
        for b in range(1, k):
            for c in range(1, k):
                x += math.gcd(math.gcd(a, b), c)
    print(x)


if __name__ == '__main__':
    run()


Measured memory_bytes: 9108
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int n;
  cin >> n;
  vll a(n);
  rep(i,n) cin >> a[i];
  
  ll sum = 0;
  rep(i,n) {
    sum += a[i];
  }

  ll x = 0, y;
  ll ans = INFLL;
  rep(i,n-1) {
    x += a[i];
    y = sum - x;
    ans = min(ans, abs(x-y));
  }

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

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

int main()
{
    int n, d, Count = 0;
    cin>>n>>d;
    int a[n][d];

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

    for(int i = 0; i < n; i++)
    {
        float ans;
        int temp;
        for(int j = i + 1; j < n; j++)
        {
            ans = 0;
            for(int k = 0; k < d; k++)
            {
                temp = (a[i][k] - a[j][k]);
                temp *= temp;
                ans += temp;
            }
            ans = sqrt(ans);
            int check;
            check = (int)ans;
            if(check == ans)
                Count++;
        }
    }
    cout<<Count<<endl;
}


Measured memory_bytes: 256
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#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 ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main(void){
    string s;
    cin >>s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
        
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int S, h, m, s;
	cin >> S;
	h = S / 3600;
	S = S % 3600;
	m = S / 60;
	s = S % 60;
	cout << h << ":" << m << ":" << s << '\n';
	return 0;
}

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

using namespace std;

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

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	ll n, k;
	cin >> n >> k;
	int res = 0;
	while (n) {
	  n /= k;
	  res++;
	}
	cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 3624
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool Finish_read;
template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
/*================Header Template==============*/
map<string,int>s;
string w;
int n,m;
int main() {
	read(n);
	while(n--) {
		cin>>w;
		s[w]++;
	}
	read(m);
	while(m--) {
		cin>>w;
		s[w]--;
	}
	int mx=0;
	for(auto it=s.begin();it!=s.end();it++) {
		mx=max(mx,it->second);
	}
	printf("%d\n",mx);
}

Measured memory_bytes: 256
// WARNING: Add compile option "-std=c++11" for C++11 compile.

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;


/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back


/*---  Type ---*/
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;


/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// 4-direction
int dy4[] = {0,  1, -1,  0};
int dx4[] = {1,  0,  0, -1};

// 8-direction
int dy8[] = {0,  1,  1,  1,  0, -1, -1, -1};
int dx8[] = {1,  1,  0, -1, -1, -1,  0,  1};

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

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

  int w[n+1];
  w[0] = 0;
  rep(i, n) {
    int wi;
    cin >> wi;
    w[i+1] = w[i] + wi;
  }

  int ans = 10000000;
  rep(i, n+1) {
    ans = min(ans, abs(w[i] - (w[n]-w[i])));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
// Author: 23forever
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
typedef long long LL;
const int INF = 0x3f3f3f3f;
const int MAXN = 300000;
using namespace std;

inline void enableFileIO() {
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
}

inline int read() {
  int x = 0, w = 1;
  char c = ' ';

  while (c < '0' || c > '9') {
    c = getchar();
    if (c == '-') w = -1;
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }

  return x * w;
}

int n, pre[MAXN + 5][2];

void init() {
  //enableFileIO();

  n = read();
  for (int i = 1; i <= n; ++i) {
    char c = getchar();
    while (c != 'E' && c != 'W') c = getchar();
    //cout << (c == 'E') << endl;
    pre[i][0] = pre[i - 1][0] + (c == 'E');
    pre[i][1] = pre[i - 1][1] + (c == 'W');
  }
}

int main() { 
  init();

  int ans = INF;
  for (int i = 1; i <= n; ++i) {
    int left = pre[i - 1][1], right = pre[n][0] - pre[i][0];  
    //cout << left << ' '  << right << endl;
    ans = min(ans, left + right);
  }

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

Measured memory_bytes: 2560
#include<stdio.h>

int solve(int N){

    int H[N];
    for (int i = 0; i < N; i+=1){scanf("%d", &H[i]);}

    int temp_max = 0;
    int max = 0;

    for (int i = 0; i < N - 1; i += 1){

        if(H[i] >= H[i+1]){

            temp_max += 1;

            if(temp_max > max){
                max = temp_max;
            }
        }else{
            temp_max = 0;
        }
    }

    return max;
}

int main(){

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

    int ans = solve(N);

    printf("%d", ans);

    return 0;
}

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

const int MAX_N = 101000;
int a[MAX_N];
bool visited[MAX_N];
int N;

int main()
{
    scanf("%d", &N);
    for(int i = 1; i <= N; ++i) scanf("%d", &a[i]);
    int res = 0;
    for(int i = 1; i <= N; ++i) {
        if(visited[i]) continue;
        if(a[a[i]] == i) ++res, visited[i] = visited[a[i]] = true; 
    }
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 768
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  const int n=3;
  auto c=new int[][](n, n);
  foreach(i; 0..n) c[i]=readln.split.to!(int[]);

  for(int a0=-105; a0<=105; a0++){
    auto a=new int[](n), b=new int[](n);
    a[0]=a0;
    foreach(j; 0..n) b[j]=c[0][j]-a[0];
    foreach(i; 1..n) a[i]=c[i][0]-b[0];
    bool ok=true;
    foreach(i; 1..n)foreach(j; 1..n){
      if(c[i][j]!=a[i]+b[j]) ok=false;
    }
    if(ok){writeln("Yes"); return;}
  }

  writeln("No");
}

/+
  a1+b1 a1+b2 a1+b3 
  a2+b1 a2+b2 a2+b3
  a3+b1 a3+b2 a3+b3
+/

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int ans1=0,ans2=0;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	 if(s[i]-'0'==(i%2))ans1++;
	 else ans2++;
	cout<<min(ans1,ans2)<<endl;
}

Measured memory_bytes: 512
N, M = map(int, input().split())
s = [0] * M
t = [0] * M
for i in range(M):
    s[i], t[i] = map(int, input().split())

imos = [0] * (10**5+2)

for i in range(M):
    imos[s[i]] += 1
    imos[t[i]+1] -= 1

for i in range(10**5+1):
    imos[i+1] += imos[i]

count = 0
for i in range(10**5+2):
    if imos[i] == M:
        count += 1

print(count)


Measured memory_bytes: 14836
import java.util.*;

public class Main {
    static StringBuilder sb = new StringBuilder();
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        setStr(1, 0, new int[n]);
        System.out.print(sb);
    }
    
    static void setStr(int idx, int max, int[] arr) {
        if (idx == arr.length) {
            for(int i = 0; i < arr.length; i++) {
                sb.append((char)(arr[i] + 'a'));
            }
            sb.append("\n");
            return;
        }
        for (int i = 0; i <= max + 1; i++) {
            arr[idx] = i;
            setStr(idx + 1, Math.max(max, i), arr);
        }
    }
}


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

int ans;
string s;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	
 	cin >> s;
 	for (int i = 0; i < s.size(); i++) {
 		if (!(i&1)) {
 			ans -= (s[i] == 'p');
 		}
 		else {
 			ans += (s[i] == 'g');
 		}
 	}
 	cout << ans << '\n';
 	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,n,m) for(int i=n;i<int(m);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int vx[]={0,0,-1,1};
int vy[]={1,-1,0,0};
int dx[]={1,0,-1,1,-1,1,0,-1};
int dy[]={1,1,1,0,0,-1,-1,-1};

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=100010;

int main(){
	int t;
	cin>>t;
	bool ans[t];
	for(int time=0;time<t;time++){
		ll a,b,c,d;
		cin>>a>>b>>c>>d;
		ans[time]=true;

		if(a<b)ans[time]=false;
		else if(a%b>c){
			ans[time]=false;
		}else if(d<b){
			ans[time]=false;
		}else if(d%b==0){
			ans[time]=true;
		}else{
			//b<x<dのxになったらアウト
			d%=b;
			for(int j=0;j<3000;j++){
				if(a%b>c){
					ans[time]=false;
					break;
				}
				a=a%b;
				if(c>a)a+=(c-a)/d*d;
				a+=d;
			}
		}
	}
	REP(i,t){
		if(ans[i])cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll, ll>
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const int sz=2e5+100;
map<pii,int> mp;
vector<pii> edge;
vector<int> ad[sz];
int clr;
void DFS(int p,int parent,int last)
{
    int i=1;
    for(auto xx: ad[p])
    {
         if(xx != parent)
         {
             if(i==last) ++i;
             while(i>=clr) ++clr;
             int tempp=p,tempq=xx;
             if(tempp>tempq) swap(tempp,tempq);
             mp[{tempp,tempq}]=i;
             DFS(xx,p,i);
             ++i;
         }
    }
}
int main()
{
    Khela
    int a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    while(cin>>n)
    {
        for(i=0;i<=n;i++) ad[i].clear();
        mp.clear();
        edge.clear();
        for(i=1;i<n;i++)
        {
            cin>>p>>q;
            ad[p].pb(q);
            ad[q].pb(p);
            if(p>q) swap(p,q);
            edge.pb({p,q});
        }
        clr=0;
        DFS(1,-1,-1);
        cout<<clr-1<<endl;
        if(n==1) clr=0;
        for(auto xx: edge){
            cout<<mp[{xx.f,xx.s}]<<endl;
        }
 
    }
 
}

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

using namespace std;

template<typename T>void read(T&x){x=0;int fl=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')
fl=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}x*=fl;}
template<typename T,typename...Args>inline void read(T&t,Args&...args){read(t);read(args...);}

typedef long long LL;
typedef pair<int, int> pii;
#define mp(x, y) make_pair(x, y)
#define pb(x) emplace_back(x)

int main(){
	int a, b, c;
	read(a, b, c);
	printf("%d %d %d\n", c, a, b);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#define _for(i,n) for(int i = 0; i < n; i++)

using namespace std;



int main() {
  int a[5];
  _for(i,5) cin >> a[i];
  int b[5];
  _for(i,5) {
    b[i] = a[i]%10;
  }
  int sum = 0;
  _for(i,5) {
    sum += (a[i]/10+1)*10;
  }
  int minb = 9;
  int all0 = 1;
  _for(i,5) {
    if(b[i]==0) sum-=10;
    else {minb = min(minb,b[i]);
    all0 = 0;
    
    }
  }
  sum += minb - 10;
  if(all0==1) sum+=1;
  cout << sum << endl;
  

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>PP;
ll key[1005]={0};
ll cost[1005]={0};
ll dp[(1<<12)+5][1005]={0};
const ll INF=123456789012;
int main(){
  ll n, m;cin>>n>>m;
  for(int i=0;i<(1<<12)+5;i++){
    for(int j=0;j<1005;j++){
      dp[i][j]=INF;
    }
  }
  dp[0][0]=0;
  for(int i=1;i<=m;i++){
    ll b;
    cin>>cost[i]>>b;
    for(int j=0;j<b;j++){
      ll c;
      cin>>c;
      key[i]+=(1<<(c-1));
    }
  }
  for(ll i=0;i<(1<<n);i++){
    for(int j=0;j<m;j++){
      dp[i][j+1]=min(dp[i][j],dp[i][j+1]);
      dp[i|key[j+1]][j+1]=min(dp[i|key[j+1]][j+1],dp[i][j]+cost[j+1]);
    }
  }
  if(dp[(1<<n)-1][m]==INF)cout<<-1<<endl;
  else cout<<dp[(1<<n)-1][m]<<endl;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

bool cmp(pair<ll, ll> a, pair<ll, ll> b)
{
    return a.second < b.second;
}

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

    int N; cin >> N;
    vector<pair<ll, ll>> A(N), B(N);
    rep(i, N) cin >> A[i].fi >> A[i].se;
    rep(i, N) {
        B[i].fi = A[i].fi - A[i].se + 1e9;
        if (A[i].fi + A[i].se <= 1e9) B[i].se = A[i].fi + A[i].se + 1e9;
        else B[i].se = 1e18;
    }
    sort(all(B), cmp);
    ll res = 0;
    ll endtime = -1e9;
    // rep(i, N) {
    //     cout << B[i].fi << ' ' << B[i].se;
    //     cout << endl;
    // }
    for (int i = 0; i < N; ++i) {
        if (B[i].first >= endtime) {
            endtime = B[i].second;
            ++res;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3456
/*
 * @Author: RBQRBQ
 * @Date: 2020-04-15 20:54:51
 * @LastEditors: RBQRBQ
 * @LastEditTime: 2020-04-16 21:28:50
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
const ll maxn=1000005;
namespace IO{
    template<typename T>inline void read(T &x){
        x=0;ll f=1;char ch=getchar();
        while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
        while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
        x=x*f;
    }
}
using namespace IO;
namespace MOD{
inline int M(int x){return (x+20*mod)%mod;}
inline int mul(int x,int y){return 1ll*(M(x))*(M(y))%mod;}
inline int add(int x,int y){return M(x+y);}
inline int sub(int x,int y){return (M(x-y));}
inline int sq(int x){return 1ll*x%mod*x%mod%mod;}}
using namespace MOD;
ll mu[maxn+10],p[maxn+10],phi[maxn+10],v[maxn+10],func[maxn+10],inv[maxn+10];
ll  qpow(ll x, ll y) {
    if (y == 0) return 1;
	ll tmp = qpow(x, y / 2);
	if (y % 2 == 0) return 1ll * tmp * tmp % mod;
	else return 1ll * tmp * tmp % mod * x % mod;
}

inline void init() {
    for(int i=1;i<=maxn;i++)
    inv[i]=qpow(i,mod-2);
    v[1]=mu[1]=phi[1]=1;
    int cnt=0;
    for (int i=2;i<=maxn;++i) {
        if (!v[i]) p[++cnt]=i,mu[i]=-1,phi[i]=i-1;
        for ( int j=1;j<=cnt&&i*p[j]<=maxn;++j) {
            v[i*p[j]]=1;
            if (i%p[j]) mu[i*p[j]]=-mu[i],phi[i*p[j]]=phi[i]*phi[p[j]];
            else { mu[i*p[j]]=0,phi[i*p[j]]=phi[i]*p[j]; break; }
        }
    }
    for(int i=1;i<=maxn;i++)
    for(int j=1;j*i<=maxn;j++)
    func[i*j]=add(func[i*j],mul(mu[i],inv[j]));
}
int N;
ll A[maxn+10];
ll mp[maxn+10];
ll ans1,ans2;
ll f[maxn+10];
ll mn(-1);
int main(){
    read(N);
    init();
    for(int i=1;i<=N;i++){read(A[i]);ans2=add(ans2,A[i]);++mp[A[i]];mn=max(mn,A[i]);}
    for(int i=1;i<=mn;i++)
    for(int j=i;j<=mn;j+=i)
    {
        f[i]=add(f[i],mul(mp[j],j));
    }
    ans1=0;
    for(int i=1;i<=mn;i++)
    {
        ans1=add(ans1,mul(func[i],sq(f[i])));
    }
    cout<<(sub(ans1,ans2)*inv[2])%mod;
    return 0;
}

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

bool f(const long kind, const long n, const vector<long>& a){
    map<long,long> c;
    for(long i=0; i<n-1; i++){
        if(a[i]>=a[i+1]){
            c.erase(c.lower_bound(a[i+1]), c.end());
            long j = a[i+1]-1;
            c[j]++;
            while(c[j]>=kind){
                c[j]=0;
                if(j<=0){
                    return false;
                }
                c[j-1]++;
                j--;
            }
        }
    }
    return true;
}

bool strict_increasing(const vector<long>& a){
    size_t n = a.size();
    for(size_t i=1; i<n; i++){
        if(a[i-1]>=a[i]){
            return false;
        }
    }
    return true;
}

int main(void){
    long n;
    cin >> n;
    vector<long> a(n);
    for(long i=0; i<n; i++){
        cin >> a[i];
    }
    if(strict_increasing(a)){
        cout << 1 << endl;
        return 0;
    }
    long left=1, right=n;
    for(;;){
        const long mid = (left+right)/2;
        if(right-left<=1){
            if(f(right, n, a)){
                cout << right << endl;
            }else{
                cout << left << endl;
            }
            return 0;
        }
        const bool b = f(mid, n, a);
        //printf("[%ld, %ld] %ld %s\n", left, right, mid, b ? "true" : "false");
        if(b){
            right=mid;
        }else{
            left=mid;
        }
    }
}


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

int main()
{
	int y = 700;
	string S;
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'o') {
			y += 100;
		}
		
	}
	cout << y << endl;
		}

Measured memory_bytes: 3496
n=int(input())
l=list(map(int,input().split()))
k=l[n]
count=1
sumleaf=1
flag=True
i0=0
suml=[]
for i in l:
    i0+=i
    suml.append(i0)
if l[0]>2 or l[0]==1 and n>=1:
    print(-1)
    flag=False
elif n==0 and l[0]!=1:
    print(-1)
    flag=False
    
else:
    for i in range(1,n+1):
        sumleaf*=2
        if i==n and sumleaf<k:
            flag=False
            print(-1)
            break
        elif i==n:
            count+=k
        else:
            if sumleaf<=l[i]:
                flag=False
                print(-1)
                break
            else:
                sumlnew=suml[n]-suml[i-1]
                count+=min(sumlnew,sumleaf)
                sumleaf=min(sumlnew,sumleaf)-l[i]
    
                    
                    
                    
                    
                
if flag==True:
    print(count)

Measured memory_bytes: 86124
#include<iostream>
#include<algorithm>
 
using namespace std;
typedef long long Int;
#define INF (1LL<<60)
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
Int dp[20][54000];
Int table[54000];

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

	Int N;
	cin >> N;

	Int i=0;
	while(i*i<=N) i++;

	cout << (i-1)*(i-1)	<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    vector<int>T(N);
    int sum = 0;
    for(int i = 0; i < N; i++) {
        cin >> T[i];
        sum+=T[i];
    }
    int M;
    cin >> M;
    for(int i = 0; i < M; i++) {
        int P,X;
        cin >> P >> X;
        P--;
        cout << sum-T[P]+X << endl;
    }
}


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

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

ll dp[100005];

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

    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a), q(b), r(c);
    for(int i = 0; i < a; ++i)  cin >> p[i];
    for(int i = 0; i < b; ++i)  cin >> q[i];
    for(int i = 0; i < c; ++i)  cin >> r[i];
    sort(p.begin(), p.end(), greater<ll>());
    sort(q.begin(), q.end(), greater<ll>());
    sort(r.begin(), r.end(), greater<ll>());
    priority_queue<ll, vector<ll>, greater<ll>> que;
    for(int i = 0; i < x; ++i)  que.push(p[i]);
    for(int i = 0; i < y; ++i)  que.push(q[i]);
    for(int i = 0; i < c; ++i){
        if(r[i] > que.top()){
            que.pop();
            que.push(r[i]);
        }
    }
    ll ans = 0;
    while(!que.empty()){
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 4852
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
typedef pair<int,int> P;
typedef pair<int,P> PP; 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1e9+7;

signed main(){
  int n,k;
  cin>>n>>k;
  if(k==1)cout<<0<<endl;
  else cout<<(n-k)<<endl;
  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> graph[1050];
int main() {
  int a,b,x;
  cin >> a >> b >> x;
  double S = 0;
  if((a * a * b) / 2.0 < x) 
  S = 2 * (((double)b / a) - (double)x / (a * a * a)); 
  else 
  S = (double)(b * b * a) / (2 * x);
    cout << fixed << setprecision(10) << (atan(S) * 180.0) / M_PI;
    return 0;
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rp(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep(i, x, n) for (int i = (x); i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)

#define TRACE(x...)
#define PRINT(x...)
#define WATCH(x) TRACE(cout << #x << " = " << x << endl )

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const int MOD = 1e9 + 7;
char mat[1001][1001];
int dp[1001][1001];

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    int h, w;
    cin >> h >> w;
    rp(i,h) rp(j,w) cin >> mat[i][j];
    rp(j,w) {
    	if(mat[0][j] == '.') dp[0][j] = 1;
    	else break;
    }
    rp(i,h) {
    	if(mat[i][0] == '.') dp[i][0] = 1;
    	else break;
    }
    rep(i,1,h) {
    	rep(j,1,w) {
    		if(mat[i][j] == '.') {
    			dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD;
    		}
    	}
    }
    
    TRACE(
    	rp(i,h) {
   			rp(j,w) {
   				cout << dp[i][j];
   			}
   			cout << '\n';
   		}
    )
    
    cout << dp[h-1][w-1] << '\n';
    
   
    return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))

int main()
{
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << (H - h)*(W - w) << endl;
}



Measured memory_bytes: 256