akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.io.IOException;

class Main 
{
	public static void main(String[] args) throws IOException
	{
		Scanner sc = new Scanner(System.in);
		int N;
		int[] data;

		while(true)
		{
			N = sc.nextInt();

			if(N == 0)
			{
				break;
			}

			data = new int[N];

			for(int i = 0; i < N; i++)
			{
				data[i] = sc.nextInt();
			}

			sort(data);

			System.out.println(myMean(data));
		}
	}

	private static void sort(int[] data)
	{
		int min, tmp;

		for(int i = 0; i < data.length; i++)
		{
			min = i;
			for(int j = i + 1; j < data.length; j++)
			{
				if(data[j] < data[min])
				{
					min = j;
				}
			}
			tmp = data[i];
			data[i] = data[min];
			data[min] = tmp;
		}
	}

	public static int myMean(int[] data)
	{
		int s = 0;
		
		for(int i = 1; i < data.length - 1; i++)
		{
			s += data[i];
		}

		return s / (data.length - 2);
	}
}

Measured memory_bytes: 20920
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int n;
  cin >> n;
  ll a[n];
  ll b[n];
  rep(i,n)cin >> a[i];
  b[0]=a[0];
  rep(i,n-1){
    b[i+1]=max(b[i],a[i+1]);
  }
  ll ans=0;
  rep(i,n){
    ans=ans+(b[i]-a[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 6752
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.ST                 as ST
import qualified Data.Array.Unboxed            as AU
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.Int
import qualified Data.IntMap                   as IM
import           Data.List
import qualified Data.Map                      as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                      as S
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

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

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)


main = do
  [n] <- readInt
  as  <- map read . words <$> getLine
  print $ solve as

solve :: [Integer] -> Integer
solve as = foldl' (\acc a -> acc + l `div` a) 0 as `mod` 1000000007
  where l = foldl1' lcm as


Measured memory_bytes: 4476
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll a, v;
    cin >> a >> v;
    ll b, w;
    cin >> b >> w;
    ll t;
    cin >> t;

    ll tmp = abs(a-b);
    ll tmp2 = (v-w) * t;

    if(v*t >= w*t + tmp){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

}

Measured memory_bytes: 3636
import java.util.*;
public class Main{
  public static void main(String[] args){
  	Scanner stdIn = new Scanner(System.in);
    	int a = stdIn.nextInt();
    	int kisuu = 0;
    		for(int i = 1; i <= a; i++){
              if(i%2!=0){
                kisuu++;
              }
            }
         System.out.println((double)kisuu/(double)a);
            }
  }
           

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

typedef long double ld;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<double> vd;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define pi 3.14159265358979
#define eps 1e-9
#define inf 1<<30
#define MOD 1000000007 // 1e9+7

int main()
{
	int n, x, y, t;
	int xp = 0, yp = 0, tp = 0;

	cin >> n;
	rep(i,n){
		cin >> t >> x >> y;
		int dt = t - tp;
		int dist = abs(x - xp) + abs(y - yp);
		if( dt < dist || dt % 2 != dist % 2 ){
			cout << "No" << endl;
			return 0;
		}
		xp = x;
		yp = y;
		tp = t;
	}
	cout << "Yes" << endl;

	return 0;
}



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


// æ­Ôá¤Æ±ëB
// âè¶É¢ÄÈ­ÄàâèZbgÍ¡Åæªª0ÅI¹Å éB
// âèZbgÌJèÔµÉú»Rê

// 2011/10/18

//@0110 ¢ÊZ
public class Main {

	
	// C return falseÅ¨µÜ¢
	boolean main() throws IOException {

		String s = reader.readLine();
		if (s == null)
			return false; /* ¨µÜ¢ */
		
		for(int i = 0; i < 10; i++) {
			String s2 = s.replace('X', (char)('0' + i));
			String reg = "([0-9]+)\\+([0-9]+)=([0-9]+)";
			String st1 = s2.replaceAll(reg, "$1");
			String st2 = s2.replaceAll(reg, "$2");
			String st3 = s2.replaceAll(reg, "$3");
			if (st1.length() > 1 && st1.charAt(0) == '0')
				continue;
			if (st2.length() > 1 && st2.charAt(0) == '0')
				continue;
			if (st3.length() > 1 && st3.charAt(0) == '0')
				continue;
			BigInteger v1 = new BigInteger(st1);
			BigInteger v2 = new BigInteger(st2);
			BigInteger v3 = new BigInteger(st3);
			if (v1.add(v2).equals(v3)) {
				System.out.printf("%d\n", i);
				return true;
			}
		}
		System.out.printf("NA\n");
		
		return true; /* ³íI¹ Ö */
	}
	

//	private final static boolean DEBUG = true;  // debug
	private final static boolean DEBUG = false; // release

	public static void main(String[] args) throws IOException {

		if (DEBUG) {
			log = System.out;
			
			String inputStr = "XXXXXXXXXX0000022222+11111111110000022222=22222222220000044444\n";

			reader = new BufferedReader(new StringReader(inputStr)); 

		}
		else {
			log = new PrintStream(new OutputStream() { public void write(int b) {} } ); // «ÌÄ
			reader = new BufferedReader(new InputStreamReader(System.in)); // R\[©ç
		}
		
		//int N = readIntArray()[0];

		for(int i = 0; /*i < N*/; i++) {
			boolean b = new Main().main();
			if (!b)
				break;
		}		
		
		reader.close();
	}

	
	static PrintStream log;
	static BufferedReader reader;
	

	// WüÍæè@1sªÌXy[XæØèÌ®lðÇÞ
	private static int[] readIntArray() throws IOException {
		
		String s = reader.readLine();
		String[] sp = s.split(" ");
		int[] a = new int[sp.length];
		for(int i = 0; i < sp.length; i++) {
			a[i] = Integer.parseInt(sp[i]);
		}
		return a;
	}
		
}

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

const int mx=200010;
const ll mod=1e9+7;

int main(){
  ll h;
  cin >> h;
  ll cnt=0;
  while(h!=1){
    cnt++;
    h/=2;
  }
  ll ans=0;
  ll p=1;
  for(int j=1; j<=cnt+1; j++){
    ans+=p;
    p*=2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a, b;
    scanf("%d%d", &a, &b);
    if(a >= 13){
        printf("%d", b);
    }else if(a >= 6){
        printf("%d", b / 2);
    }else{
        printf("0");
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        String S=sc.next();
        String T=sc.next();
        String Sspt[] = S.split("");
        String Tspt[] = T.split("");
        
        for(int i=0;i<N;i++){
            System.out.print(Sspt[i]);
            System.out.print(Tspt[i]);
            
        }
        
        
    }
}


Measured memory_bytes: 35620
a, b = map(int, input().split())
c = a * b
for i in range(a, b+1):
    for j in range(a, b+1):
        if i != j:
            if c > i * j % 2019:
                c = i * j % 2019
            if c == 0:
                print(0)
                exit()
print(c)


Measured memory_bytes: 2940
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n, m;
    cin >> n >> m;
    aoi<i64> pq;
    i64 ans = 0;
    while (n--)
    {
        i64 x;
        cin >> x;
        ans += x;
        pq.push(x);
    }
    while (m--)
    {
        i64 x = pq.top();
        pq.pop();
        ans -= (x + 1) / 2;
        pq.push(x / 2);
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 1400
#include<stdio.h>
int main()
{
    int x,y,c;
    scanf("%d%d",&x,&y);
    if(x%2 != y%2)
    {
    printf("IMPOSSIBLE\n");
    }
    else
    {
        c=(x+y)/2;
        printf("%d",c);
    }
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,a,b;
	cin >> n >> a >> b;
	cout << min(n*a,b) << endl;
	return 0;
}


Measured memory_bytes: 256
from sys import stdin
a,b,c = [int(x) for x in stdin.readline().rstrip().split()]
if b-a < c*2:
    for i in range(a,b+1):
        print(i)
else:
    for i in range(a,a+c):
        print(i)
    for j in range(b-c+1,b+1):
        print(j)

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

int main()
{
  int n,k;
  cin>>n>>k;
  int l=0;

  for(int i=0;i<n;i++)
  {
    int x,y;
    cin>>x;
    y=x*2;
    if(y<=k)
    {
      l+=y;
    }
    else
    {
      l+=(k-x)*2;
    }
  }
  cout<<l<<endl;
}


Measured memory_bytes: 384
package main

import (
	"fmt"
)

func abs(i int) int {
	if i < 0 {
		return i * (-1)
	}
	return i
}

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

func main() {
	var n, x, r, t int
	fmt.Scan(&n, &x)

	for i := 0; i < n; i++ {
		fmt.Scan(&t)
		t = abs(t - x)
		if i == 0 {
			r = t
			continue
		}
		if g := gcd(t, r); r > g {
			r = g
		}
	}

	fmt.Println(r)
}

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

ll calc(ll n){
	n++;
	ll ans = 0;
	for(int i = 0; i < 41; i++){
		ll loop = 1LL << (i + 1);
		ll cnt = (n / loop) * (loop / 2);
		cnt += max(0LL, (n % loop) - (loop / 2));
		if(cnt % 2 == 1) ans += 1LL << i;
	}
	return ans;
}

int main() {
	
	ll a, b;
	cin >> a >> b;
	
	ll ans = calc(b) ^ calc(a-1);
	cout << ans << endl;
	return 0;
}

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

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

    int res = -1, tmp8, tmp10;
    for (int i = 1; i <= 1250; i++) {
        tmp8 = i * 0.08;
        tmp10 = i * 0.1;
        if (tmp8 == a && tmp10 == b) {
            res = i;
            break;
        }
    }

    cout << res << endl;

    return 0;
}


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

int main() {
  char c[3][3];
  int i, j;
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
      cin >> c[i][j];
    }
  }
  for (i = 0; i < 3; i++) {
    cout << c[i][i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int ar[200005];
int main()
{
  ll n, m, ans, mi, sum=0, x, count=0;
  cin>>n>>m;
  for(int i=0; i<n; i++)
  {
    cin>>ar[i];
    sum+=ar[i];
  }
  sort(ar,ar+n);
  for(int i=0; i<n; i++)
  {
    if(ar[i]*4*m>=sum)count++;
  }
  if(count>=m)
  {
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }


}

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

#define REP(i,n) for(int i=0,_n=(int)(n); i < _n; i++)
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }

typedef long long ll;

int nextInt() {
  int x; scanf("%d", &x); return x;
}

const int MAX_N = 5000 + 10;
const int MAX_K = 5000 + 10;

int N, K;
int a[MAX_N];
bool dp[2 * MAX_K];

bool isNeed(int t) {
  if (a[t] >= K) return true;

  memset(dp, 0, sizeof(dp));
  dp[0] = true;
  REP(i, N) if (i != t) {
    for (int k = K; k >= 0; k--) {
      if (dp[k]) { 
        dp[k + a[i]] = true;
      }
    }
  }
  bool need = false;
  for (int j = 0; j < K; j++) {
    if (dp[j] && j + a[t] >= K) need = true;
  }
  return need;
}

int main2() {
  N = nextInt();
  K = nextInt();
  REP(i, N) a[i] = nextInt();
  sort(a, a + N);
  while (N >= 0 && a[N-1] >= K) {
    N--;
  }

  int lo = -1;
  int hi = N;
  while (hi - lo > 1) {
    int mid = (hi + lo) / 2;
    if (isNeed(mid)) {
      hi = mid;
    } else {
      lo = mid;
    }
  }
  int ans = hi;
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}


Measured memory_bytes: 256
N = int(input())
t = list(map(int,input().split()))
v = list(map(int,input().split()))

from_start=[0]
for i in range(N):
  for s in range(2*t[i]):
    from_start += [min(from_start[-1]+1, 2*v[i])]

to_goal=[0]
t.reverse()
v.reverse()
for i in range(N):
  for s in range(2*t[i]):
    to_goal += [min(to_goal[-1]+1, 2*v[i])]
to_goal.reverse()
velo=[]
for s in range(2*sum(t)+1):
  velo+=[min(from_start[s],to_goal[s])]
  

print(sum(velo)/4-(velo[0]+velo[-1])/8)

Measured memory_bytes: 4116
#include <bits/stdc++.h> 
using namespace std; 
#define int long long
# define pii pair<char,int>
const int maxn=1e6+5;
signed main() { 
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    if(a==1 && b==1)cout<<"Draw";
    else if(a==1)cout<<"Alice";
    else if(b==1)cout<<"Bob";
    else
    {
        cout<<(a>b?"Alice":(a==b)?"Draw":"Bob");
    }
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>> ;
using GraphEdge = vector<vector<int>> ;
long long modinv(long long a, long long m=MOD) {long long b = m, u = 1, v = 0;while (b) {    long long t = a / b;    a -= t * b; swap(a, b);    u -= t * v; swap(u, v);}u %= m; if (u < 0) u += m;return u;}
//MODの割り算の際にa/＝b;をa *= modinv(b,MOD);とする。
int gcd(int a, int b){if (a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}
 
bool ser(const pair<int,int> &a, const pair<int,int> &b){
    if(a.first != b.first)return a.first < b.first;
    return a.second < b.second;
}

int main(){
    int N,M;cin >> N >> M;
    vector<pair<int,int> > V;
    vector<pair<int,int>> V_2;
    map<pair<int,int>, int> Ma;
    rep(i,M){
        int a,b;cin >> a  >> b;
        V.push_back(make_pair(a,b));
        V_2.push_back(make_pair(a,b));
    }
    sort(V_2.begin(), V_2.end(),  ser);

    int before = 0;
    int count = 1;
    for(pair<int,int> i : V_2){
        if(before != i.first)count = 1;
        Ma[i] = count;
        count++;
       
        before = i.first;
    }


    rep(i,M){
        int num = Ma[V[i]];
        int ken = V[i].first;

        printf("%06d%06d\n",ken,num);

    }


    return 0;
}

Measured memory_bytes: 11156
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
     int n;
     cin >> n;
     int a[10]={1,2,4,8,16,32,64,128};
     for(int i = 0 ; i < 7;i++){
         if(n >= a[i]  && n < a[i+1])
             cout << a[i] << endl;
     }
 
}

Measured memory_bytes: 256
N = int(input())
ans = 0

#Nの約数をdivisorsにぶちこむ
def Num_divisor(N):
    divisors = []
    for i in range(1,N):
        #調べるのはNの1/2乗まででよい
        if i * i > N:
            break
        if ( N % i == 0):
            #Nがiで割り切れたら約数は B と i
            B = N / i
            #Bとiが同じ時は一つだけ追加
            if B == i :
                divisors.append(B)
            else:
                divisors.append(B)
                divisors.append(i)
    return len(divisors)

for i in range(1,N+1):
    #奇数のとき
    if (i % 2) != 0:
        if Num_divisor(i) == 8:
            ans += 1

print(ans)


Measured memory_bytes: 38504
#include <iostream>
#include <map>
#include <algorithm>
#define int long long
using namespace std;
map<int,int> p;
void prfac(int n){
	int a=2;
	while(n>=a*a){
		if(n%a==0){
			p[a]++;
			n/=a;
		}
		else{
			a++;
		}
	}
	p[n]++;
} 
int cnt=0;
signed main(void){
    int n;
    cin>>n;
    prfac(n);
    
    for(auto x:p){
        if(x.first==1)continue;
        int s=x.second;
        for(int i=1;;i++){
            if(s-i>=0){
                s-=i;
                cnt++;
            }
            else break;
        }
    }
    cout<<cnt<<endl;
}


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

using namespace std;

int main()
{
  int N, D, Q, d[500000], q[500000];
  int L[500001], R[500001];

  cin >> N >> D;
  for(int i = 0; i < N; i++) cin >> d[i];
  cin >> Q;
  for(int i = 0; i < Q; i++) cin >> q[i];

  L[0] = D;
  for(int i = 0; i < N; i++) {
    L[i + 1] = min(L[i], abs(L[i] - d[i]));
  }
  R[N] = 1;
  for(int i = N - 1; i >= 0; i--) {
    if(R[i + 1] <= d[i] / 2) R[i] = R[i + 1];
    else R[i] = R[i + 1] + d[i];
  }

  for(int i = 0; i < Q; i++) {
    if(L[q[i] - 1] == 0 || R[q[i]] > L[q[i] - 1]) cout << "NO" << endl;
    else cout << "YES" << endl;
  }
}

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

using namespace std;

typedef long long int lli;

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

    int n, a[100000], big;
    vector<int> pl, mn;

    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> a[i];
        if (a[i] >= 0) pl.push_back(a[i]);
        else mn.push_back(a[i]);
    }

    int idx = 0, val = 0, ans[100000][2];
    sort(a, a+n);

    for (int i=1; i<n-1; i++) {
        if (a[i] >= 0) {
            ans[idx][0] = a[0];
            ans[idx++][1] = a[i];
            a[0] -= a[i];
        }
    }
    for (int i=0; i<n-1; i++) {
        if (i == 0 || a[i] < 0) {
            ans[idx][0] = a[n-1];
            ans[idx++][1] = a[i];
            a[n-1] -= a[i];
        }
    }

    cout << a[n-1] << endl;
    for (int i=0; i<n-1; i++) {
        cout << ans[i][0] << " " << ans[i][1] << endl;
    }

/*
    sort(pl.begin(), pl.end());
    sort(mn.begin(), mn.end());

    int plen = pl.size(), nlen = mn.size(), idx = 0, ans[100000][2];
    vector<int> tmp;
    // plus
    if (mn.size()) {
        for (int i=0; i<plen-1; i++) {
            ans[idx][0] = mn[0];
            ans[idx++][1] = pl[i];
            mn[0] -= pl[i];
        }
        plen = 1;
    }
    for (int i=0; i<plen/2; i++) {
        ans[idx][0] = pl[plen-i-1];
        ans[idx++][1] = pl[i];
        tmp.push_back(pl[plen-i-1]-pl[i]);
    }
    for (int i=1, len=tmp.size(); i<len; i++) {
        ans[idx][0] = tmp[0];
        ans[idx++][1] = tmp[0]-tmp[i];
        tmp[0] -= tmp[i];
    }

    int val;
    if (plen == 0) {
        val = mn[nlen-1];
        nlen--;
    }
    else {
        val = tmp[0];
    }

    for (int i=0; i<nlen; i++) {
        ans[idx][1] = val;
        ans[idx++][0] = mn[i];
        val -= mn[i];
    }
*/
    return 0;
}


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

using namespace std;

int main() {
        int a,b,c,k;

        cin >> a >> b >> c >> k;

        while(k > 0) {
                if (c <= b || c <= a) {
                        c *= 2;
                        k--;
                }

                else if (b <= a) {
                        b *= 2;
                        k--;
                }else if(c > b && b > a) {
                        break;
                }

        }

        (c > b && b > a) ? cout << "Yes" << endl : cout << "No" << endl;

        return 0;
}   

Measured memory_bytes: 3612
import sys
input = sys.stdin.readline

if __name__ == '__main__':
  n=int(input())
  A_str=input().strip("\n")
  A=A_str.split()
  q=int(input())

  C={}
  for a in A:
    if a in C:
      C[a]+=1
    else:
      C[a]=1
  
  def rep(b,c):
    if c in C:
      C[c]+=C[b]
    else:
      C[c]=C[b] 
    C[b]=0
    #print(b,c,C)

  Ans=[]
  ans=''
  b,c=input().strip("\n").split()
  #tmp=eval(A_str.replace(b,c).replace(" ","+"))
  tmp=0
  hoge=map(int,A)
  for a in hoge:
    if str(a)==b:
      tmp+=int(c)
    else:
      tmp+=a
  #ans+=str(tmp)
  #ans+="\n"
  Ans.append(tmp)
  if b in C:
    rep(b,c)
  for i in range(1,q-1):
    b,c=input().strip("\n").split()
    if b in C:
      tmp+=(int(c)-int(b))*C[b]
      rep(b,c)
    #ans+=str(tmp)+"\n"
    Ans.append(tmp)
  b,c=input().strip("\n").split()
  if b in C:
    tmp+=(int(c)-int(b))*C[b]
  #ans+=str(tmp)
  Ans.append(tmp)
  #print(ans)
  for ans in Ans:
    print(ans)


Measured memory_bytes: 24788
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cstring>
#include <math.h>
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
using namespace std;

int swap(int &a,int &b){
	int c;
	c=a;
	a=b;
	b=c;

	return 0;
}



int main(){
	double r;
	cin>>r;
	cout<<fixed<<M_PI*r*r<<" "<<2*M_PI*r<<endl;

	return 0;
}

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

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define pb push_back
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define endl "\n"
#define pii pair<int,int>
#define mii map<int,int>
#define int long long int
#define fbo find_by_order
#define ook order_of_key
#define in insert
#define F first
#define S second
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a) for(auto ws: a)cout<<ws<<" "; cout<<endl
#define print1(a,b) for(int ws=0;ws<b;ws++) {cout<<a[ws]<<" ";} cout<<endl
#define all(a) a.begin(), a.end()
#define si set<int>
#define print2(a) for(auto ws: a)cout<<"("<<ws.F<<","<<ws.S<<") "; cout<<endl

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}
int n;
vi a;
int cache[100001];
int dp(int index, int cost)
{
	//bug(cost);
	if (index >= n)return (int)1e18;
	int &ans = cache[index];
	if (ans != -1)return ans;
	ans = 0;
	if (index == n - 1)return cost;
	else
	{
		ans = min(dp(index + 1, cost + abs(a[index + 1] - a[index])), index + 2 < n ? dp(index + 2, cost + abs(a[index + 2] - a[index])) : (int)1e18);
		return ans;
	}
	cout << cost << endl;
}
int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cout << setprecision(9) << fixed;


	cin >> n;
	a.resize(n);
	memset(cache, -1, sizeof(cache));
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int cost[n];
	cost[0] = 0;
	cost[1] = abs(a[1] - a[0]);
	for (int i = 2; i < n; ++i)
	{
		cost[i] = min(cost[i - 1] + abs(a[i] - a[i - 1]), cost[i - 2] + abs(a[i] - a[i - 2]));
	}
	cout << cost[n - 1];
	return 0;
}

Measured memory_bytes: 2560
class Node:
    
    def __init__(self, root, length, dist):
        self.root = root
        self.child = None
        self.length = length
        self.dist = dist
        self.tail = root
        
def relate(x, y, z):
    X = A[x].root
    Y = A[y].root
    if A[X].length > A[Y].length:
        x, y, z, X, Y = y, x, -z, Y, X
    T = A[Y].tail
    A[T].child = X
    A[Y].tail = A[X].tail
    A[Y].length += A[X].length
    tmp = X
    xd = A[x].dist
    yd = A[y].dist
    for _ in range(A[X].length):
        A[tmp].root = Y
        A[tmp].dist += yd - z - xd
        tmp = A[tmp].child
    
n,q = [int(i) for i in input().split()]
A = []
for i in range(n):
    A.append(Node(i, 1, 0))
for _ in range(q):
    c = [int(i) for i in input().split()]
    if c[0] == 0 and A[c[1]].root != A[c[2]].root:
        relate(c[1], c[2], c[3])
    elif c[0] == 1:
        if A[c[1]].root == A[c[2]].root:
            print(A[c[2]].dist - A[c[1]].dist)
        else:
            print("?")


Measured memory_bytes: 29292
#include<stdio.h>

#define MOD 1000000007

long long factorial[100010];
long long fact_inv[100010];

long long power(long long n, int p) {
  if (p == 0) {
    return 1;
  }
  if (p == 1) {
    return n % MOD;
  }
  long long s;
  s = power(n, p/2);
  if (p % 2 == 0) {
    return s*s % MOD;
  }
  if (p % 2 == 1) {
    return n*power(n, p-1) % MOD;
  } else {
    return 0;
  }
}

long long combi(long long n, int p) {
  if (p > n || p < 0) {
    return 0;
  } else {
    return factorial[n] * fact_inv[p] % MOD * fact_inv[n-p] % MOD;
  }
}

int main() {
  int n, i, temp, lr;
  int twice;
  int a[100010];
  int b[100010];
  int num[2];
  long long ans[100010] = {};
  scanf("%d", &n);
  for (i = 0; i < n+1; i++) {
    a[i] = -1;
  }
  for (i = 0; i < n+1; i++) {
    scanf("%d", &temp);
    if (a[temp] == -1) {
      a[temp] = i;
    } else {
      lr = a[temp] + n - i;
    }
  }
  for (i = 0; i < n; i++) {
    if (b[i] == 2) {
      twice = i;
    }
  }
  /*printf("%d\n", twice);*/
  int dd = 0;
  for (i = 0; i < n+1; i++) {
    if (a[i] == twice) {
      num[dd] = i;
      dd = 1;
    }
  }
  factorial[0] = 1;
  fact_inv[0] = 1;
  for (i = 1; i < n+2; i++) {
    factorial[i] = factorial[i-1] * i % MOD;
    /*printf("%lld\n", fact_inv[i]);*/
  }
  fact_inv[n+1] = power(factorial[n+1], MOD-2);
  for (i = n; i > 0; i--) {
    fact_inv[i] = fact_inv[i+1] * (i+1) % MOD;
  }
  
  /*printf("l=%d r=%d\n", l, r);*/
  
  for (i = 1; i < n+1; i++) {
    ans[i] = (combi(n+1, i) - combi(lr, i-1) + MOD) % MOD;
  }
  
  for (i = 1; i < n+1; i++) {
    printf("%lld\n", ans[i]);
  }
  printf("1\n");
  return 0;
}
    


Measured memory_bytes: 3840
# Problem https://atcoder.jp/contests/abc072/tasks/abc072_b
# Ruby 1st Try
s = gets.chomp.split('')
# p s
# p s.length
answer = s[0]
for j in 1..(s.length-1) do
    if j % 2 == 0
        answer << (s[j])
    end
end
puts(answer)

Measured memory_bytes: 7036
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second

using Graph = vector<vector<int>>;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> vec(100100, 0);
    for (int i = 0; i < m; i++)
    {
        int l, r;
        cin >> l >> r;
        vec[l] += 1;
        vec[r + 1] -= 1;
    }
    int ans = 0;
    for (int i = 0; i < 100010; i++)
    {
        vec[i + 1] += vec[i];
        if (vec[i + 1] == m)
        {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
N = int(input())
A = list(map(int,input().split()))

A.sort(reverse = True)


ans2 = A[0]
cnt = 0
j = 1
for i in range(1,N-1):
    if cnt == 2:
        j += 1
        cnt = 0
    ans2 += A[j]
    cnt += 1

print(ans2)


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

#define pb push_back
#define mp make_pair

typedef long long ll;

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

int s[2][101];

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

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

  for(int i = 0; i < 2; i++){
    for(int j = 1; j <= n; j++){
      s[i][j] = s[i][j-1] + a[i][j-1];
    }
  }

  int ans = 0;
  for(int i = 1; i <= n; i++){
    ans = max(ans, s[0][i]+s[1][n]-s[1][i-1]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;	
}
using namespace std;
int h,w,dx[8]={-1,-1,-1,0,0,1,1,1},dy[8]={-1,0,1,-1,1,-1,0,1};
char s[66][66];
int main()
{
	re(h),re(w);
	for(int i=1;i<=h;++i)
		scanf("%s",s[i]+1);
	for(int i=1;i<=h;++i,puts(""))
		for(int j=1;j<=w;++j)
		{
			if(s[i][j]=='#')putchar('#');
			else 
			{
				int cnt=0;
				for(int k=0;k<8;++k)
					if(s[i+dx[k]][j+dy[k]]=='#')
						++cnt;
				putchar(cnt+48);
			}
		}
}

Measured memory_bytes: 256
n,k,*a=map(int,open(0).read().split())
b=[-1]*(n+1)
b[1]=0  #町のリストで，何回目で初めて訪れたか
c=a[0]
d=[0]*min(k+1,10**7)
d[0]=1  #i回目の移動でどこにいるかを記録
for i in range(1,k+1):
    d[i]=c
    if b[c]!=-1:
        # print(i,c,b[c])
        print(d[b[c]+(k-b[c])%(i-b[c])])
        exit()
    b[c]=i    
    c=a[c-1]
print(d[-1])  

Measured memory_bytes: 102328
#include<stdio.h>
int a,b,c,d;
char p[1010];
int main(){
    int i;
    scanf("%s",p);
    for(i=0;p[i];i++){
        if(p[i]=='N')a++;
        if(p[i]=='S')b++;
        if(p[i]=='E')c++;
        if(p[i]=='W')d++;
    }
    if((!a == !b) && (!c == !d))printf("Yes\n");
    else printf("No\n");
}

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

#define f(a, b) for(auto i = a;i < b;i++)
typedef long long int ll;

void solve()
{
	return ;	
}

int main()
{
	// solve();
	ll k, n, x;
	cin >> k >> n;

	ll sum = 0, maxi = 0;
	vector < ll > vect;
	vect.push_back(0);
	f(0, n)
	{
		ll a;
		cin >> a;
		vect.push_back(a);
		x = a - vect[i];
		maxi = max(maxi, x);
		sum += (a - vect[i]);
	}

	
	cout << min(sum - maxi + k - vect[n] , sum - vect[1]) << "\n";
}

Measured memory_bytes: 2420
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

float marume(float x, float N){
	x = x*pow(10,N);
	x = int(x+0.5-(x<0));
	return x/pow(10,N);
}

int main() {
	float a,b,c,d,e,f,x,y;
	while(cin >> a >> b >> c >> d >> e >> f){
		x = (c*e-b*f)/(a*e-b*d);
		y = (a*f-c*d)/(a*e-b*d);
		cout << fixed << setprecision(3) << marume(x,3) << " " << fixed << setprecision(3) << marume(y,3) << endl;
	}
	return 0;
}

Measured memory_bytes: 3408
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	int N, D;
	cin >> N >> D;
	D = 2 * D + 1;
	int ans = 0;
	while(N > 0){
		N -= D;
		ans ++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import numpy as np

n, d = map(int, input().split())
xs = [np.array(list(map(int, input().split()))) for _ in range(n)]
count = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        d = np.linalg.norm(xs[i] - xs[j])
        if d == int(d):
            count += 1
print(count)


Measured memory_bytes: 12492
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
 
using namespace std;

int main()
{
    int N;
    while(1){
        cin >> N;
        if(N == 0) break;
        int gemmap[21][21] = {0};
        int gem_x, gem_y;
        for(int i = 0; i < N; i++){
            cin >> gem_x >> gem_y;
            gemmap[gem_x][gem_y] = 1;
        }
        int M;
        cin >> M;
        char direction;
        int howfar;
        int now_x = 10, now_y = 10;
        int get_gem = 0;
        for(int i = 0; i < M; i++){
            cin >> direction >> howfar;
            if(direction == 'N'){
                for(int j = 1; j <= howfar; j++){
                    now_y++;
                    if(gemmap[now_x][now_y] == 1){
                        get_gem++;
                        gemmap[now_x][now_y] = 0;
                    }
                }
            }else if(direction == 'E'){
                for(int j = 1; j <= howfar; j++){
                    now_x++;
                    if(gemmap[now_x][now_y] == 1){
                        get_gem++;
                        gemmap[now_x][now_y] = 0;
                    }
                }
            }else if(direction == 'S'){
                for(int j = 1; j <= howfar; j++){
                    now_y--;
                    if(gemmap[now_x][now_y] == 1){
                        get_gem++;
                        gemmap[now_x][now_y] = 0;
                    }
                }
            }else if(direction == 'W'){
                for(int j = 1; j <= howfar; j++){
                    now_x--;
                    if(gemmap[now_x][now_y] == 1){
                        get_gem++;
                        gemmap[now_x][now_y] = 0;
                    }
                }
            }
        }
        if(get_gem == N) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
   return 0;
}

Measured memory_bytes: 1152
list = []
count = 0
flag = True

while flag:
    h,w=input().split()
    list.append((int(h),int(w)))
    if list[count][0] == 0:
        flag = False
    count += 1

for i in range(len(list)):
    for j in range(list[i][0]):
        for k in range(list[i][1]):
            if j%2 == 1:
                if k%2 == 1:
                    print("#",end="")
                else:
                    print(".",end="")
            else:
                if k%2 == 0:
                    print("#",end="")
                else:
                    print(".",end="")
        print("")
    if list[i][0] == 0:
        break
    print("")


"""
for i in range(1):
    for j in range(3):
        for k in range(4):
            if j%2 == 1:
                if k%2 == 1:
                    print("#",end="")
                else:
                    print(".",end="")
            else:
                if k%2 == 0:
                    print("#",end="")
                else:
                    print(".",end="")
        print("")

    print("")
"""



Measured memory_bytes: 7016
#include <iostream>
#include <string>
#include <map>
#include <stdio.h>
#include <cmath>

using namespace std;

int main()
{
    string str;
    cin >> str;
    // 文字列の長さ
    int strLength = str.size();
    string complete;
    if(strLength >= 3){
        // 最初の文字
        string firstStr = str.substr(0, 1);
        // 最後の文字
        string lastStr = str.substr(strLength - 1);
        // 文字列の中間部分の切り出し
        string midStr = str.substr(1, strLength - 2);
        int midLength = midStr.size();
        // 中間文字列数の文字列変換
        string mid = to_string(midLength);
        // 文字列結合
        complete = firstStr + mid + lastStr;
    }else{
        complete = str;
    }
    cout << complete << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main(){
	ll n;
	cin >> n;
	vector <ll> value(n);
	vector <ll> sum(n + 1,0);
	for(ll i = 0;i < n;i++){
		cin >> value[i];
		sum[i + 1] = sum[i] + value[i];
	}
	vector <vector <ll>> dp(n+1,vector <ll>(n + 1,0));
	for(ll i = 0;i < n;i++){
		dp[i][i]= value[i];
	}
	for(ll i = 2;i <= n;i++){
		for(ll j = 0;j < n;j++){
			if(j + i > n) break;
				dp[j][j + i - 1] = max(sum[j + i] - sum[j] - dp[j+1][j+i-1],sum[j + i] - sum[j] - dp[j][j + i - 2]);
		}
	}
	ll x = dp[0][n - 1];
	if(x == sum[n] - sum[0] - dp[1][n - 1]){
		cout << x - dp[1][n - 1];
	}
	else{
		cout << x - dp[0][n - 2];
	}
 	return 0;
}

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

int main(){
    string s;
    cin >> s;
    map<char, int> mp;
    for(int i = 0; i < s.size(); i++){
        mp[s[i]]++;
    }

    int f = 0;
    for(int i = 0; i < 26; i++){
        if(mp['a' + i]);
        else{
            f = 1;
            cout << s << (char)('a' + i) << endl;
            break;
        }
    }
    if(f);
    else{
        int f2 = 0, idx;
        for(int i = s.size() - 1; i > 0; i--){
            if(s[i - 1] < s[i]){
                f2 = 1;
                idx = i - 1;
                break;
            }
        }
        if(f2){
            bool A[26] = {};
            for(int i = 0; i <= idx; i++){
                if(i == idx){
                    if(A[(int)(s[i] - 'a' + 1)]){
                        int j = (int)(s[i] - 'a') + 2;
                        while(1){
                            if(A[j]) j++;
                            else{
                                cout << (char)('a' + j) << endl;
                                break;
                            }
                        }
                    }
                    else cout << char(char(s[i]) + 1) << endl;
                }else{
                    cout << s[i];
                    A[(int)(s[i] - 'a')] = true;
                }
            }
        }else cout << -1 << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
    char s[101],t[101],u[101];
    int i=0,j=0;
    scanf("%s%s",s,t);
    while(i<strlen(s)){
        u[0]=s[strlen(s)-1];
        for(j=1;j<strlen(s);j++){
            u[j]=s[j-1];
        }
        u[j]='\0';
        if(strcmp(u,t)==0){
            printf("Yes\n");
            return 0;
        }
        for(j=0;j<strlen(s);j++)
            s[j]=u[j];
        i++;
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
  int N,A,B;
  std::cin >> N >> A >> B;

  std::vector<int> h_arr(N);
  for(int i = 0; i < N; i++) std::cin >> h_arr[i];

  std::sort(h_arr.begin(), h_arr.end());

  long long l = 0, r = 1000000009;
  while(r-l > 1){
    long long m = (l+r)/2;
    long long na = 0;
    for(auto it = std::upper_bound(h_arr.begin(), h_arr.end(), m); it < h_arr.end(); ++it){
      long long nl = (*it)-B*m;
      if(nl > 0) na += (nl-1)/(A-B)+1;
    }
    if(na > m){
      l = m;
    }else{
      r = m;
    }
  }

  std::cout << r << std::endl;

  return 0;
}



Measured memory_bytes: 640
n = int(input())
a = 0
r = 26
count = 1
result = ""
moji = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
while a == 0:
    if r < n:
        n -= r
        r *= 26
        count += 1
    else:
        a = 1
zenbu = 26**count

def kaidan(zenbu,n):
    global moji
    for i in range(26):
        #print(i)
        if (zenbu/26)*i < n <= (zenbu/26)*(i+1):
            return(moji[i],i)

for l in range(count):
    kotae,s = kaidan(zenbu/(26**l),n)
    result += kotae
    n -= 26**(count-l-1)*s
print(result)

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

int main(){

    int A, B, C, D, total = 10000;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> D;

    if(total > A + C) total = A + C;
    if(total > A + D) total = A + D;
    if(total > B + C) total = B + C;
    if(total > B + D) total = B + D;

    cout << total << endl;

    return 0;
}

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

using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;

    int let = 1, ans = 0;

    while (let < B)
    {
        --let;
        let += A;
        ++ans;
    }
    cout << ans << endl;
    return 0;
}

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

//#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
//const int MOD = 1e9 + 7;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    string s;
    cin >> s;
    cout << (s == "ABC" ? "ARC" : "ABC") << endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <vector>

using namespace std;


int main()
{
    int area_sum = 0;
    stack<int> slope;
    stack< pair<int, int> > ponds;
    char ch;
    for (int i = 0; cin >> ch; i++) {
        if (ch == '\\') {
            slope.push(i);
        } else if (ch == '/' && !slope.empty()) {
            int down_slope = slope.top();
            slope.pop();

            int new_area = i - down_slope;
            area_sum += new_area;

            int pond_area = new_area;
            while (!ponds.empty() && ponds.top().first > down_slope) {
                pond_area += ponds.top().second;
                ponds.pop();
            }
            ponds.push(make_pair(down_slope, pond_area));
        }
    }

    vector<int> pond_sizes;
    while (!ponds.empty()) {
        pond_sizes.push_back(ponds.top().second);
        ponds.pop();
    }

    cout << area_sum << endl;
    cout << pond_sizes.size();
    for (int i = pond_sizes.size() - 1; i >= 0; i--) {
        cout << " ";
        cout << pond_sizes[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3252
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> h(n);
    int i;
    for (i = 0; i < n; ++i) {
        cin >> h[i];
    }
    vector<bool> isGood(n, true);
    int a, b;
    for (i = 0; i < m; ++i) {
        cin >> a >> b; 
        if (h[a - 1] >= h[b - 1]) {
            isGood[b - 1] = false;
        }
        if (h[a - 1] <= h[b - 1]) {
            isGood[a - 1] = false;
        }
    }
    int ans{};
    for (i = 0; i < n; ++i) {
        if (isGood[i]) {
            ++ans;
        }
    }
    cout << ans;
}


Measured memory_bytes: 3980
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl

using namespace std;

template<typename S,typename T>auto&operator<<(ostream&o,pair<S,T>p){return o<<"{"<<p.fi<<","<<p.se<<"}";}
template<typename T>auto&operator<<(ostream&o,set<T>s){for(auto&e:s)o<<e<<" ";return o;}
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,priority_queue<S,T,U>q){while(!q.empty())o<<q.top()<<" ",q.pop();return o;}
template<typename K,typename T>auto&operator<<(ostream&o,map<K,T>m){for(auto&e:m)o<<e<<" ";return o;}
template<typename T>auto&operator<<(ostream&o,vector<T>v){for(auto&e:v)o<<e<<" ";return o;}
void ashow(){cout<<endl;}template<typename T,typename...A>void ashow(T t,A...a){cout<<t<<" ";ashow(a...);}

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n){
        ll a, b;
        cin >> a >> b;
        if(a == b){
            cout << 2*(a-1) << "\n";
            continue;
        }
        if(a < b) swap(a, b);
        ll ans = b-1;
        ll T = a*b;
        ll r = (ll)sqrt(T);
        ans += r-1+(T-1)/r-b;
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
R={"*":2,"/":2,"+":1,"-":1,"(":0,")":0}
for _ in[0]*int(input()):
 L=[];t=''
 for e in input()[:-1]:
  if e.isdigit():t+=e
  else:
   if t:L+=[t];t=''
   L+=e
 if t:L+=[t]
 P,S=[],[]
 for i in L:
  if"("==i:S+=i
  elif")"==i:
   while"("!=S[-1]:P+=S.pop()
   S.pop()
  elif i in R:
   while S and R[S[-1]]>=R[i]:P+=S.pop()
   S+=i
  else:P+=[i]
 while S:P+=S.pop()
 for x in P:
  S+=[str(int(eval(S.pop(-2)+x+S.pop())))if x in"+-*/"else x]
 print(*S)


Measured memory_bytes: 5604
import scala.io.StdIn
import scala.collection.mutable.ListBuffer

object Main extends App {
  val Array(h, w) = StdIn.readLine.split(" ").map(_.toLong)

  val res1 = {
    val list = ListBuffer.empty[Long]
    val m = h / 2L
    val res = (1L to w/2)./:(Long.MaxValue, Long.MaxValue)((min, i) => {
      val a =( h * i ) 
      list += a
      list += ( m * (w-i) )
      list += ( (h-m) * (w-i) )
      val r1 = list.max - list.min
      list.clear
      val k = (w-i) / 2L
      list += a
      list += ( k * h )
      list += ( (w-i-k) * h )
      val r2 = list.max - list.min
      list.clear
      ( math.min(min._1, r1), math.min(min._2, r2) )
    })
    math.min(res._1, res._2)
  }

  val res2 = {
    val list = ListBuffer.empty[Long]
    val m = w / 2L
    val res = (1L to h/2)./:(Long.MaxValue, Long.MaxValue)((min, i) => {
      val a = w * i
      list += a
      list += ( m * (h-i) )
      list += ( (w-m) * (h-i))
      val r1 = list.max - list.min
      list.clear
      val k = (h-i) / 2L
      list += a
      list += ( k * w )
      list += ( (h-i-k) * w )
      val r2 = list.max - list.min
      list.clear
      ( math.min(min._1, r1), math.min(min._2, r2) )
    })
    math.min(res._1, res._2)
  }

  val ans = math.min(res1, res2)
  println(ans)
}

Measured memory_bytes: 49652
#include <iostream>
#include <vector>

using namespace std;

int main(void){
    int k, n;
    cin >> k >> n;
    vector <int> a(n);
    for (int i = 0; i < n; i++){
        cin >> a.at(i);
    }
    int max = 0;
    int d = 0;
    // vector <int> d(n);
    for(int i = 0; i < n; i++){
        if(i != n - 1){
            d = a.at(i+1) - a.at(i);
        }
        else if(i == n - 1){
            d = k + a.at(0) - a.at(n - 1);
        } 
        if(d > max){
            max = d;
        }
    }

    cout << k - max << endl;
    
    return 0;
}

Measured memory_bytes: 1024