akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define FORR(i, m, n) for(int i=m; i>=n; i--)
#define INF 999999999
#define ll long long
#define VSORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
58 23 42
)");
#define cin input
#endif

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

	cout << ((b-a)%2==0 ? "Alice":"Borys") << endl;
}

Measured memory_bytes: 256
D,G=[int(x) for x in input().rstrip().split()]
l=[]
val=[]
ans_cnt=float('inf')
cnt=float('inf')
now=0
for i in range(D):
  pc=[int(x) for x in input().rstrip().split()]


  l.append(pc)
kai=0
for i in range(2**D):
  for j in range(D):#現在のiを2進数で表したものをシフトさせるためのfor文
    if ((i>>j) & 1):
      kai=l[D-j-1][0]#D=4でj=0のときは0001などの時にインデックス3を参照したい。
      for s in range(kai):
        if s+1==kai:
          now+=l[D-j-1][1]
        
        now+=(D-j)*100
        cnt+=1   

        if G<=now:
          ans_cnt=min(ans_cnt,cnt)
          break

  cnt=0
  now=0

print(ans_cnt)
  



Measured memory_bytes: 3188
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int[] v = new int[n];
		int[] c = new int[n];
		Arrays.setAll(v, i -> sc.nextInt());
		Arrays.setAll(c, i -> sc.nextInt());
		
		int ans = 0;
		for (int i = 0; i < n; i++) {
			ans += Math.max(v[i] - c[i], 0);
		}
		
		System.out.println(ans);
		
		sc.close();
	}
	
}




Measured memory_bytes: 32252
import collections
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
l=[]
for _ in range(Q):
    l.append(list(map(int,input().split())))
c = collections.Counter(A)
sum=sum(A)
for i in range(Q):
    if c[l[i][0]] == 0:
        print(sum)
        continue
    else:
        sum+=c[l[i][0]]*(l[i][1]-l[i][0])
        c[l[i][1]]+=c[l[i][0]]
        del c[l[i][0]]
        print(sum)


Measured memory_bytes: 37616
import itertools
n, k=map(int, input().split())
benchmark=((n-1)*(n-2))//2
seq=[]
for i in range(n-1):
    seq.append(i+2)

if k<=benchmark:
    m=(n-1)+(benchmark-k)
    count=benchmark-k
    print(m)
    for i in range(n-1):
        print("1 {}".format(i+2))
    combi_list=list(itertools.combinations(seq, 2))
    for i in range(count):
        print("{} {}".format(combi_list[i][0], combi_list[i][1]))

else:
    print(-1)


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

int main()
{
    int n, m;
    cin >> n >> m;
    P p[m];
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        p[i] = make_pair(b,a);
    }

    sort(p, p + m);

    int ans = 0;
    int s = p[0].first;

    for (int i = 0; i < m; i++) {
        if (s <= p[i].second) {
            ans++;
            s = p[i].first;
        }
    }

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

Measured memory_bytes: 1024
def Main(N, A, B):
    div = N // (A + B)
    res = N % (A + B)
    res2 = min(res, A)
    return div*A + res2
                     

def main():
    N, A, B = map(int, input().split())
    print(Main(N, A, B))

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
N,W = map(int,input().split())

w=[]
v=[]


for _ in range(N):
    x,y = map(int,input().split())
    v.append(x)
    w.append(y)


dp = [[0]*(W+1) for i in range(N+1)]

for i in range(N):
    for j in range(W+1):
        if j < w[i]:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+v[i])
    
print(dp[N][W])


Measured memory_bytes: 25496
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+1;
const int mod = 1e9+7;
int arr[upperlimit];
int main() {
	int k,n,ans=INF;
	sd(k);sd(n);
	for(int i = 1; i <= n; i++) sd(arr[i]);
	sort(arr+1,arr+n+1);
	for(int i = 1; i < n; i++){
		ans=min(ans,arr[i]+k-arr[i+1]);
	}
	ans=min(ans,arr[n]-arr[1]);
	pd(ans);
	return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
N = int(input())
A = list(map(int, input().split()))
A.sort()

print (str(A[N-1]-A[0]))

Measured memory_bytes: 38256
D = input()

ops = []
for i in range(1 << 3):
    op = ""
    xx = bin(i)[2::].zfill(3)
    for x in xx:
        if x=="0":
            op += "+"
        else:
            op += "-"
    ops.append(op)

for op in ops:
    res = D[0]
    for i in range(3):
        res += op[i]+D[i+1]
    if eval(res)==7:
        print(res + "=7")
        break


Measured memory_bytes: 3060
MOD = 998244353

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

dp = [0] * (N+1)
dp[1] = 1

LR = []

for i in range(K):
  l, r = list(map(int, input().split()))
  LR.append([l, r])

for i in range(2, N+1):
  dp[i] = dp[i-1]
  for j in range(K):
    l, r = LR[j]
    dp[i] += dp[max(i-l, 0)] - dp[max(i-r-1, 0)]
    dp[i] %= MOD

print((dp[N]-dp[N-1]) % MOD)

Measured memory_bytes: 74612
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

alias P = Tuple!(int, "from", int, "to");
alias Q = Tuple!(int, "to", long, "cost");
long[][] a;
alias RBT = RedBlackTree!(P, (p, q) => a[p.from][p.to] < a[q.from][q.to], true);

void main()
{
  int n = readln.chomp.to!int;
  a = new long[][](n);
  foreach (i; 0 .. n)
  {
    a[i] = readln.chomp.split.map!(to!long).array;
  }
  RBT queue = new RBT();
  foreach (i; 0 .. n)
  {
    foreach (j; i + 1 .. n)
    {
      queue.insert(P(i, j));
    }
  }
  Q[][] adj = new Q[][](n);
  long[][] dist = new long[][](n, n);
  foreach (i, ref arr; dist)
  {
    arr[] = 1L << 60;
    arr[i] = 0;
  }
  bool ng = false;
  while (queue.length)
  { // O(n^2 log n)
    P node = queue.front;
    queue.removeFront;
    foreach (i; 0 .. n)
    {
      if (dist[i][node.to] > dist[i][node.from] + dist[node.from][node.to])
      {
        dist[i][node.to] = dist[node.to][i] = dist[i][node.from] + dist[node.from][node.to];
      }
      if (dist[node.from][i] > dist[node.from][node.to] + dist[node.to][i])
      {
        dist[node.from][i] = dist[i][node.from] = dist[node.from][node.to] + dist[node.to][i];
      }
    }
    long atom = dist[node.from][node.to];
    long vs = a[node.from][node.to];
    if (atom < vs)
    {
      ng = true;
      break;
    }
    if (atom == vs)
    {
      continue;
    }
    // link
    // stderr.writeln(node.from, " ", node.to, " : ", vs);
    adj[node.from] ~= Q(node.to, vs);
    adj[node.to] ~= Q(node.from, vs);
    dist[node.from][node.to] = vs;
    dist[node.to][node.from] = vs;
    foreach (i; 0 .. n)
    {
      if (dist[i][node.to] > dist[i][node.from] + dist[node.from][node.to])
      {
        dist[i][node.to] = dist[node.to][i] = dist[i][node.from] + dist[node.from][node.to];
      }
      if (dist[node.from][i] > dist[node.from][node.to] + dist[node.to][i])
      {
        dist[node.from][i] = dist[i][node.from] = dist[node.from][node.to] + dist[node.to][i];
      }
    }
    /+
    foreach (i; 0..n) {
      foreach (j; 0..n) {
        if (j) stderr.write = " ";
        stderr.write = dist[i][j] == 1L << 60 ? "*" : dist[i][j].to!string;
      }
      stderr.writeln;
    }
    stderr.writeln;
    +/
  }
  /+
  foreach (i; 0..n) {
    foreach (j; 0..n) {
      ng |= a[i][j] != dist[i][j];
    }
  }
  +/
  if (ng)
  {
    writeln = -1;
    return;
  }

  long sum = 0;
  foreach (arr; adj)
  {
    foreach (q; arr)
    {
      sum += q.cost;
    }
  }
  sum /= 2;
  
  sum.writeln;
}


Measured memory_bytes: 9340
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = 10**5 + 2
    E = [False]*2 + [True]*N
    for i in range(2,int(sqrt(N)+1)):
        if E[i]:
            j = 2*i            
            while j < N:
                E[j]=False
                j+=i
    memo = [0]*N
    for i in range(1,N):
        memo[i] = memo[i-1]
        if i&1 and E[(i+1)//2] and E[i]:
            memo[i] += 1
            # print(i)
    # print(E[:12])
    # print(memo[:12])
    Q = I()
    for _ in range(Q):
        l,r = MI()
        # print("r",r)
        ans = memo[r] - memo[l-1]
        # print(memo[r] ,memo[l-1])
        print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 51148
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv vector<int>
#define endl "\n"
#define test(i) cout<<i<<endl
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())

void file(){
    #ifdef LOCAL
    freopen("demo.in","r",stdin);
    freopen("demo.out","w",stdout);
    #endif
}

void test_case(){
    string s;
    cin>>s;
    if(s[0]=='7' ||s[1]=='7'||s[2]=='7'){
        test("Yes");
    }
    else{
        test("No");
    }
}

int main(){
    fastio;
    file();
    int T=1;
    // cin>>T;
    for(int nr=1;nr<=T;++nr) {
    //     cout<<"Case #"<<nr<<": ";
		test_case();
    }
}

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

int main()
{
	int H, W, N,sum,ans;
	cin >> H >> W >> N;
	if (H < W) {
		ans = N / W;
		if (W*ans < N) {
			ans++;
		}
	}
	else {
		ans = N / H;
		if (H*ans < N) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

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

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

int main(){
	init();
	ll N;cin>>N;
	vector<pair<ll,ll>>G[N];
	for(int i=0;i<N-1;i++){
		ll a,b,c;cin>>a>>b>>c;
		a--;b--;
		G[a].push_back(make_pair(b,c));
		G[b].push_back(make_pair(a,c));
	}
	
	ll Q,K;cin>>Q>>K;K--;
	
	//dis K and i
	queue<pair<ll,ll>>que;
	vector<ll>d(N,0);
	que.push(make_pair(K,0));
	vector<bool>ex(N,false);
	ex[K]=true;
	
	while(!que.empty()){
		ll u=que.front().first;
		ll dis=que.front().second;
		d[u]=dis;
		que.pop();
		for(int i=0;i<G[u].size();i++){
			ll next = G[u][i].first;
			//cout<<" next"<<next<<endl;
			if(ex[next])continue;
			ex[next]=true;
			que.push(make_pair(next,dis+G[u][i].second));
		}
	}
	for(int q=0;q<Q;q++){
		ll x,y;cin>>x>>y;x--;y--;
		cout<<d[x]+d[y]<<endl;
	}
}


Measured memory_bytes: 10864
import sys
a, b = [int(i) for i in input().split()]

if b > (a-1)*(a-2)//2:
    print(-1)
    sys.exit()

c = []
cur = 1
while cur < a:
    for i in range(1, a + 1):
        if cur < i:
            c.append([cur, i])
    cur += 1

for _ in range(b):
    c.pop()

print(len(c))

for i in c:
    print(int(i[0]), int(i[1]))

Measured memory_bytes: 4120
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const ld Pi=acos(-1);
int nature(ll a){
  if(a>=0){return a;}
  else{return 0;}
}
int main(){
  ll N,M,sum=0,penalty=0;
  cin>>N>>M;
  vector<ll> wa(N);
  vector<bool> whether(N);
  for(ll i=0;i<M;i++){
    ll a;
    string str;
    cin>>a>>str;
    if(str=="WA" &&  whether.at(a-1)==false){wa.at(a-1)++;}
    else{whether.at(a-1)=true;}
  }
  for(ll i=0;i<N;i++){
    if(whether.at(i)){++sum;penalty+=wa.at(i);}
  }
  cout<<sum<<" "<<penalty<<endl;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 100000000)

	n, k := scanInt(), scanInt()
	r, s, p := scanInt(), scanInt(), scanInt()
	t := scanText()

	f := make([]bool, n)
	ans := 0

	for i := 0; i < n; i++ {
		if i-k<0 {
			if t[i] == 'r' {
				ans += p
			} else if t[i] == 's' {
				ans += r
			} else {
				ans += s
			}
			f[i] = true
		} else {
			if f[i-k] == true && t[i-k] == t[i] {
				continue
			} else {
				if t[i] == 'r' {
					ans += p
				} else if t[i] == 's' {
					ans += r
				} else {
					ans += s
				}
				f[i] = true
			}
		}
	}

	fmt.Println(ans)

}


Measured memory_bytes: 1152
N = int(input())
L = list(map(int,input().split()))

FF= []

count =0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            a = L[i]
            b = L[j]
            c = L[k]
            if a != b and b != c and a != c and a + b > c and b + c > a and c + a > b:
                    FF.append(str(a) + str(b) + str(c))
print(len(FF))

Measured memory_bytes: 22824
M = 10 ** 9 + 7
n = int(input())

if n <= 1:
    print(0)
    exit()

nones = 8
zero = 1
nine = 1
other = 0
for x in range(1, n):
    other = other * 10 + zero + nine
    zero = zero * 9 + nones
    nine = nine * 9 + nones
    nones *= 8

    other %= M
    zero %= M
    nine %= M
    nones %= M

print(other)

Measured memory_bytes: 9196
/**
 *    Creator :  bizarre
 *    Date : 4/2020
 *    Problem Number : 415
**/
#include <bits/stdc++.h>
using namespace std;
#define bizarre     ios_base::sync_with_stdio( false ), cin.tie( nullptr ), cout.tie( nullptr );
/*
vector<int> prime_Numbers;
int primes[1000005];
void prime(int n)
{
    primes[1]=primes[0]=0;
    for(int i=2; i<=n; i++)
        primes[i]=true;
    for(int i=2; i<=n; i++)
    {
        if(primes[i]==true)
        {
            prime_Numbers.push_back(i);
            for(int j=i+i; j<=n; j+=i)
                primes[j]=false;
        }
    }
    for(int i=2; i<=n; i++)
        primes[i]+=primes[i-1];
}

void move1step(long long& a, long long& b, long long q)
{
    long long c= a-q*b;
    a=b;
    b=c;
}
long long egcd(long long r0,long long r1,long long& x0,long long& y0)
{
    long long x1=0,y1=1;
    x0=1;
    y0=0;
    while(r1)
    {
        long long q=r0/r1;
        move1step(r0,r1,q);
        move1step(x0,x1,q);
        move1step(y0,y1,q);
    }
    return r0;
}
bool  solve (long long a, long long b, long long c,long long&x, long long& y)
{
    long long g=egcd(a,b,x,y);
    int m=c/g;
    x*=m;
    y*=m;
    return c%g==0;
}



int npr(long long n, long long r)
{
    return (fact[n] * inv[n - r]) % mod;
}

int gcd(int a, int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
void PrimeFactorization(int n)
{
    for(int i=2; i*i<=n; i++)
    {
        int c=0;
        if(n%i==0)
        {
            while(n%i==0)
            {
                n/=i;
            }

        }
    }

}
const int inf = 2e9, mod = 1e9 + 7,N=1e5+5;
long long fact[N], inv[N];
long long fp(long long base, long long exp)
{
    if (exp == 0)
        return 1;
    long long ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}
void pre(long long n)
{
    fact[0] = 1;
    inv[0] = 1;
    for (long long i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}
int ncr(long long n, long long r)
{
    return (((fact[n] * inv[n - r]) % mod) * inv[r]) % mod;
}
long long ncrtane(long long n, long long r)
{
    long long ans=1,cntr=1;
    for(int i=n;i>n-r;i--)
    {
        ans*=i;
        ans/=cntr;
        cntr++;
    }
    return ans;
}
*/
int main()
{
    bizarre
  long long n,k,mnm=2e9;
  cin>>n>>k;
  long long a[n+2];
  for(int i=0;i<n;i++)
  {
      cin>>a[i];
  }
  sort(a,a+n);
  for(int i=0;i<=n-k;i++)
  {
     mnm=min(mnm,a[(i+k-1)]-a[i]);
  }
  cout << mnm;
    return 0;
}


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

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);		
		int n=in.nextInt();
		int [] p=new int [n];
		for(int i=0;i<n;i++)
		{
			p[i]=in.nextInt();
		}
		int ans=0;
		for(int i=1;i<n-1;i++)
		{
			if((p[i]>p[i-1]&&p[i]<p[i+1])||(p[i]>p[i+1]&&p[i]<p[i-1]))
			{
				ans++;
			}
		}
		System.out.println(ans);
	}
}
	

Measured memory_bytes: 23892
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;
 


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define X first
#define Y second
typedef long long ll;
using namespace std;

const int MOD = 1e9 + 7;
const ll INF = 1e18;

int main () {

	int r, g, b, n;
	cin >> r >> g >> b >> n;
	ll sol = 0;
	for (int i = 0; i <= n; i += r) {
		for (int j = 0; j <= n-i; j += g) {
			int ost = n-i-j;
			if (ost % b == 0) {
				sol ++;
			}
		}	
	}
	
	cout << sol;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){

  vector<int>in(3);
	while(cin>>in[0]>>in[1]>>in[2],in[0]||in[1]||in[2]){
  	sort(in.begin(),in.end());	
	  double h=hypot(in[0],in[1])/2;
	
  	int n;
	  cin>>n;
	  rep(i,n){
		  int ans;
		  cin>>ans;
		  if(h<ans)cout<<"OK"<<endl;
		  else cout<<"NA"<<endl;
		}
	
	}
}

Measured memory_bytes: 1220
import sys
input=sys.stdin.readline
class UnionFind:
    def __init__(self,n):
        self.par=[i for i in range(n)] #親要素のノード番号を格納
        self.rank=[0]*n #木の高さを格納
        self.size=[1]*n #size[i]:iを根とするグループのサイズ
    def find(self,x): #根を検索
        if self.par[x]==x: #par[x]==xの時そのノードは根
            return x
        else:
            self.par[x]=self.find(self.par[x]) #親を書き換える
            return self.par[x]
    def union(self,x,y):
        px=self.find(x)
        py=self.find(y)
        if px!=py:
            if self.rank[px]==self.rank[py]: #木の高さが同じなら親とする方を1増やす
                self.rank[px]+=1
            elif self.rank[px]<self.rank[py]:
                px,py=py,px #木の高さが高い方をpxとする
            self.par[py]=px #木の高さが高い方を親とする
            self.size[px]+=self.size[py]
    def same_check(self,x,y): #同じ木に属するか判定
        return self.find(x)==self.find(y)
    
def main():
    n,m,k=map(int,input().split())
    uf=UnionFind(n)
    F_edges=[[] for _ in range(n)]
    for _ in range(m):
        a,b=map(int,input().split())
        a-=1; b-=1
        uf.union(a,b)
        F_edges[a].append(b)
        F_edges[b].append(a)
    B=[0]*n
    for _ in range(k):
        a,b=map(int,input().split())
        a-=1; b-=1
        if uf.same_check(a,b):
            B[a]+=1
            B[b]+=1
    Ans=[]
    for i in range(n):
        Ans.append(uf.size[uf.find(i)]-1-len(F_edges[i])-B[i])
    print(*Ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 104224
#include<iostream>

using namespace std;

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

  return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

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

    int H,W; cin >> H >> W;
    vector<string> grid(H);
    rep(i,H) cin >> grid[i];

    int cnt = 0;
    rep(i,H)rep(j,W) {
        if (grid[i][j] == '#') ++cnt;
    }
    cout << (cnt == H + W - 1 ? "Possible" : "Impossible") << '\n';
    return 0;
}

Measured memory_bytes: 3568
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (LLONG_MAX - 1e5)
#define fcout cout << fixed << setprecision(10)

using namespace std;

string S;
int W;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> S >> W;

    string ans;
    int index = 0;
    while (index < S.size()) {
        ans += S[index];
        index += W;
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long 
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll; 
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
// int ab  (int  x ) { return (x>0?x:-x); }


vector<int> freq [28];
int main(){

	string s , t ; 
	cin >> s >> t; 
	for(int i = 0 ; i < (int)s.length() ; i++ ){
		freq[s[i]-'a'].pb(i+1); 
	}
	// for(int i = 0 ; i < 28 ; i++ ){
	// 	reverse(all(freq[i])); 
	// }

	ll S= (ll)s.length() ,T = (int)t.length() ; 
	int j = 0 ; 
	ll cnt=0, last = 0 ; 
	for(  ; j < T && cnt <= T; ){
		auto it = lower_bound(all(freq[t[j]-'a']),last+1);
		if( it == freq[t[j]-'a'].end()){
			cnt++; 
			last = 0 ; 
		}else{
			j++; 
			last = (*it)*1LL; 
		}
	}
	// cerr << cnt << endl; 
	if( j == T )
	cout << (cnt)*S+last << endl; 
	else cout<<-1; 
}

Measured memory_bytes: 1216
use std::io;


fn main() {
    let mut n = String::new();
    let mut p = String::new();

    io::stdin().read_line(&mut n).ok();
    io::stdin().read_line(&mut p).ok();

    n = n.trim_right().to_owned();
    p = p.trim_right().to_owned();

    let mut n: usize = n.parse().unwrap();
    let mut i = p.split_whitespace();
    let mut p: Vec<i32> = Vec::new();

    for _ in 0..n {
        p.push(i.next().unwrap().parse().unwrap());

    };

    let mut ans = 0;

    for j in 1..n-1 {
        let mut q = [ p[j-1], p[j], p[j + 1]];
        q.sort();
        if p[j] == q[1] {
            ans += 1;
        };
    };
    println!("{}", ans);
}

Measured memory_bytes: 4352
function main(input)
{
    const args = input.split('\n');
    const numbers = args[1].split(' ').map(x => parseInt(x, 10));
    // console.log(numbers);

    var answers = [];
    for (var i = 0; i < numbers.length; i++)
    {
    	answers.push(i + 1);
    }

    // console.log(answers);

    var count = 0;
    for (var i = 0; i < numbers.length; i++)
    {
    	count += (answers[i] === numbers[i]) ? 0 : 1
    }
    // console.log(count);

    const answer = (count === 2 || count === 0) ? 'YES' : 'NO';
    console.log(answer);
}

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

// main(require("fs").readFileSync("/Users/hiroi_junki/IdeaProjects/atcoder/test_abc_135_b.txt", "utf8"));



Measured memory_bytes: 7372
/*
 ABC149 A
 auther: takeheroaf
 created at 2020-1-1 0:49:36
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vc vector
#define a first
#define b second
#define pb push_back
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (100000)

/////////////////////////////////////////////////////////

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

/////////////////////////////////////////////////////////
void Main(){
  string S, T;
  cin >> S >> T;
  cout << T << S << endl;
  return;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// // 整数の入力
		// int a = sc.nextInt();
		// // スペース区切りの整数の入力
		// int b = sc.nextInt();
		// int c = sc.nextInt();
		// // 文字列の入力
		// String s = sc.next();
		// // 出力
    // System.out.println((a+b+c) + " " + s);
    String S = sc.next();
    System.out.print("2018");
    System.out.println(S.substring(4));
	}
}

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

int main() {
	long int n, k, q;
	long int a[100001] = { 0 }, count[100001] = { 0 };

	scanf("%ld %ld %ld", &n, &k, &q);
	for (int i = 1; i <= q; i++) {
		scanf("%ld",&a[i]);
		count[a[i]]++;
	}
	for (int j = 1; j <= n; j++) {
		if (count[j] >= q - k + 1)printf("Yes\n");
		else printf("No\n");
	}

}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int N;cin >> N;
    cout << 180 * (N-2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<class U, class V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}
 
int main() {
    int N; cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    multimap<int, int> mp;
    int color = 0;
    rep(i, N) {
        if(mp.empty()) {
            mp.insert({-A[i], color});
            continue;
        }
        auto it = mp.upper_bound(-A[i]);
        if(it == mp.end()) {
            mp.insert({-A[i], ++color});
        } else {
            mp.insert({-A[i], it->second});
            mp.erase(it);
        }
    }
    cout << color + 1 << "\n";
}


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

int main() {
  int N,M,C;
  int A;
  int count=0;
  cin>>N>>M>>C;
    int B[M];
  for(int i=0;i<M;i++){
    cin>>B[i];
  }
  for(int j=0;j<N;j++){
    int sum=0;
    for(int i=0;i<M;i++){
      cin>>A;
      sum+=A*B[i];
    }

    if(sum+C>0) count++;
  }

  cout<<count<<endl;
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    queue<int> a[1000];
    for(int i=0;i<n;i++){
        for(int j=0;j<n-1;j++){
            int v;
            cin >> v;
            a[i].push(v-1);
        }
    }

    queue<pair<int,int>> next[2];
    set<pair<int,int>> card;
    for(int i=0;i<n;i++){
        int j = a[i].front();
        pair<int,int> p {max(i, j), min(i, j)};
        if(card.count(p)){
            next[0].push(p);
            card.erase(p);
        }else card.insert(p);
    }
    bool is_empty[1000] = {0};
    int cnt = n;
    for(int d=1;d<n*n;d++){
        if(next[(d+1)%2].empty()){
            cout << -1 << endl;
            return 0;
        }
        while(!next[(d+1)%2].empty()){
            auto p = next[(d+1)%2].front();
            next[(d+1)%2].pop();
            for(int x: {p.first, p.second}){
                a[x].pop();
                if(!a[x].empty()){
                    pair<int,int> q {max(x, a[x].front()), min(x, a[x].front())};
                    if(card.count(q)){
                        next[d%2].push(q);
                        card.erase(q);
                    }else card.insert(q);
                }else{
                    if(!is_empty[x]) cnt--;
                    is_empty[x] = true;
                }
            }
        }
        if(cnt == 0){
            cout << d << endl;
            return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
namespace io{
    const int l=1<<20;
    char buf[l],*s,*t,c;
    inline void gc(){
        if(s==t){
            t=(s=buf)+fread(buf,1,l,stdin);
            c=s==t?EOF:*s++;
        }else c=*s++;
    }
    template<class IT>inline void gi(IT &x){
        x=0;gc();while(c<'0'||c>'9')gc();
        while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
    }
    char buf0[20];int a;
    template<class IT>inline void pi(IT x){
        if(x<0){putchar('-');x=-x;}
        do buf0[++a]=x%10+48;while(x/=10);
        while(a)putchar(buf0[a--]);
        putchar('\n');
    }
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
typedef vector<int> vi;
typedef vector<ll > vl;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=200005;

int main(){
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n,i,j,t;
    scanf("%d",&n);
    if(n<=500){
		printf("%d\n",n);
		rep(i,1,n){rep(j,1,n)printf("%d ",i);puts("");}
	}else{
		puts("500");
		rep(i,1,500){
			rep(j,1,500){
				t=(i+j)%500+((i&1)?501:1);
				printf("%d ",t<=n?t:t-500);
			}
			puts("");
		}
	}
    return 0;
}

Measured memory_bytes: 1280
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        long memo[]=new long[n+1];
        System.out.println(cal(n,memo));

    }
    public static long cal(int n,long[]memo){
        if(n==1) return 1;
        if(n==0) return 2;
        if(memo[n]!=0) return memo[n];
        memo[n]=cal(n-1,memo)+cal(n-2,memo);
        return memo[n];
    }
}

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

typedef long long ll;
const int INF = 1 << 30;

int n;
int s[10];

int main(){
    cin >> n;

    for (int i = 1; i < 10; i++){
        s[i] = i * 111;
    }

    for (int i = 1; i < 10; i++){
        if (n <= s[i]){
            cout << s[i] << endl;
            return 0;
        }
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void chmin(int &a, int b) { if (a > b) a = b; }
constexpr int INF = 1e9;

inline bool dif (int s, int i) {
    int a = (1&(s>>i)), b = (1&(s>>(i+1)));
    return (a == b);
}

inline bool over_k (const vector<int> &v, int k) {
    bool ret = false;
    for (const auto &e : v) ret |= (k < e);
    return ret;
}

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<int>> s(h, vector<int>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            char c;
            cin >> c;
            s[i][j] = (c - '0');
        }
    }
    
    int ans = INF;
    for (int bit = 0; bit < (1<<h); bit++) {
        vector<vector<int>> sum;
        vector<int> div(w, 0);
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) div[j] += s[i][j];
            if (i+1 == h or dif(bit, i)) {
                sum.emplace_back(div);
                fill(div.begin(), div.end(), 0);
            }
        }
        
        const int n = sum.size();
        vector<int> cnt(n, 0);
        vector<vector<int>> check;
        for (int j = 0; j < w; j++) {
            for (int i = 0; i < n; i++) cnt[i] += sum[i][j];
            if (over_k(cnt, k)) {
                for (int i = 0; i < n; i++) cnt[i] -= sum[i][j];
                check.emplace_back(cnt);
                fill(cnt.begin(), cnt.end(), 0);
                for (int i = 0; i < n; i++) cnt[i] += sum[i][j];
                if (j + 1 == w) check.emplace_back(cnt);
            } else if (j + 1 == w) {
                check.emplace_back(cnt);
            }
        }
        bool ng = false;
        const int m = check.size();
        for (int i = 0; i < m; i++) ng |= over_k(check[i], k);
        if (not ng) chmin(ans, n + m - 2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=100000+10;
int fa[maxn],co[maxn];
bool bz[maxn],pd[maxn];
int i,j,k,l,r,t,n,m,cnt;
ll ans;
int getfa(int x){
	if (!fa[x]) return x;
	int t=getfa(fa[x]);
	co[x]^=co[fa[x]];
	return fa[x]=t;
}
int main(){
	//freopen("data.in","r",stdin);
	scanf("%d%d",&n,&m);
	fo(i,1,m){
		scanf("%d%d",&j,&k);
		bz[j]=1;bz[k]=1;
		l=getfa(j);r=getfa(k);
		if (l<r){
			swap(l,r);
			swap(j,k);
		}
		if (l==r&&co[j]==co[k]) pd[l]=1;
		if (l==r) continue;
		pd[r]|=pd[l];
		fa[l]=r;
		co[l]=co[j]^co[k]^1;
	}
	fo(i,1,n)
		if (!bz[i]) cnt++;
	ans=(ll)cnt*(n-cnt)*2+(ll)cnt*cnt;
	cnt=0;
	fo(i,1,n)
		if (bz[i]&&!fa[i]) cnt++;
	ans+=(ll)cnt*cnt;
	cnt=0;
	/*fo(i,1,n)
		if (bz[i]&&fa[i]){
			k=getfa(i);
			if (!pd[k]&&co[i]!=co[k]) cnt++;
		}*/
	fo(i,1,n)
		if (bz[i]&&!fa[i]&&!pd[i]) cnt++;
	fo(i,1,n)
		if (bz[i]&&!fa[i]&&!pd[i]) ans+=(ll)cnt;
	printf("%lld\n",ans);
}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b || b == c || a == c){
    if(a == b && b == c) cout << "No" << endl;
  else puts("Yes");
  }
  else puts("No");
}


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

int board[60][60] ;
int d[60][60] ;
queue<P> que ;
int pre = 0 ;
int H , W ;
const int INF = 100000000 ;
int dx[4] = {-1,1,0,0} , dy[4]= {0,0,-1,1} ;

int bfs() {
  int sx = 0 , sy = 0 ;
  int gx = H - 1 , gy = W - 1 ;
  que.push(P(sx,sy)) ;
  d[sx][sy] = 0 ;
  
  while(que.size()){
    P p = que.front() ; que.pop() ;
    if(p.first == gx && p.second == gy ) break ;
    
    for(int i = 0 ; i < 4 ; i++ ){
      int nx = p.first + dx[i] , ny = p.second + dy[i] ;
      if(nx >= 0 && ny >= 0 && nx < H && ny < W && d[nx][ny] == INF && board[nx][ny] == 0 ){
        d[nx][ny] = d[p.first][p.second] + 1 ;
        que.push(P(nx,ny)) ;
      }
    }
  }
  return d[gx][gy] ;
}

int main () {
  //入力
  cin >> H >> W ;
  for(int i = 0 ; i < H ; i++ ){
    for(int j = 0 ; j < W ; j++ ){
      char ch ;
      cin >> ch ;
      if(ch == '#') board[i][j] = 1 ;
      else {
        board[i][j] = 0 ;
        pre ++ ;
      }
    }
  }
  
  //演算
  for(int i = 0 ; i < H ; i++ )
    for(int j = 0 ; j < W ; j++ )
      d[i][j] = INF ;
  int ans = bfs() ;
  if(ans != INF )cout << pre - ( ans + 1 ) << endl ;
  else cout << -1 << endl ;
}


Measured memory_bytes: 3596
#!/usr/bin/env python3

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def main():
    a, b, c = map(int, input().split())
    su = sum([a, b, c])
    ma = max(a, b, c)
    if (ma * 3 - su) % 2 == 0:
        print((ma * 3 - su) // 2)
    else:
        print(((ma + 1) * 3 - su) // 2)

main()


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

using namespace std;
using   ll=long long;

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int
#define pll				pair<int , int>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007
#define hell            998244353

ll mod_pow(ll a,ll b,ll m)
{
    ll res = 1;
    while(b)
    {
        if(b&1)
        {
        	res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a)
{
	return mod_pow(a , mod-2 , mod);
}

void solve()
{
	int n;
	
	cin >> n;
	
	map<int,int> f;
	map<int,int> ff;
	
	for(int i = 0; i < n; ++i) {
		int x;
		
		cin >> x;
		
		if(i % 2) {
			f[x]++;
		}
		else {
			ff[x]++;
		}
	}
	
	int ans = n;
	int m1 = 0;
	int m2 = 0;
	
	int x1;
	int x2;
	
	for(auto u : f) {
		if(u.second > m1) {
			m1 = u.second;
			x1 = u.first;
		}
	}
	
	for(auto u : ff) {
		if(u.second > m2) {
			m2 = u.second;
			x2 = u.first;
		}
	}
	
	for(auto u : f) {
		if(u.first != x2) {
			ans = min(ans , n - u.second - m2);
		}
	}
	
	for(auto u : ff) {
		if(u.first != x1) {
			ans = min(ans , n - u.second - m1);
		}
	}
	
	if(ans == n) {
		ans = n/2;
	}
	
	cout << ans;
}

signed main() {
	fast;
   
    int t = 1;

	//cin >> t;

    while(t--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 9908
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int n=s.length();
    s='A'+s;
    bool maki=true;
    if(s[n]=='1')maki=false;
    if(s[1]=='0')maki=false;
    for(int i=1;i<n;i++){
    	if(s[i]!=s[n-i])maki=false;
    }
    if(!maki){
    	cout << -1<<endl;
    	return 0;
    }
    int m=n/2;
    vector<int> v;
    for(int i=2;i<=m;i++){
    	if(s[i]=='1')v.pb(i);
    }
    vector<pair<int,int> > ans;
    int index=1;
    for(auto& i:v){
    	for(int j=index;j<i;j++){
    		ans.push_back({j,i});
    	}
    	index=i;
    }
    for(int i=index;i<n;i++){
    	ans.push_back({i,n});
    }
    for(auto& i:ans){
    	cout <<i.first<< " " <<i.second <<endl;
    }

    return 0;
}


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

using namespace std;

//#define PRAGMA 448
#ifdef PRAGMA
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

#ifdef LUCARIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif

typedef int intt;
typedef pair<long long,long long> pll;
typedef pair<int,int> pii;

#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define int long long
#define pb push_back
#define bs binary_search
#define up upper_bound
#define fs first 
#define sd second 
#define mp make_pair    
#define endl "\n"

#define fore(i,a,b) for(ll i = a; i < b; i++)
#define rfore(i, a, b) for(ll i = a - 1; i >= b; i--)
#define forev(a,b) fore(i,0,b)cout<<a[i]<<" "; 
#define ing(g,u,v)  g[u].pb(v); g[v].pb(u);
#define ingp(g,u,v,c) (g[u].pb({v,c});g[v].pb({u,c});)
#define mm(a,b) memset(a , b , sizeof a) 
#define ALL(a) a.begin(),a.end() 
#define SZ(n) ((ll) (n).size())
#define sfind(s,t) (s.find(t) != string::npos)

#define infll (ll)1e14
#define infi  (int)(1e9+1)
#define PI 3.14159265359 
#define mod (ll)(1e9+7)
#define eps  1e-6

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b,a%b); } 
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }

int n,k;
pii a[100001];
int dp[101][100001];

int solve(int i,int sum){
    if(sum > k)return -infll;
    if(i == n)return 0;
    int &r = dp[i][sum];
    if(r != -infll)return r;
    r = a[i].sd + solve(i+1,sum+a[i].fs);
    r = max(r,solve(i+1,sum));
    return r;
}


int32_t main(int32_t argc, char const *argv[]){
    FIN;

    fore(i,0,101){
        fore(j,0,100001){
            dp[i][j] = -infll;
        }
    }

    cin>>n>>k;
    fore(i,0,n)cin>>a[i].fs>>a[i].sd;
    cout<<solve(0,0);   

    return 0;
}



















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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int rem = n % k;
    print(min(rem, k - rem));

    return 0;
}


Measured memory_bytes: 256
// problem: "https://atcoder.jp/contests/abc126/tasks/abc126_c"

#include<iostream>
#include<iomanip>
#include<math.h>

using namespace std;

double ans(double n, double k)
{
    double a = 0.0;
    if(n-k+1.0>0.0)
        a = (n-k+1.0)/n;

    for(int i=1;i<min(n+1,k);i++)
        a = a + 1.0/n * (1.0/pow(2.0,ceil(log(k/i)/log(2))));

    return a;
}

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


    cout<<fixed;
    cout<<setprecision(14)<<ans(n,k);

    return 0;
}


Measured memory_bytes: 256