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

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

constexpr int mod = 1e9 + 7;

inline LL invMod(LL a, LL m = mod) {
	LL b = m, u = 1, v = 0;
	while (b) {
		LL t = a / b;
		swap(a -= t * b, b);
		swap(u -= t * v, v);
	}
	return (u % m + m) % m;
}

constexpr int SZ = 1123456;
LL fact[SZ];
LL rfact[SZ];
struct fact_ {
	fact_() {
		fact[0] = 1;
		for (int i = 1; i<SZ; i++)
			fact[i] = fact[i - 1] * i%mod;
		rfact[SZ - 1] = invMod(fact[SZ - 1]);
		for (int i = SZ - 1; i>0; i--) {
			rfact[i - 1] = rfact[i] * i%mod;
		}
	}
}fact_init;

//O(1)
LL Perm(LL n, LL k) {
	LL u = fact[n];
	LL d = rfact[n - k] % mod;
	return u * d%mod;
}

//O(1)
LL Comb(LL n, LL k) {
	LL u = fact[n];
	LL d = (rfact[k] * rfact[n - k]) % mod;
	return u * d%mod;
}


int main() {
	int N, M;
	while (cin >> N >> M) {
		vector<int> A(M);
		cin >> A;
		reverse(ALL(A));
		vector<LL> dp(1 << N, 0);
		dp[0] = 1;
		for (int a : A) {
			auto nxt = dp;
			for (int i : range(1 << N)) {
				nxt[i] %= mod;
				bitset<32> b(i);
				for (int j : range(N)) {
					if (b[j])continue;
					if ((1 << N) - a + 1 < i + (1 << j))continue;
					LL cnt = Comb((1 << N) - a - i, (1 << j) - 1) * fact[1 << j] % mod;
					nxt[i | (1 << j)] += dp[i] * cnt% mod;
				}
			}
			
			swap(dp, nxt);
		}
		LL ret = 0;
		for (int i : range(1 << N)) {
			bitset<32> b(i);
			int rest = 0;
			for (int j : range(N)) {
				if (b[j])continue;
				rest += 1 << j;
			}
			LL cnt = fact[rest] * dp[i] % mod;
			if (__builtin_popcount(i) % 2) {
				ret += mod - cnt;
			}
			else {
				ret += cnt;
			}
		}
		ret %= mod;
		for (int i : range(N)) {
			ret *= 2;
			ret %= mod;
		}
		cout << ret << endl;
	}
	return 0;
}


Measured memory_bytes: 18816
s = list(input())
s.sort()
alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
no_include = []
sum = 0

for i in alpha:
    if i not in s:
        no_include.append(i)
        sum += 1

if sum != 0:
    print(no_include[0])
else:
    print('None')

Measured memory_bytes: 4328
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define ri rd<int>
using namespace std;
const int maxN = 6007;
const int INF = 1e9 + 7;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

int n;
char A[maxN], B[maxN];
int pre[maxN], nx[maxN];
struct rec {
	int l, r;
}a[maxN], tp[maxN];
int b[maxN], m;
int sum[maxN];

void getlr() {
	int cur = 0;
	rep (i, 1, 2*n) {
		if (B[i] == '1') cur = i;
		if (n < i) pre[i] = i - cur;
	}
	per (i, 3*n, n+1) {
		if (B[i] == '1') cur = i;
		if (i <= 2*n) nx[i] = cur - i;
	}
}

void chk() {
	int cnt = 0;
	rep (i, 1, n) if (B[i] == '1') ++ cnt;
	if (!cnt) {
		int res = INF;
		rep (i, 1, n) {
			bool ok = 1;
			For (j, 0, n) if (B[i+j] != A[1+j]) ok =0;
			if (ok) res = min(res, min(i - 1, n + 1 - i));
		}
		if (res == INF) puts("-1");
		else printf("%d\n", res);
		exit(0);
	}
}

int solve(int d) {
	int res = INF;
	int lim = (d < 0 ? -d : 0), cur = m;
	for (int l = n, r = (d > 0 ? d : 0); l >= lim; -- l) {
		for (; cur && l < a[cur].l; -- cur) r = max(r, a[cur].r);
		res = min(res, 2* (l + r));
	}
	return res;
}

int main() {

	scanf("%s%s", A+1, B+1); n = strlen(A+1);
	rep (i, 1, n) B[i+n] = B[i+n+n] = B[i];
	rep (i, 1, n) A[i+n] = A[i];

	chk();
	getlr();

	int res = INF;
	rep (p, 1, 2*n+1) {
		int d = p - (n + 1);
		m = 0;
		For (j, 0, n) if (A[1+j] != B[p+j]) a[++m] = (rec){pre[n+1+j], nx[n+1+j]};

		rep (i, 0, n) sum[i] = 0;
		rep (i, 1, m) ++sum[a[i].l];
		rep (i, 1, n) sum[i] += sum[i - 1];
		rep (i, 1, m) b[sum[a[i].l]--] = i;
		rep (i, 1, m) tp[i] = a[i];
		rep (i, 1, m) a[i] = tp[b[i]];

		res = min(res, solve(d) - abs(d) + m);
	}
	printf("%d\n", res);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
 
#define pb push_back
#define mp make_pair

typedef long long ll; 

#define fi first
#define se second
 
#define all(x) (x).begin(), (x).end()
 
using namespace std;             
//using namespace __gnu_pbds;

typedef vector<int> vi;
 
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int INF = (int)1e10;                   

int n;
double a[55];

void solve() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }               
    
    sort(a + 1, a + n + 1);

    double sum = a[1];

    for (int i = 1; i <= n; i++) {
        sum = (sum + a[i]) / 2;
    } 
    cout.precision(10);
    cout << fixed << sum; 
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int tt = 1;
 
    while (tt--) {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n);(i)>0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}


int main(){
    lint N,M;
    cin>>N>>M;
    lint ans=1;
    if(N==1){
        cout<<M;
        return 0;
    }
    rep(i,M){
        if(i==0)continue;
        if(M%i==0&&i*N<=M)ans=i;
        if(i*N>M)break;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n;
	int i,j;
	int a[100001]={};
	int b[100001]={};
	int anum=0,bnum=0;
	int temp;
	int a1=0,a2=0,b1=0,b2=0;
	scanf("%d",&n);
	//配列の添字に数字の数を対応付けるという戦略
	//a[1]は1の数
	for(i=0;i<n;i++){
		if(i%2==0){
			scanf("%d",&temp);
			a[temp]++;
		}else{
			scanf("%d",&temp);
			b[temp]++;
		}
	}
	for(i=0;i<100001;i++){
		//a[]の中で1番めと2番めの添字を探す
		//a1は1番出現数が多い数でa2は2番目に出現数の多い数
		//a[a1]はa1がa[a1]回出現したことを意味する
		if( a[a1]< a[i]){
			a2 = a1;
			a1 = i;
		}else if ( a[a2]<a[i]){
			a2 = i;
		}
		if( b[b1]< b[i]){
			b2 = b1;
			b1 = i;
		}else if ( b[b2]<b[i]){
			b2 = i;
		}
	}
	//printf("%d %d %d %d",a1,a2,b1,b2);
	//最後にansを出力する
	//a1!=b1だったら ans = n - (a1)-(b1);
	//a1==b1だったら a1+b2 と a2+b1の大きいほうを採用して
	//ans = n - 大きい方
	int ans;
	int big = a[a1] + b[b2];
	if ( big < a[a2]+b[b1]){
		big = a[a2]+b[b1];
	}
	if( a1!=b1){
		ans = n-(a[a1])-(b[b1]);
	}else{
		ans = n - big;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 896
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
B = LIST()
C = LIST()
ans = B[A[0]-1]

for i in range(1, N):
  ans += B[A[i]-1]
  if A[i] == A[i-1]+1:
    ans += C[A[i-1]-1]
    
print(ans)

Measured memory_bytes: 5200
#include<iostream>
#include<algorithm>
int main()
{
	int x, y;
	scanf("%d%d", &x, &y);
	for(int i=0;i<=x;i++)
	{
		int ans=2*i+4*(x-i);
		if(ans==y)
		{
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
 } 

Measured memory_bytes: 3776
#include<iostream>
using namespace std;
 
int main(){
    int r, c, A[101][101] = {0};
    cin >> r >> c;
    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            cin >> A[i][j];
            A[i][c] += A[i][j];
        }
    }
    for(int j = 0; j <= c; j++){
        for(int i = 0; i < r; i++){
            A[r][j] += A[i][j];
        }
    }
    for(int i = 0; i <= r; i++){
        for(int j = 0; j < c; j++){
            cout << A[i][j] << ' ';
        }
        cout << A[i][c] << endl;
    }   
    return 0;
}

Measured memory_bytes: 3124
h, w, k = map(int, input().split())

S = [list(map(int, input())) for _ in range(h)]
#print(S)
min_v = 10**18
for i in range(2**(h-1)):
  cnt = [0]*h
  row = [0]*h
  splt_cnt = 0
  splt = [0]*(h-1)
  find = 1
  for j in range(h-1):
    if (i>>j)&1:
      splt[j] = 1
  
  for x in range(1, h):
    if splt[x-1]==0:
      row[x] = row[x-1]
    elif splt[x-1]==1:
      row[x] = row[x-1] + 1
  #print(row, splt)
  for c in range(w):
    for r in range(h):
      #print(c,r)
      cnt[row[r]] += S[r][c]
    #print(max(cnt))
    if max(cnt)>k:
      cnt = [0] * h
      splt_cnt += 1
      for r in range(h):
        cnt[row[r]] += S[r][c]
      if max(cnt)>k:
        find = 0
  
  splt_cnt += sum(splt)
  #print('split _ %i'%sum(splt))
  if splt_cnt<min_v and find:
    min_v = splt_cnt

print(min_v)

Measured memory_bytes: 45660
H, W = map(int, input().split())
c = [list(map(int, input().split())) for i in range(10)]
A = []
for i in range(H):
    A.extend(list(map(int, input().split())))

for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j] = min(c[i][j], c[i][k] + c[k][j])

ans = 0
for Ai in A:
    if Ai != -1:
        ans += c[Ai][1]
print(ans)


Measured memory_bytes: 3572
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int A = sc.nextInt();
        
        if (X < A) {
            System.out.println(0);
        } else {
            System.out.println(10);
        }
    }
}

Measured memory_bytes: 22228
let [| N; D |] = stdin.ReadLine().Split() |> Array.map int64
let D2 = D * D

let rec solver result i =
    if i = N then result
    else
        let [| X; Y |] = stdin.ReadLine().Split() |> Array.map int64
        if X * X + Y * Y <= D2 then solver (result + 1) (i + 1L)
        else solver result (i + 1L)

solver 0 0L |> stdout.WriteLine


Measured memory_bytes: 41188
#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;

int main(){
  double a, b, c;
  cin >> a >> b >> c;
  double PI = acos(-1);
  // cout << PI << endl;
  double rad = PI * c/180.0;
  double h = b * sin(rad);
  double L = a + b + (sqrt(a*a+b*b-2*a*b*cos(rad)));
  double S = a * b * sin(rad) / 2;
  cout << fixed << setprecision(6) << S << endl;
  cout << fixed << setprecision(6) << L << endl;
  cout << fixed << setprecision(6) << h << endl;
}


Measured memory_bytes: 3508
#include <stdio.h>
#include <string.h>
int main(void){
	char de[4][10]={"dream","dreamer","erase","eraser"};
	char s[100001];
	int t=0,f=1;
	scanf("%s",s);
	while(strlen(s)-t>=5){
		if(strncmp(s+t,de[1],7)==0){
			if(strncmp(s+t+5,de[2],5)!=0){
				t+=7;
			}
			else{
				t+=5;
			}
		}
		else if(strncmp(s+t,de[0],5)==0){
			t+=5;
		}
		else if(strncmp(s+t,de[3],6)==0){
			t+=6;
		}
		else if(strncmp(s+t,de[2],5)==0){
			t+=5;
		}
		else{
			f=0;
			break;
		}
	}
	if(strlen(s)-t!=0){
		f=0;
	}
	if(f){
		puts("YES");
	}
	else{
		puts("NO");
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
bool used[256];
int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s;
    cin >> s;
    for(int i = 0;i < s.length();i++)
        used[s[i]] = true;

    for(char i = 'a';i <= 'z';i++)
    {
        if(!used[i])
        {
            cout << (char)i;
            return 0;
        }
    }
    cout << "None";
}


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

using namespace std;

const int N = 100005;
char s[N];

int main()
{
  int k;
  scanf("%s %d", s, &k);
  
  int n = strlen(s);
  
  for (int i = 0; i < n; ++i) {
    if (k == 0) break;
    if (i == n - 1) {
      int op = k % 26;
      s[i] = (s[i] - 'a' + op) % 26 + 'a';
      break;
    }
    char mn = s[i];
    int per = 0;
    for (int op = 0; op < min(k + 1, 26); ++op) {
      char nx = (s[i] - 'a' + op) % 26 + 'a';
      if (nx < mn) {
        mn = nx;
        per = op;
      }
    }
    s[i] = mn;
    k -= per;
  }
  
  printf("%s\n", s);
  return(0);
}

Measured memory_bytes: 384
function Main(input){
  var s = input.split('');
  s.pop();
  var check = 0;
  for(var i=s.length-1;i>=0;i--){
    if(s[i]=='Z'){
      check=i+1;
      break;
    }
  }
  for(var i=0;i<s.length;i++){
    if(s[i]=='A'){
      check-=i+1;
      break;
    }
  }
  console.log(check+1);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9548
(n, m) = map(int, input().split())
cities = {}
for i in range(m):
    (pref, year) = map(int, input().split())
    if not pref in cities.keys():
        cities[pref] = []
    cities[pref].append((i, year))


def get_id(pref, index):
    return "{}{}".format(str(pref).zfill(6), str(index).zfill(6))


ids = []
for key, values in cities.items():
    values.sort(key=lambda x: x[1])
    for i, value in enumerate(values):
        ids.append((value[0], get_id(key, i + 1)))
ids.sort(key=lambda x: x[0])
for id in ids:
    print(id[1])


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

using namespace std;

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

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

    int *p = new int[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i]--;
    }

    UnionFind u(n);
    for (int i = 0; i < n; i++) u.unionSet(i, i);

    int x, y;
    for (int i = 0; i < m; i++) {
        cin >> x;
        cin >> y;

        u.unionSet(x-1, y-1);
    }

    int count = 0;
    for (int i = 0; i < n; i++) {
        if (u.findSet(i, p[i])) count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

int main()
{
    unsigned long long n,m;
    std::cin >> n >> m;
    std::vector<std::pair<unsigned long long,unsigned long long>> a(n); 
    for (unsigned long long i = 0; i < n; i++)
    {
        std::cin >> a[i].first >> a[i].second;
    }

    std::sort(a.begin(),a.end(), [](std::pair<unsigned long long, unsigned long long> A,
                std::pair<unsigned long long, unsigned long long> B) { return A.first < B.first; });
    unsigned long long cost = 0;
    for (unsigned long long i = 0; i < n; i++)
    {
        if (m > a[i].second)
        {
            cost += a[i].first * a[i].second;
            m -= a[i].second;
        }
        else
        {
            cost += a[i].first * m;
            break;
        }
    }
    std::cout << cost << std::endl;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>


#define	ll_int	long long int


void max(ll_int *box, int b, int e)
{
	ll_int max;
	int i;

	max = box[b];

	for(i = b + 1; i < e; i++)
		if(max < box[i])
			max = box[i];

	printf("%lld\n", max);
}


void min(ll_int *box, int b, int e)
{
	ll_int min;
	int i;

	min = box[b];

	for(i = b + 1; i < e; i++)
		if(min > box[i])
			min = box[i];

	printf("%lld\n", min);
}


int main()
{
	int n, q;
	int query, b, e;
	ll_int *box;
	int i;

	scanf("%d", &n);

	box = (ll_int *)malloc(sizeof(ll_int) * n);

	for(i = 0; i < n; i++)
		scanf("%lld", &box[i]);


	scanf("%d", &q);

	for(i = 0; i < q; i++){
		scanf("%d", &query);

		if(query){
			scanf("%d %d", &b, &e);
			max(box, b, e);
		}else{
			scanf("%d %d", &b, &e);
			min(box, b, e);
		}
	}

	return 0;
}


Measured memory_bytes: 2112
#include <stdio.h>
int main()
{
    char s1[100],s2[100],s3[100];
    scanf("%s %s %s",&s1,&s2,&s3);
    s1[0]=(s1[0]-32);
    s2[0]=(s2[0]-32);
    s3[0]=(s3[0]-32);
    printf("%c%c%c\n", s1[0],s2[0],s3[0]);
    return 0;
}


Measured memory_bytes: 1708
#include<bits/stdc++.h>
using namespace std;
int fx(int x,int y){
    for(int i=min(x,y);i>0;i--){
        if(x%i==0 && y%i==0)return i;
    }
}

int main(){
    int x,y;    cin>>x>>y;
    int ans=0;
    if(x>y)swap(x,y);
    int ss=y/x;
    double s=1.0*y/x;
    if(ss<s)ss++;
    //    cout<<s<<endl;
    //    cout<<ss<<endl;
    ans += (x-1)+(y-1)+2;
    //    ans += -1*(x/ss) ;
    ans-= (fx(x,y)-1);


    cout<<ans<<endl;



    return 0;
}



Measured memory_bytes: 3088
n, k = map(int, input().split())
ans = 0
p = 10 ** 9 + 7
a = 0
b = 0
for j in range(k-1):
  a += j
  b += n-j
for i in range(k-1, n+1):
  a += i
  b += n-i
  ans = (ans+b-a+1)%p
print(ans)

Measured memory_bytes: 9192
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		int x1, x2, y1, y2, x3, x4, y3, y4;

		Scanner sc = new Scanner(System.in);

		x1 = sc.nextInt();
		y1 = sc.nextInt();
		x2 = sc.nextInt();
		y2 = sc.nextInt();
		y4 = x2 - x1 + y1;
		x4 = x1 + y1 - y2;
		y3 = x2 - x1 + y2;
		x3 = y1 - y2 + x2;
		System.out.println(x3 + " " + y3 + " " + x4 + " " + y4);

		sc.close();
	}
}


Measured memory_bytes: 20820
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int sum=0,last;
	for(int i=1;;i++){
		sum+=i;
		if(sum>=n){
			last=i;
			break;
		}
	}
	for(int i=1;i<=last;i++){
		if(i!=sum-n){
			printf("%d\n",i);
		}
	}
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<long long> vl;
typedef pair<long long, long long> pl;
typedef vector<vector<long long>> matrix;

#define F 						first
#define S 						second
#define PB 						push_back
#define MP 						make_pair
#define all(c) 					c.begin(), c.end()
#define f(i,a,b) 				for(ll i=a; i<b; i++)
#define rep(i,n) 				f(i,0,n)
#define tr(c,i) 				for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) 			(c.find(x) != c.end())	//for set and map
#define cpresent(c,x) 			(find(all(c),x) != c.end())	//for vectors
#define w(t)					ll t; cin>>t; while(t--)
#define epsilon 				1e-9
#define MOD						(ll)1e9

void doublade() {
	ios::sync_with_stdio(false); cin.tie(0); cout.precision(10);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

int main() {
	doublade();
	// w(t) {
		string s, t;
		cin >> s >> t;
		ll ans = t.length();
		rep(i, s.length()-t.length()+1) {
			ll tmp = 0;
			f(j, i, i+t.length()) {
				if(s[j]!=t[j-i]) tmp++;
			}
			ans = min(tmp, ans);
		}
		cout<<ans<<"\n";
	// }
	return 0;
}

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

const int MAXN = 1e5 + 10;

vector<int> grafo[MAXN];
int dp[MAXN],vis[MAXN],N,M;

int solve(int v){

	if(vis[v]) return dp[v];

	vis[v] = 1;
	int best = 0;

	for(int u : grafo[v]){
		best = max(best, solve(u) + 1 );
	}

	return dp[v] = best;

}

int main(){

	scanf("%d %d",&N,&M);
	for(int i = 1;i<=M;i++){
		int u,v;
		scanf("%d %d",&u,&v);
		grafo[u].push_back(v);
	}

	int best = 0;
	for(int i = 1;i<=N;i++) best = max(best, solve(i) );
	printf("%d\n",best);

	return 0;

}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    vector<P> V(N);
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        V[i] = P(a, b);
    }

    // dp1[i][j] := i番目までかつj分以下で得られる幸福度の最大
    vector<vector<int>> dp1(N + 1, vector<int>(T));
    rep(i, N) {
        P p = V[i];
        int a = p.first, b = p.second;
        rep(j, T) {
            dp1[i + 1][j] = max(dp1[i + 1][j], dp1[i][j]);
            if (j + a >= T) continue;
            dp1[i + 1][j + a] = max(dp1[i + 1][j + a], dp1[i][j] + b);
        }
    }

    // dp2[i][j] := i番以降かつj分以下で得られる幸福度の最大
    vector<vector<int>> dp2(N + 1, vector<int>(T));
    for (int i = N - 1; i >= 0; --i) {
        P p = V[i];
        int a = p.first, b = p.second;
        rep(j, T) {
            dp2[i][j] = max(dp2[i][j], dp2[i + 1][j]);
            if (j + a >= T) continue;
            dp2[i][j + a] = max(dp2[i][j + a], dp2[i + 1][j] + b);
        }
    }

    // 最後に食べるものを全探索する
    int ans = 0;
    rep(i, N) {
        P p = V[i];
        int a = p.first, b = p.second;
        rep(j, T) {
            if (T - 1 - j < 0) continue;
            int res = dp1[i][j] + dp2[i + 1][T - 1 - j];
            res += b;
            ans = max(ans, res);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 70912
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
    // Your code here!
    int n, k;
    scanf("%d %d", &n, &k);
    double p= 0.0;
    int temp;
    int q;
    
    for(int a=1; a<=n; a++){
        temp=(k-1)/a;
        q=1;
        while(1){
            if(temp/q==0) break;
            q*=2;
        }
        p += 1/(double)q;
    }
    p /= n;
    
    printf("%.12lf", p);
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define DEBUG(x) cerr << #x << ": " << x << "\n"

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int N;
    ll x;
    cin >> N >> x;
    vector<ll> a(N + 1);
    FOR(i, 1, N + 1) {
        cin >> a[i];
    }
    SORT(a);
    int res = 0;
    FOR(i, 1, N + 1) {
        if (x >= a[i]) {
            ++res;
            x -= a[i];
            if (i == N && x > 0) {
                --res;
            }
        } else {
            break;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;

import javax.swing.text.Segment;
import javax.xml.ws.WebEndpoint;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main //implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        long mod=1000000007;
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        
//        int n=sc.nextInt();
        int x=sc.nextInt()-sc.nextInt()*2;        
        
        out.println(max(x,0));
     	out.flush();
    }
    
    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}


class P {
	int x, y, d;
	P(int  x, int y, int d) {
	  this.x=x;
	  this.y=y;
	  this.d=d;
	}
}

//class P implements Comparable<P>{
//    int a,b;
//    P(int a, int b) {
//    	this.b=b;
//    	this.a=a;
//    }
//
//    public int compareTo(P p){
//        return p.a-a;//des
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() throws IOException{
        return this.nextString().toCharArray();
    }    
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 23252
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <numeric>
#include <vector>
#include <regex>

using namespace std;
using ll = long long;
template<typename T> void print(T t) {cout << t << endl;}


int main() {
	int c[3][3] = {};
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> c[i][j];
		}
	}
	bool ok = true;
	for (int j = 1; j < 3; j++) {
		for (int k = 0; k < 3; k++) {
			ok = ok && (c[0][0] - c[0][k] == c[j][0] - c[j][k]);
			ok = ok && (c[0][0] - c[k][0] == c[0][j] - c[k][j]);
		}
	}
	print(ok?"Yes":"No");
}

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

int main()
{
    int a[5][4][11];
    int b, f, r;
    for(int b=1;b<=4;b++)
    {
        for(int f=1;f<=3;f++)
        {
            for(int r=1;r<=10;r++)
            {
                a[b][f][r]=0;
            }
        }
    }
    
    int n, v;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> b >> f >> r >> v;
        a[b][f][r] += v;
    }
    
    for(int b=1;b<=4;b++)
    {
        for(int f=1;f<=3;f++)
        {
            for(int r=1;r<=10;r++)
            {
                cout << " " << a[b][f][r];
            }
            cout << endl;
        }
        if(b != 4) cout << "####################" << endl;
    }    

    return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int r; cin >> r;
  cout << 3*r*r << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)

#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
///                →,↑,←,↓,↗,↖,↙,↘
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };


signed main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int res = 0;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int num = 0;
		int x = i;
		while (true) {
			if (x % 2 == 0) {
				x /= 2;
				num++;
			}
			else {
				break;
			}
		}
		if (num >= res)
			ans = i;
		res = max(res, num);
		
	}
	cout << ans << endl;
	return 0;
}

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

namespace Program
{
    public class ABC084D
    {
        static public void Main(string[] args)
        {
            var prime = new HashSet<int>(Prime(100000));
            var sumary = new int[100001];
            for (int i = 1; i <= 100000; ++i)
            {
                if (prime.Contains(i) && prime.Contains((i + 1) / 2))
                {
                    sumary[i] = 1;
                }
                sumary[i] += sumary[i - 1];
            }

            var Q = NextInt;
            for (int i = 0; i < Q; ++i)
            {
                var l = NextInt;
                var r = NextInt;
                Console.WriteLine(sumary[r] - sumary[l - 1]);
            }
        }

        static class Console_
        {
            private static Queue<string> param = new Queue<string>();
            public static int NextInt() => int.Parse(NextString());
            public static long NextLong() => long.Parse(NextString());
            public static string NextString()
            {
                if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);
                return param.Dequeue();
            }
        }
        static int NextInt => Console_.NextInt();
        static long NextLong => Console_.NextLong();
        static string NextString => Console_.NextString();

        static IEnumerable<int> Prime(int x)
        {
            if (x < 2) yield break;
            yield return 2;
            var halfx = x / 2;
            var table = new bool[halfx + 1];
            var max = (int)(Math.Sqrt(x) / 2);
            for (int i = 1; i <= max; ++i)
            {
                if (!table[i])
                {
                    var add = 2 * i + 1;
                    yield return add;
                    for (int j = 2 * i * (i + 1); j <= halfx; j += add)
                    {
                        table[j] = true;
                    }
                }
            }
            for (int i = max + 1; i <= halfx; ++i)
            {
                if (!table[i]) yield return 2 * i + 1;
            }
        }
    }
}


Measured memory_bytes: 18764
#include<stdio.h>

int main(){
    int sum = 0, max=0;
    for(int i=0; i<5; i++){
        int a;
        scanf("%d", &a);
        sum += (a+9)/10*10;
        if(max < (10 - a%10)%10){
            max = (10 - a%10)%10;
        }
    }
    printf("%d", sum-max);

    return 0;
}

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

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

    for (int i = 0; i < B; i++)
    {
        if ((i * A) % B == C)
        {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 998244353
using namespace std;
using ll = long long;
using ldb = long double;

typedef struct {
	vector<int> edge;
	int hd = 0, tl = 0;
}node_t;
vector<node_t> node;
vector<bool> vi;

void dfs1(int st) {
	queue<int> qu;
	qu.push(st), vi[st] = true, node[st].hd = 0;
	while (!qu.empty()) {
		int x = qu.front();
		qu.pop();
		for (auto to : node[x].edge) {
			if (vi[to])continue;
			vi[to] = true;
			node[to].hd = node[x].hd + 1;
			qu.push(to);
		}
	}
}

void dfs2(int st) {
	queue<int> qu;
	qu.push(st), vi[st] = true, node[st].tl = 0;
	while (!qu.empty()) {
		int x = qu.front();
		qu.pop();
		for (auto to : node[x].edge) {
			if (vi[to])continue;
			vi[to] = true;
			node[to].tl = node[x].tl + 1;
			qu.push(to);
		}
	}
}

int main() {
	int N; cin >> N;
	node = vector<node_t>(N + 1);
	for (int i = 0; i < N - 1; i++) {
		int a, b; cin >> a >> b;
		node[a].edge.push_back(b);
		node[b].edge.push_back(a);
	}

	vi = vector<bool>(N + 1);
	dfs1(1);
	vi = vector<bool>(N + 1);
	dfs2(N);
	int fe = 0, su = 0;
	for (int i = 1; i <= N; i++) {
		//printf("node[%d].hd=%d node[%d].tl=%d\n", i, node[i].hd, i, node[i].tl);
		if (node[i].hd <= node[i].tl) fe++;
		else su++;
	}

	if (fe > su) cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
}


Measured memory_bytes: 9532
$mod = 10 ** 9 + 7

def fac(n, m)
    (n..m).inject(1) {|r, v| r * v % $mod}
end

def power(x, n)
    n == 0 ? 1 : ((n.odd? ? x : 1) * power(x ** 2 % $mod, n / 2) % $mod)
end

def com(n, m)
    m = n - m if n < 2 * m
    fac(n - m + 1, n) * power(fac(1, m), $mod - 2) % $mod
end

x, y = gets.split.map(&:to_i)

a, ma = (2 * y - x).divmod(3)
b, mb = (2 * x - y).divmod(3)

puts a < 0 || b < 0 || ma != 0 || mb != 0 ? 0 : com(a + b, a)

Measured memory_bytes: 3836
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <regex>
#include <string>
#include <stack>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
using ip = pair<int, int>;

class DisjointSet {
private:
	vector<int> p, rank;

	void link(int x, int y) {
		if (rank[x] > rank[y]) {
			p[y] = x;
		}
		else {
			p[x] = y;

			if (rank[x] == rank[y])
				rank[y]++;
		}
	}
public:
	DisjointSet() {};

	DisjointSet(int n) {
		p.resize(n);
		rank.resize(n);
		for (int i = 0; i < n; i++) {
			make_set(i);
		}
	}

	void make_set(int x) {
		p[x] = x;
		rank[x] = 0;
	}

	int find_set(int x) {
		if (p[x] != x) {
			p[x] = find_set(p[x]);
		}
		return p[x];
	}

	void unite(int x, int y) {
		link(find_set(x), find_set(y));
	}

	bool same(int x, int y) {
		return find_set(x) == find_set(y);
	}
};


int main()
{
	int N, K, L;
	scanf("%d%d%d", &N, &K, &L);

	DisjointSet ds1 = DisjointSet(N + 10);
	for (int i = 0; i < K; i++) {
		int p, q;
		scanf("%d%d", &p, &q);
		ds1.unite(p, q);
	}

	DisjointSet ds2 = DisjointSet(N + 10);
	for (int i = 0; i < L; i++) {
		int r, s;
		scanf("%d%d", &r, &s);
		ds2.unite(r, s);
	}

	map<ip, int> ans;
	for (int i = 1; i <= N; i++) {
		ans[ip(ds1.find_set(i), ds2.find_set(i))]++;
	}

	for (int i = 1; i <= N; i++) {
		printf("%d", ans[ip(ds1.find_set(i), ds2.find_set(i))]);
		if (i != N) printf(" ");
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 15104
import java.util.*;

public class Main{
    
    static int[][] lcs = new int[5002][5002];
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        String s = sc.next();
        
        lcs(s,s);
        int ans = 0;
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                if(i!=j && lcs[i][j]==lcs[j][i] && lcs[i][j]<=Math.abs(i-j)){
                    ans = Math.max(lcs[i][j], ans);
                }
            }
        }
        System.out.println(ans);
    }

    public static int lcs(String s1, String s2){
        int l1 = s1.length();
        int l2 = s2.length();

    	int maxLen = 0;
		
    	for (int i = 0; i < l1; i++) {
      		if (s1.charAt(i) == s2.charAt(0)) {
        		lcs[i][0] = 1;
        		maxLen = 1;
      		} else lcs[i][0] = 0;
    	}
    	for (int i = 0; i < l2; i++) {
      		if (s2.charAt(i) == s1.charAt(0)) {
        		lcs[0][i] = 1;
        		maxLen = 1;
      		} else lcs[0][i] = 0;
    	}
		
    	for (int i = 1; i < l1; i++) {
      		for (int j = 1; j < l2; j++) {
        		if (s1.charAt(i) != s2.charAt(j)){
            		lcs[i][j] = 0;
        		}else{
          			lcs[i][j] = lcs[i-1][j-1] + 1;
          			maxLen = Math.max(lcs[i][j], maxLen);
        		}
      		}
    	}
    	return maxLen;
    }
}


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


int main(){
    int k,n;
    string s;
    cin >> k >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    int mn;
    mn=k+v[0]-v[n-1];
    int sum=mn;
    for(int i=1;i < n;i++){
        sum+=v[i]-v[i-1];
        mn=max(mn,v[i]-v[i-1]);
    }
    cout << sum-mn << endl;
    return 0;  
}


Measured memory_bytes: 1024
#include <iostream>
#include <queue>


using namespace std;

#define REP(x, y) for(int (x) = 0; (x) < (y); (x)++)

const int MAX_H = 20, MAX_W = 20;
const int INF = -1;

char maze[MAX_H][MAX_W];
int h, w;
int sx, sy;
int gx, gy;

int d[MAX_H][MAX_W];

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

int bfs() {

    queue<pair<int, int>> que;
    int max_d = 0;

    REP(i, h){
        REP(j, w) {
            d[i][j] = INF;
        }
    }

    que.push(pair<int, int>(sx, sy));
    d[sx][sy] = 0;

    while (que.size()) {
        pair<int, int> p = que.front();
        que.pop();

        REP(i, 4){
            int nx = p.first + dx[i], ny = p.second + dy[i];

            if (0<=nx && nx < h && 0 <= ny && ny < w && maze[nx][ny] != '#' && d[nx][ny] == INF) {
                que.push(pair<int, int>(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }

    REP(i, h){
        REP(j, w) {
            if (max_d < d[i][j]) {
                max_d = d[i][j];
            }
        }
    }
    return max_d;


}


int main() {
    cin >> h >> w;
    REP(i, h) {
        REP(j, w) {
            cin >> maze[i][j];
        }
    }

    int max_d = 0;

    REP(i, h) {
        REP(j, w) {
            if (maze[i][j] == '#') continue;
            sx = i, sy = j;
            int d = bfs();
            if (max_d < d){
                max_d = d;
            }
        }
    }
    cout << max_d << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define ss cout << " ";
#define nn cout << "\n";
#define ct(x) cout << x;
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define qr queries();
void solve();
void YN(bool b){if (b){ctn("YES");}else{ctn ("NO");}};
void yn(bool b){if (b){ctn("Yes");}else{ctn ("No");}};
void queries(){int n;cin >> n;while (n--)solve();}
// // // // // // // // // // // // // // // // // // // // // // 
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
const int maxn = 200200;
 
void solve(){

    return;
}
 
 
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int64 rs = 0;
    int n;
    cin >> n;
    vec arr (n);
    for (int i = 0; i < n; i++){
        cin >> arr[i];
    }
    for (int i = 1; i < n; i++){
        if (arr[i] < arr[i-1]){
            rs+=arr[i-1] - arr[i];
            arr[i] = arr[i-1];
        }
    }
    ctn(rs);
    return 0;
}


Measured memory_bytes: 3984
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
ll power(ll x, ll y); 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitcount(n) __builtin_popcountll(n)
#define in_edges(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"

const ll MOD = 1000000007;
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    ll a, b, c = 0;
    cin >> a >> b;
    a = __gcd(a, b);
    repp(i, 2, 1000000){
        c += a % i == 0;
        while(a % i == 0) a /= i;
    }
    cout << c + 1 + (a > 1);
}

ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

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

int main(){
    int n, k;cin>>n>>k;
    vector<char> dislike(k); for (int i=0;i<k;i++){cin>>dislike[i];}
    for (int i=n;true;i++){
        string num_string = to_string(i);
        if (find_first_of(num_string.begin(), num_string.end(), dislike.begin(), dislike.end()) == num_string.end()){
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main (String[] args) throws IOException
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));

		Dice dice = new Dice();

		dice.setDice(input.readLine().split(" "));

		String solution = dice.Move(input.readLine().toCharArray());

		System.out.println(solution);
	}
}


class Dice{

	private String[] dice;

	private char[] move;

	private String[] over;

	public void setDice (String[] diceStr)
	{
		dice = new String[6];

		for(int num = 0; num < diceStr.length; num++)
			dice[num] = diceStr[num];
	}

	public String Move (char[] compass)
	{
		move = compass;

		//move.length回、転がす
		for(int kai = 0; kai < move.length; kai++)
		{
			over = new String[6];

			//東に転がす場合
			if(move[kai] == 'E')
			{
				over[0] = dice[3];
				over[1] = dice[1];
				over[2] = dice[0];
				over[3] = dice[5];
				over[4] = dice[4];
				over[5] = dice[2];

				for(int num = 0; num < over.length; num++)
					dice[num] = over[num];
			}

			//西に転がす場合
			else if(move[kai] == 'W')
			{
				over[0] = dice[2];
				over[1] = dice[1];
				over[2] = dice[5];
				over[3] = dice[0];
				over[4] = dice[4];
				over[5] = dice[3];

				for(int num = 0; num < over.length; num++)
					dice[num] = over[num];
			}

			//南に転がす場合
			else if(move[kai] == 'S')
			{
				over[0] = dice[4];
				over[1] = dice[0];
				over[2] = dice[2];
				over[3] = dice[3];
				over[4] = dice[5];
				over[5] = dice[1];

				for(int num = 0; num < over.length; num++)
					dice[num] = over[num];
			}

			//北に転がす場合
			else if(move[kai] == 'N')
			{
				over[0] = dice[1];
				over[1] = dice[5];
				over[2] = dice[2];
				over[3] = dice[3];
				over[4] = dice[0];
				over[5] = dice[4];

				for(int num = 0; num < over.length; num++)
					dice[num] = over[num];
			}
		}
		return dice[0];
	}
}


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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

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

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  preprocess();
  int n; cin>>n;
  vi ar(n);
  rep(i,0,n) cin>>ar[i];
  ar[0]--;
  int flag = 0;
  for(int i = 1; i<n; i++) {
    if(ar[i]>ar[i-1]) {
      ar[i]--;
    }
    else {
      if(ar[i]<ar[i-1]) flag = 1;
    }
  }
  if(!flag) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <fstream>
#include <cstring>

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, k;
	string s;
	vector <pair<int, int>> v;

	cin >> n >> k;
	cin >> s;

	int res = 0;
	int cnt = 0;
	int front = -1, end = -1;
	bool flag = false;

	for (int i = 0; i < n; i++)
	{
		if (flag == false)
		{
			if (s[i] == '1')
			{
				cnt++;
			}
			else
			{
				res = max(res, cnt);
				cnt = 0;
				front = i;
				flag = true;
			}
		}
		else
		{
			if (s[i] == '1')
			{
				end = i - 1;
				v.push_back(make_pair(front, end));
				flag = false;
				cnt = 1;
			}
		}
	}
	
	if (flag == false)
	{
		res = max(res, cnt);
	}
	else
	{
		v.push_back(make_pair(front, n - 1));
	}

	//cout << ' ' << k << ' '<< v.size() << '\n';

	int start = 0;
	for (int i = 0; i < v.size(); i++)
	{
		int idx = i + k;
		if (idx < v.size())
		{
			//cout << i << ' ' << k << ' ' << idx << '\n';
			int end = v[idx].first - 1;
			res = max(res, end - start + 1);
			start = v[i].second + 1;
		}
		else if (idx == v.size())
		{
			int end = n - 1;
			res = max(res, end - start + 1);
		}
	}

	if (k >= v.size())
	{
		res = max(res, n);
	}

	cout << res << '\n';

	return 0;
}


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

int main() {
	int64_t N, A, B;
	cin >> N >> A >> B;
  
  	if(A == 0){
      cout << 0 << endl;
      return 0;
    }
  	
  	int64_t total = N / (A + B) * A;
  	total += min(N % (A + B), A);
  
  	cout << total << endl;

}

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

int main(){
	double a;
	cin >> a;
	printf("%.6f %.6f\n",M_PI*pow(a,2.0),2*M_PI*a);
	return 0;
}


Measured memory_bytes: 3156
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl



signed main(){

	int N;
	string S;
	cin >> S;
	N = S.length();

	int odd = 0, even = 0;
	rep(i, N){
		if (i % 2 == 0){
			if (S[i] == '0') odd++;
			else even++;
		}
		else{
			if (S[i] == '1') odd++;
			else even++;
		}
	}
	if (odd > even){
		cout << N - odd << endl;
	}
	else
		cout << N - even << endl;


	return 0;
}

Measured memory_bytes: 512