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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;
typedef vector<pp> vpp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()
#define pb push_back


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b, n; cin >> a >> b >> n;
    ll ret = min(n, b-1);
    cout << floor(a*ret/ b) - floor(ret/b) * a << endl;
    return 0;
}



Measured memory_bytes: 3804
#include <bits/stdc++.h>
#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, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

bool cmp(pair<int, int> a, pair<int, int> b)
{
  if(a.second!=b.second)
    return a.second < b.second;
  else
    return a.first < b.first;
}

int main()
{
  int n,m;
  cin >> n >> m;
  vector<pair<int, int>> op(m);
  REP(i,m)  cin >> op[i].first >> op[i].second;
  sort(ALL(op), cmp);
  int endt = 0;
  int ans = 0;
  REP(i,m){
    if(op[i].first >= endt){
      ans++;
      endt = op[i].second;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int i, n, max;
    String[] s;
    int[] count;
    String l;

    n = 0; s = new String[1000]; count = new int[1000];
    for(;sc.hasNext();){
      s[n] = sc.next();
      n++;
      for(i = 0;i < n - 1;i++)if(s[n - 1].equals(s[i]))count[i]++;
    }

    max = 0; l = s[0];
    for(i = 1;i < n;i++){
      if(count[max] < count[i])max = i;
      if(l.length() < s[i].length())l = s[i];
    }

    out.println(s[max] + " " + l);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

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

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    ll i,j,k;
    ll sum=0,gcd=1;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            for(k=1;k<=n;k++)
            {
                gcd=__gcd(j,k);
                gcd=__gcd(gcd,i);
                sum+=gcd;
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	int n;cin>>n;
	ll a[n],b[n],suma=0,sumb=0;
	rep(i,n) {
		cin>>a[i];
		suma+=a[i];
	}
	rep(i,n) {
		cin>>b[i];
		sumb+=b[i];
	}
	if(suma<sumb){
		cout<<-1<<"\n";
		return 0;
	}

	ll cnt=0,minus=0;
	vector<ll> plus;
	rep(i,n){
		if(a[i]<b[i]){
			cnt++;
			minus+=b[i]-a[i];
		}
		else if(a[i]>b[i]){
			plus.push_back(a[i]-b[i]);
		}
	}
	int lp=plus.size();
	sort(plus.begin(),plus.end());
	reverse(plus.begin(),plus.end());
	
	//cout<<lp<<"\n";

	rep(i,lp){
		if(minus<=0) break;
		minus-=plus[i];
		cnt++;
	}

	cout<<cnt<<"\n";
}

Measured memory_bytes: 2428
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int M = sc.nextInt();
		System.out.println(48-M);
	}
}

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

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

    int pair = 0;

    for (int a = 0; a <= A; a++){
        for (int b = 0; b <= B; b++){
            for (int c = 0; c <= C; c++){
                if(X == 500 * a + 100 * b + 50 * c) { pair++; }
            }
        }
    }

    std::cout << pair << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
typedef long long ll;
typedef long double ld;
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))

int main() {
	int n; char s[11]; ll ans = 0, m[6] = { 0 };
	int a[10] = { 1,1,1,1,1,1,2,2,2,3 };
	int b[10] = { 2,2,2,3,3,4,3,3,4,4 };
	int c[10] = { 3,4,5,4,5,5,4,5,5,5 };
	scanf("%d", &n);
	rep(i,n) {
		scanf("%s", &s);
		if (s[0] == 'M')m[1]++;
		else if (s[0] == 'A')m[2]++;
		else if (s[0] == 'R')m[3]++;
		else if (s[0] == 'C')m[4]++;
		else if (s[0] == 'H')m[5]++;
	}
	rep(i, 10)ans += m[a[i]] * m[b[i]] * m[c[i]];
	printf("%lld", ans);	
}

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

using namespace std;

vector<int> Factorize(int sum) {
  vector<int> F;
  for (int i = 1; i * i <= sum; i++) {
    if (sum % i != 0) continue;
    int j = sum / i;
    F.push_back(i);
    if (j != i) F.push_back(j);
  }

  sort(F.rbegin(), F.rend());
  return F;
}

bool OK(int f, int K, vector<int> A) {
  for (int i = 0; i < A.size(); i++) {
    int r = A[i] / f;
    A[i] -= r * f;
  }
  sort(A.begin(), A.end());

  int total = 0;
  int l = 0;
  int r = A.size() - 1;
  while (l < r) {
    while (l < r && (A[l] % f) == 0) l++;
    while (l < r && (A[r] % f) == 0) r--;
    if (l >= r) break;
    int move = min(A[l], f - A[r]);
    A[l] -= move;
    A[r] += move;
    total += move;
  }
  return total <= K;
}

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  int sum = accumulate(A.begin(), A.end(), 0);
  vector<int> F = Factorize(sum);

  for (int f : F) {
    if (OK(f, K, A)) {
      cout << f << endl;
      break;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
#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,C,K; cin >> A >> B >> C >>K;
    if(A>=B && A>=C) cout << (ll)A*pow(2,K)+B+C << endl;
    else if(B>=A && B>=C) cout << (ll)B*pow(2,K)+A+C << endl;
    else cout << (ll)C*pow(2,K)+B+A << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	static int[]heap;
    static int MAXHEAP=2000000;
    static int n;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int i;
		heap=new int[MAXHEAP+1];
       Scanner sca= new Scanner(System.in);
       n=sca.nextInt();
       for(i=1;i<=n;i++){
    	   heap[i]=sca.nextInt();
    	   heap[i*2]=heap[i*2+1]=Integer.MIN_VALUE;
       }
       buildMaxHeap();
       for(i=1;i<=n;i++){
      System.out.print(" "+heap[i]);
      if(i==n)System.out.println("");
       }
	}
	public static void maxHeapify(int i){
		int l=i*2,r=i*2+1,largest,hz;
		if(l<=n&&heap[l]>heap[i]){
			largest=l;
		}else{
			largest=i;
		}
		if(r<=n&&heap[r]>heap[largest])largest=r;
		if(largest!=i){
			hz=heap[largest];
			heap[largest]=heap[i];
			heap[i]=hz;
			maxHeapify(largest);
		}
	}
	public static void buildMaxHeap(){
		int i;
		for(i=n/2;i>=1;i--){
			maxHeapify(i);
		}
	}

}


Measured memory_bytes: 179008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
  int a,b;cin>>a>>b;
  string s;cin>>s;
  bool flag=true;
  rep(i,s.size()){
   if(i==a&&s[i]!='-')flag=false;
    else if(i!=a&&!(s[i]>='0'&&s[i]<='9'))flag=false;
  }
  if(flag==true)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
    return 0;
}

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

using namespace std;

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

	vector<int> vi;

	for (int i = 0; i < N; i++) {
		int p;
		cin >> p;
		vi.push_back(p);
	}

	sort(vi.begin(), vi.end());

	int sum = 0;

	for (int i = 0; i < K; i++) {
		sum += vi[i];
	}

	cout << sum;
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

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

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

template<ll Modulus>
class ModInt {
  ll value;
public:
  inline ModInt(ll val = 0) noexcept :
    value((val >= Modulus) ? (val % Modulus) : (val < 0) ? ((val + Modulus) % Modulus) : val) {}

  template<class Int>
  explicit inline operator Int() const noexcept { return static_cast<Int>(value); }

  inline ModInt inv() const noexcept {
    return ModInt<Modulus>::pow(value, Modulus-2);
  }

  inline ModInt& operator+=(ModInt x) noexcept {
    if ((value += x.value) >= Modulus) value -= Modulus;
    return *this;
  }
  inline ModInt& operator-=(ModInt x) noexcept {
    if ((value -= x.value) < 0) value += Modulus;
    return *this;
  }
  inline ModInt& operator*=(ModInt x) noexcept {
    value = (value * x.value) % Modulus; return *this;
  }
  inline ModInt& operator/=(ModInt x) noexcept {
    value = (value * x.inv().value) % Modulus; return *this;
  }

  inline ModInt operator+(ModInt x) const noexcept { return ModInt(*this) += x; }
  inline ModInt operator-(ModInt x) const noexcept { return ModInt(*this) -= x; }
  inline ModInt operator*(ModInt x) const noexcept { return ModInt(*this) *= x; }
  inline ModInt operator/(ModInt x) const noexcept { return ModInt(*this) /= x; }
  inline bool operator==(ModInt x) const noexcept { return value == x.value; }
  inline bool operator!=(ModInt x) const noexcept { return !(this->operator==(x)); }

  friend ostream& operator<<(ostream &os, ModInt x) noexcept { os << x.value; return os; }
  friend istream& operator>>(istream &is, ModInt &x) noexcept { is >> x.value; return is; }

  static constexpr inline ModInt pow(ll n, ll p) noexcept {
    ll ret = 1;
    for(; p > 0; p >>= 1) {
      if (p & 1) ret = (ret * n) % Modulus;
      n = (n * n) % Modulus;
    }
    return ret;
  }

  ModInt p(ll p){
	ll n = value;
    ll ret = 1;
    for(; p > 0; p >>= 1) {
      if (p & 1) ret = (ret * n) % Modulus;
      n = (n * n) % Modulus;
    }
    return value = ret;
  }
};

#define MOD 1000000007
using mint = ModInt<MOD>;

mint fact(ll n){
  mint res = 1;
  rep(i, n) res *= mint(i+1);
  return res;
}

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

  mint ans = 0, tmp = 1;
  rep(i, N+1){
    ans += tmp;
    tmp *= mint(N + S.size() - i) / mint(i+1) * mint(25);
  }

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



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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int n,m;
    cin >> n >> m;
    int P[m],Y[m];
    REP(i,m){
        cin >> P[i] >> Y[i];
        P[i]--;
    }
    vector<vector<int>> v(n);
    REP(i,m)v[P[i]].push_back(Y[i]);
    REP(i,n)sort(v[i].begin(),v[i].end());
    REP(i,m){
        int it = lower_bound(v[P[i]].begin(),v[P[i]].end(),Y[i])-v[P[i]].begin();
        printf("%06d",P[i]+1);
        printf("%06d\n",it+1);
    }
    return 0;
}


Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void){
    ll n,k; cin>>n>>k;
    if(k==0) {cout<<n*n<<endl; return 0;}
    long long ans = 0;
    for(ll b=k+1;b<=n;b++){
        if(b-k>0)
        ans += (n/b)*(b-k);
        if(n%b>=k)
        ans += (n%b) - k+1 ;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
long long dp[101][100001];
vector<int> w, v;
int N, W;

void input() {
    cin >> N >> W;
    w.resize(N+1);
    v.resize(N+1);
    for(int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }
}
    
long long solve() {    
    for(int i = 0; i < N; i++) {
        for(int j = 0; j <= W; j++) {
            if(j < w[i]) {
                dp[i+1][j] = dp[i][j];
            } else {
                dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
            }
        }
    }
    return dp[N][W];
}
int main() {
    input();
    cout << solve() << endl;
}

Measured memory_bytes: 78464
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
#include <unordered_map>
#include <stack>
#include <map>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T>bool chmaxj(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
void YesNo(bool y) { cout << (y ? "Yes" : "No") << endl; } //true==yes


#define INF 21474836

//////////////////////////////////////////////////////////////



int main() {

	int S, W;
	cin >> S >> W;
	if (W >= S) {
		cout << "unsafe" << endl;
	}
	else {
		cout << "safe" << endl;
	}
	

}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

int main(){
  int n;
  int a[2][109];
  cin>>n;
  rep(i,2){
    rep(j,n){
      cin>>a[i][j];
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    int sum=0;
    for(int j=0;j<=i;j++){
      sum+=a[0][j];
    }
    for(int j=i;j<n;j++){
      sum+=a[1][j];
    }
    ans=max(ans,sum);
  }
  cout<<ans<<endl;
  return(0);
}



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

int main(){
	int a, b;

	while(1){
	  cin >> a >> b;
	  if( a == 0 && b == 0 ) break;

	  for( int i = 0; i < a; i++){
		for( int j = 0; j < b; j++){
		  if( i == 0 || i == a - 1){
			cout << "#";
		  } else{
			if( j == 0 || j == b - 1){
				 cout << "#";
			} else{
				 cout << ".";
		        }
		  }
                }
		cout << endl;
	 }
	 cout << endl;
        }

return 0;
}

Measured memory_bytes: 3080
#include<stdio.h>
#include<math.h>
int main(void) {
	int A,N,M,R;
	int i;
	int ans = 0;
	scanf("%d%d", &N, &M);
	for (i = 0; i < M; i++) {
		scanf("%d", &A);
		ans = ans + A;
	}
	if (N >= ans)
		printf("%d", N - ans);
	else
		printf("-1");
	return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    string s; cin >> s;

    ll n = s.size() + 1;
    ll a[n];
    fill(a, a+n, 0LL);

    // rep(i, n-1){
    //     if(s[i] == s[i+1]){
    //         a[i+1] = a[i] + 1;
    //     }
    // }

    // repr(i, n-1){
    //     if(s[i] == s[i+1]){
    //         a[i] = a[i+1];
    //     }
    // }

    // rep(i, n-1){
    //     cout << a[i];;
    // }

    rep(i, n-1){
        if(s[i] == '<'){
            a[i+1] = a[i] + 1;
        }
    }

    repr(i, n-1){
        if(s[i] == '>' && a[i] <= a[i+1]){
            a[i] = a[i+1] + 1;
        }
        // if(s[i] == '>' && s[i-1] == '>'){
        //     a[i] = a[i+1] + 1;
        // }
    }

    // if(s[0] == '<' && s[1] == '>'){
    //     a[1] = max(a[0] + 1, a[2] + 1);
    // }

    // rep(i, n){
    //     cout << a[i];
    // }

    ll ans = accumulate(a, a+n, 0LL);

    cout << ans << endl;

    

    return 0;
}

Measured memory_bytes: 4764
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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;
}

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

ll factrial(ll n){
    if(n == 0) return 1;
    ll p = factrial(n-1)*n%MOD;
    return p;
}

//MOD逆元
ll farmat(ll n,ll p){    
    if(p == 0) return 1;
    else if(p == 1) return n%MOD;
    ll d = farmat(n,p/2);
    if(p%2 == 0){
        return (d*d)%MOD;
    }else{
        return ((n*d)%MOD*d)%MOD;
    }
}

ll conbination(ll n,ll k){
    ll a = factrial(n);
    ll b = factrial(k);
    ll c = factrial(n-k);
    return (a*farmat(b,MOD-2)%MOD*farmat(c,MOD-2))%MOD;
}

int n;
int memo[10000000];

int fib(int i){
    if(i <= 1) return i;
    if(memo[i] != 0) return memo[i];
    return memo[i] = fib(i-1)+fib(i-2);
}

ll dig(ll n){
    ll d = 0;
    while(n != 0){
        n/=10;
        d++;
    }
    return d;
}
map<char,int> a;
void solve() {
    string s;
    cin >> s;
    bool flag = false;
    for(int i = 0;i < s.size();i++){
        if(i%2 == 0){
            if(s[i] == 'L') {
                flag = true;
                break;
            }
        }else{
            if(s[i] == 'R'){
                flag = true;
                break;
            }
        }
    }
    if(flag) cout << "No" << endl;
    else cout << "Yes" << endl;
}


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}



Measured memory_bytes: 256
package main

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

var (
	A, B, answer int
)

func readVariables() {
	A, B = nextInt(), nextInt()
}

func main() {
	readVariables()
	answer = MaxInt(0, A-2*B)
	fmt.Println(answer)
}

/* 以下、テンプレート*/

var scanner *bufio.Scanner

func init() {
	Max := 10010010
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, Max), Max)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

// MinInt は、2つの整数を受け取り、最小値を返します。
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt は、2つの整数を受け取り、最大値を返します。
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt は、整数の絶対値を返します。
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//ModPow は整数の累乗関数で、剰余もサポートします。
//base^exponentの値をmoduleで割った余りを返します。
//moduloが1以下の場合には、剰余演算をしません。
//baseが負の値である場合には、返す値が負になることがあります。
func ModPow(base, exponent, modulo int) (result int) {
	result = 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			if modulo > 1 {
				result %= modulo
			}
		}
		base *= base
		if modulo > 1 {
			base %= modulo
		}
		exponent /= 2
	}
	return
}

//Gcd は、引数の整数全ての最大公約数を返します。
func Gcd(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = gcd(result, vals[i])
	}
	return
}

func gcd(x, y int) int {
	x, y = AbsInt(x), AbsInt(y)
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

//Lcm は、与えられた整数の最小公倍数を返します。
func Lcm(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = lcm(result, vals[i])
	}
	return
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using lli=long long;
using pii=pair<int,int>;

int n;
pii a[200000];

lli f() {
	int sma=0,smi=1e9,lma=0,lmi=1e9;
	for(int i=0;i<n;i++) {
		if(a[i].fi > a[i].se) swap(a[i].fi,a[i].se);
		sma = max(sma,a[i].fi); smi = min(smi,a[i].fi);
		lma = max(lma,a[i].se); lmi = min(lmi,a[i].se);
	}
	return 1ll*(lma-lmi)*(sma-smi);
}
lli g() {
	int mi=1e9,ma=0,mv=1e9;
	priority_queue<pii,vector<pii>,greater<pii>> que;
	for(int i=0;i<n;i++) {
		if(a[i].fi > a[i].se) swap(a[i].fi,a[i].se);
		que.push(pii(a[i].fi,i+1));
		ma = max(ma,a[i].fi);
	}
	mv = ma - que.top().fi;

	while(!que.empty()) {
		pii cur=que.top();que.pop();
		if(cur.se > 0) {
			cur.se--;
			ma = max(ma, a[cur.se].se);
			que.push(pii(a[cur.se].se, -1));
		} else {
			mi = min(mi, cur.fi);
		}
		mv = min(mv, ma - min(que.top().fi,mi));
	}
	ma=0; mi=1e9;
	for(int i=0;i<n;i++) ma=max(ma,a[i].se),mi=min(mi,a[i].fi);
	return 1ll*(ma-mi)*mv;
}
int main() {
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d%d",&a[i].fi,&a[i].se);
	printf("%lld\n",min(f(),g()));
	
	return 0;
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 1e6 + 6;
int main()
{
    fastRead;
    int n, k;
    cin>>n>>k;
    vector<int>vec(n);
    for(int i =0 ; i < n ; i++ ) cin>>vec[i];
    sort(vec.begin(), vec.end());
    ll sum =0 ;
    for(int i = 0 ; i < k ; i++) sum +=vec[i];
    cout<<sum<<'\n';
    return 0;
}

Measured memory_bytes: 3644
N, K = gets.split.map(&:to_i)
TDs = readlines.map{|l| l.split.map(&:to_i)}

tds = TDs.sort_by{|t, d| -d}
p1, r1 = tds.take(K), tds.drop(K)
th = p1.each_with_object(Hash.new(0)){|(t, d), h| h[t] += 1}
k0 = tds.map(&:first).uniq.size
k1 = th.keys.size
n = [k0, K].min - k1
p2 = p1.select{|t, d| th[t] > 1}.group_by{|t,d| t}.flat_map{|k, v| v.map(&:last).drop(1).reverse}.sort.take(n)
r2 = r1.select{|t, d| th[t].zero?}.group_by{|t, d| t}.flat_map{|k, v| v.map(&:last).take(1)}.sort.reverse.take(n)
pt1 = p1.inject(0){|s, (t, d)| s + d} + k1*k1
puts (k1 + 1 .. k1 + n).each_with_object([pt1]){|i, a| a << a.last -  p2.shift + r2.shift + 2*i - 1}.max

Measured memory_bytes: 30532
import java.io.*;

class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str1 = br.readLine();
    String[] str2 = str1.split(" ");
    int W = Integer.parseInt(str2[0]);
    int H = Integer.parseInt(str2[1]);
    int x = Integer.parseInt(str2[2]);
    int y = Integer.parseInt(str2[3]);
    int r = Integer.parseInt(str2[4]);

    if ((x - r) >= 0 && (x + r) <= W && (y - r) >= 0 && (y + r) <= H)
      System.out.println("Yes");
    else
      System.out.println("No");
    }
}

Measured memory_bytes: 24320
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
typedef vector<int> vi;
typedef vector<lln> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


int arr[maxii];
int arr2[maxii];
int gcd(int a,int b)
{
    if(b==0){
      return a;
     }
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    int res=(a*b)/gcd(a,b);
    return res;
}
int po(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b%2!=0)
        {
            res*=a;
            b--;
        }
        else
        {
            a*=a;
            b/=2;
        }
    }
    return res;
}

lln modMul(lln  a, lln b,lln mod){
    lln ans = 0;
    a = a % mod;
    while (b > 0){
        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;
        a = (a%mod * 2%mod) % mod;
        b /= 2;
    }
    return ans % mod;
}
lln powerMod(lln a,lln b,lln mod){
	if(b==0)return 1LL%mod;
	lln x=powerMod( a,b/2,mod );
	x = ( x%mod * x%mod ) % mod;
	if( b%2==1 )x = ( x%mod * a%mod ) % mod;
	return x%mod;
}

int main()
{
   int n;
   cin>>n;
   if(n<1200)cout<<"ABC";
   else cout<<"ARC";

}






Measured memory_bytes: 3512
S=input()

start_S_flag=False
like_Center_C_flag=False
if S[0]!='A':
    print('WA')
    exit(0)

kaburi=False
for i in range(len(S)):
    #print(i)
    if S[i].isupper() and i>0:
        if S[i]=='C' and i>=2 and i<=(len(S)-2) and not kaburi:
            kaburi=True
            like_Center_C_flag=True
        else:
            print ( 'WA' )
            exit ( 0 )
if kaburi:
    print ( 'AC' )
else:
    print('WA')

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

int main() {
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  int z = min(x,y);
  int m = max(x,y);
  int ans1 = a*x+b*y;
  int ans2 = a*(x-z)+b*(y-z)+c*2*z;
  int ans3 = c*2*m;
  int ans = min(ans1,min(ans2,ans3));
  cout << ans <<endl;
}


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

int main(){
    int a,b,c,d,e,na,nb,nc;
    while(cin>>a>>b>>c>>d>>e,a){
        cin>>na>>nb>>nc;
        long long int sum=0;
        if(nc>=d){
            sum=na*a+nb*b+nc*e;
        }else{
            sum+=(nc/d)*d*e;
            nc-=(nc/d)*d;
            if(nc+nb>=d){
                sum+=min(nc*c+(d-nc)*b,e*d);
                nb-=d-nc;
                sum+=nb*b+na*a;
            }else if(na+nb+nc>=d){
                sum+=min(nc*c+nb*b+(d-nc-nb)*a,e*d);
                na-=d-nc-nb;
                sum+=na*a;
            }else{
                sum+=min(na*a+nb*b+nc*c,e*d);
            }
        }
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 3068
from sys import stdin

def Int_all(): return list(map(int, stdin))
def IL():return list(map(int, stdin.readline().split()))


def dfs(i,s):

	if i == 4:
		return s==7

	if dfs(i+1,s+a[i]):
		if i != 0:
			ans[i] = "+"+str(a[i])
		else:
			ans[i] = str(a[i])
		return True
	if dfs(i+1, s-a[i]):
		if i != 0:
			ans[i] = "-"+str(a[i])
		else:
			ans[i] = str(a[i])
		
		return True

	return False



a = list(map(int,list(input())))
ans = [0 for i in range(4)]

def main():
	dfs(0,0)
	print("{}=7".format(''.join(ans)))

if __name__ == "__main__": main()

Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
	int q,c,a,n,i,cnt;
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d %d %d",&c,&a,&n);
		cnt=0;
		while(1){
			if(c==0||a==0||n==0)break;
			c--;
			a--;
			n--;
			cnt++;
		}
		while(1){
			if(c<2||a==0)break;
			c-=2;
			a--;
			cnt++;
		}
		while(1){
			if(c<3)break;
			c-=3;
			cnt++;
		}
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 600
using System;
using System.Collections.Generic;
using System.Linq;
 
static class MainClass {

  public static void Main (string[] args) {
    var N = int.Parse(Console.ReadLine());
    var list = new List<string>();
    var ans ="Yes";
    for(var i = 0; i < N; i++){
      list.Add(Console.ReadLine());
    }
    
    if(list.Distinct().Count() != list.Count()){
      ans = "No";
    }

    for(var i = 0; i < N - 1; i++){ 
      if(list[i].ToCharArray().Last() != list[i + 1].ToCharArray().First()){
        ans = "No";
        break;
      }
    }

    Console.WriteLine(ans);
  }
  
}

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

#define pb push_back
#define F first
#define S second
#define fo(i,a,b)  for(int i = a; i < b; i++)

using ll = long long;
using ld = long double;
using ul = unsigned long long;
using ii = pair<int, int>;
#define Mosta     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ReadFile            freopen("input.in","r",stdin)
#define WriteFile           freopen("output.txt","w",stdout)
const ll mod7 = 1000000007,mod = 1000000000,OO = 0x3f3f3f3f;
const ld EPS = 1e-7;
double Pi=acos(-1);
const ld rad=Pi/180.0;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll nCr (ll n,ll m)
{
        return(m == 0)?1:n*nCr(n-1,m-1)/m;
}
/*****************************************************/

const int N = (int) 1e5 + 5;

bool prime[N];

int ans[N];

int main()
{
    memset(prime , 1 , sizeof(prime));
    prime[0]=prime[1]=0;
    for(int i = 2; i <= N; ++i){
        if(prime[i]){
            for(int j = i+i; j <= N; j+=i)
                prime[j] = 0;
        }
    }

    for(int i = 3; i <= 100000; i+=2){
        if(prime[i] && prime[(i+1)/2])
            ans[i]++;
    }

    for(int i = 3; i <= 100000; i++)
        ans[i] += ans[i-1];

    int q;
    cin >> q;

    while(q--){
        int l , r;
        cin >> l >> r;
        cout << ans[r] - ans[l-1] << "\n";
    }

    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>  // ver2.3.0
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define COUNT(a,k) upper_bound(ALL(a),k)-lower_bound(ALL(a),k)
#define BIGGER(a,k) a.end()-upper_bound(ALL(a),k)
#define SMALLER(a,k) lower_bound(ALL(a),k)-a.begin()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define cyes cout<<"yes"<<endl
#define cno cout<<"no"<<endl
#define _ <<' '<<
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){if(!a[lY].empty()){Vout(a[lY]);}else cout<<endl;}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define Verr(a) rep(iZ,0,a.size()-1)cerr<<a[iZ]<<' ';cerr<<a.back()<<endl
#define VVerr(a) rep(J,0,a.size()){if(!a[J].empty()){Verr(a[J]);}else cerr<<'.'<<endl;}
#define VPerr(a) rep(iX,0,a.size())cerr<<a[iX].FI<<' '<<a[iX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int scomb(int n, int r){if((n-r)<r)r=n-r;  //  nCr (小さい場合)
int a=1;for(int i=n;i>n-r;--i){a=a*i;}for(int i=1;i<r+1;++i){a=a/i;}return a;}
int comb(int n, int r){if((n-r)<r)r=n-r;  //  nCr (%MOD)
int a=1;for(int i=n;i>n-r;--i){a=a*i%MOD;}for(int i=1;
i<r+1;++i){a=a*mypow(i,MOD-2,MOD)%MOD;}return a%MOD;}
int stpow(int n){  //  階乗(%MOD)
if(n==0)return 1;int a=1;rep(i,1,n+1)a=a*i%MOD;return a;}
Vi stpowV(){Vi a(100001);  //  階乗配列(%MOD)
a[0]=1;repeq(i,1,100000)a[i]=a[i-1]*i%MOD;return a;}
void press(auto &v){v.erase(unique(ALL(v)),v.end());}  //  圧縮



signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int a,b;
  cin >> a >> b;
  
  if((a+b)%3!=0){cout<<0<<endl;return 0;}
  if(b > a*2){cout<<0<<endl;return 0;}
  if(a > b*2){cout<<0<<endl;return 0;}
  
  int ct = (a+b)/3;
  
  int yoko = a-ct;
  cout << comb(ct,yoko) << endl;
  
  return 0;
}

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

int main(void) {
  string a, b;
  cin >> a >> b;
  string s = a + b;
  int num = stoi(s);

  ll r = (ll)floor(sqrt((long double) num));
  if (r * r == num) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<queue>
#include <string>
#include <sstream>
#include <complex>
#include <cmath>
#include <algorithm>
using namespace std;



int main(){
    long n,i;
    cin  >> n >> i ;


    cout << (n-i+1);
    
    return 0;
}

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

using namespace std;

int main(void){
    
    int h, w;
    cin >> h >> w;
    
    vector<vector<int>> a(h, vector<int>(w));
    
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            cin >> a[i][j];
        }
    }
    
    vector<int> b(w);
    
    int sum;
    for(int i = 0;i < h;i++){
        sum = 0;
        for(int j = 0;j < w;j++){
            cout << a[i][j] << " ";
            sum += a[i][j];
        }
        cout << sum << endl;
    }
    
    for(int i = 0;i < w;i++){
        sum = 0;
        for(int j = 0;j < h;j++){
            sum += a[j][i];
        }
        cout << sum << " ";
        b[i] = sum; 
    }
    
    sum = 0;
    for(int i = 0;i < w;i++){
        sum += b[i];
    }
    
    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <string>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

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

//static const ll MOD = 1000000007;
//static const ll INF = 100000000;

int main() {
    ll n, answer = 0;
    string s;

    // input
    cin >> n >> s;

    // process
    if ((n % 2) == 1) {
        cout << "No" << endl;
        return 0;
    }

    for(ll i=0;i<n/2;i++){
        if(s[i]!=s[n/2+i]){
            cout << "No" << endl;
            return 0;
        }
    }


    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
import itertools
N = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
ite = [x for x in range(1, N + 1)]
ite = itertools.permutations(ite)
a = 0
b = 0
s = 1
for i in ite:
    if i == p:
        a = s
    if i == q:
        b = s
    s += 1
if a > b:
    total = a - b
else:
    total = b - a
print(total)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const int N = 3e3 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 3e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);

template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,a,b;
main() {
    file("exercise");
    ios;
    cin>>n>>a>>b;
    cout<<min(a*n,b);
    return 0;
}
/**

*/


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static FastReader s = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);

    private static int[] rai(int n) {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = s.nextInt();
        }
        return arr;
    }

    private static int[][] rai(int n, int m) {
        int[][] arr = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                arr[i][j] = s.nextInt();
            }
        }
        return arr;
    }

    private static long[] ral(int n) {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = s.nextLong();
        }
        return arr;
    }

    private static long[][] ral(int n, int m) {
        long[][] arr = new long[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                arr[i][j] = s.nextLong();
            }
        }
        return arr;
    }

    private static int ri() {
        return s.nextInt();
    }

    private static long rl() {
        return s.nextLong();
    }

    private static String rs() {
        return s.next();
    }
    static int gcd(int a,int b)
    {
        if(b==0)
        {
            return a;
        }
        return gcd(b,a%b);
    }


    public static void main(String[] args) {
        StringBuilder ans = new StringBuilder();
//        int t = ri();
        int t=1;
        while (t-- > 0) {
            int n=ri();
            long[] arr=ral(n);
            long max=arr[0];
            long res=0;
            for(long i:arr)
            {
                if(i<max)
                {
                    res+=max-i;
                }
                max=Math.max(max,i);
            }
            ans.append(res).append("\n");
        }
        out.print(ans.toString());
        out.flush();

    }

}


Measured memory_bytes: 56264
N,P = map(int,input().split())
from collections import defaultdict
elem = defaultdict(int)
tmpP = P
from math import sqrt
for i in range(2,int(sqrt(P))+1):
    while tmpP % i == 0:
        elem[i] += 1
        tmpP = tmpP//i
ans = 1
for k,v in elem.items():
    ans = ans * k ** (v//N)
if N == 1: ans = P
print(ans)

Measured memory_bytes: 3316
//abc068_b Break Number


#include <bits/stdc++.h>
using namespace std;

int main()
{
int N;

	cin >> N;

	if( N >= 64 )
		cout << 64 << endl;
	else if( N >= 32 )
		cout << 32 << endl;
	else if( N >= 16 )
		cout << 16 << endl;
	else if( N >= 8 )
		cout << 8 << endl;
	else if( N >= 4 )
		cout << 4 << endl;
	else if( N >= 2 )
		cout << 2 << endl;
	else
		cout << 1 << endl;

	return 0;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int a,b;
    while (1){
       cin>>a>>b;
        string s;
       if (a==0 && b==0) return 0;
       int m=b-2;
       int n=a-2;
        s.append (b,'#');
        s.append("\n");
        for (int i=1;i<=n;i++){
            s.append(1,'#');
            s.append(m,'.');
            s.append(1,'#');
            s.append ("\n");
        }
        s.append (b,'#');
        s.append("\n");

        cout<<s;
        cout<<"\n";
    }

    return 0;

}



Measured memory_bytes: 3248
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
    int n,k;
    scanf("%d%d",&n,&k);
    long long int ans=k;
    for(int i=1;i<n;i++){
        ans*=(k-1);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;
char str[maxn];
int main(void) {
    scanf("%s", str);
    ll len = strlen(str);
    sort(str, str + len);
    ll tot = 1;
    ll i, t;
    for(i = 0; i < len; i = t) {
        t = upper_bound(str + i + 1, str + len, str[i]) - str;
        if(t == len) break;
        tot += (t - i) * (len - t);
    }
    printf("%lld\n", tot);
}


Measured memory_bytes: 384
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}

	for i := n - 1; i > 0; i-- {
		fmt.Printf("%d ", a[i])
	}
	fmt.Println(a[0])
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<n; ++i)
#define FOR(i, a, b) for(int i=a; i<b; ++i)
#define FORR(i, a, b) for(int i=b-1; i>=a; --i)

int g[50][50];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, a, b;
	cin>>n>>m;
	REP(i, m){
		cin>>a>>b;
		g[a-1][b-1]=g[b-1][a-1]=1;
	}
	int c[10];
	REP(i, n){
		c[i]=i;
	}
	int ans=0;
	do{
		bool ok=true;
		REP(i, n-1){
			if(g[c[i]][c[i+1]]==0){
				ok=false;
				break;
			}
		}
		if(ok) ++ans;
	}while(next_permutation(c+1, c+n));
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int c = 0;
        Scanner sc = new Scanner(System.in);
        Double[] iData = new Double[8];

        int dataSet = sc.nextInt();
        while ( c < dataSet ) {
            for ( int i = 0; i < 8; i++ )
                iData[i] = sc.nextDouble();
            
            if ( (iData[3] - iData[1]) / (iData[2] - iData[0])
                 == (iData[7] - iData[5]) / (iData[6] - iData[4]) )
                System.out.println("YES");
            else
                System.out.println("NO");
            c++;
        }
    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    unsigned long a, b;
    cin >> a;
    b = 0;
    string s;
    cin >> s;
    b += (s[0] - '0') * 100;
    if (s[2]) b += (s[2] - '0') * 10;
    if (s[3]) b += (s[3] - '0');

    cout << (a * b) / 100 << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair <int, int> pii;
typedef vector<int> vi;

#define mp make_pair
#define pb push_back

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
 
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
 
const int MOD = 1000000007;
double PI = 4*atan(1);

string s;
int S,E,N,W;

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> s;
	for (char i: s) {
		if (i == 'S') S = 1;
		else if (i == 'E') E = 1;
		else if (i == 'N') N = 1;
		else W = 1;
	}
	if ((S+N) == 1 || (W+E) == 1) {
		cout << "No";
		return 0;
	} else cout << "Yes";
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int r, g, b;
	cin >> r >> g >> b;
	
	if( (100 * r + 10 * g + b ) % 4 == 0 ) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3624