akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n;
ll a[101010], b[101010];
ll cnta, cntb;
ll diff[101010];
int main(){
    cin>>n;
    REP(i, 0, n){
        cin>>a[i];
        cnta+=a[i];
    }
    REP(i, 0, n){
        cin>>b[i];
        cntb+=b[i];
    }

    REP(i, 0, n){
        diff[i]=a[i]-b[i];
    }

    sort(diff, diff+n);

    ll ans=0, sum=0;
    if(cnta<cntb){
        cout<<-1<<endl;
    }
    else{
        REP(i, 0, n){
            if(diff[i]>=0) break;
            ans++;
            sum+=diff[i];
        }
        RREP(i, 0, n){
            if(sum>=0) break;
            ans++;
            sum+=diff[i];
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s,t,ans;
int main()
{
    cin>>s>>t;
    int l1=s.length();
    int l2=t.length();
    if(l1<l2){
        ans=s+t;
    }
    else ans=t+s;
    cout<<ans;
    return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    LL a, b, x;cin >> a >> b >> x;
    cout << b/x - max(a-1, 0LL)/x + (a == 0) << endl;
    return 0;
}


Measured memory_bytes: 384
n = int(input())
#a,b=map(int,input().split()) #横並び
a=input()
b=input()
c=input()
cnt = 0
for i in range(n):
    ret = 0
    if a[i] != b[i] :
        ret+=1
    if b[i] != c[i] :
        ret+=1
    if c[i] != a[i]:
        ret+=1
    if ret % 3 != 0 :
        cnt+=1
    elif ret == 3:
        cnt+=2
#x=[int(input()) for i in range(3)] #縦に並んだのを配列に
#y=list(map(int,input().split())) #横に並んだのを配列に
print(cnt)
#print('YNEOS'[1::2])


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

using namespace std;

int main(){
	int N, K; cin >> N >> K;
	int l[N];
	for(int i = 0; i < N; ++i){
		cin >> l[i];
	}
	sort(l, l + N, greater<int>());
	cout << accumulate(l, l + K, 0) << endl;
}

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

using namespace std; 

#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mmp make_pair
#define st first
#define nd second
#define rd third
#define ll long long
#define pii pair <int, int>
#define tri pair <pii, int>
#define itr pair <int, pii>
#define PQ priority_queue
#define all(v) (v).begin(), (v).end()
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, n) for (int (i) = (a); (i) < (int)(n); i++)
#define FORN(i, a, n) for (int (i) = (a); (i) > (int)(n); i--)
#define Rep(i, n) for (int (i) = 0; (i) <= (int)(n); i++)
#define For(i, a, n) for (int (i) = (a); (i) <= (int)(n); i++)
#define Forn(i, a, n) for (int (i) = (a); (i) >= (int)(n); i--)
#define rep(i, n) for (int (i) = 1; (i) <= (int)(n); i++)
#define EACH(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define DEBUG(x) cout << #x << " = " << (x) << endl; 
#define PR(a, n) {cout << #a << " = "; FOR(_, 1, n) cout << a[_] << ' '; puts(""); }
#define PRO(a, n) { cout << #a << " = "; REP(_, n) cout << a[_] << ' '; puts(""); }
#define pi 3.1415926535897932384626433832795028841971

const int INF = 1e9; 
const int N = 1005; 
const int dx[] = {-1, 0, 1, 0}; 
const int dy[] = {0, 1, 0, -1}; 

inline ll read()
{
	ll x = 0; int f = 1, c = getchar(); 
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f; 
	for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48); 
	return x * f; 
}

int n, m; 

vector <vector <int> > g, b; 
vector <int> order, in, vis; 
queue <int> q; 

vector <int> dp; 

int main()
{
	n = read(); 
	m = read(); 
	
	b.resize(n); 
	g.resize(n); 
	in.resize(n); 
	vis.resize(n); 
	dp.resize(n); 
	
	REP(i, m)
	{
		int x = read() - 1, y = read() - 1; 
		g[x].pb(y); 
		b[y].pb(x); 
		in[y]++; 
	}
	
	REP(i, n) if (!in[i]) vis[i] = true, q.push(i); 
	
	while (!q.empty())
	{
		int x = q.front(); 
		q.pop(); 
		order.pb(x); 
		vis[x] = false; 
		REP(y, g[x].size())
		{
			in[g[x][y]]--; 
			if (!in[g[x][y]] && !vis[g[x][y]])
			{
				vis[g[x][y]] = true; 
				q.push(g[x][y]); 
			}
		}
	}
	
	int ans = 0; 
	REP(i, n)
	{
		int x = order[i]; 
		dp[x] = -1; 
		REP(y, b[x].size()) dp[x] = max(dp[x], dp[b[x][y]]); 
		dp[x]++; 
		ans = max(dp[x], ans); 
	}
	
	printf("%d\n", ans); 
	
	return 0; 
}

Measured memory_bytes: 13056
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef vector<int>         vi;
const int mod = 1000000007;






int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,great=0;
    cin>>n;
    int no;
    set<string>s;
    for(int i =0;i < n;i++){
        cin>>no;

        if(no<=399){
            s.insert("gray");
        }
        else if (no<=799){
            s.insert("brown");
        }
        else if(no<=1199){
            s.insert("green");
        }
        else if (no<=1599){
            s.insert("cyan");

        }
        else if( no<=1999){
            s.insert("blue");

        }
        else if (no<=2399){
            s.insert("yellow");

        }
        else if (no<=2799){
            s.insert("orange");

        }
        else if( no<=3199){
            s.insert("red");
        }
        else{
            great++;
        }
        }

    if(s.size()!=0)
    cout<<s.size()<<" "<<s.size()+great<<endl;
    else{
         cout<<1<<" "<<s.size()+great<<endl;
    }
    }













































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

#define FOR(i,a,b)    for (int i=(a)  ;i<(b) ;i++)
#define RFOR(i,a,b)   for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)      for (int i=0    ;i<(n) ;i++)
#define RREP(i,n)     for (int i=(n)-1;i>=0  ;i--)
#define EACH(i,a,b)   for (int i=(a)  ;i<=(b);i++)
#define REACH(i,a,b)  for (int i=(b)  ;i>=(a);i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

using ll = long long;
using P = pair<int,int>;

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

  int N;
  vector<int> A(9);
  REP(i,9)
    cin >> A[i];

  cin >> N;
  vector<bool> hit(9,false);
  int b;
  REP(i,N) {
    cin >> b;
    auto it = find(ALL(A), b);
    auto n = distance(A.begin(), it);
    if (n != 9) hit[n] = true;
  }

  bool ans = hit[0] && hit[1] && hit[2]
    || hit[3] && hit[4] && hit[5]
    || hit[6] && hit[7] && hit[8]
    || hit[0] && hit[3] && hit[6]
    || hit[1] && hit[4] && hit[7]
    || hit[2] && hit[5] && hit[8]
    || hit[0] && hit[4] && hit[8]
    || hit[2] && hit[4] && hit[6];

  cout << (ans ? "Yes" : "No") << endl;

  return 0;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
const int N=1011;
int used[N],br[N],l[N];
vector<int>v[N],ans;
bool dfs(int x,int z)
{
	used[x]=1;
	bool l,l2=1;
	for(auto y:v[x])
	{
		br[y]++;
		if(used[y]==1 && br[y]>1)l2=0;
	}
	if(l2)
		for(auto y:v[x])
		{
			if(y==z && br[z]==1)
			{
				ans.push_back(x);
				return 1;
			}
			else if(br[y]==1 && used[y]==0)
			{
				l=dfs(y,z);
				if(l)
				{
					ans.push_back(x);
					return 1;
				}
			}
		}
	for(auto y:v[x])
		br[y]--;
	used[x]=2;
	return 0;
}
int main()
{
     ios_base::sync_with_stdio(0);
     cin.tie(0);
     int n,m,i,a,b;
     cin>>n>>m;
	 for(i=0;i<m;i++)
	 {
		 cin>>a>>b;
		 v[a].push_back(b);
	 }
	 bool l;
	 for(i=1;i<=n;i++)
	 {
		 memset(used,0,sizeof(used));
		 l=dfs(i,i);
		 if(l)break;
	 }
	 if(ans.size()==0)
	 {
		 cout<<"-1\n";
		 return 0;
	 }
	 cout<<ans.size()<<'\n';
	 for(auto x:ans)
		 cout<<x<<'\n';
}


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

int main (){
  int a , b ;
  cin >> a >> b ;
  if (a<b){
  cout << "a < b" << endl ;
  }
	else if(a>b){
	cout << "a > b" <<endl ;
	}
	
	else {
	cout << "a == b" << endl ;
	}
	return 0;
}

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

int main() {

  int N = 0;
  cin >> N;
  
  vector<int> A(N);
  vector<int> bukaninzu(N+1);
  for(int i = 1; i < N; i++){
    cin >> A.at(i);
    bukaninzu.at(A.at(i))++;
  }

  for(int i = 0; i < N; i++){
    cout << bukaninzu.at(i+1) << endl;
  }
}


Measured memory_bytes: 4844
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cmath>
#include <climits>

typedef long long ll;
using namespace std;

int main(){
	ll a, b;
	cin >> a >> b;
	cout << a*b << endl;
	return 0;
}


Measured memory_bytes: 3616
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T, class U>using vp = vector<pair<T, U>>;
template<class T>using vv = vector<vector<T>>; template<class T, class U>using vvp = vv<pair<T, U>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MAX = 1e5 + 5, MOD = 1e9 + 7;
constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
constexpr int dy[4] = { 0,1,0,-1 }, dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

ll f(ll b, ll n) {
    ll s = 0;
    while (n > 0) {
        s += n % b;
        n /= b;
    }
    return s;
}

ll N, S;

void solve() {
    if (S == N) {
        write(N + 1); return;
    }
    else if (N == 1) {
        write(-1); return;
    }

    ll s_max = f(N / 2 + 1, N);
    if (S > s_max) {
        write(-1); return;
    }

    ll b_sqrt = sqrt(N);
    for (ll b = 2; b <= b_sqrt; ++b) {
        if (f(b, N) == S) {
            write(b); return;
        }
    }

    for (ll i = N / b_sqrt; i > 1; --i) {
        ll b1 = N / i + 1;
        ll s1 = f(b1, N);
        if (s1 < S) continue;
        else if (s1 == S) {
            write(b1); return;
        }
        ll b2 = N / (i - 1);
        ll s2 = f(b2, N);
        if (s2 > S) continue;
        else if (s2 == S) {
            write(b2); return;
        }

        while (b2 - b1 > 1) {
            ll mid = (b2 + b1) / 2;
            if (f(mid, N) >= S) {
                b1 = mid;
            }
            else {
                b2 = mid;
            }
        }
        if (f(b1, N) == S) {
            write(b1); return;
        }
    }
    write(-1);
}

int main() {
    cin >> N >> S;
    //for (int b = 2; b < 5000; ++b) {
    //    cout << b << " " << N / b << " " << f(b, N) << "\n";
    //}
    solve();
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

const int MAX = 7368800;

int sieve[MAX];

int n, m;

int main () {
    for (int i = 0; i < MAX; ++i) {
        sieve[i] = -1;
    }
    for (int i = 2; i < MAX; ++i) {
        if(sieve[i] == -1) {
            sieve[i] = i;
            for(int k = i + i; k < MAX; k += i) {
                sieve[k] = i;
            }
        }
        for(int k = i + i; k < MAX; k += i) {
            sieve[k] = i;
        }
    }

    //for (int i = 0; i < MAX; ++i) {
    //    cout << sieve[i] << " ";
    //}
    //cout << endl;

    while (1) {
        cin >> m >> n;
        if (m * n == 0) break;
        int i;
        for (i = m; i < MAX && n > 0; ++i) {
            if (!(m <= sieve[i] && sieve[i] < i)) {
                n--;
            }
        }
        while (m <= sieve[i] && sieve[i] < i) i++;
        cout << i << endl;
    }
}

Measured memory_bytes: 31876
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    int k,a,b;
    cin >> k >> a >> b;
    for(int i=a;i<=b;i++){
        if(i%k == 0) {cout << "OK" << endl; return 0;}
    }

    cout << "NG" << endl;    
    return 0;
}

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

int main() {
    string S;
    cin >> S;

    reverse(S.begin(), S.end());
    int x = 1;
    vector< int > A(S.size());
    rep(i, S.size()) {
        A[i] = ((S[i] - '0') * x) % 2019;
        x = x * 10 % 2019;
    }

    vector< int > cs(S.size() + 1);
    cs[0] = 0;
    rep(i, S.size()) { cs[i + 1] += (cs[i] + A[i]) % 2019; }

    int ans = 0;
    vector< int > cnt(2019);
    for (auto s : cs) {
        ans += cnt[s];
        ++cnt[s];
    }
    cout << ans << endl;
}

Measured memory_bytes: 5136
#include <bits/stdc++.h>
/*cout<<setprecision(5)<<ret<<endl;で、数字部分を計5桁表示かつゼロ埋め無*/
/*cout<<fixed<<setprecision(5)<<ret<<endlで、小数部のみ5桁表示かつゼロ埋め有*/
using namespace std;

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
/* [Shift+Command+b]（コンパイル）ー＞[Ctrl+Shift+`]（ターミナル起動）ー＞[./a.out] */

//////////////////
//  A
int main(void){
    int a,b;cin>>a>>b;
    double c=(double)(a+b)/2.0;
    if(c==(a+b)/2) cout<<(int)c<<endl;
    else cout<<"IMPOSSIBLE"<<endl;

    return 0;
}
//////////////////
//  B
/*int main(void){

    return 0;
}*/
//////////////////
//  C 
/*int main(void){

    return 0;
}*/
//////////////////
//  D
/*int main(void){

    return 0;
}*/


Measured memory_bytes: 3628
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	slice := make([]int, n)

	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}

	length := 1
	up := 0
	down := 0

	for i := 1; i < len(slice); i++ {
		if slice[i-1] < slice[i] {
			up = 1
		} else if slice[i-1] > slice[i] {
			down = 1
		} else {
			// i++
			continue
		}

		if up == 1 && down == 1 {
			up = 0
			down = 0

			length++
		}

	}

	fmt.Println(length)

	// for i := 0; i < len(slice); i++ {
	// 	// tmp := slice[start:len(slice)]
	// 	// fmt.Println(slice)

	// 	for j := 1; j < len(slice)-1; j++ {
	// 		// fmt.Printf("i=%d, j=%d\n", i, j)
	// 		if j+1 < n && slice[i] <= slice[j] {
	// 			continue
	// 		}

	// 		if j+1 < n && slice[i] >= slice[j] {
	// 			length++
	// 			i += j
	// 			break
	// 		}

	// 		if j+1 < n && slice[i] > slice[j] && slice[j] > slice[j+1] {
	// 			continue
	// 		}

	// 		if j+1 < n && slice[i] < slice[j] && slice[j] > slice[j+1] {
	// 			length++
	// 			i += j
	// 			break
	// 		}

	// 		if j+1 < n && slice[i] == slice[j] && slice[j] == slice[j+1] {
	// 			continue
	// 		}

	// 	}
	// fmt.Println(length)

	// }

	// fmt.Println(length)

}


Measured memory_bytes: 3072
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  ll a,b,c;
  cin>>a>>b>>c;
  if(a%2==0||b%2==0||c%2==0)
  {
    cout << 0 << endl;
  }
  else
  {
    cout << min(min(a*b, b*c), c*a) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    cin >> n;

    vector <ll> A(n);
    for (int i = 0; i < n; i++) cin >> A[i];

    ll ans = 0LL;
    for (int i = 0; i < 60; i++) {
        ll count = 0;
        for (int j = 0; j < n; j++) {
            if (A[j] & (1LL << i)) {
                count++;
            }
        }

        ans = (ans + (1LL << i) % MOD * count % MOD * (n - count) % MOD) % MOD;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a!=b)
    {
        if(b!=c)
        {
            printf("%d\n",b);
        }
        else
        {
            printf("%d\n",a);
        }
    }
    else
    {
        printf("%d\n",c);
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define mod (ll)1000000007
#define N 105
#define W 100005
using namespace std;
ll dp[N][W];
ll n,w1;
ll val[N];
ll w[N];

ll rec(int pos, int remw)
{
	if(pos == 0 || remw == 0)
		return 0;

	if(dp[pos][remw] != -1)
		return dp[pos][remw];

	dp[pos][remw] = INT_MIN;

	if(remw < w[pos-1])
		dp[pos][remw] = rec(pos-1,remw);

	else
	{
		dp[pos][remw] = max(rec(pos-1,remw), rec(pos-1,remw-w[pos-1])+val[pos-1]);
	}

	return dp[pos][remw];

}

int main()
{
	// int t;
	// cin>>t;
	// while(t--){
	cin>>n>>w1;
	for(int i = 0; i < n; i++)
		cin>>w[i]>>val[i];

	// for(int i = 0; i < n; i++)
	// 	cin>>w[i];

	memset(dp,-1,sizeof(dp));

	cout<<rec(n,w1)<<"\n";



	return 0;
}

Measured memory_bytes: 82304
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pii pair<int,int>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define vi vector<ll>
#define all(x) x.begin(),x.end()
#define show(x) cerr<<#x<<" is: "<<x<<endl;
#define sout(x) cout<<#x<<" is: "<<x<<endl;
#define countBits(x) __builtin_popcount(x)
#define mt make_tuple
#define eb emplace_back
#define pob pop_back
#define star(x) cout<<"********** "<<x<<" **********"<<endl;
#define yes cout<<"YES"<<endl; return;
#define no cout<<"NO"<<endl; return;
#define flus fflush(stdin); fflush(stdout);
#define F first
#define S second
#define np next_permutation
#define prio priority_queue
#define greatPrio priority_queue <ll, vector<ll>, greater<ll>>
#define inf 1e9
#define mod 1000000007
#define N 200100

void solve(){
	ll ind;
	rep(i,0,5){
		ll temp;
		cin>>temp;
		if(temp==0)
			ind=i+1;
	}
	cout<<ind<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n\n";
}

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

using namespace std;
typedef long long ll;

#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)

const ll N = 123456;
const ll mod = 1e9 + 7;

ll power(ll a , ll b) {
    if(b == 0) return 1LL;
    ll d = power(a , b / 2);
    d *= d;
    d %= mod;

    if(b % 2 != 0) d *= a;

    d %= mod;

    return d;
}

ll inverse_mod(ll a) {
    return power(a , mod - 2);
}

ll f[N];

ll ncr(ll no , ll r) {
    if(r == 0) return 1LL;
    if(r > no) return 0LL;
    if(r == no) return 1LL;
    ll ans = f[no];
    ans *= inverse_mod(f[r]);
    ans %= mod;
    ans *= inverse_mod(f[no - r]);
    ans %= mod;
    return ans;
}

double a[N];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cout.precision(10);

    int n; cin >> n;

    rep(i , 1 , n) cin >> a[i];

    double sum= 0.0;

    rep(i , 1 , n) sum += 1.0 / a[i];

    cout << 1 / sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;

int main()
{ 
    fast;

   char ch;
   cin>>ch;
   ch++;
   cout<<ch;


    
  }

Measured memory_bytes: 256
#!/usr/bin/env python3
import itertools
MOD = 2  # type: int


def solve(N, M, k, s, p):
    count = 0
    bluteforce = list(itertools.product([0, 1], repeat = N))

    for b in range(len(bluteforce)):
        for i in range(M):
            temp = [bluteforce[b][x-1] for x in s[i]]
            if sum(temp) % 2 == p[i]:
                success = 1
                pass
            else:
                success = 0
                break
        if success == 1:
            count += 1
    print(count)

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    # Failed to predict input format
    N, M = map(int, input().split())
    k = []
    s = []
    for i in range(M):
        k_temp, s_temp = input().split(' ', 1)
        k.append(int(k_temp))
        s.append(list(map(int, s_temp.split())))
    p = list(map(int, input().split()))

    solve(N, M, k, s, p)
    pass


if __name__ == '__main__':
    main()


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

ll min(ll a, ll b, ll c){
    ll ret;
    ret = min(a, min(b, c));
    return ret;
}

int main(){
    int x, y, z, k; cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    for(int i = 0; i < x; i++) cin >> a[i];
    for(int i = 0; i < y; i++) cin >> b[i];
    for(int i = 0; i < z; i++) cin >> c[i];
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    sort(c.rbegin(), c.rend());
    vector<ll> ans;
    for(int i = 0; i < x; i++){
        for(int j = 0; j < y; j++){
            for(int l = 0; l < z; l++){
                if((i+1)*(j+1)*(l*1) <= k) ans.push_back(a[i] + b[j] + c[l]);
                else break;
            }
        }
    }
    sort(ans.rbegin(), ans.rend());
    for(int i = 0; i < k; i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 18796
#include <iostream>
using namespace std;
 
int main(){
	int64_t k;
	cin >> k;
	int n = 50;
	cout << n << endl;
	int64_t a[n];
	for(int i = 0; i < n; i++) a[i] = i + k / n;
	for(int i = 0; i < k % n; i++){
		a[i] += n;
		for(int j = 0; j < 50; j++) if(i != j) a[j]--;
	}
	for(int i = 0; i < 50; i++) cout << a[i] << ' ';
	return 0;
}

Measured memory_bytes: 256
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int N = 4e5 + 5;
const int mod = 998244353;

int fac[N], inv[N];

int power(int x, int y) {
    int res = 1;
    while(y) {
        if(y & 1) 
            res = res * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return res;
}

void pre() {
    fac[0] = inv[0] = 1;
    for(int i = 1; i < N; i++) {
        fac[i] = i * fac[i - 1] % mod;
        inv[i] = power(fac[i], mod - 2);
    }
}

int ncr(int n, int r) {
    if(r < 0 || r > n)
        return 0;
    return fac[n] * inv[r] % mod * inv[n - r] % mod;
}

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    pre();

    int T = 1; 
    // cin >> T; 
    while (T--) {
        int n, m, k;
        cin >> n >> m >> k;

        int ans = 0;
        for(int i = 0; i <= k; i++) {
            int curr = ncr(n - 1, i) * m % mod * power(m - 1, n - 1 - i) % mod;
            ans = (ans + curr) % mod; 
        }

        cout << ans << '\n';
        
    }
    
    return 0;
}



Measured memory_bytes: 9868
#include<iostream>
using namespace std;
int main(){
int H,R;
cin >> H >> R;
H=H+R;
if(H==0){
cout << 0 << endl;
}else if(H>0){
cout << 1 << endl;
}else if(0>H){
cout << "-1" << endl;
}
return(0);
}


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

int main() {
  int a,b,c,d,e,k,N,M;
  cin >>a>>b>>c>>d>>e>>k;
  M = e-a;
  N = min(M,k);
  
  if(N == M){
    cout << "Yay!" << endl;
  }
  else{
    cout << ":(" << endl;
  }
   
}

Measured memory_bytes: 764
#pragma GCC optimze("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
// inbuilt function in c++
// abs(-2)=2 , __gcd(2,3)=1 , swap(a,b) , 
//string/array s = "aba"; sort(s.begin(), s.end());  do {  cout << s << '\n';  } while(next_permutation(s.begin(), s.end()));  
//for all permutation of s.
#include <bits/stdc++.h>
#define int                 long long int
#define double              long double
#define get(a,n)            for(int i=0;i<n;i++){cin>>a[i];}
#define out(a,n)            for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<endl;
#define maxm(a)             int maxi=LLONG_MIN;int index;for(int i=0;i<n;i++){if(maxi<a[i]){maxi=a[i];index=i;}}
#define minm(a)             int mini=LLONG_MAX;int index;for(int i=0;i<n;i++){if(mini>a[i]){mini=a[i];index=i;}}
#define db(x)               cout<<x<<" "<<endl;
#define endl                "\n"
#define PI                  acos(-1)
#define half(a)             a%2?cout<<(a/2+1)<<endl:cout<<a/2<<endl;
#define array               int a[n];for(int i=0;i<n;i++){cin>>a[i];}
#define pb(a)                push_back(a)
#define all(a)              a.begin(),a.end()
using namespace std;
void show(int *a)
{
    int size = (*(&a + 1) - a)-1;
    for(int i=0;i<size;i++)
    {
            cout<<a[i]<<" ";
    }   
    cout<<endl;
}
int binary_search(int *a,int n,int e)
{
    int f,l,m;f=0;l=n-1;
    while(f<=l)
    {//returns index of that value.
        m=(f+l)/2;
        if(e==a[m])
            return(m);
        else if(e>a[m])
                f=m+1;
            else
                l=m-1;
    }
    return -1;
}
vector<int> pf;
void primefactors(int n)  
{  
    while (n % 2 == 0)  
    pf.push_back(2),n = n/2;  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        while (n % i == 0)  
        {  
            pf.push_back(i); 
            n = n/i;  
        }  
    }  
    if (n > 2)  
        pf.push_back(n);
        //dont forgot to clear pf vector. 
}  
vector<int> fac;
//vector<int,greater<int>>fac;
void factors(int n) 
{ 
    for (int i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            if (n/i == i) 
            fac.push_back(i);
            else
            fac.push_back(i),fac.push_back(n/i); 
        } 
    } 
    //dont forgot to clear fac vector.
} 
// priority_queue stores the values in descending order q.front() returns maximum element. ".size() works for priority_queue."
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(15);
    int t=1;
//    cin>>t;
    while(t--)
    {
      int x,n;
      cin>>x>>n;
      int p[n];map<int,int>mp;
      for(int i=0;i<n;i++)
      {
          cin>>p[i];mp[p[i]]=1;
      }int a,b;
      for(int i=x;i<=200;i++)
      {
          if(mp[i]==0){
          a=i;break;}
      }
      for(int i=x;i>=-100;i--)
      {
          if(mp[i]==0){
          b=i;break;}
      }
        if(abs(a-x)==abs(b-x))
        cout<<b<<endl;
        else if(abs(a-x)>abs(b-x))
        cout<<b<<endl;
        else
        cout<<a<<endl;
    }
   

  
}

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

#define fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair

using namespace std;

typedef long long ll;

const int inf = (int)1e9 + 7;
const int N = (int)1e5 + 7;

int n;
int a;
int u[N],cnt[N];
int mx;

 main () {
        cin >> n;

        for (int i = 1; i <= n; i ++) {
                cin >> a;
                u[a] ++;
        }

        for (int i = 1; i <= 1e5; i ++) {
               mx = max(mx,u[i + 1] + u[i - 1] + u[i]);
        }
        cout << mx << endl;
}


Measured memory_bytes: 640
#import math
#import bisect
#import numpy as np
import sys
input = sys.stdin.readline
MOD = 10**9 + 7
INF = float('INF')

def main():
    n = int(input())
    ans = 0

    for i in range(1, n+1, 2):
        cnt = 0
        for j in range(1, i+1, 2):
            if i % j == 0:
                cnt += 1
        if cnt == 8:
                ans += 1

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
n, t = map(int, input().split())

keiros = []
for i in range(n):
	keiros.append(list(map(int, input().split())))

mincost = 10000
flg = 0
for keiro in keiros:
	if keiro[0] < mincost and keiro[1] <= t:
		mincost = keiro[0]
		flg = 1

if flg == 0:
	print("TLE")
else:
	print(mincost)

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

void Main()
{
  ll N;
  cin >> N;
  ll sum = 0;
  rep(i,N+1) {
    if (i % 5 == 0 || i % 3 == 0);
    else sum += i;
  }
  cout << sum << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
#define MAX 100
main()
{
        int i, j, n, a[MAX][MAX] = {0};
        scanf("%d", &n);
        for (i = 0; i < n; i++) {
                int u, k, v;
                scanf("%d%d", &u, &k);
                for (j = 0; j < k; j++) {
                        scanf("%d", &v);
                        a[u - 1][v - 1] = 1;
                }
        }
        for (i = 0; i < n; i++) {
                for (j = 0; j < n - 1; j++) {
                        printf("%d ", a[i][j]);
                }
                printf("%d\n", a[i][j]);
        }
}


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

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

vector<vector<ll>> dp(1005, vector<ll>(20005, -1));

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

    int N;
    cin >> N;
    using T = tuple<int, int, int>;
    vector<T> table;
    for(int i = 0; i < N; ++i){
        int w, s, v;
        cin >> w >> s >> v;
        table.emplace_back(w, s, v);
    }
    sort(table.begin(), table.end(), [](const T& a, const T& b){
        return get<0>(a) + get<1>(a) < get<0>(b) + get<1>(b);
    });

    dp[0][0] = 0;
    for(int i = 0; i < N; ++i){
        int w, s, v;
        tie(w, s, v) = table[i];
        for(int j = 0; j <= 20000; ++j){
            if(dp[i][j] == -1)  continue;
            chmax(dp[i + 1][j], dp[i][j]);
            if(j + w > 20000)   continue;
            if(j <= s)  chmax(dp[i + 1][j + w], dp[i][j] + v);
        }
    }

    ll ans = 0;
    for(int i = 0; i <= 20000; ++i) chmax(ans, dp[N][i]);
    cout << ans << endl;
}

Measured memory_bytes: 164096
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<climits>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

int main(){
    int a;
    string s;
    cin>>a>>s;
    if(a>=3200) cout<<s<<endl;
    else cout<<"red"<<endl;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
template <class T> int size(const T &x) { return x.size(); }
const int INF = 2147483647;
#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); ++i)
#define iter(it,c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)

int cnt[4010][4010];
ll fac[100100],
   ifac[100100],
   inv[100100];

int main() {
    int mod = 1000000007;
    fac[0] = 1;
    ifac[0] = 1;
    inv[1] = 1;
    rep(i,2,100100) {
        inv[i] = (mod - (mod/i) * inv[mod % i] % mod) % mod;
    }
    rep(i,1,100100) {
        fac[i] = i * fac[i-1] % mod;
        ifac[i] = inv[i] * ifac[i-1] % mod;
    }

    int n;
    cin >> n;
    vii arr(n);
    ll sub = 0;
    rep(i,0,n) {
        cin >> arr[i].first >> arr[i].second;
        cnt[arr[i].first+2005][arr[i].second+2005]++;
        sub += fac[2*arr[i].first+2*arr[i].second] * ifac[2*arr[i].first] % mod * ifac[2*arr[i].second] % mod;
        if (sub >= mod) sub -= mod;
    }
    for (int i = 4008; i >= 0; i--) {
        for (int j = 4008; j >= 0; j--) {
            cnt[i][j] += cnt[i+1][j];
            if (cnt[i][j] >= mod) cnt[i][j] -= mod;
            cnt[i][j] += cnt[i][j+1];
            if (cnt[i][j] >= mod) cnt[i][j] -= mod;
        }
    }
    int ans = 0;
    rep(i,0,n) {
        ans += cnt[2005-arr[i].first][2005-arr[i].second];
        if (ans >= mod) ans -= mod;
    }
    ll div2 = (mod+1)/2;
    cout << (ans + mod - sub) % mod * div2 % mod << endl;
    return 0;
}



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

signed main(void)
{
	long long a, b, c, x;
	long long cnt;
	
	cnt = 0;
	cin >> a >> b >> c >> x;
		rep(i, a) rep(j, b) rep(k, c)
		{
			if (x == 500 * i + 100 * j + 50 * k)
				cnt++;
		}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  int x,y;
  cin>>x>>y;
  if((x==4||x==6||x==9||x==11)&&(y==4||y==6|y==9||y==11)){
    cout<<"Yes"<<endl;
  }else if((x==1||x==3||x==5||x==7||x==8||x==10||x==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


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

long long a[1 + MAXN];

int main(){
    FILE*fi,*fo;
    //fi = fopen("a.in","r");
    //fo = fopen("a.out","w");
    fi = stdin;
    fo = stdout;

    int n;
    long long sum = 0;
    fscanf(fi,"%d", &n);
    for(int i = 1; i <= n; i++){
        fscanf(fi,"%d", &a[i]);
        a[i] -= i;
        sum += a[i];
    }
    std::sort(a + 1, a + n + 1);
    long long min = sum - n * std::min(0LL, a[1]);
    for(int i = 1; i <= n; i++){
        sum -= 2 * a[i];
        long long coef = i - (n - i);
        min = std::min(min, sum + coef * a[i]);
    }
    fprintf(fo,"%lld", min);

    return 0;
}


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

int main(){
    bool ans=false;
    string s, p;
    cin >> s >> p;
    s+=s;
    for(int i=0; i<s.size()-p.size()+1; i++){
        if(s.substr(i,p.size()) == p){
            ans=true;
            break;
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3212
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define pb push_back
#define S second
#define F first
using namespace std;
ll n,mod;
ll p1[100009];
ll p2[100009];
ll dpDn[100009];
ll dpUp[100009];
vector < ll > v[100009];
void dfsDn(ll node,ll p){
    ll &ret = dpDn[node] = 1;
    for(int i=0;i<v[node].size();i++){
        ll u = v[node][i];
        if(u == p) continue;
        dfsDn(u,node);
        ll x = (dpDn[u]+1)%mod;
        ret = (ret*x)%mod;
    }
}
void dfsUp(ll node,ll p){
    ll ret = 1;
    for(int i=0;i<v[node].size();i++){
        ll u = v[node][i];
        ll x = (dpDn[u]+1)%mod;
        if(u != p){
            ret = (ret*x)%mod;
        }
        p1[i] = ret;
    }
    ret = 1;
    for(int i=v[node].size()-1;i>=0;i--){
        ll u = v[node][i];
        ll x = (dpDn[u]+1)%mod;
        if(u != p){
            ret = (ret*x)%mod;
        }
        p2[i] = ret;
    }
    for(int i=0;i<v[node].size();i++){
        ll u = v[node][i];
        if(u == p) continue;
        ll x = 1,y = 1;
        if(i-1 >= 0) x = p1[i-1];
        if(i+1 < v[node].size()) y = p2[i+1];
        ll curr = (x*y)%mod;
        ll tmp = (curr*dpUp[node])%mod;
        dpUp[u] = (tmp+1)%mod;
    }
    for(auto u:v[node]){
        if(u != p) dfsUp(u,node);
    }
}
int main(){
    fast,cin>>n>>mod;
    for(int i=0;i<n-1;i++){
        ll a,b;
        cin>>a>>b;
        a--;b--;
        v[a].pb(b);
        v[b].pb(a);
    }
    dpUp[0] = 1;
    dfsDn(0,0),dfsUp(0,0);
    for(int i=0;i<n;i++){
        cout<<(dpDn[i]*dpUp[i])%mod<<endl;
    }
}


Measured memory_bytes: 13056
import heapq

N, M = map(int, input().split())
AB = (list(map(int, input().split())) for _ in range(N))

AB = sorted(AB, key=lambda x: x[0])
hq = []
ind = 0
ans = 0
for lim in range(1, M + 1):
    for i in range(ind, N):
        if AB[i][0] == lim:
            AB[i][0], AB[i][1] = -AB[i][1], AB[i][0]
            heapq.heappush(hq, AB[i])
            ind += 1
        else:
            break
    if hq:
        ans += -heapq.heappop(hq)[0]

print(ans)


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

using namespace std;

typedef long long ll;

const int INF = (1<<29);
const int INFF = 0x7fffffff;
const ll LINF = (1ll<<60);
const ll LINFF = 0x7fffffffffffffff;
const long double PI = 3.14159265359;

#define _fi(n) for(int i = 0;i < n;i++)
#define _fj(n) for(int j = 0;j < n;j++)
#define _fk(n) for(int k = 0;k < n;k++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define prec(x) cout << fixed << setprecision(x)
#define sz(x) (int)x.size()
#define _log2(x) 31-__builtin_clz(x)

#define hash sodnf9843bsd
#define right iadjfof23n3okd
#define pqueue priority_queue
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define len length
#define endl '\n'

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll a, ll b){return uniform_int_distribution<ll>(a, b)(rng);}


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

    int n;cin>>n;
    vector<ll>v(n);
    _fi(n) cin>>v[i];

    ll ans = 0;
    for(int i = 1;i < n;i++){
        ans += max(0ll, v[i-1]-v[i]);
        v[i] = max(v[i], v[i-1]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4740
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

int main(){
    int n;
    scanf("%d",&n);
    if(n%2==0){
        printf("0.5000000000\n");
    }else{
        printf("%lf\n",(n/2+1)/(double)n);
    }
    return 0;
}


Measured memory_bytes: 256
"use strict";
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.trim().split(/ |\n/), cid = 0;

function main() {
    let X = +cin.shift();
    let s = 0;
    while (s <= 240) {
        for (let a = 0; a <= s; a++) {
            let b = s - a;
            let ma = -a;
            let mb = -b;
            if (a ** 5 - b ** 5 == X) {
                console.log(a, b);
                return;
            }
            if (a ** 5 - mb ** 5 == X) {
                console.log(a, mb);
                return;
            }
            if (ma ** 5 - b ** 5 == X) {
                console.log(ma, b);
                return;
            }
            if (ma ** 5 - mb ** 5 == X) {
                console.log(ma, mb);
                return;
            }
        }
        s++;
    }
}
main();


Measured memory_bytes: 32460
s = input()
cnt = 0
for i in range(len(s)):
  if s[i] == s[-(i + 1)]:
    cnt += 1
if cnt != len(s):
  ans = 'No'
else:
  t = s[:(len(s)-1)//2]
  l = s[(len(s)+1)//2:]
  cnt_t = 0
  cnt_l = 0
  for j in range(len(t)):
    if t[j] == t[-(j+1)]:
      cnt_t += 1
  for k in range(len(l)):
    if l[k] == l[-(k+1)]:
      cnt_l += 1
  if cnt_t == len(t) and cnt_l == len(l):
    ans = 'Yes'
  else:
    ans = 'No'
print(ans)
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int Q;
  cin >> Q;
  while (Q-- > 0) {
    int A, B;
    cin >> A >> B;

    if (A > B)
      swap(A, B);

    // now A<=B
    int ans = 2 * (A - 1);

    if (B - A <= 1) {
      cout << ans << endl;
      continue;
    }

    int C = sqrt(A * B);
    if (C * C == A * B)
      C--;

    ans += 2 * (C - A);
    if (C * (C + 1) < A * B)
      ans++;
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
ABab = []
for i in range(N):
    a, b = list(map(int, input().split()))
    ABab.append([a+b, a, -1*b])
ABab.sort(reverse = True)
ans = 0
for i in range(N):
    ans += ABab[i][i%2 + 1]
print(ans)

Measured memory_bytes: 25460
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
f = sorted(list(map(int, input().split())), reverse=True)

ok, ng = a[-1]*f[0], -1
while ok-ng > 1:
	x = (ok+ng)//2
	tmp = 0
	for i in range(n):
		tmp += max(0, a[i] - x//f[i])
	if tmp > k:
		ng = x
	else:
		ok = x
print(ok)

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

dp = [[0]*N for i in range(N)]

for i,a in enumerate(A) :
    dp[i][i] = a

for i in range(N-2, -1, -1) :
    for j in range(i+1, N) :
        left = A[i] - dp[i+1][j]
        right = A[j] - dp[i][j-1]
        dp[i][j] = max(left, right)

ans = dp[0][N-1]

print(ans)


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

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 1;
  while(true){
    if(ans == 100000){
      cout << -1 << endl;
      return 0;
    }
    int aa = ans * 0.08;
    int bb = ans * 0.1;
    if(aa == a && bb == b){
      cout << ans << endl;
      return 0;
    }else{
      ans++;
    }
  }
}

Measured memory_bytes: 256
void main() {
	auto N = ri;
	auto S = rs;
	int c, res;
	foreach(i; S) {
		if(i == 'I') c++;
		else c--;
		res = max(res, c);
	}
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
def resolve():
    N = int(input())
    S = input()
    answer = encrypt_ceasor(S, N)
    print(answer)

      
def encrypt_ceasor(text, n):
    result = ""
    for i in range(len(text)):
        char = text[i]
        if char.isupper():
            result += chr((ord(char) + n - 65) % 26 + 65)
        else:
            result += chr((ord(char) + n - 97) % 26 + 97)
    return result


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 3060
"use strict";
const main = arg => {
  let count = 0;
  for(let i = 1; i <= arg; i++){
  	if(String(i).length % 2 == 1){
      count++;
    }
  }
  console.log(count);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 11084
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<long long> in(n);
  vector<long long> best(n + 1), sum(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> in[i];
    best[i + 1] += best[i] + max(in[i], 0LL);
    sum[i + 1] = sum[i] + in[i];
  }
  long long ans = -(1LL << 60);
  for (int i = 1; i + k - 1 <= n; i++) {
    ans = max(ans, best[i - 1] + best[n] - best[i + k - 1] + max(0LL, sum[i + k - 1] - sum[i - 1]));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
int main(void){
	int a,b,c,n,x,Count=0,count2=0,i,point[100],j,allcount=0;
	
	while(1){
		scanf("%d %d",&n,&x);
		i=0;
		for(a=i;a<=n;a++){
			for(b=a;b<=n;b++){
				for(c=b;c<=n;c++){
					if(a+b+c==x && a!=b && a!=c && b!=c &&a!=0 &&b!=0 &&c!=0){
						count2++;
						//printf("%d+%d+%d=%d\n",a,b,c,a+b+c);
						
					}
				}
			}
		}
		if(n!=0 || x!=0){
			printf("%d\n",count2);
		}
		if(n==0 && x==0){
			break;
		}
		count2=0;
	}
	/*for(i=0;i<=Count;i++){
		for(a[i]=i;a[i]<=n[i];a[i]++){
			for(b[i]=a[i];b[i]<=n[i];b[i]++){
				for(c[i]=b[i];c[i]<=n[i];c[i]++){
					if(a[i]+b[i]+c[i]==x[i] && a[i]!=b[i] && a[i]!=c[i] && b[i]!=c[i] &&a[i]!=0 &&b[i]!=0 &&c[i]!=0){
						count2[i]++;
						printf("%d %d+%d+%d=%d\n",i,a[i],b[i],c[i],a[i]+b[i]+c[i]);
					}
				}
			}
		}
		printf("%d??±???\n",i);
	}
	for(i=0;i<Count;i++){
		printf("%d %d\n",i,count2[i]);
	}*/
	return 0;
}

Measured memory_bytes: 600