akhauriyash/Code-Regression huggingface dataset:
N,U,V = map(int, input().split())

"""
高橋くんの戦略
最も遠くに行けるなら言って往復
そのためには、遠くに行くときのポイントに青木より早く到達しなければいけない
青木くん -> 最も遠くに向かって進んでいく
"""

from collections import deque
# 木構造を作る
G = [[] for i in range(N)]
for i in range(N-1):
    # グラフに頂点を追加(距離があるときは,u,vの後に入れる)
    u,v = map(int,input().split())
    G[u-1].append((v-1))
    G[v-1].append((u-1))


## aoki
used_a = [-1] * N
used_a[V-1] = 0 
q = deque([V-1])
while len(q) > 0:
    a = q.popleft()
    Vs = G[a]
    for u in Vs:
        if used_a[u] == -1:
            q.append(u)
            used_a[u] = used_a[a] + 1

## takahashi
used_t = [-1] * N
used_t[U-1] = 0 
q = deque([U-1])
while len(q) > 0:
    a = q.popleft()
    Vs = G[a]
    for u in Vs: 
        if used_t[u] == -1:
            q.append(u)
            used_t[u] = used_t[a] + 1

ans = 0
# print("aoki",used_a)
# print("taka",used_t)
for a,t in zip(used_a,used_t):
    if a > t: # 高橋くんのほうが近い=先に達することができる
        ans = max(ans,a-1)
print(ans)

Measured memory_bytes: 29308
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long h,w;
  cin>>h>>w;
  long long c=0;

  if(h%2==0)
  {  if(w%2==0)
      c=c+h/2*(w/2)+h/2*(w/2);
        else
      c=c+h/2*(w/2)+h/2*(w/2+1);
  } else {if(w%2==0)
      c=c+(h/2+1)*(w/2)+(h/2)*(w/2);
  else
      c=c+(h/2+1)*(w/2+1)+(h/2)*(w/2);}
  if(h==1 || w==1) c=1;
  cout<<c;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

// 3 1 5 4 2
// 1 3 5 4 2
// 1 2 5 4 3
// 1 2 3 4 5

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> flag1(N + 1, 0);
    vector<int> flag2(N + 1, 0);
    flag1[1] = true;
    flag2[N] = true;
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        if (a > b) swap(a, b);
        if (a == 1) {
            flag1[b] = 1;
        }
        if (b == N) {
            flag2[a] = 1;
        }
    }
    bool flag = false;
    for (int i = 1; i <= N; i++) {
        if (flag1[i] && flag2[i]) {
            flag = true;
        }
    }
    if (flag) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
function Main(input) {
	input = input.trim();
	var N = parseInt(input, 10);
	var vec_p = [];
	var vec_e = [];
	var tmpN = N;
	var j = 0;
	var k = 0;
	var ans = 0;
	var checkTmpN = 1;
	var tmp;
	for (var i = 2; i <= Math.sqrt(N); i++){
		j = 0;
		same_number:
		while (true) {
			if (tmpN % i === 0){
				j ++;
				tmpN = tmpN / i ;
				checkTmpN *= i;
				if (j === 1) {
					vec_p.push(i);
					vec_e.push(1);
					k++;
				} else {
					vec_e[k - 1] ++;
				}
			} else {
				break same_number;
			}
		}
	}
	if (checkTmpN !== N) {
		vec_p.push(N / checkTmpN);
		vec_e.push(1);
	}
	for (var i = 0; i < vec_e.length; i++){
		tmp = Math.floor((Math.sqrt(1 + (8 * vec_e[i])) - 1) / 2);
		ans += tmp;
	}
 	console.log(ans);	
}   

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

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

int main() {
  int n;
  cin>>n;
  long long int a[n],even=0,odd=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]%2==0)
      even++;
    else odd++;
  }
  
  if(odd%2==0)
    cout<<"YES";
  else cout<<"NO";
  
    
}

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

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1


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


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


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


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


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


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


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


def mt(f):
    import time

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

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

    return wrap


@mt
def slv(N, A, X):
    ans = 0
    Y = [x - A for x in X]
    M = 2*N*50 + 1
    dp = [[0]*M for _ in range(N+1)]

    dp[0][N*50] = 1
    for i in range(1, N+1):
        for j in range(0, M):
            if j - Y[i-1] < 0 or j - Y[i-1] > 2*N*50:
                dp[i][j] = dp[i-1][j]
            else:
                dp[i][j] = dp[i-1][j] + dp[i-1][j-Y[i-1]]


    return dp[N][N*50] - 1


def main():
    N, A = read_int_n()
    X = read_int_n()
    print(slv(N, A, X))


if __name__ == '__main__':
    main()


Measured memory_bytes: 61676
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

using namespace std;
using P = pair<int, int>;
using T = tuple<long, long, long>;

long long MOD = 1000000007;
long long dp[100005][4];

int main() {
	long long N,K;
	cin >> N >> K;

	long long ans = 0;
	for (long long i = K+1; i <= N; ++i) {
		long long set = (N+1) / i;
		long long amari = (N+1) % i;
		long long hairuKosu = max(0LL,i - K);
		ans += set * hairuKosu + max(0LL,amari - (i - hairuKosu));
	}
	if (K == 0)ans -= N;
	cout << ans << endl;
}


Measured memory_bytes: 256
// AIZU - 0-1 Knapsack Problem
#include <bits/stdc++.h>
using namespace std;
int dp[1005][10005];
int main()
{
    int N, W;
    cin >> N >> W;
    int v[N+1], w[N+1];
    for(int i=1; i<=N; i++){
        cin >> v[i] >> w[i];
    }
    for(int i=1; i<=N; i++){
        for(int j=0; j<=W; j++){
            if(j < w[i]){
                dp[i][j] = dp[i-1][j];
            }
            else{
                dp[i][j] = max(v[i]+dp[i-1][j-w[i]], dp[i-1][j]);
            }
        }
    }
    /*
    cout << fixed << endl;
    for(int i=0; i<=N; i++){
        for(int j=0; j<=W; j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    */
    cout << dp[N][W] << endl;

    return 0;
}


Measured memory_bytes: 6996
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<pair<int, int>> p(n);
    for (int i = 0; i < n; i++) {
        int x, l;
        cin >> x >> l;
        p[i] = make_pair(x + l, x - l);
    }
    sort(p.begin(), p.end());

    int ans = n;
    for (int i = 0; i < n;) {
        auto now = p[i++];
        while (now.first > p[i].second && i < n) { i++, ans--; }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
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 mod(ll a){
  return (a % 1000000007);
}

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


int main(){
  string s; cin >> s;
  
  rep(i,3){
    if(s[i] == '1') s[i] = '9';
    else if(s[i] == '9') s[i] = '1';
  }
  
  cout << s << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

struct Point{
	double x,y;
};

int main(){
	
	int n, ans, count;
	Point seal[100];
	
	while(cin >> n){
		if(n == 0) break;
		
		for(int i = 0; i < n; i++){
			scanf("%lf,%lf",&seal[i].x,&seal[i].y);
		}
		
		ans = -1;
		for(double i = 0; i <= 10; i += 0.1){
			for(double j = 0; j <= 10; j +=0.1){
				count = 0;
				for(int s = 0; s < n; s++){
					if(sqrt((i-seal[s].x)*(i-seal[s].x)+(j-seal[s].y)*(j-seal[s].y)) < 1 ||
							fabs(sqrt((i-seal[s].x)*(i-seal[s].x)+(j-seal[s].y)*(j-seal[s].y)) - 1) < 0.00000001){
						count++;
					}
				}
				if(ans < count) ans = count;
			}
		}
	
		cout << ans << endl;
	
	}
	
	return 0;
}



Measured memory_bytes: 3156
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner $ = new Scanner(System.in);
		int S = $.nextInt(), Flag = 0;
		int[] s = {S / 100, S % 100};
		for (int i = 0; i < 2; i++){
			if (s[i] > 0 && s[i] < 13){
				Flag += (i + 1);
			}
		}
		if (Flag == 0){
			System.out.println("NA");
		}
		else if (Flag == 1){
			System.out.println("MMYY");
		}
		else if (Flag == 2){
			System.out.println("YYMM");
		}
		else if (Flag == 3){
			System.out.println("AMBIGUOUS");
		}
		/*
		1905 -> YYMM
		0112 -> AMBIGUOUS
		1700 -> NA
		*/
	}
}


Measured memory_bytes: 20948
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<vector>
#include<queue>
using namespace std;

int main(){
	int a;
	cin>>a;
	if(a==3||a==5||a==7){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
	int n;cin>>n;
	vll cnt(SIZE);
	ll tot=0;
	rep(i,n) {int a;cin>>a; cnt[a]++;}
	rep(i,SIZE) tot+=i*cnt[i];
	int q; cin>>q;
	rep(i,q){
		int b,c; cin>>b>>c;
		tot-=b*cnt[b];
		tot-=c*cnt[c];
		cnt[c]+=cnt[b];		
		cnt[b]=0;
		tot+=b*cnt[b];
		tot+=c*cnt[c];
		cout<<tot<<endl;
				
	}
	return 0;
}

Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int A;
    string B;
    cin>>A>>B;
    int c=B[0]-'0';
    int d=stoll(B.substr(2,2));
    int e=100*c+d;
    int ans=A*e;
    ans/=100;
    cout << ans << endl;

    



}


Measured memory_bytes: 3548
module Main where

import Control.Applicative
import Control.Monad
import Data.List
import Text.Printf

op :: Char -> Int -> Int -> Int
op '+' = (+)
op '-' = (-)

calc :: Int -> Int -> Int -> Int -> [Char] -> Int
calc a b c d [s, t, u]
    = (flip (op u) d) . (flip (op t) c) . (flip (op s) b) $ a

main :: IO ()
main = do
    [a, b, c, d] <- fmap (read . (:[])) <$> getLine :: IO [Int]
    let cs = sequence $ replicate 3 ['+', '-']
    let [s, t, u] = head $ filter ((== 7) . calc a b c d) cs
    printf "%d%c%d%c%d%c%d=7\n" a s b t c u d

Measured memory_bytes: 508
/*
 * Author       : YangDavid
 * Created Time : 2019年07月14日 星期日 20时37分25秒
 */

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

const int maxn = 222222;
int n, a[maxn], v[maxn], p;
map<int, int> cnt;

int main() {
    scanf("%d", &n);
    rep(i, n) scanf("%d", &a[i]), cnt[a[i]]++;
    for(auto g : cnt)
        v[++p] = g.first;
    if(p == 1) {
        if(v[1] == 0) puts("Yes");
        else puts("No");
        return 0;
    }
    if(n % 3 != 0) { puts("No"); return 0; }
    if(p == 2) {
        if(v[1] != 0 || cnt[v[1]] * 2 != cnt[v[2]]) puts("No");
        else puts("Yes");
        return 0;
    } else if(p == 3) {
        if((v[1] ^ v[2] ^ v[3]) != 0 || cnt[v[1]]!=cnt[v[2]] || cnt[v[2]]!=cnt[v[3]]) puts("No");
        else puts("Yes");
        return 0;
    } else if(p > 3) {
        puts("No");
        return 0;
    }
    assert(false);
    return 0;
}


Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double db;
typedef vector<ll> VI;
typedef vector<pair<ll,ll> > VII;
typedef map<ll,ll> mll;
typedef pair<ll,ll> pll;
//
#define M 1000000007
#define INF (ll)1e16
#define mp make_pair
#define pb emplace_back
#define F first
#define S second
#define itr iterator
#define error(x) cerr<<#x<<"-->>"<<x<<endl;
#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define IO1 freopen("input.txt", "r", stdin);
#define IO2 freopen("output.txt", "w", stdout); 
#define IO3 freopen("error.txt","w",stderr);

void time_elapsed(){
  cerr<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
}


//
int main()
{
    GO;
    // #ifndef ONLINE_JUDGE
    // IO1 IO2 IO3
    // #endif
    ll n,a,b;
    cin>>n>>a>>b;
    if((b-a)%2==0){
        cout<<(b-a)/2<<endl;
        return 0;
    }
    if(a-1<n-b){
        cout<<a+(b-a-1)/2<<endl;
        return 0;
    }
    cout<<n-b+1+(n-(a+n-b))/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#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, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    map<char, int> mp;
    cin >> n >> mp['A'] >> mp['B'] >> mp['C'];
    string s[n], ans = "";
    for(int i=0;i<n;i++) cin >> s[i];
    for(int i=0;i<n;i++){
    	string t = s[i];
    	if(mp[t[0]] == 0){
    		if(mp[t[1]] == 0){
    			cout << "No" << endl;
    			return 0;
    		}else{
    			mp[t[1]]--;
    			mp[t[0]]++;
    			ans += t[0];
    		}
    	}else{
    		if(mp[t[1]] == 0){
    			mp[t[0]]--;
    			mp[t[1]]++;
    			ans += t[1];
    		}else{
    			if(mp[t[0]] == 1 && mp[t[1]] == 1){
    				if(i == n - 1) ans += t[0];
    				else{
    					i++;
    					if(t == s[i]){
    						ans += t[0];
    						ans += t[1];
    					}else{
    						if(t[0] == s[i][0]) swap(t[0], t[1]), swap(s[i][0], s[i][1]);
    						else if(t[1] == s[i][0]) swap(s[i][0], s[i][1]);
    						else if(t[0] == s[i][1]) swap(t[0], t[1]);
    						mp[t[0]]--;
    						mp[s[i][0]]++;
    						ans += t[1];
    						ans += s[i][0];
    					}
    				}
    			}
    			else{
    				if(mp[t[0]] > mp[t[1]]){
    					mp[t[0]]--;
    					mp[t[1]]++;
    					ans += t[1];
    				}
    				else{
    					mp[t[1]]--;
    					mp[t[0]]++;
    					ans += t[0];
    				}
    			}
    		}
    	}
    }
    cout << "Yes" << endl;
    for(int i=0;i<n;i++){
    	cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 6876
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
// const int mod=998244353;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,m;
    cin>>n>>m;
    vvi g(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--,b--;
        g[a].eb(b);
    }
    int s,t;
    cin>>s>>t;
    s--,t--;
    vvi d(n,vi(3,-3));
    d[s][0]=0;
    queue<pi> q;
    q.push({s,0});
    while(!q.empty()){
        pi p=q.front();
        q.pop();
        int v=p.fi;
        int c=p.se;
        for(int u:g[p.fi]){
            int nc=(p.se+1)%3;
            if(d[u][nc]==-3){
                d[u][nc]=d[v][c]+1;
                q.push({u,nc});
            }
        }
    }
    cout<<d[t][0]/3<<endl;
}

Measured memory_bytes: 14212
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
double n;
double r=3.1415926;
int main()
{
	cout <<fixed<<setprecision(6);
	cin >>n;
	cout <<n*2.0*r;
	return 0;
} 

Measured memory_bytes: 3784
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int[] array = new int[5];
		for (int i = 0; i < array.length; i++) {
			array[i] = sc.nextInt();
		}
		int k = sc.nextInt();

		boolean flag = true;
		for (int i = 0; i < array.length; i++) {
			for (int j = i + 1; j < array.length; j++) {
				if (array[j] - array[i] > k) {
					System.out.println(":(");
					flag = false;
					break;
				}


			}if (!flag) {
				break;
			}
		}
		if (flag) {
			System.out.println("Yay!");
		}
	}

}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
string z;
int M,A,R,C,H;
int main(){
    while(cin>>z){
        if(z[0]=='M')M++;
        if(z[0]=='A')A++;
        if(z[0]=='R')R++;
        if(z[0]=='C')C++;
        if(z[0]=='H')H++;
    }
    long long int a=C+H,b=A+R,c=A*R,d=C*H;
    cout<<c*(M+a)+d*(M+b)+(M*a*b)<<endl;
}


Measured memory_bytes: 256
from sys import stdin
import numpy as np
import math

n = int(stdin.readline().rstrip())
lin = [stdin.readline().rstrip() for _ in range(n)]
m = int(stdin.readline().rstrip())
lim = [stdin.readline().rstrip() for _ in range(m)]

lis = list(set(lin))
ma = 0
for i in lis:
    ma = max(lin.count(i)-lim.count(i),ma)

print(ma)

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

using namespace std;

int main() {
    int l;
    int length = 5;
    //int input[length];
    vector<int> input(length);
    for(int i = 0;i < length && cin>>l;i++){
        input[i] = l;
    }
    string out;
    if(input[2] + input[4] > input[0] || input[2] - input[4] < 0 || input[3] + input[4] > input[1] || input[3] - input[4] < 0) out = "No";
    else out = "Yes";
    cout << out << endl;

    return 0;
}



Measured memory_bytes: 3216
import java.util.ArrayList;
        import java.util.List;
        import java.util.Scanner;
        import java.util.function.Consumer;

public class Main {
    private static final Scanner scanner = new Scanner(System.in);
    private static final Consumer<List<String>> consumer = solve();

    public static void main(String[] args) {
        consumer.accept(readInput());
    }

    private static List<String> readInput() {
        final List<String> lineList = new ArrayList<>();
        while (scanner.hasNextLine()) {
            lineList.add(scanner.nextLine());
        }
        return lineList;
    }

    private static Consumer<List<String>> solve() {
        return args -> {
            int k = args.get(0).length();
            long w = args.get(0).codePoints().filter(i -> (char) i == 'o').count();
            boolean cond = w + 15 - k >= 8;
            System.out.println(cond ? "YES" : "NO");
        };
    }

}


Measured memory_bytes: 28364
x1, y1, x2, y2 = map(int, input().split())

dx = x2 - x1
dy = y2 - y1

x3, y3 = x2 - dy, y2 + dx
x4, y4 = x1 - dy, y1 + dx
print(x3, y3, x4, y4)

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

int main(){
    string N;
    cin >> N;
    int sum = 0;
    for(int i=0;i<N.size();i++){
        sum += N[i]-'0';
        //cout << sum << endl;
    }
    //cout << N.size();
    //cout << sum;

    if(sum % 9 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
vector<ll> H;
//A2 B1として1e9/2回全探索、ぎりまにあう？
//最大値がどれかの探索でまいかい10^5だからむり
//降順sort、
//2番目との差
//おいついたら3番目との差
//おいついたら4番目･･･
//A3 B1
//100 80 70 40
//70 70 60 30
//50 60 50 20...

//グラフがあって、1個だけウエからA-B減らせる
//下からB全部へるって感じ
//priority_queueでだしてはいれて。カウントとる
//priorityがどんだけかかるかわかんない。間に合わないきがすんだよな
//ああ、だめそう
//2分探索?
//A3 B1
//100 80 70 40
//2番目に大きい値との差 20
//20/A=6+1=7
//2番目は80-7*B=73>0　NG
//3番目に大きい値との差30+10=40
//30/A+10/A=10+4=14
//3番目70-A*14=56>0
//4番目 60+40+30
//20+14+10=44
//40-44*B=-4<0
//44回おえた時点
//56 36 26 -4
//16 8 6 -4 //AでなくA-Bをひくのか

//100 80 70 40
//4番目 60+40+30
//30 20 15=65
//35 15 5 -25
//-25 -25 -25 -25
//いったん全部B引いて、A-Bを個別に判定、倒せるかどうか。
//攻撃回数で２分探索
bool beat(ll n, ll A, ll B, ll N){
  ll a=n;
  for(int i=0; i<N; i++){
    ll tmp=(H[i]-n*B);
    if(tmp<0) break;
    if(tmp%(A-B)>0) a--;
    tmp/=A-B;
    a-=tmp;
    if(a<0) return false;
  }
  return true;
}

int main(){
  ll N,A,B; cin>>N>>A>>B;
  ll ans=0, tmp;
  H.assign(N,0);
  for(int i=0; i<N; i++){
    ll h; cin>>h; H[i]=h;
  }
  sort(H.begin(), H.end(), greater<ll>());
  ll high=1e10, low=0, mid;
  while(high-low>1){
    mid=(high+low)/2;
    if(beat(mid,A,B,N))
      high=mid;
    else
      low=mid;
  }
  if(beat(low,A,B,N)) ans=low;
  else ans=high;
  cout<<ans<<endl;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 2e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int X, A, B; cin >> X >> A >> B;
    if(A >= B) cout << "delicious" << endl;
    else if(B - A >= X+1) cout << "dangerous" << endl;
    else cout << "safe" << endl;
}

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

    return 0;
}

Measured memory_bytes: 256
require 'prime'

N = gets.to_i

# N!の素因数分解を行う
h = Hash.new(0)
1.upto(N) do |i|
  (i.prime_division).each do |k|
    h[k[0]] += k[1]
  end
end
# p h

cnt = Hash.new(0)
h.each do |k, v|
  [2, 4, 14, 24, 74].each do |t| 
    cnt[t]+=1 if v >= t
  end
end

# @satanic0258さんのツイートを見て、これか～ってなった。丸写しかな。
ans = 0
ans += cnt[4] * ( cnt[4] - 1 ) / 2 * ( cnt[2] - 2 )
ans += cnt[14] * ( cnt[4] - 1 )
ans += cnt[24] * ( cnt[2] - 1 )
ans += cnt[74]

p ans

Measured memory_bytes: 2300
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC125cs
{
    class Program
    {
        static void Main(string[] args)
        {
            var abt = Console.ReadLine().Split(' ').Select(int.Parse);
            var a = abt.First();
            var b = abt.Skip(1).First();
            var t = abt.Last();
            var result = t / a * b;
            Console.WriteLine(result);
        }
    }
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int x, y; cin >> x >> y;
  if(x % y) cout << x << endl;
  else cout << -1 << endl;
}


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

#define REP(i, start, count) for (int i = (start); i < (int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<long long> vecll;
typedef vector<unsigned long long> vecull;

int K;
string S;

int main(void)
{
    cin >> K >> S;
    if (K >= S.size()) {
        cout << S << endl;
    }
    else {
        cout << S.substr(0, K) << "..." << endl;
    }
    return 0;
}

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

import collections
import sys
input=sys.stdin.readline

h,w,m=map(int,input().split())
items=[set() for _ in range(h+1)]
count_h=[0]*(h+1)
count_w=[0]*(w+1)
for _ in range(m):
    y,x=map(int,input().split())
    items[y].add(x)
    count_h[y]+=1
    count_w[x]+=1
count_num=collections.defaultdict(int)
for x in range(1,w+1):
    count_num[count_w[x]]+=1
count_cand=list(count_num.keys())
count_cand=sorted(count_cand,reverse=True)
ans=0
for y in range(1,h+1):
    value_y=count_h[y]
    count_tmp=collections.defaultdict(int)
    for x in items[y]:
        value_x=count_w[x]
        count_tmp[value_x]+=1
        ans=max(ans,value_y+value_x-1)
    for x in count_cand:
        if count_num[x]>count_tmp[x]:
            ans=max(ans,value_y+x)
            break
print(ans)

Measured memory_bytes: 158652
#include<bits/stdc++.h>
    using namespace std;
    
    #define ll long long
    #define pb push_back
    #define printV(v) for(int i=0;i<v._size();i++){cout << v[i]<< " ";} cout << endl
    #define printRev(v) for(int i=v._size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
    #define sortV(v) sort(v.begin(),v.end())
    #define revV(v) reverse(v.begin(),v.end())
    #define FOR(i,from,n) for(int i=from;i<n;i++)
    #define FOL(i,from,n) for(int i=from;i >= n;i--)

        ll a,b,c,d,e,f,g,n,m,k,t,x,h,w,p,q,y;
        string str = "";
        ll mod = 1e9 + 7;

        ll pow(ll base, ll q, ll mod){
            ll answer = 1;
            while(q > 0){
                if(q & 1LL)
                    answer = (answer * base) % mod;

                q = q >> 1LL;
                base = (base*base) % mod;
            }
            return answer % mod;
        }
        

        
        
        void solve(){
            string s1,s2;
            cin >> s1 >> s2;
            int cnt = 0;
            for(int i=0;i<s1.size();i++) if(s1[i] != s2[i]) cnt++;
            cout << cnt << endl;
        }



            



        int main(){
            ios_base::sync_with_stdio(false);

        
            

            int cases = 1;
            //cin >> cases;

            while(cases--) solve();
            return 0;

        }

Measured memory_bytes: 3868
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

template<typename Abel> struct BIT {
    vector<Abel> dat;
    BIT(int n, Abel UNITY_SUM = 0) : dat(n + 1, UNITY_SUM) { }  // [1, n]
    inline void add(int i, Abel x) {
        while (i < dat.size()) { dat[i] += x; i += i & -i; }
    }
    inline Abel sum(int i) {    // [1, i]
        Abel res = dat[0];
        while (i > 0) { res += dat[i]; i -= i & -i; }
        return res;
    }
    inline Abel sum(int a, int b) { return sum(b - 1) - sum(a - 1); }   // [a, b)
    Abel operator[](int i) { return sum(i, i + 1); }
    friend ostream& operator<<(ostream& os, BIT<Abel> &bit) {
        for (int i = 1; i < bit.dat.size(); i++) os << bit[i] << " ";
        return os;
    }
};

int main() {
    int N, Q; cin >> N >> Q;
    BIT<int> bit(N);
    for (int query = 0; query < Q; ++query) {
        int com, x, y; cin >> com >> x >> y;
        if (com == 0) bit.add(x, y);
        else cout << bit.sum(x, y + 1) << endl;
    }
    return 0;
}


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

int main() {
  string S;
  cin>>S;
  int count1=0;
  int count2=0;
  //条件1
  if(S.at(0)!='A'){
    cout<<"WA"<<endl;
    return 0;
  }
  //条件2
  for(int i=2;i<S.size()-1;i++){
    if(S.at(i)=='C')
      count1++;
  }
  if(count1!=1){
    cout<<"WA"<<endl;
    return 0;
  }  
  //条件3
  for(int j=0;j<S.size();j++){
    if(isupper(S.at(j)))
      count2++;
  }
  if(count2!=2){
    cout<<"WA"<<endl;
    return 0;    
  }

  cout<<"AC"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
typedef struct{
  int i;
  int p;
  int q;
  int r;
  int c;
}a;
int main(void){
  vector<a> hoge;
  a h;
  int n,P,Q,R,C;
  while(cin >> n,n){
    hoge.clear();
    for(int i=0;i<n;i++){
      cin >> h.i >> h.p >> h.q >> h.r;
      h.c=4*h.p+9*h.q+4*h.r;
      hoge.push_back(h);
    }
    cin >> P >> Q >> R >> C;
    int f=0;
    for(int i=0;i<hoge.size();i++){
      if(hoge[i].p<=P && hoge[i].q<=Q && hoge[i].r<=R && hoge[i].c<=C){
	cout << hoge[i].i << endl;
	f=1;
      } 
    }
    if(!f) cout << "NA" << endl;
  }
}


Measured memory_bytes: 1260
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	switch s {
	case "A":
		fmt.Println("T")
	case "T":
		fmt.Println("A")
	case "C":
		fmt.Println("G")
	case "G":
		fmt.Println("C")
	}
}


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

using namespace std;

int main(){
	
	while(1){
		int n,m;
		
		cin >> n >> m;
		
		if(n==0&&m==0)
			return 0;
		
		int a[n],b[m],c[n],d[m];
		
		for(int i=0;i<n;i++){
			cin >> a[i];
			c[i]=a[i];
		}
		for(int i=0;i<m;i++){
			cin >> b[i];
			d[i]=b[i];
		}
		
		int ans=100000;
		int c1,c2;
		int suma=0,sumb=0;
		
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				c[i]=b[j];
				d[j]=a[i];
				suma=0;sumb=0;
				for(int k=0;k<n;k++){
					suma+=c[k];
				}
				for(int k=0;k<m;k++){
					sumb+=d[k];
				}
				c[i]=a[i];d[j]=b[j];
				if(suma==sumb && ans > suma){
					ans=suma;
					c1=a[i];c2=b[j];
				}
			}
		}
		if(ans!=100000) cout << c1 << " " << c2 << endl;
		else cout << -1 << endl;
	}
}


Measured memory_bytes: 3004
#include<bits/stdc++.h>
using namespace std;
const int N=1<<11;
int a[N],f[N],dp[N];

int absi(int a)
{
	return a>0?a:-a;
}

int main()
{
	int n,x,y;
	scanf("%d%d%d",&n,&x,&y);
	for(int i=0;i<n;i++)
	{
		scanf("%d",a+i);
	}
	int ans=absi(a[n-1]-y);
	for(int i=n-1;i>=0;i--)
	{
		f[i]=dp[i]=absi(a[i]-a[n-1]);
		for(int j=i+1;j<n-1;j++)
		{
			f[i]=max(f[i],dp[j]);
			dp[i]=min(dp[i],f[j]);
		}
		ans=max(ans,dp[i]);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Arrays;

public class Main {

    private static Scanner sc;

    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
          int[] array = new int[3];

          array[0] = sc.nextInt();
          array[1] = sc.nextInt();
          array[2] = sc.nextInt();

          Arrays.sort(array);

          String ans = "No";

          if (array[0] + array[1] == array[2]) {
            ans = "Yes";
          }
            System.out.println(ans);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 8148
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long
 
const int N = 2000001;
 
int n, k, fact[N], inv[N], mod = 1e9 + 7;
string s;
 
int powlog(int a, int b){
    if(b == 0) return 1;
    int ret = powlog(a, b / 2);
    if(b % 2) return 1LL * ret * ret % mod * a % mod;
    return 1LL * ret * ret % mod;
}
int C(int n, int r){
    if(r > n) return 0;
    return 1LL * fact[n] * inv[n - r] % mod * inv[r] % mod;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    fact[0] = 1;
    for(int i = 1 ; i < N ; i++){
        fact[i] = 1LL * i * fact[i - 1] % mod;
    }
    inv[N - 1] = powlog(fact[N - 1], mod - 2);
    for(int i = N - 2 ; i >= 0 ; i--){
        inv[i] = 1LL * (i + 1) * inv[i + 1] % mod;
    }
    cin >> k >> s;
    n = s.size();
    int ans = 0;
    for(int i = 0 ; i <= k ; i++){
        ans = (ans + 1LL * powlog(25, k - i) * powlog(26, i) % mod * C(n - 1 + k - i, n - 1)) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 19876
<?php
  $N = trim(fgets(STDIN));
  $input = trim(fgets(STDIN));
  $input = str_replace(array("\r\n", "\r", "\n"), "", $input);
  $array = explode(" ", $input);
  rsort($array);
  for($i = 0; $i < $N; $i++){
    if($i % 2 == 1){
      $bob[] = $array[$i];
    }else{
      $alice[] = $array[$i];
    }
  }

  $diff = array_sum($alice) - array_sum($bob);
  echo $diff;
?>

Measured memory_bytes: 3576
n, t = list(map(int,input().split()))
list1 = []
list2 = []
for i in range(0,n):
  list1.append(list(map(int, input().split())))

for i in list1:
  if int(i[1]) <= t:
    list2.append(i)

if(list2):
  list2.sort()
  print(list2[0][0])
else:
  print("TLE")

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.PriorityQueue;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] nm = br.readLine().split(" ");
		int n = Integer.parseInt(nm[0]), m = Integer.parseInt(nm[1]);
		String[] line = br.readLine().split(" ");
		PriorityQueue<Integer> prices = new PriorityQueue<>(n, Collections.reverseOrder());
		for (int i = 0; i < n; i++) {
			prices.add(Integer.parseInt(line[i]));
		}
		for (int i = 0; i < m; i++) {
			prices.offer(prices.poll()/2);
		}
		long sum = 0;
		for (int i = 0; i < n; i++) {
			sum+= prices.poll();
		}
		System.out.println(sum);
		br.close();
	}

}


Measured memory_bytes: 48760
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
constexpr ll mod = 998244353;
#define endl '\n'


template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char c) {
  return string(1,c);
}

string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (int i = int(N)-1; i >= 0; --i) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef COMPETITIVE_PROGRAMMING_LOCAL
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) if(0){}
#endif

 
ll pow_mod(ll a, int e) {
  ll ret = 1LL;
  while (e > 0) {
    if (e & 1) ret = (ret * a) % mod;
    a = (a*a) % mod;
    e >>= 1; // e /= 2
  }
  return ret;
}   

#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ar array
 
const int mxN=5e5;

ll iv[mxN+1], f1[mxN+1], f2[mxN+1];
 
ll nck(int n, int k) {
  return f1[n]*f2[k]%mod*f2[n-k]%mod;
}
 
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  iv[1]=1;
  for(int i=2; i<=mxN; ++i)
    iv[i]=mod-mod/i*iv[mod%i]%mod;
  f1[0]=f2[0]=1;
  for(int i=1; i<=mxN; ++i) {
    f1[i]=f1[i-1]*i%mod;
    f2[i]=f2[i-1]*iv[i]%mod;
  }


  ll N,M,K;
  cin >> N >> M >> K;
  ++K;

  ll ans = 0;
  for (int i = 0; i < K; ++i) {
    ll val = M*pow_mod(M-1, N-1-i);
    val %= mod;
    val *= nck(N-1,i);
    val %= mod;
    ans += val;
    ans %= mod;
  }


  cout << ans << endl;

}


Measured memory_bytes: 15344
#include <stdio.h>

int main(void) {
	int a,b,n,i;
	int sa,sb;

	while(1){

		sa = 0;
		sb = 0;

		scanf("%d",&n);
		if(n <= 0){
			return 0;
		}

		for(i = 0;i < n;i++){
			scanf("%d %d",&a,&b);
			if(a == b){
				sa += a;
				sb += b;
			}else if(a < b){
				sb += a + b;
			}else{
				sa += a + b;
			}
		}

		printf("%d %d\n",sa,sb);

	}


	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string>
#define int long long
#define P pair<int,int>
#define V vector<int>
#define rep(i,n) for(int i=0;i<n;++i)
#define vsort(vec) sort(vec.begin(),vec.end())
#define end system("PAUSE");return 0
using namespace std;
signed main() {
	int a[3];
	for (int i = 0; i < 3; i++)cin >> a[i];
	sort(a, a + 3);
	int b = a[2] * 3;
	int c = a[0] + a[1] + a[2];
	if ((b - c) % 2 == 0)cout << (b - c) / 2 << endl;
	else cout << (b - c + 3) / 2 << endl;
	end;
}


Measured memory_bytes: 504
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;

ll N;
ll A[200010], B[200010];
ll S, mi = 1ll<<60;
bool fl = true;

int main()
{
  std::cin >> N;

  rep( i, N )
  {
    std::cin >> A[i] >> B[i];

    S += A[i];

    if( A[i] > B[i] )
      chmin( mi, B[i] );

    fl &= A[i]==B[i];
  }

  std::cout << (fl ? 0 : S-mi) << std::endl;

  return 0;
}

Measured memory_bytes: 1144
n = int(input())
a, b, c = [], [], []
for i in range(n):
    ab = list(map(int, input().split()))
    a.append(ab[0])
    b.append(ab[1])
    if(ab[0] > ab[1]):
        c.append(ab[1])
if(len(c) == 0):
    print(0)
else:
    print(sum(a) - min(c))

Measured memory_bytes: 5108
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#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 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b;cin >> a >> b;
  if(a<10&&b<10){
    cout << a * b << endl;
  }else{
    cout << -1 << endl;
  }
}

Measured memory_bytes: 256
import heapq
n, m = map(int, input().split())
aa = list(map(int, input().split()))
h = []
for a in aa:
    heapq.heappush(h, -a)
for mm in range(m):
    heapq.heappush(h, heapq.heappop(h) / 2)

s = sum([int(-v) for v in h])
print(s)


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

using namespace std;

#define FOR(i, a, b) for (int(i) = a; (i) <= (b); ++(i))
#define rep(i, n) FOR(i, 0, n-1 )
#define all(c) (c).begin(), (c).end()
#define mod 1000000007LL
#define INF 123456789012345
#define int long long

int dp[505][505];

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

  rep(i,m)
  {
    int l,r;cin>>l>>r;
    l--,r--;
    dp[l][r]++;
  }

  rep(i,n)FOR(j,i,n)
  {
    if(j==0)continue;
    dp[i][j]+=dp[i][j-1];
  }

  for(int j=n-1;j>=0;j--)for(int i=j;i>=0;i--)
  {
    if(i==n-1) continue;
    dp[i][j] += dp[i+1][j];
  }


  rep(i,q)
  {
    int p,q;cin>>p>>q;
    p--,q--;
    cout << dp[p][q] << endl;
  }
     
}


Measured memory_bytes: 2944
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
const int MOD = 1000000007;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, m; cin >> n >> m;
  vector<int> a(n), b(m);
  REP(i, n) cin >> a[i];
  sort(ALL(a));
  a.erase(unique(ALL(a)), a.end());
  reverse(ALL(a));
  REP(i, m) cin >> b[i];
  sort(ALL(b));
  b.erase(unique(ALL(b)), b.end());
  reverse(ALL(b));
  if (a.size() != n || b.size() != m) {
    cout << 0 << '\n';
    return 0;
  }
  long long ans = 1;
  int gyo = 0, retu = 0;
  for (int now = n*m; now >= 1; --now) {
    if (gyo < n && a[gyo] == now) {
      ++gyo;
      if (retu < m && b[retu] == now) ++retu;
      else (ans *= retu) %= MOD;
    } else if (retu < m && b[retu] == now) {
      ++retu;
      (ans *= gyo) %= MOD;
    } else (ans *= (gyo*retu-(n*m-now))%MOD) %= MOD;
  }
  cout << ans << '\n';
  return 0;
}


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

#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;



int main() {
	long long int N,K;cin>>N>>K;
	long long int ans=0;
	if (K % 2 == 0) {
		long long int nans=0;
		long long int x=(N+(K/2))/K;
		nans=x*x*x;

		long long int yans=0;
		long long int y=N/K;
		yans=y*y*y;

		ans=nans+yans;
	}
	else {
		long long int yans = 0;
		long long int y = N / K;
		yans = y*y*y;

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

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define out(x) cout << x << '\n'
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
//---------------------------------------------------------------------------------------------------
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
//---------------------------------------------------------------------------------------------------
lli a = 0, b = 0, c = 0, h = 0, L, R, d, n = 0, w = 0, ans = 0, count = 0;
string s = "", t = "";
vector<pair<lli, lli>> pr;
map<lli, lli> mp;
set<lli> st;

//---------------------------------------------------------------------------------------------------
lli solve()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> L >> R >> d;
  lli count = 0;
  repe(i, L, R)
  {
    if (i % d == 0)
    {
      count++;
    }
  }
  return count;
}

//---------------------------------------------------------------------------------------------------
signed main()
{
  out(solve());
  // if (solve() > 0)
  // {
  //   cout << "Yes"
  //        << "\n";
  // }
  // else
  // {
  //   cout << "No"
  //        << "\n";
  // }
}

Measured memory_bytes: 3652