akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define INF 1e9
//dp[i][j] - till i, j heads probab
int main(){
	int n;cin>>n;
	vector<double> v(n);
	for(int i=0;i<n;i++) cin>>v[i];
	vector<vector<double> > dp(n,vector<double>(n+1,0));
	dp[0][0] = 1-v[0];dp[0][1] = v[0];
	for(int i=1;i<n;i++){
		for(int j=0;j<=n;j++){
			if(j>i+1) continue;
			if(j==0) dp[i][j] = (1-v[i])*dp[i-1][j];
			else dp[i][j] = v[i]*dp[i-1][j-1]+(1-v[i])*dp[i-1][j];
		}
	}
	double ans=0;
	for(int j = (n/2)+1;j<=n;j++){
		ans+=dp[n-1][j];
	}
	printf("%.10lf\n", ans);
	// cout<<ans<<endl;
}

Measured memory_bytes: 73740
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)
#define repd(i,x,y) for(int i=x; i>=y; --i)
#define mid (l+r>>1)

using namespace std;
typedef long long LL;
char s[20];
int n,ans;

int main()
{
	scanf("%s",s+1),n=strlen(s+1);
	rep(i,1,n) ans+=s[i]=='o';
	if(ans+15-n>=8) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
const int MOD = 1000000007;


typedef long long int ll; 
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

void floatOutPutSetup(){
    cout << fixed;
    cout << setprecision(10);
}

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> h(n);
    vector<int> g(n,1);
    rep(i,n) {cin >> h[i];}
    rep(j,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        if(h[a] >= h[b]){
            g[b]=0;
        }
        if(h[a] <= h[b]){
            g[a]=0;
        }
    }

    int ans = 0;
    rep(i,n){
        if(g[i] == 1)ans++;
    }
    cout<<ans << endl;

    return 0;
}

Measured memory_bytes: 4048
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String [] a = sc.nextLine().split("");
        int b = a.length;
        String answer = "";
        for(int i = 0;i<b;i++){
            if(a[i].equals("0")){
                answer += "0";
            }
            if(a[i].equals("1")){
                answer += "1";
            }
            if(a[i].equals("B")){
                if(answer != null && answer.length() > 0){
                    answer = answer.substring(0,answer.length()-1);
                }
            }
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 21844
m,i,j,k,c[],p;main(n){for(;scanf("%d%d",&n,&m),n;printf("%d\n",j>m?k:j)){for(k=3;k--;)for(scanf("%d",&i);j=i--;c[n-j]=k)scanf("%d",&j);for(i=n;i--;p+=c[i]*2)j+=pow(3,i)*abs(p%4-c[i]);j=fmin(j,pow(3,n)+~j);}}

Measured memory_bytes: 0
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  ll i,N,x;
  cin>>N;
  vec a(N,1),b(N,1);
  rep(i,N){
    cin>>x;
    a[x-1]+=i;
    a[i]+=N*i;
    b[i]+=N*(N-1-i);
  }
  output(a);
  output(b);
  return 0;
}

Measured memory_bytes: 896
i=input
N=int(i())
A=list(map(int,i().split()))
r=range
c=0
for i in r(N):
    m=i
    for j in r(i,N):
        if A[j] < A[m]:m=j
    if i!=m:A[i],A[m]=A[m],A[i];c+=1
print(*A)
print(c)

Measured memory_bytes: 5608
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll MOD = 998244353;

template <typename Monoid>
struct SegmentTree {
	using F = function<Monoid(Monoid, Monoid)>;

	int sz;
	vector<Monoid> seg;
	const F f;
	const Monoid M1;

	SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid &x) { seg[k + sz] = x; }

	void build() {
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid &x) {
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b) {
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid operator[](const int &k) const { return seg[k + sz]; }
};

ll dp[200001];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N;
	cin >> N;
	SegmentTree<int> seg(N, [](int a, int b) {return max(a, b); }, 0);
	vector<P> robot;
	for (int i = 0; i < N; i++) {
		int X, D;
		cin >> X >> D;
		robot.emplace_back(X, D);
	}
	sort(begin(robot), end(robot));
	seg.update(N - 1, N - 1);
	for (int i = N - 2; i >= 0; i--) {
		int idx = lower_bound(begin(robot), end(robot), P(robot[i].first + robot[i].second, -1)) - begin(robot);
		int x = seg.query(i, idx);
		seg.update(i, max(i, x));
	}
	dp[0] = 1;
	for (int i = 0; i < N; i++) {
		(dp[i + 1] += dp[i]) %= MOD;
		int m = seg[i];
		(dp[m + 1] += dp[i]) %= MOD;
	}
	cout << dp[N] << endl;
}

Measured memory_bytes: 5616
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h1 = sc.nextInt();
		int h2 = sc.nextInt();
		int k1 = sc.nextInt();
		int k2 = sc.nextInt();
		int score[] = new int[4];
		score[0] = sc.nextInt();
		score[1] = sc.nextInt();
		score[2] = sc.nextInt();
		score[3] = sc.nextInt();
		int hP = h1 * score[0] + h1 / 10 * score[2] + h2 * score[1] + h2 / 20 * score[3];
		int kP = k1 * score[0] + k1 / 10 * score[2] + k2 * score[1] + k2 / 20 * score[3];
		if(hP == kP) {
			System.out.println("even");
		}else {
			System.out.println(hP > kP ? "hiroshi" : "kenjiro");
		}
	}
}

Measured memory_bytes: 26168
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int inptCount = int.Parse(Reader.ReadLine());

        this.items = Reader.ReadLine().Split(' ').Select(a=>long.Parse(a)).ToArray();
        long ans = 0;
        if (items[0] == 0)
        {
            ans = GetAns(1, 1) + 1;
            ans = Math.Min(ans, GetAns(1, -1) + 1);
        }
        else 
        {
            ans = GetAns(1, items[0]);
            if (items[0] > 0)
            {
                ans = Math.Min(ans, GetAns(1, -1) + items[0] + 1);
            }
            else
            {
                ans = Math.Min(ans, GetAns(1, 1) + Math.Abs(items[0]) + 1);
            }
        }
        Console.WriteLine(ans);
    }

    private long GetAns(int idx, long subtotal)
    {
        if (idx >= items.Length)
        {
            return 0;
        }
        if (subtotal < 0 && subtotal + items[idx] > 0)
        {
            return GetAns(idx + 1, subtotal + items[idx]);
        }
        else if (subtotal > 0 && subtotal + items[idx] < 0)
        {
            return GetAns(idx + 1, subtotal + items[idx]);
        }
        else if(subtotal > 0)
        {
            return GetAns(idx + 1, -1) + (subtotal + items[idx] + 1);
        }
        else
        {
            return GetAns(idx + 1, 1) + Math.Abs(subtotal + items[idx]) + 1;
        }

    }

    private long[] items;


    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"



6
-1 4 3 2 -5 4


";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

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

int main(){
	string s;
	int ans=0;

	cin>>s;
	
	char prev= s.at(0);
	
	for(int i=1; i<s.size(); i++){
		if(prev!= s.at(i)) ans++;
		prev= s.at(i);
	}

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

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

using namespace std;

using LL = long long;
using PII = pair<int, int>;
using ll = long long;
using DBL = double;
using VI = vector<int>;
using VD = vector<DBL>;
using VVI = vector<VI>;
using VVD = vector<VD>;

#define FOR(i,a,b) for(int i = a; i < b; i++)
#define REP(i,n) FOR(i,0,n)
#define SZ(a) ((int)((a).size()))
#define ALL(x) (x).begin(), (x).end()
#define SET(a,v) memset((a), (v), sizeof(a))
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define ST first
#define ND second

//#define trace(...) {__f(#__VA_ARGS__, __VA_ARGS__);}
//template<typename Arg> void __f(const char* name, Arg&& arg) {
//  cerr << name << " = " << arg << std::endl;
//} template <typename Arg1, typename... Args>
//void __f(const char* names, Arg1&& arg1, Args&&... args) {
//  const char* comma = strchr(names + 1, ',');
//  cerr.write(names, comma - names) << " = " << arg1<<" | ";__f(comma+1, args...); }
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds; // OST: find_by_order, order_of_key
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//#pragma GCC optimize("Ofast")
//optimize("unroll-loops")
//target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
///*** RNGS ***/
//SEED=chrono::steady_clock::now().time_since_epoch().count();
//// or high_resolution_clock
//mt19937 rng(SEED); /*or*/ random_device rd; mt19937 rng(rd());
//uniform_int_distribution<> dis(MIN, MAX);// usage: dis(rng)
//struct chash {int operator()(int x) const {return x^SEED;}};
//gp_hash_table<int,int,chash>m;//use cc if very less updates
///*** FAST IO ***/
//inline int scan(){ bool y=0; int x=0; char c=getchar_unlocked();
//while(c<'0'||c>'9'){ if(c=='-')y=1; c=getchar_unlocked();}
//while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+c-'0';c=getchar_unlocked();}
//return y?-x:x; }

const int MOD = 1000000007;
string k;
int d;
int dp[2][10010][128];

int calc(int pos, int rem, int lo) {
    if(pos == k.size()) return (rem == 0);
    int &y = dp[lo][pos][rem];
    if(y != -1) return y;
    y = 0;
    for(int i=0; i<=(lo?9:(k[pos]-'0')); ++i) {
        y += calc(pos+1, (rem+i)%d, (lo or (i < (k[pos]-'0'))));
        if(y >= MOD) y -= MOD;
    }
    return y;
}

int main() {
    #ifdef LOCAL_EXEC
//    freopen("sample.in", "r", stdin);
//    freopen("sample.out", "w", stdout);
    #else
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    #endif
    memset(dp, -1, sizeof(dp));
    cin >> k >> d;
    cout << ((calc(0, 0, 0) == 0) ? (MOD - 1) : (calc(0, 0, 0) - 1)) << endl;
	return 0;
}


Measured memory_bytes: 14544
import itertools
N=int(input())


P=[]
P.append(input().split())
P=P[0]
P = [int(i) for i in P]

Q=[]
Q.append(input().split())
Q=Q[0]

Q= [int(i) for i in Q]



result=list(itertools.permutations(P))

x=[]
for i in result:
    x.append(list(i))

x.sort()

numP=x.index(P)+1
numQ=x.index(Q)+1

print(abs(numP-numQ))


Measured memory_bytes: 15348
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  string s;cin>>s;
  REP(i,(int)s.size()-1){
    if(s[i]=='A' && s[i+1]=='C'){
      P("Yes");
      return 0;
    }
  }
  P("No");
  return 0;
}


Measured memory_bytes: 256
from collections import deque
n, u, v = list(map(int, input().split()))
a = [[] for _ in range(n+1)]
for _ in range(n-1):
  x, y = map(int, input().split())
  a[x].append(y)
  a[y].append(x)
  
def dis(a,v):
  d = [[1,0] for _ in range(n+1)]
  c = 1
  for i in a[v]:
    d[i][0] = 1
    d[i][1] = c
    c += 1
  b = deque(a[v])
  while b:
    x = b.pop()
    for i in a[x]:
      if d[i][1] == 0:
        d[i][0] = d[x][0] + 1
        d[i][1] = d[x][1]
        b.append(i)
  d[v] = [0,0]
  return d

du = dis(a,u)
dv = dis(a,v)
dis = max([dv[i][0] for i in range(n+1) if dv[i][1]==dv[u][1] and dv[i][0]>du[i][0]])
print(dis-1)

Measured memory_bytes: 82080
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz");
char s[2100][2100];
ll n, cnt, ans, a, b, c, tmp, m, h, w, x, y, sum, k, q;
ll u[2100][2100], d[2100][2100];
ll r[2100][2100], l[2100][2100];

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

  cin >> h >> w;
  rep(i, h) {
    rep(j, w) { cin >> s[i][j]; }
  }
  rep(i, h) {
    rep(j, w) {
      if (s[i][j] == '.') {
        u[i][j]++;
        d[i][j]++;
        r[i][j]++;
        l[i][j]++;
      }
    }
  }
  rep(i, h) {
    rrep(j, 1, w) {
      if (s[i][j] == '#') continue;
      l[i][j] += l[i][j - 1];
    }
    rrrep(j, w - 1, 0) {
      if (s[i][j] == '#') continue;
      r[i][j] += r[i][j + 1];
    }
  }

  rep(j, w) {
    rrep(i, 1, h) {
      if (s[i][j] == '#') continue;
      u[i][j] += u[i - 1][j];
    }
    rrrep(i, h - 1, 0) {
      if (s[i][j] == '#') continue;
      d[i][j] += d[i + 1][j];
    }
  }

  rep(i, h) {
    rep(j, w) {
      if (s[i][j] == '#') continue;
      cnt = l[i][j] + r[i][j] + u[i][j] + d[i][j];
      cnt -= 3;
      ans = max(ans, cnt);
    }
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 142208
mod = 1000000007

H,W = map(int,input().split())
root = []
for _ in range(H):
    s = list(input())
    root.append(s)

dp = [[0]*(W+1) for _ in range(H+1)]
dp[0][0] = 1
for h in range(H):
    for w in range(W):
        if (h != 0 or w != 0) and root[h][w] == '.':
            dp[h][w] = (dp[h-1][w] + dp[h][w-1])%mod

print(dp[H-1][W-1])

Measured memory_bytes: 117140
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int L, R, d;
  cin >> L >> R >> d;
  int32_t cnt = 0;
  for (int i = L; i <= R; i++) {
    if (i % d == 0) cnt++;
  }
  cout << cnt << endl;
  return 0;

}


Measured memory_bytes: 3648
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0067
"""
import sys
import copy

def solve(map):
    num_of_land = 0
    work = []
    lmap = copy.deepcopy(map)
    for i, line in enumerate(lmap[1:], start=1):
        while 1 in line[1:-1]:
            j = line.index(1)
            num_of_land += 1
            work.append([i, j])
            lmap[i][j] = 0

            while work:
                y, x = work.pop()
                if lmap[y][x+1] == 1: #  ????????????
                    work.append([y, x+1])
                    lmap[y][x+1] = 0
                if lmap[y+1][x] == 1: #  ????????????
                    work.append([y+1, x])
                    lmap[y+1][x] = 0
                if lmap[y][x-1] == 1: #  ????????????
                    work.append([y, x-1])
                    lmap[y][x-1] = 0
    return num_of_land


def main(args):
    # data = [
    # [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    # [0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0],
    # [0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0],
    # [0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0],
    # [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0],
    # [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0],
    # [0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0],
    # [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0],
    # [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],
    # [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0],
    # [0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0],
    # [0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0],
    # [0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0],
    # [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
    # 
    # [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    # [0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0],
    # [0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0],
    # [0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0],
    # [0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0],
    # [0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0],
    # [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0],
    # [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0],
    # [0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0],
    # [0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0],
    # [0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0],
    # [0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0],
    # [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    # [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
    #         ]
    data = []
    buff = []
    for line in sys.stdin:
        line = line.strip()
        if line:
            if len(buff) == 0:
                buff = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
            line = '0' + line + '0'
            buff.append([int(x) for x in line])
        else:
            if len(buff) > 0:
                buff.append([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
                data.append(buff)
                buff = []
    if len(buff) > 0:
        buff.append([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
        data.append(buff)
        buff = []

    for map in data:
        result = solve(map)
        print(result)

if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 8064
#include<iostream>
#include<algorithm>
using namespace std;
int t[114514];

int main() {
	int n,c,k;
	cin >> n>>c>>k;
	for (int i = 0; i < n; i++)cin >> t[i];
	sort(t, t + n);
	int ans = 0;
	int m = 0, nt = t[0];//乗っている人数,今の時間,行った人数
	for (int i = 0; i < n; i++) {
		if (nt + k < t[i]) {
			ans++;
			nt = t[i];
			m = 1;
		}
		else {
			m++;
		}

		if (m == c) {
			ans++;
			m = 0;
			nt = t[i + 1];
		}
	}
	if (m)ans++;
	cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        int nn = Integer.parseInt(n);
        char[] c = n.toCharArray();
        int sum = 0;
        for (int i = 0; i < c.length; i++) {
            sum += Integer.parseInt(String.valueOf(c[i]));
        }
        if(nn % sum == 0) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 35736
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <limits>
using namespace std;
// 素因数分解
typedef pair<long long, long long> P;
vector<P> prime_factorize(long long n)
{
vector<P> res;
for (long long p = 2; p * p <= n; ++p)
{
if (n % p != 0)
continue;
int num = 0;
while (n % p == 0)
{
++num;
n /= p;
}
res.push_back(make_pair(p, num));
}
if (n != 1)
res.push_back(make_pair(n, 1));
return res;
}
// 因数分解
long long gcd(long long x, long long y)
{
  if (y == 0)
  {
    return x;
  }
  else
  {
    return gcd(y, x % y);
  }
}
//素数判定
bool is_prime(long long n){
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
#define MOD 1000000007
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
    int n, k;
    cin >> n >> k;
    vector<ll> m, p;
    rep(i,n){
        int t;
        cin >> t;
        if(t>=0){
            p.push_back(t);
        }else{
            m.push_back(-t);
        }
    }
    sort(m.begin(), m.end());
    sort(p.begin(), p.end());
    if (k == n)
    {
        ll ans = 1;
        rep(i,m.size()){
            ans =ans* (MOD - m[i]) % MOD;
        }
        rep(i,p.size()){
            ans =ans* p[i] % MOD;
        }
        cout << ans << endl;
        return 0;
    }
    if(k%2==1&&m.size()==n){
        ll ans = 1;
        rep(i,k){
            ans =ans* (MOD - m[i]) % MOD;
        }
        cout << ans << endl;
        return 0;
    }

    ll ans = 1;
    ll msize = m.size(),psize=p.size();
    while (k)
    {
        if(k>=2&& msize>=2&&(psize<=1||(psize>=2&& m[msize-1]*m[msize-2]>=p[psize-1]*p[psize-2]))){
            ans =ans* m[--msize] % MOD;
            ans =ans* m[--msize] % MOD;
            k -= 2;
        }else{
            ans =ans* p[--psize] % MOD;
            k--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5520
# -*- coding: utf-8 -*-
"""
A - Add Sub Mul

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    A, B = map(int, input().split())
    add = A + B
    sub = A - B
    mul = A * B
    print(max(add, sub, mul))


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
using namespace std;
int main(void){
   int N,M,C;
   cin >> N >> M >> C;
   vector<int> B(M);
   for(int i=0;i<M;i++){
       cin >> B[i];
   }
   vector<vector<int>> A(N, vector<int>(M));
   for(int i=0;i<N;i++){
       for(int j=0;j<M;j++){
           cin >> A[i][j];
       }
   }
   int ans =0;
   for(int i=0;i<N;i++){
       int sum =0;
       for(int j=0;j<M;j++){
      sum += A[i][j] *B[j];
   }
   if (sum + C >0) ans++;
   }
   cout << ans << endl;
}

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

int main(){ 
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a+b>c+d){
        cout<<"Left";
    }else if(a+b<c+d){
        cout <<"Right";
    }else{
        cout<<"Balanced";
    }
    return 0;
}


Measured memory_bytes: 256
d = int(input())
c = {}
s = []
C = list(map(int, input().split()))
for i in range(26):
    c[i] = C[i]
for i in range(d):
    s.append(list(map(int, input().split())))

t = 0
while t < 365:
    for i in range(26):
        if t < 365:
            t += 1
            print(26-i)
        else:
            break;

Measured memory_bytes: 9356
#include<stdio.h>

int main()
{
    int W, H, x, y, r;
    while(scanf("%d%d%d%d%d", &W, &H, &x, &y, &r)!=EOF){
        if((x+r)>W || (x-r)<0 || (y+r)>H || (y-r)<0 || x<0 || y<0)
            printf("No\n");
        else
            printf("Yes\n");
    }
    return 0;
}



Measured memory_bytes: 2684
def main():
    K, N = map(int, input().split())
    A = list(map(int, input().split()))
    B = [0] * (2 * N)

    for i in range(2*N):
        if i < N:
            B[i] = A[i]
        else:
            B[i] = K + A[i - N]

    l = 0
    for i in range(N):
        tmp = B[i+1] - B[i]
        l = max(l, tmp)

    ans = K - l
    print(ans)



if __name__ == "__main__":
    main()

Measured memory_bytes: 80684
# coding: utf-8
n=int(input())
A=list(map(int,input().split()))
l=[]
r=[]
k=1
for i in range(n):
    if i%2==0:
        r.append("{}".format(A[i]))
    else:
        l.append("{}".format(A[i]))
l.reverse()

b=l+r

if n%2==1:
    b.reverse()

print(" ".join(b))




Measured memory_bytes: 33572
import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7

def sol():
    H, W = map(int, input().split())
    chart = [[False] * (W + 2) for _ in range(H + 2)]

    for h in range(1, H + 1):
        line = input()
        for w, s in enumerate(line):
            if s == '.':
                chart[h][w + 1] = True

    dp = [[0] * (W + 2) for _ in range(H + 2)]
    dp[1][1] = 1

    for h in range(1, H + 1):
        for w in range(1, W + 1):
            if chart[h + 1][w]:
                dp[h + 1][w] = (dp[h + 1][w] + dp[h][w]) % MOD
            if chart[h][w + 1]:
                dp[h][w + 1] = (dp[h][w + 1] + dp[h][w]) % MOD

    print(dp[H][W] % MOD)

sol()

Measured memory_bytes: 58844
// C++ program to Find Number of digits 
// in base b. 
#include <iostream> 
#include <math.h> 
using namespace std; 

// function to print number of 
// digits 
void findNumberOfDigits(long n, int base) 
{ 
    // Calculating log using base 
    // changing property and then 
    // taking it floor and then 
    // adding 1. 
    int dig = (int)(floor( log(n) / 
                        log(base)) + 1); 
    
    // printing output 
    cout<< dig; 
} 

// Driver method 
int main() 
{ 
    // taking inputs 
    long n;
    int base;
    cin>>n>>base; 
    // calling the method 
    findNumberOfDigits(n, base); 
    return 0; 
} 

// This code is contributed by Manish Shaw 
// (manishshaw1) 


Measured memory_bytes: 512
(defvar *n* (read))

(defun check-first-and-last (lst)
  (let ((count 0)
        (previous nil)
        (check t))
    (dolist (s lst)
      (let* ((tmp (concatenate 'list s))
             (size (length tmp)))
        (if (= count 0)
            (progn (setq previous (nth (- size 1) tmp))
                   (incf count))
            (if (not (eql previous (car tmp)))
                (setq check nil)
                (setq previous (nth (- size 1) tmp))))))
    check))

(defun word-count (lst)
  (let ((tmp (sort lst 'string<))
        (previous nil)
        (check t))
    (dolist (s tmp)
      (if (null previous)
          (setq previous s)
          (if (string= previous s)
              (setq check nil)
              (setq previous s))))
    check))

(defun main ()
  (let ((lst (list nil)))
    (dotimes (x *n*)
      (push (read-line) lst))
    (setq lst (cdr (reverse lst)))
    (if (null (check-first-and-last lst))
        (format t "No~%")
        (if (null (word-count lst))
            (format t "No~%")
            (format t "Yes~%")))))

(main)

Measured memory_bytes: 6756
program prob3
    implicit none
    character(len=50) :: O, E
    integer :: i, leno, lene
    read(*,*) O
    read(*,*) E

    leno = len_trim(O)
    lene = len_trim(E)

    do i = 1, lene
        write(*,'(a)',advance='no') O(i:i)
        write(*,'(a)',advance='no') E(i:i)
    end do

    if(leno > lene) then
        write(*,'(a)',advance='no') O(leno:leno)
    end if
    write(*,*)

    stop
contains
end program prob3

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        vll A(N);
        rep(i, 0, N) cin >> A[i];
        sort(all(A));

        map<ll, ll> mp;
        rep(i, 0, N) mp[A[i]]++;

        vector<bool> is(N);
        rep(i, 0, N) {
                rep(j, 2, inf) {
                        if (A[i] * j > A.back()) break;
                        ll target = A[i] * j;
                        if (binary_search(A.begin()+i+1, A.end(), target)) {
                                ll pos = lower_bound(A.begin()+i+1, A.end(), target) - A.begin();
                                is[pos] = true;
                        }
                }
        }

        ll ans = 0;
        rep(i, 0, N) {
                if (not is[i] and mp[A[i]] == 1) ++ans;
        }
        cout << ans << endl;
}



Measured memory_bytes: 17064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

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

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	int n;
	cin >> n;
	
	vector<vector<pii>> g(n + 1);
	vector<int> ans(n + 1);
	
	int mx = 0;
	
	for(int i = 0; i + 1 < n; i++){
		int a, b;
		cin >> a >> b;
		g[a].push_back({b, i});
		g[b].push_back({a, i});
		
		mx = max(mx, (int)g[a].size());
		mx = max(mx, (int)g[b].size());
	}
	
	queue<int> Q;
	vector<bool> used(n + 1);
	Q.push(1);
	used[1] = true;
	
	vector<set<int>> s(n + 1);
	
	while(!Q.empty()){
		int u = Q.front();Q.pop();
		
		int mx = 1;
		for(auto &e : g[u]){
			int v = e.first;
			int idx = e.second;
			
			if(used[v])
				continue;
			used[v] = true;
			
			while(s[u].count(mx))
				mx++;
			
			ans[idx] = mx;
			s[u].insert(mx);
			s[v].insert(mx);
			mx++;
			
			Q.push(v);
			
		}
	}
	
	
	cout << mx << endl;
	for(int i = 0; i + 1 < n; i++)
		cout << ans[i] << endl;

	return 0;
}


Measured memory_bytes: 20992
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int a,b,k,i,x;
	cin>>a>>b>>k;
	if(k*2>b-a+1){
		for(i=a;i<=b;i++){
			cout<<i<<endl;
		}
	}
	else{
		for(i=a;i<=a+k-1;i++){
			cout<<i<<endl;
		}
		for(i=b-k+1;i<=b;i++){
			cout<<i<<endl;
		}
	}
	return 0;
}


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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

struct Expr {
    char val;
    vector<Expr> childs;
    int eval() {
        if (isdigit(val)) return val - '0';
        int n = childs.size();
        vector<int> v(n);
        rep(i, 0, n) v[i] = childs[i].eval();
        int rv;
        if (val == '+') {
            rv = 0;
            rep(i, 0, n) rv += v[i];
        } else if (val == '*') {
            rv = 1;
            rep(i, 0, n) rv *= v[i];
        } else {
            printf("PANIC\n");
            exit(1);
        }
        return rv;
    }
    void out() const {
        cerr << "(" << val;
        if (childs.size()) cerr << " ";
        for (const auto &e : childs) e.out();
        cerr << ")";
    }
};

Expr gen(list<string> &lst, int depth = 1) {
    // cout << depth << endl;

    if (isdigit(lst.front().back())) {
        char v = lst.front().back(); lst.pop_front();
        return Expr {v, {}};
    }

    Expr e {lst.front().back(), {}};
    lst.pop_front();
    while (lst.size() && lst.front().length() > depth) {
        e.childs.push_back(gen(lst, depth + 1));
    }
    return e;
}

int main() {
    for (;;) {
        int n; cin >> n; if (!n) break;
        list<string> lst;
        rep(i, 0, n) {
            string s; cin >> s; lst.push_back(s);
        }
        Expr e = gen(lst);
        // e.out(); cerr << endl;
        cout << e.eval() << endl;
    }
}


Measured memory_bytes: 3104
def prime(n):
  if n==1:
    return False
  if n==2:
    return True
  if n==3:
    return True
  for i in range(2,int(n**0.5)+1):
    if n%i==0:
      return False
  else:
    return True 

n=int(input())
for i in range(n,n+10**5):
  if prime(i)==True:
    print(i)
    break

Measured memory_bytes: 3064
import java.util.*;
class Main{
    public static void main(String args[]){
        Scanner s=new Scanner(System.in);
        while(s.hasNext()){
            String line=s.nextLine();
            for(int i=0;i<26;i++){
                String now="";
                for(int j=0;j<line.length();j++){
                    if(line.charAt(j)>='a'&&line.charAt(j)<='z'){
                        now+=(char)('a'+(line.charAt(j)-'a'+i)%26);
                    }else now+=line.charAt(j);
                }
                boolean ok=false;
                for(int j=0;j<now.length()-2;j++){
                    if(now.charAt(j)=='t'&&now.charAt(j+1)=='h'&&now.charAt(j+2)=='e')ok=true;
                }
                for(int j=0;j<now.length()-3;j++){
                    if(now.charAt(j)=='t'&&now.charAt(j+1)=='h'){
                        if(now.charAt(j+2)=='i'&&now.charAt(j+3)=='s')ok=true;
                        if(now.charAt(j+2)=='a'&&now.charAt(j+3)=='t')ok=true;
                    }
                }
                if(ok){
                    System.out.println(now);
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 26316
/*
ID: y1197771
PROG: test
LANG: C++
*/
#include<bits/stdc++.h>
#define pb push_back
#define FOR(i, n) for (int i = 0; i < (int)n; ++i)
#define dbg(x) cout << #x << " at line " << __LINE__ << " is: " << x << endl
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e3 + 10;
map<string, bool> ma;
int func(string & s) {
    if(s.size() <= 2) return 0;
    int t = 0;
    for (int i = 1; i < s.size(); i++) {
        if(s[i - 1] != s[i + 1]) t++;
    }
    return t;
}
bool work(string s) {
    if(s.size() <= 2) return 0;
    if(ma.count(s)) return ma[s];
    for (int i = 1; i < s.size() - 1; i++) {
        if(s[i - 1] == s[i + 1]) continue;
        string st = s.substr(0, i) + s.substr(i + 1);
        if(func(st) <= 0)
            return ma[s] = 1;
    }
    for (int i = 1; i < s.size() - 1; i++) {
        if(s[i - 1] == s[i + 1]) continue;
        string st = s.substr(0, i) + s.substr(i + 1);
        if(!work(st)) return ma[s] = 1;
    }
    return ma[s] = 0;
}
void solve() {
    string s;
    while(cin >> s) {
        int n = s.size();
       if((s[0] == s[n - 1] && s.size()%2 == 0) ||(s[0] != s[n - 1] && s.size() %2) )
        cout << "First" << endl;
       else cout << "Second" << endl;
    }

}
int main() {
    //freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 512
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] Az = new long[N];
        for (int i = 0; i < N; i++) {
            Az[i] = sc.nextLong();
        }

        long ans = 0;
        long min = Az[0];
        for (int i = 1; i < N; i++) {
            if (min < Az[i]){
                min = Az[i];
            }
            if (min > Az[i]){

                ans += min - Az[i];
            }
        }

        System.out.println(ans);

    }
}

Measured memory_bytes: 61480
#include <iostream>
#include <string>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

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

	int ans = 700;

	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'o') {
			ans += 100;
		}
	}

	cout << ans << endl;


}

Measured memory_bytes: 3560
#include<iostream>
#include<string.h>
using namespace std;
int main(){
    int n,w,h;
    cin>>n;
    while(n--){
        cin>>h>>w;
        char bo[51][51];
        int dis[26][26];
        int ma[27][4];
        for(int i=0;i<26;i++){
            ma[i][0]=51;
            ma[i][1]=51;
            ma[i][2]=0;
            ma[i][3]=0;
        }
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin>>bo[i][j];
                if(bo[i][j]=='.')continue;
                ma[bo[i][j]-'A'][0]=min(ma[bo[i][j]-'A'][0],j);
                ma[bo[i][j]-'A'][1]=min(ma[bo[i][j]-'A'][1],i);
                ma[bo[i][j]-'A'][2]=max(ma[bo[i][j]-'A'][2],j);
                ma[bo[i][j]-'A'][3]=max(ma[bo[i][j]-'A'][3],i);
            }
        }
        memset(dis,0,sizeof(dis));
        for(int k=0;k<26;k++){
            for(int i=ma[k][0];i<=ma[k][2];i++){
                for(int j=ma[k][1];j<=ma[k][3];j++){
                    if(bo[j][i]=='.'){
                        cout<<"SUSPICIOUS"<<endl;
                        goto next;
                    }
                    if(bo[j][i]-'A'!=k)
                        dis[k][bo[j][i]-'A']=-1;
                }
            }
        }
        for(int k=0;k<26;k++)
            for(int i=0;i<26;i++)
                for(int j=0;j<26;j++)
                    if(dis[i][k]<0&&dis[k][j]<0)
                        dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
        for(int i=0;i<26;i++)
            if(dis[i][i]<0){
                cout<<"SUSPICIOUS"<<endl;
                goto next;
            }
        cout<<"SAFE"<<endl;
    next:;
    }
}

Measured memory_bytes: 1156
//#include "bits/stdc++.h"
//using namespace std;
//typedef long long ll;
//typedef pair<int,int> pii;
//#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
//#define all(a)  (a).begin(),(a).end()
//#define pb push_back
//#define INF 999999999

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define pb push_back
#define INF 999999999

#define MAX_V 100001


//each_scc  : ????????????????????£?????????????????????
//cmp[i]    : ?????????i????±??????????????????£??????????????????

vector<int> G[MAX_V];
vector<int> rG[MAX_V];
vector<int> vs;

void add_edge(int from, int to){
    G[from].push_back(to);
    rG[to].push_back(from);
}

void dfs(int v, bool used[MAX_V]){
    used[v] = true;
    rep(i,G[v].size()){
        if(!used[G[v][i]])dfs(G[v][i],used);
    }
    vs.push_back(v);
}

void rdfs(int v,int k,vector<int> &sccs, vector<int> &cmp, bool used[MAX_V]){
    used[v] = true;
    sccs.pb(v);
    cmp[v] = k;
    rep(i,rG[v].size()){
        if(!used[rG[v][i]])rdfs(rG[v][i],k,sccs,cmp,used);
    }
}

int scc(int V, vector< vector<int> > &each_scc, vector<int> &cmp){
    bool used[MAX_V];
    rep(i,MAX_V)used[i] = false;
    vs.clear();
    rep(v,V){
        if(!used[v])dfs(v, used);
    }
    rep(i,MAX_V)used[i] = false;
    int k=0;
    
    for(int i=vs.size()-1;i>=0;i--){
        vector<int> sccs;
        if(!used[vs[i]]){
            rdfs(vs[i], k++, sccs, cmp, used);
            each_scc.pb(sccs);
        }
    }
    return k;
}

int main(){
    int v,e;
    cin>>v>>e;
    rep(i,e){
        int s,t;
        cin>>s>>t;
        add_edge(s,t);
    }
    vector< vector<int> > each_scc;     //????????????????????£?????????????????????
    vector<     int     > cmp(MAX_V);   //???????????????????±??????????????????£??????????????????
    scc(v,each_scc,cmp);
    
    int q;
    cin>>q;
    rep(i,q){
        int a,b;
        cin>>a>>b;
        if(cmp[a]==cmp[b])cout<<1<<endl;
        else cout<<0<<endl;
    }
}

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define dbg(var) {std::cout << #var << "  = " << var << nl;}
#define vi vector<int>
typedef long long ll;

using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 

	int n;
	cin >> n;
	
	vi v(n);
	rep(i , n) cin >> v[i];
	
	map<int,int> fr[2];
	rep(i , n) fr[i % 2][v[i]]++;
	
	vector<pii> frv[2];
	
	for(const auto& el : fr[0]) frv[0].pb({el.se , el.fi});
	for(const auto& el : fr[1]) frv[1].pb({el.se , el.fi});
	frv[0].pb({0 , 0});
	frv[1].pb({0 , 0});
	
	
	SORT(frv[0]), SORT(frv[1]);
	reverse(all(frv[0])), reverse(all(frv[1]));
	
	
	int ans = 0;
	rep(i , 2) {
		rep(j , 2) {
			if(frv[0][i].se != frv[1][j].se) {
				ans = max(ans , frv[0][i].fi + frv[1][j].fi);
			}
		}
	}
	
	cout << n - ans << nl;

	return 0;
}

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

using namespace std;

int main()
{
   int a,b,c;
   cin>>a>>b>>c;
    int box[6];
   if(a>0 && a<=9 && b>0 && b<=9 && c>0 && c<=9){


            box[0]=((a*10)+b)+c;
            box[1]=((a*10)+c)+b;
            box[2]=((b*10)+c)+a;
             box[3]=((b*10)+a)+c;
            box[4]=((c*10)+a)+b;
            box[5]=((c*10)+b)+a;


     sort(box,box+6);
     printf("%d\n",box[5]);


   }

   return 0;
}


Measured memory_bytes: 256
a, b, c = map(int, input().split())
k = 1
cnt = 0

while True:
  amari = a * k % b
  if amari == c:
    cnt += 1
  if amari == 0:
    break
  k += 1
  
if cnt == 0:
  print('NO')
else:
  print('YES')


Measured memory_bytes: 2940
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib> 
#include <ctime>
#include <unordered_map>
using namespace std;
typedef long long ll;
int main() {
	int a,b,c;
	scanf("%d%d\n", &a, &b);
	if (a > b) swap(a, b);
	if (a == 1 && b == 2) c = 3;
	else if (a == 1 && b == 3) c = 2;
	else c = 1;
	printf("%d\n", c);
}

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

#define pb push_back
#define mp make_pair
#define N 200001
vector< pair<int, int> > ej;

int is[N] = {0};

int main(){
	int n, m, fg = 0;
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		if(a == 1){
			is[b]++;
		}
		if(b == n){
			is[a]++;
		}
		if(is[a] == 2 || is[b] == 2)
			fg++;
	}
	if(fg)
		cout << "POSSIBLE\n";
	else cout << "IMPOSSIBLE\n";
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>
#include <queue>

#define int long long
int inf = (1LL <<  62);
using namespace std;

signed main(){
    string s;
    cin >> s;
    int k = s.size();
    int a = 15 - k;
    int cnt = 0;
    for(int i = 0; i < k; i++){
        if(s[i] == 'o'){
            cnt++;
        }
    }
    if(a + cnt >= 8){
        cout << "YES";
    }else{
        cout << "NO";
    }
}

Measured memory_bytes: 256