akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    int N,D;
    private void solve() {
        N = nextInt();
        D = nextInt();

        int ans = N / (D * 2 + 1);
        if (N - ans * (D * 2 + 1) > 0) {
            ans++;
        }
        out.println(ans);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21332
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c<=32)c=_buff.get();return c;}
ll qpow(ll x,ll k){return k==0?1:1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
int n,m,a,b;
char g[1011][1011];
int cnta,cntb;
void puth(int x,int y)
{
	cnta++;
	g[x][y]='<';
	g[x][y+1]='>';
}
void putv(int x,int y)
{
	cntb++;
	g[x][y]='^';
	g[x+1][y]='v';
}
void out()
{
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)putchar(g[i][j]==' '?'.':g[i][j]);
		puts("");
	}	
}
void check()
{
	if(cnta==a&&cntb==b)
	{
		puts("YES");
		out();
		exit(0);
	}
}
void solve1()
{
	cnta=cntb=0;
	for(int i=0;i<n;i++)for(int j=0;j<m;j++)g[i][j]=' ';
	if(n&1)
	{
		for(int i=0;i+1<m&&cnta<a;i+=2)
		{
			puth(0,i);
		}
	}
	for(int j=0;j+1<m;j+=2)
	{
		for(int i=n&1;i<n&&cnta<a;i++)
		{
			puth(i,j);
		}
	}
	for(int i=0;i+1<n;i++)
	{
		for(int j=0;j<m&&cntb<b;j++)
		{
			if(g[i][j]==' '&&g[i+1][j]==' ')
			{
				putv(i,j);
			}
		}
	}
	check();
}
void solve2()
{
	for(int i=0;i<n;i++)for(int j=0;j<m;j++)g[i][j]=' ';
	cnta=cntb=0;
	if(n>=3&&m>=3)
	{
		puth(0,0);
		puth(2,1);
		putv(0,2);
		putv(1,0);
		for(int j=m-2;j>=0;j-=2)
		{
			if(g[0][j]==' '&&g[0][j+1]==' ')
			{
				puth(0,j);
			}
		}
		for(int j=m-2;j>=0;j-=2)
		{
			for(int i=1;i<n&&cnta<a;i++)
			{
				if(g[i][j]==' '&&g[i][j+1]==' ')
				{
					puth(i,j);
				}
			}
		}
		for(int j=m-1;j>=0;j--)
		{
			for(int i=0;i<n&&cntb<b;i++)
			{
				if(g[i][j]==' '&&g[i+1][j]==' ')
				{
					putv(i,j);
				}
			}
		}
		check();
	}
}
int main()
{
	cin>>n>>m>>a>>b;
	solve1();
	solve2();
	puts("NO");
	return 0;
}


Measured memory_bytes: 2176
# -*- 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

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()


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


def warshall_floyd(g):
    d = defaultdict(dict)
    V = list(g.keys())
    for v in g.values():
        V.extend(list(v))
    V = set(V)
    for i in V:
        for j in V:
            if i in g and j in g[i]:
                d[i][j] = g[i][j]
            else:
                d[i][j] = sys.maxsize
    for k in g:
        for i in g:
            for j in g:
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]

    return d


@mt
def slv(N, M, R, ABC):
    g = defaultdict(dict)
    for a, b, c in ABC:
        g[a][b] = c
        g[b][a] = c

    d = warshall_floyd(g)
    ans = sys.maxsize
    for m in permutations(R):
        c = 0
        for i in range(len(R)-1):
            c += d[m[i]][m[i+1]]
        ans = min(ans, c)

    return ans


def main():
    N, M, R = read_int_n()
    R = read_int_n()
    ABC = [read_int_n() for _ in range(M)]
    print(slv(N, M, R, ABC))


if __name__ == '__main__':
    main()


Measured memory_bytes: 78804
#include<bits/stdc++.h>
using namespace std;
char a[10];
int l;
int main()
{
	cin>>a;
	l=strlen(a)-1;
	for(int i=0;i<=l;i++)
		if(a[i]=='A'&&a[i+1]=='C')
		{
			cout<<"Yes";return 0;
		}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>

#define int long

const int INF = 1000000009;
const long LINF = 1123456789012345678;

long gcd(long num1, long num2){
	if(num2 > num1){
		std::swap(num1, num2);
	}
	if(num2 == 0){
		return num1;
	}else{
		return gcd(num2, num1 % num2);
	}
}

int n;

signed main(){
	scanf("%ld", &n);
	int ans = 0;
	for(int i = 0; i < n; i++){
		int a;
		scanf("%ld", &a);
		if(i == 0){
			ans = a;
		}else{
			ans = gcd(ans, a);
		}
	}
	printf("%ld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod1e7(ll a){
  return (a % 1000000007);
}

ll mod1e9(ll a){
  return (a % 1000000009);
}

ll mod998(ll a){
  return (a % 998244353);
}

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

vector<ll> fac(200001);
void factorial(){
  fac[0] = 1; 
  for(ll i=1; i < 200001; i++){
    fac[i] = mod998(fac[i-1]*i);
  }
}
    
ll nCr(ll n,ll r){
  if(r == 1) return n;
  else if(r == 0) return 1;
  else return mod998(fac[n]/fac[r]/fac[n-r]);
}

int main(){
  ll a,b,k; cin >> a >> b >> k; ll ans = min(a,b);
  
  while(k != 0){
    if(a % ans == 0 and b % ans == 0) k--;
    ans--;
  }
  
  cout << ans + 1 << endl;
  
  
}

Measured memory_bytes: 4592
#include <math.h>
#include <ctype.h>
#include <limits.h>
#include <string.h>
#include <assert.h>

#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>

#define nl                std::cout << "\n"
#define in(x)             std::cin  >> (x)
#define out(x)            std::cout << (x) << " "
#define err(x)            std::cerr << "DBG: " << #x << " " << (x) << "\n"

#define inn(x)            int x; in(x)
#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)
#define rrep(i, n)        for (int i = (n) - 1; i > -1; --i)

#define no                puts("NO")
#define yes               puts("YES")

using ll  = long long int;
using vi  = std::vector<int>;
using ii  = std::pair<int, int>;
using iii = std::pair<ii, int>;
using vii = std::vector<ii>;

const int N = 1010101;
const int MD = 1e9 + 7;

void solve() {
    inn(n);

    vii jobs;
    rep(i, n) {
        inn(a); inn(b);
        jobs.push_back({b, a});
    }

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

    ll t = 0;
    for (auto& i: jobs) {
        t += i.second;
        if (t > i.first) {
            puts("No"); return;
        }
    }
    puts("Yes");
}

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

    //int t; in(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define MP make_pair
#define llu unsigned long long
#define U unsigned int
#define ff first
#define ss second
#define SIZE 100005
#define pie 3.14159265358979323
#define minuss 1e-6
#define pair pair<ll,ll>
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define BIG 1000000000
#define INF 1000000000000005
#define N 10000
vector<ll>vec;
map<string,ll> mps;
map<ll,string> mpss;
set<ll>s1;
set<string>s2;
map<string,ll>::iterator str;
set<ll>::iterator itr;
/*
std::cout << std::fixed;
std::cout << std::setprecision(1);
std::cout << VALUE NAME<<endl;
*/
ll tra[100006],tra1[100006];


int main()
{

    map<ll,ll>mp;
    map<ll,ll>::iterator it;
    string s,s1;
    ll n,m,lock=0;
    cin>>s>>s1;

    for(int i=0; i<s.length(); i++)
    {
        if(s[i]!=s1[i])
        {
            lock=1;
            cout<<"No"<<endl;
            break;
        }
    }
    if(lock==0)
        cout<<"Yes"<<endl;


}



Measured memory_bytes: 3612
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

long long N, cnt, sum;

int main() {
	cin >> N; cnt = 1;
	while (N >= 1) {
		sum += cnt; cnt *= 2LL;
		N /= 2;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int n, k, l[50], ans=0;
	cin >> n >> k;
	rep(i, n) cin >> l[i];
	sort(l, l+n);
	reverse(l, l+n);
	rep(i, k) ans+=l[i];
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(2e5 + 5);
const double EPS = 1e-8;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int n, k, a[105], dp[2][MAX_N];

bool rec(bool turn, int m){
    if(m==0){
        return false;
    }
    if(dp[turn][m]>=0){
        return dp[turn][m];
    }
    bool res = false;
    REP(i,n){
        if(m>=a[i]){
            res |= !rec(!turn,m-a[i]);
        }
        else break;
    }
    dp[turn][m] = res;
    return res;
}

int main() {
    cin >> n >> k;
    REP(i,n) cin >> a[i];
    REP(i,2)fill(dp[i],dp[i]+k+1,-1);
    if(rec(true, k)){
        cout << "First" << endl;
    }
    else {
        cout << "Second" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 8832
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    int M;
    scanf("%d", &M);

    ll sum=0;
    ll sum0=0;
    int i;
    for(i=0; i<M; i++) {
        int d;
        ll c;
        scanf("%d%lld", &d, &c);
        sum+=d*c;
        sum0+=c;
    }
    ll ans=(sum-1)/9+sum0-1;
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 128
(defun lref (list i j)
  (nth j (nth i list)))

(defun check-bingo (list)
  (or (loop for i from 0 below 3
            thereis (loop for j from 0 below 3
                          always (zerop (lref list i j))))
      (loop for i from 0 below 3
            thereis (loop for j from 0 below 3
                          always (zerop (lref list j i))))
      (loop for i from 0 below 3
            always (zerop (lref list i i)))
      (loop for i from 0 below 3
            always (zerop (lref list (- 2 i) i)))))

(let ((bingo
        (loop for i from 0 below 3
              collect (loop for j from 0 below 3
                            collect (read))))
      (n (read)))
  (loop repeat n
        do (setf bingo (subst 0 (read) bingo)))
  (format t "~a~%" (if (check-bingo bingo)
                       "Yes" "No")))


Measured memory_bytes: 15848
x, y = map(int, input().split())

MOD = int(1.0e+9 + 7)
DP_max = 3333334

DP = []

X = int((2 * y - x) / 3)
Y = int((2 * x - y) / 3)

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

if((2 * y - x) % 3 != 0 or (2 * x - y) % 3 != 0 or
   (2 * y - x) < 0 or (2 * x - y) < 0):
    print(0)
else:
    print(cmb(X + Y, Y, MOD))

Measured memory_bytes: 122220
'use strict'

const main = (INPUT) => {
  const N = INPUT.split('\n')[0].split(' ').map(n => Number(n))

  const tmp = N[0] * 3 + N[1]
  const ans = Math.floor(tmp / 2)
  console.log(ans)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 21064
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll a, b;
  cin >> a >> b;

  ll ans = -1;
  for (int i = 1; i <= 2000000; i++) {
    ll na = i * 0.08;
    ll nb = i * 0.1;
    if (na == a && nb == b) {
      ans = i;
      break;
    }
  }

  cout << ans << ln;
  return 0;
}

Measured memory_bytes: 384
#![allow(non_snake_case)]

use std::cmp::max;
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let s = buf.chars().collect::<Vec<char>>();
    let n = buf.len() + 1;
    let mut vs: Vec<i64> = vec![0; n];

    for i in 0..n - 1 {
        if s[i] == '<' {
            vs[i + 1] = vs[i] + 1;
        }
    }

    for i in 0..n - 1 {
        let j = n - 2- i;
        if s[j] == '>' {
            vs[j] = max(vs[j + 1] + 1, vs[j]);
        }
    }
    println!("{}", vs.iter().fold(0, |sum, elem| sum + *elem));
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
void FastInputOutput(){
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}
inline ll power(ll x, ll p, ll m){
    ll res = 1;
    while(p){
        if(p & 1)
            res = ((res % m) * (x % m)) % m;
        x = ((x % m) * (x % m)) % m;
        p >>= 1;
    }
    return res % m;
}
long double ModLog(long double base, long double x) {
    return (logl(x) / logl(base));
}
int gcd (int a, int b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
int lcm(int a, int b){
    return a / gcd(a, b) * b;
}

const int N = 2e3 * 2e3 + 5;
vector<int> a[20];
int n, d;
bool calc(int f, int s){
    ll sum = 0;
    for(int i = 0; i < d; ++i){
        ll part = a[f][i] - a[s][i];
        sum += (part * part);
    }
    ll sq = sqrtl((long double)sum);
    return sq * sq == sum;
}
int main() {
    n = D(), d = D();
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < d; ++j)
            a[i].push_back(D());
    int cnt = 0;
    for(int i = 0; i < n; ++i)
        for(int j = i + 1; j < n; ++j)
            cnt += calc(i, j);
    printf("%d", cnt);
}


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

int num[205];

int main(){
    int n;
    cin>>n;
    REP(i,n){
        int t=1;
        while(t*i<=n){
            num[t*i]+=1;
            t++;
        }
    }
    int ans = 0;
    REP(i,n){
        if(num[i]==8&&i%2==1){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define ms_valtype int

//比較関数
int compare_ms(ms_valtype a, ms_valtype b){
	return a - b;
}

//昇順
void sort_sub(ms_valtype *origin, int left, int right, ms_valtype *tmp){
	if(right - left > 1){
		int i, j, k, half = (left + right) / 2;
		sort_sub(origin, left, half, tmp);
		sort_sub(origin, half, right, tmp);
		for(i = left; i < right; i++){
			tmp[i] = origin[i];
		}
		for(i = left, j = left, k = half; i < right; i++){
			if(k == right){
				origin[i] = tmp[j];
				j++;
			}
			else if(compare_ms(tmp[j], tmp[k]) <= 0 && j < half){
				origin[i] = tmp[j];
				j++;
			}
			else{
				origin[i] = tmp[k];
				k++;
			}
		}
	}
}

void sort(ms_valtype *origin, int N){
	ms_valtype *tmp = (ms_valtype *)malloc(sizeof(ms_valtype) * N);
	sort_sub(origin, 0, N, tmp);
	free(tmp);
}

int min(int a, int b){
	return a <= b ? a : b;
}

int main(){
	int N, i, j, S = 0, maxj, Shalf;
	scanf("%d", &N);
	int *A = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%d", &A[i]);
		S += A[i];
	}
	sort(A, N);
	Shalf = S / 2;
	int *dp = (int *)malloc(sizeof(int) * (Shalf + 1));
	for(j = 0; j <= Shalf; j++){
		dp[j] = 0;
	}
	dp[0] = 1;
	for(i = 0, maxj = 0; i < N; i++){
		maxj = min(maxj + A[i], Shalf);
		for(j = maxj; j >= A[i]; j--){
			dp[j] |= dp[j - A[i]];
		}
		if(dp[Shalf] == 1){
			printf("%d\n", S - Shalf);
			return 0;
		}
	}
	for(i = maxj; i >= 0; i--){
		if(dp[i] == 1){
			printf("%d\n", S - i);
			return 0;
		}
	}
}

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

using namespace std;

#define endl "\n"
typedef long long int ll;
#define f first
#define s second

inline void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
inline void setPrecision(int n){cout.precision(n);}

//DEBUG
#define dbg(x) cerr<<(#x)<<": "<<x<<endl
#define dbgV(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgS(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgM(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
#define dbg2D(x) cerr<<(#x)<<": \n"; for(auto y: x) { for(auto it: y) cerr<<it<<" "; cerr<<endl; } cerr<<endl;
#define dbgA(x, n) cerr<<(#x)<<": "; for(int i=0;i<n;++i) cerr<<x[i]<<" "; cerr<<endl;
#define dbgVP(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;

ll INF = 1e10;
int MOD = 1e9+7;

inline bool ok(double x, double y, double d){
    return ((x*x) + (y*y)) <= (d*d);
}

int main(){
    #ifndef ONLINE_JUDGE
        freopen("debug.txt", "w", stderr);
    #endif
    fastio();
    int n;
    double d;
    cin>>n>>d;
    int cnt = 0;
    for(int i=0;i<n;++i){
        double x,y;
        cin>>x>>y;
        cnt += ok(x, y, d);
    }
    cout<<cnt<<"\n";
    return 0;
}


Measured memory_bytes: 3800
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        xs: [i64; n],
    }

    let mut xs = xs;

    let mut stop = false;
    let mut depth = 0;
    while !stop {
        for x in &mut xs {
            if *x % 2 != 0 {
                stop = true;
                depth -= 1;
                break;
            }
            *x /= 2;
        }

        depth += 1;
    }

    println!("{}", depth);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	for(register int i=0;i<s.size();i++){
		if(s[i]=='C'){
			for(register int j=i+1;j<s.size();j++){
				if(s[j]=='F'){
					cout<<"Yes"<<endl;
					return 0;
				}
			}
		}
	}	
	cout<<"No"<<endl;
	return 0;
}

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

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"
#define all(x) x.begin(),x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

void solve()
{
    int n;
    cin>>n;
    vector<bool> v(n);
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        v[i]=(a==b);
    }
    string ans="No";
    for(int i=0;i+2<n;i++){
        if(v[i] && v[i+1] && v[i+2])ans="Yes";
    }
    cout<<ans<<"\n";
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

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


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

int main()
{
    long long n,sum=0;
    cin>>n;
    for(long long  i=1;i<=n;i++)
    {
        for(long long j=1;j<=n;j++)
        {
            for(long long k=1;k<=n;k++)
                sum+=gcd(i,gcd(j,k));

        }
    }
    cout<<sum<<"\n";
}


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

string s;

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

	cin >> s;

	if (s.size() % 2 == 1) {
		cout << "No";
		return 0;
	}

	for (int i = 0; i < s.size(); i++) {
		if ((i % 2 == 0 && s[i] != 'h') || (i % 2 == 1 && s[i] != 'i')) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
l = [int(input()) for _ in range(5)]
ans = 10**9
for i in range(5):
    ret = 0
    for j in range(5):
        if i==j:
            continue
        else:
            if l[j]%10==0:
                ret += l[j]
            else:
                ret += l[j]+(10-l[j]%10)
    ret += l[i]
    ans = min(ret,ans)
print(ans)

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main()
{
    string s;
    cin >> s;
    if(s == "AAA" || s == "BBB") cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <map>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 1e9+7;
int N, M;
int par[100005], tree_rank[100005], siz[100005], C[100005][2];
ll anslist[100005];

// n要素で初期化
void init(int n){
  rep(i, n){
    par[i] = i;
    tree_rank[i] = 0;
    siz[i] = 1;
  }
}

// 木の根を求める
int find(int x){
  if (par[x] == x) return x;
  else return par[x] = find(par[x]);
}

// xとyの属する集合を併合
void unite(int x, int y){
  x = find(x);
  y = find(y);
  if (x == y) return;

  if (tree_rank[x] < tree_rank[y]) {
    par[x] = y;
    int tmp = siz[x];
    siz[x] += siz[y];
    siz[y] = siz[x];
  }
  else{
    par[y] = x;
    int tmp = siz[x];
    siz[x] += siz[y];
    siz[y] = siz[x];
    if (tree_rank[x] == tree_rank[y]) tree_rank[x]++;
  }
}

// xとyが同じ要素に属するかどうか
bool same(int x, int y){
  return find(x) == find(y);
}

int size(int x) { // 素集合のサイズ
  return siz[find(x)];
}

ll connect_count_in_tree(int a) {
  ll sz = (ll) size(a);
  return sz*(sz-1)/2;
}

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

  cin >> N >> M;
  int a,b;
  rep(i, M) {
    cin >> a >> b;
    a--;b--;
    C[i][0] = a;
    C[i][1] = b;
  }
  init(N);
  ll ans = (ll) N*(N-1)/2;
  anslist[M-1] = ans;
  for (int i=M-1; i>=1; i--) {
    a = C[i][0]; b = C[i][1];
    ll pre_a_size = connect_count_in_tree(a);
    ll pre_b_size = connect_count_in_tree(b);
    if (!same(a, b)) {
      unite(a, b);
      ans += pre_a_size + pre_b_size;
      ll tmp = connect_count_in_tree(a);
      ans -= tmp;
    }
    anslist[i-1] = ans;
  }

  rep(i, M) cout << anslist[i] << "\n";
  return 0;
}

Measured memory_bytes: 4096
import Control.Monad
import Control.Applicative
import Data.List

main = do
  n <- readLn :: IO Int
  when (n /= 0) $ do
    print $ solve n
    main

solve :: Int -> Int
solve x = sum $ take x pn

pn = 2:3:[x | x <- [5,7..], not (any (\y -> x `mod` y == 0) (takeWhile (\z -> z * z <= x) pn))]

Measured memory_bytes: 6464
#include<stdio.h>

int main(void)
{
  int a,b=0;
  
  scanf("%d %d",&a,&b);
  
  if(a<=b)
  {
    while(b>0)
    {
      b--;
      printf("%c",a+'0');
    }
  }
  else
  {
    while(a>0)
    {
      a--;
      printf("%c",b+'0');
    }
  }
  printf("\n");
  
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<string> vecs;
template<class T,class U> using Hash=unordered_map<T,U>;

#define REP(i, a, n) for(ll i = a; i < (ll)n; i++)
#define RREP(i, a, n) for(ll i = n-1; i >= (ll)a; i--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, 0, n)
#define MD 1000000007

template<class T> T read(){T a;cin >> a;return a;}
template<class T> void read(T& a){cin >> a;}
template<class T, class ...Args> void read(T& a, Args&... args){cin >> a; read(args...);} 
template<class T> void rarr(T a, int n){for(int i = 0; i < n; i++) {cin >> a[i];}}
template<char c = ' ',class T> void write(T a){cout << fixed << setprecision(4) << a << endl;}
template<char c = ' ',class T,class ...Args> void write(T a, Args... args){cout << fixed << setprecision(4) << a << c; write<c>(args...);}
template<class T> void warr(vector<T> a, const char* c = " "){cout << a[0];for(int i = 1; i < (int)a.size(); i++)cout << c << a[i];cout << endl;;}
template<class T> void warr(T a, int n, const char* c = " "){cout << a[0];for(int i = 1; i < n; i++)cout << c << a[i];cout << endl;}
void split(string s, string delim, veci& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(atoi(s.substr(pos).data()));break;}else {result.push_back(atoi(s.substr(pos, p - pos).data()));}pos = p + delim.size();}}
void split(string s, string delim, vecs& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(s.substr(pos));break;}else {result.push_back(s.substr(pos, p - pos));}pos = p + delim.size();}}
ull gcd(ull a, ull b){while(true){ull k = a % b;if(k == 0)return b;a = b;b = k;}}
ull comb(ull n, ull m){ull p=1;m=min(m,n-m);for(ull i=1;i<=m;i++){p*=n-i+1;p/=i;}return p;}

int main(void)
{
    string s;
    read(s);
    reverse(s.begin(),s.end());
    write(s);
    return 0;
}

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

const int MOD = 1e9+7;

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

	int N, M;
	cin >> N >> M;
	vector<vector<bool>> g(N+2, vector<bool>(M+2, false));
	char c;
	for(int i=0; i<N; i++)
		for(int j=0; j<M; j++){
			cin >> c;
			g[i][j] = c=='.';
		}

	vector<vector<int>> dp(N+10, vector<int>(M+10, 0));
	dp[N-1][M-1] = 1;

	for(int i=N-1; i>=0; i--){
		for(int j=M-1; j>=0; j--){
			if(!g[i][j] || (i==N-1 && j==M-1)) continue;
			dp[i][j] += (g[i+1][j]) ? dp[i+1][j] : 0;
			dp[i][j] += (g[i][j+1]) ? dp[i][j+1] : 0;
			dp[i][j] %= MOD;
		}
	}
	cout << dp[0][0];
}


Measured memory_bytes: 4480
while True:
    n,m=map(int, input().split())
    if(n==0):
        break
    cn=[]
    cm=[]
    
    for i in range(n):
        cn.append(int(input()))
    for i in range(m):
        cm.append(int(input()))

    k=0
    for i in range(n):
        for j in range(m):
            cn[i],cm[j]=cm[j],cn[i]
            if(sum(cn)==sum(cm)):
                print(cm[j],cn[i])
                k+=1
                break
            else:
                cn[i],cm[j]=cm[j],cn[i]
        else:
            continue
        break
    
    if(k!=1):
        print(-1)


Measured memory_bytes: 5600
import math

N = int(input())
town_location = [input().split() for _ in range(N)]
town_location = [[int(town_location[i][0]), int(town_location[i][1])] for i in range(N)]
sum_length = 0
for i in range(N-1):
    for j in range(i+1, N):
        sum_length += math.sqrt((town_location[i][0]-town_location[j][0])**2 + (town_location[i][1]-town_location[j][1])**2)
ans = (sum_length * 2) / N
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string o,e,ans;
    int j=0,k=0;
    cin >> o >> e;
    int size = (o + e).size();
    for(int i = 0;i <size;i++){
        if(i % 2==0) {
            ans += o[k];
            k++;
        }
        else {
            ans += e[j];
            j++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
from collections import defaultdict
import sys
readline = sys.stdin.readline
C = defaultdict(int)
N = int(readline())
ans = 0
for i in range(N):
    *s, = readline()
    s.sort()
    t = tuple(s)
    ans += C.get(t, 0)
    C[t] += 1
print(ans)

Measured memory_bytes: 24676
use std::io::{self, BufRead};

fn find(x: i64) -> Option<(i64, i64)> {
  for i in 1..200 {
    let i5 = i*i*i*i*i;
    for k in (-i+1)..(i+1) {
      let j = -k;
      let j5 = j*j*j*j*j;
      if i5 - j5 == x {
        return Some((i, j));
      }
    }
  }
  None
}

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let x: i64 = lines.next().unwrap().unwrap().parse().unwrap();
  if let Some((i, j)) = find(x) {
    println!("{} {}", i, j);
  }
}

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

#define repo(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main(){
    int K,A,B;
    cin >> K >> A >> B;
    for(int i = A; i <=B; i++){
        if(i % K == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;

    return 0;
}



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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000001
#define INFL (1LL << 60)
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main() {
  string s;
  cin >> s;
  sort(ALL(s));
  cout << (s == "abc"?"Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  int i,t=0;
  cin>>s;
  for(i=0;i<s.size()/2;i++){
    if(s[i]!=s[s.size()-1-i]&&s[i]!='('&&s[i]!=')')t++;
    else if(s[i]=='('&&s[s.size()-1-i]!=')')t++;
    else if(s[i]==')'&&s[s.size()-1-i]!='(')t++;
  } 
  if(s.size()%2==1&&(s[s.size()/2]=='('||s[s.size()]/2==')'))t++;
  cout<<t<<endl;
  return 0;
}

Measured memory_bytes: 1184
#include<iostream>

using namespace std;

int main() {
    int N;

    cin >> N;

    int ans = 0, count = 0;
    int back, front;

    cin >> back;

    for(int i = 1; i < N; i++){
        cin >> front;
        if(back >= front) {
            count++;
        } else {
            if(ans < count) {
                ans = count;
            }
            count = 0;
        }

        back = front;

    }

    if(ans < count) {
        ans = count;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
 
ll power(ll a, ll b){//a^b
    ll res=1;
    while(b>0){
        if(b&1){res=(res*a);b--;}
        a=(a*a);
        b>>=1;
    }
    return res;
}
 
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll h,a;
	cin>>h>>a;
	if(h%a)
		cout<<h/a+1<<"\n";
	else
		cout<<h/a<<"\n";
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,m,c,i,s=0,p,j,k;
    cin>>n>>m>>c;
    vector<ll>b;
    vector<ll>a;
    for(i=0;i<m;i++)
    {
        cin>>p;
        b.push_back(p);
    }
    for(i=0;i<n;i++)
    {
        k=0;
        for(j=0;j<m;j++)
        {
            cin>>p;
            k+=(b[j]*p);
        }
        if(k+c>0)
            s++;
    }
    cout<<s<<endl;
}




Measured memory_bytes: 256
s = input()
former, latter = int(s[:2]), int(s[2:])

if 1 <= former <= 12 and 1 <= latter <= 12:
  print('AMBIGUOUS')
elif 1 <= former <= 12 and (latter == 0 or 13 <= latter <= 99):
  print('MMYY')
elif (former == 0 or 13 <= former <= 99) and 1 <= latter <= 12:
  print('YYMM')
else:
  print('NA')


Measured memory_bytes: 2940
/*
AizuOnline A0512
Caesar Cipher
*/
#include <stdio.h>
#include <ctype.h>

char fukugou(char c)
{
  if(isupper(c))
    {if(c >'C')
	return(c-3);
      else
	return(c+23);
    }
  else
    return(c);
}


main()
{
  char input[1001];
  char *x;

  scanf("%s",input);
  x = input;
  while(*x)
  {
    *x = fukugou(*x);
    x++;
  }
      
  printf("%s\n",input);    
  return(0);
}

Measured memory_bytes: 0
# coding :utf-8
import math

num_N = int(input())
num_S = int(input())


def get_s(n, b):
    s = 0
    while n > 0:
        s += n % b
        n //= b
    return s


def solve():
    if num_S == num_N:
        return num_N + 1

    num_sqr = int(math.sqrt(num_N))
    for i in range(2, num_sqr + 1):
        if get_s(num_N, i) == num_S:
            return i

    if num_N % num_S == 0 and num_N // num_S > num_S:
        return num_N // num_S

    num_dif = num_N - num_S
    for i in range(num_sqr + 1, 0, -1):
        b = num_dif / i + 1
        if b != int(b) or b < 2:
            continue
        b = int(b)
        if get_s(num_N, b) == num_S:
            return b
    return -1


print(solve())


Measured memory_bytes: 3188
function Main(input) {
  
	var args = input.split(" ");
  var ans = parseInt(args[0], 10) + (args[1] === "+" ? parseInt(args[2], 10) : - parseInt(args[2], 10));
  console.log(ans);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7668
n = int(input())
x = [i for i in map(int, input().split())]
s = 0

for i in range(n):
    s += x[i]
p = int(s/n)

s = 0
for i in range(n):
    s += (x[i]-p)**2

p += 1
s2 = 0
for i in range(n):
    s2 += (x[i]-p)**2
s = min(s, s2)

print(s)

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
using namespace std;

#define loop(i,first,end) for(int i=(first);i<(end);i++)
#define uint unsigned int
#define ull unsigned long long
#define ll long long
#define vint vector<int>
#define vuint vector<unsigned int>
#define vull vector<ull>
#define vll vector<ll>
#define init(type,var) type var;cin>>var;
#define vinit(vtype,var,n) vtype var(n);loop(i,0,n)cin>>var[i];

const ull MOD = 1000000007ULL;
const ull INF = (ull)(-1LL);

uint func(string& s, vuint& p, uint i){
	int d = (s[i] == 'R' ? +1 : -1);

	if (s[i] != s[i + d]){
		p[i] = i;
		return i;
	}
	else if (p[i] != -1)return p[i];
	else{
		uint _p = func(s, p, i + d);
		_p += (s[_p] == 'R' ? +1 : -1);
		p[i] = _p;
		return _p;
	}
}

int main(void){
	init(string, s);

	vuint p(s.size(), -1);

	loop(i, 0, s.size())func(s, p, i);

	vuint c(s.size());
	loop(i, 0, s.size())c[p[i]]++;
	loop(i, 0, c.size())cout << c[i] << ' ';
	cout << endl;

	return 0;
}

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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}


signed main() {
    vi A(4);
    REP(i, 4) cin >> A[i];
    vector<bool> mask = {0,0,1,1};
    int sum = accumulate(ALL(A), 0);
    int ans = sum;
    do {
        int t1 = 0;
        REP(i, 4) {
            if(mask[i]) t1 += A[i];
        }
        int t2 = sum - t1;
        chmin(ans, abs(t1-t2));
    } while (next_permutation(ALL(mask)));

    print(ans);

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々


Measured memory_bytes: 3220
using System.Collections.Generic;
using System.Linq;
using System;
class Program
{
    static void Main()
    {
        int count = int.Parse(Console.ReadLine());
        uint[] array = new uint[count];
        for (int i = 0; i < count; i++)
        {
            array[i] = uint.Parse(Console.ReadLine());
        }
        Array.Sort(array);


        uint before = 0;
        int result = 0;
        int streak = 0;
        for (int i = 0; i < count; i++)
        {
            if (array[i] == before)
            {
                streak++;
            }
            else
            {
                if (streak % 2 != 0)
                    result++;

                streak = 1;
            }
            before = array[i];
        }

        if (before == array[count - 1])
        {
            if (streak % 2 != 0)
                result++;
        }

        Console.WriteLine(result.ToString());
    }
}

Measured memory_bytes: 15580
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <numeric>
#include <cmath>

using namespace std;

template<class T>
class Input {
public:
    auto operator()() const {
        T v;
        cin >> v;
        return v;
    }
};

template<class L, class R>
class Input<pair<L, R>> {
public:
    auto operator()() const {
        L l;
        R r;
        cin >> l >> r;
        return make_pair(l, r);
    }
};

template<class U>
class Input<vector<U>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        return (*this)(n);
    }
    auto operator()(size_t n) const {
        vector<U> v;
        v.reserve(n);
        Input<U> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in();
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class U>
class Input<vector<vector<U>>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        auto m = in();
        return (*this)(n, m);
    }
    auto operator()(size_t n, size_t m) const {
        vector<vector<U>> v;
        v.reserve(n);
        Input<vector<U>> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in(m);
            v.emplace_back(move(u));
        }
        return v;
    }
};

class InputType
{
public:
    template<class T>
    operator T() const {
        Input<T> i{};
        return i();
    }
};

class InputType2
{
public:
    InputType2(size_t n)
        : n_(n)
    {}
    template<class T>
    operator T() const {
        Input<T> i{};
        return i(n_);
    }
private:
    size_t n_;
};

auto input() {
    return InputType();
}

template<class... Args>
auto input(Args&&... args) {
    return InputType2(std::forward<Args>(args)...);
}

size_t bitcount(size_t n) {
    size_t c = 0;
    while (n) {
        if (n & 1ull)
            ++c;
        n >>= 1;
    }
    return c;
}

auto make_order(size_t n) {
    vector<size_t> a(n, 0);
    iota(begin(a), end(a), 0);
    return a;
}

template<class T>
auto next_permutation(T&& x) {
    using std::begin;
    using std::end;
    return next_permutation(begin(x), end(x));
}

using ll = long long;
using ull = unsigned long long;

auto gcd(size_t l, size_t r) {
    if (r == 0)
        return l;
    return gcd(r, l % r);
}

auto gcd(size_t a, size_t b, size_t c) {
    return gcd(a, gcd(b, c));
}

int main() {
    size_t n = input();
    switch (n % 10) {
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            break;
        default:
            cout << "bon" << endl;
            break;
    }
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 100000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return r;
}

void Integer_factorization(ll factor[],ll n){
    ll a = 2;
    bool flag = false;
    for(int p = 2;p*p <= n;p++){
        while(n%p == 0){
            n/=p;
            factor[p]++;
        }
    }
    if(n!=1)  factor[n]++; //prime num
}

void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}

void solve(void){
    int  a,b,t;
    cin >> a >> b >> t;
    cout << b*(t/a);

}

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

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

using namespace std;

int main() {
  int n, a;
  cin >> n >> a;
  int w = n % 500;
  if ((w == 0) || (n < a) || ((w == 0) && (a == 0)) || (w < a)) {
      cout << "Yes" << endl;
  }
  else {
      cout << "No" << endl;
  }
}

Measured memory_bytes: 3092