akhauriyash/Code-Regression huggingface dataset:
def resolve():
    # from collections import deque
    k = int(input())
    a = list(map(int, input().split()))
    rl = [2, 2]
    ra = a[::-1]

    for i in range(k):
        nxt = []
        nowa = ra[i]
        if (rl[-1] // nowa) - ((rl[0]-1)//nowa) > 0:
            nxt.append((((rl[0]-1)//nowa)+1)*nowa)
            nxt.append((rl[-1]//nowa)*nowa + nowa-1)
        if not nxt:
            print(-1)
            exit()
        rl = nxt

    print("{} {}".format(rl[0], rl[-1]))
resolve()

Measured memory_bytes: 85668
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main(void){
	int n;

	cin >> n;

	vector<int> t(n+1, 0), x(n+1, 0), y(n+1, 0);

	for (int i = 1; i < n + 1; i++){
		cin >> t[i] >> x[i] >> y[i];
	}

	int ok = 1;
	for (int i = 1; i < n + 1; i++){
		if (abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]) <= t[i] - t[i-1]
		 && (abs(x[i] - x[i-1]) + abs(y[i] - y[i-1])) % 2 == (t[i] - t[i-1]) % 2)
			;
		else
			ok = 0;
	}

	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}	


Measured memory_bytes: 1408
## 貪欲
# 大きい数xとすると、2べきになるyは一意に定まる
# x < x + y < = 2*x
from collections import defaultdict

N = int(input())
As = sorted(list(map(int, input().split())),reverse=True)
d = defaultdict(int)
for a in As:
    d[a] += 1

cnt = 0
for a in As:
    if d[a] == 0:continue
    d[a] -= 1
    n = 0
    while 2**n <= a:
        n += 1
    p = 2**n - a
    if d[p] > 0:
        cnt += 1
        d[p] -= 1

print(cnt)



Measured memory_bytes: 111828
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll mod = 1000000007;
  ll N, K;
  cin >> N >> K;
  ll small = 0, large = 0;
  for (ll i = 0; i < K; ++i) {
    small += i;
    large += N - i;
  }
  ll ans = large - small + 1;
  for (ll i = K; i <= N; ++i) {
    small += i;
    large += N - i;
    ans = (large - small + 1 + ans) % mod;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 3636
N = int(input())
a = [int(input()) for i in range(N)]

a.sort()
S=sum(a)

if S%10!=0:
    print(S)
else:
    for i in a:
        if i%10!=0:
            S=S-i
            print(S)
            break

        if i==max(a):
            if i%10==0:
                print("0")
                break
            



Measured memory_bytes: 2940
from __future__ import print_function

import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

import math
# import string
import fractions
from fractions import Fraction
from fractions import gcd

def lcm(n,m):
    return int(n*m//gcd(n,m))

# import re
# import array
# import copy
# import functools
# import operator

# import collections
# import itertools
# import bisect
# import heapq


# from heapq import heappush
# from heapq import heappop
# from heapq import heappushpop
# from heapq import heapify
# from heapq import heapreplace

# from queue import PriorityQueue as pq

def reduce(p, q):
    common = fractions.gcd(p, q)
    return (p//common , q//common )
# # from itertools import accumulate
# # from collections import deque

# from operator import mul
# from functools import reduce

# def combinations_count(n, r):
#     r = min(r, n - r)
#     numer = reduce(mul, range(n, n - r, -1), 1)
#     denom = reduce(mul, range(1, r + 1), 1)
#     return numer // denom

# import random

def main():
    a,b = map(int, input().strip().split())
    print(lcm(a,b))
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 63980
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define all(x) x.begin(),x.end()
using namespace std;
inline int mex(unordered_set<int> st)
{
	int m = 0;
	while (st.find(m) != st.end())
	{
		m += 1;
	}
	return m;
}
inline int calculateGrundy(int n)
{
	if (n == 1)
		return 0;
	unordered_set<int> mexi;
	for (int i = 1; i <= sqrt(n); i += 1)
	{
		if (n % i == 0)
		{
			if (n / i != n)
				mexi.insert(calculateGrundy(n / i));
			mexi.insert(calculateGrundy(i));
		}
	}
	return mex(mexi);
}
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
inline ll power(ll base, ll exp)
{
	ll ans = 1;
	while (exp > 0)
	{


		if (exp % 2 != 0)
			ans = (ans * base) % N;

		base = (base * base) % N;
		exp /= 2;
	}
	return ans % N;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n, m;
	ll ans = 0;
	cin >> n >> m;
	f(i, 0, m)
	{
		ll t;
		cin >> t;
		ans += t;
	}
	if (ans > n)
		cout << "-1";
	else
		cout << n - ans;
	return 0;
}

Measured memory_bytes: 3656
// stay fuckin hard -- Abhinav -IIITA
#include<bits/stdc++.h>
#define int long long
#define ld long double
using namespace std;
int mod=1e9;
ld pi=3.1415926535;
int32_t main(){
	int n,m; cin>>n>>m;
	int s=0;
	while(m--){
		int t; cin>>t;
		s+=t;
	}
	n-=s;
	n<0 ? cout<<-1 : cout<<n;
	return 0;
}


Measured memory_bytes: 3568
import math

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

n,x = map(int,input().split())
t   = list(map(int,input().split()))

ans = abs(t[0]-x)
for i in range(1,len(t)):
    t[i] = abs(t[i]-x)
    ans = gcd(ans,t[i])

print(ans)


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

int main() {
    cin >> k;
    while (k > a) {
        a *=1.01;
        b++;
    }
    cout << b;
}

Measured memory_bytes: 3636
max = -1000000
min = 1000000
sum = 0

n = gets.to_i
numbers = gets.split
for i in 0..n-1
    if numbers[i].to_i >= max
        max = numbers[i].to_i
    end
    if numbers[i].to_i <= min
        min = numbers[i].to_i
    end
    sum += numbers[i].to_i
end
puts "%d %d %d" %[min, max, sum]


Measured memory_bytes: 8900
#include<stdio.h>

int main()
{

    //input
  int N, swap, cnt=0, mini;
  scanf("%d", &N);
  int A[N];
  for(int i=0; i<N; i++) scanf("%d", &A[i]);
  //calc
  for(int i=0; i<N; i++)
    {
      mini = i;
      for(int j = i; j<N; j++)
	{
	  if(A[j] < A[mini])
	  {
	    mini = j;

	  }
	}
      if(i!=mini)
	{
      	    swap=A[i];
	    A[i] = A[mini];
	    A[mini] = swap;
	    cnt++;
	}
    }

  for(int i=0; i<N; i++)
  {
    printf("%d", A[i]);
    if(i!=N-1) printf(" ");
  }
  printf("\n%d\n", cnt);
  return 0;

}



Measured memory_bytes: 2048
import sys
import os
import fractions

MOD = 10 ** 9 + 7


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B, C, D = list(map(int, sys.stdin.readline().split()))
    E = B - A + 1

    ret = 0
    ret += B // C
    ret += B // D
    ret -= (A - 1) // C
    ret -= (A - 1) // D
    ret -= B // lcm(C, D)
    ret += (A-1) // lcm(C, D)
    print(E - ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5304
#include <bits/stdc++.h>
using namespace std;
#define int long long
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;
//cout<<fixed<<setprecision(15);

signed main(){
    int n; cin >> n;
    string s; cin >> s;
    int res=1;
    rep(i,n-1){
        if(s[i]!=s[i+1]) res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true) {
			String s = scan.next();
			if(s.equals("-")) {
				break;
			}
			int m = scan.nextInt();
			for(int i = 0; i < m; i++) {
				int t = scan.nextInt();
				s = s.substring(t, s.length()) + s.substring(0, t);
			}
			System.out.println(s);
		}
		scan.close();
	}
}


Measured memory_bytes: 26260
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
template <typename T> T In() {
    T t;
    cin >> t;
    return t;
}
template <typename T> vector<T> ReadVec1(int N) {
    vector<T> vec(N);
    for(int i = 0; i < N; i++)
        vec[i] = In<T>();
    return move(vec);
}
template <typename T> vector<vector<T>> Vec2(int i, int j, T ini = 0) {
    vector<vector<T>> vec(i, vector<T>(j, ini));
    return move(vec);
}
template <typename T>
vector<vector<vector<T>>> Vec3(int i, int j, int k, T ini = 0) {
    vector<vector<vector<T>>> vec(i, vector<vector<T>>(j, vector<T>(k, ini)));
    return move(vec);
}

int count(const vector<int> &bs, int i) {
    int c = 0;
    for(int n = 1; i * n <= bs.size(); n++) {
        if(bs[i * n-1] == 1)
            c++;
    }
    return c;
}

int main() {
    int N = In<int>();
    vector<int> as(N, 0), bs(N, 0);
    for(int i = 1; i <= N; i++) {
        as[i-1] = In<int>();
    }

    int num = 0;
    for(int i = N; i > 0; i--) {
        if(count(bs, i) % 2 != as[i-1]) {
            bs[i-1] = 1;
            num++;
        }
    }

    cout << num << endl;
    for(int i = 1; i <= N; i++) {
        if(bs[i-1] == 1)
            cout << i << endl;
    }
}

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

int main() {
  int N,M;
  cin>>N>>M;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  int S=0;
  for(int i=0;i<N;i++){
    S=S+A.at(i);
  }
  int B=0;
  for(int i=0;i<N;i++){
    if(A.at(i)>=(10000*S/(4*M))*0.0001){
      B=B+1;
    }
  }
  if(B>=M){
    cout<<"Yes"<< endl;
  }
  else{
    cout<<"No"<< endl;
  }
}
      


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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var firstLine = Console.ReadLine().Split(' ').Select(value => long.Parse(value)).ToList();
			var n = firstLine[0];
			var k = firstLine[1];

			long count = 0;

			for (long i = k; i <= n + 1; i++)
			{
				count += ((n + (n - (i - 1))) * i / 2) - (((i - 1) * i / 2) - 1);
				count %= 1000000007;
			}

			Console.WriteLine(count);
		}
	}
}


Measured memory_bytes: 19052
/*input
1
3 3
1 2 3
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
#define PI 3.14159265
#define endl '\n'
#define debug(x) cout << #x << " = " << x << endl;
#define MAX 100001

template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(ll a, ll b) {a += b; if (a < 0) a += mod; return a;}
inline int sub(ll a, ll b) {a -= b; if (a < 0) a += mod; return a;}
inline int mul(ll a, ll b) {return (a * 1ll * b) % mod;}
inline int pwr(ll x, ll y) {
    int ans = 1 % mod;
    while (y) {
        if (y & 1) ans = mul(ans, x);
        x = mul(x, x);
        y >>= 1;
    }
    return ans;
}
inline int inv(int a) {return pwr(a, mod - 2);}

vector <int> adj[MAX];


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

    int a, b, c;
    cin >> a >> b >> c;
    cout << min(b / a, c) << endl;
    
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <queue>
#include <set>

using namespace std;

constexpr int inf = 1e9+7;

int main () {
    int N;
    cin>>N;
    set<int> mochi;
    for (int n = 0; n < N; n++) {
        int d;
        cin>>d;
        mochi.insert(d);
    }
    cout<<mochi.size()<<endl;

    return 0;
}

Measured memory_bytes: 256
// 2015/03/09 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int t;
		cin >> t;

		if(t==0)
			break;

		int n;
		cin >> n;

		int sum = 0;

		for(int i=0; i<n; i++){
			int s, f;
			cin >> s >> f;

			sum += (f-s);
		}

		if(sum>=t){
			cout << "OK" << endl;
		}
		else{
			cout << t-sum << endl;
		}
	}

	return 0;
}

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

using namespace std;
#define next _next
#define y1 _y1
#define y2 _y2
#define lowbit(x) (x&(-x))
#define lc ((rt)<<1)
#define rc ((rt)<<1|1)
#define mid  ((l+r)>>1)
#define clr(a, b) memset(a,b,sizeof(a))

#ifdef __LOCAL_DEBUG__
#define _debug(fmt, ...)fprintf(stdout,"\033[94m%s: " fmt "\n\033[0m",__func__,##__VA_ARGS__)
#define debug(a) cerr <<"\033[94m" <<#a << "\033[0m = "<< a << endl;
#define debug_loop(v) {cerr <<#v;for(auto x:v) cerr <<"\033[94m " <<x<<"\033[0m";cerr<<endl;}
#else
#define _debug(...)((void)0)
#define debug(a)((void)0)
#define debug_loop(v)((void)0)
#endif

typedef long long ll;
const double pi = acos(-1);
const double eps = 1e-10;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = static_cast<int>(1e6 + 7);

int main() {
#ifndef __LOCAL_DEBUG__
    ios::sync_with_stdio(false), cin.tie(nullptr);
#endif
    char g[101][101];
    int flag_n[101], flag_m[101];
    int n, m;
    clr(flag_m, 0);
    clr(flag_n, 0);
    cin >> n >> m;
    for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> g[i][j];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            if (g[i][j] == '#') {
                flag_n[i] = 1;
                break;
            }

    for (int i = 0; i < m; i++)
        for (int j = 0; j < n; j++)
            if (g[j][i] == '#') {
                flag_m[i] = 1;
                break;
            }


    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (flag_m[j] == 0 || flag_n[i] == 0) continue;
            cout << g[i][j];
        }
        if (flag_n[i]) cout << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef DEBBY
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define ll long long
#define rep(i,a,b) for(int i=int(a); i<=int(b); i++)
#define sz(v)  (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
#define fs first
#define sd second
#define pb push_back


void solve(){
    int n; cin >> n;
    vi v(n);
    rep(i,0,n-1)
      cin >> v[i];
    sort(all(v));
    int middle = n >> 1;
    cout << v[middle] - v[middle-1];
} 

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}
    





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

const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
    mint choose(int n, int a){
        mint x = 1 ,y = 1;
        for(int i=0; i<a; ++i){
            x *= n-i;
            y *= i+1;
        }
        return x / y;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

int main(){
    int x,y;
    cin>>x>>y;
    int n=(-x+2*y)/3;
    int m=(2*x-y)/3;
    if(n<0||m<0||(-x+2*y)%3!=0){cout<<0<<endl; return 0;}
    cout<<mint().choose(n+m,n)<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// debug & operator << (debug & dd, P p) { dd << "(" << p.x << ", " << p.y << ")"; return dd; }

const int nax = 2005;
char grid[nax][nax];
bool pion[nax][nax], poziom[nax][nax];
// int len_pion[nax][nax], len_poziom[nax][nax];
int len[nax][nax];

int main() {
	int h, w;
	scanf("%d%d", &h, &w);
	if(min(h, w) == 1) {
		printf("%d\n", h * w);
		return 0;
	}
	for(int i = 0; i < h; ++i) {
		for(int j = 0; j < w; ++j) {
			scanf(" %c", &grid[i][j]);
		}
	}
	for(int row = 0; row < h; ++row) {
		for(int col = 0; col < w; ++col) {
			if(row != h - 1) {
				pion[row][col] = (grid[row][col] != grid[row+1][col]);
			}
			if(col != w - 1) {
				poziom[row][col] = (grid[row][col] != grid[row][col+1]);
			}
		}
	}
	for(int row = h - 2; row >= 0; --row) {
		for(int col = w - 1; col >= 0; --col) {
			if(col + 1 < w && pion[row][col] == pion[row][col+1]) {
				len[row][col] = 1 + len[row][col+1];
				// len_pion[row][col] = 1 + pion[row+1][col];
			}
			else {
				len[row][col] = 1;
			}
		}
	}
	int answer = 0;
	for(int col = 0; col < w; ++col) {
		vector<int> v;
		for(int row = 0; row < h - 1; ++row) {
			v.push_back(len[row][col]);
		}
		debug() << imie(v);
		vector<pair<int,int>> they;
		int n = v.size();
		for(int i = 0; i < n; ++i) {
			they.emplace_back(v[i], i);
		}
		sort(they.begin(), they.end());
		set<int> already{-1, n};
		for(pair<int,int> p : they) {
			int i = p.second;
			int value = p.first;
			auto it = already.upper_bound(i);
			int R = *it;
			--it;
			int L = *it;
			int len = R - L;
			debug() << imie(len) imie(value);
			already.insert(i);
			answer = max(answer, len * value);
		}
	}
	printf("%d\n", max({answer, h, w}));
}



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

int main(){
  int K;
  cin >> K;
  int ans=0;
  if(K%2 == 0){
    ans = (K/2)*(K/2);
  }else{
    ans = ((K/2)+1)*(K/2);
  }

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, const char *argv[]) {
  int Y, M, D;
  char c1, c2;
  cin >> Y >> c1 >> M >> c2 >> D;

  if(M > 4){
    cout << "TBD" << endl;
  }else{
    cout << "Heisei" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
  	cin>>n;
  	vector<int>v(n);
  	for(int i=0;i<n;i++){
      cin>>v.at(i);
	}
	sort(v.begin(),v.end());
	int count=0;
	for(int i=0;i<n-1;i++){
    	if(v.at(i)==v.at(i+1)){
         count++; 
        }
    }
	if(count==0){
    	cout<<"YES"<<endl;
    }
	else{
    	cout<<"NO"<<endl;
    }


}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
using namespace std;
class Cir{
public :
    int x,y,r;
};
class Node{
public :
    double d;int u;
    Node(double b,int a){
        u=a; d=b;
    }
    bool operator<(Node t)const{
        return d>t.d;
    }
};
int n;
Cir cs[1005];
double  dist(int x,int y){
    double temp=(long long)(cs[x].x-cs[y].x)*(cs[x].x-cs[y].x)+(long long int)(cs[x].y-cs[y].y)*(cs[x].y-cs[y].y);
    temp=sqrt(temp);
    temp=temp-cs[x].r-cs[y].r;
    if(temp<0)return 0.0;
    return  temp;
}
double  d[1005];
bool done[1005];
priority_queue<Node>Q;
int main(){
    int xs,ys,xt,yt;
    cin>>xs>>ys>>xt>>yt;
    cin>>n;
    cs[0].x=xs; cs[0].y=ys; cs[0].r=0;
    cs[1].x=xt; cs[1].y=yt; cs[0].r=0;
    for(int i=2;i<n+2;i++){
        scanf("%d%d%d",&cs[i].x,&cs[i].y,&cs[i].r);
    }
    for(int i=1;i<n+2;i++){
        d[i]=1e20;
    }
    d[0]=0;
    memset(done,0,sizeof(done));
    Q.push(Node(0.0,0));
    while(!Q.empty()){
        Node x=Q.top();Q.pop();
        int u=x.u;
        if(done[u])continue;
        done[u]=1;
        for(int i=1;i<n+2;i++){
            if(i!=u&&!done[i]){
                if(d[i]>d[u]+dist(u,i)){
                    d[i]=d[u]+dist(u,i);
                    Q.push(Node(d[i],i));
                }
            }
        }
    }
    printf("%.10lf\n",d[1]);
return 0;
}


Measured memory_bytes: 4464
from fractions import gcd
from functools import reduce
 
N = int(input())
A = list(map(int, input().split()))
 
MOD = 10 ** 9 + 7
 
lcm = reduce(lambda x,y: x*(y//gcd(x,y)), A)
 
answer = sum(lcm//x for x in A)
answer %= MOD
print(answer)


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

int main(){
  int n;
  cin >> n;
  int count = 0;
  rep(i, n){
    rep(j, n){
      if (n <= i * j) break;
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long long
using namespace std;

int H;
int dfs(int H){
  if( H == 1 ){
    return 1;
  }else{
    int A = 2 * dfs(H/2) + 1;
    H /= 2;
    return A;
  }
}
signed main() {
  cin >> H;
  cout << dfs(H) << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int dp[104][110000];
int v[104],w[104];
int32_t main()
{
	int n=in();int W=in();
	for(int i=1;i<=n;i++)
	{w[i]=in();v[i]=in();}
	
	int w1=w[1];
	//shifting the origin of weights
	if(w1>1000)
	for(int i=1;i<=n;i++)w[i]=w[i]-w1+1000;
	
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=105000;j++)
		{
			dp[i][j]=dp[i-1][j];
			if(j-w[i]>=0)
			dp[i][j]=max(dp[i][j],dp[i-1][j-w[i]]+v[i]);
		}
	}
	
	int ans=0;
	for(int wi=1;wi<=105000;wi++)
	{
		if(w1>1000 and (wi/1000)*w1+wi%1000>W)continue;
		if(w1<=1000 and wi>W)continue;
		ans=max(ans,dp[n][wi]);
	}
	cout<<ans;
	
	
	
}

Measured memory_bytes: 86060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

int main() {
  char b;
  char ans;
  cin >> b;

  switch(b) {
    case 'A':
      ans = 'T';
      break;
    case 'T':
      ans = 'A';
      break;
    case 'C':
      ans = 'G';
      break;
    case 'G':
      ans = 'C';
      break;
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string str;
    cin >> str;
    string checkstr(begin(str), begin(str) + str.size() / 2);
    if(str != string(rbegin(str), rend(str))){
        cout << "No\n";
        return 0;
    }
    if (checkstr != string(rbegin(checkstr), rend(checkstr)))
    {
        cout << "No\n";
        return 0;
    }
    checkstr = string(begin(str) + str.size() / 2 + 1, end(str));

    if (checkstr != string(rbegin(checkstr), rend(checkstr)))
    {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
}

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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define debug(x) cerr << #x << " = " << (x) << endl;
template<typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
    for (auto& x : v) o << x << ' ';
    return o;
}

int main(){
    std::ios_base::sync_with_stdio(false); cin.tie(0);
    ll n, a, b; cin >> n >> a >> b;
    vector<ll> arr(n);
    for (int i = 0; i < n; i++) cin >> arr[i];
    ll res = 0;
    for (int i = 1; i < n; i++){
        ll dist = arr[i] - arr[i-1];
        res += min(b, a * dist);
    }
    cout << res << endl;

}


Measured memory_bytes: 1024
/*
 * main.c
 *
 *  Created on: 2020/07/27
 *      Author: 113896
 */
#include <stdio.h>

int main() {

	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	int ans = 0;
	for (int x = a; x <= b; x++) {
		if (c % x == 0) ans++;
	}
	printf("%d\n", ans);

	return 0;
}




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

struct node{
    int key;
    node *prev;
    node *next;
} *head = NULL, *tail = NULL;

void insert(int x){
    node *newnode = new node;
    newnode->key = x;
    if(tail == NULL){
        head = newnode;
        tail = newnode;
        head->prev = NULL;
        head->next = NULL;
    }else{
        head->prev = newnode;
        newnode->next = head;
        head = newnode;
        head->prev = NULL;

    }
}

void delete_node(node *p){
    if((p == head) && (p == tail)){
        head = NULL;
        tail = NULL;
    }else if(p == head){
        head = p->next;
        head->prev = NULL;
    }else if(p == tail){
        tail = p->prev;
        tail->next = NULL;
    }else{
        p->prev->next = p->next;
        p->next->prev = p->prev;
    }
    delete p;
}

void deletekey(int x){
    for(node *p = head; p != NULL; p = p->next){
        if(p->key == x) {
            delete_node(p);
            break;
        }
    }
}

void print_list(void){
    for(node *p = head; p != tail; p = p->next){
        cout << p->key << ' ';
    }
    cout << tail->key << endl;
}

int main(void){
    int n, x;
    string command;
    cin >> n;

    for(int i = 0; i < n; ++i){
        cin >> command;
        if(command == "insert"){
            cin >> x;
            insert(x);
        }else if(command == "delete"){
            cin >> x;
            deletekey(x);
        }else if(command == "deleteFirst"){
            delete_node(head);
        }else if(command == "deleteLast"){
            delete_node(tail);
        }
    }

    print_list();
    return 0;
}


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

const ll INF = 1e18;
const int MX = 2005;

int main() {
  string s , t;
  cin >> s >> t;
  int dp[3010][3010] = {0};
  rep(i,s.size()){
    rep(j,t.size()){
      if(s[i] == t[j]){
        dp[i+1][j+1] = dp[i][j] + 1;
      }
      dp[i+1][j+1] = max(dp[i+1][j+1],dp[i+1][j]);
      dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j+1]);
    }
  }
  string ans = "";
  int i = (int)s.size();
  int j = (int)t.size();
  while (i > 0 && j > 0){
    if(dp[i][j] == dp[i-1][j]){
      --i;
    }else if(dp[i][j] == dp[i][j-1]){
      --j;
    }else{
      ans = s[i-1] + ans;
      --i,--j;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 35712
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
int main(){
  int n;
  cin>>n;
  map<int,int> mp;
  for(int i=0;i<n-1;i++){
    int a;
    cin>>a;
    mp[a]++;
  }
  for(int i=1;i<=n;i++){
    cout<<mp[i]<<"\n";
  }
}

Measured memory_bytes: 12520
#include<bits/stdc++.h>
using namespace std;
int n,f[2000001],add,p=1e9+7;
int main(){
    scanf("%d",&n);
    f[n]=n;
    f[n-1]=(long long)n*n%p;
    for(int i=n-2;i>=1;--i)
    {
        add=(add+f[i+3])%p;
        f[i]=f[i+1];
        f[i]=(f[i]+(long long)(n-1)*(n-1)%p)%p;
        f[i]=(f[i]+add)%p;
        f[i]=(f[i]+i+1)%p;
    }
    printf("%d",f[1]);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

vector<vector<int>> g;
int n,u,v;
int mx=0;


int dist_v[101000];
int dist_u[101000];

void dfs_v(int now,int cost){
 if(dist_v[now]!=inf)return;
  dist_v[now]=cost;
 for(auto next:g[now]){
  // cout<<next<<endl;
  dfs_v(next,cost+1);
 }
  return;
}

void dfs_u(int now,int cost){
  if(dist_u[now]!=inf)return;
  if(cost>=dist_v[now])return;
  dist_u[now]=cost;
  if(chmax(mx,dist_v[now])){
   //cout<<now<<endl; 
  }
 for(auto next:g[now]){
  dfs_u(next,cost+1);
 }
  return;
}




int main(){cout<<fixed<<setprecision(20);
           cin>>n>>u>>v;
           u--;v--;
           g.resize(n,vin());
           int a,b;
           rep(i,0,n-1){
            cin>>a>>b;
             a--;b--;
             g[a].pb(b);
             g[b].pb(a);
           }
           //vを根として考える
           /*
           vからの距離を保存（dfs）　uからdfs(vからの距離>uからの距離になるように動く)
           answer=max（dis(u)のvからの距離）-1
           */
           rep(i,0,n)dist_v[i]=dist_u[i]=inf;
           dfs_v(v,0);
           dfs_u(u,0);
          // cout<<dist_v[1]<<endl;
           cout<<mx-1<<endl;
}

Measured memory_bytes: 12224
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {
	int N;
	scanf("%d", &N);

	if (N <= 999)printf("ABC");
	else printf("ABD");









}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


class Math {
    ll mod = 1e9+7;
  public:
    template<typename T1, typename T2> 
    ll gcd(T1 a, T2 b){
        if(b==0) return a; 
        return gcd(b, a%b);
    }

    template<typename T1, typename T2>
    ll lcm(T1 a, T2 b){
        return a*(b/gcd(a, b));
    }

    template<typename T>
    int keta(T num){
        T k=0; 
        while(num>0){ 
            num/=10;
            k++;
        }
        return k;
    }

    template<typename T1, typename T2>
    ll powpow(T1 num1, T2 num2){
        ll res = 1;
        while(num2 > 0){
            res *= num1;
            res %= mod;
            num2--;
        }
        return res%mod;
    }

    template<typename T1, typename T2>
    ll powl(T1 a, T2 b){
        ll res = 1;
        while(b > 0){
            res *= a;
            b--;
        }
        return res;
    }

    template<typename T1, typename T2>
    ll ceil(T1 a, T2 b){
        return (a+b-1)/b;
    }
};


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

    int n;
    ll c, k;
    Math mt;
    vector<ll> t;
    ll tmpt;
    cin >> n >> c >> k;
    rep(i, n){
        cin >> tmpt;
        t.push_back(tmpt);
    }

    sort(all(t));

    ll marker = t[n-1];
    ll res = 0;
    ll cnt = 1;
    repr(i, n-2, 0){
        if(t[i] >= marker - k){
            if(cnt%c != 0){
                cnt++;
                continue;
            }
        }
        marker = t[i];
        res += mt.ceil(cnt, c);
        cnt = 1;
    }
    res += mt.ceil(cnt, c);

    cout << res << endl;

    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<pair<ll, ll>> p(N);
    for (int i = 0; i < N; i++) {
        ll X, L;
        cin >> X >> L;
        p[i] = {X+L, L};
    }
    sort(p.begin(), p.end());
    ll y = p[0].first;
    int ans = 1;
    for (int i = 1; i < N; i++) {
        if (y <= p[i].first-2*p[i].second) {
            ans++;
            y = p[i].first;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

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

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}


//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
ll x;
cin>>x;
ll sum=0;
sum+=(x/500)*1000;
x=x%500;
sum+=(x/5)*5;
cout<<sum<<endl;
}









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

using namespace std;
using ll = long long;

int main() {
    ll H, W;
    cin >> H >> W;

    ll ans = H * W;
    ll s[3];
    for (int i = 0; i < 2; ++i) {
        for (ll h = 1; h < H; ++h) {
            s[0] = h * W;
            s[1] = (H - h) * (W / 2);
            s[2] = H * W - (s[0] + s[1]);
            sort(s, s + 3);
            ans = min(ans, s[2] - s[0]);
            s[0] = h * W;
            s[1] = ((H - h) / 2) * W;
            s[2] = H * W - (s[0] + s[1]);
            sort(s, s + 3);
            ans = min(ans, s[2] - s[0]);
        }
        swap(H, W);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d", &n)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
	}

	fmt.Println(solve(n, a))
}

func solve(n int, a []int) int {
	sum := 0
	max := a[0]

	for i := 0; i < n; i++ {
		max = maxInt(max, a[i])
		sum += (max - a[i])
		// if a[i] < max {
		// }
	}

	return sum
}

func maxInt(a, b int) int {
	if a > b {
		return a
	}

	return b
}


Measured memory_bytes: 6468
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

namespace problem001
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = ReadLine().Split(' ');
			int a = int.Parse(s[0]);
			int b = int.Parse(s[1]);
			int tmpA, tmpB;
			int c;
			if (a > b)
			{
				tmpA = a;
				tmpB = b;
			}
			else
			{
				tmpA = b;
				tmpB = a;
			}
			while (true)
			{
				tmpA = tmpA % tmpB;
				if(tmpA == 0)
				{
					c = tmpB;
					break;
				}
				tmpB = tmpB % tmpA;
				if(tmpB == 0)
				{
					c = tmpA;
					break;
				}
			}
			long ans = (long)a * (long)b / c;
			WriteLine(ans);

		}
	}
}


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

const int MN = 200010;

int N;
int A[MN];

bool ok(int x) {
	set<pii> S;

	int cl = A[0];

	map<int, int> M;
	for (int i = 1; i < N; ++i) {
		if (A[i] <= cl) {
			while (!M.empty()) {
				auto it = M.end(); --it;
				if (it->fi >= A[i]) {
					M.erase(it);
				} else {
					break;
				}
			}

			int p = A[i] - 1;
			++M[p];

			while (M[p] >= x) {
				M.erase(p);
				--p;
				if (p < 0) {
					return false;
				}
				++M[p];
			}
		}
		cl = A[i];
	}
	return true;
}

int main() {
	cin >> N;
	rep(i, N) {
		cin >> A[i];
	}

	bool mon = 1;
	rep(i, N-1) if (A[i] <= A[i-1]) {
		mon = 0;
	}

	if (mon) {
		puts("1");
		return 0;
	}

	int lo = 1, hi = N;

	while (hi - lo > 1) {
		int m = (lo + hi) / 2;
		if (ok(m)) {
			hi = m;
		} else {
			lo = m;
		}
	}

	cout << hi << endl;
	return 0;
}

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

using namespace std;

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

    int a, b;
    cin >> a >> b;

    string s;
    cin >> s;


    if(s[a] == '-')
    {
        for(int i = 0; i < s.size(); ++i)
        {
            if(i == a)
                continue;
            else
            {
                if((s[i] - '0') >= 0 && (s[i] - '0') <= 9)
                    continue;
                else
                {
                    cout << "No\n";
                    exit(0);
                }
            }
        }

        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }


//    cout << 48 - n << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cctype>
using namespace std;
 
int main() {
 int A, B; cin >> A >> B;
 string s; cin >> s;
 bool flag = true;
 for (int i = 0; i < s.size(); i ++) {
  if (i == A) {
   if (s[i] != '-') flag = false;
  } else if (!isdigit(s[i])) flag = false;
 }
 if (flag) cout << "Yes\n";
 else cout << "No\n";

 return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);

    vi d(N);
    Rep(i,N) Scd(d[i]);

    int ans = 0;
    Rep(i,N) Rep(j,N){
        if( i!=j ) ans += d[i]*d[j];
    }

    printf ("%d\n", ans/2 );

    return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void) {
    long long h, w;
    scanf("%lld %lld", &h, &w);
    if (h == 1 || w == 1) {
        printf("1\n");
        return 0;
    }
    
    long long sum;
    sum = ceil((double)(h * w) / 2);
    printf("%lld\n", sum);
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=100005;
int n,m,i,j,k,head[N],adj[N*2],nxt[N*2],p[N],cnt;
bool v[N];
void dfs(int x)
{
	v[x]=true;
	for(int y=head[x];y;y=nxt[y])
		if(!v[adj[y]])
		{
			dfs(adj[y]);
			break;
		}
	p[++cnt]=x;
}
void Dfs(int x)
{
	if(x!=1)
		p[++cnt]=x;
	v[x]=true;
	for(int y=head[x];y;y=nxt[y])
		if(!v[adj[y]])
		{
			Dfs(adj[y]);
			break;
		}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;++i)
	{
		scanf("%d%d",&j,&k);
		adj[i*2-1]=k;
		nxt[i*2-1]=head[j];
		head[j]=i*2-1;
		adj[i*2]=j;
		nxt[i*2]=head[k];
		head[k]=i*2;
	}
	dfs(1);
	Dfs(1);
	printf("%d\n",cnt);
	for(i=1;i<=cnt;++i)
		printf("%d ",p[i]);
	return 0;
}


Measured memory_bytes: 3200