akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {

    class Sieve(n: Int) {
        val f = IntArray(n + 1)
        val primes = mutableListOf<Int>()

        init {
            f[0] = -1
            f[1] = -1
            for (i in 2..n) {
                if (f[i] > 0) continue
                primes.add(i)
                f[i] = i
                if (i.toLong() * i.toLong() > n) continue
                for (j in i * i..n step i) {
                    if (f[j] == 0) f[j] = i
                }
            }
        }

        fun factor(x: Int): MutableMap<Int, Int> {
            val r = mutableMapOf<Int, Int>()
            var x1 = x
            while (x1 != 1) {
                r[f[x1]] = r.getOrElse(f[x1]) { 0 } + 1
                x1 /= f[x1]
            }
            return r
        }
    }

    val mod = 1e9.toLong() + 7

    fun pow(base: Long, exp: Long): Long {
        if (exp == 0L) return 1L
        var a = pow(base, exp shr 1)
        a *= a
        a %= mod
        if (exp and 1L == 0L) return a
        return base * a % mod
    }

    fun inv(x: Long): Long {
        return pow(x, mod - 2)
    }

    val s = Sieve(1e6.toInt())

    val n = readLine()!!.toInt()
    val a = readLine()!!.split(' ').map { it.toInt() }

    val map = mutableMapOf<Int, Int>()
    for (i in 0 until n) {
        val fs = s.factor(a[i])
        for ((f, c) in fs) {
            map[f] = Math.max(c, map.getOrElse(f) { 0 })
        }
    }

    var lcm = 1L
    for ((f, c) in map) {
        repeat(c) {
            lcm *= f
            lcm %= mod
        }
    }

    println(a.map { lcm * inv(it.toLong()) % mod }.reduce { acc, l -> (acc + l) % mod })
}


Measured memory_bytes: 49968
import java.util.*;
class Main{
    /*
     * 整数 -> nextInt() (遅い場合は下のni())
     * 単語 -> next()
     * 1行 -> nextLine()
     * 注意 : nextLIneをnext(),nextInt()のあとに呼び出す場合、次が改行だと改行だけ取ってしまうので注意
     */
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] A = new int[N];
        for(int i=0;i<N;i++) A[i] = sc.nextInt();

        int[] cnt = new int[N+1];
        for(int i=0;i<N;i++) cnt[A[i]]++;
        Arrays.sort(cnt);

        int sum = 0;
        for(int i=0;i<K;i++){
            sum += cnt[N-i];
        }
        System.out.println(N-sum);
    }
}


Measured memory_bytes: 78756
def chess(arr)
	arr.each{|i|
		count = 1
		1.upto(i[0]){
			line = ""
			if (count % 2 == 1)
				cnt = 1
				1.upto(i[1]){
					if (cnt % 2 == 1)
						line << "#"
					else
						line << "."
					end
					cnt += 1
				}
				puts line
				count += 1
			else
				cnt = 1
				1.upto(i[1]){
					if (cnt % 2 == 1)
						line << "."
					else
						line << "#"
					end
					cnt += 1
				}
				puts line
				count += 1
			end
		}
		puts ""
	}
end


input_arr = []
while input = gets
	h, w = input.split(' ').map(&:to_i)
	break if (h == 0 && w == 0)
	input_arr << [h, w]
end

chess(input_arr)

Measured memory_bytes: 8728
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

vector<vector<char>> table(22,vector<char>(22,'#'));
vector<vector<int>> dist(22,vector<int>(22,0));
vector<vector<bool>> seen(22,vector<bool>(22,0));
int h,w;
queue<pair<int,int>> q;


void init_seen(){
  rep1(i,h) rep1(j,w) seen[i][j] = 0;
}

void init_dist(){
  rep1(i,h) rep1(j,w) dist[i][j] = 0;
}

void init_q(){
  while(!q.empty()) q.pop();
}

void search(int x,int y,int a){
  if(table[x][y] == '.'){
    if(seen[x][y] == 0){
      dist[x][y] = a+1;
      pair<int,int> next = make_pair(x,y);
      q.push(next);
    }
  }
}

int main(){
  cin >> h >> w;
  rep1(i,h) rep1(j,w) cin >> table[i][j];
  
  int ans = 0;
  rep1(i,h){
    rep1(j,w){
      
  init_dist();
  init_seen();
  init_q();
  pair<int,int> p = make_pair(i,j);
  q.push(p);
  while(!q.empty()){
    int a = q.front().first;
    int b = q.front().second;
    q.pop();
    if(seen[a][b]) continue;
    seen[a][b] = 1;
    if(a<1 || a>h) continue;
    if(b<1 || b>w) continue;
    if(table[a][b] == '#') continue;
    int d = dist[a][b];
    search(a+1,b,d);
    search(a-1,b,d);
    search(a,b+1,d);
    search(a,b-1,d);
  }
  int tmp = 0;
  rep1(i,h)rep1(j,w) tmp = max(tmp,dist[i][j]);
  ans = max(ans,tmp);
      
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &&j : v) scanf("%d", &j);
    ll ans = INF<ll>;
    for (int i = 1; i <= 100; ++i) {
        ll val = 0;
        for (int j = 0; j < n; ++j) {
            val += (i-v[j])*(i-v[j]);
        }
        ans = min(ans, val);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main
{
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    int N;
    long W;
    long[][] a;
    int w1;

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        N = sc.nextInt();
        W = sc.nextInt();
        HashMap<Integer, ArrayList<Integer>> map = new HashMap<>();
        w1 = sc.nextInt();
        int v1 = sc.nextInt();
        ArrayList<Integer> l1 = new ArrayList<>();
        l1.add(v1);
        map.put(w1, l1);

        for (int i = 1; i < N; i++) {
            int w = sc.nextInt(), v = sc.nextInt();
            ArrayList<Integer> l = map.getOrDefault(w, new ArrayList<>());
            l.add(v);
            map.put(w, l);
        }

        ArrayList<Integer> W1 = map.getOrDefault(w1, new ArrayList<>());
        ArrayList<Integer> W2 = map.getOrDefault(w1 + 1, new ArrayList<>());
        ArrayList<Integer> W3 = map.getOrDefault(w1 + 2, new ArrayList<>());
        ArrayList<Integer> W4 = map.getOrDefault(w1 + 3, new ArrayList<>());
        Collections.sort(W1, Collections.reverseOrder());
        Collections.sort(W2, Collections.reverseOrder());
        Collections.sort(W3, Collections.reverseOrder());
        Collections.sort(W4, Collections.reverseOrder());

        int s1 = W1.size(), s2 = W2.size(), s3 = W3.size(), s4 = W4.size();
        a = new long[4][];
        a[0] = new long[s1 + 1];
        a[1] = new long[s2 + 1];
        a[2] = new long[s3 + 1];
        a[3] = new long[s4 + 1];

        for (int i = 1; i <= s1; i++) {
            a[0][i] = a[0][i - 1] + W1.get(i - 1);
        }
        for (int i = 1; i <= s2; i++) {
            a[1][i] = a[1][i - 1] + W2.get(i - 1);
        }
        for (int i = 1; i <= s3; i++) {
            a[2][i] = a[2][i - 1] + W3.get(i - 1);
        }
        for (int i = 1; i <= s4; i++) {
            a[3][i] = a[3][i - 1] + W4.get(i - 1);
        }

        solve(0, 0, 0);
        out.println(ans);

        out.flush();
    }

    long ans = 0;
    void solve(int i, long ws, long sum) {
        if (i == 3) {
            long cnt = Math.min(a[3].length - 1, (W - ws) / (w1 + 3));
            sum += a[3][(int)cnt];
            ans = Math.max(ans, sum);
            return;
        }

        for (int j = 0; j < a[i].length; j++) {
            if (ws + j * (w1 + i) > W) break;
            solve(i + 1, ws + j * (w1 + i), sum + a[i][j]);
        }
    }

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

    public static void main(String[] args) {
        new Main().run();
    }
}

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

int main() {   
  int n, y;
  cin >> n >> y;
  bool a = false;
  int no, hi, yu;
  for (int i = 0; i <= n; i++) {
  	for (int j = 0; j <= n-i; j++) {
      for(int k = 0; k <= n-i-j; k++) {
      	if((1000*i + 5000*(j) + 10000*(k) == y) && (i+ j+k == n)) {          
          a = true;
          no = i;
          hi = j; 
          yu = k;
          break;
      }
    }
  }

}
      if(a) {
    	cout << yu << ' ' << hi << ' ' << no << endl;
    }
    else {
    	cout << "-1 -1 -1" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<utility>
#include<stdlib.h>
#include<limits.h>
#include<cmath>
#include<set>
#include<initializer_list>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include<iomanip>
#include<algorithm>

#define sze 1000005
#define ld long double
#define ll long long
#define endl "\n"
#define pb push_back
#define mkp make_pair
#define mod 1000000007
#define ff first
#define ss second
#define F(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)

using namespace std;

int main(int argc, const char *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,w; cin>>n>>w;
    ll v[n+1],w1[n+1];
    for(ll i=0;i<n;i++)
    {
        cin>>w1[i]; cin>>v[i];
    }
    ll mx = 500005;
    ll dp[mx+5];
    memset(dp,mx,sizeof(dp));
    dp[0]=0;
    for(ll i=0;i<n;i++)
    {
        for(ll val = mx;val>=0;val--)
        {
            dp[val] = min(dp[val],(val>=v[i])?dp[val-v[i]]+w1[i]:INT_MAX);
        }
    }
    ll fin = 0;
    for(ll i=0;i<=mx;i++)
    {
        if(dp[i]<=w) fin = i;
    }
    cout<<fin<<endl;
}


Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <utility>

#include <cassert>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	int m = 0;
	rep(i,N) {
		cin >> a[i];
		m += a[i];
	}
	int mn = 1e9;
	int res = -1;
	rep(i,N) {
		if(mn > abs(a[i]*N - m)) {
			mn = abs(a[i]*N - m);
			res = i;
		}
	}
	cout << res << endl;
	return 0;
}


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

const int N = 100005;
int n, m, x, y;
vector<int> v[N];
vector<pair<int, int> > fp;
bool bo[N], st[N], sh[N];

void sgd(int dg, int op) {
	bo[dg] = sh[dg] = 1;
	for(int sw : v[dg]) {
		if(!bo[sw]) {
			sgd(sw, dg);
		} else {
			if(!sh[sw]) fp.push_back({dg, sw}), st[dg] ^= 1;
		}
	}
	if(dg ^ 1) {
		if(st[dg]) {
			fp.push_back({dg, op});
			st[dg] = 0;
		} else {
			fp.push_back({op, dg});
			st[op] ^= 1;
		}
	}
	sh[dg] = 0;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	if(m & 1)
		return cout << -1 << endl, 0;
	for(int i = 1; i <= m; ++i) {
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	sgd(1, 0);
	for(pair<int, int> a : fp) {
		cout << a.first << " " << a.second << "\n";
	}
	cout << flush;
	return 0;
}


Measured memory_bytes: 14324
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+10;
ll n,m,a,b,cnt;
ll head[N],bl[N];
struct Edge{ll nxt,to;}edge[N<<1];
inline void add(ll u,ll v){edge[++cnt]=(Edge){head[u],v};head[u]=cnt;}
void dfs(ll u,ll col){
	bl[u]=col;
	for(ll i=head[u];i;i=edge[i].nxt){
		ll v=edge[i].to;
		if(bl[v]==-1) dfs(v,!col);
		if(bl[v]!=!col){printf("%lld",n*(n-1)/2-m);exit(0);}
	}
}
int main(){
	scanf("%lld%lld",&n,&m);
	for(ll i=1;i<=m;i++) scanf("%lld%lld",&a,&b),add(a,b),add(b,a);
	memset(bl,-1,sizeof(bl));
	dfs(1,0);
	ll s1=0,s2=0;
	for(ll i=1;i<=n;i++) if(bl[i]) s1++; else s2++;
	
	printf("%lld",s1*s2-m);
}

Measured memory_bytes: 5120
#include<iostream>
#include<cmath>
#include<map>
#include<deque>
#include<string>
#include<algorithm>

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define fore(i,a) for(auto i:a)
#define ll long long
using namespace std;
int h,n;
int a[10005],b[10005];
int dp[10005];//hp i　分にかかるmp最小値
int main(){
    cin>>h>>n;
    rep(i,0,n){
        cin>>a[i]>>b[i];
    }
    dp[0]=0;
    rep(i,1,h+1){
        rep(j,0,n){//すべての魔法を検索
            if(i>=a[j]){
                int x=dp[i-a[j]]+b[j];
                if(dp[i]!=0){
                    dp[i]=min(dp[i],x);
                }else{
                    dp[i]=x;
                }
            }else{//hpが少ないとき
                int x=b[j];
                if(dp[i]!=0){
                    dp[i]=min(dp[i],x);
                }else{
                    dp[i]=x;
                }
            }
        }
    }
    // rep(i,0,h+1){
    // puts(dp[i]);
    // }
    puts(dp[h]);
}

Measured memory_bytes: 256
// AtCoder ABC104: A - Rated for Me
// 2019.9.10 bal4u

#include <stdio.h>

int main()
{
	int R;
	
	scanf("%d", &R);
	if (R < 1200) puts("ABC");
	else if (R < 2800) puts("ARC");
	else puts("AGC");
	return 0;
}

Measured memory_bytes: 128
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

A, B = MAP()
print("Yay!" if A <= 8 and B <= 8 else ":(")

Measured memory_bytes: 5588
#include <stdio.h>

#define NUM 1000

int main(void)
{
	int h[NUM];
	int w[NUM];
	int i, j;
	int s;

	i = 0;
	s = 0;

	while (1){
		scanf("%d %d", &h[i], &w[i]);
		if (h[i] == 0 && w[i] == 0)break;
		i++;
	}

	while (h[s] != 0 && w[s] != 0){
		for (i = 0; i < h[s]; i++){	//???
			for (j = 0; j < w[s]; j++){	//?¨?
				printf("#");
			}
			printf("\n");
		}
		s++;
		printf("\n");
	}
			

	
	return 0;
}

Measured memory_bytes: 580
// Problem : F - Select Half
// Contest : AtCoder - AtCoder Beginner Contest 162
// URL : https://atcoder.jp/contests/abc162/tasks/abc162_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 2e5 + 5;
const ll MOD = 1e9 + 7;

int n, arr[maxN];
vi poss[maxN];
map<int, ll> dp[maxN][2];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n;
	RI(i, n) cin >> arr[i];
	if (n % 2 == 0) {
		RI(i, n) {
			if (i % 2 == 1) poss[i] = {i / 2, i / 2 + 1};
			else poss[i] = {i / 2};
		}
	} else {
		RI(i, n) {
			poss[i] = {(i - 1) / 2, (i - 1) / 2 + 1};
		}
	}
	// dp[i][f][k] - i-ty, f znaczy czy biore, k - ile wzialem
	dp[0][0][0] = 0;
	dp[0][1][0] = -inf;
	dp[0][0][1] = dp[0][0][2] = dp[0][1][1] = dp[0][1][2] = -inf;
	RI(i, n) {
		for (auto k: poss[i]) dp[i][0][k] = dp[i][1][k] = -inf;
	}
	RI(i, n) {
		for (auto k: poss[i]) {
			FOR(j, i - 3, i - 1) {
				if (j < 0) continue;
				if (dp[j][0].count(k))
					dp[i][0][k] = max(dp[i][0][k], dp[j][0][k]);
				if (dp[j][1].count(k))
					dp[i][0][k] = max(dp[i][0][k], dp[j][1][k]);
				if (dp[j][0].count(k - 1))
					dp[i][1][k] = max(dp[i][1][k], dp[j][0][k - 1] + arr[i]);
				if (dp[j][1].count(k - 1) && j != i - 1) {
					dp[i][1][k] = max(dp[i][1][k], dp[j][1][k - 1] + arr[i]);
				}
			}
		}
	}
	cout << max(dp[n][0][n / 2], dp[n][1][n / 2]) << endl;
	return 0;
}
 


Measured memory_bytes: 84108
import java.util.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;

public class Main {
	public static void main(String[] args) throws ParseException{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      	int k = sc.nextInt();
      	int ans = k;
         
      	for(int i = 1; i < n;i++) {
          ans *= (k-1);
        }
      
      	System.out.println(ans);
      	
        
	}
}

Measured memory_bytes: 35804
#include <bits/stdc++.h>
#define deb(x)     cerr << (#x) << " : " << (x) << "\n"
#define ll long long int
#define ld long double
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
using namespace std;

ll powmod(ll a, ll b, ll MOD = MOD){
	if(!a and !b)	return 1ll;
	if(!a)	return a;
	ll res = 1ll;
	b %= (MOD - 1ll), a %= MOD;
	while(b){
		if(b%2 == 1)	res = (res * a) % MOD;
		a = (a * a) % MOD;
		b /= 2;
	}
	return res;
}

ll dp[2010][2010];

int main(){    
    #ifdef XOX
        freopen("D:\\V S Code\\cpp\\competitiveProgramming\\Input.txt", "r", stdin);
        freopen("D:\\V S Code\\cpp\\competitiveProgramming\\OPT.txt", "w", stdout);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

	int n;
	cin >> n;
	pair<ll, ll> arr[n];
	for(int i = 0; i < n; i++){
		cin >> arr[i].first;
		arr[i].second = i;
	}

	sort(arr, arr + n, greater<pair<ll, ll>>());
	memset(dp, -20, sizeof(dp));
	dp[0][0] = 0ll;

	ll cur, ans = 0;
	for(int len = 1; len <= n; len++){
		cur = arr[len-1].first;
		for(int i = 0, j = len; i <= len; i++, j--){
			if(i)	dp[i][j] = max(dp[i][j], dp[i-1][j] + cur*abs(arr[len-1].second - i + 1));
			if(j)	dp[i][j] = max(dp[i][j], dp[i][j-1] + cur*abs(arr[len-1].second - n + j));
			if(len == n)	ans = max(ans, dp[i][j]);
		}
	}

	cout << ans;
}

Measured memory_bytes: 35212
#include <iostream>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <vector>
using namespace std;

int main() {
	long long n;
	cin >> n;
	int keta = 0;
	long long sum = 0;
	while (n >= 10) {
		int amari = n % 10;
		sum += amari;
		n -= amari;
		n = n / 10;
		keta++;
	}
	sum += n;
	long long ans;
	ans = max(sum, n - 1 + keta * 9);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e6+6;


int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int n;
	
	cin>>n;
	
	ll ans = 0;
	int p = 0;
	for(int i=0;i<n;++i){
		int x;
		cin>>x;
		if(x<p){
			ans+=p-x;
		}else p = x;
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 3652
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)

#define DumpArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

/*
 * ***_bound(6)
 * 5 6 6 6 6 6 7 7 7
 *   ^lower    ^upper
 * void reverse(c.begin(), c.end())
 *
 * graph
 * seg tree
 * dp
 * brute force
 */
struct Comparator{
    int operator()(int l, int r) const {
        return r<l;
    }
};
//set<int, Comparator> S;

struct Vec{
    double v[2];
    string to_s(){
        return "("+to_string(v[0])+","+to_string(v[1])+")";
    }
    double& operator[](int t){
        return v[t];
    }
    Vec operator+(Vec t) {
        return {v[0]+t[0],v[1]+t[1]};
    }
    Vec& operator+=(Vec t) {
        v[0]+=t[0];v[1]+=t[1];
        return *this;
    }
    Vec operator-(Vec t) {
        return {v[0]-t[0],v[1]-t[1]};
    }
    Vec& operator-=(Vec t) {
        v[0]-=t[0];v[1]-=t[1];
        return *this;
    }
    Vec operator*(double t) {
        return {v[0]*t,v[1]*t};
    }
    Vec& operator*=(double t) {
        v[0]*=t;v[1]*=t;
        return *this;
    }
    double operator*(Vec t) {
        return v[0]*t[0]+v[1]*t[1];
    }
    Vec operator-(){
        return {-v[0],-v[1]};
    }
    static Vec Z;
};
Vec Vec::Z={0,0};

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef vector<P> VP;
typedef pair<ll,ll> RP;
int main() {
    ll N,K,S;
    cin>>N>>K>>S;
    if (S<=2) {
        REP(i,K)
            cout << S << " ";
        REP(i,N-K)
            cout << S+1<<" ";
    } else {
        REP(i,K)
            cout << S << " ";
        REP(i,N-K)
            cout << S-1<<" ";
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 1280
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")

#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int a,b,c;
int main()
{
	cin>>a>>b>>c;
	if (b==a+c || a==b+c || c==a+b)
	   cout<<"Yes\n";
	else
	   cout<<"No\n";
	return 0;
} 

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

int main() {
  int n, i, k, c;
  string s;
  cin>>s;
  n = s.size();
  k = n/2;
  c = 0;
  for (i = 0; i < k; i++) {
    if (s.at(i) != s.at(n-i-1)) c++;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var N = Int64.Parse(input);
            var S =  (Int64)Math.Floor(Math.Sqrt(N));
            Int64 A = 0;
            Int64 B = 0;
            for(var i = S; i > 0; i--)
            {
              if(N%i == 0)
              {
                A = i;
                B = N/A;
                break;
              }
            }
          	Console.WriteLine(A+B-2);
        }
    }
}


Measured memory_bytes: 13140
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn readu() -> usize {
    read::<usize>()
}

#[allow(dead_code)]
fn readi() -> i32 {
    read::<i32>()
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let mut b = vec![0; n];

    for i in (1..n + 1).rev() {
        let mut j = i * 2;
        let mut sum: i32 = a[i - 1] as i32;
        loop {
            if j > n {
                break;
            }
            sum -= b[j - 1];
            j += i;
        }
        b[i - 1] = sum % 2;
        if b[i - 1] < 0 {
            b[i - 1] += 2;
        }
    }
    let mut cnt = 0;
    for &bi in &b {
        if bi > 0 {
            cnt += 1;
        }
    }
    println!("{}", cnt);
    for (i, &bi) in b.iter().enumerate() {
        if bi > 0 {
            println!("{}", i + 1);
        }
    }
}


Measured memory_bytes: 7164
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
import java.math.BigInteger;
import java.math.BigDecimal;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		long a = sc.nextLong();
		String b = sc.next();
		BigDecimal A = new BigDecimal(a);
		BigDecimal B = new BigDecimal(b);
		
		// 計算
		
		// 出力
		System.out.println(A.multiply(B).toBigInteger());
	}

}


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

#define ascent(i, a, b) for(int i = a; i < b; i ++)

int ans;
int n, k, s;

using namespace std;

void find(int level, int num, int sum) {
  if(level == k) {
    if(sum == s) {
      ans ++;
    }
    return;
  }

  ascent(i, num+1, n+1) {
    find(level+1, i, sum+i);
  }
}

int main() {
  while(cin >> n >> k >> s, n||k||s) {
    ans = 0;
    find(0, 0, 0);
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define debug(x) (cout << "#x = " << (x) << '\n')

using namespace std;
typedef long long ll;

inline char gc() {
	static char buf[100000], *p1 = buf, *p2 = buf;
	return (p1 == p2) && (p2 = (p1 = buf) +
		fread(buf, 1, 100000, stdin), p1 == p2)? EOF: *p1++;
}

#define dd ch = getchar()
template <class T>
inline void read(T &x) {
	x = 0;
	int f = 0; char dd;
	for (; !isdigit(ch); dd) f ^= (ch == '-');
	for (; isdigit(ch); dd)  x = (x << 1) + (x << 3) + (ch ^ 48);
	x = f? -x: x;
}
#undef dd

template <class T>
inline void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 | 48);
}

template <class T>
inline void wrn(T x) {
	write(x), putchar(' ');
}

template <class T>
inline void wln(T x) {
	write(x), putchar('\n');
}

template <class T>
inline void wlnn(T x, T y) {
	wrn(x), wln(y);
}

const int N = 1e5 + 5;

int Mn = 1e9;
int A, B, m, a[N], b[N], x[N], y[N], c[N];

int main()
{
	read(A), read(B), read(m);
	for (int i = 1; i <= A; ++i) read(a[i]);
	for (int i = 1; i <= B; ++i) read(b[i]);
	for (int i = 1; i <= m; ++i) {
		read(x[i]), read(y[i]), read(c[i]);
		Mn = min(Mn, a[x[i]] + b[y[i]] - c[i]);
	}
    int minA = 1e9, minB = 1e9;
    for (int i = 1; i <= A; ++i) minA = min(minA, a[i]);
    for (int i = 1; i <= B; ++i) minB = min(minB, b[i]);
	return wln(min(Mn, minA + minB)), 0;
}

/*

*/




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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> data(N);
  
  for (int i = 0; i < N; i++){
  	cin >>  data.at(i);
  }
  
  sort(data.begin(),data.end());
  reverse(data.begin(),data.end());
  int A = 0, B = 0;
  
  for (int i = 0; i < N; i++){
    if (i % 2 == 0) A += data.at(i);
    else B += data.at(i);
  } 
    
  cout << A - B << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

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


// 素数判定
bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return true;
}

// 約数の列挙
vector<ll> divisor(ll n) {
    vector<ll> res;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if(i != n/i){
              res.pb(n/i);
            }
        }
    }
    return res;
}


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

  ll ans = 1;

  ll tmp = gcd(A,B);
  //cout<<tmp<<endl;

  vector<ll> a;
  //tmpの約数の列挙
  a = divisor(tmp);

  if(tmp == 1){
    cout<<1<<endl;
    return 0;
  }
  //公約数が素数の時はans=2
  if(is_prime(tmp)){
    cout<<2<<endl;
    return 0;
  }

  //cout<<a.size()<<endl;
  //それ以外
  for(ll i = 0; i<a.size(); i++){
    if(is_prime(a[i])) ans++;
  }

  cout<<ans<<endl;
}


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

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = y.pow(y, n);
  Mint pow(Mint a, long long n) const {
    Mint y(1);
    Mint b(a);
    while (n > 0) {
      if (n & 1) y *= b;
      b *= b;
      n >>= 1;
    }
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return pow(a, mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= i;
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};

int main(){
  int X;
  std::cin >> X;
  if (X>=30) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 3044
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b != c ||
      a == c && a != b ||
      b == c && a != b) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

#define Max(a, b) (a > b ? a : b)

typedef struct grid{
  int x;
  int y;
  int a;
} grid;

//昇順
int a_acs(const void *a, const void *b)
{
  return ((grid *)a)->a - ((grid *)b)->a;
}

int main() {
  int h, w, d;
  scanf("%d%d%d", &h, &w, &d);
  grid g[h*w];
  for (int i=0; i<h; i++)
    for (int j=0; j<w; j++) {
      scanf("%d", &(g[i*w+j].a));
      g[i*w+j].x = i+1;
      g[i*w+j].y = j+1;
    }
  int q;
  scanf("%d", &q);
  int l[q], r[q];
  for (int i=0; i<q; i++)
    scanf("%d%d", l+i, r+i);
  qsort(g, h*w, sizeof(grid), a_acs);
  long cost[h*w];
  for (int i=0; i<d; i++)
    cost[i] = 0;
  for (int i=d; i<h*w; i++)
    cost[i] = cost[i-d] + abs(g[i-d].x - g[i].x) + abs(g[i-d].y - g[i].y);
  for (int i=0; i<q; i++)
    printf("%ld\n", cost[r[i]-1]-cost[l[i]-1]);
  return 0;
}


Measured memory_bytes: 3548
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.IO;
using System.Text;
using N = System.Int32;

static class Program
{
    static public void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        var solver = new Solver();
        solver.Solve();
        Console.Out.Flush();
    }
}

public class Solver
{
    N[] parent;
    N[] size;
    public void Solve()
    {
        N n = rn;
        N m = rn;
        parent = new N[n];
        size = new N[n];
        for (int i = 0; i < n; i++) { parent[i] = i; size[i] = 1; }
        N a = 0, b = 0;
        for (int i = 0; i < m; i++)
        {
            a = rn - 1; b = rn - 1;
            unite(a, b);
        }
        N p = 0;
        for(int i = 0; i < n; i++)
        {
            if (parent[i] == i && size[i] > p) p = size[i];
        }
        Write(p);
    }

    public N root(N x)
    {
        if (parent[x] == x) return x;
        else return parent[x] = root(parent[x]);
    }
    public void unite(N x, N y)
    {
        var rx = root(x);
        var ry = root(y);
        if (rx == ry) return;
        else
        {
            parent[ry] = rx;
            size[rx] += size[ry];
        }
    }

    N rn { get { return sc.Integer(); } }
    double rd { get { return sc.Double(); } }
    string rs { get { return sc.Scan(); } }
    public StreamScanner sc = new StreamScanner(Console.OpenStandardInput());

    void Write<T>(T t) { Console.WriteLine(t.ToString()); }
    void YN(bool t) { Console.WriteLine(t ? "YES" : "NO"); }
    void Yn(bool t) { Console.WriteLine(t ? "Yes" : "No"); }
    void yn(bool t) { Console.WriteLine(t ? "yes" : "no"); }
}



public class StreamScanner
{
    public StreamScanner(Stream stream) { str = stream; }
    private readonly Stream str;
    private readonly byte[] buf = new byte[1024];
    private int len, ptr;
    public bool isEof = false;
    public bool IsEndOfStream { get { return isEof; } }
    private byte read()
    {
        if (isEof) throw new EndOfStreamException();
        if (ptr >= len)
        {
            ptr = 0;
            if ((len = str.Read(buf, 0, 1024)) <= 0)
            {
                isEof = true;
                return 0;
            }
        }
        return buf[ptr++];
    }
    public char Char()
    {
        byte b = 0;
        do b = read();
        while (b < 33 || 126 < b);
        return (char)b;
    }
    public string Scan()
    {
        var sb = new StringBuilder();
        for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
            sb.Append(b);
        return sb.ToString();
    }
    public N Integer()
    {
        N ret = 0; byte b = 0; var ng = false;
        do b = read();
        while (b != '-' && (b < '0' || '9' < b));
        if (b == '-') { ng = true; b = read(); }
        for (; true; b = read())
        {
            if (b < '0' || '9' < b)
                return ng ? -ret : ret;
            else ret = ret * 10 + b - '0';
        }
    }
    public double Double() { return double.Parse(Scan()); }
}


Measured memory_bytes: 25344
#include<stdio.h>
int main(void){
	
	int a,b,c,d,e,k;
	
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&e);
	scanf("%d",&k);
	
	if(e-a<=k){
		printf("Yay!");
	}else{
		printf(":(");
	}
	return(0);
}

Measured memory_bytes: 2148
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = Integer.parseInt(scanner.next());
        int answer = 0;

        scanner.close();
        answer = a + a * a + a * a * a;
        
        System.out.println(answer);
    }
}


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

using namespace std;

int arr[5][105];

int dp[5][105];

int n, m;

void solve() {
    scanf("%d", &m);
    n = 2;

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            scanf("%d", &arr[i][j]);
        }
    }

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + arr[i][j];
        }
    }

    printf("%d\n", dp[n][m]);
}

int main() {
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
use proconio::{input};

fn main() {
    input! {
        N: usize,
        P: [usize; N * N]
    }
    use std::collections::{VecDeque};

    let mut dist = vec![vec![-1; N]; N];
    let mut queue = VecDeque::new();
    for i in 0..N {
        for j in 0..N {
            if i == 0 || j == 0 || i == N - 1 || j == N - 1 {
                dist[i][j] = 1;
                queue.push_back((i as i32, j as i32));
            }
        }
    }
    
    while let Some((y, x)) = queue.pop_front() {
        for (dy, dx) in &[(1, 0), (0, 1), (-1, 0), (0, -1)] {
            let ny = y + dy;
            let nx = x + dx;
            if ny < 0 || nx < 0 || ny >= N as i32 || nx >= N as i32 { continue }
            if dist[ny as usize][nx as usize] == -1 {
                dist[ny as usize][nx as usize] = dist[y as usize][x as usize] + 1;
                queue.push_back((ny, nx));
            }
        }
    }

    let mut ans = 0;
    let mut grid = vec![vec![true; N]; N];
    for p in P {
        let y = ((p - 1) / N) as i32;
        let x = ((p - 1) % N) as i32;
        grid[y as usize][x as usize] = false;
        dist[y as usize][x as usize] -= 1;
        ans += dist[y as usize][x as usize] as i64;
        let mut queue = VecDeque::new();
        queue.push_back((y, x));
        while let Some((y, x)) = queue.pop_front() {
            for (dy, dx) in &[(1, 0), (0, 1), (-1, 0), (0, -1)] {
                let ny = y + dy;
                let nx = x + dx;
                if ny < 0 || nx < 0 || ny >= N as i32 || nx >= N as i32 { continue }
                let cost = if grid[ny as usize][nx as usize] { 1 } else { 0 };
                if dist[ny as usize][nx as usize] > dist[y as usize][x as usize] + cost {
                    dist[ny as usize][nx as usize] = dist[y as usize][x as usize] + cost;
                    queue.push_back((ny, nx))
                }
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 6852
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ball
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; ++i)
            {
                string[] input = Console.ReadLine().Split(' ');
                int[] nums = new int[10];
                for (int j = 0; j < 10; ++j)
                {
                    nums[j] = int.Parse(input[j]);
                }
                int minL = 0, minR =0;
                for (int j = 0; j < 10; ++j)
                {
                    if (nums[j] > minL)
                    {
                        minL = nums[j];
                        if (j == 9) Console.WriteLine("YES");
                    }
                    else if (nums[j] > minR)
                    {
                        minR = nums[j];
                        if (j == 9) Console.WriteLine("YES");
                    }
                    else
                    {
                        Console.WriteLine("NO");
                        break;
                    }
                }


            }
        }
    }
}



Measured memory_bytes: 15884
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    string s;
    cin>>s;
    int n=s.size();
    vec v(3,0);
    rep(i,n){
        if(s[i]=='a') v[0]++;
        if(s[i]=='b') v[1]++;
        if(s[i]=='c') v[2]++;
    }
    bool flag;
    sort(all(v));
    if(v[1]==0){
        if(v[2]==1) flag=true;
        else flag=false;
    }
    else if(v[0]==0){
        if(v[1]==1&&v[2]==1) flag=true;
        else flag=false;
    }else{
        if((v[2]-v[1]<=1&&v[1]-v[0]==0)||(v[2]-v[1]==0&&v[1]-v[0]<=1)) flag=true;
        else flag=false;
    }
    if(flag) cout<<"YES";
    else cout<<"NO";
}

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define MOD 1000000007
#define int ll

int N,a,b;


int __attribute__((optimize("Ofast"), target("arch=sandybridge"))) power(int a,int b,int M){ //returns a^b % M, O(logb)
  	 if (b==0) return 1;
    
   	int half = b/2;
   	int halfval;
    
   	halfval = (power(a,half,M))%M;
   	if (b%2 == 0) return (halfval * halfval) % M;
   	else return (((halfval * halfval) % M) * (a % M)) % M;
}


inline int __attribute__((optimize("Ofast"), target("arch=sandybridge"))) modinv(int A,int B,int M){
	A %= M;
	B = power(B,M-2,M);
	A *= B;
	A %= M;
	return A;
}


inline int __attribute__((optimize("Ofast"), target("arch=sandybridge"))) nchoosek(int n,int k){
	ll ans = 1;
	
	FOR(i,n-k+1,n){
		ans = (ans * i) % MOD;
	}
	
	int amt = 1;
	FOR(i,1,k){
		amt = (amt * i) % MOD;
	}

	
	return modinv(ans,amt,MOD);
		

}
int32_t main(){
	fast;
	
	cin>>N>>a>>b;

	
	int ans = (power(2,N,MOD) - 1 - nchoosek(N,a) - nchoosek(N,b)) % MOD;
	while (ans < 0) ans += MOD;
	cout<<ans;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	string s;
	cin >> s;
	ll ans = 0;
	vvi vv(s.size(), vi(s.size(), 0));
	rep(i, s.size()) {
		rep(j, s.size()-i) {
			int mul = s.size() - i - 2;
			if (j == s.size() - i - 1)mul++;;
			vv[i][j] = pow(2, mul);
		}
	}
	rep(i, s.size()) {
		rep(j, s.size()) {
			ans += vv[i][j]*(s[j]-'0')*pow(10, i);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512