akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int pwmd(int a, int n)
{
	if (!n)
		return 1;
	int pt = pwmd(a, n / 2);
	pt *= pt, pt %= mod;
	if (n & 1)
		pt *= a, pt %= mod;
	return pt;
}
int pow(int a,int b)
{
	int ans=1;
	while(b>0)
	{
		if(b&1)
			ans*=a;
		a*=a;
		b=b>>1;
	}
	return ans;
}
vector<pair<int,int>> vec;
bool compare(pair<int,int> v1,pair<int,int> v2)
{
	return v1.ss<v2.ss;
}
int32_t main()
{       
    FIO;
    int n;
    cin>>n;

    int a[n-1];
    memset(a,0,sizeof(a));
    int c[n+1];
    memset(c,0,sizeof(c));

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

   for(int i=1;i<=n;i++)
   	  cout<<c[i]<<endl;


    return 0;
}

Measured memory_bytes: 6784
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            int wa = A + B;
            int sa = A - B;
            int seki = A * B;

            int ans = Math.Max(wa, sa);
            ans = Math.Max(ans, seki);

            Console.WriteLine(ans);

        }
    }
}


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

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
	int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

int n, a, b;

int main() {
	read(n), read(a), read(b);
	write(min(a * n, b));
	putchar('\n');
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf(), getc(), ungetc()
#include <ctype.h>          // isdigit()
#include <stdbool.h>

#define MAX_N 2000000
#define swap(a, b) { int t; t = a; a = b; b = t; }

int heap[MAX_N];
int sz;

int
extract()
{
	int res = heap[0];
	int x = heap[--sz];
	int i = 0;
	while (i * 2 + 1 < sz)
	{
		int a = i * 2 + 1, b = i * 2 + 2;
		if (b < sz && heap[b] > heap[a])
			a = b;

		if (heap[a] <= x)
			break;

		heap[i] = heap[a];
		i = a;
	}

	heap[i] = x;
	return res;
}

void
insert(int x)
{
	int i = sz++;
	while (i > 0)
	{
		int p = (i - 1) / 2;
		if (heap[p] >= x)
			break;

		heap[i] = heap[p];
		i = p;
	}

	heap[i] = x;
}

int
main(int argc, char** argv)
{
	char command[8];
	int key;
	int n;
	int c;

	sz = 0;
	while (true)
	{
		scanf("%s", command);
		if (command[0] == 'e' && command[1] == 'n')
			break;

		else if (command[0] == 'e' && command[1] == 'x')
			printf("%d\n", extract());

		else if (command[0] == 'i')
		{
			n = 0;
			c = getc(stdin);
			while (c == ' ' || c == '\n')
				c = getc(stdin);
			
			while (isdigit(c))
			{
				n = 10 * n + c - '0';
				c = getc(stdin);
			}

			ungetc(c, stdin);
			key = n;
			insert(key);
		}
	}

	return 0;
}

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

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

    cin >> n;
    int i;
    for(i = 1; i <= 10; i++){
      if(1000*i >= n) 
        break;
    }
    cout << (1000*i-n);
}


Measured memory_bytes: 3636
#!/usr/bin/ruby
s=gets.chomp.bytes.map{|b|b-97}
n=gets.to_i
(s.size-1).times{|i|
	next if s[i]==0
	m=26-s[i]
	if n>=m
		n-=m
		s[i]=0
	end
}
s[s.size-1]=(s[s.size-1]+n)%26
puts s.map{|e|(e+97).chr}*''

Measured memory_bytes: 7668
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
template<class T>bool chmax(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; }
const long long INF = 1LL << 60;

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

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int modPow(long long a, long long n, long long p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}
int main()
{
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;

    int x = 60*c + d - 60*a - b;

    int ans = x - e;

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

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
 
int N,K;
int dp[2][1001][1001];
int dm[2][1001][1001];
int a[1000];
 
int main(){
  scanf("%d %d",&N,&K);
  for(int i=0;i<N;i++)scanf("%d",&a[i]);
  sort(a,a+N);
  fill( (int*)dp[0], (int*)dp[1], 1e9);
  int ans=1e9;
  for(int T=1;T<=K;T++){
    int t=T%2;
    int u=1-t;
    for(int i=0;i<N;i++){
      dp[0][i][i+1]=0;
      dp[1][i][i+1]=0;
    }
    for(int w=2;w<=N;w++){
      for(int i=0;i+w<=N;i++){
        int j=i+w;
        int si=i+1;
        int ti=j-1;
        if(w>2){
          si=dm[t][i][j-1];
          ti=dm[t][i+1][j];
        }
        dp[t][i][j]=1e9;
        for(int k=si;k<=ti;k++){
          if(dp[t][i][j] > dp[u][i][k]+dp[u][k][j]+a[j-1]-a[k-1]){
            dp[t][i][j]=dp[u][i][k]+dp[u][k][j]+a[j-1]-a[k-1];
            dm[t][i][j]=k;
          }
        }
      }
    }
  }
  printf("%d\n",dp[K%2][0][N]);
  return 0;
}

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

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

int main(void){
	int h, a;
	scanf("%d%d",&h,&a);
	printf("%d",(h-1)/a +1);
    return 0; 
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

#define CEILLL(x,y) (((x)+(y)-1)/(y))


int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    REP(i,0,N) cin >> A[i];

    DESC(A);
    ll ng = 0, ok = 1e9+1;
    while(abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        ll cnt = 0;
        REP(i,0,N) {
            cnt += (A[i] + mid - 1) / mid - 1;
        }
        if(cnt <= K) ok = mid;
        else ng = mid;
    }
    PR(ok);

    return 0;
}

/*

20 3 -> 6
21 3 -> 6
22 3 -> 7

ceil(A/X) - 1

*/

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

struct Item {
  int64 a, b;
  Item(int64 a, int64 b) : a(a), b(b) {}
};

int64 GCD(int64 a, int64 b) {
  if (a < b) return GCD(b, a);
  int64 r = a % b;
  if (r == 0) return b;
  else return GCD(b, r);
}

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

  int n;
  cin >> n;
  vector<Item> items;
  int64 a_sum = 0;
  for (int i = 0; i < n; i++) {
    int64 a, b;
    cin >> a >> b;
    items.emplace_back(a, b);
    a_sum += a;
  }
  sort(items.begin(), items.end(), [](const Item& item1, const Item& item2) {
    return max(item1.a, item1.b) > max(item2.a, item2.b);
  });

  int64 t_sum = 0;
  int64 t_count = 0;
  for (int i = 0; i < n; i++) {
    t_sum += max(items[i].a, items[i].b);
    t_count++;
    if (t_sum >= a_sum) break;
  }

  if (DEBUG) cout << "t_sum: " << t_sum << endl;
  if (DEBUG) cout << "t_count: " << t_count << endl;

  int64 max_num = 0;
  int64 max_den = 1;
  for (int i = 0; i < n; i++) {
    if (i < t_count) {
      if (t_sum - max(items[i].a, items[i].b) + items[i].b >= a_sum) {
        int64 r = a_sum - (t_sum - max(items[i].a, items[i].b));
        int64 num = items[i].b - r;
        int64 den = items[i].b;
        if (num * max_den > max_num * den) {
          max_num = num;
          max_den = den;
        }
      }
    } else {
      if (t_sum - max(items[t_count - 1].a, items[t_count - 1].b) + items[i].b
              >= a_sum) {
        int64 r =
            a_sum - (t_sum - max(items[t_count - 1].a, items[t_count - 1].b));
        int64 num = items[i].b - r;
        int64 den = items[i].b;
        if (num * max_den > max_num * den) {
          max_num = num;
          max_den = den;
        }
      }
    }
  }

  if (DEBUG) cout << "max_num: " << max_num << endl;
  if (DEBUG) cout << "max_den: " << max_den << endl;

  int64 ans_num = (n - (t_count)) * max_den + max_num;
  int64 ans_den = n * max_den;
  if (ans_num == 0) ans_den = 1;
  else {
    int64 d = GCD(ans_num, ans_den);
    ans_num /= d;
    ans_den /= d;
  }
  cout << ans_num << " " << ans_den << endl;
}

Measured memory_bytes: 2420
a = input()
if int(a[0]) > int(a[1]):
  print(a[0]+a[0]+a[0])
elif int(a[0]) == int(a[1]) and int(a[0]) >= int(a[2]):
  print(a[0]+a[0]+a[0])
else:
  b = str(int(a[0]) + 1)
  print(b+b+b)

Measured memory_bytes: 3064
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 100000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

struct line{double a,b,c; double grad;};

bool comp_grad(line l, line r){
  return l.grad>r.grad;
}

struct inv_num{
  vector<ll>bit;
  ll n;
  void init(ll _n){
    n = _n;
    bit.resize(2*n);
  }
  ll sum(ll i){
    ll s = 0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }
  void add(ll i, ll x){
    while(i<=n){
      bit[i]+=x;
      i+=i&-i;
    }
  }
  ll ans(ll* list, ll n){
    init(n);
    ll res = 0;
    REP(j,n){
      res+=j-sum(list[j]);
      add(list[j],1);
    }
    return res;
  }
};


int main(){
  ll n; cin >> n;
  line lines[n];
  REP(i,n){
    cin >> lines[i].a >> lines[i].b >> lines[i].c;
    lines[i].grad = -lines[i].a/lines[i].b;
  }
  sort(lines,lines+n,comp_grad);
  double lb = -INF, ub = INF, mid;
  REP(_,100){
    mid = (lb+ub)/2;
    pair<double,int> y[n];
    REP(i,n) y[i].first=(lines[i].c-lines[i].a*mid)/lines[i].b, y[i].second = i+1;
    //printf("%e %e %e\n",y[0].first, y[1].first, y[2].first);
    sort(y,y+n);
    ll a[n];
    REP(i,n) a[i]=y[i].second;
    inv_num inv;
    ll rev_num = inv.ans(a,n);
    if(rev_num<ceil(n*(n-1)/4.0)){
      lb = mid;
    }else{
      ub = mid;
    }
  }
  double ans_x = mid;

  REP(i,n) lines[i].grad = -lines[i].b/lines[i].a;
  sort(lines,lines+n,comp_grad);
  lb = -INF, ub = INF;
  REP(_,100){
    mid = (lb+ub)/2;
    pair<double,int> x[n];
    REP(i,n) x[i].first=(lines[i].c-lines[i].b*mid)/lines[i].a, x[i].second = i+1;
    //printf("%e %e %e\n",y[0].first, y[1].first, y[2].first);
    sort(x,x+n);
    ll a[n];
    REP(i,n) a[i]=x[i].second;
    inv_num inv;
    ll rev_num = inv.ans(a,n);
    if(rev_num<ceil(n*(n-1)/4.0)){
      lb = mid;
    }else{
      ub = mid;
    }
  }
  printf("%.10f %.10f\n",ans_x,mid);
  return 0;
}


Measured memory_bytes: 3084
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007

using namespace std;

bool cmpf(const pair<lli, lli> left, const pair<lli, lli> right) {
	return left.first < right.first;
}
bool cmps(const pair<lli, lli> left, const pair<lli, lli> right) {
	return left.second < right.second;
}
using namespace std;
lli n, m, p;

int getFib(int k, vector<lli> &memo,vector<lli> &vec) {
	lli ans=0;

	//cout << k << ' ' << vec[k] << endl;
	for (int i = 2;; i++) {
		if (i * k > n)break;
		if (memo[i * k] >=0)ans +=memo[i*k];
		else if (memo[i * k] == -1)ans+=(memo[i*k]=getFib(i * k, memo,vec));
	}
	if (k * 2 > n)return vec[k];
	else return ((ans % 2) != vec[k] ? 1:0);
}



int main() {

	cin >> n;
	vector<lli> vec(n+1),memo(n+1,-1);
	rep1(i, n)cin >> vec[i];

	memo[1]=getFib(1, memo,vec);
	
	lli ans = 0;
	rep1(i, n)ans += memo[i];
	cout << ans <<'\n';
	rep1(i, n)if(memo[i]==1)cout << i <<' ';

	

}


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

int main(){
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> a(n, vector<ll>(2));
    rep(i, n) cin >> a.at(i).at(0) >> a.at(i).at(1);
    sort(a.begin(), a.end());
    ll sum = 0;
    ll dsum = 0;
    rep(i, n){
        if(a.at(i).at(1) + dsum >= m){
            sum += (m-dsum)*a.at(i).at(0);
            break;
        }else{
            sum += a.at(i).at(0)*a.at(i).at(1);
            dsum += a.at(i).at(1);
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header
ll calc(P p1, P p2){
	ll ans = abs(p1.first -p2.first) + abs(p1.second - p2.second);
	return ans;
}
int main() {
	ll n, m;
	cin >> n >> m;
	vector<P> x(n);
	vector<P> y(m);
	rep(i,n) cin >> x[i].first >> x[i].second;
	rep(i,m) cin >> y[i].first >> y[i].second;
	for(auto k : x){
		ll min = INF, ans;
		rep(i,m){
			ll dist = calc(k, y[i]);
			if(dist < min){
				min = dist;
				ans = i+1;
			}
		}
		cout << ans << endl;
	}
 	return 0;
}

Measured memory_bytes: 3564
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,P[200001];
	scan(N);
	rep(i,N){
		scan(P[i]);
	}
	int m=INF;
	int ans=0;
	rep(i,N){
		if(P[i]<=m) ans++;
		m=min(m,P[i]);
	}
	prin(ans);
	return 0;
}


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

int main() {
  vector<string> vec;
  vec = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "k", "j", "l", "m", "n", "o",
         "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
  
  string C;
  cin >> C;
  
  for ( int i = 0; i < 26; i++) {
    
    if ( C == vec.at(i) ) {
      cout << vec.at(i + 1) << endl;
      break;
    }
  }
}
      

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

namespace ConsoleApp15
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();

            var grouped = line.GroupBy(x => x);

            if (grouped.First().Count() == 2 && grouped.Skip(1).First().Count() == 2)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13396
import sys
import pprint

pp = pprint.PrettyPrinter(indent=4)

def main():
    """ Code implementation """
    a, b = map(int, input().split())
    if b % a == 0:
        print(b + a)
    else:
        print(b - a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
from itertools import permutations
n, m = map(int, input().split())
g = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)
ans = 0
for order in permutations(range(1, n), n-1):
    seen = [False] * n
    seen[0] = True
    pre = 0
    for v in order:
        if v not in g[pre] or seen[v]:
            break
        pre = v
        seen[v] = True
    else:
        ans += 1
print(ans)

Measured memory_bytes: 9104
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll long long 
#define ull long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd long long
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
#define fre freopen("input.txt","r",stdin),freopen("output.txt","w",stdout)
using namespace std;
char a[10005];
int main(){
   boost;
   cin>>(a+1);
   ll f=1;
   ll s=0;
   ll ans=0;
   for(ll i=1;i<=3;i++){
   	   if(a[i]=='S'){
   	   	   f=0;
   	   	   ans=max(ans,s);
   	   	   s=0;
		}
		else{
			f=1;
			s++;
		}
   }
   if(f)ans=max(ans,s);
   cout<<ans;
}
	
 
    


Measured memory_bytes: 3580
fn main() {
    proconio::input! {
        n: usize,
        a: [u32; n],
    }
    let mut r = 0;

    let mut i = 0;
    while i < n {
        if a[i] % 2 == 1 {
            r += 1;
        }
        i += 2;
    }
    println!("{}", r);
}


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

using namespace std;
typedef long long ll;

int main(void) {
  ll N;
  cin >> N;

  for (ll h = 1; h <= 3500; h++) {
    for (ll n = 1; n <= 3500; n++) {
      ll p = 4 * h * n - N * (n + h);
      ll q = N * h * n;
      if (p > 0 && q % p == 0) {
        cout << h << " " << n << " " << q / p << endl;
        return 0;
      }
    }
  }

  return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────────────────

int facctorialMethod(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}

int main() {
	int n; cin >> n;
	vii pair(n);
	rep(i, n) cin >> pair[i].first >> pair[i].second;

	vi order(n);
	iota(ASC(order), 0);
	double min_ = 0;
	do {
		double ans = 0;
		for (int i = 0; i < n - 1; ++i) {
			double tmp = (pair[order[i]].first - pair[order[i + 1]].first) *
				(pair[order[i]].first - pair[order[i + 1]].first) +
				(pair[order[i]].second - pair[order[i + 1]].second) *
				(pair[order[i]].second - pair[order[i + 1]].second);
			ans += sqrtl(tmp);
		}
		//cout << ans << endl;
		min_ += ans;
	} while (next_permutation(ASC(order)));
	cout << std::fixed << std::setprecision(15) << min_ / facctorialMethod(n) << endl;
}

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

#define MOD 1000000007
#define ll long long int 
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

template <typename T>
void printvec(vector<T>& vec)
{
    for(int i=0;i<vec.size();++i){
        cout<<vec[i]<<" ";
    }
    cout<<endl;

}

struct ListNode {
    int val;
    ListNode *next;
    ListNode(int x) : val(x), next(NULL) {}
};
 
int main()
{
    int n;cin>>n;

    int happiness[n+1][3];

    for (int i = 0; i < n; ++i)
        {
          cin>>happiness[i+1][0]>>happiness[i+1][1]>>happiness[i+1][2];
        }    

    int dp[n+1][3];

    dp[1][0] = happiness[1][0];
    dp[1][1] = happiness[1][1];
    dp[1][2] = happiness[1][2];

    for (int i = 2; i <= n; ++i)
    {
      dp[i][0] = happiness[i][0] + max(dp[i-1][1], dp[i-1][2]);
      dp[i][1] = happiness[i][1] + max(dp[i-1][0], dp[i-1][2]);
      dp[i][2] = happiness[i][2] + max(dp[i-1][0], dp[i-1][1]);
    }

    cout<<max(dp[n][0], max(dp[n][1], dp[n][2]));

    return 0;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    set<int> s;
    for (int i = 0; i < n; i++)
    {
        int v;
        cin >> v;
        s.insert(v);
    }
    cout << (s.size() == n ? "YES" : "NO") << endl;
}


Measured memory_bytes: 9600
i=8;main(A,B,C,D){scanf("%1d%1d%1d%1d",&A,&B,&C,&D);while(i--)if(A+(i/4%2?-B:B)+(i/2%2?-C:C)+(i%2?-D:D)==7){char p[]={'+','-'};printf("%d%c%d%c%d%c%d=7\n",A,p[i/4%2],B,p[i/2%2],C,p[i%2],D);break;}}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int h,a;
    cin >> h >> a;
    int ans = h/a;
    if(h % a == 0) cout << ans << endl;
    else{
        ans += 1;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define int  unsigned long long int
#define tc int t; cin>>t; while(t--)
#define inn ll arr[n]; for(int i=0;i<n;i++) cin>>arr[i];
#define fora(i,n); for(int i=0;i<n;i++)
#define forb(i,a,n); for(int i=a;i<n;i++)
#define mod 1000000007
#define endl "\n"
#define F first
#define S second
#define vi vector<ll>
#define pii pair<ll,ll>
int32_t main()
{

int n;
cin>>n;
int arr[n+1];
fora(i,n+1) cin>>arr[i];
  if(n==0)
{
    if(arr[0]==1) cout<<1;
    else cout<<-1;
return 0;
}

    int cnt=0;
    bool flag=0;
    int minlevel[n+1]={0},maxlevel[n+1]={0};
    minlevel[n]=arr[n];
    maxlevel[n]=arr[n];
    for(int i=n;i>=1;i--) {
        int parents=maxlevel[i];
        parents+=arr[i-1];
        maxlevel[i-1]=parents;
        int parent2=minlevel[i]/2+(minlevel[i]%2!=0);
        parent2+=arr[i-1];
        minlevel[i-1]=parent2;

    }
    int define[n+1]={0};
    define[0]=1;
    for(int i=1;i<=n;i++) {
        int above=define[i-1];
        int net=2ULL*(above-arr[i-1]);

        if(net<minlevel[i]||(net>maxlevel[i]&&(net-maxlevel[i]>above-arr[i-1])))
        {   //cout<<net<<" "<<i<<"\n";
//        cout<<net-maxlevel[i]<<"\n";
//            cout<<i<<"\n";
            flag=1;
//            break;
        }
         define[i]=min(net,maxlevel[i]);



    }
//    for(auto it:minlevel) cout<<it<<" ";
//    cout<<"\n";
//    for(auto it:maxlevel) cout<<it<<" ";
//    cout<<"\n";
//    for(auto it:define) cout<<it<<" ";
//    cout<<"\n";
if(!flag)
cout<<accumulate(define,define+n+1,0ULL);
else cout<<-1;




return 0; }


Measured memory_bytes: 6708
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = float(10 ** 5)
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


class UnionFind:
    def __init__(self, n):
        # 負  : 根であることを示す。絶対値はランクを示す
        # 非負: 根でないことを示す。値は親を示す
        self.table = [-1] * n
        self.size = [1] * n
        # self.group_num = n

    def root(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.root(self.table[x])
            return self.table[x]

    def get_size(self, x):
        r = self.root(x)
        return self.size[r]

    def is_same(self, x, y):
        return self.root(x) == self.root(y)

    def union(self, x, y):
        r1 = self.root(x)
        r2 = self.root(y)
        if r1 == r2:
            return
        # ランクの取得
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.size[r1] += self.size[r2]
            if d1 == d2:
                self.table[r1] -= 1
        else:
            self.table[r1] = r2
            self.size[r2] += self.size[r1]


n, k, l = LI()

u1 = UnionFind(n)
u2 = UnionFind(n)
for _ in range(k):
    p, q = LI()
    u1.union(p - 1, q - 1)

for _ in range(l):
    r, s = LI()
    u2.union(r - 1, s - 1)


D = defaultdict(int)
for i in range(n):
    D[(u1.root(i), u2.root(i))] += 1

for j in range(n):
    print(D[(u1.root(j), u2.root(j))], end=" ")




Measured memory_bytes: 48100
fun main(args:Array<String>){
  var n = readLine()!!.toInt()
  var s = readLine()!!.toCharArray()
  var r = 0
  var b = 0
  for(i in 0..n-1){
    if(s[i].equals('R')) r++
    else b++
  }
  
  if(r>b){
    println("Yes")
  }
  else{
    println("No")
  }
}

Measured memory_bytes: 33476
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return sorted 約数s 1 <= x <= n
vector<ll> divv(ll n) {
  vector<ll> v;
  for(ll i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.push_back(i);
      if(i*i != n) v.push_back(n/i);
    }
  }
  sort(alll(v));
  return v;
}

int main() {
    ll n,m,l;
    cin>>n>>m;
    vector<ll> v(n);
    rep(i, n) {
        ll a;
        cin>>a;
        v[i] =a ;
    }
    vector<pair<ll,ll>> u;
    rep(i, m) {
        ll b,c;
        cin>>b>>c;
        u.push_back(make_pair(c,b));
    }
    sort(alll(v));
    reverse(alll(v));
    sort(alll(u));
    reverse(alll(u));
    // prr(v);
    // prr(u);
    vector<ll> y ;
    ll vc=0,uc=0;
    ll sum = 0;
    while(y.size()!=n) {
        // cout<<v[vc]<<" "<<u[uc]<<endl;
        if(u.size() > uc && v[vc] < u[uc].first) {
            y.push_back(u[uc].first);
            sum+=u[uc].first;
            if(u[uc].second  == 1) uc++;
            else u[uc].second--;
        } else {
            y.push_back(v[vc]);
            sum+=v[vc];
            vc++;
        }
    }
    pr(sum);
    return 0;
}

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

#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()

using namespace std;

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

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

    int N, D, A;
    cin >> N >> D >> A;
    vector<ll> X(N), H(N);
    vector<pii> XH(N);
    REP(i, N) {
        cin >> X[i] >> H[i];
        XH[i] = pii(X[i], H[i]);
    }
    sort(all(XH));
    REP(i, N) {
        tie(X[i], H[i]) = XH[i];
    }
        
    ll result = 0;
    ll atack = 0;
    vector<ll> acc(N + 1, 0);

    REP(i, N) {
        atack += acc[i];
        int life = max(H[i] - atack, 0ll);
        int cnt = (life + A - 1) / A;
        int j = distance(X.begin(), upper_bound(all(X), X[i] + 2 * D));
        acc[i] += A * cnt;
        acc[j] -= A * cnt;
        result += cnt;
        atack += A * cnt;
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 6528
# -*- coding: utf-8 -*-
def inpl(): return map(int, input().split())
N = int(input())

A = [int(input()) for _ in range(N)]
ans = 0

for i in range(N-1):
    d, m = divmod(A[i], 2)
    if m and A[i+1]>0:
        d += 1
        A[i+1] -= 1
    ans += d

ans += A[-1]//2
print(ans)

Measured memory_bytes: 7064
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <functional>
#include <string>
#include <utility>
#include <cstdio>
#include <cmath>
#include <deque>

#define REP(i,n) for(int i = 0; i < (n); ++i)
#define REP1(i,n) for(int i = 1; i <= (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
#define ALL(a) begin(a), end(a)
#define MP(a,b) make_pair((a), (b))
#define ROUNDUP(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second
#define DEBUG(a) cout << #a << ": " << a << "\n"
// #define DEBUG(a) {}

using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

constexpr int MOD = 1e9 + 7;
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 4 * 1e18 + 1;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

template<typename T>
T debug(T x) {
	DEBUG(x);
	return x;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	cin >> s;
	if(s[0] == s[1] && s[1] == s[2]) cout << "Yes\n";
	else if(s[1] == s[2] && s[2] == s[3]) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int A[100], n, i, j, t, sw = 0;

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

  for ( i = 0; i < n; i++ ){
    for ( j = n-1; j >= i+1; j-- ){
      if ( A[j] < A[j-1] ){
	t = A[j]; A[j] = A[j-1]; A[j-1] = t;
	sw++;
      }
    }
  }

  for ( i = 0; i < n; i++ ){
    if (i) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d\n", sw);

  return 0;
}



Measured memory_bytes: 2752
class Node:
    def __init__(self,name):
        self.name=name
        self.left=-1
        self.right=-1
        self.parent=-1



def mk_tree(Tree,p_order,in_order):
    tmp_p_order=[]
    tmp_in_order=[]
    root=p_order[0]#p_orderの先頭要素が、rootになる

    root_ind=0    
    while(in_order[root_ind] != root):
        root_ind+=1#in_orderでのrootのindexを返す 



    if(root_ind!=0):
        Tree[root].left=p_order[1]
        Tree[p_order[1]].parent=root
        tmp_in_order=in_order[0:root_ind]
        tmp_p_order=p_order[1:root_ind+1]
        mk_tree(Tree,tmp_p_order,tmp_in_order)

    if(root_ind!=len(p_order)-1):
        Tree[root].right=p_order[root_ind+1]
        Tree[p_order[root_ind+1]].parent=root
        tmp_in_order=in_order[root_ind+1:]
        tmp_p_order=p_order[root_ind+1:]
        mk_tree(Tree,tmp_p_order,tmp_in_order)
    


def Postorder(Tree,root,order):
    if(Tree[root].left!=-1):
        Postorder(Tree,Tree[root].left,order)
    if(Tree[root].right!=-1):
        Postorder(Tree,Tree[root].right,order)
    order.append(root)
       






n=int(input())
p_order=list(map(int,input().split()))
root=p_order[0]
in_order=list(map(int,input().split()))
Tree=[None]
for i in range(n):
   Tree.append(Node(i+1))

mk_tree(Tree,p_order,in_order)

#for i in range(1,n+1):
 #  print(f"id {i}: left = {Tree[i].left}, right = {Tree[i].right}, parent = {Tree[i].parent}")



post_order=[]
Postorder(Tree,root,post_order)
print(" ".join(list(map(str,post_order))))


Measured memory_bytes: 5612
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;

int odd_mx[]  = { 1, 1, 1,  0, -1,  0};
int even_mx[] = { 0, 1, 0, -1, -1, -1};
int my[]	  = {-1, 0, 1,  1,  0, -1};


int main()
{

	int H, W, cnt = 0;
	int MAP[102][102];
	bool visited[102][102];
	queue< pair<int, int> > search_info;

	memset(MAP, 0, sizeof(MAP));
	memset(visited, false, sizeof(visited));

	cin >> W >> H;
	for(int i = 1; i <= H; i++) {
		for(int j = 1; j <= W; j++) cin >> MAP[i][j];
	}

	search_info.push(make_pair(0, 0));
	visited[0][0] = true;

	while(!search_info.empty()) {
		pair<int, int> now = search_info.front();
		search_info.pop();

		for(int i = 0; i < 6; i++) {
			int nx = now.first  + (now.second % 2 ? odd_mx[i] : even_mx[i]);
			int ny = now.second + my[i];

			if(nx >= 0 && nx <= W + 1 && ny >= 0 && ny <= H + 1) {
				if(MAP[ny][nx]) {
					cnt++;
				}
			}
			if(nx >= 0 && nx <= W + 1 && ny >= 0 && ny <= H + 1 && !MAP[ny][nx] && !visited[ny][nx]) {
				visited[ny][nx] = true;
				search_info.push(make_pair(nx, ny));
			}
		}
	}

	cout << cnt << endl;

	return 0;

}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 1001001001;

int main(){
	int r, d, x; cin >> r >> d >> x;
	rep(i, 10){
		x = r * x - d;
		cout << x << endl;
	}
}

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

int main()
{
	long long int n;
	cin>>n;
	long long int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	long long int sumf=INT_MAX;

	for(int i=1;i<=100;i++)
	{
		long long int sum=0;
		for(int j=0;j<n;j++)
		{
			sum=sum+((a[j]-i)*(a[j]-i));
		}
		if(sum<=sumf)
		{
			sumf=sum;
		}
	}
	cout<<sumf;
}


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

int a, b, c, x, y;
int ans = 1e9+7;

int main(){
	cin >> a >> b >> c >> x >> y;
	for(int i=0; i<=max(x, y); ++i)
		ans = min(ans, 2*i*c + max(0, x-i)*a + max(0, y-i)*b);
/*	int mi = min(x, y);
	int ma = max(x, y);
	ans = ma*2*c;
	ans = min(ans, mi/2*2*2*c + (x-mi/2*2)*a + (y-mi/2*2)*b);
	ans = min(ans, x*a + y*b);
*/	cout << ans << endl;
}

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

int main(){
  int n;
  cin >> n;
  map<string,int> mp;
  
  rep(i,n){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    mp[s]++;
  }
  ll ans = 0;
  for(auto& p : mp){
    int s = p.second;
    ans += (ll)s*(s-1)/2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 11136
#include "bits/stdc++.h"
using namespace std;

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define REVREP(i, n)      for(ll i = n - 1; i >= 0 ; i--)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
//#define MOD             998244353
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a <= b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }

void Solve()
{
	ll N;
	cin >> N;
	VL A(N);
	REP(i, N) cin >> A[i];

	ll ans = 0;
	REP(i, N - 1) {
		if (A[i] > A[i + 1]) {
			ll ansOne = A[i] - A[i + 1];
			ans += ansOne;
			A[i + 1] = A[i];
		}
	}

	cout << ans << endl;

}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

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

    map<char,ll> D;
    bool f = true;
    REP(i,0,SZ(S)) ++D[S[i]];
    if(D['N'] == 0 && D['S'] != 0) f = false;
    if(D['S'] == 0 && D['N'] != 0) f = false;
    if(D['E'] == 0 && D['W'] != 0) f = false;
    if(D['W'] == 0 && D['E'] != 0) f = false;
    if(f) PR("Yes");
    else PR("No");

    return 0;
}

/*



*/

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

int check(int i, int j, int k, vector<int> &l){
  int flag = 0;
  if( l[i]!=l[j] && l[j]!=l[k] && l[k]!=l[i]) flag =1;
  if(flag==1){
    int maxl = max(l[i],l[j]);
    maxl = max(maxl, l[k]);
    if(maxl < l[i]+l[j]+l[k]-maxl) flag =2;
  }
  if(flag==2){
    return 1;
  } else {
    return 0;
  }
}

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

  vector<int> l(n);
  for(int i=0; i<n; i++){
    cin >> l[i];
  }

  int ans = 0;
  for(int i=0;i<n-2;i++){
    for(int j=i;j<n-1;j++){
      for(int k=j; k<n;k++){
	if(check(i,j,k,l)==1){
	  ans++;
	}
      }
    }
  }

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


Measured memory_bytes: 3576
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  int n, m;
  cin >> n >> m;
  vi p(m);
  vector<string> s(m);
  rep(i, m) cin >> p[i] >> s[i];
  rep(i, m) p[i]--;

  vi pe(n), ac(n);
  rep(i, m){
    if (s[i] == "AC") ac[p[i]] = 1;
    else if (!ac[p[i]]) pe[p[i]]++;
  }

  int ac_sum=0, pe_sum=0;
  rep(i, n){
    if (ac[i]) {
      ac_sum++;
      pe_sum += pe[i];
    }
  }
  cout << ac_sum << " " << pe_sum << endl;
  return 0;
}

Measured memory_bytes: 6912
#include<iostream>
using namespace std;
int main() {
    int x, y;
    while (1) {
        cin >> x >> y;
        if (x==0 && y ==0) break;
        if (x <= y) {
            cout << x << " " << y << endl;
        } else {
            cout << y << " " << x << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2984
//Swarina Jaiswal

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

#define ll long long
#define ld long double
#define endl "\n"
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout); 
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
void solve() {
   int n;
   cin>>n;

   cout<< !n <<endl;
}


int main() {
  #ifndef ONLINE_JUDGE
  OJ
  #endif
  fast;
    int t=1;
    //cin>>t;

    while(t--)
    solve();
 
return 0;  

}

Measured memory_bytes: 3636
import collections
import time


h, n = map(int, input().split())

INF = 10 ** 20

dp = collections.defaultdict(lambda : INF)
dp[0] = 0

magic = []

for i in range(n):
    magic.append(list(map(int, input().split())))


t = time.time()

que = [0]
cc = [0]
m = 0
c = 0
while que:
    next_que = set()
    for now_dam in que:
        for a, b in magic:
            dam = now_dam + a
            if dp[dam] > dp[now_dam] + b:
                dp[dam] = dp[now_dam] + b
                if h > dam:
                    next_que.add(dam)
    que = list(next_que)
ans = INF
# print(time.time() - t)

for k, v in dp.items():
    if k >= h:
        ans = min([v, ans])

print(ans)

# print(time.time() - t)


Measured memory_bytes: 46808
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stdio.h>

using namespace std;

typedef struct _line
{
    int x;
    int y;
} Line;
int cmp(const void* a, const void* b)

{
    Line* l1 = (Line*)a;
    Line* l2 = (Line*)b;
    return l1->y - l2->y;

}
int main()
{
    Line a[100000+10];
    int n;
    scanf("%d", &n);
    int i;
    for(i = 0; i < n; i++)
    {

        int x, y;
        scanf("%d%d", &x, &y);
        a[i].x = x-y;
        a[i].y = x+y;
    }
    qsort(a, n, sizeof(a[0]), cmp);
    int count = 0, j;
    for(i = 0; i < n; )
    {
        count++;
        for(j = i + 1; j < n; j++)
        {
            if(a[j].x >= a[i].y)
                break;
        }
        i = j;
    }
    printf("%d\n", count);
}




Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define name first
#define lt second

using namespace std;

const int MAXN=100000;

typedef pair<string,int> psi;

int main()
{
	queue<psi> que;
	int n,q;
	scanf("%d%d",&n,&q);
	for(int i=0;i<n;i++)
	{
		string s;
		int t;
		cin>>s>>t;
		que.push(make_pair(s,t));
	}
	int time=0;
	while(!que.empty())
	{
		psi qt=que.front();
		que.pop();
		if(qt.lt<=q)
		{
			time+=qt.lt;
			cout<<qt.name<<' '<<time<<endl;
		}
		else
		{
			time+=q;
			qt.lt-=q;
			que.push(qt);
		}
	}
	return 0;
}

Measured memory_bytes: 6332
n = int(input())
taro = 0
hana = 0
s=[]
ss=[]

for i in range(n):
    s = list(map(str, input().split()))
    # print(s)
    ss = sorted(s)
    # print(ss)

    if s[0] == s[1]:
        taro += 1
        hana += 1
    elif s == ss:
        hana += 3
    else:
        taro += 3
    

print("{} {}".format(taro, hana))




Measured memory_bytes: 5596