akhauriyash/Code-Regression huggingface dataset:
/*****************************************************
 				*	Logged in : HABIBUR RAHMAN						 *
				*	Dept	  : COMPUTER SCIENCE AND ENGINEERING	 *
				*													 *
				*	KHULNA UNIVERSITY OF ENGINEERING AND TECHNOLOGY  *
				******************************************************/


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<string> vs;
typedef pair<ll,ll> pll;
#define fast_io 			ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) 				v.begin(),v.end()
#define allr(v) 			v.rbegin(),v.rend()
#define rep(i,a,b) 			for(ll i=a;i<=b;i++)
#define rep0(i,n)			for(ll i=0;i<n;i++)
#define rrep0(i, n) 		for(ll i=(ll)(n);i>0;--i)
#define rrep(i, a, b) 		for(ll i=(ll)(a);i>=(ll)(b);--i)
#define pb(z) 				emplace_back(z)
#define ff					first
#define ss 					second
#define caset 				int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define sz(X) 				((ll)(X).size())
#define scan(X) 			scanf("%s", (X))
#define ms(v,val)			memset((v),(val),sizeof((v)))
#define ms0(X) 				memset((X), 0, sizeof((X)))
#define ms1(X) 				memset((X), -1, sizeof((X)))
#define m_p(a,b)            make_pair(a,b)
#define get_pos(c,x) 		(lower_bound(c.begin(),c.end(),x)-c.begin())
#define lcm(a,b)            (a*b)/__gcd(a,b)
#define INF9                1000000010
#define INF18               4000000000000000010
#define bpll(a)             __builtin_popcountll(a)
#define sqr(a)              ((a)*(a))
#define nl					"\n"
//#define mod					1e9+7;
#define mx_el(v)			*max_element(all(v));
#define mn_el(v)			*min_element(all(v));
#define pcase(z,x)    		cout<<"Case "<<z<<": "<<x<<"\n"
const double pi = 2*acos(0) ;
#define display(v)			vi :: iterator it;for(it=(v).begin();it!=(v).end();it++){cout << *it << " " ;}cout << endl;
#define taking(n,v) 		for(ll i=0;i<(n);i++){ll inp;cin>>inp;(v).push_back(inp);}
/*-------------------------some important functions--------------------------------------------------------------------*/
ull binpow(ull b,ull n){if(n==0)return 1;if(n==1)return b;if(n&1) return binpow(b,n-1)*b;else return binpow(b*b,n/2);}
ll bigmod(ll a,ll n,ll mod){if(n==0)return 1;ll res=bigmod(a,n/2,mod);if(n&1){return ((res%mod)*(res%mod)*a)%mod;}else return ((res%mod)*(res%mod))%mod;}
/*--------------------------------------------x----------------------------------------------x--------------------------*/
void start(){
      #ifndef ONLINE_JUDGE 
      freopen("input.txt" , "r" , stdin) ;
      freopen("output.txt" , "w" , stdout) ;
      #endif
}
void solve(){
	ll n;cin>>n;
	ll a[n+1];
	rep0(i,n){
		cin>>a[i];
	}
	ll cnt=a[0];
	rep(i,1,n-1){
		cnt=__gcd(a[i],cnt);
	}
	cout << cnt << nl;
}
 	 
int main() {
	fast_io
	//start();
    //caset{
    	//cout << "Case " << tt << ": ";
		  solve();
	//}
	
	return 0;
}

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

int main() {
    int h, w; cin >> h >> w;
    vector <string> v(h);
    for (int i=0; i < h;i++) cin >> v.at(i);

    for (int i =0;i < w+2; i++) cout << '#';
    cout << endl;

    for (int i=0; i< h; i++) {
        cout << '#' << v.at(i) << '#' << endl;
    }

    for (int i =0;i < w+2; i++) cout << '#';
    cout << endl;
}

Measured memory_bytes: 3596
const main = (input: void) => {
  const D: number = parseInt(input.split(' ')[0],10);
  const N: number = parseInt(input.split(' ')[1],10);
  let ans: number;

  if (D === 0){
    ans = N * 1;
  } else if (D === 1) {
    ans = N * 100;
  } else if (D === 2) {
    ans = N * 10000;
  }
  if (N === 100) {
    ans = ans/N;
    ans = ans * (N+1);
  }
  console.log(ans);
}

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

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

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

    int x;
    cin >> x;
    int max_root = pow(x, 0.5);
    int res = 1;
    for (int i = 2; i <= max_root; ++i) {
        int cnt = 0;
        int x_copy = x;
        while(x_copy >= i) {
            cnt += 1;
            x_copy /= i;
        }
        res = max(res, static_cast<int>(pow(i, cnt)));
    }

    cout << res << '\n';

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;



int main() {
	int a, b, ab;
	cin >> a >> b >> ab;
	int x, y;
	cin >> x >> y;

	ab *= 2;
	
	
	int money = a * x + b * y;

	int z = min(x, y);
	if (money > ab*z + a*(x - z) + b*(y - z)) {
		money = ab * z + a * (x - z) + b * (y - z);
	}

	if (money > ab*max(x, y)) {
		money = ab * max(x, y);
	}
	cout << money << endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int S[111];

signed main(){
    cin>>N;
    rep(i,N)cin>>S[i];

    bool flag=false;
    rep(i,N)if(S[i]%10)flag=true;
    if(!flag){
        cout<<0<<endl;
        return 0;
    }

    int ans=accumulate(S,S+N,0ll);
    int mi=INT_MAX;
    rep(i,N)if(S[i]%10)chmin(mi,S[i]);
    if(ans%10==0)ans-=mi;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.14159265358979323

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;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> s(m);
    rep(i,m){
        int k;
        cin >> k;
        rep(j,k) {
            int S;
            cin >> S;
            S--;
            s[i].push_back(S);
        }
    }
    vector<int> p(m);
    rep(i, m) cin >> p[i];
    int count = 0;
    for (int bit = 0; bit < (1 << n); bit++){
        bool flag = true;
        rep(j,m){
            int cnt = 0;
            for (const auto& v : s[j]){
                if (bit & (1 << v))
                    cnt++;
            }
            if  (cnt % 2 != p[j])
                flag = false;
        }
        if (flag)
            count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

char a, b;

int main()
{
	cin >> a >> b;
	if (a == 'H' && b == 'H') cout << "H" << endl;
	if (a == 'D' && b == 'H') cout << "D" << endl;
	if (a == 'H' && b == 'D') cout << "D" << endl;
	if (a == 'D' && b == 'D') cout << "H" << endl;

	return 0;
}


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

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

int main() {
    int n, cnt = 0;
    cin >> n;
    double x[n], y[n], ans = 0;
    vector<int> a(n);

    rep(i, n) {
        cin >> x[i];
        cin >> y[i];
    }
    rep(i, n) { a[i] = i; }

    do {
        for (int i = 1; i < n; ++i) {
            int j = a[i];
            int k = a[i - 1];
            ans += sqrt(pow(x[j] - x[k], 2) + pow(y[j] - y[k], 2));
        }
        cnt++;
    } while (next_permutation(a.begin(), a.end()));

    cout << fixed << setprecision(10) << ans / (double)cnt << endl;
    return 0;
}

Measured memory_bytes: 3796
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int N, X, L; cin >> N >> X;
  int pos = 0, cnt = 1;
  REP(i, N){
    cin >> L;
    pos += L;
    if(pos <= X) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;

typedef long double ld;
typedef complex<ld> P;
typedef vector<P> VP;
const ld eps = 1e-8, pi = acos(-1.0);

#define EQ(a,b) (abs((a)-(b))<eps)

ld dot (P a, P b) { return real(conj(a) * b); }
ld cross (P a, P b) { return imag(conj(a) * b); }

namespace std {
  bool operator<(const P &lhs, const P &rhs) {
    return lhs.real() == rhs.real() ? lhs.imag() < rhs.imag()
                                    : lhs.real() < rhs.real();
  }
}

struct L{ P a, b; };
struct C { P p; ld r; };

// counter clockwise
int ccw (P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > eps) return 1;   // counter clockwise
  if (cross(b, c) < -eps) return -1; // clockwise
  if (dot(b, c) < 0) return 2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line
  return 0;                          // a--c--b on line
}

bool isis_ss(L s, L t) {
  return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 &&
         ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}

bool isis_sp(L s, P p) {
  return abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps;
}

P proj(L l, P p) {
  ld t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
  return l.a + t * (l.a - l.b);
}

ld dist_sp(L s, P p) {
  P r = proj(s, p);
  if (isis_sp(s, r)) return abs(r - p);
  return min(abs(s.a - p), abs(s.b - p));
}

P is_ll(L s, L t){
  P sv = s.b - s.a, tv = t.b - t.a;
  return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}

bool crs(L s, L t) {
  return isis_ss(s, t) && dist_sp(s, t.a) > eps && dist_sp(s, t.b) > eps && dist_sp(t, s.a) > eps && dist_sp(t, s.b) > eps;
}

int main() {
  int n,m;
  cin>>n>>m;
  vector<VP> polys;
  REP(i,n) {
    int l;
    cin>>l;
    VP vp;
    REP(j,l) {
      int x,y;
      cin>>x>>y;
      vp.emplace_back(x,y);
    }
    polys.push_back(vp);
  }
  VP r;
  REP(i,m) {
    int x,y;
    cin>>x>>y;
    r.emplace_back(x,y);
  }
  vector<L> vl;
  REP(i,n)REP(j,polys[i].size())REP(k,m) {
    vl.push_back({polys[i][j], r[k]});
  }
  int l=vl.size();
  VP cand;
  REP(i,l)REP(j,i) {
    cand.push_back(is_ll(vl[i], vl[j]));
  }
  int res = 0;
  for(auto p : cand) {
    int cnt = 0;
    REP(i,m) {
      L s={p,r[i]};
      bool ok = true;
      for(auto poly : polys) {
        int v = poly.size();
        REP(j,v) {
          L e={poly[j],poly[(j+1)%v]};
          if (crs(s,e)) ok = false;
        }
      }
      if (ok) ++cnt;
    }
    res = max(res, cnt);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3428
def resolve():
    '''
    code here
    '''
    import math
    a, b, x = [int(item) for item in input().split()]

    s = x/a

    s_delta = a*b - s
    if s_delta <= a*b/2:
        print(math.degrees(math.atan((2* s_delta)/a**2)))
    else:
        print(math.degrees(math.atan(b**2/(2*s))))

if __name__ == "__main__":
    resolve()


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

int n;
int m[110];
int p[110][110];
int k;
int l[110];
bool date[110][110];
int main(){
  while(1){
    for(int i=0;i<110;i++)
      for(int j=0;j<110;j++)
	date[i][j]=0;
    cin>>n;
    if(n==0)break;
    for(int i=1;i<=n;i++){
      cin>>m[i];
      for(int j=1;j<=m[i];j++){
	cin>>p[i][j];
	date[i][p[i][j]]=1;
      }
    }
    cin>>k;
    for(int i=1;i<=k;i++){
      cin>>l[i];
    }
    int ans=0;
    int crimer;
    for(int i=1;i<=n;i++){
      int flag=1;
      for(int j=1;j<=k;j++){
	if(date[i][l[j]]==0){
	  flag=0;
	  break;
	}
      }
      if(flag){
	ans++;
	crimer=i;
      }
    }
    if(ans==1){
      cout<<crimer<<endl;
    }else{
      cout<<-1<<endl;
    }
  }
  return 0;
}
    



Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
int main(){
    vector<vector<int>> A(3, vector<int>(3));
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> A.at(i).at(j);
        }
    }
    vector<int> a(3), b(3);
    a.at(0) = 0;
    b.at(0) = A.at(0).at(0);
    b.at(1) = A.at(0).at(1);
    b.at(2) = A.at(0).at(2);
    a.at(1) = A.at(1).at(0) - b.at(0);
    a.at(2) = A.at(2).at(0) - b.at(0);
    bool ans = true;
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            if(A.at(i).at(j) != a.at(i) + b.at(j)){
                ans = false;
            }
        }
    }
    if(ans){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>

#define loop(i, num) for (int i = 0; i < num; i++)

using namespace std;

int a, b, c, d;

int main() {
    
    cin >> a >> b >> c >> d;
    
    int start = max(a, c), end = min(b, d);
    
    cout << (end - start < 0 ? 0 : end - start) << endl;
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define N 1000
int Sosuu(int);
int main(){
  int i,n,so,count=0,b;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&b);
    so = Sosuu(b);
    if(so==1) count++;
  }
  printf("%d\n",count);
  return 0;
}
int Sosuu(int b){
  int i;
  if(b==2)return 1;

  if(b<2||b%2==0)return 0;

  i=3;
  while(i <=sqrt(b)){
    if(b%i==0)return 0;
    i=i+2;
  }
  return 1;
}



Measured memory_bytes: 2104
N=int(input())
B=list(map(int,input().split(' ')))
able=True
ans=[]
if [1 if B[i]<=(i+1) else 0 for i in range(N)].count(0)!=0:
	able=False
	print('-1')
if able:
	while True:
		if len(B)==0:
			break
		else:
			goodposition=0
			for i in range(len(B)):
				if B[i]==(i+1):
					goodposition=i
			ans.append(str(B.pop(goodposition)))
	for a in ans[::-1]:
		print(a)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define ll long long
#define ALL(x) x.begin(),x.end()
using namespace std;

int main(){
ll N,M;
cin>>N>>M;
vector<pair<ll,ll>> w(N);
ll tmp,tmp1;
ll ans =0;
for(ll i=0;i<N;i++){
cin>>tmp>>tmp1;
w[i]=make_pair(tmp,tmp1);
}
sort(ALL(w));
priority_queue<ll> nums;
ll p =0;
for(ll i=0;i<M;i++){
for(ll j=p;j<N;j++){
if(w[j].first<=i+1){
nums.push(w[j].second);
if(j==N-1)
p=N;
}
else{
p=j;
break;
}
}
if(!(nums.empty())){
ans += nums.top();
nums.pop();
}
}





cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 2936
#include <stdio.h>
int main(void){
    // Your code here!
    int n, k, i, j, v;
    scanf("%d", &n);
    int A[n];
    for(k=0; k<=n-1; k++){
        scanf("%d", &A[k]);
        printf("%d", A[k]);
        if(k!=n-1) printf(" ");
    }
    printf("\n");
    
    for(i=1; i<=n-1; i++){
        v=A[i];
        j=i-1;
        while(j>=0 && A[j]>v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
        for(k=0; k<=n-1; k++){
            printf("%d", A[k]);
            if(k!=n-1)
                printf(" ");
        }
        printf("\n");
    }
}



Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int h,n,i,sum =0;
	cin>>h>>n;
	int a[n];
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<n;i++)
	{
		sum=a[i]+sum;
	}

	if(sum>=h)
	{
		cout<<"Yes";
	}
	else{
		cout<<"No";}
}


Measured memory_bytes: 640
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	PrintWriter out = new PrintWriter(System.out);
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok = new StringTokenizer("");
    String next() throws IOException {
        if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); }
        return tok.nextToken();
    }
    int ni() throws IOException { return Integer.parseInt(next()); }
    long nl() throws IOException { return Long.parseLong(next()); }
  
    void solve() throws IOException {
        String s=next();
        int ans=0;
        if (s.equals("SAT")) ans=1;
        if (s.equals("FRI")) ans=2;
        if (s.equals("THU")) ans=3;
        if (s.equals("WED")) ans=4;
        if (s.equals("TUE")) ans=5;
        if (s.equals("MON")) ans=6;
        if (s.equals("SUN")) ans=7;
        System.out.println(ans);
    }
    
    public static void main(String[] args) throws IOException {
        new Main().solve();
    }
}

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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

// constexpr int INF = 1e9;
constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

class xorShift{
    uint32_t x, y, z, w;
    static const double TO_DOUBLE;
public:
    xorShift(){
        x = 123456789;
        y = 362436069;
        z = 521288629;
        w = 88675123; 
    }
    xorShift(uint32_t seed){
        x = seed = 1812433253u * (seed ^ (seed >> 30));
        y = seed = 1812433253u * (seed ^ (seed >> 30)) + 1;
        z = seed = 1812433253u * (seed ^ (seed >> 30)) + 2;
        w = seed = 1812433253u * (seed ^ (seed >> 30)) + 3;
    }
    uint32_t nextInt(uint32_t n){
        uint32_t t = x ^ (x << 11);
        x = y; y = z; z = w;
        w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
        return w % n;
    }
    uint32_t nextInt(){
        uint32_t t = x ^ (x << 11);
        x = y; y = z; z = w;
        return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
    }
    double nextDouble(){
        return nextInt() * TO_DOUBLE;
    }
};
const double xorShift::TO_DOUBLE = 1.0 / (1LL << 32);

class Timer{
    chrono::time_point<chrono::system_clock>start;
public:
    Timer(){
        start = chrono::system_clock::now();
    }
    double duration(){
        return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now()- start).count();
        //return chrono::duration<chrono::milliseconds>(chrono::system_clock::now()- start).count();
    }
};

Timer T;
xorShift rnd;
constexpr double TIME_LIMIT = 1900;

int D = 365;
vector<int> c(26);
vector<vector<int>> s(D, vector<int>(26));
int main(){
  cin >> D;
  REP(i, 26){
      cin >> c[i];
  }
  REP(i, D){
      REP(j, 26){
          cin >> s[i][j];
      }
  }
  REP(i, D){
      cout << rnd.nextInt() % 26 + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 3680
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        if(a*b>c*d){
            System.out.println((a*b));
        }else{
            System.out.println((c*d));
        }
        System.out.println();
        sc.close();
    }
}

Measured memory_bytes: 22740
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ull unsigned long long 
#define int long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define MAX 1e18
#define PI 3.14159265
const int mod = 1e9 + 7;
#define ordered_set tree<pair<int, int>, null_type,less<pair<int, int>>, rb_tree_tag,tree_order_statistics_node_update>
 
 
 
int power(int x, int y) 
{ 
   int res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  
 
        y = y>>1; 
 
        if (x<=100000000)
        x = (long long)(x*x);
 
        //cout<<x<<'\n'; 
    } 
    return res; 
} 
 
int gcd (int a, int b) {
    if (b == 0)
        return a;
    else
        return gcd (b, a % b);
}

int ceiling(int a,int b){
  if(a%b!=0){
    return (a/b)+1;

  }
  else
    return (a/b);
}
 

 void solve()
 {
  int n;
  cin>>n;
  vector<int>v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());

  int count=0;
  int ans=0;

  ans+=v[0];
  count++;

  for(int i=1;i<n;i++){
    if(count>=n-1)
      break;
    ans+=v[i];
    count++;
    if(count>=n-1)
      break;
    ans+=v[i];
    count++;
  }

  cout<<ans<<endl;

  return;
 }


 int32_t main()
 {
  int t;
  t=1;
  while(t--){
    solve();
  }
  return 0;
 }


Measured memory_bytes: 4860
#include<bits/stdc++.h>
using namespace std;
#define FOR(a,b,n) for(int a=b;a<=b;a++)
#define sc(a) scanf("%d",&a)
#define scc(a,b) scanf("d",&a,&b)
#define sccc(a,b,c) scanf("d%d",&a,&b,&c)
#define sccs(s) scanf("%s",s)
#define pccs(s) printf("%s",s)
#define debug printf("---debug---");
#define pcc(a,b) printf("d",a,b)
#define pccc(a,b,c) printf("d%d",a,b,c)
#define pb push_back
typedef long long ll;
const int MAXN_1e5=1e5+5;
const int MAXN_2e5=2e5+5;
const int MAXN_3e5=3e5+5;
const int MAXN_4e5=4e5+5;
const int MAXN_5e5=5e5+5;
const int INF_INT=0x3f3f3f3f;
const long long INT_LL=2e18;
struct node
{
    ll val;
    int id;
    bool operator < (const node &b)const
    {
        return val<b.val;
    }
}arr[MAXN_1e5];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i].val;
        arr[i].id=i+1;
    }
    sort(arr,arr+n);
    for(int i=0;i<n;i++)
    {
        cout<<arr[i].id<<" ";
    }
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int data[n];
    for (int i = 0; i < n; i++){
        int a;
        cin >> a;
        data[i] = a;
    }
    for (int j = n-1; j >= 0; j -= 1){
        if (j == 0){
            cout << data[j] <<endl;
        } else  {
            cout << data[j] << " "; 
        }
    }
    return 0;
}


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

int n;
int p[1000];
int cnt;
double total;
double x[1000], y[1000];
double poww(double a) {
	return a * a;
}

int main() {
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		p[i] = i;
	}
	do{
		for(int i = 1; i < n; i++) {
			total += sqrt(poww(x[p[i]] - x[p[i - 1]]) + poww(y[p[i]] - y[p[i - 1]]));
		}
		cnt++;
	}while(next_permutation(p, p + n));
	printf("%.10f", total / cnt);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
        string a,b;
        int i,t;
        t=0;
        cin >> a >> b;
        for (i=0;i<3;i++){
                if (a[i]==b[i]){
                        t = t + 1;
                }
        }                
        cout << t;
}


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

int main(){
    Int N;
    cin >> N;

    vector<string> S(N);

    rep(i,N) cin >> S[i];

    vector<Int> a(N, 0), b(N, 0);

    rep(i,N) {
        rep(j,S[i].size()) {
            if (S[i].at(j) == '(') a[i]++;
            else a[i]--;
            if (j == 0) b[i] = a[i];
            else b[i] = min(b[i], a[i]);
        }
    }

    
    vector<pair<Int,Int>> P1, P2;
    rep(i,N) {
        if (a[i] >= 0) {
            P1.push_back(make_pair(b[i],i));
        }
        else {
            P2.push_back(make_pair(a[i]-b[i],i));
        }
    }

    sort(P1.begin(),P1.end());
    reverse(P1.begin(),P1.end());
    sort(P2.begin(),P2.end());
    reverse(P2.begin(),P2.end());

    Int cnt = 0;
    rep(i,P1.size()) {
        if (cnt + b[P1[i].second] < 0) {
            cout << "No" << endl;
            return 0;
        }
        else {
            cnt += a[P1[i].second];
        }
            
    }
    rep(i,P2.size()) {
        if (cnt + b[P2[i].second] < 0) {
            cout << "No" << endl;
            return 0;
        }
        else {
            cnt += a[P2[i].second];
        }
    }
    if (cnt != 0) {
        cout << "No" << endl;
        return 0;
    }
    else {
        cout << "Yes" << endl;
        return 0;
    }

}

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

main() {
    int A,B; cin >> A >> B;
    int sum=0;
    rep(i,B-A){
        sum+=i+1;
    }
    cout << sum-B << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}
int main(){
  int c,d,n;
  cin>>c>>d>>n;
  int a[1001],b[1001];
  lp(i,1001){
    a[i]=0;
    b[i]=0;
  }
  lp(i,n){
    int x,y;
    cin>>x>>y;
    b[x]=1;
    b[y]=2;
    a[x]+=1;
    a[y]-=1;
  }
  for(int i=1;i<=1000;i++){
    a[i]+=a[i-1];
  }
  int check=0;
  for(int i=c;i<=d;i++){
    if(i==c){
      if(a[i]!=0 && b[i]!=2){
	check=1;
	break;
      }
    }
    else if(i==d){
      if(a[i]!=0 && b[i]!=1){
	check=1;
	break;
      }
    }
    else if(a[i]!=0){
      check=1;
      break;
    }
  }
  cout<<check<<endl;
    
  return 0;
  
}



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

int main()
{
  int h, w;
  cin >> h >> w;
  vector<vector<char>> s(h, vector<char>(w));
  int i, j;
  for(i = 0; i < h; i++)
  {
    for(j = 0; j < w; j++)
    {
      cin >> s.at(i).at(j);
    }
  }
  vector<vector<int>> l(h, vector<int>(w));
  vector<vector<int>> r(h, vector<int>(w));
  vector<vector<int>> u(h, vector<int>(w));
  vector<vector<int>> d(h, vector<int>(w));
  for(i = 0; i < h; i++)
  {
    for(j = 0; j < w; j++)
    {
      if(s.at(i).at(j) == '#')
      {
        l.at(i).at(j) = 0;
      }
      else if(j == 0)
      {
        l.at(i).at(j) = 1;
      }
      else
      {
        l.at(i).at(j) = l.at(i).at(j-1) + 1;
      }
    }
  }
  for(i = 0; i < h; i++)
  {
    for(j = w-1; j >= 0; j--)
    {
      if(s.at(i).at(j) == '#')
      {
        r.at(i).at(j) = 0;
      }
      else if(j == w-1)
      {
        r.at(i).at(j) = 1;
      }
      else
      {
        r.at(i).at(j) = r.at(i).at(j+1) + 1;
      }
    }
  }
  for(j = 0; j < w; j++)
  {
    for(i = 0; i < h; i++)
    {
      if(s.at(i).at(j) == '#')
      {
        u.at(i).at(j) = 0;
      }
      else if(i == 0)
      {
        u.at(i).at(j) = 1;
      }
      else
      {
        u.at(i).at(j) = u.at(i-1).at(j) + 1;
      }
    }
  }
  for(j = 0; j < w; j++)
  {
    for(i = h-1; i >= 0; i--)
    {
      if(s.at(i).at(j) == '#')
      {
        d.at(i).at(j) = 0;
      }
      else if(i == h-1)
      {
        d.at(i).at(j) = 1;
      }
      else
      {
        d.at(i).at(j) = d.at(i+1).at(j) + 1;
      }
    }
  }
  int max = 0;
  int light;
  for(i = 0; i < h; i++)
  {
    for(j = 0; j < w; j++)
    {
      light = l.at(i).at(j)+r.at(i).at(j)+u.at(i).at(j)+d.at(i).at(j)-3;
      if(light > max) max = light;
    }
  }
  cout << max << endl;
}

Measured memory_bytes: 67072
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int a = input[0];
        int b = input[1];
        if (a < b)
            Console.WriteLine("a < b");
        else if (a > b)
            Console.WriteLine("a > b");
        else
            Console.WriteLine("a == b");
    }
}

Measured memory_bytes: 9324
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
#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 pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	string S;
	cin >> S;
	ll n = S.size();
	ll ans = n * (n - 1LL) / 2LL + 1;
	map<char, int>mp;
	for (int i = 0; i < n; i++)mp[S[i]]++;
	for (int i = 0; i < n; i++) {
		mp[S[i]]--;
		ans -= mp[S[i]];
	}

	puts(ans);

	return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
typedef long long int ll;

using namespace std;

int main()
{
    ll n,maxx=0,maxx2=0,max_prev=-1,max2_prev=-1,max_now,max2_now,temp,flag=-1;
    ll arr[4];
    cin>>n;

    vector <ll> DP(3,0);

    for(int i=0;i<n;i++)
    {
        vector <ll> NEW_DP(3,0);
        cin>>arr[0]>>arr[1]>>arr[2];

        for(int j=0;j<3;j++)
        {
            for(int k=0;k<3;k++)
            {
                if(j!=k)
                    NEW_DP[k] = max(NEW_DP[k], DP[j]+arr[k]);
            }
        }
        DP = NEW_DP;
    }
    cout<<max({DP[0],DP[1],DP[2]});
    return 0;
}

Measured memory_bytes: 256
let print_array a =
  Array.iteri (fun i n -> Printf.printf (if i = 0 then "%d" else " %d") n) a;
  print_newline ()

let insertion_sort a n =
  print_array a;
  let rec insert j v =
    if j < 0 || a.(j) <= v then a.(j + 1) <- v
    else (a.(j + 1) <- a.(j); insert (j - 1) v)
  in
  let rec doit i =
    if i >= n then ()
    else (insert (i - 1) a.(i); print_array a; doit (i + 1))
  in
  doit 1

let () =
  let n = read_int () in
  let a = Array.of_list (List.map int_of_string (Str.split (Str.regexp " ") (read_line ()))) in
  insertion_sort a n

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

int main()
{
    int n;
    cin >> n;
    int l = 0, r = n;
    string left, right;
    cout << 0 << endl;
    fflush(stdout);
    cin >> left;
    right = left;
    while(true){
        string center;
        int c = (l + r) / 2;
        cout << c << endl;
        fflush(stdout);
        cin >> center;
        if(center == "Vacant") return 0;
        if(center == right){
            if((r - c) % 2){
                l = c;
                left = center;
            }
            else{
                r = c;
                right = center;
            }
        }
        else{
            if((r - c) % 2){
                r = c;
                right = center;
            }
            else{
                l = c;
                left = center;
            }
        }
        if(r - l <= 1) return 0;
    }
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<b;i++)
#define f(i,n) for(int i=0;i<n;i++)
typedef unsigned long long ull;
typedef long long ll;
#define vint vector<int>
#define pb(a) push_back(a);
#define bug(x) cout<<#x<<" = "<<x<<endl;
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
// using namespace std;
int main(){
	fastio;
	int h,w;
	cin>>h>>w;
	int dp[h+1][w+1];
	char a[h][w];
	memset(dp,0,sizeof dp);
	f(i,h){
		f(j,w){
			cin>>a[i][j];
			if(a[i][j]=='#'){
				dp[i][j]=0;
			}
			else{
				if(i==0 && j==0){
					dp[i][j]=1;
				}
				else if(i==0){
					dp[i][j]=dp[i][j-1];
				}
				else if(j==0){
					dp[i][j]=dp[i-1][j];
				}
				else{
					dp[i][j]= (dp[i-1][j] + dp[i][j-1])%1000000007;
				}
			}
			// cout<<dp[i][j]<<" ";
		}
		// cout<<"\n";
	}
	cout<<dp[h-1][w-1]<<"\n";
	return 0;
}

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

using namespace std;

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;*/
    
    string s;cin>>s;
    int n=s.size();
    vector<int> dp(n);
    dp[0]=0;
    map<char,char> m;
    m['0']='1';
    m['1']='0';
    for(int i=1;i<n;i++){
        if(s[i]==s[i-1]){
            dp[i]=dp[i-1]+1;
            s[i]=m[s[i-1]];
        }
        else {
            dp[i]=dp[i-1];
        }
    }
    cout<<dp[n-1];

    /*#ifndef ONLINE_JUDGE
        cout << "\nTime Elapsed : " << 1.0 * clock() << " ms\n";
    #endif*/
    return 0;
}

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

int main(){
  char b;
  cin >> b;
  
  if(b == 'A')
    cout << 'T' << endl;
  else if(b == 'T')
    cout << 'A' << endl;
  else if(b == 'C')
    cout << 'G' << endl;
  else
    cout << 'C' << endl;
    
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        
        char[][] field = new char[h][w];
        int [][] numStep = new int[h][w];
        numStep[0][0] = 1;
        
        int numDot = 0;
        for (int i = 0; i < h; i++) {
            String line = sc.next();
            for (int j = 0; j < w; j++) {
                field[i][j] = line.charAt(j);
                numDot += (line.charAt(j) == '.') ? 1 : 0;
            }
        }
        
        Queue<Integer> qI = new ArrayDeque<>();
        Queue<Integer> qJ = new ArrayDeque<>();
        qI.add(0);
        qJ.add(0);

        int[] moveI = new int[]{1, 0, -1, 0};
        int[] moveJ = new int[]{0, 1, 0, -1};
        
        while (!qI.isEmpty()) {
            int i = qI.poll();
            int j = qJ.poll();
            
            for (int k = 0; k < 4; k++) {
                int nextI = i + moveI[k];
                int nextJ = j + moveJ[k];
                
                if (nextI >= 0 && nextI < h && nextJ >= 0 && nextJ < w &&
                        numStep[nextI][nextJ] == 0 &&
                        field[nextI][nextJ] == '.') {
                    numStep[nextI][nextJ] = numStep[i][j] + 1;
                    qI.add(nextI);
                    qJ.add(nextJ);
                }
            }
        }
        
        if (numStep[h-1][w-1] == 0) {
            System.out.println(-1);
        } else {
            System.out.println(numDot - numStep[h-1][w-1]);
        }
    }
}

Measured memory_bytes: 23636
#include <stdio.h>
#include <string.h>

#define M 1046527
#define NIL (-1)
#define L 14

//n<=10^6なので最大でそれだけ辞書に追加される可能性がある
//Mが10^6に近い素数なのはそういうことか
//ちなみに1,046,527は素数だが、10^6より大きい最小の素数ではないみたい
char H[M][L];

//char->int
int getChar(char ch)
{
    if(ch=='A')return 1;
    else if(ch=='C')return 2;
    else if (ch=='G')return 3;
    else if(ch=='T')return 4;
    else return 0;
}

//strig -> int key
//long long型およびunsigned long long型は、64ビット以上の値を表現できる
long long getKey(char str[])
{
    long long sum=0,p=1,i;
    for (i=0;i<strlen(str);i++)
    {
        sum+=p*(getChar(str[i]));
        p*=5;
    }
    return sum;
}
/*
getKeyの処理を考える
たとえば'AGC'が入ったとして順番に処理する
- p=1,sum=0
getChar('A')=1
sum+=1*1
- p=5,sum=1
getChar('G')=3
sum+=5*3
- p=25,sum=1+5*3
getChar('C')=2
sum+=25*2

- sum=1+5*3+25*2=66

これをかいてみて分かったが、文字列は最大で12文字続く
このとき最後にはp=5^11がかかるわけで
5^11=48,828,125>10^7
たしかにこれだけあれば異なる文字列でkeyが被ることもないか
まず文字数でかなり位置取りが変わる
そのうえで同じ文字数でもさまざまにズレることができる
*/

//hash1関数
int h1(int key){return key%M;}
//hash2関数
int h2(int key){return 1+(key%(M-1));}

int find(char str[])
{
    long long key,i,h;
    key=getKey(str);
    for(i = 0; ;i++)
    {
        h=(h1(key)+i*h2(key))%M;
        //strcmp:文字列s1と文字列s2を比較します
        //s1 > s2 で正の値、s1 < s2 で負の値、s1 = s2で 0 を返す。この大小関係は一般に文字コード順による。
        if(strcmp(H[h],str)==0)return 1;
        else if(strlen(H[h])==0)return 0;
    }
    return 0;
}

int insert(char str[])
{
    long long key,i,h;
    key=getKey(str);
    for( i = 0;; i++)
    {
        h=(h1(key)+i*h2(key))%M;
        //豆知識；c++では0 とstrのfalseが偽でそれ以外が真
        //H[h]==strのときreturn 1;
        //それ以外はstrcpyしてinsert
        if(strcmp(H[h],str)==0)return 1;//衝突の確認
        else if(strlen(H[h])==0)//H[h]が空、つまり衝突の確認
        {   
            //char *strcpy(char *s1, const char *s2);
            //文字型配列 *s1 に文字列 *s2 を '\0' までコピーします。'\0' もコピーするので s1 はその分も考えて大きさを宣言しておかなければなりません。
            //もし、s1 と s2 が重なっている場合には動作は未定義となります。
            // char *s1　：　複写先の文字型配列
            // const char *s2　：　複写する文字列
            // 【戻り値】
            // s1の値。つまり返却値はコピー後の文字列を指す。
            strcpy(H[h],str);//H[h]<-str
            return 0;
        }
    }
    return 0;
    
}

int main()
{
    int i,n,h;
    char str[L],com[9];
    
    for(i=0;i<M;i++)H[i][0]='\0';
    scanf("%d",&n);

    for(i=0;i<n;i++)
    {
        scanf("%s %s",com,str);

        if(com[0]=='i')
        {
            insert(str);
        }
        else
        {
            if(find(str))
            {
                printf("yes\n");
            }
            else
            {
                printf("no\n");
            }
            
        }
        
    }
    return 0;
}














// 値とboolについては次のでも試してください
// int main(void){

//     if(-5)return 1;//if内を好きに変えてね
    
//     return 0;
// }


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

#define ll long long
#define endl "\n" 
#define FOR(n) for(int i=0 ; i<n ; i++)
#define FORa(a, n) for(ll i=a ; i<=n ; i++)
ll mod=1000000007;
ll inf=1e9;
vector<ll> dp;
void solve()
{
ll n,ans=0;
cin >> n;
ll a[n];
FOR(n) cin >> a[i];
for(int i=1 ; i<n ; i++) {
    if(a[i-1]>a[i]){
       ans+=a[i-1]-a[i];
       a[i]=a[i-1];
    }
}
cout << ans << endl;
}   
  


int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t=1;
  //cin >> t;
  while(t--)
    solve();
    return 0 ;
}
  

Measured memory_bytes: 5148
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

pair<int, int> E[100001];
int H[100001];
int sagasu(int A) {
	vector<int> kari;
	for (int i = H[A]; i; i = E[i].second) kari.pb(sagasu(E[i].first));
	sort(kari.begin(), kari.end(), greater<int>());
	int ret = 0;
	rep(i, kari.size()) ret = max(ret, i + kari[i] + 1);
	return ret;
}

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


	int N = getint();

	for (int i = 2; i <= N; i++) {
		int a = getint();
		E[i] = mp(i, H[a]);
		H[a] = i;
	}

	co(sagasu(1));

	Would you please return 0;
}

Measured memory_bytes: 9344
#include<bits/stdc++.h>
using namespace std ;
#define ll long long 
#define pb push_back
#define in(x) int x; cin>>x;
#define ln(x) long long x; cin>>x;
#define memf(a) memset(a,false,sizeof(a))
#define F first
#define S second
#define endl "\n"
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
ll dp[6000];
int main()
{
	fast
	ll n;
	cin>>n;
	ll M=1e9+7;
	dp[0]=1;
	for(int i=3;i<=n;i++)
	{
		for(int j=3;j<=(i);j++)
		{
			if((i-j)>=0)
			dp[i]+=(dp[i-j]);
			// cout<<(i+j)<<" "<<dp[i+j]<<endl;
			dp[i]%=M;
		}	

	}

	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <sstream>

using namespace std;

int main(){
	
	while(true){
		
		int N, M, P;
		
		cin >> N >> M >> P;
		if(N == 0 && M == 0 && P == 0){
			break;
		}
		
		int hit;
		int sum = 0;
		
		for(int i = 0; i < N; i++){
			int num;
			cin >> num;
			if(i + 1 == M){
				hit = num;
			}
			sum += num;
		}
		
		if(hit == 0){
			cout << "0" << endl;
		}else{
			cout << sum * (100 - P) / hit << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 2976
#include <stdio.h>

int N;
int a[5001];
 
int main(void){
    int i , j;
    while(scanf("%d", &N) != EOF) {
        if(N == 0) break;
        
        for(i = 0; i < N; ++i){
            scanf("%d", &a[i]);
        }
        
        int ans = a[0];
        for(i = 0; i < N; ++i){
            long long int sum = 0;
            for(j = i; j < N; ++j){
                sum += a[j];
                ans = (sum >= ans ? sum : ans);
            }
        }
        printf("%d\n" , ans);
    }
    return 0;
}


Measured memory_bytes: 2120
#include <stdio.h>
#include <math.h>

void distance(double x1,double y1,double x2,double y2) {
    double dis = sqrt ( (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 -y2) );
    printf ("%f\n",dis);
}

int main () {
    double x1,y1,x2,y2;
    scanf ("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    distance (x1,y1,x2,y2);
    
    return 0;
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n),b(n),ooi;
    ll sukunai=0;
    ll ans=-1;
    ll sukunaicnt=0;
    
    for(int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    
    for(int i = 0; i < n; i++)
    {
        cin>>b[i];
    }
    
    for(int i = 0; i < n; i++)
    {
        if(a[i]<b[i])
        {
            sukunai+=b[i]-a[i];
            sukunaicnt++;
        }
        else if(a[i]>b[i])
        {
            ooi.push_back(a[i]-b[i]);
        }
    }
    sort(all(ooi));
    reverse(all(ooi));
    
    for(int i = 0; i < ooi.size(); i++)
    {
        if(sukunai<=0)
        {
            ans=i+sukunaicnt;
            break;
        }
        sukunai-=ooi[i];
        if(sukunai<=0)
        {
            ans=i+1+sukunaicnt;
            break;
        }
    }
    

    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2556
#include <iostream>
#include <cmath>
#include <iomanip>
#include <algorithm>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 aa, bb;
	cin >> aa >> bb;
	string as, bs;
	for(int64 ii = 0;ii < bb;ii++)
	{
		as += aa + '0';
	}
	for(int64 ii = 0;ii < aa;ii++)
	{
		bs += bb + '0';
	}
	if(as < bs)
	{
		cout << as << endl;
	}
	else
	{
		cout << bs << endl;
	}
	return 0;
}

Measured memory_bytes: 256
while True:
	output_even, output_odd = "", ""
	H, W = map(int, input().split())
	if H == 0 and W == 0:
		break
	for x in range(W):
		if x % 2 == 0:
			output_even += '#'
			output_odd  += '.'
		else:
			output_even += '.'
			output_odd  += '#'
	for y in range(H):
		if y % 2 == 0:
			print(output_even)
		else:
			print(output_odd)
	print()

Measured memory_bytes: 7576
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(), v.end()


int main(int argc, char const *argv[])
{
    ll n, Y;
    cin >> n >> Y;

    for (ll x = 0; x <= n; x++)
    {
        for (ll y = 0; y <= n - x; y++)
        {
            ll z = n - x - y;
            if (Y == 10000 * x + 5000 * y + 1000 * z)
            {
                cout << x << " " << y << " " << z << endl;
                exit(0);
            }
        }
    }
    
    cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int N, K;

int main() {

  cin >> N >> K;

  double ans = 0;
  for (ll i = 1; i <= N; ++i) {
     ll t = 1;
     while (t*i < K) t *= 2;
     ans += 1.0/(double(t));
  }
  ans *= 1.0/(double(N));

  printf("%.14lf\n", ans);

  return 0;
}


Measured memory_bytes: 384