akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int mod = 998244353;
int n,m,f[201][18010],g1[18010],g2[18010];
ll fac[18010],ifac[18010];
namespace FFT{
	int r[18010],maxn,len;
	ll fp(ll a,ll k){
		ll ans=1;
		for(;k;k>>=1,a=a*a%mod)
			if(k&1) ans=a*ans%mod;
		return ans;
	}
	void build(int n){
		maxn=1;len=0;while(maxn<=n) maxn<<=1,len++;
		for(int i=0;i<maxn;i++) r[i]=r[i>>1]>>1|(i&1)<<len-1;
	}
	int add(int x,int y){return x+y<mod?x+y:x+y-mod;}
	void NTT(int *a,int tag){
		for(int i=0;i<maxn;i++) if(r[i]>i) swap(a[r[i]],a[i]);
		for(int mid=1;mid<maxn;mid<<=1){
			int wn=fp(3,(mod-1)/mid/2);
			if(tag<0) wn=fp(wn,mod-2);
			for(int l=0;l<maxn;l+=mid<<1)
				for(int i=l,w=1;i<l+mid;i++,w=1ll*w*wn%mod){
					int x=a[i],y=1ll*a[i+mid]*w%mod;
					a[i]=add(x,y);a[i+mid]=add(x,mod-y);
				}
		}
		if(tag<0){
			int Inv=fp(maxn,mod-2);
			for(int i=0;i<maxn;i++) a[i]=1ll*a[i]*Inv%mod;
		}
	}
	void mult(int *g1,int *g2,int *g3,int n,int m){
		build(n+m);
		for(int i=n+1;i<maxn;i++) g1[i]=0;
		for(int i=m+1;i<maxn;i++) g2[i]=0;
		NTT(g1,1);NTT(g2,1);
		for(int i=0;i<maxn;i++) g3[i]=1ll*g1[i]*g2[i]%mod;
		NTT(g3,-1);
	}
}
int main(){
	read(n);read(m);
	for(int i=0;i<=n;i++) f[1][i]=1;
	fac[0]=1;
	for(int i=1;i<=n+2;i++) fac[i]=fac[i-1]*i%mod;
	ifac[n+2]=FFT::fp(fac[n+2],mod-2);
	for(int i=n+2;i;i--) ifac[i-1]=ifac[i]*i%mod;
	for(int i=1;i<m;i++){
		for(int j=0;j<=n;j++) g1[j]=1ll*f[i][j]*ifac[j]%mod;
		for(int j=1;j<=n;j++) g2[j]=ifac[j+2];
		g2[0]=0;
		FFT::mult(g1,g2,f[i+1],n,n);
		for(int j=0;j<=n;j++) f[i+1][j]=(1ll*f[i+1][j]*fac[j+2]+1ll*((j+1)*j/2+1)*f[i][j])%mod;
	}
	//for(int i=1;i<=n;i++)
	//	for(int j=1;j<=m;j++)
	//		cout<<i<<' '<<j<<' '<<f[j][i]<<'\n';
	ll ans=0;
	for(int i=0;i<=n;i++)
		ans=(ans+fac[n]*ifac[i]%mod*ifac[n-i]%mod*f[m][i])%mod;
	cout<<(ans+mod)%mod<<'\n';
	return 0;
}


Measured memory_bytes: 14592
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define MOD 1000000007

int main(){
	ll K, A, B;
	cin >> K >> A >> B;
	if (B - A < 3) {
		cout << 1 + K << endl;
		return 0;
	}
	
	ll a = A - 1;
	if (K <= a) {
		cout << 1 + K << endl;
		return 0;
	}

	K -= a;
	cout << A + (B - A) * (K / 2) + K % 2 << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>

using namespace std;

int n,m,q[1010],g;
const int soup=1000000007;
long long int tabi=1;


int main(){
    scanf("%d",&n);
    for(int j=0;j<=1000;j++)q[j]=1;
    for(int i=1;i<=n;i++){
        g=i;
        for(int j=2;j<=1000;j++){
            while(g%j==0){
                g/=j;
                q[j]++;
            }
        }
    }
    
    //printf("%d\n",sp);
    for(int j=0;j<=n;j++){
        tabi=(tabi*q[j])%soup;
    }
    printf("%lld\n",tabi);
}

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

int main() {
	int n;
	cin >> n;
	int a[n+1], b[100001] = {};
	for(int i = 1; i < n+1; i++) cin >> a[i];
	
	sort(a+1, a+n+1);
	int j = 1, c = 0;
	for(int i = 1; i <= 1e5; i++)
	{
		if(a[j] < i)
		{
			while(a[j] < i && j < n+1)
			{
				c++;
				j++;
			}
		}
		b[i] = c;
	}
	int ans = 0;
	for(int i = 1; i < 1e5+1; i++)
	{
		if(b[i] == n/2) ans++;
	}
	cout << ans;
	
	// your code goes here
	return 0;
}

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

using namespace std;

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

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

    vector<int> ans;
    for (int i = x - k + 1; i <= x + k - 1; i++) {
        if (-1000000 <= i && i <= 1000000) {
            ans.push_back(i);
        }
    }
    for (int a : ans) {
        cout << a << ' ';
    }
}

Measured memory_bytes: 256
#!python
# -*- coding: utf-8 -*-

def main():
    H, W = map(int, input().split())
    grid = []
    for h in range(H):
        grid.append([c for c in input()])

    for x in range(W):
        for y in range(H):
            if grid[y][x] == '#':
                for x_, y_ in zip([0, 0, -1, 1], [-1, 1, 0, 0]):
                    nx = x + x_
                    ny = y + y_
                    if not(0 <= nx < W):
                        continue
                    if not(0 <= ny < H):
                        continue
                    if grid[ny][nx] == '#':
                        break
                else:
                    print('No')
                    return
    print("Yes")
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
K,T = map(int,input().split())
from heapq import heapify, heappop, heappush
A = list(map(int,input().split()))
for i in range(T):
    A[i] = (-A[i],i)
A.append((0,999))
A.sort()
heapify(A)
ans = 0
pre = -1

for i in range(K):
    a,i = heappop(A)
    if pre != i:
        heappush(A,(a+1,i))
        pre = i
    else:
        a2,i2 = heappop(A)
        if a2 < 0:
            pre = i2
            heappush(A,(a2+1,i2))
            heappush(A,(a,i))
        else:
            ans += 1
            heappush(A,(a+1,i))
            heappush(A,(a2,i2))
print(ans)

    




Measured memory_bytes: 49880
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n,c = readline() |> split |> parseMap
	d = Array{Int}(c,c)
	for i in 1:c
		d[:,i] = readline() |> split |> parseMap
	end
	a0 = zeros(Int,c)
	a1 = zeros(Int,c)
	a2 = zeros(Int,c)
	for i in 1:n
		cc = readline() |> split |> parseMap
		for j in 1:n
			if (i+j)%3 == 1
				a1[cc[j]] += 1
			elseif (i+j)%3 == 2
				a2[cc[j]] += 1
			else
				a0[cc[j]] += 1
			end
		end
	end
	m = maximum(d)*n*n
	for i in 1:c
		for j in 1:c
			for k in 1:c
				if i!=j && j!=k && k!=i
					total = 0
					for p in 1:c
						total += a1[p]*d[i,p]
						total += a2[p]*d[j,p]
						total += a0[p]*d[k,p]
					end
					m = min(m,total)
				end
			end
		end
	end
	println(m)
end

main()

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n;
    int a;
    priority_queue<int> q;

    ll ans = 0;

    Scd(n);

    for(int i = 0; i < 3*n; i++){
        Scd(a);
        q.push(a);
    }

    Rep(i,n){
        q.pop();
        ans += q.top();
        q.pop();
    }

    printf ("%llu\n", ans);

    return 0;
}



Measured memory_bytes: 2420
//By Don4ick
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qwer1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

using namespace std;

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

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

	ll n, a, b;
	cin >> n >> a >> b;
	if (a > b || (n == 1 && a != b))
		cout << 0 << endl;
	else
		cout << a + b * (n - 1) - b - (n - 1) * a + 1 << endl;

	return 0;
}


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

int gcd(int a,int b) {
	int t;
	while (b != 0) {
		t = a % b; a = b; b = t;
	}
	return a;
}

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

	vector<int>l(n + 1, 0), r(n + 1, 0);
	for (int i = 0; i < n; ++i)l[i+1]=gcd(a[i], l[i]);//累積gcdなので単純に連続するものの比較ではダメ
	for (int i = n - 1; i >=0; --i)r[i]=gcd(a[i], r[i+1]);
	int maxv = 0,ans;
	for (int i = 0; i < n; ++i) {
		ans = gcd(l[i], r[i+1]);
		maxv=max(ans,maxv);
	}
	cout << maxv << endl;
	return 0;
}


Measured memory_bytes: 1408
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
n,k = map(int,input().split())
ans = Base_10_to_n(n,k)
print(len(ans))

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

 
int main(){
    int A,B,C,D,E,F;
    cin >> A >> B >> C >> D >> E >> F;
    set<int> W;
    set<int> S;
    for(int i=0;i<=30;i++){
        int K = 0;
        for(int j=0;j<=30;j++){
            int K = 100 * A * i + 100 * B * j;
            if(K > F) break;
            W.insert(K);
        }
    }
    for(int i=0;i<=3000;i++){
        for(int j=0;j<=3000;j++){
            int K = C * i + D * j;
            if(K > F) break;
            S.insert(K);
        }
    }
    int water=0,suger=0;
    double c = 0;
    for(auto itrW = W.begin();itrW != W.end();itrW++){
        int w = *itrW;
        for(auto itrS = S.begin();itrS != S.end();itrS++){
            int s = *itrS;
            if(w + s > F) break;
            if(100 * s <= E * w){
                double m = 100 * s / (double)(w+s);
                if(c <= m){
                    //cout << m << "%" << w << " " << s << endl;
                    c = m;
                    water = w;
                    suger = s;
                }
            }
        }
    }
    cout << water + suger << " " << suger << endl;
    return 0;
}

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

int gcd(int a,int b){
    int temp;
    if(a == 0 || b==0)return 0;
    while(true){
        if(a == 0) return b;
        if(a < b){
            temp = a;
            a = b;
            b = temp;
        }
        temp = a;
        a = a%b;
    }
}

int main(){
    long k;
    cin >> k;
    long long ans=0;
    //すべて同じになる場合．
    ans = ((1+k)*k)/2;
    //すべて別々になる場合
    rep(i,k+1){
        for(int j=i+1; j<k+1;j++){
            for(int l=j+1;l<k+1;l++){
                int temp;
                ans += gcd(l, gcd(j,i))*6;
            }
        }
    }
    //同じ数字が一組
    rep(i,k+1){
        for(int j=i+1;j<k+1;j++){
            ans += gcd(j,i)*6;
        }
    }
    cout << ans << endl;
}

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

int main()
{
  string s, t;
  cin >> s;
  if (s.size() % 2 == 1)
  {
    cout << "No" << endl;
    return 0;
  }
  int ans = 0;
  for (int i = 0; i < s.size() - 1; i++)
  {
    if (s[i] =='h' && s[i + 1] == 'i')
    {
      ans++;
    }
  }
  if (ans == s.size()/2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair
using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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 gcd(int a, int b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));}

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

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  FOR(i, 1, 1000000){
    int val = a * i;
    int md = val % b;
    if (md == c){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
const int INF = 1<<30;
struct MaxFlow {
	struct Edge { int to, cap, rev; };
	int N;
	vector<vector<Edge>> G;
	vector<bool> used;
	MaxFlow(int N) : N(N), G(N) {}
	void add_edge(int from, int to, int cap) {
		G[from].push_back({to, cap, (int)G[to].size()});
		G[to].push_back({from, 0, (int)G[from].size()-1});
	}
	int dfs(int v, int t, int f) {
		if (v == t) return f;
		used[v] = true;
		for (unsigned i = 0; i < G[v].size(); ++ i) {
			auto& e = G[v][i];
			if (!used[e.to] && e.cap > 0) {
				int d = dfs(e.to, t, min(f, e.cap));
				if (d > 0) {
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}
	int max_flow(int s, int t) {
		int flow = 0;
		for (;;) {
			used = vector<bool>(N);
			int f = dfs(s, t, INF);
			if (f == 0) return flow;
			flow += f;
		}
	}
};
int main() {
	int H, W;
	cin >> H >> W;
	vector<string> A(H);
	for (auto& x : A) cin >> x;
	MaxFlow m(202);
	for (int i = 0; i < H; ++ i) for (int j = 0; j < W; ++ j) {
		switch (A[i][j]) {
		case 'S':
			m.add_edge(200, i, 300);
			m.add_edge(200, j+100, 300);
			break;
		case 'T':
			m.add_edge(i, 201, 300);
			m.add_edge(j+100, 201, 300);
			break;
		case 'o':
			m.add_edge(i, j+100, 1);
			m.add_edge(j+100, i, 1);
			break;
		}
	}
	int r = m.max_flow(200, 201);
	if (r >= 250) r = -1;
	cout << r << endl;
}


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

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

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

void solve_A(){
    string n;
    cin >> n;

    int m = n.size();
    if(n[m-1] == '3'){
        cout << "bon";
    } else if(n[m-1] == '0' || n[m-1] == '1' || n[m-1] == '6' || n[m-1] == '8'){
        cout << "pon";
    } else cout << "hon";

}

void solve_B(){
    int k;
    string s;
    cin >> k >> s;
    int n = s.size();

    if(n <= k) cout << s;
    else{
        for(int i = 0; i < k; i++){
            cout << s[i];
        }
        cout << "...";
    }
}

void solve_C(){
    int a, b, h, m;
    cin >> a >> b >> h >> m;

    double kakudo = (double) fabs(30 * h - 5.5 * m);
    //double kakudo = (double) fabs((6.5 * h + 30 * m - 360) + 360);
   
    double ans = a * a + b * b - 2 * a * b * cos(kakudo * PI / 180);
    printf("%.10f\n", sqrt(ans));
}

using Graph = vector< vector<int> >;

void solve_D(){
    int n, m;
    cin >> n >> m;
    Graph G(n);
    REP(i,m){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> distance(n, 100000);
    vector<int> ans(n, -1);
    ans[0] = 0;
    distance[0] = 0;

    queue<int> que;

    que.push(0);

    while(!que.empty()){
        int v = que.front();
        que.pop();

        for(int nv : G[v]){
            if(distance[nv] > distance[v] + 1){
                distance[nv] = distance[v] + 1;
                ans[nv] = v;
                que.push(nv);
            }
        }
    }

    cout << "Yes" << endl;
    for(int i = 1; i < n; i++){
        cout << ans[i] + 1 << endl;
    }
}

int main(void){
    solve_D();
    
    return 0;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;

void bfs(const vvi& g, vi& ds, int i) {
    int n = g.size();

    vector<bool> seen(n, false);
    queue<int> queue;
    queue.push(i);
    ds[i] = 0;
    seen[i] = true;

    while (!queue.empty()) {
        int v = queue.front();
        queue.pop();

        for (auto itr = g[v].begin(); itr != g[v].end(); ++itr) {
            if (!seen[*itr]) {
                queue.push(*itr);
                ds[*itr] = ds[v] + 1;
                seen[*itr] = true;
            }
        }
    }

    rep(i, 0, n) {
        if (!seen[i]) { ds[i] = -1; }
    }
}

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

    int n, x, y;
    cin >> n >> x >> y;

    vvi G(n);
    rep(i, 0, n - 1) {
        G[i].push_back(i + 1);
        G[i + 1].push_back(i);
    }
    G[x - 1].push_back(y - 1);
    G[y - 1].push_back(x - 1);

    vvi dists(n, vi(n));
    rep(i, 0, n) { bfs(G, dists[i], i); }

    vi ans(n, 0);
    rep(i, 0, n) {
        rep(j, i + 1, n) { ++ans[dists[i][j]]; }
    }

    rep(i, 1, n) { cout << ans[i] << endl; }

    return 0;
}

Measured memory_bytes: 16128
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#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;}

ll N;
vl A;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> N;
    A = vl(N);
    for(int i = 0; i < N; ++i){
        cin >> A[i];
    }
    solve();
}

// 1 <= N <= 2× 10^5
// 1 <= A_i <= 10^9
// 入力は全て整数

// ll N, vl A
// 踏み台の高さの合計の最小値を出力せよ。
void solve(){
    ll sum=0;
    ll mx=A[0];
    rep(i,1,N){
        sum+=max(0LL,mx-A[i]);
        chmax(mx,A[i]);
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 4712
import java.util.*;

public class Main {
    public static void main(String []args) throws Exception {
    	Main o = new Main();
        o.run();
    }

	void run() throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int []alist = new int[n];
		for (int i = 0; i < n; i++) {
			alist[i] = sc.nextInt();
		}
		LinkedList<Integer> bList = new LinkedList<Integer>();
		for (int i = 0; i < n; i++) {
			if (i % 2 == 0) {
				bList.add(alist[i]);
			} else {
				bList.addFirst(alist[i]);
			}
		}
		if (n % 2 == 1) {
			boolean isFirst = true;
			for (ListIterator<Integer> it = bList.listIterator(bList.size()); it.hasPrevious();) {
				if (isFirst) {
					isFirst = false;
				} else {
					System.out.print(" ");
				}
				System.out.print(it.previous());
			}
			System.out.println();
		} else {
			boolean isFirst = true;
			for (ListIterator<Integer> it = bList.listIterator(); it.hasNext();) {
				if (isFirst) {
					isFirst = false;
				} else {
					System.out.print(" ");
				}
				System.out.print(it.next());
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 100488
import sys


fin = sys.stdin.readline
N = int(fin())
A_list = [int(fin()) for _ in range(N)]
max_prefix = []
cur_max = float('-inf')
for A in A_list:
    cur_max = max(cur_max, A)
    max_prefix.append(cur_max)

cur_max = float('-inf')
max_suffix = [None] * N
for i in reversed(range(N)):
    A = A_list[i]
    cur_max = max(cur_max, A)
    max_suffix[i] = cur_max

print(max_suffix[1])
for i in range(1, N - 1):
    print(max(max_prefix[i - 1], max_suffix[i + 1]))
print(max_prefix[-2])


Measured memory_bytes: 66084
#include <algorithm>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <string>
#include <vector>

#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using ll = long long;
using namespace std;

int main() {
    // int n;
    char c;
    cin >> c;
    int i = (int)c;

    if (i < 97) {
        cout << 'A' << endl;
    } else {
        cout << 'a' << endl;
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int N;
  cin >> N;
  vector<ll> a(N);
  cin >> a;
  ll sum = accumulate(all(a), 0ll);
  ll s = 0ll;
  ll ans = LLINF;
  for (int i = 0; i < N - 1; i++) {
    s += a[i];
    chmin(ans, abs(sum - s * 2ll));
  }
  cout << ans << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 1792
//abc067_b Snake Toy


#include <bits/stdc++.h>
using namespace std;

namespace
{
int L[ 60 ];
}

int main()
{
int i;
int iSum;
int N;
int K;

	cin >> N;
	cin >> K;

	for( i = 0; i < N; i++ ) cin >> L[ i ];

	sort( L, L + N );

	iSum = 0;
	for( i = N - K; i < N; i++ ) iSum += L[ i ];

	cout << iSum << endl;

	return 0;
}






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

#define debug(x) cout<<#x<<"="<<x<<endl
#define pii pair<int,int>
#define ll long long
#define pb push_back
#define mp make_pair

int a[26];
string s;

int main(){
	cin>>s;
	for (int i=0;i<s.size();i++){
		a[s[i]-'a']=1;
	}
	for (int i=0;i<26;i++){
		if (!a[i]){
			cout<<(char)('a'+i);
			return 0;
		}
	}
	cout<<"None";
	return 0;
}

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

int main(){
  long long A,B;
  cin >> A >> B;
  for (long long i = 1; i< B+1 ;i++){
    if (A * i % B == 0){
      cout << i*A;
      break;
    }
  }
}
    

Measured memory_bytes: 3644
#![allow(unused_imports)]
#![allow(unused_macros)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;


//
// Macro debug!
//

#[cfg(debug_assertions)]
include!{"./procon/debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}


//
// Macro input!
//

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


//
// IteratorExt
//

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}


//
// Main
//

fn main() {
    input! {
        n: usize,
        xs: [u64; n],
    }
    let mut xs = xs;
    xs.reverse();

    let f = |a: Option<u64>, &x: &u64| -> Option<u64> {
        match a {
            Some(n) => {
                if x <= n {
                    Some(x)
                } else if x == n + 1 {
                    Some(x - 1)
                } else {
                    None
                }
            },
            None => None,
        }
    };
    let ans = match xs.iter().fold(Some(xs[0]), f) {
        Some(_) => "Yes",
        None => "No",
    };
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){
  int n;cin>>n;vin a(n);rep(i,0,n)cin>>a[i];sort(all(a));cout<<a[n-1]-a[0]<<endl;
}

Measured memory_bytes: 3604
import sys

n, c, k = map(int, input().split())

t = [int(input()) for i in range(n)]
t.sort()

cnt = 1
teiin = 1
for i in range(n):
    if i == 0:
        mati = t[i] + k
    else:
        if teiin < c:
            if mati >= t[i]:
                teiin += 1
            else:
                cnt += 1
                teiin = 1
                mati = t[i] + k
        else:
            cnt += 1
            teiin = 1
            mati = t[i] + k


print(cnt)

Measured memory_bytes: 7532
"use strict";

process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {

    const n = parseInt(input[0], 10);

    let ans = 0;
    if (n % 2 === 0) {
        ans = n;
    }
    else {
        ans = n * 2;
    }

    console.log(ans);

    return 0;
}


Measured memory_bytes: 21192
#include<bits/stdc++.h>
 
using namespace std;
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<long long , long long>
#define pb push_back
#define ll long long
#define ld long double
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
ll power(ll x,ll y,ll m){ll r=1;for(;y;y>>=1){if(y&1)r=r*x%m;x=x*x%m;}return r;}
const ll mod = 1e9 + 7;
const ld pi = 3.14159265358979;
 
int run_test(){
      int n;
      cin >> n;
      set<string> st;
      for(int i=0; i<n; i++){
            string s;
            cin >> s;
            st.insert(s);
      }
      cout << st.size();
      return 0;
}
 
int main(){
    FAST;
    ll t;
    t = 1;
 
    while(t--){
        run_test();
    }
}

Measured memory_bytes: 19232
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define mm 1000000007
int n,m,x,y,z,a,b,c,cc[300000],dd[300000],ff[300000];
char s[500000],ss[500000],g;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=9;i++){
		if (i*100+i*10+i>=n){
			printf("%d\n",i*100+i*10+i);
			return 0;			
		}
	}
	return 0;
}

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

int main(){
	int a,b;
  	char op;
    cin>>a>>op>>b;
	while(op!='?'){
		int ans;
	if ( op == '+' ) ans=a+b;
	else if ( op == '-' ) ans=a-b;
	else if ( op == '*' ) ans=a*b;
	else if ( op == '/' ) ans=a/b;
	cout << ans<< endl;
	cin>>a>>op>>b;
	}
	return 0;
}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define pb push_back
using namespace std;

string s="", t, kmpinp="", inps, inp2="";
int selfkmptmp;

vector<int> KMP(string S)
{
	vector<int> pi(S.length()+1, 0);
	for(int i = 1; i < S.length(); i++)
	{
		int j = pi[i-1];
		while(S[j]!=S[i] && j)
		{
			j=pi[j-1];
		}
		pi[i]= j + (S[i]==S[j]);
	}
	vector<int> occ;
	for(int i = 0; i < S.length(); i++)
	{
		if(pi[i]==t.length())
		{
			occ.pb(i);
		}
	}
	return occ;
}
int solve(vector<int> occ)
{
	vector<int> dp(occ.size() + 1);
	int ptr=0;
	int ret = (occ.size()>0);
	dp[0] = (occ.size()>0);
	for(int i = 1; i < occ.size(); i++)
	{
		while(occ[i]-occ[ptr]>t.length()) ptr++;
		if(occ[i]-occ[ptr]==t.length())
		{
			dp[i]=dp[ptr]+1;
			ret=max(ret, dp[i]);
		}
		else
		{
			dp[i] = 1;
		}
	}
	return ret;
}
int main()
{
	cin >> inps >> t;
	while(inp2.length() < t.length())
	{
		inp2+=inps;
	}
	s+=inp2;
	s+=inp2;
	kmpinp+=t;
	kmpinp+="#";
	kmpinp+=s;
	kmpinp+=s;
	//cout << kmpinp << endl;
	vector<int> occ1 = KMP(kmpinp);
	// for(auto v: occ1) cout << v << " ";
	// 	cout << endl;
	kmpinp+=inp2;
	//cout << kmpinp << endl;
	vector<int> occ2 = KMP(kmpinp);
	// for(auto v: occ2) cout << v << " ";
	// 	cout << endl;
	int pow1=solve(occ1), pow2=solve(occ2);
	if(pow2>pow1) 
	{	
		cout << -1;
		return 0;
	}
	cout << pow1;
}

Measured memory_bytes: 105520
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    int N; cin >> N;
    vector<int> V(N);
    vector<int> C(N);
    for(int &v:V)
        cin >> v;
    for(int &c:C)
        cin >> c;
    
    int ans = -INF;
    for(int i=0; i<(1<<N); i++){
        int sum = 0;
        for(int j=0; j<N; j++){
            if((i>>j) & 1) sum += V[j] - C[j];
        }
        ans = max(ans, sum);
    }
    
    cout << ans << endl;
    return 0;
}


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

string LCS(string s,string t){

  int n=s.length();
  int m=t.length();

  //int dp[n+1][m+1];
  int**dp=new int*[n+1];
  for(int i=0;i<=n;i++){
    dp[i]=new int[m+1];
  }
  //base case
  for(int j=0;j<=m;j++){
    dp[n][j]=0;
  }
  for(int i=0;i<=n;i++){
    dp[i][m]=0;
  }

  //fill dp array
  for(int i=n-1;i>=0;i--){
    for(int j=m-1;j>=0;j--){
      if(s[i]==t[j]){
        dp[i][j]=dp[i+1][j+1]+1;
      }else{
        dp[i][j]=max(dp[i+1][j],dp[i][j+1]);
      }
    }
  }/*
  for(int i=0;i<=n;i++){
    for(int j=0;j<=m;j++){
      cout<<dp[i][j]<<" ";
    }
    cout<<endl;
  }*/
  //cout<<dp[0][0];
  string ans="";
  // now backtrack the dp array to find the string
  int i=0,j=0;
  while(i<n && j<m){

    if(s[i]==t[j]){
      ans+=s[i];
      i++;
      j++;
    }
    else if(dp[i+1][j] < dp[i][j+1]){
      j++;
    }
    else {
      i++;
    }
  }


  return ans;
}

int main(){

  string s,t;
  cin>>s>>t;

  string ans=LCS(s,t);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 35456
// abc152_a
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int n,m;
  cin>>n>>m;
  cout<<((n==m)?"Yes":"No")<<endl;
  return 0;
}


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

int main(){
    int N,L,i;
    cin >> N >> L;
    vector<string> S(N);
    for(i=0;i<N;i++) cin >> S.at(i);
    sort(S.begin(),S.end());
    for(i=0;i<N;i++) cout << S.at(i);
    cout << endl;
    return 0;
}

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

using namespace std;

int main(void){
  vector<int> A(3);
  for(int i = 0; i < 3; i++) cin >> A[i];
  sort(A.rbegin(), A.rend());
  cout << A[0] * 10 + A[1] + A[2] << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = double.Parse(Console.ReadLine());
            Console.WriteLine(Math.Pow(n / 3, 3));
        }
    }
}

Measured memory_bytes: 11092
N = int(input())
A = list(map(int,input().split()))

dic = {}
for a in A:
  if a in dic:
    dic[a] += 1
  else:
    dic[a] = 1
    
dic = sorted(dic.items(), reverse=True)

ans = 1
check = 0
bool1 = False
for (i,j) in dic:
  cnt = j // 2
  for _ in range(cnt):
    ans *= i
    check += 1
    if check == 2:
      bool1 = True
      break
  if bool1:
    break

print(ans if ans != 1 else 0)

Measured memory_bytes: 25556
n = int(input())
l = list(map(int, input().split()))
ans_l = []
for j in range(2):
    last_sum = l[0]
    ans = 0
    if j == 0:
        if last_sum <= 0:
            ans += abs(1 - last_sum)
            last_sum += 1 - last_sum
    else:
        if last_sum >= 0:
            ans += abs(-1 - last_sum)
            last_sum += -1 - last_sum
    for i in range(n - 1):
        # print(last_sum)
        if last_sum > 0:
            if last_sum + l[i + 1] < 0:
                last_sum += l[i + 1]
            else:
                a = -1 - last_sum - l[i + 1]
                ans += abs(a)
                last_sum += a + l[i + 1]
        else:
            if last_sum + l[i + 1] > 0:
                last_sum += l[i + 1]
            else:
                a = 1 - last_sum - l[i + 1]
                ans += abs(a)
                last_sum += a + l[i + 1]
    ans_l.append(ans)
print(min(ans_l))

Measured memory_bytes: 14468
#include <bits/stdc++.h>
typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)

#define FOREACH(x,a) for(auto&& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template <class T = ll>
T IN(){T x;cin>>x;return (x);}

template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}

template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}

#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc

// #include <boost/multiprecision/cpp_ll.hpp>
// using namespace boost::multiprecision; // cpp_ll

#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>

#define pb(a) push_back(a)
#define mp make_pair


signed main(){
    CIN(n,m);
    VC2(m,a,b);
    vector<P> p;
    REP(i,m)p.emplace_back(a[i],b[i]);
    sort(ALL(p));
    p.emplace_back(INF, LINF);

    ll num = INF;
    int ans = 0;
    REP(i,m+1){

        int pos = p[i].first;

        if(pos >= num){
            num = INF;
            ans++;
        }

        num = min(num, p[i].second);
    }
    COUT(ans);

}


Measured memory_bytes: 3956
#include <iostream>

int main()
{
    const int n =3;
    int num[n];
    
    for(int i=0;i<n;i++)
    {
        std::cin >> num[i];
    }
    
    for(int t=0;t<n-1;t++){
        for(int f=t+1;f<n;f++){
            if(num[f]<num[t]){
                int box= num[f];
                num[f]= num[t];
                num[t]= box; 
            }
        }
    }
    
    std::cout <<num[0]<< " "<<num[1]<< " "<<num[2]<<std::endl;
    
    return 0;
}


Measured memory_bytes: 3096
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main(){
  int a,b;
  cin>>a>>b;
  
  cout<<(a-1)*(b-1)<<endl;

  return 0;
}

Measured memory_bytes: 3588
n,a,b=map(int,input().split())
if (b-a)%2==0:
    print(min(b-1,n-a,(b-a)//2))
else:
    ans=min(b-1,n-a,(b-a)//2+a,-(-(n-a-(n-b))//2)+(n-b))
    print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	int n;
	cin >> n;
	cout << (n + 1) / 2 << "\n";


	return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 123;

char a[N][N];
bool sc[N], sr[N];

void solve() {
  int h, w; scanf("%d%d", &h, &w);
  for (int i = 0; i < h; ++i) {
    sr[i] = true;
    for (int j = 0; j < w; ++j) {
      scanf(" %c", a[i]+j);
      if (a[i][j] == '#') sr[i] = false;
    }
  }
  for (int i = 0; i < w; ++i) {
    sc[i] = true;
    for (int j = 0; j < h; ++j) {
      if (a[j][i] == '#') sc[i] = false;
    }
  }
  for (int i = 0; i < h; ++i) {
    if (sr[i]) continue;
    for (int j = 0; j < w; ++j) {
      if (sc[j]) continue;
      putchar(a[i][j]);
    }
    puts("");
  }
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3640
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repe(i, n) REPN(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
template <typename T>
void coVec(const Vec1<T> &v){for(T i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

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

	Vec2<ll> a(n, Vec(m));
	rep(i, n) rep(j, m) cin >> a[i][j];

	ll l = 0, r = n;
	while(r-l > 1){
		ll mid = (l+r)/2;
		Vec pos(n);
		bool flg;
		VecB sports(m+1, true);
		while(true){
			flg = true;
			Vec cnt(m+1);
			rep(i, n) cnt[a[i][pos[i]]]++;
			repn(i, m) flg &= (cnt[i] <= mid);
			if(flg) break;
			repn(i, m) sports[i] = sports[i]&(cnt[i] <= mid);
			bool flag = false;
			repn(i, m) flag |= sports[i];
			if(!flag) break;
			rep(i, n) while(!sports[a[i][pos[i]]]) pos[i]++;
			rep(i, n) if(pos[i] >= m) break;
		}
		if(flg) r = mid;
		else l = mid;
	}
	co(r);

	return 0;
}


Measured memory_bytes: 1024
cnt = 0
zorome = 0
num = int(input())

while cnt < num:
  mass = input().split()
  
  if(mass[0] == mass[1]):
    zorome += 1
    
    if(zorome >= 3):
      break
  else:
    zorome = 0
  
  cnt += 1

print("Yes" if zorome >= 3 else "No")




Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " "
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;
int main(){
    int a,b;
    cin >> a >> b;
    println(a * b);
    return 0;
}

Measured memory_bytes: 3636
N = int(input())
A = list(map(int, input().split()))

even = 0
odd = 0
ans = "NO"
for i in range(N):
    if A[i]%2 == 0:
        even += 1
    else:
        odd += 1

if odd%2 == 0:
    ans = "YES"

print(ans)


Measured memory_bytes: 14108
import java.util.*;

class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().new aizu0009().run();
	}
	class pku1207{
		void run(){
			Scanner sc=new Scanner(System.in);
			while(sc.hasNextInt()){
				int a=sc.nextInt(),b=sc.nextInt(),ans=0;
				for(int i=Math.min(a, b	);i<=Math.max(a,b);i++){
					ans=Math.max(ans, calc(i));
				}
				System.out.println(a+" "+b+" "+ans);
			}
		}
		int calc(int n){
			int ret=1;
			while(n>1){
				n=n%2==0?n/2:3*n+1;
				ret++;
			}
			return ret;
		}
	}
	class aizu0009{
		void run(){
			notPrime=new boolean[MX];
			ans=new int[MX];
			
			for(int i=2;i*i<MX;i++)if(!notPrime[i])for(int j=i+i;j<MX;j+=i)notPrime[j]=true;
			for(int i=2;i<MX;i++)ans[i]=ans[i-1]+(notPrime[i]?0:1);
			
			Scanner sc=new Scanner(System.in);
			while(sc.hasNextInt()){
				int n=sc.nextInt();
				System.out.println(ans[n]);
			}
		}
		int MX=1000000;
		boolean[] notPrime;
		int[] ans;
	}
}

Measured memory_bytes: 17000
#include<bits/stdc++.h>
#define LL long long
#define SZ(x) (int)x.size()-1
#define F(i,a,b) for (int i=a;i<=b;++i)
#define DF(i,a,b) for (int i=a;i>=b;--i)
#define pb push_back
#define ms(a,b) memset(a,b,sizeof a)
using namespace std;
LL read(){
    char ch=getchar(); LL w=1,c=0;
    for (;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
    for (;isdigit(ch);ch=getchar()) c=(c<<3)+(c<<1)+(ch^48);
    return w*c;
}
const int M=2e5+10;

int main(){
	int n=read();
	LL tt=0,s=0;
	F(i,1,n){
		LL dig=read(),x=read(); s+=x;
		tt+=dig*x;
	}
	cout<<(tt-1)/9+s-1<<"\n";
    return 0;
}



Measured memory_bytes: 256