akhauriyash/Code-Regression huggingface dataset:
/**
 *     author: qodjf
 *     created: 04.18.2020 01:05:58
 */
#include <bits/stdc++.h>
using namespace std;

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

#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif

#define mst(x, a) memset(x, a, sizeof(x))

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9 + 7;

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

void solve() {}

int N, M;
bool cmp(const vector<string> &a, const vector<string> &b, int i, int j) {
  for (int k = 0; k < M; k++) {
    for (int l = 0; l < M; l++) {
      if (a[i + k][j + l] != b[k][l]) {
        return false;
      }
    }
  }
  return true;
}

int main() {
  cin >> N >> M;
  vector<string> a(N), b(M);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < M; i++) {
    cin >> b[i];
  }

  for (int i = 0; i <= N - M; i++) {
    for (int j = 0; j <= N - M; j++) {
      if (cmp(a, b, i, j)) {
        cout << "Yes\n";
        return 0;
      }
    }
  }
  cout << "No\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int p = SZ(S);
    while(1)
    {
        dump(p)
        if(p == 0)
        {
            cout << "YES" << endl;
            return 0;
        }

        dump(S.substr(p-5,5))

        if(S.substr(p-5,5) == "dream")
        {
            p -= 5;
            continue;
        }
        if(p-7 >= 0 && S.substr(p-7,7) == "dreamer")
        {
            p -= 7;
            continue;
        }
        if(S.substr(p-5,5) == "erase")
        {
            p -= 5;
            continue;
        }
        if(p-6 >= 0 && S.substr(p-6,6) == "eraser")
        {
            p -= 6;
            continue;
        }

        cout << "NO" << endl;
        return 0;




    }

}

Measured memory_bytes: 512
N = int(input())
h = list(map(int, input().split()))

s = [0]*(N+2)
s[1] = h[0]
s[N+1] = -h[N-1]
for i in range(1, N):
    s[i+1] = h[i] - h[i-1]
ans = 0
for x in s:
    if x > 0:
        ans += x
print(ans)


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

# define Rep(i,a,b) for(int i=a;i<=b;i++)
# define _Rep(i,a,b) for(int i=a;i>=b;i--)
# define RepG(i,u) for(int i=head[u];~i;i=e[i].next)

typedef long long ll;

const int N=1e5+5;

template<typename T> void read(T &x){
   x=0;int f=1;
   char c=getchar();
   for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
   for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
    x*=f;
}

# define int long long

int n;
int x=100,t;

signed main()
{
    read(n);
    while(x<n){
        x+=x/100;
        t++;
    }
    printf("%lld\n",t);
    return 0;
}

Measured memory_bytes: 3760
#  --*-coding:utf-8-*--

import bisect

N, K = map(int, input().split())
V = list(map(int, input().split()))

QA = []
SA = 0
M = 0

N2 = min(N, K)

for a in range(N2+1):
    if a > 0:
        v = V[a-1]
        if v < 0:
            bisect.insort_left(QA, v)

        SA += v

    Q = QA[:]
    S = SA

    for b in range(N2-a+1):
        if b > 0:
            v = V[-b]
            if v < 0:
                bisect.insort_left(Q, v)

            S += v

        M = max(M, S - sum(Q[:min(len(Q), K-a-b):]))

print(M)
        
        


Measured memory_bytes: 3188
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define pb push_back
#define all(x) x.begin(),x.end()
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
const int maxM = 1e6+10;
const int inf = 0x3f3f3f3f;
const ll inf2 = 0x3f3f3f3f3f3f3f3f;

template<class T>void read(T &x){
    T s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    x = s*w;
}
template<class H, class... T> void read(H& h, T&... t) {
    read(h);
    read(t...);
}

void solve(){
	
}	
int main(){
	// debug;
	
	int n;read(n);
	printf("%d",(n^1));
	
	return 0;
}


Measured memory_bytes: 3728
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"

#define DEBUG 0
#define dd if (DEBUG)

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

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, A) for (auto & a : A)
#define all(a) (a).begin (), (a).end ()
#define rall(a) (a).rbegin (), (a).rend ()
#define sz(a) (int) (a).size ()
#define szl(a) (int) (a).length ()
#define FASTIO cin.sync_with_stdio (0); cin.tie (0); cin.exceptions (cin.failbit);

typedef long long ll;
typedef pair <int, int> pii;
#define f first
#define s second
#define mp(a, b) make_pair((a), (b))
typedef vector <int> vi;
typedef vector <vi> mi;
typedef vector <ll> vll;
typedef vector <vll> mll;
#define pb(a) push_back ((a))

const ll MOD = 1e+9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int INFi = 0x3f3f3f3f;
const ll MAXN = 1e+6+7;

int main ()
{
    FASTIO;
    ll i, j, n, mn, sum = 0;
    cin >> n;
    vll A (n);
    mll dp (n, vll (n));
    trav (a, A)
        cin >> a;
    for (int l = n - 1; l >= 0; --l)
    {
        for (int r = l; r < n; ++r)
        {
            if (l == r) dp[l][r] = 0;
            else
            {
                dp[l][r] = INF;
                for (i = l, sum = 0; i <= r; sum += A[i++]);
                for (i = l; i <= r - 1; ++i)
                    dp[l][r] = min (dp[l][r], dp[l][i] + dp[i + 1][r] + sum);
            }
        }
    }
    dd trav (v, dp)
    {
        trav (a, v)
            printf ("% 4lld", a);
        printf ("\n");
    }
    printf ("%lld\n", dp[0][n - 1]);

    return 0;
}



Measured memory_bytes: 1536
#include<stdio.h>
#include<math.h>
#define PI 3.14159265358979323846264338327950L
int main()
{
	int a,b,h,m;
	long double rad,length;

	scanf("%d%d%d%d",&a,&b,&h,&m);

	rad=2.0*PI*((long double)h/12.0+(long double)m/60.0/12.0-(long double)m/60.0);
	length=sqrtl((long double)(a*a+b*b)-(long double)(2.0*a*b)*cosl(rad));
	printf("%20.20Lf",length);
	return 0;
}

Measured memory_bytes: 2584
#define _CRT_SECURE_NO_DEPRECATE
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <bitset>
#include <cmath>
#include <ctime>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <sstream>
#include <chrono>
#include <functional>
#include <random>
#include <numeric>
#include <tuple>
#include <bitset>
using namespace std;
#define sz(v) ((int)((v).size()))
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef pair<int, int> ii;
template<class T> string toString(T x) { ostringstream ss; ss << x; return ss.str(); }
void solve();
int main() {
#ifdef LOCAL_COMP
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);
	solve();
#ifdef LOCAL_COMP
	cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec" << endl;
#endif
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void solve() {
	int n, a, b;
	while (cin >> n >> a >> b) {
		vector<int> p(n);
		for (int i = 0; i < n; i++) {
			cin >> p[i];
		}
		vector<int> cnt(3);
		for (int x : p) {
			if (x <= a) cnt[0]++;
			if (a < x && x <= b) cnt[1]++;
			if (b < x) cnt[2]++;
		}
		sort(all(cnt));
		cout << cnt[0] << endl;
	}
}


Measured memory_bytes: 888
#include<cstdio>
using namespace std;
int saiki(int n,int m,int cnt);
int main(){
    int n,m;
    while(1){
        scanf("%d%d",&n,&m);
        if(n == 0 && m == 0)break;
        int ans = 0;
        int cnt = 0;
        ans = saiki(n,m,cnt);
        printf("%d\n",ans);
    }
    return 0;
}
int saiki(int n,int m,int cnt){
    if(n == 0&&m == 0)return 1;
    if(cnt >= 10)return 0;
    return saiki(n-1,m-cnt,cnt+1)+saiki(n,m,cnt+1);
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        string s, t; cin >> s >> t;
        int n = sz(s), m = sz(t);
        int ans = 1e9;
        for (int i = 0; i + m - 1 < n; i++) {
                auto ss = s.substr(i, m);
                int cnt = 0;
                for (int j = 0; j < m; j++) cnt += t[j] != ss[j];
                ans = min(ans, cnt);
        }

        cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3644
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las
    

main = do
    c <- getLine
    putStrLn $ case c of
        "Sunny" -> "Cloudy"
        "Cloudy" -> "Rainy"
        "Rainy" -> "Sunny"


Measured memory_bytes: 380
s = input()
q = int(input())

printlist = []

for _ in range(q):
    c = list(map(str, input().split()))
    start = int(c[1])
    end = int(c[2]) + 1

    if c[0] == "print":
        printlist.append(s[start:end])
    elif c[0] == "reverse":
        r = s[start:end]
        sr = r[::-1]
        s = s[:start] + sr + s[end:]
    elif c[0] == "replace":
        r = c[3]
        s = s[:start] + r + s[end:]

for p in printlist:
    print(p)



Measured memory_bytes: 5620
#include<stdio.h>
int main(void){
	int h[10],i,m[3]={};
	
	for(i=0;i<10;i++){
		scanf("%d",&h[i]);
		if(m[0]<h[i]){
			m[2]=m[1];
			m[1]=m[0];
			m[0]=h[i];
			
		}
		else if(m[1]<h[i]){
			m[2]=m[1];
			m[1]=h[i];
		}
		else if(m[2]<h[i])
			m[2]=h[i];
			
		
	}
	for(i=0;i<3;i++)
	printf("%d\n",m[i]);
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
# define ll long long
# define mod 1000000007
# define lar 1000
using namespace std;
int main()
{
	int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin>>k;
	cout<<a[k-1];
	return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
n, k = map(int, readline().split())
v = [int(readline()) for _ in range(n)]
lo = max(v) - 1
hi = sum(v)
while hi - lo > 1:
    p = P = (lo + hi) // 2
    m = 1
    for i in range(n):
        if v[i] > p:
            p = P
            m += 1
        p -= v[i]
    if m <= k:
        hi = P
    else:
        lo = P
print(hi)



Measured memory_bytes: 9560
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

int main(void) {
    Int n;
    cin >> n;
    VI a(n), b(n);
    for (Int i = 0; i < n; ++i) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b.begin(), b.end());
    if (b[n - 2] == b[n - 1]) {
        for (Int i = 0; i < n; ++i) {
            cout << b[n - 1] << endl;
        }
    } else {
        for (Int i = 0; i < n; ++i) {
            if (a[i] == b[n - 1]) {
                cout << b[n - 2] << endl;
            } else {
                cout << b[n - 1] << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 6428
import sys

def main():
    N, Y = map(lambda i: int(i), input().split(' '))
    for i in range(N + 1):
        for j in range(N + 1):
            y = i
            z = j
            x = N - y - z
            s = 10000 * x + 5000 * y + 1000 * z
            if x >= 0 and Y == s:
                print(' '.join(map(lambda i: str(i), [x, y, z])))
                sys.exit()
    print('-1 -1 -1')

main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll dis[305][305];
bool x[305][305];
ll ans;
int main() {
	cin>>n;
	memset(x,1,sizeof x);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			cin>>dis[i][j];
	for(int k=1;k<=n;k++)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				if(i!=j&&i!=k&&j!=k) {
					if(dis[i][j]>dis[i][k]+dis[k][j]) {
						puts("-1");
						return 0;
					}
					if(dis[i][j]==dis[i][k]+dis[k][j])
						x[i][j]=0;
				}
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(x[i][j])
				ans+=dis[i][j];
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>

#define FOR(i, a, b) for (int i = a; i < b; i++)
#define FORN(i, a, b) for (int i = a; i <= b; i++)
#define P(s) cout << s << endl
#define PC(condition, _true, _false) if (condition) _true; else _false;
#define toInt(_char) _char - '0'

using namespace std;
//
// Created by karayuu on 2018-12-18.
//

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

    P(48 - m);
}

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

int main()
{
	int a, b;
	
	cin >> a >> b;
	
	if(a>b)
		cout << "a > b" << endl;
	else if(a<b)
		cout << "a < b" << endl;
	else
		cout << "a == b" << endl;
	
	return 0;
}

Measured memory_bytes: 1160
import java.util.*;

public class Main {
	public static void main(String[] args){
		try{
			
		Scanner inputTime = new Scanner(System.in);
		int input = inputTime.nextInt();
		int h = input / 3600;
		int amari = input % 3600;
		int m = amari / 60;
		int s = amari % 60;
		
		System.out.println(h + ":" + m + ":" + s);
		
		}catch(InputMismatchException e){
			System.out.println("数字を入力してください。");
		}
	}
}

Measured memory_bytes: 17160
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

int k;

struct Graph {
    struct Vertex { int n, d; };
    struct Edge { int i, n; };
    Graph(int n, int m) : v(n, { -1, -1 }), e(m), n(n), m(0) {}
    void add_edge(int i, int j) {
        e[m] = { j, v[i].n };
        v[i].n = m;
        m++;
    }
    void dfs(int i, int p, int d) {
        if (i == n - 1) {
            v[i].d = d;
            return;
        }
        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge& o = e[j];
            if (o.i == p) continue;

            dfs(o.i, i, d + 1);
            if (v[o.i].d >= 0) {
                v[i].d = d;
                return;
            }
        }
    }
    void dfs2(int i, int p) {
        if (v[i].d >= 0 && v[i].d * 2 > v[n - 1].d) return;
        k++;
        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge& o = e[j];
            if (o.i == p) continue;
            dfs2(o.i, i);
        }
    }
    vector<Vertex> v;
    vector<Edge> e;
    int n, m;
};

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

    int n;
    cin >> n;

    Graph g(n, (n - 1) * 2);

    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;

        g.add_edge(a, b);
        g.add_edge(b, a);
    }

    g.dfs(0, -1, 0);
    g.dfs2(0, -1);

    cout << (k > n - k ? "Fennec" : "Snuke") << endl;

    return 0;
}

Measured memory_bytes: 6272
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    vector<int> which {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    int a, b;
    cin >> a >> b;
    if(which[a] == which[b]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;


double inscribed_circle_radius(double a, double b, double c) {
  // area / half_perimeter
  double o = (a + b + c) / 2;
  return sqrt(o*(o-a)*(o-b)*(o-c)) / o;
}

int main(void) {
  int x[3], y[3];
  REP(i, 3) scanf("%d %d", &x[i], &y[i]);

  double a = std::hypot(x[0]-x[1], y[0]-y[1]);
  double b = std::hypot(x[1]-x[2], y[1]-y[2]);
  double c = std::hypot(x[2]-x[0], y[2]-y[0]);

  double r = inscribed_circle_radius(a, b, c);
  double p = max(max(a, b), c);

  double ans = p / (2 + p / r);
  printf("%.12lf\n", ans);
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
 
namespace at
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = int.Parse(Console.ReadLine());
            if(x<1200) Console.WriteLine("ABC");
            else Console.WriteLine("ARC");
        }    
    }
}

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

int main() {
    int n, m; cin >> n >> m;
    int x, y; x = 0; y = n+1;
    rep(i,m){
        int l, r; cin >> l >> r;
        x = max(x,l);
        y = min(y,r);
    }
    int ans = max(0,y-x+1);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <memory.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 200000;
struct point {
	int x, y;
	void read() {
		scanf("%d%d", &x, &y);
	}
	bool operator<(const point &p)const {
		if (x != p.x)
			return x < p.x;
		return y < p.y;
	}
}v[N];
int n;
ll calc(ll l, ll r) {
	int mn = 1e9 + 1, mx = -1;
	vector<point> s;
	for (int i = 0; i < n; ++i) {
		if (v[i].x >= l && v[i].x <= r && v[i].y >= l && v[i].y <= r) {
			s.push_back(v[i]);
			continue;
		}
		if (v[i].x >= l && v[i].x <= r) {
			mn = min(mn, v[i].y);
			mx = max(mx, v[i].y);
		}
		else {
			mn = min(mn, v[i].x);
			mx = max(mx, v[i].x);
		}
	}
	ll res = (r - l)*max(0, (mx - mn));
	if (!s.empty())
		res = 2e18;
	int until = mn;
	set<int> pushed;
	for (int i = 0; i < s.size(); ++i) {
		while (!pushed.empty() && *pushed.begin() == s[i].x)
			pushed.erase(pushed.begin());
		int cur = s[i].x;
		bool st = false;
		if (!pushed.empty() && *pushed.begin() < s[i].x) {
			st = true;
			--i;
			cur = *pushed.begin();
			pushed.erase(pushed.begin());
		}
		if (cur > until)
			break;
		int L = cur;
		int R = max(mx, s.back().x);
		R = max(R, L);
		res = min(res, (r - l)*(R - L));
		if (st)
			continue;
		until = min(until, s[i].y);
		mx = max(mx, s[i].y);
		pushed.insert(s[i].y);
	}
	return res;
}
int main()
{
	scanf("%d", &n);
	int mn = 1e9, mxmn = -1e9, mx = -1, mnmx = 1e9;
	for (int i = 0; i < n; ++i) {
		v[i].read();
		mn = min(mn, min(v[i].x, v[i].y));
		mxmn = max(mxmn, min(v[i].x, v[i].y));
		mnmx = min(mnmx, max(v[i].x, v[i].y));
		if (v[i].x > v[i].y)
			swap(v[i].x, v[i].y);
		mx = max(mx, v[i].y);
	}
	sort(v, v + n);
	ll res = calc(mn, mx);
	res = min(res, (mxmn - mn)*(ll)(mx - mnmx));
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 11632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[5];
        
        
        for (int i = 0; i < n; i++) {
            char ch = sc.next().charAt(0);
            if (ch == 'M')
                a[0]++;
            else if (ch == 'A')
                a[1]++;
            else if (ch == 'R')
                a[2]++;
            else if (ch == 'C')
                a[3]++;
            else if (ch == 'H')
                a[4]++;
        }
        
        long ans = 0;
        for (int i = 0; i <= 2; i++) {
            for (int j = i+1; j <= 3; j++) {
                for (int k = j+1; k <= 4; k++) {
                    ans += a[i] * a[j] * a[k];
                }
            }
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 43188
function Main(input) {
    const nums = input.split(/\s/).map(str => { return parseInt(str) });
    const max = Math.min(nums[1], nums[2]);
    const min = Math.max(nums[1] + nums[2] - nums[0], 0);
    console.log(max + ' ' + min);
};
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
 
int main() {
    int yyyy,mm,dd;
    char p,q;
    cin >> yyyy >> p >> mm >> q >> dd;
 
    bool res = false;
    if (yyyy < 2019) res = true;
    else if (yyyy == 2019 && mm <= 4) res = true;

    if (res) cout<<"Heisei"<<endl;
    else cout<<"TBD"<<endl;
}


Measured memory_bytes: 256
def resolve():
    S = input()
    n = len(S)
    ans = 0
    for i in range(2**(n-1)):
        s = ''
        for j in range(n):
            s += S[j]
            if i & 2**j != 0:
                s += '+'
        ans += eval(s)
    print(ans)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3060
a,b = map(int,input().split())
s = str(input())
#suji = [str(i) for i in range(10)]
ans = True
for i in range(a+b+1):
    if i==a:
        if s[i]!='-':
            ans = False
    else:
        if s[i]=='-':
            ans = False
if ans:
    print('Yes')
else:
    print('No')

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


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

    if(n%k==0)cout<<0<<endl;
    else cout<<1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int h,w;
	string ans;
	cin >>h>>w;
	rep(i,h){
		cin>>ans;
		cout<<ans<<endl<<ans<<endl;
	}

}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf 1999999999
#define ALL(x) (x).begin(), (x).end()
#define LBi(x, n) lower_bound(ALL(x), n) - (x).begin()
#define ZIP(x) (x).erase(unique(ALL(x)), (x).end())
#define Pi pair<int, int>
#define Vi vector<int>

#define rep(n) for(int i = 0; i < n; i++)

string s, t;
char ch[10];
int n, a, b, c, d, x, m[5];

int main() {
	cin >> a >> b >> c;
	if (a == b)x = c;
	else if (a == c)x = b;
	else x = a;
	cout << x << endl;
	return 0;
}


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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int x = sc.nextInt();
        int bottomArea = a * a;
        int cube = a * a * a;
        int volume = bottomArea * b;
        double radian = 0.0;

        if (volume / 2 <= x) {
            radian = Math.atan((2.0 * volume - 2.0 * x) / cube);
        } else {
            radian = (Math.PI / 2.0) - Math.atan((2.0 * x) / (a * b * b));
        }
        double angle = radian * 180.0 / Math.PI;
        out.printf("%.10f\n", angle);
        out.flush();
    }
}


Measured memory_bytes: 22868
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:108777216")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <bitset>
#include <queue>
#include <algorithm>
#include <ctime>
using namespace std;
 
int const MAX_N = 128;
int const DX[4] = {-1,1,0,0};
int const DY[4] = {0,0,-1,1};

char st[MAX_N];
char s[MAX_N][MAX_N];

int dst[MAX_N][MAX_N];
struct node {int x,y;} och[MAX_N*MAX_N];

void my_gets(char * st) {
	int len = 0;
	char ch = getc(stdin);
	while (ch != '\n' && ch != '\r' && ch != 0 && !feof(stdin)) {
		st[len++] = ch;
		ch = getc(stdin);
	}
	st[len] = 0;
}

int main() {
  //  freopen("input.txt","r",stdin);
   // freopen("output.txt","w",stdout);
 
	int n,m;
	my_gets(st);
	sscanf(st,"%d%d",&n,&m);
    
	for (int i=0; i<n; i++) {
		my_gets(st);
		for (int j=0; j<m; j++) s[i][j] = st[j];
	}

	int p_read = 0, p_write = 1;
	och[0].x = 0;
	och[0].y = 0;
	for (int i=0; i<n; i++)
		for (int j=0; j<m; j++)
			dst[i][j] = 1000000000;
	dst[0][0] = 0;
	while (p_read < p_write) {
		int x = och[p_read].x;
		int y = och[p_read].y;
		p_read++;

		for (int k=0; k<4; k++) {
			int xx = x + DX[k];
			int yy = y + DY[k];
			if (xx >= 0 && xx < n && yy >= 0 && yy<m)
				if (dst[xx][yy] > dst[x][y] + 1)
					if (s[xx][yy] != '#') {
						dst[xx][yy] = dst[x][y] + 1;
						och[p_write].x = xx;
						och[p_write].y = yy;
						p_write++;
					}
		}
	}
	
	if (dst[n-1][m-1] > 5000000) cout<<"-1";
	else {
		int cnt = dst[n-1][m-1] + 1;
		int ans = n * m - cnt;
		for (int i=0; i<n; i++)
			for (int j=0; j<m; j++)
				ans -= s[i][j] == '#';
		cout<<ans;
	}
    return 0;
}  


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

typedef long long ll;
ll n, a, b, c, d;

int main() {
    scanf("%lld %lld %lld %lld %lld", &n, &a, &b, &c, &d), n--;
    for (ll i = 0; i <= n; i++) {
        ll l1 = a + i * c, r1 = a + i * d;
        ll l2 = b + (n - i) * c, r2 = b + (n - i) * d;
        if (max(l1, l2) <= min(r1, r2)) printf("YES\n"), exit(0);
    }
    printf("NO\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

ll n, a[100100];

int main() {
	cin >> n;
	ll MIN = INF;
	ll MAX = 0;
	REP(i, n) {
		cin >> a[i];
		MIN = min(MIN, a[i]);
		MAX = max(MAX, a[i]);
	}
	cout << MAX - MIN << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int mod = 1000000007;

int main(){
    int n, h;
    cin >> n >> h;
    vi a(n), b(n);
    rep(i, n){
        cin >> a[i] >> b[i];
    }

    sort(b.begin(), b.end(), greater<int>());

    int count = 0;

    int a_max = 0;
    rep(i, n){
        a_max = max(a_max, a[i]);
    }

    rep(i, n){
        if(a_max < b[i]){
            h -= b[i];
            count++;
        }
        if(h <= 0) break;
    }

    if(h>0){
        count += (h/a_max);
        if(h%a_max!=0) count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 1024
use std::collections::HashMap;

fn main() {
    let s: String = read();
    let mut map: HashMap<char, usize> = HashMap::new();

    for c in s.chars() {
        let v = map.entry(c).or_insert(0);
        *v += 1;
    }

    if map.len() != 2 {
        println!("No");
        return;
    }

    for (_, v) in map.iter() {
        if *v != 2 {
            println!("No");
            return;
        }
    }

    println!("Yes");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 2160
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
const int M=100010;
const int INF=1000000007;
using ll=long long;

int main(){
	int n,a[M];
	vector<int> v(M);
	ll ans=1;
	cin>>n;
	v[0]=v[1]=0;
	rep(i,0,n)cin>>a[i];
	sort(a,a+n);
	rep(i,1,n){
		if(a[i-1]==a[i]){
			v.push_back(a[i]);
			i++;
		}
	}
	sort(ALL(v),greater<int>());
	ans=ans*v[0]*v[1];
	cout<<ans<<endl;
}


Measured memory_bytes: 1408
import std.stdio;
import std.string;
import std.conv;
import std.math;

void main() {
	string[] inputs = split(readln());
	//int r = to!int(inputs[0]);
	int g = to!int(inputs[1]);
	int b = to!int(inputs[2]);
	
	if((10*g + b) % 4 == 0) "YES".writeln;
	else "NO".writeln;
}


Measured memory_bytes: 256
//首先若k是偶数，答案显然是k/2，k，k，k……
//若k是奇数，我们考虑这样一个序列B：k/2，k/2，k/2……的排名。
//构造一个映射f(X)->X’，X是一个序列，X’是每个Xi替换成k-Xi+1后的序列，
//这显然是一个一一映射，那么除了X是B的前缀以外，每个X和X’的排名都是一个再B前，
//一个再B后。那么B的排名就是(S+1)/2+N/2，S为数列总个数。
//于是从B往前倒推N/2个即是答案。
//代码：

#include<cstdio>
#include<iostream>
using namespace std;
int n,k;
int a[300010];
int main()
{
    scanf("%d%d",&k,&n);
    if(k&1)
    {
        for(int i=1;i<=n;i++)
            a[i]=(k+1)/2;
        int last=n;
        for(int i=1;i<=n/2;i++)
            if(a[last]==1) last--;
            else
            {
                a[last]--;
                for(int j=last+1;j<=n;j++)
                    a[j]=k;
                last=n;
            }
        for(int i=1;i<=last;i++)
            printf("%d ",a[i]);
    }
    else
    {
        printf("%d ",k/2);
        for(int i=2;i<=n;i++)
            printf("%d ",k);
    }
    return 0;
}


Measured memory_bytes: 3456
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, map) for(auto it = m.begin(); it != m.end(); it++)

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll H, W; cin >> H >> W;
    vvl as(H + 1, vl(W + 1, 0));
    FOR(i, 1, H + 1){
        FOR(j, 1, W + 1){
            cin >> as[i][j];
        }
    }
    
    bool started = false;
    vs ret_str;
    string one_lin;
    FOR(idx, 0, H * W){
        ll w = idx / H + 1;
        ll h = (w % 2 == 1) ? idx % H + 1: H - (idx % H);
        if(as[h][w] % 2 == 0){
            if(started){
                one_lin += " " + to_string(h) + " " + to_string(w);
                ret_str.push_back(one_lin);
                one_lin = to_string(h) + " " + to_string(w);
            }
        }
        else{
            if(started){
                one_lin += " " + to_string(h) + " " + to_string(w);
                ret_str.push_back(one_lin);
                one_lin = "";
                started = false;
            }
            else{
                one_lin = to_string(h) + " " + to_string(w);
                started = true;
            }
        }
    }
    cout << ret_str.size() << endstr;
    REP(i, ret_str.size()){
        cout << ret_str[i] << endstr;
    }
    return 0;
}


Measured memory_bytes: 12532
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};
using namespace std;
typedef long long  ll;
typedef pair<int, int> P;

/** Problem2006 : Keitai Message **/
int main()
{
	string list[10] = {"#", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
	int l[10] = {0, 5, 3, 3, 3, 3, 3, 4, 3, 4};
	int n;
	cin >> n;
	rep(k, n) {
		string in, ans;
		cin >> in;
		int tmp=-1; char c='#';
		rep(i, in.length()) {
			if (in[i]!='0') {
				tmp++; tmp%=l[in[i]-'0'];
				c = list[in[i]-'0'][tmp];
			} else {
				if (c != '#')
					ans+=c;
				tmp=-1;
				c='#';
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1216
#include<stdio.h>

#define G_SIZE 100
struct node{
	int d, f, l;
};

int fds(struct node G[][G_SIZE+1], int size, int id, int t)
{
	int i;

	G[id][id].d = t++;
	for(i = 1; i <= size; i++){
		if((G[id][i].l == 1) && (G[i][i].d == 0)){
			 t = fds(G, size, i, t);
		}
	}
	G[id][id].f = t++;
	return(t);
}

int main(int argc, char* argv[])
{
	int u, k, n, v, i, j, t;
	struct node G[G_SIZE+1][G_SIZE+1];

	for(i = 1; i <= G_SIZE; i++){
		for(j = 1; j <= G_SIZE; j++){
			G[i][j].d = 0;
			G[i][j].f = 0;
			G[i][j].l = 0;
		}
	}

	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%d", &u);
		scanf("%d", &k);
		for(j = 0; j < k; j++){
			scanf("%d", &v);
			G[u][v].l = 1;
		}
	}

	t = 1;
	for(i = 1; i <= n; i++){
		for(j = 1; j <= n; j++){
			if((G[i][j].l == 1) && (G[j][j].d == 0)){
				t = fds(G, n, i, t);
			}
		}
	}

	for(i = 1; i <= n; i++){
		printf("%d %d %d\n", i, G[i][i].d, G[i][i].f);
	}

	return(0);
}

Measured memory_bytes: 716
S = list(input())
T = list(input())
NS,NT = len(S),len(T)
outs = []
if NS>=NT:
    for i in range(NS-NT+1):
        flag = 0
        for j in range(NT):
            if S[i+j]==T[j] or S[i+j]=="?":
                continue
            else:
                flag = 1
                break
        if flag==0:
            out = ["a"]*NS
            for j in range(NT):
                out[i+j]=T[j]
            for j in range(NS):
                if S[j]!="?":
                    out[j]=S[j]
            outs.append("".join(out))

if len(outs) == 0:
    print("UNRESTORABLE")
else:
    outs.sort()
    print(outs[0])

Measured memory_bytes: 62996
n = int(input())
a = list(map(int, input().split()))

h_max = 0
step_h = 0
for i in range(n):
  if a[i] < h_max:
    step_h += h_max - a[i]
  if a[i] > h_max:
    h_max = a[i]

print(step_h)
    

Measured memory_bytes: 32104
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = Integer.parseInt(scanner.next());
        int b = 1000-(a%1000);
        if (b==1000){b=0;}
            System.out.println(b);
        }
    }


Measured memory_bytes: 35576
#include<cstdio>
#include<complex>
typedef std::complex<double>P;
double C(P a,P b){return a.real()*b.imag()-a.imag()*b.real();}
int F(P p,P a,P b,P c)
{
	double x=C(b-a,p-a),y=C(c-b,p-b),z=C(a-c,p-c);
	return x>0&&y>0&&z>0||x<0&&y<0&&z<0;
}
int main()
{
	P p[5];
	int n,i,x,y;
	for(scanf("%d",&n);n--;)
	{
		for(i=0;i<5;++i)scanf("%d%d",&x,&y),p[i]=P(x,y);
		puts((F(p[3],p[0],p[1],p[2])^F(p[4],p[0],p[1],p[2]))?"OK":"NG");
	}
}

Measured memory_bytes: 0
import java.io.*;
public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader mBufferedReader=new BufferedReader(new InputStreamReader(System.in));
        String str=mBufferedReader.readLine();
        String[] arr=str.split(" ");
        
        int a=Integer.parseInt(arr[0]);
        int b=Integer.parseInt(arr[1]);
     
        if(a>b){
            System.out.println("a > b");
        }else if(a<b){
            System.out.println("a < b");
        }else{
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 24192
#include<iostream>
#include<cmath>
#include<string>
#include<cctype>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
        for(;;){
                int x,y;
                cin>>x>>y;
                if(x==0 && y==0){
                        break;
                }else{
                        if(x<y){
                                printf("%d %d\n",x,y);
                        }else{
                                printf("%d %d\n",y,x);
                        }
                }
        }
        return 0;
}

Measured memory_bytes: 1136
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
#define INF 1<<20

struct edge{
	int to;
	int cost;
	edge() {};
	edge(int a, int b) {
		to = a;
		cost = b;
	}
};

struct Node {
	int pos;
	int cost;
	Node() {};
	Node(int a, int b) {
		pos = a;
		cost = b;
	}
	bool operator <(const Node& rhs) const {
		return cost > rhs.cost;
	}
};

void dijkistra(int st, int TO,int V,vector<vector<edge> > graph) {
	priority_queue<Node> q;
	vector<int> d(V);
	for (int i = 0;i < V;i++) {
		d[i] = INF;
	}
	d[st] = 0;
	q.push(Node(st, 0));
	while (!q.empty()) {
		Node s = q.top(); q.pop();
		int pos = s.pos;
		for (int i = 0;i < graph[pos].size();i++) {
			int to = graph[pos][i].to;
			int cost = graph[pos][i].cost;
			if (d[pos] + cost < d[to]) {
				d[to] = d[pos] + cost;
				q.push(Node(to, d[to]));
			}

		}
	}
	cout << d[TO] << endl;
}
int partition(int A[],int p, int r) {
	int x = A[r];
	int i = p - 1;
	for (int j = p;j < r;j++) {
		if (x >= A[j]) {
			i = i + 1;
			swap(A[i], A[j]);
		}
	}
		swap(A[i + 1], A[r]);
		return i + 1;
}
void quicksort(int A[], int p, int r) {
	if (p < r) {
		int q = partition(A, p, r);
		quicksort(A, p, q-1);
		quicksort(A, q + 1, r);
	}
}

int getNumberOfCoin(int C[],int n,int m) {
	int T[50000];
	for (int j = 0;j <= n;j++) {
		T[j] = INF;
	}
	T[0] = 0;
	for (int i = 0;i < m;i++) {
		for (int j = 0;j <= n;j++) {
			if (j - C[i] >=0  ) {
				T[j] = min(T[j], T[j - C[i]] + 1);
			}
		}
	}
	return T[n];
}
int knapsack(int w, int n,int* v,int* ww) {
	int W[101][10001];
		for (int j = 0;j <= w;j++) {
			W[0][j] = 0;
		}
	for (int i = 0;i < n;i++) {
		for (int k = 0;k < n;k++){
			for (int j = 0;j <= w;j++) {
				if (j - ww[k] < 0) {
					W[i + 1][j] = W[i][j];
				}
				if (j - ww[i] >= 0) {
					W[i + 1][j] = max(W[i][j], W[i][j - ww[k]] + v[k]);

				}
			}
		}
	}
	return W[n][w];
}
int fib(int n) {
	vector<int> v(n+1);
	v[0] = 1;
	v[1] = 1;
	for (int i = 2;i < n+1;i++) {
		v[i] = v[i - 2] + v[i - 1];
	}
	return v[n];
}
int isPrime(int x) {
	if (x <= 1) return false;
	if (x>2 && x % 2 == 0) return false;
	for (int i = 2;i <= sqrt(x);i++) {
		if (x%i == 0) {
			return false;
		}
	}
	if (x == 2) return true;
	return true;
}
int Prime(int x) {
	vector<int> prime(x+1,1);
	int num = 2;
	while (num <= sqrt(x)) {
		for (int i = 2;i <= x / num;i++) {
			prime[num*i] = 0;
		}
		num++;
		while (prime[num] == 0)
			num++;
	}
	int count = 0;
	for (int i = 2;i < x + 1;i++) {
		if (prime[i] == 1) count++;
	}
	return count;
}
int main(){
	int n;
	vector<int> a;
	while (cin >> n) {
		a.push_back(n);
	}
	for (int j = 0;j < a.size();j++){
		cout<<Prime(a[j])<<endl;
	}
	

}

Measured memory_bytes: 5380
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int64_t i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    vector<int64_t> A(N);
    rep(n,0,N) cin>>A.at(n);

    int64_t ans=0, t=1;
    rep(i,0,60){
        int64_t one=0,zero=0;
        rep(j,0,N){
            if(A.at(j)&((int64_t)1<<i)) one++;
            else zero++;
        }

        int64_t _ans=(one*zero)%MOD*t%MOD;
        ans=(ans+_ans)%MOD;
        t=(t*2)%MOD;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 5540
#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back

#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

std::vector<int> get_prefix(string str)
{
    int n=str.size();
    std::vector<int> pi(n,0);
    for(int i=1;i<n;++i)
    {
        int j=pi[i-1];
        while(j>0&&str[i]!=str[j])
            j=pi[j-1];
        if(str[i]==str[j])
            ++j;
        pi[i]=j;
    }
    return pi;
}
std::vector<int> nex;
vector<int> longest;
int dfs(int ix)
{
    if((nex[ix]!=-1))
    {
        if(longest[nex[ix]]==0){dfs(nex[ix]);}
    }
    longest[ix]=((nex[ix]==-1)?1:(1+longest[nex[ix]]));
}
signed main()
{
    speed
    string s,t;cin>>s>>t;
    string ts;
    while(ts.length()<t.length())
    {
        ts+=s;
    }
    string master=(t+'#'+ts+ts);
    int tlen=t.length(),slen=s.length();
    
    nex.resize(slen,-1);
    longest.resize(slen,0);
    
    std::vector<int> pi=get_prefix(master),todo;
    int len=master.size();
    std::vector<bool> node(slen,0);
    for(int i=0;i<slen;++i)
    {
        if(pi[(i+tlen+1)+tlen-1]==tlen)
        {
            node[i]=1;
            nex[i]=((i+tlen)%slen);
        }
    }
    for(int i=0;i<slen;++i)
    {
        if(nex[i]!=-1)
        {
            if(!node[nex[i]])
            {
                nex[i]=-1;
            }
        }
        //cout<<i<<" "<<nex[i]<<"\n";
    }
    int ans=0;
    for(int i=0;i<slen;++i)
    {
        if(node[i]&&(longest[i]==0))
        {
            int pres=nex[i];
            int tot=0;
            while(pres!=-1)
            {
                if(pres==i)
                    {cout<<-1<<"\n";return 0;}
                pres=nex[pres];
            }
            dfs(i);
        }
        ans=max(longest[i],ans);
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 35424