akhauriyash/Code-Regression huggingface dataset:
/*
██╗  ██╗ █████╗ ██████╗ ███████╗███████╗███╗   ███╗        ██╗  ██╗██╗  ██╗ █████╗ ██╗     ███████╗██████╗
██║ ██╔╝██╔══██╗██╔══██╗██╔════╝██╔════╝████╗ ████║        ██║ ██╔╝██║  ██║██╔══██╗██║     ██╔════╝██╔══██╗
█████╔╝ ███████║██████╔╝█████╗  █████╗  ██╔████╔██║        █████╔╝ ███████║███████║██║     █████╗  ██║  ██║
██╔═██╗ ██╔══██║██╔══██╗██╔══╝  ██╔══╝  ██║╚██╔╝██║        ██╔═██╗ ██╔══██║██╔══██║██║     ██╔══╝  ██║  ██║
██║  ██╗██║  ██║██║  ██║███████╗███████╗██║ ╚═╝ ██║███████╗██║  ██╗██║  ██║██║  ██║███████╗███████╗██████╔╝
╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═╝     ╚═╝╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═════╝
Believe in yourself ,( try and try and then try ), You can do it  
*/
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#define endl "\n"
#define Ceil(x,y) ((x+y-1)/y)
#define clr(arr, x) memset(arr, x, sizeof arr)
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define rt(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define OO 0x3f3f3f3f3f3f3f3fLL
const int oo = 0x3f3f3f3f, mod = 1e9 + 7;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//x = xDegrees*3.14159265 / 180;
//ef1tn=(( (n / 2)*( (n / 2) + 1) / 2) * 2);
//of1tn=(n * (n + 1) / 2 - 2 * ((n / 2) * (n / 2 + 1) / 2));
int dx[] { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy[] { 0, 0, 1, -1, 1, -1, 1, -1 };
void K_K(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
ll gcd(ll a, ll b) {
	return b == 0 ? abs(a) : gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
int n;
vector<int>arr;
map < pair<int, int>, int > dp;
int sol(int idx, int cur){
	if (idx >= n){
		if (cur == arr[n - 1])
			return 0;
		return oo;
	}
	if (dp.find({ idx, cur }) != dp.end())
		return dp[{idx, cur}];
	int ch1 = sol(idx + 1, arr[idx]) + abs(cur - arr[idx]);
	int ch2 = sol(idx + 2, arr[idx]) + abs(cur - arr[idx]);
	return dp[{idx, cur}] = min(ch1, ch2);
}
int main(){
	K_K();
	cin >> n;
	arr.resize(n);
	for (auto &it : arr)
		cin >> it;
	cout << sol(0, arr[0]);
}

Measured memory_bytes: 24064
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll N;
ll a[100000];
vector<int> E[100000];
int ans[100000];
void dfs(int x){
    if(sz(E[x])==0){
        ans[x]=0;
        return;
    }
    vector<int> v;
    rep(i,0,sz(E[x])){
        dfs(E[x][i]);
        v.pb(ans[E[x][i]]);
    }
    sor(v);
    rep(i,0,sz(v)){
        v[i]+=sz(v)-1-i;
    }
    ans[x]=*max_element(v.begin(), v.end())+1;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    rep(i,1,N){
        ll a;
        cin>>a;
        a--;
        E[a].pb(i);
    }
    dfs(0);
    cout <<ans[0]<<"\n";
}

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

void lca_prepare(vector<vector<ll>> &g, vector<ll> &parents, vector<ll> &depths, ll root = 0, ll parent = -1, ll depth = 0) {
  parents[root] = parent;
  depths[root] = depth;
  for (ll next : g[root]) {
    if (next == parent) continue;
    lca_prepare(g, parents, depths, next, root, depth + 1);
  }
}

ll get_path(vector<vector<ll>> &g, vector<ll> &parents, vector<ll> &depths, ll u, ll v) {
  ll flag = 0;
  if (depths[u] < depths[v]) swap(u, v);
  while (depths[u] != depths[v]) {
    flag |= 1ll<<u;
    u = parents[u];
    
  } 
  while (u != v) {
    flag |= 1ll<<u | 1ll<<v;
    u = parents[u];
    v = parents[v];
  }
  return flag;
}

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

  ll a, b;
  vector<vector<ll>> g(n);
  for (ll i = 0; i < n - 1; i++) {
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  ll m;
  cin >> m;

  vector<ll> u(m);
  vector<ll> v(m);
  for (ll i = 0; i < m; i++) {
    cin >> u[i] >> v[i];
    u[i]--;
    v[i]--;
  }
  
  vector<ll> parents(n);
  vector<ll> depths(n);
  lca_prepare(g, parents, depths);

  // for (ll i = 0; i < n; i++) {
  //   cout << parents[i] << " " << depths[i] << endl;
  // }

  vector<ll> paths(m);
  for (ll i = 0; i < m; i++) {
    paths[i] = get_path(g, parents, depths, u[i], v[i]);
  }

  // for (ll i = 0; i < m; i++) {
  //   cout << bitset<8>(paths[i]) << endl;
  // }

  ll ans = 0;
  for (ll i = 0; i < 1ll<<m; i++) {
    ll flag = 0;
    for (ll j = 0; j < m; j++) {
      if (i>>j & 1ll) flag |= paths[j];
    }
    ll cnt = __builtin_popcountll(flag);
    ll sign = __builtin_popcountll(i) % 2 ? -1 : +1;
    ans += sign * (1ll << (n - 1 - cnt));
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")

import sys,collections
sys.setrecursionlimit(100000)

INF = float("inf")

V,E = map(int,sys.stdin.readline().split())
st = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(E)) # multi line with multi param
Q = int(sys.stdin.readline())
uv = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(Q)) # multi line with multi param
#st = [[0,1],[0,2],[1,2],[2,3]]
#uv = [[0,1],[0,2],[1,2],[2,3]]
G = {i:[] for i in range(V)}
rG = {i:[] for i in range(V)}

for s,t in st:
    G[s].append(t)
    rG[t].append(s)

def dfs(current):
    visited.add(current)
    for nex in G[current]:
        if not nex in visited: dfs(nex)
    post_order.append(current)

def rdfs(current,k):
    visited.add(current)
    topological_order[current]=k
    for nex in rG[current]:
        if not nex in visited: rdfs(nex,k)

visited = set()
post_order = []
for i in range(V):
    if not i in visited: dfs(i)

topological_order = [0]*V
visited = set()

k = 0
for i in post_order[::-1]:
    if not i in visited:
        rdfs(i,k)
        k += 1

for u,v in uv:
    if topological_order[u] == topological_order[v]:
        print(1)
    else:
        print(0)





Measured memory_bytes: 28852
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
#define MOD 1000000007

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    vll x(n);
    rep(i,n) cin >> x[i];
    ll cost=0;
    for(int i=0;i<n-1;i++){
        cost+=min(a*(x[i+1]-x[i]),b);
    }
    cout << cost << endl;
}

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

int main(){
  int N;
  scanf("%d", &N);
  int last = N%10;
  if (last==2 ||
      last==4 ||
      last==5 ||
      last==7 ||
      last==9){
    std::cout << "hon" << std::endl;
  } else if (last==0 || last==6 || last == 1 || last==8) {
    std::cout << "pon" << std::endl;
  } else {
    std::cout << "bon" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 3164
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int N = 200 + 5, INF = 1e9;
int n,m,R, d[N][N], dp[N][1<<8];
vector<int> r;

int get_dp(int pos, int to_vis){
    int& ans = dp[pos][to_vis];
    
    if(ans != INF)return ans;
    if(to_vis==0)return 0;
    
    for (int i = 0; i < R; i++){
        if(to_vis&(1<<i)){
            ans = min(ans, d[r[pos]][r[i]] + get_dp(i, to_vis - (1<<i)));
        }
    }
    return ans;
}


int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n>>m>>R;
    
    int tmp;
    for (int i = 1; i <= R; i++){
        cin>>tmp;
        tmp--;
        r.push_back(tmp);
    }
    
    fill_n(&d[0][0], N*N, INF);
    for (int i = 0; i < n; i++)d[i][i] = 0;
    
    for(int i = 1; i <= m; i++){
        int u,v,dist;
        cin>>u>>v>>dist;
        u--,v--;
        d[u][v] = dist;
        d[v][u] = dist;
    }
    
    for(int k = 0; k < n; k++)
        for(int i = 0; i < n; i++)
            for(int j = 0; j < n; j++)
                if(d[i][k] < INF && d[k][j] < INF)
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    
    
    fill_n(&dp[0][0], N*(1<<8), INF);
    int ans = 1e9;
    for (int i = 0; i < R; i++){
        ans = min(ans, get_dp(i, (1<<R)-1 -(1<<i)));
    }
    
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    vector<ll> a(n),b(m);
    set<ll> cnt1,cnt2;
    rep(i,n){
      cin>>a[i];
      cnt1.insert(a[i]);
    }
    rep(i,m){
      cin>>b[i];
      cnt2.insert(b[i]);
    }
    if(len(cnt1)!=n || len(cnt2)!=m){
      cout<<0<<endl;
      return 0;
    }
    sort(begin(a),end(a));
    sort(begin(b),end(b));
    ll ans=1;
    for(int i=n*m;i>=1;i--){
      if(!cnt1.count(i) && cnt2.count(i)) (ans*=end(a)-lower_bound(begin(a),end(a),i))%=mod;
      else if(cnt1.count(i) && !cnt2.count(i)) (ans*=end(b)-lower_bound(begin(b),end(b),i))%=mod;
      else if(!cnt1.count(i) && !cnt2.count(i)) (ans*=(end(a)-lower_bound(begin(a),end(a),i))*(end(b)-lower_bound(begin(b),end(b),i))-(n*m-i))%=mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
N=int(input())
Ans='No'
A=[0 for _ in range(81)]
count = 0
for i in range(9) :
    for j in range(9) :
        A[count]=(i+1)*(j+1)
        count+=1

for i in range(81) :
    if (A[i]==N) : Ans='Yes'

print(Ans)

Measured memory_bytes: 38704
/********************************************
 *Author*        :ZZZZone
 *Created Time*  : 六  9/16 20:28:06 2017
 *Ended  Time*  : 六  9/16 21:27:38 2017
*********************************************/

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
const LL inf = 1LL << 60;
const int MaxN = 300;

LL a[305][305], temp[305][305];
int cnt[305][305];

int n;
LL sum;
bool flag = false;

void floyd(){
    for(int k = 1; k <= n; k++){
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
            }
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(i == j) continue;
            if(a[i][j] != temp[i][j]) flag = true;
        }
    }
}

void solve(){
    memset(cnt, 0, sizeof(cnt));
    for(int k = 1; k <= n; k++){
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                if(i == j) continue;
                if(a[i][j] <  a[i][k] + a[k][j]) cnt[i][j]++;
            }
        }
    }
    LL ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            if(cnt[i][j] == n) ans += a[i][j];
        }
    }
    printf("%lld\n", ans);
}


int main()
{
    while(~scanf("%d", &n)){
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                scanf("%lld", &a[i][j]);
                if(i == j) a[i][j] = inf;
                temp[i][j] = a[i][j];
            }
        }
        floyd();
        if(flag) printf("-1\n");
        else solve();
    }
    
    return 0;
}


Measured memory_bytes: 2048
#include<iostream>

using namespace std;

int main() {
	int r, c, i, j;
	int table[101][101] = { 0 };
	cin >> r >> c;
	for (i = 0; i< r; i++){
		for (j = 0; j < c; j++) {
			cin >> table[i][j];
			table[i][c] += table[i][j];
			table[r][j] += table[i][j];
			table[r][c] += table[i][j];
		}
	}
	for (i = 0; i <= r; i++){
		for (j = 0; j <= c; j++) {
			cout << table[i][j];
                             if (j < c) cout << " ";
			else cout << "\n";
		}
	}
}

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

int main() {
  int n, m = 0;
  cin >> n;
  vector<int> v(n), l(n), r(n);
  rep(i, n) cin >> v[i];
  l[0] = v[0];
  r[n-1] = v[n-1];
  rep(i, n-1){
    l[i+1] = __gcd(l[i], v[i+1]);
    r[n-i-2] = __gcd(r[n-i-1], v[n-i-2]);
  }
  rep(i, n){
    if(i == 0) m = max(m, r[i+1]);
    else if(i == n-1) m = max(m, l[i-1]);
    else m = max(m, __gcd(l[i-1], r[i+1]));
  }
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 1408
n = int(input())
a = list(map(int, input().split()))
lst = [0] * 10 ** 5
for i in range(n):
    lst[a[i] - 1] += 1
q = int(input())
ans = sum(a)

for i in range(q):
    b, c = map(int, input().split())
    b -= 1
    c -= 1
    ans += (c + 1) * lst[b]
    ans -= (b + 1) * lst[b]
    lst[c] += lst[b]
    lst[b] = 0
    print(ans)


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


void prime_factor(ll n){
  map<ll,int> mp;
  if(n==2){
    cout << " " << n << endl;
  }
  for(ll i=2;i*i<=n;++i){
    if(n%i==0){
      int ex=0;
      while(n%i==0){
        n/=i;
        ex++;
      }
      mp[i]=ex;
    }
  }
  if(n!=1) mp[n]++;
  for(auto p : mp){
    for(int i=0;i<p.second;++i){
      //cout << p.first << p.second;
      cout << " " << p.first;
    }
  }
  cout << endl;
  return;
}


int main(){
  ll n;
  cin >> n;
  cout << n << ":";
  prime_factor(n);
  return 0;
}



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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << min(a,b)+min(c,d) << endl;
}

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

ll gcd(ll m, ll n) {
  if (n == 0) return m;
  else return gcd(n, m%n);
}

int main(void) {
  ll N; cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++) cin >> A.at(i);

  vector<ll> gcd1(N); gcd1.at(0) = A.front();
  for (ll i = 1; i < N; i++) gcd1.at(i) = gcd(gcd1.at(i-1), A.at(i));
  vector<ll> gcd2(N); gcd2.at(0) = A.back();
  for (ll i = 1; i < N; i++) gcd2.at(i) = gcd(gcd2.at(i-1), A.at(N-1-i));

  ll a = gcd1.back();
  for (ll i = 1; i < N-1; i++) {
    ll tmp = gcd(gcd1.at(i-1), gcd2.at(N-2-i));
    if (a < tmp) a = tmp;
  }
  if (a < gcd1.at(N-2)) a = gcd1.at(N-2);
  if (a < gcd2.at(N-2)) a = gcd2.at(N-2);
  cout << a << endl;

  return 0;
}


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

using namespace std;

#define ll long long 
#define Coming ios_base :: sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"

int main()
{
	int n, x, arr[105];
	
	cin >> n >> x;
	
	for(int i = 1; i <= n; i++)
	{
		cin >> arr[i];
	}
	
	
	ll sum = 0, coun = 1;
	
	for(int i = 1; i <= n; i++)
	{
		sum += arr[i];
		
		if(sum <= x) coun++;
		else break;
	}
	
	cout << coun << endl;
	
	return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
	int N;
	cin >> N;
	std::vector<int> H(N);
	for (int i = 0; i < N; i++){
		cin >> H[i];
	}

	std::vector<int> test(N);
	test[0] = 0;
	for (int i = 1; i < N; i++){
		if (H[i-1] >= H[i]){
			test[i] = test[i-1] +1 ; 
		}
		else test[i] = 0;
	}

	cout << *max_element(test.begin(),test.end()) << endl;

	return 0;
}

Measured memory_bytes: 1024
// AOJ 2018

#include <iostream>

using namespace std;

int main(void)
{
	int n, m, p, x;
	while(cin >> n >> m >> p, n && m){
		int win = 0, money, sum = 0;
		
		for (int i = 1; i <= n; i++){
			cin >> x;
			if (i == m) win = x;
			sum += x;
		}

		money = sum * 100;
		money -= (int)(money * (p / 100.0));
		// cout << money << endl;

		cout << (win == 0 ? 0 : money / win) << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
import java.util.*;
public class Main {
	final char MARK = '+';
	Scanner sc;
	Stack<Integer> xSta;
	Stack<Integer> ySta;
	int w ;
	int h;
	char [][] list;

	private void setSta(int x, int y){
		xSta.push(x);
		ySta.push(y);
	}

	private void set(){
		for(int i=1; i < h + 1; i++){
			String str = sc.next();
			for(int j=0; j < w;j++){
				list[i][j+1] = str.charAt(j);
			}
		}
		//set a flame
		for(int i=0; i < w + 2; i++){
			list[0][i] = MARK;
			list[h+1][i] = MARK;
		}
		for(int i=0; i < h + 2; i++){
			list[i][0] = MARK;
			list[i][w+1] = MARK;
		}
	}

	public void doIt(){
		sc = new Scanner(System.in);
		list = new char[102][102];
		xSta = new Stack<Integer>();
		ySta = new Stack<Integer>();
		while(true){
			h = sc.nextInt();
			w = sc.nextInt();
			if(w == 0 && h == 0){
				break;
			}
			//reset
			for(int i=0; i < 102; i++){
				for(int j=0; j < 102; j++){
					list[i][j] = ' ';
				}
			}
			//set
			set();
			int count = 0;
			for(int i=1; i < h + 1;i++){
				for(int j=1; j < w + 1; j++){
					if(list[i][j] != MARK){
						count++;
						setSta(j, i);
						char patMark = list[i][j];
						while(!xSta.empty()){
							int x = xSta.pop();
							int y = ySta.pop();
							if(list[y][x] != patMark){
							}
							else{
								list[y][x] = MARK;
								setSta(x+1, y);
								setSta(x, y+1);
								setSta(x, y-1);
								setSta(x-1, y);
							}
						}
					}
				}
			}
			System.out.println(count);
		}
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin >> A >> B;
  
  if (A + B == 15){
    cout << '+' << endl;
  }
  else if (A * B == 15){
    cout << '*' << endl;
  }
  else {
    cout << 'x' << endl;
  }
}
    
 

Measured memory_bytes: 3592
#include <iostream>
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
using namespace std;
int main() {
fastio;
ll t;cin>>t;
ll prv=0;
ll sum=0;
for(ll i=0;i<t;i++){
    ll ele;
    cin>>ele;
    if(i==0)prv=ele;
    if(ele>prv)prv=ele;
    sum+=prv-ele;
}
cout<<sum;
return 0;
}

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




int main(){
  int N[4];
  cin >> N[0] >> N[1] >> N[2] >> N[3];
  bool a = false,b = false,c = false,d = false;
  for(int i=0;i<4;++i){
    if(N[i]==1) a = true;
    if(N[i]==9) b = true;
    if(N[i]==7) c = true;
    if(N[i]==4) d = true;
  }

  if(a && b && c && d) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <queue>

#define INF 1000000000000000;

using namespace std;

typedef long long ll;

typedef struct edge_ {
    int to;
    long long yen;
    long long snuuk;
} edge;

typedef pair<ll,int> P;

int n;
vector<vector<edge> > G;
priority_queue<P, vector<P>, greater<P> > p_que;

//which == 0の時は円
void dijkstra(int s, int which, ll *cost) {
    for (int i = 0; i < n; i++)
        cost[i] = INF;
    cost[s] = 0;
    p_que.push(P(0,s));

    while (!p_que.empty()) {
        P p = p_que.top();
        p_que.pop();
        int v = p.second;

        if (cost[v] < p.first)
            continue;

        for (ll i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            int u = e.to;
            ll l = ((which == 0) ? e.yen : e.snuuk);

            if (cost[u] <= cost[v] + l)
                continue;

            cost[u] = cost[v] + l;
            
            p_que.push(P(cost[u], u));
        }
    }
}

int main() {
    int m, s, t;  cin >> n >> m >> s >> t;

    G.resize(n);
    ll *cost = new ll[n];
    
    for (int i = 0; i < m; i++) {
        int u, v;   ll a, b;
        cin >> u >> v >> a >> b;
        edge e1 = {v-1, a, b}, e2 = {u-1, a, b};
        G[u-1].push_back(e1);
        G[v-1].push_back(e2);
    }

    ll *ye = new ll[n];
    ll *sn = new ll[n];

    dijkstra(s-1, 0, cost);
    for (int i = 0; i < n; i++)
        ye[i] = cost[i];
   
    while (!p_que.empty())
        p_que.pop();
    dijkstra(t-1, 1, cost);
    for (int i = 0; i < n; i++)
        sn[i] = cost[i];

    while (!p_que.empty())
        p_que.pop();
    
    for (int i = 0; i < n; i++) {
        p_que.push(P(ye[i]+sn[i], i));
    }

    int i;
    for (i = 0; i < n;) {
        P p;
        do {
            p = p_que.top();
            p_que.pop();
        } while (p.second < i);

        ll ans = p.first;
        int year = p.second;

        for (; i <= year; i++) {
            cout << 1000000000000000 - ans << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 14832
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
template<class T> inline void chmin(T &a, T b){if(a>=b)a=b;}
template<class T> inline void chmax(T &a, T b){if(a<=b)a=b;}
typedef long long ll;
const int INF = 1e9;

int R;

int main()
{
    cin >> R;
    if(R < 1200) cout << "ABC" << endl;
    else if (R < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
    return 0;
}

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

int main(){
  int h, w;
  while (true){
    cin >> h >> w;
    if (h == 0 && w == 0) break;
    for (int i = 1; i <= h; i++){
      for (int j = 1; j <= w; j++){
        cout << '#';
      }
      cout << endl;
    }
    cout << endl;
  }
}


Measured memory_bytes: 3080
#abc079 c
s=input()


def dfs(i,num,ans):
    #print(i,num,ans)
    if i==3:
        if num==7:
            global memo
            memo=ans
        return 0
    dfs(i+1,num+int(s[i+1]),ans+"+"+str(s[i+1]))
    dfs(i+1,num-int(s[i+1]),ans+"-"+str(s[i+1]))
    return 0

memo=""
dfs(0,int(s[0]),s[0])
memo+="=7"
print(memo)


Measured memory_bytes: 3060
/**
 *     author: qodjf
 *     created: 04.18.2020 01:24:46
 */
#include <bits/stdc++.h>
using namespace std;

string to_string(string s) { return '"' + s + '"'; }

string to_string(const char *s) { return to_string((string)s); }

string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif

#define mst(x, a) memset(x, a, sizeof(x))

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 998244353;

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

ll mul(ll a, ll b) { return a * b % MOD; }

ll add(ll a, ll b) { return (a + b) % MOD; }

ll sub(ll a, ll b) { return (a - b + MOD) % MOD; }

ll my_pow(ll a, ll b) {
  ll r = 1;
  while (b) {
    if (b & 1) r = mul(r, a);
    a = mul(a, a);
    b >>= 1;
  }
  return r;
}

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  vector<int> cnt(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  ll ans = 1;
  if (a[0] != 0 || cnt[0] != 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 1; i < N; i++) {
    dbg(i, cnt[i]);
    ans = mul(ans, my_pow(cnt[i-1], cnt[i]));
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
int main(){
  std::string s;int i,a=-1,z;
  for(std::cin>>s,i=0;i<s.size();++i){
    if(s[i]=='A'&&a<0)a=i;
    if(s[i]=='Z')z=i;
  }
  std::cout<<z-a+1<<"\n";
}

Measured memory_bytes: 640
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N, X = get_ints

all = 0
smallest = 10 ** 9
N.times do |i|
  m = get_int
  all += m
  smallest = m if m < smallest
end

x = X - all

puts N + x/smallest


Measured memory_bytes: 14528
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    String s = sc.next();
    int k = sc.nextInt();
    StringBuilder b = new StringBuilder();
    for (int i = 0; i < s.length() - 1; i++) {
      char c = s.charAt(i);
      if (c == 'a') {
        b.append('a');
      } else {
        int need = 'z' + 1 - c;
        if (need <= k) {
          k -= need;
          b.append('a');
        } else {
          b.append(c);
        }
      }
    }
    char c = s.charAt(s.length() - 1);
    k = k % 26;
    c += k;
    if ('z' < c) c -= 26;
    b.append(c);
    os.println(b.toString());
  }

  private static class Scanner {

    private final InputStream is;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    Scanner(InputStream is) {
      this.is = is;
    }

    private boolean hasNextByte() {
      if (ptr < buflen) {
        return true;
      } else {
        ptr = 0;
        try {
          buflen = is.read(buffer);
        } catch (IOException e) {
          e.printStackTrace();
        }
        if (buflen <= 0) {
          return false;
        }
      }
      return true;
    }

    private int readByte() {
      if (hasNextByte()) {
        return buffer[ptr++];
      } else {
        return -1;
      }
    }

    private static boolean isPrintableChar(int c) {
      return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
      while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
        ptr++;
      }
      return hasNextByte();
    }

    public String next() {
      if (!hasNext()) {
        throw new NoSuchElementException();
      }
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while (isPrintableChar(b)) {
        sb.appendCodePoint(b);
        b = readByte();
      }
      return sb.toString();
    }

    public long nextLong() {
      if (!hasNext()) {
        throw new NoSuchElementException();
      }
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
        minus = true;
        b = readByte();
      }
      if (b < '0' || '9' < b) {
        throw new NumberFormatException();
      }
      while (true) {
        if ('0' <= b && b <= '9') {
          n *= 10;
          n += b - '0';
        } else if (b == -1 || !isPrintableChar(b)) {
          return minus ? -n : n;
        } else {
          throw new NumberFormatException();
        }
        b = readByte();
      }
    }

    public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
        throw new NumberFormatException();
      }
      return (int) nl;
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }
  }
}


Measured memory_bytes: 23252
// AOJ GRL_5_A Diameter of a Tree
// 2018.5.4 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define INF   0x10101010
#define MAX_N 100002

typedef struct { int s, d; } QUE;
QUE que[MAX_N*2]; int top, end;
int n;
int hi[MAX_N], *to[MAX_N], *w[MAX_N];
int dist[MAX_N];

int bfs(int s)
{
	int i, t, d, nd;
	int ans_n, ans_d;

	memset(dist, INF, n<<2);
	que[0].s = s, que[0].d = 0, dist[s] = 0, top = 0, end = 1;
	ans_n = s, ans_d = 0;
	while (top != end) {
		s = que[top].s, d = que[top++].d;
		if (dist[s] < d) continue;
		if (d > ans_d) ans_d = d, ans_n = s;
		for (i = 0; i < hi[s]; i++) {
			t = to[s][i], nd = d+w[s][i];
			if (dist[t] > nd) {
				dist[t] = nd, que[end].s = t, que[end++].d = nd;
			}
		}
	}
	return ans_n;
}

int treeDiameter()
{
	int s, g;
	
	s = bfs(0);
	g = bfs(s);
	return dist[g];
}

int main()
{
	int s, t, x, i, j, k;
	int *memo;

	n = in();
	memo = malloc(n*12);
	j = 0; for (i = 1; i < n; i++) {
		memo[j++] = s = in();
		memo[j++] = t = in();
		memo[j++] = in();
		hi[s]++, hi[t]++;
	}
	for (i = 0; i < n; i++) if (hi[i]) {
		to[i] = malloc(hi[i]<<2), w[i] = malloc(hi[i]<<2);
	}
	memset(hi, 0, n<<2);
	j = 0; for (i = 1; i < n; i++) {
		s = memo[j++], t = memo[j++], x = memo[j++];
		k = hi[s]++, to[s][k] = t, w[s][k] = x;
		k = hi[t]++, to[t][k] = s, w[t][k] = x;
	}
	free(memo);

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



Measured memory_bytes: 11140
#include<bits/stdc++.h>
using namespace std;
string s,p;
int main()
{
    long long int i,a,j,k,z,t,x,y=0,n,m;
    cin>>s>>p;
    x=0;
    for(i=0;i<s.size();i++)
        if(s[i]!=p[i])x++;
    cout<<x<<endl;

}


Measured memory_bytes: 3864
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 100005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

P U[SIZE];
int H,W,D,Q;
int cost[SIZE];

int f(int a,int b){
  return abs(U[a].first-U[b].first) + abs(U[a].second-U[b].second);
}

int main(){
  cin >> H >> W >> D;
  int a;
  rep(i,0,H) rep(j,0,W) {
    cin >> a;
    U[a] = P(i,j);
  }
  cin >> Q;

  rep(i,1,D+1) {
    int k = i+D;
    while(k<=H*W){
      cost[k] = cost[k-D] + f(k-D,k);
      k += D;
    }
  }

  rep(i,0,Q){
    int l,r;
    cin >> l >> r;
    cout << cost[r] - cost[l] << endl;
  }

  return 0;
}


Measured memory_bytes: 2176
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    int out = -1;
    if (a >= 1 && a <= 9 && b >= 1 && b <= 9) {
      out = a * b;
    }
    cout << out << endl;
    return 0;
}

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


int main() {
    string s;
    cin>>s;
    long long int n = s.length();
    long long int ans=0;
    for(int i=0;i<n;i++)
    {
    	if(s[i] != s[n-i-1])
    		break;
    	//ans++;
    }
    long long int f[26]={0};
    for(int i=0;i<n;i++)
    {
    	f[s[i]-'a']++;
    }
    if(n==1)
    {
    	cout<<"1";
    	return 0;
    }
    for(int i=0;i<26;i++)
    {
    	ans += f[i]*(f[i]-1)/2;
    }
    cout<<(n*(n-1))/2 - ans + 1;
    return 0;
}

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

int main(){
	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

	int n;
	cin >> n;
	int a[n],dp[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
		dp[i]=INT_MAX;
	}
	dp[0]=0;
	for(int i=0;i<n;i++){
		if(i+1<n) dp[i+1]=min(dp[i+1],abs(a[i+1]-a[i])+dp[i]);
		if(i+2<n) dp[i+2]=min(dp[i+2],abs(a[i+2]-a[i])+dp[i]);
	}
	cout << dp[n-1];	


 
 
	
 
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define ll long long
#define vi vector <int>
#define vvi vector <vector<int> >
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>=b;i--)
#define init(i,k) memset(i,k,sizeof i)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 998244353
#define PI 3.14159265359
inline ll add(ll a, ll b){ return ((a%MOD)+(b%MOD))%MOD;}
inline ll mul(ll a, ll b){ return ((a%MOD)*(b%MOD))%MOD;}
inline ll sub(ll a, ll b){ return ((a%MOD)-(b%MOD)+MOD)%MOD;}
// const int N = 1e5+7;
 
#define deb(x) {x}
#ifndef local
	#define deb(x) ;
#endif
///---------------------------------------------------------------

void solve()
{
	long double r;cin>>r;
	long double t = PI;
	t*=(2*r);
	cout<<setprecision(10)<<t<<endl;
}

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	
	#ifdef local
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	clock_t qwertyuiop = clock();
	#endif
 
	int t=1;
	// cin>>t;
	rep(a,0,t)
	{
		// cout<<"Case #"<<a+1<<": ";
		solve();
	}

	// solve();
	
	#ifdef local
	{qwertyuiop = clock() - qwertyuiop;
	double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;
	cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "
	<<time_taken<<" seconds\n";}
	#endif
}

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

#define pb push_back
#define all(v) (v).begin(),(v).end()
#define ll long long int
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define sz(a) (ll)(a.size())
#define MOD 1000000007
#define fi first
#define se second
#define pii pair<ll,ll>

using namespace std;
const ll hell = (ll)(1e18+100LL);
const double pi = acos(-1.0);

int main(){
    ll t,i,j,k,m,n,x,y;
    t=1;
    //cin>>t;
    while(t--){
        ll flag=0,K;
        cin>>n;
        if(n>=400&&n<=599){
            x = 8;
        }else if(n>=600&&n<=799){
            x = 7;
        }else if(n>=800&&n<=999){
            x = 6;
        }else if(n>=1000&&n<=1199){
            x = 5;
        }else if(n>=1200&&n<=1399){
            x = 4;
        }else if(n>=1400&&n<=1599){
            x = 3;
        }else if(n>=1600&&n<=1799){
            x = 2;
        }else if(n>=1800&&n<=1999){
            x = 1;
        }

        cout<<x;
        
    }
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
int main(){
  int n;
  scanf("%d",&n);
  int a[n];
  int i,j,k,f,limit,s;
  int so[9265]={2};
  k=1;
  for(i=3;i<55555;i+=10){
    f=0;
    limit=(int)sqrt(i);
    for(j=3;j<=limit;j+=2){
      if(i%j==0){
        f=1;
        break;
      }
    }
    if(f==0){
      so[k]=i;
      k++;
    }
  }
  for(i=0;i<n;i++){
    printf("%d ",so[i]);
  }
  printf("\n");
  return 0;
}


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

LL dp[3005][3005][4];
int a[3005][3005];
int r,c;
int main()
{
	int i,j,k;
	scanf("%d%d%d",&r,&c,&k);
	while(k--)
	{
		int t1,t2,t3;
		scanf("%d%d%d",&t1,&t2,&t3);
		a[t1][t2]=t3;
	}
	for(i=1;i<=r;i++)
		for(j=1;j<=c;j++)
		{
			for(k=0;k<4;k++)
				dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][k]);
			for(k=0;k<4;k++)
				dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k]);
			if(a[i][j])
			{
				for(k=0;k<4;k++)
					dp[i][j][1]=max(dp[i][j][1],dp[i-1][j][k]+a[i][j]);
				for(k=1;k<4;k++)
					dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k-1]+a[i][j]);
			}
		}
	LL ans=0;
	for(k=0;k<4;k++)
		ans=max(ans,dp[r][c][k]);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 320572
<?php
  
  $nd=trim(fgets(STDIN));
  $n=explode(" ", $nd)[0];
  $d=explode(" ", $nd)[1];

$cnt=0;
  for($i=0;$i<$n;$i++){
    $xy=trim(fgets(STDIN));
    $x=explode(" ", $xy)[0];
    $y=explode(" ", $xy)[1];
    
    if(sqrt($x*$x+$y*$y) <= $d){
      $cnt+=1;
    }
    
  }

echo $cnt;
    

  
  ?>

Measured memory_bytes: 16180
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin>>N>>K;
  int sum=0;
  for(int i=1;i<=N;i++){
    int x;
    cin>>x;
    int sa;
    if(x-K<=0){
      sa=K-x;
    }
    if(x-K>0){
      sa=x-K;
    }
    if(x>=sa){
      sum+=sa;
    }
    if(x<sa){
      sum+=x;
    }
  }
  cout<<2*sum<<endl;
}
    
    
      
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  int n,d=1;
  string s;
  cin>>n>>s;
  for(int i=1;i<n;i++){
    if(s[i-1]!=s[i])d++;
  }
  cout<<d;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

int main() {
	int N,M;
	cin >>N>>M;
	int P[M], Y[M];
	rep(i,0,M) cin >>P[i]>>Y[i];
	tuple<int, int, int> p[M];
	rep(i,0,M) p[i]=make_tuple(P[i],Y[i],i);
	sort(p,p+M);
	int A[M];
	A[get<2>(p[0])]=1;
	rep(i,0,M){
		if(get<0>(p[i])==get<0>(p[i-1])){
			A[get<2>(p[i])]=A[get<2>(p[i-1])]+	1;
		}
		else{
			A[get<2>(p[i])]=1;
		}
	}
	 rep(i,0,M){
		printf("%06d%06d\n", P[i], A[i]);
	}
}


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

void solve(long long X){
    const long long val = 120;
    unordered_map<long long, long long> a;
    for (int i = -val; i <= val; i++) {
        long long res = 1;
        for (int j = 0; j < 5; j++) {
            res *= i;
        }
        a[i] = res;
    }

    vector<long long> v;
    for (int i = -val; i <= val; i++) {
        for (int j = -val; j <= val; j++) {
            if (a[i] - a[j] == X) {
                cout << i << " " << j << endl;
                return;
            }
        }
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3704
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
 

int  A(int x){
    if(x>=0)return x;
    else return -x;
}

ll inv(ll x) {
	ll res = 1;
	ll k = N - 2;
	ll y = x%N;
	while (k) {
		if (k & 1)res = (res*y) % N;
		y = (y%N)*(y%N) % N;
		k /= 2;
	}
	return res;
}

unsigned long long popCount64bitB(unsigned long long x) 
{ 
    x = ((x & 0xaaaaaaaaaaaaaaaaUL) >> 1) 
      +  (x & 0x5555555555555555UL); 
    x = ((x & 0xccccccccccccccccUL) >> 2) 
      +  (x & 0x3333333333333333UL); 
    x = ((x & 0xf0f0f0f0f0f0f0f0UL) >> 4) 
      +  (x & 0x0f0f0f0f0f0f0f0fUL); 
    x = ((x & 0xff00ff00ff00ff00UL) >> 8) 
      +  (x & 0x00ff00ff00ff00ffUL); 
    x = ((x & 0xffff0000ffff0000UL) >> 16) 
      +  (x & 0x0000ffff0000ffffUL); 
    x = ((x & 0xffffffff00000000UL) >> 32) 
      +  (x & 0x00000000ffffffffUL); 
    return x; 
} 


vector<ll>g[2010];

ll dist[2010]={0};

int main(void){
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<ll>p(a),q(b),r(c);
    for(ll i=0;i<a;i++)cin>>p[i];
    for(ll i=0;i<b;i++)cin>>q[i];
    for(ll 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> >pq,qq;
    priority_queue<ll,vector<ll>,less<ll> >rq;
    for(ll i=0;i<x;i++)pq.push(p[i]);
    for(ll i=0;i<y;i++)qq.push(q[i]);
    for(ll i=0;i<c;i++)rq.push(r[i]);
    while(!rq.empty()){
        ll x1 = pq.top();
        ll x2 = qq.top();
        ll x3 = rq.top();
        if(x1>=x3){
            if(x2>=x3){
                break;
            }
            else{
                qq.pop();
                qq.push(x3);
                rq.pop();
            }
        }
        else{
            if(x2>=x3){
                pq.pop();
                pq.push(x3);
                rq.pop();
            }
            else{
                if(x1>=x2){
                    qq.pop();
                    qq.push(x3);
                    rq.pop();
                }
                else{
                    pq.pop();
                    pq.push(x3);
                    rq.pop();
                }
            }
        }
    }
    ll ans = 0;
    while(!pq.empty()){
        ll x1 = pq.top();
        ans+=x1;
        pq.pop();
    }
    while(!qq.empty()){
        ll x1 = qq.top();
        ans+=x1;
        qq.pop();
    }
    cout<<ans<<endl;
    return 0;
}

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



int main()
{
    string A, B;
    cin >> A >> B;
    if(A.size() > B.size()){
        cout << "GREATER" << endl;
    }
    else if(A.size() < B.size()){
        cout << "LESS" << endl;
    }
    else{
        for (int i = 0; i < A.size();i++)
        {
            if(A == B){
                cout << "EQUAL" << endl;
                break;
            }
            if(A[i] > B[i]){
                cout << "GREATER" << endl;
                break;
            }
            else if(A[i] < B[i]){
                cout << "LESS" << endl;
                break;
            }
        }
    }
}


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

int main(){
    int x = 1 , a , b , Ans = 0;
    scanf( "%d%d" , &a , &b );

    while( x < b ){
        x += ( a - 1 );
        ++Ans;
    }

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

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, c, ta, tb, tc int
	fmt.Scan(&a, &b, &c)
	origin_a := a
	origin_b := b
	origin_c := c

	count := 0
	flag := true
	for a % 2 == 0 && b % 2 == 0 && c % 2 == 0{
		ta = a
		tb = b
		tc = c
		a = tb / 2 + tc / 2
		b = ta / 2 + tc / 2
		c = ta / 2 + tb / 2

		if a == origin_a && b == origin_b && c == origin_c{
			fmt.Println(-1)
			flag =false
			break
		}

		count++
	}
	if flag{
		fmt.Println(count)
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int h, w, n;
    cin >> h >> w >> n;
    vector< vector<int> > s(h);
    generate(s.begin(), s.end(), [w](){ return vector<int>(w); });
    vector<int> a(n);
    in_arr(int, a, n);
    int c = 0, r = 0;
    rep(i, n){
        while(a[i] > 0){
            --a[i];
            s[r][c] = i + 1;
            if((r % 2 == 0 && c == w - 1) || (r % 2 == 1 && c == 0)){
                ++r;
            }else if(r % 2 == 0){
                ++c;
            }else {
                --c;
            }
        }
    }
    repi(i, s){
        repi(j, *i){
            cout << *j << " ";
        }
        cout << endl;
    }
    return 0;
}



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

using namespace std;
#define int long long
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    int a=n%10;
    if(a==2 || a==4 || a==5 || a==7 || a==9)
    {
        cout<<"hon";
    }
    else if(a==3)
    {
        cout<<"bon";
    }
    else
    {
        cout<<"pon";
    }
    return 0;
}


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

int main() {
    int N, d[110];

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

    sort(d, d+N);

    int num = 1;
    for (int i=0; i<N-1; i++) {
        if (d[i] != d[i+1])
            num++;
    }

    cout << num << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(c) c.begin(), c.end()
#define endl "\n"
#define sz(u) (int)(u.size())
#define L(x)(2*x)
#define R(x)(2*x+1)
#define M(x,y)((x+y)/2)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	ll n,mxw;
	cin>>n>>mxw;
	ll dp[n+1][mxw+1];
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=n;i++){
		ll ww,vv;
		cin>>ww>>vv;
		for(ll w=0;w<=mxw;w++){
			if(ww>w){
				dp[i][w]=dp[i-1][w];
				continue;
			}
			dp[i][w]=max(dp[i-1][w],dp[i-1][w-ww]+vv);
		}
	}
	cout<<dp[n][mxw];
}


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


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

//セグ木
ll dat[2560000], sz;

void init(ll n) {
	sz = 1;
	while (sz < n)sz *= 2;
	REP(i, sz * 2 - 1) dat[i] = INF; //初期値
}

void update(ll k, ll a) { //場所(0-indexed), 値
	k += sz - 1;
	dat[k] = a;
	while (k > 0) {
		k = (k - 1) / 2;
		dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]); //更新
	}
}

ll query(ll a, ll b, ll k, ll l, ll r) { //[a, b) 呼ぶとき (a, b, 0, 0, sz)
	if (r <= a or b <= l)return INF;
	if (a <= l and r <= b)return dat[k];
	ll v1 = query(a, b, k * 2 + 1, l, (l + r) / 2);
	ll v2 = query(a, b, k * 2 + 2, (l + r) / 2, r);
	return min(v1, v2); //戻り値
}

//セグ木
ll dat2[2560000], sz2;

void init2(ll n) {
	sz2 = 1;
	while (sz2 < n)sz2 *= 2;
	REP(i, sz2 * 2 - 1) dat2[i] = MINF; //初期値
}

void update2(ll k, ll a) { //場所(0-indexed), 値
	k += sz2 - 1;
	dat2[k] = a;
	while (k > 0) {
		k = (k - 1) / 2;
		dat2[k] = max(dat2[k * 2 + 1], dat2[k * 2 + 2]); //更新
	}
}

ll query2(ll a, ll b, ll k, ll l, ll r) { //[a, b) 呼ぶとき (a, b, 0, 0, sz)
	if (r <= a or b <= l)return MINF;
	if (a <= l and r <= b)return dat2[k];
	ll v1 = query2(a, b, k * 2 + 1, l, (l + r) / 2);
	ll v2 = query2(a, b, k * 2 + 2, (l + r) / 2, r);
	return max(v1, v2); //戻り値
}

ll dat3[2560000], sz3;

void init3(ll n) {
	sz3 = 1;
	while (sz3 < n)sz3 *= 2;
	REP(i, sz3 * 2 - 1) dat3[i] = 0; //初期値
}

void update3(ll k, ll a) { //場所(0-indexed), 値
	k += sz2 - 1;
	dat3[k] = a;
	while (k > 0) {
		k = (k - 1) / 2;
		dat3[k] = dat3[k * 2 + 1] + dat3[k * 2 + 2]; //更新
	}
}

ll query3(ll a, ll b, ll k, ll l, ll r) { //[a, b) 呼ぶとき (a, b, 0, 0, sz)
	if (r <= a or b <= l)return 0;
	if (a <= l and r <= b)return dat3[k];
	ll v1 = query3(a, b, k * 2 + 1, l, (l + r) / 2);
	ll v2 = query3(a, b, k * 2 + 2, (l + r) / 2, r);
	return v1 + v2; //戻り値
}

ll ans, c2, cnt, t;


int main() {
	ll n, k;
	cin >> n >> k;
	init(n);
	init2(n);
	init3(n);
	vector<ll> s(n);
	REP(i, n) {
		cin >> s[i];
		update(i, s[i]);
		update2(i, s[i]);
	}
	REP(i, n - 1) {
		if (s[i + 1] < s[i]) update3(i + 1, 1);
	}
	if (query3(1, k, 0, 0, sz) == 0)cnt++;
	else ans++;
	FOR(i, 1, n - k + 1) {
		ll mi = query(i, i + k - 1, 0, 0, sz);
		ll ma = query2(i, i + k - 1, 0, 0, sz);
		bool ok = false;
		if (query3(i + 1, i + k, 0, 0, sz) == 0)ok = true;
		//cout << mi << " " << ma << " " << ok << endl;
		if (ok) {
			cnt++;
			continue;
		}
		if (mi > s[i - 1] and ma < s[i + k - 1]) continue;
		ans++;
	}
	if (cnt > 0)ans++;
	cout << ans << endl;
}

Measured memory_bytes: 20224