akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    int n,m,cnt=0;
    cin >> n >> m;
    int a[m];
    rep(i,m){
        cin >> a[i];
        cnt += a[i];
    } 
    if(0<=n-cnt) cout << n-cnt << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 3664
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String c = sc.next();
        if(c.equals ("a") ||c.equals ("i") ||c.equals("u") || c.equals("e") ||c.equals ("o")){
            System.out.println("vowel");
            }else{
                System.out.println("consonant");
            }
    }
}

Measured memory_bytes: 23252
#include<stdio.h>
#include<string>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>

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

int main(){
    char s[4]={};
    scanf("%s",s);
    int n=1;
    REP(i,3){
        if(s[i]==s[i+1])n=0;
    }
    if(n)printf("Good\n");
    else printf("Bad\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define N 200005
using namespace std;
int n, mn, mj, d[N], e[N], c[N], x[30];
string a, s;
int main() {
	int i, j;
	cin>>a;
	n = a.size();
	a = '.' + a;
	for(i=0; i<26; i++) x[i] = n+1;
	for(i=n; i>=0; i--) {
		mn = N;
		for(j=0; j<26; j++)
			if(d[x[j]] < mn) mn = d[x[j]], mj = j;
		d[i] = mn + 1;
		e[i] = x[mj];
		c[i] = mj;
		x[a[i]-'a'] = i;
	}
	for(i=0; i<=n; i=e[i]) s += c[i]+'a';
	cout<<s;
	return 0;
}
/////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 2880
import bisect

n, q = map(int, input().split())
s = input()
ans = []

for i in range(len(s)-1):
    if s[i] == "A" and s[i+1] == "C":
        ans.append(i+1)

for _ in range(q):
    l, r = map(int, input().split())
    L = bisect.bisect_left(ans, l)
    R = bisect.bisect_right(ans, r-1)
    print(R-L)

Measured memory_bytes: 5724
#include <bits/stdc++.h> 
    #include<ext/pb_ds/assoc_container.hpp> 
    #include<ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    using namespace std;
    template <typename T>
    using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
    #define int long long  
    typedef long double ld;
    #define pb push_back
    #define f(i,a,b) for(int i=a;i<b;i++)
    #define fd(i,a,b) for(int i=a-1;i>=b;i--)
    #define pf push_front
    #define fi first
    #define se second
     int mn=1e9+7;
    int cnt=0;
    vector<pair<int ,int >> v1,v2;  
    signed main() {
    ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("INPUT.txt", "r", stdin);
    // for writing output to output.txt
    freopen("OUTPUT.txt", "w", stdout);
    #endif
 
    // -------------------------------------Code starts here--------------------------------------------------------------------- 

   int n,m;
   cin>>n>>m;
   int a[m];
   int s=0;
   f(i,0,m)
   {
    cin>>a[i];
    s+=a[i];
   }
   if(s>n)
   {
    cout<<-1<<endl;
   }
   else
   {
    cout<<n-s<<endl;
   }
}

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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

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

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

        int N, M;
        std::cin >> N >> M;

        vector<vector<int>> S(M);
        REP(i, M) {
            int k;
            std::cin >> k;
            S[i].resize(k);
            REP(j, k) {
                std::cin >> S[i][j];
                S[i][j]--;
            }
        }

        vector<int> P(M);
        REP(i, M) {
            std::cin >> P[i];
        }

        int ans = 0;
        for(int i = 0; i < (1 << N); i++) {
            vector<int> cnt(M, 0);
            for(int j = 0; j < N; j++) {
                if(i & (1 << j)) {
                    REP(k, M) {
                        for(const auto& v : S[k]) {
                            if(v == j) {
                                cnt[k]++;
                            }
                        }
                    }
                }
            }
            bool is_ok = true;
            REP(j, M) {
                if(P[j] != cnt[j] % 2) {
                    is_ok = false;
                    break;
                }
            }
            if(is_ok) {
                ans++;
            }
        }

        std::cout << ans << std::endl;
    }
    catch(const exception& e) {
        std::cout << e.what() << std::endl;
        exit(1);
    }
    return 0;
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#include <queue>
#define INF 1e10
struct edge{ll to; double cost;};
typedef pair<double,ll> P;

struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<double> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    for(int i = 0; i < V; i++){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, double cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    for(int i = 0; i < V; i++){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  double sx , sy , gx , gy;

  cin >> sx >> sy >> gx >> gy;
  int n;
  cin >> n;
  vector<double> x(n),y(n),r(n);
  rep(i,n) cin >> x[i] >> y[i] >> r[i];
  graph g(n+2);
  rep(i,n) {
    FOR(j,i+1,n){
      double dist = pow( x[i] - x[j] , 2) + pow(y[i] - y[j], 2);
      double rpow = pow( r[i] + r[j] , 2);
      // case : コスト0
      if(rpow >= dist){
        g.add_edge(i,j,0);
        g.add_edge(j,i,0);
      }else{
        g.add_edge(i,j,sqrt(dist) - r[i] - r[j]);
        g.add_edge(j,i,sqrt(dist) - r[i] - r[j]);
      }
    }
    // s -> i
    {
      double dist = pow( x[i] - sx , 2) + pow(y[i] - sy, 2);
      double rpow = pow( r[i] , 2);
      if(rpow >= dist){
        g.add_edge(i,n,0);
        g.add_edge(n,i,0);
      }else{
        g.add_edge(i,n,sqrt(dist) - r[i] );
        g.add_edge(n,i,sqrt(dist) - r[i] );
      }
    }
    // g -> i
    {
      double dist = pow( x[i] - gx , 2) + pow(y[i] - gy, 2);
      double rpow = pow( r[i] , 2);
      if(rpow >= dist){
        g.add_edge(i,n+1,0);
        g.add_edge(n+1,i,0);
      }else{
        g.add_edge(i,n+1,sqrt(dist) - r[i] );
        g.add_edge(n+1,i,sqrt(dist) - r[i] );
      }
    }
  }
  // g -> s
  {
    double dist = pow( gx - sx , 2) + pow(gy - sy, 2);
    g.add_edge(n,n+1,sqrt(dist) );
    g.add_edge(n+1,n,sqrt(dist) );
  }
  g.dijkstra(n);
  printf("%.10lf\n",g.d[n+1]);
  return 0;
}


Measured memory_bytes: 21652
import sys
import math

ALPHABET = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
result = []

def alphabet_decimal(v):
    quotient = math.floor(v / len(ALPHABET))
    surplus = v % len(ALPHABET)
    quotient -= 1 if surplus == 0 else 0
    surplus = len(ALPHABET) if surplus == 0 else surplus
    result.append(surplus)
    if len(ALPHABET) < quotient:
        alphabet_decimal(quotient)
    elif len(ALPHABET) < v:
        result.append(quotient)
    return "".join([ALPHABET[i - 1] for i in reversed(result)])

N = input()
ans = alphabet_decimal(int(N))
print(ans.lower())


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


int main() {
    ll a;
    double b;
    cin>>a>>b;
    int b2=int(llround(b*100));
    cout<<ll(a*b2/100);
    return 0;
}

Measured memory_bytes: 3656
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9

int main() {
	int n;
	cin >> n;
	cout << pow(n, 3) << endl;
	return 0;
}

Measured memory_bytes: 256
n = STDIN.gets.to_i
x = STDIN.gets.split.map(&:to_i)

sum = x.inject(&:+)
ave = sum / n

avem = ave - 1
avep = ave + 1

ret0 = ret1 = ret2 = 0
x.each do |v|
  ret0 += (v - avem)**2
  ret1 += (v - ave)**2
  ret2 += (v - avep)**2
end

puts [ret0, ret1, ret2].min


Measured memory_bytes: 3836
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    int a[10];
    for (int j=0;j<10;j++)
    cin >> a[j];
    int left,right; left = a[0];
    right = 0;
    for (int j=1;j<10;j++){
      if(a[j]<left && a[j]<right){
        cout << "NO" << endl; break;
      } else{
        if(j==9){
          cout << "YES" << endl; break;
        } else{
          if(a[j]>left && a[j]<right)
            left = a[j];
          else{
            if(a[j]<left && a[j]>right)
              right = a[j]; else{ if(left<right) right = a[j];
          else left = a[j];
          }
          }
          }
          }
    }
  }
} 


Measured memory_bytes: 2984
s=input()
for i in range(len(s)-1):
    if s[i]==s[i+1]:
        print(i+1,i+2)
        exit()
for i in range(len(s)-2):
    if s[i]==s[i+2]:
        print(i+1,i+3)
        exit()
print(-1,-1)

Measured memory_bytes: 3188
//%std
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define y1 ysgh
#define endl '\n'
inline int read()
{
	int out = 0, fh = 1;
	char jp = getchar();
	while ((jp > '9' || jp < '0') && jp != '-') jp = getchar();
	if (jp == '-')
		fh = -1, jp = getchar();
	while (jp >= '0' && jp <= '9') out = out * 10 + jp - '0', jp = getchar();
	return out * fh;
}
void print(int x)
{
	if (x >= 10)
		print(x / 10);
	putchar('0' + x % 10);
}
void write(int x, char c)
{
	if (x < 0)
		putchar('-'), x = -x;
	print(x);
	putchar(c);
}
namespace Module
{
	const int P = 998244353;
	int add(int a, int b, int Mod = P) {return a + b >= Mod ? a + b - Mod : a + b;}
	void inc(int &a, int b, int Mod = P) {a = add(a, b, Mod);}
	void dec(int &a, int b, int Mod = P) {a = add(a, P - b, Mod);}
	int mul(int a, int b, int Mod = P) {return 1LL * a * b % Mod;}
	int fpow(int a, int b, int Mod = P)
	{
		int res = 1;
		while (b)
		{
			if (b & 1) res = mul(res, a, Mod);
			a = mul(a, a, Mod);
			b >>= 1;
		}
		return res;
	}
}
using namespace Module;
const int N = 1 << 19 | 10, Mod = 200003;
const double PI = acos(-1.0);
struct cp
{
	double r, i;
	cp(double r = 0, double i = 0) : r(r), i(i) {}
	cp operator + (const cp &rhs) const
	{
		return cp(r + rhs.r, i + rhs.i);
	}
	cp operator - (const cp &rhs) const
	{
		return cp(r - rhs.r, i - rhs.i);
	}
	cp operator * (const cp &rhs) const
	{
		return cp(r * rhs.r - i * rhs.i, r * rhs.i + i * rhs.r);
	}
	cp conj()
	{
		return cp(r, -i);
	}
};
int rev[N];
cp omega[N], inv[N];
void DFT(cp *a, int n, int invflag)
{
	for(int i=0;i<n;++i)
		if(i<rev[i])
			swap(a[i],a[rev[i]]);
	for(int l=2;l<=n;l<<=1)
	{
		int m=l>>1;
		cp gi=omega[l];
		if(invflag)
			gi=inv[l];
		for(cp *p=a;p!=a+n;p+=l)
		{
			cp g=cp(1,0);
			for(int i=0;i<m;++i)
			{
				cp t=g*p[i+m];
				p[i+m]=p[i]-t;
				p[i]=p[i]+t;
				g=g*gi;
			}
		}
	}
	if(invflag)
	{
		for(int i=0;i<n;++i)
			a[i].r/=n,a[i].i/=n;
	}
}
cp A[N];
void FFT(ll *a)
{
	int n = 1 << 19;
	int m = Mod - 1;
	for (int i = 0; i < m; ++i)
		A[i] = cp(a[i], 0);
	DFT(A, n, 0);
	for (int i = 0; i < n; ++i)
		A[i] = A[i] * A[i];
	DFT(A, n, 1);
	for (int i = 0; i < 2 * m; ++i)
		a[i] = (ll)(A[i].r + 0.5);
}
void init()
{
	int n = 1 << 19;
	for (int i = 0; i < n; ++i)
		rev[i] = (rev[i >> 1] >> 1) | ((i & 1) * (n >> 1));
	for (int l = 2; l <= n; l <<= 1)
		omega[l] = cp(cos(PI * 2 / l), sin(PI * 2 / l)), inv[l] = omega[l].conj();
}
int n, a[N], g = 2, ord[N], pw[N];
ll b[N];
unsigned long long ans = 0;
int main()
{
	init();
	n = read();
	for (int i = 1; i <= n; ++i)
		a[i] = read();
	int cur = 1;
	for (int i = 0; i < Mod - 1; ++i)
		ord[cur] = i, cur = mul(cur, g, Mod);
	pw[0] = 1;
	for (int i = 1; i < Mod; ++i)
		pw[i] = mul(pw[i - 1], g, Mod);	
	for (int i = 1; i <= n; ++i) if (a[i])
		++b[ord[a[i]]];
	FFT(b);
	for (int i = 0; i < 2 * (Mod - 1); ++i)
		ans += (1ULL) * b[i] * pw[i >= Mod - 1 ? i - (Mod - 1) : i];
	for (int i = 1; i <= n; ++i)
		ans -= mul(a[i], a[i], Mod);
	ans >>= 1;	
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 36012
#include<iostream>
#include<iomanip>
#include<string>
#include<cmath>

using std::cout;
using std::cin;
using std::endl;
using std::pow;
using std::string;

int main(){
    double A,B,H,M;
    double a,theta;
    cin >> A >> B >> H >> M;
    theta = (H/12 * 2*M_PI + M/(60*12) * 2*M_PI) - M/60 * 2*M_PI;
    a = sqrt(A*A + B*B - 2*A*B*cos(theta));
    cout << std::fixed << std::setprecision(10) << a;
}

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

int lcm(int a, int b) {
  return a / __gcd(a, b) * b;
}

int main() {
  int N, M;
  cin >> N >> M;
  int A[1001];
  for(int i = 0; i < N; i++) cin >> A[i];
  int LCM = lcm(N, M);
  int mn = 0, mx = 0, sum = 0;
  for(int i = 0; i < LCM; i++) {
    if(i%M == 0) {
      sum += mx - mn;
      mn = 10000;
      mx = 0;
    }
    mn = min(mn, A[i%N]);
    mx = max(mx, A[i%N]);
  }
  cout << sum + (mx != 10000 ? mx - mn : 0) << endl;
}

Measured memory_bytes: 3108
#include <stdio.h>

int main(void)
{
	int i=1;
	int a, b;

	
	while(1){
		scanf("%d%d", &a, &b);
		if(a==0 && b==0)
			break;
		if(a<b)
			printf("%d %d\n", a, b);
		else
			printf("%d %d\n", b, a);
	}

	return 0;

}

Measured memory_bytes: 600
n = int(input())
li_c = input()
r_index = [i for i,x in enumerate(li_c) if x=="R"]
w_index = [i for i,x in enumerate(li_c) if x=="W"]
r_num = len(r_index)
w_num = len(w_index)

R = r_num
W = 0
ans = max(R, W)
for i in range(n):
    if li_c[i]=="R":
        R -= 1
    else:
        W += 1
    ans = min(ans, max(R, W))
print(ans)

Measured memory_bytes: 17276
#include<iostream>
#include<algorithm>
#include<string.h>
#include<map>
#include<queue>
#include<cmath>
#include<stack>
#include<cstdio>
#include<vector>
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
const int maxn=1e5+5;
ll n,a[maxn],b[maxn];
ll ans;
int main()
{
	cin>>n;
	for(int i=0;i<=n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
	{
		cin>>b[i];
		if(a[i]+a[i+1]<=b[i])
		{
			ans+=a[i]+a[i+1];
			a[i]=a[i+1]=0;
		}
		else
		{
			if(a[i]<=b[i])
			{
				ans+=a[i];
				b[i]-=a[i];
				a[i]=0;
				ans+=b[i];
				a[i+1]-=b[i];
			}
			else
			{
				ans+=b[i];
				b[i]=0;
				a[i]-=b[i];
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

#define dump(x) cerr << #x << " : " << x << '\n'
#define MOD(x, y) (((y) + (x) % (y)) % (y))

void rec(int l, char L, int r, char R) {
	int m = (l + r) / 2;
	printf("%d\n", m);
	fflush(stdout);
	char s[10];
	scanf("%s", s);
	char c = s[0];
	if (c == 'V') return;
	bool LL = false;
	if ((m - l) % 2 == 0 && c == L || (m - l) % 2 == 1 && c != L) {
		LL = true;
	}
	bool RR = false;
	if ((r - m) % 2 == 0 && c == R || (r - m) % 2 == 1 && c != R) {
		RR = true;
	}
	if (LL && !RR) {
		rec(l, L, m - 1, c);
	} else {
		rec(m + 1, c, r, R);
	}
}

int main(int argc, char* argv[])
{
	int N;
	scanf("%d", &N);
	char s[10];
	printf("0\n");
	fflush(stdout);
	scanf("%s", s);
	char R = s[0];
	printf("%d\n", N - 1);
	fflush(stdout);
	scanf("%s", s);
	char L = s[0];
	if (L == 'V' || R == 'V') {
		return 0;
	}
	rec(0, L, N - 1, R);

	return 0;
}


Measured memory_bytes: 852
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

template <class T>
inline void eraque(std::vector<T>& vec) {
  vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
  return;
}

template <class T>
inline int lower_position(const std::vector<T>& vec, T val) {
  return static_cast<int>(std::distance(
      vec.begin(), std::lower_bound(vec.begin(), vec.end(), val)));
}

template <class T>
inline int upper_position(const std::vector<T>& vec, T val) {
  return static_cast<int>(std::distance(
      vec.begin(), std::upper_bound(vec.begin(), vec.end(), val)));
}

template <class T>
inline std::string to_binary(T n) {
  assert(n > 0);
  std::string ret = "";
  while (n) ret += (n & 1) ? '1' : '0', n >>= 1;
  std::reverse(ret.begin(), ret.end());
  return ret;
}

template <class T>
inline void println(T val) {
  std::cout << val << '\n';
}

template <class T>
inline void println(const std::vector<T>& vec) {
  int sz = vec.size();
  for (int i = 0; i < sz; ++i) std::cout << vec[i] << " \n"[i == sz - 1];
}

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

template <class T, class U>
std::istream& operator>>(std::istream& is, std::pair<T, U>& p) {
  return is >> p.first >> p.second;
}

template <class Tuple, std::size_t... Is>
void tuple_in(std::istream& is, Tuple& tp, std::index_sequence<Is...>) {
  ((is >> std::get<Is>(tp)), ...);
}

template <class... Args>
std::istream& operator>>(std::istream& is, std::tuple<Args...>& tp) {
  tuple_in(is, tp, std::index_sequence_for<Args...>{});
  return is;
}

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

  int n; cin >> n;
  vector<int> a(n); cin >> a;
  int64 ans = 0;
  int mx = a[0];
  for (int i = 1; i < n; ++i) {
    if (a[i] < mx) {
      ans += (mx - a[i]);
    } else {
      mx = a[i];
    }
  }

  println(ans);

  return 0;
}


Measured memory_bytes: 3940
N = int(input())

An = sorted(map(int, input().split()))
Bn = sorted(map(int, input().split()))
Cn = sorted(map(int, input().split()))


def f(xn, yn, zn):
    tn = [0] * N
    num = 0
    j = N - 1

    for i in range(N - 1, -1, - 1):
        while 0 <= j and xn[i] < yn[j]:
            num += zn[j]
            j -= 1
        tn[i] = num

    return tn


def main():
    Zn = [1] * N

    Zn = f(Bn, Cn, Zn)
    Zn = f(An, Bn, Zn)

    print(sum(Zn))
    return


main()


Measured memory_bytes: 24052
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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 maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}

vector<ll> pw2(51,1);vector<ll> pw10(19,1);
int main(){
    {rep1(i,50) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N,M; cin>>N>>M;
    ll ans=0;
    
    // ken[市]:
    vector<ll> ken(M+1,0);
    vector<ll> number(M+1,0);
    set<P> se[100001]; //県毎に
    rep1(i,M){
        ll p,Y; cin>>p>>Y;
        ken[i]=p;
        se[p].insert(P(Y,i));
    }
    
    rep1(i,N){
        ll count=1;
        for(auto it=se[i].bg;it!=se[i].ed;it++){
            number[(*it).b]=count++;
        }
    }
    
    rep1(i,M){
        printf("%06lld",ken[i]);
        printf("%06lld",number[i]);
        cout<<endl;
    }
}




Measured memory_bytes: 15648
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=2000010;
const ll mod=1e9+7;

struct UnionFind {  
  vector<int> par,sizes;                     // par[i]:iの親の番号(ex)par[3]=2 : 3の親が2
  UnionFind(int n) : par(n),sizes(n,1)  {    //最初は全てが根であるとして初期化
    for(int i=0; i<n; i++){ par[i]=i; }  
  }
  int root(int x) {                       //xが属する木の根を再帰で得る:root(x)={xの木の根}
    if(par[x]==x){ return x; }
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {                 // xとyの木を併合
    int rx = root(x);                        //xの根をrx
    int ry = root(y);                        //yの根をry
    if(rx == ry){ return; }                  //xとyの根が同じ(=同じ木にある)時はそのまま
    if(sizes[rx]<sizes[ry]){ swap(rx, ry); } //xの木をおおきくする
    par[ry] = rx; 
    sizes[rx] += sizes[ry];                  //sizes[ry]はもう使わない
  }
  bool check(int x, int y) {                 // x,yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
  int size(int x){                           //xが含まれる木の大きさを返す
    return sizes[root(x)];
  }
};

int main(){
  int n;
  cin >> n;
  vector<P> x(n),y(n);
  rep(i,n){
    cin >> x[i].F >> y[i].F;
    x[i].S = y[i].S = i;
  }
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());

  vector<pair<int,P>> v;
  rep(i,n-1){
    v.push_back({x[i+1].F-x[i].F, {x[i].S, x[i+1].S}});
    v.push_back({y[i+1].F-y[i].F, {y[i].S, y[i+1].S}});
  }
  sort(v.begin(),v.end());
  UnionFind uf(n);
  ll ans = 0;
  for(auto it:v){
    if(!uf.check(it.S.F,it.S.S)){
      uf.unite(it.S.F,it.S.S);
      ans += it.F;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6516
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <unordered_map>
using namespace std;

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

const int maxn = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

#define dbg(x1) cout<<#x1<<" = "<<(x1)<<endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<(x1)<<" "<<#x2<<" = "<<(x2)<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<(x1)<<" "<<#x2<<" = "<<(x2)<<" "<<#x3<<" = "<<(x3)<<endl
void ask(ll x)
{
    printf("? %lld\n",x);
    fflush(stdout);
}
void res(ll x)
{
    printf("! %lld\n",x);
    fflush(stdout);
}
char op[2];
bool check(ll x)
{
    ask(x);
    scanf("%s",op);
    return (op[0]=='Y');
}
ll po[11];
int main() {
    //freopen(".in", "r", stdin);
    po[0]=1;
    for(int i=1;i<=10;i++) po[i]=po[i-1]*10;
    int pos=-1;
    ll ans;
    for(int i=0;i<=10;i++)
    {
        ask(po[i]);
        scanf("%s",op);
        if(op[0]=='N')
        {
            pos=i;
            ans=po[i];
            break;
        }
    }
    if(pos==-1)
    {
        for(int i=0;i<=10;i++)
        {
            ask(po[i]+1);
            scanf("%s",op);
            if(op[0]=='Y')
            {
                ans=po[i];
                break;
            }
        }
        res(ans);
    }
    else
    {
        ll ans=0;
        for(int i=1;i<=pos-1;i++)
        {
            int l=0,r=9;
            while(l<=r)
            {
                int mid=l+r>>1;
                if(check(ans*10LL+mid)) l=mid+1;
                else r=mid-1;
            }
            ans = ans *10LL + r;
        }
        ans = ans*10LL;
        int flag=0;
        ans=ans*10LL;
        for(int i=9;i>=0;i--)
        {
            if(check(ans+i*10LL)) flag=i;
            else break;
        }
        res((ans+flag*10)/10);
    }

    return 0;
}



Measured memory_bytes: 684
a = input();
s = input().split()
b = 0;
c = True;
d = 0;
while c:
    d = 0
    for i in range(len(s)):
        if int(s[i]) % 2 == 0:
            s[i] = int(s[i]) / 2
            d = d + 1
        else:
            c = False
            break;
        if d == len(s):
            b = b + 1
print(b)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	string s;
	getline(cin, s);
	REP(i, s.size()) {
		if ('a' <= s[i] && s[i] <= 'z') {
			s[i] = s[i]+'A'-'a';
		}
	}
	cout << s << endl;
}

Measured memory_bytes: 3208
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back







int main()
{


	ll n, w;
	cin >> n >> w;

	ll wts[n + 1];
	ll vals[n + 1];
	ll max_val = 0;
	for (int i = 1; i <= n; i++)
	{	cin >> wts[i];
		cin >> vals[i];
		max_val += vals[i];
	}


	ll dp[n + 1][max_val + 1];



	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j <= max_val; j++)
		{
			dp[i][j] = INT_MAX;
		}
	}

	for (int i = 0; i <= n; i++)
		dp[i][0] = 0;

	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= max_val; j++)
		{
			if (j - vals[i] >= 0)
				dp[i][j] = min(dp[i - 1][j - vals[i]] + wts[i], dp[i - 1][j] );
			else
				dp[i][j] = dp[i - 1][j];
		}
	}

	int ans = 0;

	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= max_val; j++)
		{
			if (dp[i][j] <= w)
				ans = max(ans, j);
		}
	}
	cout << ans << endl;

}





Measured memory_bytes: 79104
#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 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;

bool comp(p left, p right){
  return left.first < right.first;
}

int main(){
  ll n,w;
  cin >> n >> w;
  p input[n];
  REP(i,n) cin >> input[i].second >> input[i].first;
  ll m = n/2;
  vector<p> first;
  vector<p> last;
  REP(i,1<<m){
    ll weight = 0, value = 0;
    REP(j,m){
      if(i>>j&1){
        weight += input[j].first;
        value += input[j].second;
      }
    }
    first.push_back(p(weight,value));
  }
  REP(i,1<<(n-m)){
    ll weight = 0, value = 0;
    REP(j,n-m){
      if(i>>j&1){
        weight += input[j+m].first;
        value += input[j+m].second;
      }
    }
    last.push_back(p(weight,value));
  }
  sort(first.begin(),first.end());
  sort(last.begin(),last.end());
  ll prev_v, prev_w;
  vector<p> first_cpy;
  REP(i,first.size()){
    if(i==first.size()-1||(i!=first.size()-1&&first[i].first<first[i+1].first)){
      if(i==0||first_cpy.back().second<first[i].second) first_cpy.push_back(p(first[i].first,first[i].second));
    }
    prev_w = first[i].first, prev_v = first[i].second;
  }
  vector<p> last_cpy;
  REP(i,last.size()){
    if(i==last.size()-1||(i!=last.size()-1&&last[i].first<last[i+1].first)){
      if(i==0||last_cpy.back().second<last[i].second) last_cpy.push_back(p(last[i].first,last[i].second));
    }
    prev_w = last[i].first, prev_v = last[i].second;
  }
  ll ans = 0;
  REP(i,first_cpy.size()){
    if(first_cpy[i].first>w) continue;
    ll itr = upper_bound(last_cpy.begin(),last_cpy.end(),p(w-first_cpy[i].first,0),comp)-last_cpy.begin();
    ans = max(ans, first_cpy[i].second+last_cpy[itr-1].second);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 43772
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  int n;
  cin >> n;
  string s,t;
  cin >> s;
  cin >> t;
  string ans="";
  for(int i=0;i<n;i++){
    ans += s[i];
    ans += t[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }
 
 
 
int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  rep(i,sz(s)) cout << "x";
  cout  << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(void) {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> cost(N+1);
    for(int i=0; i<M; i++) {
        int A;
        cin >> A;
        cost[A]++;
    }
    partial_sum(cost.begin(), cost.end(), cost.begin());
    cout << min(cost[X], cost[N] - cost[X]) << endl;
    return 0;
}


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

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pii;

#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)

int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> AC(N+1);
    vector<ll> WA(N+1);
    REP(i,0,M){
        ll p;
        string s;
        cin >> p >> s;
        if(s=="AC"){
            AC[p]=1;
        }else if(AC[p] == 0){
            WA[p]++;
        }
    }
    ll aac = accumulate(AC.begin(), AC.end(), 0LL);
    ll awa = inner_product(AC.begin(), AC.end(), WA.begin(), 0LL);
    cout << aac << " " << awa <<  endl;

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <cstdio>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
using namespace std;

double d;

int main(void) {
  cin >> d;

  double ans = d;
  int s = 1;
  while(s * s <= d * d) {
    double t = sqrt(d * d - s * s);
    ans = max(ans, s + max(1.0, t));
    s++;
  }
  ans = max(ans, d * sqrt(2));

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

  return 0;
}

Measured memory_bytes: 3244
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define vec vector
typedef long long ll;
typedef pair<ll,ll> P;
//const ll big=998244353;
const ll big=1000000007LL;
const ll INF=1e18;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}

struct unionfind{
    vector<int> par;
    unionfind(int n): par(n,-1){};
    int find(int x){
        if(par[x]==-1)return x;
        return par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y)return;
        par[x]=y;
        return;
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
};

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    int n,q;cin >> n >> q;
    unionfind uf(n);
    rep(i,q){
        int t,u,v;cin >> t >> u >> v;
        if(t==0)uf.unite(u,v);
        else cout << uf.same(u,v) << endl;
    }
}

Measured memory_bytes: 3956
#include<stdio.h>
int a[100][100],b[100][100],s=0,c1,c2,c3,v=0;
void reset(void);
main()
{
	int r,c;
	
	reset();
	
	scanf("%d %d",&r,&c);
	
	for(c1=0;c1<r;c1++){
		for(c2=0;c2<c;c2++){
			scanf("%d",&a[c1][c2]);
		}
	}
	
	for(c1=0;c1<r;c1++){
		for(c2=0;c2<c;c2++){
			printf("%d ",a[c1][c2]);
		}
		for(c3=0;c3<c;c3++){
			s+=a[c1][c3];
		}
		v+=s;
		printf("%d\n",s);
		s=0;
	}
	for(c1=0;c1<c;c1++){
		for(c2=0;c2<r;c2++){
			s+=a[c2][c1];
		}
		printf("%d ",s);
		s=0;
	}
	printf("%d",v);
	
	printf("\n");
	
	return 0;
}

void reset(void){
	for(c1=0;c1<100;c1++){
		for(c2=0;c2<100;c2++){
			a[c1][c2]=0;
			b[c1][c2]=0;
		}
	}
}

Measured memory_bytes: 680
s = input()
n = len(s)
s = s+"0"

ans1,ans2 = -1,-1

for i in range(n-1):
    if s[i] == s[i+1]:
        ans1,ans2 = i+1,i+2
        break

    if s[i] == s[i+2]:
        ans1,ans2 = i+1,i+3
        break

print(ans1,ans2)

Measured memory_bytes: 9136
#include <stdio.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
 
int main(void) {
  int n, q, ans = 0;
  scanf("%d", &n);
  int a[n];
  rep(i, n) scanf("%d", &a[i]);
  scanf("%d", &q);
  int b[q];
  rep(i, q) scanf("%d", &b[i]);
  rep(i, q) rep(j, n) if(a[j] == b[i]) {
    ++ans;
    break;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2752
Imports System

Module Program
    Sub Main(args As String())

        Dim S As String = Console.ReadLine()

        Dim ans As Integer = 0

        If InStr(S, "RRR") > 0 Then
            ans = 3
        ElseIf InStr(S, "RR") > 0 Then
            ans = 2
        ElseIf InStr(S, "R") > 0 Then
            ans = 1
        End If

        Console.WriteLine(ans)

    End Sub
End Module


Measured memory_bytes: 26632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

string s, t;
int from[26], to[26];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> s >> t;
  int n = s.size();
  fill_n((int*)from, 26, -1);
  fill_n((int*)to, 26, -1);
  for (int i = 0; i < n; i++) {
    int ss = s[i] - 'a';
    int tt = t[i] - 'a';
    if (to[ss] < 0 && from[tt] < 0) {
      to[ss] = tt;
      from[tt] = ss;
    } else if (to[ss] == tt && from[tt] == ss) {
      continue;
    } else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}

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

int main(){
  string str;
  cin>>str;
  int n;
  cin>>n;
  int ansl=(int)str[0]-48;
  for(int i=1;i<=int(str.size())/2;i++){
    if(str[2*i-1]=='+'){
      ansl+=(int(str[2*i])-48);
    }else{
      ansl*=(int(str[2*i])-48);
    }
  }
  int ansm=0;
  vector<int> vec;
  for(int i=0;i<int(str.size());i+=2){
    if((i+1>=(int)str.size()) || (str[i+1]=='+')){
      vec.push_back((int)str[i]-48);
    }else{
      int c=((int)str[i]-48);
      for(int j=i+2;j<(int)str.size();j+=2){
	c*=((int)str[j]-48);
	if((j+1>=(int)str.size()) || (str[j+1]=='+')){
	  vec.push_back(c);
	  i=j;
	  break;
	}
      }
    }
  }
  for(int i=0;i<(int)vec.size();i++)
    ansm+=vec[i];
  //  cout<<" l->"<<ansl<<" m->"<<ansm<<endl;
  if(ansm==ansl){
    if(ansm==n){
      cout<<"U"<<endl;
    }else{
      cout<<"I"<<endl;
    }
  }else{
    if(ansm==n){
      cout<<"M"<<endl;
    }else if(ansl==n){
      cout<<"L"<<endl;
    }else{
      cout<<"I"<<endl;
    }
  }
  return 0;
}

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

int main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    if(a[0]==5 && a[1]==5 && a[2]==7) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#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>;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);   
    int s;
    cin >> s;
    vector<mint> dp(s+1);
    dp[0] = 1;
    rep(i,s){
        for(int j = i+3; j <= s; j++){
            dp[j] += dp[i];
        }
    }
    cout << dp[s] << endl;
}

Measured memory_bytes: 3652
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 100000
typedef long long i64;

typedef long long T;
//#include "graph/adj.h"
#include <numeric>

typedef pair<int,T> edge;
const T MAXT = numeric_limits<T>::max();
typedef vector<vector<edge>> graph;

//#include "graph/dijkstra.h"

void dijkstra(graph &g, int source, T *dist) {
	typedef pair<T,int> node;
	int n = g.size();
	priority_queue<node, vector<node>, greater<node>> q;
	for (int i=0; i<n; i++)
		dist[i] = MAXT;
	dist[source] = 0;
	q.push({0, source});
	while (!q.empty()) {
		node x = q.top();
		q.pop();
		T d = x.first;
		int u = x.second;
		if (d > dist[u])
			continue;
		for (auto &y: g[u]) {
			int v = y.first;
			T w = y.second + d;
			if (w < dist[v]) {
				dist[v] = w;
				q.push({w, v});
			}
		}
	}
}

int n, m;

graph g;
T dist[MAXN];

int input() {
	if (scanf("%d %d", &n, &m) < 0) return 0;
	g.resize(n);
	for (int i=0; i<m; i++) {
		int x, y, z;
		scanf("%d %d %d", &x, &y, &z);
		x--, y--;
		g[x].push_back({y, z});
	}
	return 1;
}

void init() {
	for (int i=1; i<n; i++)
		g[i].push_back({i-1, 0});
}

i64 solve() {
	dijkstra(g, 0, dist);
	return dist[n-1]==MAXT? -1: dist[n-1];
}

void output(i64 ans) {
	printf("%lld\n", ans);
}

void cleanup() {
	for (int i=0; i<n; i++) g[i].clear();
	g.clear();
}

int main() {
	//precalc();
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}




Measured memory_bytes: 9340
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a>=1&&a<=9&&b>=1&&b<=9){
        printf("%d\n",a*b);
    }else{
        printf("-1\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
   int a,b,c,k;
   string s;
   cin >> a >> b >> c >> k;
   int ans = 0;
   if (k-a <= 0){
      cout << k << endl;
      return 0;
   }
   else{
      ans = a;
      k-=a;
   }
   if (k-b <= 0){
      cout << ans << endl;
      return 0;
   }
   else{
      k-=b;
   }
   if (k-c <= 0){
      //cout << k << endl;
      cout << ans-k << endl;
      return 0;
   }

   return 0;
}


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

int main(){
  ll a,b,q;
  cin >> a >> b >> q;
  
  vector<ll> s(a+2), t(b+2), x(q);
  
  s[0] = t[0] = -1e12;
  s[a+1] = t[b+1] = 1e12;
  
  for(ll i=1; i<=a; i++) cin >> s[i];
  for(ll i=1; i<=b; i++) cin >> t[i];
  for(ll i=0; i<q; i++) cin >> x[i];
  
  for(ll i=0; i<q; i++){
    
    auto it1 = lower_bound(s.begin(), s.end(), x[i]);
    ll ans1 = abs(x[i] - *it1) + min(abs(*it1 - *lower_bound(t.begin(), t.end(), *it1)), abs(*it1 - *(lower_bound(t.begin(), t.end(), *it1)-1)));
    ll ans2 = abs(x[i] - *(it1-1)) + min(abs(*(it1-1) - *lower_bound(t.begin(), t.end(), *(it1-1))), abs(*(it1-1) - *(lower_bound(t.begin(), t.end(), *(it1-1))-1)));
                                     
    auto it2 = lower_bound(t.begin(), t.end(), x[i]);
    ll ans3 = abs(x[i] - *it2) + min(abs(*it2 - *lower_bound(s.begin(), s.end(), *it2)), abs(*it2 - *(lower_bound(s.begin(), s.end(), *it2)-1)));
    ll ans4 = abs(x[i] - *(it2-1)) + min(abs(*(it2-1) - *lower_bound(s.begin(), s.end(), *(it2-1))), abs(*(it2-1) - *(upper_bound(s.begin(), s.end(), *(it2-1))-1)));
    cout << min(ans1, min(ans2, min(ans3, ans4))) << endl;
  }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;

int main(){
  int a,b; cin >> a >> b;

  if(a <= 5) cout << 0 << endl;
  else if(6 <= a && a <= 12) cout << b/2 << endl;
  else cout << b << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr int T = 86400, U = 10800;
int main()
{
    int N; cin >> N;
    vector<int> A(T);
    int t = 0;
    for (int i = 0; i < N; i++) {
        int a, b; cin >> a >> b;
        t += a;
        t %= T;
        A[t] += 1;
        t += b;
    }
    vector<int> S(2*T+1);
    for (int i = 0; i < T; i++) S[i+1] = S[i] + A[i];
    for (int i = 0; i < T; i++) S[T+i+1] = S[T+i] + A[i];
    int ans = 0;
    for (int i = 0; i < T; i++) {
        ans = max(ans, S[i+U+1] - S[i]);
    }
    cout << ans << endl;
    return 0;
}

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

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

    int64_t L0 = 2;
    int64_t L1 = 1;
    int64_t LN = 0;
  
    if(N == 1) {
        cout << L1 << endl;
        return 0;
    }
    for (int i = 1; i < N; i++) {
        LN = L0 + L1;
        if (i % 2 != 0) {
            L0 = LN;
        } else {
            L1 = LN;
        }
    }
    cout << LN << endl;
    return 0;
}


Measured memory_bytes: 256
x=int(input())
s=input()

leftw=[0]*(x+1)
righte=[0]*(x+1)

for i in range(x):
    leftw[i+1]=leftw[i]
    righte[x-i-1]=righte[x-i]

    leftw[i+1]+=1 if s[i]=='W' else 0
    righte[x-i-1]+=1 if s[x-i-1]=='E' else 0
ans=10**6
for leader in range(x):
    ans=min(ans,leftw[leader]+righte[leader+1])

print(ans)

Measured memory_bytes: 73412
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


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

    int h,w,n;
    cin >> h >> w;
    cin >> n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];

    int ans[h][w];

    int step = 1,start = 0;
    int now = 0,cnt = 0;
    for(int i = 0; i < h;i++){
        for(int l = start; l < w && l > -1;l+=step){
            ans[i][l] = now+1;
            cnt++;
            if(cnt == a[now]){
                now++;
                cnt = 0;
            }
        }
        step *= -1;
        start = start > 0 ? 0:w-1;
    }

    for(int i = 0; i < h;i++){
        for(int l = 0; l < w;l++){
            cout << ans[i][l] << " ";
        }
        cout << endl;
    }

    

    return 0;
}

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

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> v;
    for(int i=1; i<=min(a,b); i++){
        if(a%i==0&&b%i==0){
            v.push_back(i);
            // cout << i << endl;
        }
    }
    sort(v.rbegin(), v.rend());
    cout << v[k-1] << endl;

    return 0;
}

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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  
  string s;
  cin >> s;
  
  string ans = "";
  for (int i=0; i<s.length(); i++){
   	if (s[i] == '1'){
		ans.push_back('1');
    }
    else if (s[i] == '0'){
        ans.push_back('0');
    }
    else{
      if (!ans.empty()){
        ans.pop_back();
      }
    }
  }
  cout << ans;
  return 0;
}
  


Measured memory_bytes: 256