akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Applicative
import Control.Monad
import Control.Monad.State
import Control.DeepSeq
import Data.Array
import Data.Array.MArray
import Data.Array.IO
import Data.Bits
import Data.Char
import Data.Functor.Identity
import Data.List
import Data.Maybe
import Data.Ord
import Data.Tree
import Data.Tuple
import qualified System.IO
import qualified Data.Map as M
import qualified Data.Set as S
import qualified Data.Sequence as Q
import qualified Data.ByteString.Char8 as B


main = do
  n <- getInt
  xs <- getInts
  [m,k] <- getInts
  as <- getInts
  let ds = listArray (0,n-2) $ zipWith (-) (tail xs) xs
  perm :: IOArray Z Z <- newListArray (0,n-2) [0..]
  forM as $ \ a -> do
    l <- readArray perm (a-2)
    r <- readArray perm (a-1)
    writeArray perm (a-2) r
    writeArray perm (a-1) l
  f1 :: Array Z Z <- freeze perm

  let itr 0 f = listArray (0,n-2) [0..]
      -- itr 1 f = f
      itr cnt f
        | even cnt =  g `seq` listArray (0,n-2) [g!(g!i) | i<-[0..n-2]]
        | otherwise = g `seq` listArray (0,n-2) [f!(g!(g!i)) | i<-[0..n-2]]
        where g = force $ itr (cnt`div`2) f

  let fk = itr k $ force f1
  let ds2 = force $ [ds ! (fk ! i) | i<-[0..n-2]]
  mapM_ print $ scanl (+) (head xs) ds2


type Z = Int
type Q = Rational
type R = Double
type S = String

fint :: (Integral a, Num b) => a -> b
fint = fromIntegral

getInt = fst . fromJust . B.readInt <$> B.getLine
getIntPair = (\[a,b]->(a,b)) <$> getInts
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine
getStr = B.unpack <$> B.getLine

yesNo :: Bool -> String
yesNo True = "Yes"
yesNo False = "No"

printList :: (Show a) => [a] -> IO ()
printList = putStrLn . unwords . map show

readLnList :: (Read a) => IO [a]
readLnList = map read . words <$> getLine


-----  Union-find
type UnionFindT v m a = StateT (M.Map v (UnionFindVal v)) m a
newtype UnionFindVal v = UnionFindVal v

runUnionFindT :: (Monad m) => UnionFindT v m a -> m a
runUnionFindT = flip evalStateT $ M.empty

runUnionFind = runIdentity . runUnionFindT

ufFresh :: (Monad m, Ord v) => v -> UnionFindT v m ()
ufFresh v = modify $ M.insert v (UnionFindVal v)

ufClass :: (Monad m, Ord v) => v -> UnionFindT v m v
ufClass v = do
  (UnionFindVal pv) <- gets (M.! v)
  if v == pv
    then return v
    else do
      c <- ufClass pv
      modify $ M.insert v (UnionFindVal c)
      return c

ufUnify v w = do
  cv <- ufClass v
  cw <- ufClass w
  modify $ M.insert cw (UnionFindVal cv)
  return $ cv /= cw


Measured memory_bytes: 75132
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;

#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 debug(x) cout<<#x<<"="<<x<<endl;
constexpr ll MOD=1000000007;
constexpr ll INF=1LL<<60;
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;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
//template end

void solve(){
    int N;
    cin>>N;
    int ct=0;
    while(N!=1){
        ct++;N=(N+2)/3;
    }
    cout<<ct<<endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    solve();
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	vector<ll> r(n+1);
	rep(i, n) r[i + 1] = r[i] + a[i];
    int k=0;
	rep(i, n){
      if(i==0) continue;
      if(a[i]>2*r[i]) k=i;
    }
    cout<<n-k<<endl;
}


Measured memory_bytes: 1792
//ahmat
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<" = "<<(x)<<endl
#define debug_arr(x) {cout<<#x<<":";for(auto a:x) cout<<a<<" ";cout<<endl;}
using vi=vector<int>;
using pii=pair<int,int>;
using ll=long long;
using ull=unsigned long long;
const int inf=0x3f3f3f3f;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //
    int n;
    cin>>n;
    cout<<(n-2)*180<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

int main()
{
	using namespace std;

	int n;
	vector<string> words;

	cin >> n;
	words.resize(n);
	for (auto& w : words) cin >> w;

	for (int i = 1; i < n; i++) {
		for (int j = 0; j < i; j++) {
			if (words[i] == words[j]) goto Err;
		}

		if (words[i-1].back() != words[i].front()) goto Err;
	}

	cout << "Yes" << endl;

	return 0;

Err:
	cout << "No" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
using namespace std;
int main(){
  int a,b;
  int c=0;
  cin>>a>>b;
  c=a * b;
  if (c % 2 != 0)
  cout<<"Odd";
  else
  cout<<"Even";
  system ("pause");
  return 0;
  }

Measured memory_bytes: 880
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    string s; cin >> s;
    char init = s[0];
    long long i = 0,x=0,y = 0;
    long long ans = 0;
    // while(i < s.length() && s[i] == '>')
    // {
    //     x++;i++;
    // }
    // ans += x*(x+1)/2;
    while(i < s.length())
    {
        x = 0;
        while(i < s.length() && s[i] == '<')
        {
            x++; i++;
        }
        y = 0;
        while(i < s.length() && s[i] == '>')
        {
            y++; i++;
        }
        // // cout << i << " " << init << " " << x << endl;
        // if(init == '>')
        //     ans -= min(x, px);

        ans += x*(x+1)/2;
        ans += y*(y+1)/2;
        ans -= min(x, y);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1172
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A, B, C, L):
    ans = sys.maxsize
    
    S = (A, B, C)
    for l in product([0, 1, 2, None], repeat=len(L)):
        ta = 0
        s = [A, B, C]
        for i, f in enumerate(l):
            if f is None:
                continue
            if s[f] != S[f]:
                ta += 10
            s[f] -= L[i]

        if any(map(lambda x: x[0] == x[1], zip(s, S))):
            continue
        
        ta += sum(map(abs, s))
        ans = min(ans, ta)

    return ans


def main():
    # N = read_int()
    N, A, B, C = read_int_n()
    L = [read_int() for _ in range(N)]
    print(slv(N, A, B, C, L))


if __name__ == '__main__':
    main()


Measured memory_bytes: 7520
#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <cstring>
#include <fstream>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

const int MAX_N = 12+1;
const double INF = 1e+100;
double dist[10+1][10+1]; // ツ板シツ径 a ツづ個ケツーツキツづ個陳心ツづ板シツ径 b ツづ個ケツーツキツづ個陳心ツづづ個仰猟猟」ツ。
double d[MAX_N][MAX_N];
double dp[1<<MAX_N][MAX_N];
int n, w;
int a[MAX_N];

// ツケツーツキツ甘板づ個仰猟猟」ツづーツ仰づ淞づゥ
int calc (void )
{
	for (int i = 3; i <= 10; i++ )
		for (int j = 3; j <= 10; j++ )
			dist[i][j] = 2.0*sqrt ((double)i*j );
}

// ツ経ツ路ツづ個静堋堕アツづーツ仰づ淞づゥ
void make (void )
{
	// ツ渉可甘コツ可サ
	rep (i, n+1 )
		rep (j, n+1 )
				d[i][j] = INF;

	rep (i, n )
		rep (j, n )
			d[i][j] = dist[a[i]][a[j]];

	rep (i, n ){
		d[n][i] = a[i]; d[i][n] = a[i];
	} // end rep
	n++;
}

// bitDP
double solve (){

	// ツ渉可甘コツ可サ
	rep (S, 1<<n ){
		fill (dp[S], dp[S]+n, INF );
	} // end rep

	dp[(1<<n)-1][0] = 0;
	for (int S = (1 << n ) - 2; S >= 0; S-- ){
		rep (v, n ){
			 rep (u, n ){
				if (!(S >> u & 1 ) ){
					dp[S][v] = min (dp[S][v], dp[S | 1 << u][u] + d[v][u] );
				} // end if
			} // end rep
		} // end rep
	} // end for

	return dp[0][0];
}

int main()
{
	calc ();
	string str = "";

	while (getline (cin, str ) ){
		vector <int> cake; 
		stringstream ss (str );
		ss >> w;
		int i = 0, m;
		while (ss >> m ){
			 a[i++] = m;
		} // end while
		n = i;
		make ();
		if ((double)w >= solve () ){
			printf ( "OK\n" );
		}else{
			printf ( "NA\n" );
		} // end if
	} // end loop
		
	return 0;
}

Measured memory_bytes: 1744
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main()
{
    ll X,Y;
    cin >> X >> Y;
    int count = 0;
    while(X <= Y)
    {
        X *= 2;
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
H,W = map(int, input().rstrip().split())

map_list = []
black = 0
for i in range(H):
    map_list.append(input())
    black += map_list[i].count('#')

queue = [(0,0)]
check = [(0,0)]
C = [0,0]
count = 0
hNow,wNow = 0,0

while 1:
    count += 1
    if len(queue) != 0:
        if queue[0] == (H-1,W-1):
            print(H*W - black -1 - max(C))
            break # ゴールか判定
    if len(queue) == 0:
        print(-1)
        break
    hNow,wNow = queue[0][0],queue[0][1]
    queue.pop(0)
    if hNow < H-1:
        if map_list[hNow+1][wNow] != "#":
            if (hNow+1,wNow) not in check:
                queue.append((hNow+1,wNow))
                check.append((hNow+1,wNow))
                C.append(C[count]+1)
    if wNow < W-1:
        if map_list[hNow][wNow+1] != "#":
            if (hNow,wNow+1) not in check:
                queue.append((hNow,wNow+1))
                check.append((hNow,wNow+1))
                C.append(C[count]+1)
    if hNow > 0:
        if map_list[hNow-1][wNow] != "#":
            if (hNow-1,wNow) not in check:
                queue.append((hNow-1,wNow))
                check.append((hNow-1,wNow))
                C.append(C[count]+1)
    if wNow > 0:
        if map_list[hNow][wNow-1] != "#":
            if (hNow,wNow-1) not in check:
                queue.append((hNow,wNow-1))
                check.append((hNow,wNow-1)) #近いやつを入れる
                C.append(C[count]+1)
    #print(queue)
#print(count)
#print(C)
#print(black)


Measured memory_bytes: 3188
/* 
* ID: juryc
* PROG: Semi Common Multiple
* LANG: C++
*/	
#include<bits/stdc++.h>
using namespace std;
#define lcm(a,b) ((a)*(b))/(__gcd(a,b))
typedef long long ll;
int main(){
int n,m; cin>>n>>m;
vector<ll> v(n); 
for(ll& i:v) {cin>>i;}
for(ll& i: v) i/=2;
int t=__builtin_ctz(v[0]);
for(ll& i: v){
if(__builtin_ctz(i)!=t){
cout<<0<<endl; return 0;
}
}
ll lm=1;
for(ll& i: v) lm=lcm(lm,i);
m/=lm;
cout<<(m+1)/2<<"\n";   
return 0;
}

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

#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define INF 100000000000ULL

using namespace std;

namespace Kyopro {

    using ll = long long;



    const ll MOD = 998244353LL;

    const int MAX = 210000;

    long long fac[MAX], finv[MAX], inv[MAX];

    // テーブルを作る前処理
    void COMinit() {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++) {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }

    // 二項係数計算
    long long COM(int n, int k) {
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }

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

    ll f(size_t m, size_t n) {
        ll ret = (m * modpow(m - 1, n - 1, MOD)) % MOD;
        return ret;
    }

    long long modinv(long long a, long long m) {
        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;
    }

    ll combinations2(size_t n, size_t k) {
        ll r = 1;
        for (ll d = 1; d <= k; ++d) {
            r *= n--;
            r = r % MOD;
            r = r * modinv(d, MOD);
            r = r % MOD;
        }
        if (r > MOD / 2) {
            r -= MOD;
        }
        return r;
    }
}

using namespace Kyopro;


void solve() {
    size_t k;
    cin >> k;
    string s;
    cin >> s;
    string ret;
    if (s.length() > k) {
        ret = s.substr(0, k) + "...";
    }
    else {
        ret = s;
    }
    cout << ret << endl;
}

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

    COMinit();

    solve();

    return 0;
}

Measured memory_bytes: 8576
import sys
input = sys.stdin.readline
N = int(input())
r = 0
res = 1
for i in range(1, N + 1):
  t = i
  c = 0
  while t % 2 == 0:
    c += 1
    t //= 2
  if c > r:
    res = i
    r = c
print(res)

Measured memory_bytes: 38256
sx, sy, tx, ty = map(int, input().split())

ans = ""

ans += "R" * (tx - sx)
ans += "U" * (ty - sy)
ans += "L" * (tx - sx)
ans += "D" * (ty - sy)
ans += "D"
ans += "R" * (tx - sx + 1)
ans += "U" * (ty - sy + 1)
ans += "L"
ans += "U"
ans += "L" * (tx - sx + 1)
ans += "D" * (ty - sy + 1)
ans += "R"

print(ans)


Measured memory_bytes: 3060
import math

def answerCounter(N, i, answer):
    counter = 0
    power = 2
    sumPower = 1

    while N % i == 0:
        counter = counter + 1

        if sumPower == counter:
            answer = answer + 1
            sumPower = sumPower + power
            power = power + 1

        N = N // i

    return answer, N

def main():
    N = int(input())

    answer, N = answerCounter(N, 2, 0)

    for i in range(3, int(math.sqrt(N)) + 1, 2):
        answer, N = answerCounter(N, i, answer)

        if N < i:
            break

    if N > 2:
        answer, N = answerCounter(N, N, answer)

    print(answer)

if __name__ == "__main__":
    main()

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n;
  cin >> n;
  ll tot = 0;
  vector<ll> a(n), x(n);
  rep(i, n) cin >> a[i];

  ll x2 = 0;
  rep(i, n) {
    if (i & 1)
      x2 -= a[i];
    else
      x2 += a[i];
  }

  x[0] = x2 / 2;
  rep(i, n - 1) x[i + 1] = a[i] - x[i];
  for (auto t : x) cout << 2LL * t << " ";
  cout << endl;

  return 0;
}


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

int main()
{
    int n;
    cin>>n;
    double arr[n]={0};
    for(int i=0;i<n;i++)
   {
       double a;
       cin>>a;
       arr[i]=a;
   }
    
    double dp[n+1][n+1];
    for(int i=0;i<n+1;i++)
    for(int j=0;j<n+1;j++)
    dp[i][j]=0.0;
    dp[0][0]=1.00;

   

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            dp[i+1][j+1]+=dp[i][j]*arr[i];
            dp[i+1][j]+=dp[i][j]*(1-arr[i]);
        }
    }
    

    
    double ans=0;
    for(int i=(n+1)/2;i<=n;i++)
    {
        ans+=dp[n][i];
    }
cout<<fixed<<setprecision(10)<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 70528
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  int n, m;
  rd(n, m);
  auto a = readln.split.to!(long[]);

  long[long] map;
  long tot = 0, mulm = 0;
  for (int i = 0; i < n; i++) {
    if (i > 0) {
      a[i] += a[i - 1];
    }
    if (a[i] % m == 0) {
      tot += (++mulm);
    } else {
      if (a[i] % m in map)
        tot += map[a[i] % m];
      if (a[i] % m in map)
        map[a[i] % m]++;
      else
        map[a[i] % m] = 1;
    }
  }
  writeln(tot);
}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


Measured memory_bytes: 8144
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// Still trying to be normal
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e9 + 15;
int dp[maxn];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    rep(i,0,maxn)dp[i]=INF;
    ll n,k;
    cin>>n>>k;
    int vet[maxn];
    dp[0]=0;
    rep(i,0,n){
        cin>>vet[i];
    }
    rep(i,1,n){
        rep(j,1,min(i,k)+1){
            dp[i]=min(dp[i],dp[i-j]+abs(vet[i]-vet[i-j]));
        }
    }
    cout<<dp[n-1]<<'\n';
    return 0;   
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int dp[100010];

int main(){
    int k;
    cin>>k;
    int a[6],m[6];
    a[0]=100,a[1]=101,a[2]=102,a[3]=103,a[4]=104,a[5]=105;
    rep(i,6) m[i]=1000000;
    memset(dp,-1,sizeof(dp));
    dp[0]=0;
    rep(i,6){
        for(int j=0;j<=k;j++){
            if(dp[j]>=0){
                dp[j]=m[i];
            }
            else if(j<a[i] || dp[j-a[i]]<=0){
                dp[j]=-1;
            }
            else{
                dp[j]=dp[j-a[i]]-1;
            }
        }
    }
    if(dp[k]>=0) cout<<1<<endl;
    else cout<<0<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <stdlib.h>
#include <math.h>

long long int factorial(int n);
long long int WAAI = (int)pow(10, 9) + 7;
using namespace std;
int main() {

	int n, m;


	cin >> n >> m;

	if (abs(n - m) > 1) {
		cout << 0 << endl;
		return 0;
	}
	
	if (n == m) {
		cout << 2 * factorial(n) * factorial(m) %WAAI << endl;
	}
	else {
		cout << factorial(n) * factorial(m) % WAAI<< endl;
	}
	return 0;

}

long long factorial(int n)
{
	int i;
	long long x = 1;
	for (i = 2; i <= n; i++)
	{
		x = x*i%WAAI;
	}
	return x;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	long long n,t[100],i,a,b,x;
	while(scanf("%lld",&n)!=EOF)
	{
		for(i=0;i<n;i++)
		{
			scanf("%lld",&t[i]);
			if(i>=1)
			{
				if(t[i]>t[i-1])
				{
					a=t[i];b=t[i-1];
				}
				else
				{
					a=t[i-1];b=t[i];
				}
				while(b!=0)
				{
					x=a%b;a=b;b=x;
				}
				t[i]=(t[i]/a)*t[i-1];
			}
		}
		printf("%lld\n",t[n-1]);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main(){

int N, ans, wa, ty = 0;
  cin >> N;
int W[N];  
  for(int i = 0;i < N;i++){
    cin >> W[i];
    wa += W[i];
  }
  ans = wa;
  
  for(int i = 0;i < N;i++){
  ty += W[i];
  ans = min(ans, abs((wa - ty) - ty));
  }
  
  cout << ans << endl;
  return 0;
  
}

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

using namespace std;

typedef pair<int, int> PII;
typedef long long LL;
#define PB push_back
#define MP make_pair

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

  vector<PII> item;
  for (int i = 0; i < N; ++i) {
    int w, v;
    cin >> w >> v;
    item.PB(MP(w, v));
  }
  vector< vector<LL> > dp; // dp[i][w]は重さの総和がw以下、i+1番目までのみのときの最大値
  for (int i = 0; i < N + 1; ++i) {
    vector<LL> v(W + 1, 0);
    dp.PB(v);
  }
  for (int i = 1; i <= N; ++i) {
    for (int w = 1; w <= W; ++w) {
      if (item[i-1].first > w)
        dp[i][w] = dp[i-1][w]; // あきらかに入れることができない
      else
        dp[i][w] = max(dp[i-1][w - item[i-1].first] + item[i-1].second, dp[i-1][w]); // 更新する
    }
  }
  cout << dp[N][W] <<endl;
}


Measured memory_bytes: 79984
using System;

class Sample23{
    static void Main(){
        
        int[,,] house = new int[4, 3, 10];
        int data = int.Parse(Console.ReadLine());

        //データの数だけ繰り返し
        while(data-- > 0){
            
            string[] input = Console.ReadLine().Split(' ');

            int building = int.Parse(input[0]);
            int floor = int.Parse(input[1]);
            int room = int.Parse(input[2]);
            int vacation = int.Parse(input[3]);
            
            //バリデーション
            if(building < 1 || 4 < building){
                Console.WriteLine("棟は1~4の範囲で入力してください。");
                Environment.Exit(0);
                
            }else if( floor < 1 || 3 < floor ){
                Console.WriteLine("階は1~3の範囲で入力してください。");
                Environment.Exit(0);
            }

            house[building - 1, floor - 1, room - 1] += vacation;
        }
        
        //処理
        for (int i = 0; i < 4; i++){
            for (int j = 0; j < 3; j++){
                for (int k = 0; k < 10; k++){
                    
                    //バリデーション
                    if(house[i, j, k] < 0 ||  9 < house[i, j, k] ){
                          Console.WriteLine("入居者の人数が範囲外です。");
                          Environment.Exit(0);
                    }
                    Console.Write(" {0}", house[i, j, k]);
                }
                Console.WriteLine(string.Empty);
            }
            
            //棟の切り替え
            if (i < 3){
                Console.WriteLine("####################");
            }
        }

    }
}


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

int main()
{
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << " " << y << " " << z << " " << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
# import statistics
import bisect
import copy
import fractions
import math
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
def unite(x, y):
    # それぞれのノードの根を求める
    x = root(x)
    y = root(y)
    if x == y:
        return
    # node[x]の根をyに変更する
    node[x] = y
def same(x,y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:  # xが根の場合
        return x
    else:
        node[x] = root(node[x])  # 経路圧縮
        return node[x]
def dfs(v):
    # ノードに訪れた
    visited[v] = True
    for v2 in range(n):
        if graph[v][v2] == False:  # そもそもvとv2が辺でつながっていない
            continue
        if visited[v2] == True:  # もう見た
            continue
        dfs(v2)


a, p = MI()
print((a*3+p)//2)


Measured memory_bytes: 67052
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int a, b; cin >> a >> b;
    int idx  = b - a;
    int height = 0;
    for(int i = 1; i < idx; ++i) height += i;
    cout << height - a << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <utility>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int vx = x2 - x1;
    int vy = y2 - y1;
    int x3 = x2 - vy;
    int y3 = y2 + vx;
    int x4 = x3 - vx;
    int y4 = y3 - vy;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


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

int main() {
  int n,ans = 0;
  cin >> n;
  vector<int>data(1e5+1);
  rep(i,0,n){
    int a;
    cin >> a;
    data[a]++;
  }
  rep(i,0,data.size()){
    if(data[i] >= 2){
      if(data[i]%2 == 0) data[i] = 2;
      else data[i] = 3;
    }
  }
  vector<int>a(0);
  rep(i,0,data.size()) if(data[i] != 0) a.push_back(data[i]);
  if(a.size()%2 == 0) cout << a.size()-1 << endl;
  else cout << a.size() << endl;
}

Measured memory_bytes: 4064
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<tuple>
#include<utility>
#define rep(i,n) for(ll i=0; i<n; i++)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  string s;  cin >> s;
  int cnt1 = 0, cnt2 = 0;
  int cnt = 0;
  rep(i,s.size()){
    if(s[i] - '0' == cnt%2){
      cnt1++;
    }else{
      cnt2++;
    }
    cnt++;
  }
  cout << min(cnt1,cnt2);
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(){

  int a[10],max,n,i,j;
  for(i=0;i<10;i++)scanf("%d",&a[i]);
  for(i=0;i<3;i++){
    max=0;
    for(j=0;j<10;j++){
      if(a[j]>max){
	max=a[j];
	n=j;
      }
    }
    printf("%d\n",max);
    a[n]=0;
  }
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
priority_queue<int> q;
struct node {
	int money;
	int day;
};
node a[300000];
bool cmp(node a,node b)
{
	return a.day<b.day;
}
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		cin>>a[i].day>>a[i].money;
	}
	sort(a,a+n,cmp);
	int ans=0;
	int x=0;
	for(int i=1;i<=m;i++)
	{
		while(a[x].day<=i&&x<n)
		
			q.push(a[x++].money);
			if(!q.empty())
			{
			ans=ans+q.top();
			q.pop();
		    }
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 1660
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100100;
const long long MOD = 1000000007;
typedef pair<long long,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

int gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

vector<vector<long long>> dist(205,vector<long long>(205));

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int N,M,R;cin >> N >> M >> R;
    vector<int> target(R);
    for(int i = 0;i<R;i++){
        cin >> target.at(i);
        target.at(i)--;
    }
    for(int i = 0;i<205;i++)for(int j = 0;j<205;j++) dist.at(i).at(j) = INF;
    for(int i = 0;i<M;i++){
        int a,b;long long c;cin >> a >> b >> c;
        a--;b--;
        dist.at(a).at(b) = c;
        dist.at(b).at(a) = c;
    }

    //warshall_floyd
    //頂点iを経由してj→kに行く
    for(int i = 0;i<N;i++){
        for(int j = 0;j<N;j++){
            //そもそも辺が存在しないとcontinue
            if(dist.at(j).at(i) == INF) continue;
            for(int k = 0;k<N;k++){
                if(dist.at(i).at(k) == INF) continue;
                dist.at(j).at(k) = min(dist.at(j).at(k),dist.at(j).at(i)+dist.at(i).at(k));
            }
        }
    }

    long long ans = INF;
    sort(target.begin(),target.end());
    //目的地を訪れる順を全探索
    do{
        long long sum = 0;
        for(int i = 0;i<R-1;i++){
            sum += dist.at(target.at(i)).at(target.at(i+1));
        }
        ans = min(ans,sum);
    }
    while(next_permutation(target.begin(),target.end()));
    
    cout << ans << endl;
}


Measured memory_bytes: 3924
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define inf 1000000000
#define N 400086
using namespace std;
inline int read(){
    int x=0,f=1;int ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
struct opr{ll w;int id;}op[N];
ll sum[N];
int c[N],a[N];
int tot;
bool cmp(opr a,opr b){return a.w<b.w;}
int ask(int i)
{
    int res=0;
    for(;i;i-=i&(-i))res+=c[i];
    return res;
}
void ins(int i)
{
    for(;i<=tot;i+=i&(-i))c[i]+=1;
}
int main()
{
    int n=read(),k=read();
    for(int i=1;i<=n;i++)a[i]=read()-k;
    for(int i=1;i<=n;i++)sum[i]=sum[i-1]+a[i];
    n++;
    for(int i=1;i<=n;i++){
        op[i].w=sum[i-1];op[i].id=i;
    }
    sort(op+1,op+n+1,cmp);
    tot=1;a[op[1].id]=1;
    for(int i=2;i<=n;i++){
        if(op[i].w!=op[i-1].w)tot++;a[op[i].id]=tot;
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        ans+=ask(a[i]);ins(a[i]);
    }
    printf("%lld\n",ans);
    return 0;
}


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


class UnionFind(object):
    def __init__(self, n):
        self.parent={i:i for i in range(1,n+1)}
        self.size={i:1 for i in range(1,n+1)}
    def find(self, a):
        if self.parent[a]!=a:
            self.parent[a]=self.find(self.parent[a])
        return self.parent[a]
    def getsize(self, a):
        return self.size[self.find(a)]
    def unite(self, a, b):
        a=self.find(a)
        b=self.find(b)
        if a==b:return
        if self.size[a]>self.size[b]:
            self.size[a]+=self.size[b]
            self.parent[b]=a
        else:
            self.size[b]+=self.size[a]
            self.parent[a]=b
    def isunited(self, a, b):
        return self.find(a)==self.find(b)


def solve():
    N, M, K = map(int, input().split())
    uft = UnionFind(N)
    d = {i:set() for i in range(1, N+1)}
    e = {i:0 for i in range(1, N+1)}
    f = {i:0 for i in range(1, N+1)}

    for _ in range(M):
        A, B = map(int, input().split())
        d[A].add(B)
        d[B].add(A)
        f[A] += 1
        f[B] += 1
        uft.unite(A, B)

    for _ in range(K):
        C, D = map(int, input().split())
        if uft.isunited(C, D):
            if not D in d[C]:
                e[C] += 1
            if not C in d[D]:
                e[D] += 1

    print(*(uft.getsize(i)-e[i]-f[i]-1 for i in range(1, N+1)))


if __name__ == "__main__":
    solve()


Measured memory_bytes: 132112
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

a = 10 - (A % 10)
if a == 10:
    a = 0
b = 10 - (B % 10)
if b == 10:
    b = 0    
c = 10 - (C % 10)
if c == 10:
    c = 0
d = 10 - (D % 10)
if d == 10:
    d = 0
e = 10 - (E % 10)
if e == 10:
    e = 0
f = max(a, b, c, d, e)
print(A + B + C + D + E + a + b + c + d + e - f)

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

int main(){
    int n;
    cin>>n;
    int a=0,b=0,c=0;
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        if(k%4==0)
            a++;
        else if(k%2==0)
            b++;
        else
            c++;
    }
    a-=c;
    if(a>=0||(a==-1&&b==0))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, M = mapint()
As = list(mapint())
As.sort()

BC = [list(mapint()) for _ in range(M)]
BC.sort(key=lambda x: x[1])

cum = 0
for b, c in BC[::-1]:
    if c<As[0]:
        break
    As.extend([c]*b)
    cum += b
    if cum>=N:
        break

As.sort(reverse=True)
print(sum(As[:N]))

Measured memory_bytes: 107848
s=input()
t=input()
found=False
st=0
for i in range(len(s)-len(t)+1):
  for j in range(len(t)):
    if s[i+j]!=t[j] and s[i+j]!="?":
      break
  else:
    found=True
    st=i

if not found:
  print("UNRESTORABLE")
else:
  ans=s[:st]+t+s[st+len(t):]
  print(ans.replace("?","a"))

Measured memory_bytes: 3064
N = int(input())
"""
N = 100
"""
N_digits = len(str(N))

ans = 0
if N_digits % 2 == 0:
    for i in range(0,int(N_digits/2)):
        ans += 9*10**(2*i)

else:
    for i in range(0,int((N_digits-1)/2)):
        ans += 9*10**(2*i)
    ans += N - 10**(N_digits-1) + 1

print(ans)


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

using namespace std;

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

    priority_queue<long> a;

    long temp;
    for(int i=0; i<n; i++)
    {
        cin>>temp;
        a.push(temp);
    }

    while(m--)
    {
        temp=a.top()/2;
        a.pop();
        a.push(temp);
    }

    long long ans=0;
    for(int i=0; i<n; i++)
    {
        ans+=a.top();
        a.pop();
    }

    cout<<ans;

    return 0;
}

Measured memory_bytes: 1400
def main():
    a, b, c = input().split()
    ans = 0
    ans = max(ans, int(a)+int(b+c))
    ans = max(ans, int(a)+int(c+b))
    ans = max(ans, int(b)+int(a+c))
    ans = max(ans, int(b)+int(c+a))
    ans = max(ans, int(c)+int(a+b))
    ans = max(ans, int(c)+int(b+a))
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)
    
    val n = sc.nextInt()
    val m = sc.nextInt()
    
    println(if (n == m) "Yes" else "No")
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 31384
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():
    N = int(input())

    if N % 2 == 1 or N < 10:
        print(0)
        exit()

    ans = 0
    div = 10
    while div <= N:
        ans += N // div
        div *= 5

    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int A[100002], B[100001];

int main() {
  int N;
  long long result;
  int i;
  scanf ("%d", &N);
  
  for (i=0;i<N+1;i++) {
      scanf("%d", &A[i]);
  }
  for (i=0;i<N;i++) {
      scanf("%d", &B[i]);
  }
  
  result = 0;
  for (i=0;i<N;i++) {
      if (B[i]>A[i]) {
          result += A[i];
          B[i] -= A[i];
          if (B[i]>A[i+1]) {
              result += A[i+1];
              A[i+1] = 0;
          }
          else {
              result += B[i];
              A[i+1] -= B[i];
          }
      }
      else {
          result += B[i];
      }
  }
  
  
  printf("%lld", result);
  return 0;
}




Measured memory_bytes: 896
n,k = gets.split.map(&:to_i)
h={}
n.times do
    a,b = gets.split.map(&:to_i)
    if h.has_key?(a)
        h[a]+=b
    else
        h[a]=b
    end
end
i=0
h.sort.each do |key,v|
    if k.between?(i,i+v)
        puts key
        break
    else
        i+=v
    end
end

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

void solve()
{
	int n;
	cin >> n;
	int a[200000] = {};

	for(int i = 1; i < n; ++i)
	{
		int in;
		cin >> in;
		a[in]++;
	}

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

int main()
{
	solve();

	return 0;
}


Measured memory_bytes: 4392
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long A, long long B, long long C)
{
    cout << C - min(A - B, C) << endl;
}

int main()
{
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long C;
    scanf("%lld", &C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int>pi;
#define elif else if
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define Rep(x,y) for(int k=x;k<y;k++)
#define all(x) x.begin(),x.end()
#define pb push_back
#define vint vector<int>
#define vvint vector<vector<int>>
#define vtr vector<string>
#define vvtr vector<vector<string>>
#define vhar vector<char>
#define vvhar vector<vector<char>>
#define mod 100000007
#define elif else if
#define str string
int digitsum(int a){
  int b=0;
  while(a){
    b+=a%10;
    a/=10;
  }
  return b;
}
signed main(){
  int N,M,O,P=0,c=0,co=1,cou=0,minN=mod;
  double D,Do;
  char C,Ca;
  str S,T,U;
  cin>>N>>M>>O>>P;
  cout<<O-(P-M)<<" "<<P+(O-N)<<" "<<N-(P-M)<<" "<<M+(O-N);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define db double
#define inf 0x3f3f3f3f
using namespace std;

const int N=5e5+10,mod=1e9+7;

int main(){
	int n;
	ll a,b,c=0;
	cin>>n>>a>>b;
	for(int i=3;i<=n;i++) {
		ll x;
		cin>>x;
		c^=x;
	}
	ll s=a+b,d=s-c,ans=d/2;
	bool f=true;
	if((d&1)||d<0||ans>a||(ans&c)) f=false;
	if (f) {
		for(ll i=(1ll<<61);i;i>>=1) {
			if((i&c)&&ans+i<=a) 
				ans+=i;
		} 
		if(ans) cout<<a-ans<<endl;
		else cout<<-1<<endl;
	}
	else {
		cout<<-1<<endl;
	}
	
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>

const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18

using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;

    cout << t << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld =long double;
const ld eps = 1e-9;

bool solve(bitset<18>bs, vector<vector<int>>&dp,const vector<pair<int,int>>&vs,const int now) {
	if(dp[now][bs.to_ulong()]!=-1)return dp[now][bs.to_ulong()];

	bool ok = false;
	if(bs.count()==vs.size())ok=true;
	else {
		for (int i = 0; i < vs.size(); ++i) {
			if (bs[i]) {

			}
			else {
				if (vs[i].first == now || now == 7) {
					bs[i] = true;
					bool aok = solve(bs, dp, vs, vs[i].second);
					if (aok)ok = true;
					bs[i] = false;
				}
				if (vs[i].second == now || now == 7) {
					bs[i] = true;
					bool aok = solve(bs, dp, vs, vs[i].first);
					if(aok)ok=true;
					bs[i] = false;
				}
			}
		}
	
	}
	return dp[now][bs.to_ulong()]=ok;
}
int main()
{
	int N;
	while (cin >> N) {
		vector<pair<int,int>>vs;
		for (int i = 0; i < N; ++i) {
			string st;cin>>st;
			vs.push_back(make_pair(st[0]-'0',st[1]-'0'));
		}

		vector<vector<int>>dp(8,vector<int>(1<<N,-1));

		bitset<18>bs;
		int ok=solve(bs,dp,vs,7);
		if(ok)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}


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

using namespace std;

typedef long long li;

int main() {
  li n, x;
  cin >> n >> x;
  li ans = n;
  li a = x, b = n - x;
  if (a > b) {
    swap(a, b);
  }
  while (a) {
    li k = b / a;
    li r = b - k * a;
    ans += (k * 2 - 1) * a;
    if (r) {
      ans += a;
    }
    b = r;
    swap(a, b);
  }  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/dp/tasks/dp_f
//F - LCS
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    string s,t; cin>>s>>t;
    vector<vector<ll>> dp(s.size()+1,vector<ll>(t.size()+1));
    REP(i,s.size()){
        REP(j,t.size()){
            if(s[i]==t[j]){
                dp[i+1][j+1]=dp[i][j]+1;
            }else{
                dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
            }
        }
    }
    //cout<<dp[s.size()][t.size()]<<endl;
    dump(dp,s,t);
    static function<void(ll,ll)> print_lcs = [&](ll i, ll j){
        if(i==0||j==0) return;
        if(s[i-1]==t[j-1]){
            print_lcs(i-1,j-1);
            cout<<s.at(i-1);
        }else{
            if(dp[i-1][j]>=dp[i][j-1]){
                print_lcs(i-1,j);
            }else{
                print_lcs(i,j-1);
            }
        }
    };
    print_lcs(s.size(),t.size()); cout<<endl;

    return 0;
}

Measured memory_bytes: 71168
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  sort(h.begin(),h.end());
  int d=1000000001;
  for(int i=0;i<n-k+1;i++){
    d=min(d,h[i+k-1]-h[i]);
  }
  cout << d << endl;
}

Measured memory_bytes: 640
#if loc||local
#define _GLIBCXX_DEBUG
#endif

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  ll n,k;
  cin>>n>>k;
  vector<ll> a(n);
  cin>>a;

  constexpr auto ceil = [](auto a,auto b){return (a-1)/b+1;};
  auto cnt = [&](ll len)->ll{
    ll res = 0;
    rep(i,n)res+=ceil(a[i],len)-1;
    return res;
  };

  ll loweq=0,high=1e10;
  while(high-loweq>1){
    ll mid = (high+loweq)/2;
    if(cnt(mid)>k)loweq=mid;
    else high=mid;
  }
  cout<<(high)<<endl;

}

Measured memory_bytes: 4660
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>

using namespace std;

int main(){
	string s;
	cin >> s;
	if (s[s.size() - 1] == 's')
		s = s + "es";
	else 
		s = s + 's';
	cout << s << '\n';
	return 0;
}


Measured memory_bytes: 3628
import java.math.BigDecimal
import kotlin.math.PI
import kotlin.math.abs
import kotlin.math.cos
import kotlin.math.sqrt

fun main() {
    val (a, b) = next2Int()
    val (h, m) = next2Int()
    val deg = deg(h, m)
    val x = sqrt(a * a + b * b - 2 * a * b * cos(deg * PI / 180))
    println(BigDecimal(x).toPlainString())
}

fun deg(h: Int, m: Int): Double {
    val dh = h * 30 + m * 0.5
    val dm = m * 6
    val deg = abs(dh - dm)
    return if (deg < 180) {
        deg
    } else {
        360 - deg
    }
}

val sc = java.util.Scanner(System.`in`)
fun next(): String = sc.next()
fun nextInt() = sc.nextInt()
fun next2Int() = Pair(nextInt(), nextInt())
fun next3Int() = Triple(nextInt(), nextInt(), nextInt())
fun nextIntArray(size: Int) = IntArray(size) { nextInt() }
fun nextLong() = sc.nextLong()
fun nextLine(): String = sc.nextLine()
fun nextList() = nextLine().split(" ")
fun printYesNo(isYes: Boolean) = println(if (isYes) "Yes" else "No")
fun printString(action: StringBuilder.() -> Unit) = println(buildString(action))


Measured memory_bytes: 36760
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

temp = [abs(T - h * 0.006 - A) for h in H] # 各地点の気温- 平均温度 の絶対値が最小になるものが、平均値に一番近いはず
ans = temp.index(min(temp)) + 1
print(ans)

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	int n; cin>>n;
	string s;
	cin>>s;
	cout<<(s.substr(0, s.size() / 2) == s.substr(s.size() / 2, s.size()) ? "Yes\n" : "No\n");
}


Measured memory_bytes: 256