akhauriyash/Code-Regression huggingface dataset:
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=1000*1007;
const ll inf=1e15;

int n;
ll l[nax];
ll r[nax];

multiset <ll> al, ar;
multiset <ll> bl, br;

vector <pll> eve;

ll wyn;

pll pre[nax];
pll suf[nax];

pll lo(pll a, pll b)
{
	return {max(a.first, b.first), min(a.second, b.second)};
}

ll daja()
{
	if (al.empty())
		return -inf;
	auto it=al.end();
	it--;
	auto jt=ar.begin();
	return max(0LL, (*jt)-(*it)+1);
}

ll dajb()
{
	if (bl.empty())
		return -inf;
	auto it=bl.end();
	it--;
	auto jt=br.begin();
	return max(0LL, (*jt)-(*it)+1);
}

int main()
{
	scanf("%d", &n);
	for (int i=1; i<=n; i++)
	{
		scanf("%lld%lld", &l[i], &r[i]);
		eve.push_back({l[i], i});
		eve.push_back({r[i]+1, -i});
		al.insert(l[i]);
		ar.insert(r[i]);
	}
	sort(eve.begin(), eve.end());
	for (auto i : eve)
	{
		int x=abs(i.second);
		if (i.second>0)
		{
			al.erase(al.find(l[x]));
			ar.erase(ar.find(r[x]));
			bl.insert(l[x]);
			br.insert(r[x]);
		}
		else
		{
			bl.erase(bl.find(l[x]));
			br.erase(br.find(r[x]));
			al.insert(l[x]);
			ar.insert(r[x]);
		}
		wyn=max(wyn, daja()+dajb());
	}
	pre[0]=suf[n+1]={-inf, inf};
	for (int i=1; i<=n; i++)
		pre[i]=lo(pre[i-1], {l[i], r[i]});
	for (int i=n; i; i--)
		suf[i]=lo(suf[i+1], {l[i], r[i]});
	for (int i=1; i<=n; i++)
	{
		pll w=lo(pre[i-1], suf[i+1]);
		wyn=max(wyn, max(0LL, w.second-w.first+1)+r[i]-l[i]+1);
	}
	
	printf("%lld\n", wyn);
	return 0;
}


Measured memory_bytes: 23404
# gets.split.map(&:to_i)
# readlines.map(&:chomp!).map { |e| e.split.map(&:to_i) }
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i
count = 0

(0..a).each do |i|
  (0..b).each do |j|
    (0..c).each do |k|
      if(500 * i + 100 * j + 50 * k == x)
        count += 1
      end
    end
  end
end

puts count

Measured memory_bytes: 14284
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] x=new int[n];
		long sum = 0;
		for(int i=0;i<n;i++){
			x[i]=sc.nextInt();
		}
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				sum+=x[i]*x[j];
			}
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 22612
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <bitset>
#include <stack>

using namespace std;

void boostIO() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

const int maxn = 1e2 + 5;

string a[maxn];

int main() {
    boostIO();

    int n, l;

    cin >> n >> l;
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a, a + n);
    for (int i = 0; i < n; ++i) cout << a[i];
    cout << '\n';

    return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int n,k;
	cin>>n>>k;
	int i;
	int a[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(i=k;i<n;i++)
	{
		if(a[i-k]>=a[i])
		cout<<"No"<<endl;
		else
		cout<<"Yes"<<endl;
		//ans=rans;
	}
	return 0;
}



Measured memory_bytes: 4420
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
  ll x;
  cin>>x;
  if(x==22)cout<<"Christmas Eve Eve Eve"<<endl;
  if(x==23)cout<<"Christmas Eve Eve"<<endl;
  if(x==24)cout<<"Christmas Eve"<<endl;
  if(x==25)cout<<"Christmas"<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INT()

    print(ceil(N/2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38768
//It doesn't matter as long as you rise to the top - Katsuki Bakugo
#include<bits/stdc++.h>
using namespace std;
     
     
#define Fast_as_duck ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back 
#define forn(i,st,n) for(int i = st; i < n ; i++)
#define rev(i,st,n) for(int i = st; i >= n ; i--)
#define ss second
#define ff first
#define ll long long 

typedef pair <int , int> pii;

const int N = 1e5 + 10 , mod =  1000000007;

void solve(){

    int n , x  , t;
    cin >> n >> x >> t;

    int temp = (n-1) / x;
    temp++;

    cout << temp * t;

    
    

    
    
        


}

int main(){
    Fast_as_duck;

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
*/
    int t = 1; 
    
    // cin >> t;
    

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




    return 0;
}
      
       


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

#define REP(i, a, n) for (int i = a; i < n; ++i)

const int HMAX = 20;


int h;
int n;

struct Pos {
	int i, j, k;
};

struct Block {
	vector<Pos> ps;
	static Block input() {
		Block ret;
		REP(i, 0, 2) {
			REP(j, 0, 2) {
				string s;
				cin >> s;
				REP(k, 0, 2) {
					if (s[k] == '#') {
						Pos p{i, j, k};
						ret.ps.push_back(p);
					}
				}
			}
		}
		return ret;
	}
};


struct Field {
	int f[HMAX][2][2] = {};
	static Field input() {
		Field ret;
		REP(i, 0, h) {
			REP(j, 0, 2) {
				string s;
				cin >> s;
				REP(k, 0, 2) {
					ret.f[i][j][k] = s[k] == '#';
				}
			}
		}
		return ret;
	}

	int flush() {
		int cnt = 0;
		int i = 0;

		while (i < HMAX) {
			bool ok = true;
			REP(j, 0, 2) {
				REP(k, 0, 2) {
					if (!f[i][j][k]) {
						ok = false;
						break;
					}
				}
			}

			if (ok) {
				REP(p, i, HMAX - 1) {
					REP(j, 0, 2) {
						REP(k, 0, 2) {
							f[p][j][k] = f[p + 1][j][k];
						}
					}
				}
				++cnt;
			} else {
				++i;
			}
		}
		return cnt;
	}

	int drop(Block b) {
		for (Pos& p : b.ps) {
			p.i += HMAX - 3;
		}

		while (true) {
			for (Pos& p : b.ps) {
				if (p.i == 0) goto end;
			}

			bool coll = false;
			for (Pos& p : b.ps) {
				if (f[p.i - 1][p.j][p.k]) {
					coll = true;
				}
			}
			if (coll) break;

			for (Pos& p : b.ps) {
				--p.i;
			}
		}

	end:
		for (Pos& p : b.ps) {
			f[p.i][p.j][p.k] = 1;
		}
		return flush();
	}
};

Field f;
vector<Block> bs;

int rec(int p, Field field) {
	if (p == n) return 0;

	int mx = 0;
	REP(j, -1, 2) {
		REP(k, -1, 2) {
			Field curr = field;
			Block b = bs[p];
			bool valid = true;
			for (Pos& p : b.ps) {
				p.j += j;
				p.k += k;
				if (p.j < 0) valid = false;
				if (p.j >= 2) valid = false;
				if (p.k < 0) valid = false;
				if (p.k >= 2) valid = false;
			}

			if (valid) {
				int res = curr.drop(b);
				mx = max(mx, rec(p + 1, curr) + res);
			}
		}
	}
	return mx;
}

int cat() {
	return rec(0, f);
}

int sub() {
	f = Field::input();
	bs.clear();
	REP(z, 0, n) {
		bs.push_back(Block::input());
	}
	return cat();
}

int main() {
	while (cin >> h >> n, h) {
		cout << sub() << endl;
	}
}


Measured memory_bytes: 3204
<?php
list($A, $B, $C, $K) = array_map(function ($n) {
    return (int)$n;
}, explode(' ', fgets(STDIN)));

if ($K <= $A) {
    echo $K;
    return;
}

if ($K <= $A + $B) {
    echo $A;
    return;
}
echo $A - ($K - ($A + $B));

Measured memory_bytes: 16092
r, g, b, n = map(int, input().split())

nr = n // r
ans = 0

for i in range(nr + 1):
	ng = (n - i * r) // g
	for j in range(ng + 1):
		if (n - (i * r + j * g)) % b == 0:
			ans += 1

print(ans)

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        String line = scan.nextLine();
        String[] HW = line.split(" ");
        int H = Integer.parseInt(HW[0]);
        int W = Integer.parseInt(HW[1]);
        
        line = scan.nextLine();
        String[] hw = line.split(" ");
        int h = Integer.parseInt(hw[0]);
        int w = Integer.parseInt(hw[1]);
        
        int num = H * W - W * h - H * w + h * w;
        System.out.println(num);
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i<n; i++)
#define REPR(i, n) for(int i = n; n>=0; i--)
#define FOR(i, m, n) for(int i = m, i < n; i++)

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    /*example standard input and output(cout << "\n")
	int x;
	cin >> x;
	cout << x * x * x << "\n";
    */

    string S, T;
    cin >> S;
    cin >> T;

    for(int i = 0; i < S.size(); i++){ 
        if(S == T){
            cout << "Yes" << "\n";
            return 0;
        }
        S = S.back() + S.substr(0, S.size()-1);
    }

    cout << "No" << "\n";
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;

int main() {
    string S;
    cin >> S;
    for (auto i = 0; i < S.size(); i ++) {
        cout << "x";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;

int main()
{
  int n;
  for(;cin>>n,n;)
    {
      int w,h;
      cin>>w>>h;
      int map[w][h];
      memset(map,0,sizeof(map));
      for(int i=0;i<n;i++)
	{
	  int x,y;
	  cin>>x>>y;
	  map[x-1][y-1]=1;
	}
      int s,t;
      cin>>s>>t;
      int ans=0;
      /*
      for(int i=0;i<w;i++,cout<<endl)
	for(int j=0;j<h;j++)
	  cout<<map[i][j];
      */

      for(int i=0;i+s<=w;i++)
	for(int j=0;j+t<=h;j++)
	  {
	    //    cout<<"w:"<<w<<endl;
	    //	    cout<<"i+s:"<<i+s<<endl;


	    //	    cout<<"start:"<<i<<" "<<j<<endl;
	    int cnt=0;
	    for(int ii=i;ii-i<s;ii++)
	      for(int jj=j;jj-j<t;jj++)
		{ 
		  //	  cout<<""<<ii<<" "<<jj<<endl;

		  if(map[ii][jj]==1)
		    cnt++;
		}
	    //	    cout<<"count ans="<<cnt<<" "<<ans<<endl;
	    ans=max(cnt,ans);

	  }
      cout<<ans<<endl;
      
    }
}

Measured memory_bytes: 1200
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define mm(arr) memset(arr, 0, sizeof(arr))
#define scanArray(a,n) for(int i = 0; i < n; i++){cin >> a[i];}
#define pb push_back
#define PI 3.141592653589793
#define MOD 1000000007
using namespace std;
int main(){
    FAST
    ll n; cin >> n;
    string s[n];
    vector<string>vec;
    for(ll i=0;i<n;i++){
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
        vec.pb(s[i]);
    }
    map<string,ll>mpp;
    sort(vec.begin(),vec.end());
    ll cnt=0;
    ll j=1;
    map<string,ll>mpp2;
    for(ll i=0;i<n;i++){
        mpp2[s[i]]=1;
    }
    for(ll i=0;i<n;i++){
        mpp[s[i]]++;
        if(mpp[s[i]]>1){
            cnt+=mpp2[s[i]];
            mpp2[s[i]]++;
        }
    }
    cout << cnt << endl;






    return 0;
}


Measured memory_bytes: 24992
import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.IArray             as IA
import qualified Data.Array.IO                 as AI
import qualified Data.Array.MArray             as MA
import qualified Data.Array.ST                 as STA
import qualified Data.Array.Unboxed            as AU
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Graph                    as G
import           Data.Int
import qualified Data.IntMap                   as IM
import qualified Data.IntSet                   as IS
import           Data.List
import qualified Data.Map.Strict               as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence                 as SQ
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Tree                     as T
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO Int
readInt = fst . fromJust . BS.readInt <$> BS.getLine

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

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

readInteger :: IO Integer
readInteger = fst . fromJust . BS.readInteger <$> BS.getLine

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegerLists :: Int -> IO [[Integer]]
readIntegerLists n = replicateM n readIntegers

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

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

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

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putList :: Show a => [a] -> IO ()
putList [n     ] = print n
putList (n : ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n     ] = putStrLn n
putStrList (n : ns) = do
  putStr n
  putStr " "
  putStrList ns

yesNoUpper b | b         = putStrLn "YES"
             | otherwise = putStrLn "NO"

yesNo b | b         = putStrLn "Yes"
        | otherwise = putStrLn "No"

divCeiling x n | b == 0    = a
               | otherwise = a + 1
  where (a, b) = x `divMod` n

main = do
  n  <- readInt
  as <- map toPair <$> readIntLists n
  yesNo $ snd $ solve as

solve as = foldl (\(a, b) (aa, bb) -> (a + aa, b && (a + aa <= bb)))
                 (0, True)
                 ass
  where ass = sortBy (\(a, b) (aa, bb) -> b `compare` bb) as


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

using namespace std;

const int N = 1010;
const int M = N * N;

int Hash[N][N];
int Vis[M];
int Dp[M];
vector <int> Adj[M];

bool DFS(int x)
{
    if(Vis[x] == 2) return false;
    if(Vis[x] == 1) return true;

    Vis[x] = 2;

    for(int y : Adj[x])
        if(!DFS(y))
            return false;

    Vis[x] = 1;

    return true;
}

int Rec(int x)
{
    if(Dp[x] + 1)   return Dp[x];

    int Res = 1;

    for(int y : Adj[x]) Res = max( Res, 1 + Rec(y));

    return Dp[x] = Res;
}

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

    int Nodes = 0;

    for(int i = 1; i <= n; i++)
        for(int j = i + 1; j <= n; j++)
            Hash[i][j] = ++Nodes;

    for(int i = 1; i <= n; i++)
    {
        int Last = 0;

        for(int j = 2; j <= n; j++)
        {
            int x = i, y;   scanf("%d", &y);

            if(x > y)   swap( x, y);

            int Cur = Hash[x][y];

            if(Last)    Adj[Last].push_back(Cur);

            Last = Cur;
        }
    }

    for(int x = 1; x <= Nodes; x++)
        if(!Vis[x])
            if(!DFS(x))
                return 0 * puts("-1");

    int Ans = 0;

    memset( Dp, -1, sizeof(Dp));

    for(int x = 1; x <= Nodes; x++) Ans = max( Ans, Rec(x));

    cout << Ans << endl;
}


Measured memory_bytes: 51712
cnt = 0
m = 0
g = []

def insertion_sort(a, n, g):
# cnt+=1 のときにローカルスコープの外を見にいくようにするため
    global cnt
    for i in range(g, n):
        v = a[i]
        k = i - g
        while k >= 0 and a[k] > v:
            a[k+g] = a[k]
            k -= g
            cnt += 1
        a[k+g] = v

def shell_sort(a, n):
    global m, g
    h = 1
    while h <= n:
        g.append(h)
        h = h * 3 + 1
    g.reverse()
    m = len(g)
    for i in range(m):
        insertion_sort(a, n, g[i])

n = int(input())
a = [int(input()) for i in range(n)]
shell_sort(a, n)
print(m)
print(*g)
print(cnt)
for i in a:
    print(i)


Measured memory_bytes: 45512
#include <iostream>

using namespace std;

int main () {
	int n, najv = 0, sum = 0;
	cin >> n;
	
	for (int i=0; i<n; i++){
		int x;
		cin >> x;
		sum += x;
		najv = max(najv, x);
	}
	if (najv < sum-najv) cout << "Yes";
	else cout << "No";
return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a.begin(), a.end());
	cout << a[a.size() - 1] - a[0] << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	int k, s;
	cin >> k >> s;
	int res = 0;
	REP(x, k + 1) REP(y, k + 1) if (x + y <= s && x + y >= s - k) ++res;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 384
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

N=ri()
T,A=rl()
H=rl()
dif = INF
ans = 0
for i in range(N):
    res = abs(A - (T-H[i]*0.006))
    if dif > res:
        dif = res
        ans = i+1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

//------ 自分を天才だと信じる ------

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

    cin>>n;
    rrep(i,1,n+1){
        s=to_string(i);
        cnt=Size(s);
        if(cnt%2==1)ans++;
    }
    Cout(ans);
    return 0;
}


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

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

    if(a <= 9 && b <= 9) {
        cout << a*b;
    }
    else {
        cout << -1;
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
num = []


for i in range(n):
    a, b = map(int, input().split())
    num.append((a, b))

a = []
b = []
for i in range(n):
    a.append(num[i][0])
    b.append(num[i][1])

a.sort()
b.sort()

if n % 2 == 0:
    right = b[n//2] + b[n//2-1]
    left = a[n//2] + a[n//2-1]
    print(right - left + 1)

else:
    right = b[n//2]
    left = a[n//2]
    print(right - left + 1)


Measured memory_bytes: 115280
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
int main() {
	ll a, b;
	cin >> a >> b;
	cout << (1 + b - a) * (b - a) / 2 - b << endl;
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<algorithm>
using namespace std;
struct que{
	int t;
	int a;
	int wz;
	bool operator<(que b) const
	{
		return t<b.t;
	}
};
que q[262144];
int ans[131072];
int main()
{
	//freopen("c.in","r",stdin);
	//freopen("c.out","w",stdout);
	int x;
	scanf("%d",&x);
	int mn=0,mx=x,inc=0;
	bool isinc=false;
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&q[i].t);
		q[i].a=-1;
	}
	int m;
	scanf("%d",&m);
	for(int i=0;i<m;i++)
	{
		scanf("%d%d",&q[i+n].t,&q[i+n].a);
		q[i+n].wz=i;
	}
	sort(q,q+n+m);
	int lt=0;
	for(int i=0;i<n+m;i++)
	{
		int dt=q[i].t-lt;
		if(isinc)
		{
			mn+=dt;
			mx+=dt;
			inc+=dt;
			if(mn>x)
			{
				mn=x;
			}
			if(mx>x)
			{
				mx=x;
			}
		}
		else
		{
			mn-=dt;
			mx-=dt;
			inc-=dt;
			if(mn<0)
			{
				mn=0;
			}
			if(mx<0)
			{
				mx=0;
			}
		}
		lt+=dt;
		if(q[i].a<0)
		{
			isinc^=1;
		}
		else
		{
			int answer=q[i].a+inc;
			if(answer<mn)
			{
				answer=mn;
			}
			if(answer>mx)
			{
				answer=mx;
			}
			ans[q[i].wz]=answer;
		}
	}
	for(int i=0;i<m;i++)
	{
		printf("%d\n",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <cmath>
using namespace std;
double pi(void)
{
	return atan(1.0) * 4;
}
double deg2rad(double degree)
{
	return degree/180*pi();
}

int main(void)
{
	double a, b, c;
	double r, s, length, h;

	cin >> a >> b >> r;
	r = deg2rad(r);
	h = b * sin(r);
	s = a * h / 2;
	c = sqrt(a*a + b*b - 2*a*b*cos(r));
	length = a + b + c;
	cout << fixed << s << " " << length << " " << h << endl;
	return 0;
}

Measured memory_bytes: 1288
S = input()
flag = False
is_dream, is_erase = False, False

while len(S) >= 5:
    is_dream = S[:5] == 'dream'
    is_erase = S[:5] == 'erase'

    if len(S) == 5:
        if is_dream or is_erase:
            flag = True
        else:
            flag = False
        break

    if len(S) == 6:
        if is_erase and S[-1] == 'r':
            flag = True
        else:
            flag = False
        break

    if len(S) == 7:
        if is_dream and S[-2:] == 'er':
            flag = True
        else:
            flag = False
        break


    if len(S) in [8, 9]:
        flag = False
        break

    if len(S) >= 10:
        S1 = S[5:10]

        if S1 in ['dream', 'erase']:
            S = S[5:]
            continue
        elif is_erase:
            if S[5] == 'r':
                S = S[6:]
                continue
        elif is_dream:
            if S[5:7] == 'er':
                S = S[7:]
                continue
        else:
            flag = False
            break
    flag = False
    break

if flag:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3316
#include <iostream>

using namespace std;

int N;
long long int a[100005];

int main(void) {

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

	int X, Y, Z;
	X = 0; Y = 0; Z = 0;

	for (int i = 1; i <= N; i++) {
		if (a[i] % 4 == 0) { X++; }
		else if (a[i] % 2 == 0) { Y++; }
		else { Z++; }
	}

	if ((Y == 0 && X+1 >= Z) || (Y != 0 && X >= Z)) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }

	//system("pause");
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll MOD =  998244353;
ll fact[300001];
ll inv[300001];
ll pow1(ll n, ll p){
    ll res, cur;
    res = 1;
    cur = n;
    while(p){
        if(p & 1){
            res *= cur;
            res %= MOD;
        }
        p /= 2;
        cur *= cur;
        cur %= MOD;
    }
    return res;
}

void init(){
    inv[0] = 1;
    fact[0] = 1;
    for(int i = 1;i < 300001;i++){
        fact[i] = fact[i-1] * i % MOD;
        inv[i] = pow1(fact[i], MOD - 2);
    }
}

ll cnk(ll n, ll k){
  if(k > n)return 0;
  return fact[n] * inv[k] % MOD * inv[n-k] % MOD;
}

int main()
{
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  init();
  ll res = 0;
  long long n, a, b, k;
  cin >> n >> a >> b >> k;
  for(int i = 0;i <= n;i++){
    if(a * i > k)break;
    if((k - a * i) % b != 0)continue;
    res = (res + cnk(n, i) * cnk(n, (k - a * i) / b) % MOD) % MOD;
  }
  cout << res;
}


Measured memory_bytes: 4992
#include <iostream>
#include <iomanip> //setprecision()
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
using ll = long long;
using namespace std;

double Mcos(double k){return cos(k*atan(1.0)*4/180);}

void monmo(){
    
}

int main() {
    ll n=0;
    string s,t;
    cin>>s>>t;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i])n++;
    }
    cout<<n;
}


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

using namespace std;

int c[13];
int d[13][13];
long long cur[13];

int main() {

    int n,m,k;
    cin >> n >> m >> k;

    for (int i = 0; i < n; ++i) {
        cin >> c[i];
        for (int j = 0; j < m; ++j) 
            cin >> d[i][j];
    }

    int ans = 1e9;
    for (int i = 0; i < (1 << n); ++i) {
        memset(cur, 0, sizeof cur);
        int total = 0;
        for (int j = 0; j < n; ++j) {
            if(i & (1 << j)) {
                for (int l = 0; l < m; ++l) 
                    cur[l] += d[j][l];
                total += c[j];
            }
        }
        
        bool flag = 1;
        for (int j = 0; j < m; ++j) {
            flag &= cur[j] >= k;
        }

        if(flag) ans = min(ans, total);

    }
    if(ans == 1e9) cout << "-1\n";
    else cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3636
using System;
public class f{
    public static void Main(){
        int []mountain = new int[10];
        for(int i=0;i<10;i++){
            mountain[i] = int.Parse(Console.ReadLine());
        }
        Array.Sort(mountain);
        for (int i=9;i>6;i--){
            Console.WriteLine(mountain[i]);
        }
        return ;
    }
}


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

int main() {
  ll n; cin>>n;
  ll ans=0;
  if (n%2==0) {
    ll cnt=10;
    while (n>=cnt) {
      ans+=(n/cnt);
      cnt*=5;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n,i,b,c,d;
    d=0;
    c=0;
    b=0;
    cin>>n;
    for (i=1;i<=n;i++){
        d=i;
        while (d!=0){
            b=b+1;
            d=d/10;
        }
        if (b%2!=0){
            c=c+1;
            
        }
        b=0;
    }
    cout<<c;
    return 0;
}

Measured memory_bytes: 256
//AC-120D
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

vector< int > parent;
vector< int > Size;
vector< pair< int,int > > edge;
vector< ll > decayed;

ll fallen_bridge;

int find_parent(int index)
{
    return ((parent[index] == index) ? index : (parent[index] = find_parent(parent[index]))); //applying Path Compression and returning parent/representative node of the set
}

void Union(int a,int b)
{
    int x,y;
    if((x = find_parent(a)) == (y = find_parent(b)))    return; //only vertices of disjoint sets shall pass
    fallen_bridge -= ((ll)Size[x])*((ll)Size[y]);
    if(Size[y]>Size[x])swap(x,y); //union by rank
    parent[y] = x; //set the new parent
    Size[x] += Size[y];//include the new children to the bigger set
    return;
}

int main()
{
    //freopen("in.txt","r",stdin);
    ll n,m;
    cin >> n >> m;
    parent.resize(n+1);
    Size.resize(n+1);
    for(int i = 1;i <= n;i++){
        parent[i] = i; //itself its parent initially
        Size[i] = 1; //only a set of itself initially
    }
    edge.resize(m+1);
    for(int i = 1;i <= m;i++){
        int a,b;
        cin >> a >> b;
        edge[i].first = a;
        edge[i].second = b;
    }
    fallen_bridge = n*(n-1)/2; //As every combos are possible according to problem-setter,initially
    decayed.push_back(fallen_bridge);
    for(int i=m;i > 1;i--){     //this loop does not apply for edge #1 as initially all combos were included.
        int a = edge[i].first, b = edge[i].second;
        Union(a,b);
        decayed.push_back(fallen_bridge);
    }
    for(int i = m-1;i>=0;i--)    cout << decayed[i] << endl;
}


Measured memory_bytes: 3828
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n;
int h[100010];
int dp[100010];

signed main(){
    I(n);
    REP(i,n) I(h[i]);
    REP(i,n) dp[i] = 1145141919LL;

    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    FOR(i,2,n) dp[i] = min(dp[i-2] + abs(h[i] - h[i-2]), dp[i-1] + abs(h[i] - h[i-1]));
    cout << dp[n-1] << endl; 
}

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

using namespace std;

int main() {
    long long H1, M1, H2, M2, K, Ans;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    Ans = H2 * 60 + M2 - K - H1 * 60 - M1;

    cout << Ans << endl;

    return 0;
}

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

#ifdef LOCAL
	#define D(a) cerr << #a << " = " << a << endl
#else
	#define D(a)
	#define cerr false && cerr
#endif
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) dforsn(i,0,n)
#define forn(i,n) forsn(i,0,n)
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first
#define endl '\n'
using pii = pair<int,int>;
using vi = vector<int>;
using ll = long long;

int main() {
	fastio;
	
    int n; cin >> n;
    int v[n], c[n];
    forn(i,n) cin >> v[i];
    forn(i,n) cin >> c[i];
    int res = 0;
    forn(i,n) if(v[i] > c[i]) res += v[i]-c[i];
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn
import scala.annotation.tailrec

object Main{
  def main(args: Array[String]){
    StdIn.readLine()
    val line = StdIn.readLine().split(" ").toList.map(_.toInt)

    sSort(List(), line, 0)
  }

  @tailrec
  def sSort(sorted: List[Int], unsorted: List[Int], n: Int){
    if((sorted ::: unsorted).length == 1)
      println(unsorted.mkString(" ") + "\n" + n)
    else if(unsorted.length == 1)
      println((sorted ::: unsorted).mkString(" ") + "\n" + n)
    else if(unsorted.sorted == unsorted)
      println((sorted ::: unsorted).mkString(" ") + "\n" + n)
    else if(unsorted.indexWhere(_ == unsorted.min) == 0)
      sSort(sorted :+ unsorted.head, unsorted.tail, n)
    else {
      val pos = unsorted.indexWhere(_ == unsorted.min)
      // pos??¨head???????´????swap?????????
      val swapped = unsorted.updated(0, unsorted(pos)).updated(pos, unsorted.head)

      sSort(sorted :+ unsorted.min, swapped.tail, n+1)
    }
  }
}

Measured memory_bytes: 45136
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

vector<string> ans;

void solv(int pos, int curr, string s, int maxi, int N)
{
	if(pos == N-1)
	{
		s += ('a'+curr);
		ans.push_back(s);
		return;
	}

	for(int i=0; i<=maxi+1; i++)
		solv(pos+1, i, s+(char)('a'+curr), max(i, maxi), N);
}
int main(void)
{
	cin.tie(0);	ios_base::sync_with_stdio(0);
	int N;	cin >> N;
	solv(0, 0, "", 0, N);
	sort(ans.begin(), ans.end());
	for(const string &k: ans)
		cout << k << "\n";
	return 0;
}

Measured memory_bytes: 9716
import java.util.*;

public class Main {
    static int WHITE = 0;
    static int GRAY = 1;
    static int BLACK = 2;
    static int[] color;
    static int[] d;
    static int n;
    static int[][] m;

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        n = input.nextInt();
        m = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                m[i][j] = 0;
            }
        }
        for (int i = 0; i < n; i++) {
            int v = input.nextInt();
            int in = input.nextInt();
            for (int j = 0; j < in; j++) {
                int u = input.nextInt();
                m[v - 1][u - 1] = 1;
            }
        }
        bfs();

        for (int i = 0; i < n; i++) {
            System.out.println(i + 1 + " " + d[i]);
        }

    }

    static void bfs() {
        // 初始化
        color = new int[n];
        d = new int[n];
        for (int i = 0; i < n; i++) {
            color[i] = WHITE;
            d[i] = -1;
        }
        color[0] = GRAY;
        d[0] = 0;
        Queue<Integer> Q = new LinkedList<Integer>();
        Q.offer(0); // add()和remove()方法在失败的时候会抛出异常(不推荐)
        while (!Q.isEmpty()) {
            int u = Q.poll();
            for (int v = 0; v < n; v++) {
                if (m[u][v] == 1 && color[v] == WHITE) {
                    color[v] = GRAY;
                    d[v] = d[u] + 1;
                    Q.offer(v);
                }
            }
            color[u] = BLACK;
        }
    }
}


Measured memory_bytes: 28388
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define pi  acos(-1)
const int w=2e5+5;
const ll mod=1e9+7;
int main()
{
    int i,j;
    string a;
    cin>>a;
    int t;
    cin>>t;
    int pos=1;
    string bb,cc;
    while(t--)
    {
        int x;
        scanf("%d",&x);
        if(x==1)
            pos*=-1;
        else
        {
            int y;
            char c;
            scanf("%d %c",&y,&c);
            if(y==1)
            {
                if(pos==1)
                    bb+=c;
                else
                    cc+=c;
            }
            else
            {
                if(pos==1)
                    cc+=c;
                else
                    bb+=c;
            }
        }
    }
    reverse(bb.begin(),bb.end());
    bb+=a;
    bb+=cc;
    if(pos==-1)
        reverse(bb.begin(),bb.end());
    cout<<bb<<endl;
    return 0;
}


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

struct Node {
	int key;
	struct Node* parent;
	struct Node* left;
	struct Node* right; 
};

typedef struct Node * NodePointer;

void insert( NodePointer t , int z){
	NodePointer x;
	if ( t -> key <= z){
		if  ( t -> right  == NULL){
			x =  (NodePointer) malloc (sizeof(struct Node));
			x -> key = z;
			x -> right = NULL;
			x -> left = NULL;
			t -> right = x;
		}else {
			insert ( t -> right , z);
		}
	
	}else {
		if  ( t -> left  == NULL){
			x =  (NodePointer) malloc (sizeof(struct Node));
			x -> key = z;
			x -> right = NULL;
			x -> left = NULL;
			t -> left = x;
		}else {
			insert ( t -> left , z);
		}
	}
};

void preorder ( NodePointer t){
	if ( t == NULL ){ return; }
	printf(" %d", t -> key);
	preorder( t -> left);
	preorder( t -> right);
};	

void inorder (NodePointer t){
	if ( t == NULL ){ return; }
	inorder( t -> left);
	printf(" %d", t -> key);
	inorder( t -> right);
};

void postorder (NodePointer t){
	if ( t == NULL ){ return; }
	postorder( t -> left);
	postorder( t -> right);
	printf(" %d", t -> key);
};


int main (){
	int n;
	scanf("%d\n",&n);

	NodePointer tree = (NodePointer) malloc (sizeof(struct Node));
	
	char input [8];
	int k;
	
	for ( int i = 0; i  < n; i++){
		scanf("%s" ,&input);
		
		if ( strcmp( input , "insert") == 0 ){
			scanf("%d\n",&k);
	
			if ( i == 0)
			{
			tree -> key = k;
			tree -> right = NULL;
			tree -> left = NULL;
			}

			else {insert(tree , k);
			}
		}else {
			inorder(tree);
			printf("\n");
			
			preorder(tree);
			printf("\n");
		}
	}
	
	
	return 0;
}



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

#define mod 1000000007

#define rep(i, n) for(int i=0; i<n; ++i)

using namespace std;
typedef long long ll; 
 
int main(void){
	
	int a;
	string s;
	
	cin >> a >> s;
	
	if(a >= 3200)
		cout << s;
	else
		cout << "red";
	
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

const INF = 1 << 29

func main() {
	var n int
	fmt.Scan(&n)
	h := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&h[i])
	}

	dp := make([]int, n)
	dp[0] = 0
	for i := 1; i < n; i++ {
		dp[i] = INF
	}

	for i := 0; i < n-1; i++ {
		// +1
		cost1 := dp[i] + int(math.Abs(float64(h[i]-h[i+1])))
		if cost1 < dp[i+1] {
			dp[i+1] = cost1
		}

		// +2
		if i < n-2 {
			cost2 := dp[i] + int(math.Abs(float64(h[i]-h[i+2])))
			if cost2 < dp[i+2] {
				dp[i+2] = cost2
			}
		}
	}
	fmt.Println(dp[n-1])
}


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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

w,a,b = LI()
if a-w <= b <= a + w:
    print(0)
elif a-w > b:
    print(a-(b+w))
else:
    print(b-(a+w))
    

Measured memory_bytes: 38384
N = int(input())
T = [[] for i in range(N)]
for i in range(N - 1):
  a, b = map(int, input().split())
  T[a - 1].append(b - 1)
  T[b - 1].append(a - 1)
def dijkstra(N, s0):
  D = [N] * N
  D[s0] = 0
  Q = [N] * N
  Q[0] = s0
  tail = 1
  for i in range(N):
    s = Q[i]
    for adj in T[s]:
      if D[s] + 1 < D[adj]:
        D[adj] = D[s] + 1
        Q[tail] = adj
        tail += 1
  return D
D1 = dijkstra(N, 0)
D2 = dijkstra(N, N - 1)
score = 0
for i in range(N):
  score += 1 if D1[i] <= D2[i] else -1
print('Fennec' if score > 0 else 'Snuke')

Measured memory_bytes: 29856
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String target = "keyence";
		String S = sc.nextLine();
		for (int i = 0; i < target.length(); i++) {
			if (S.startsWith(target.substring(0, i)) && S.endsWith(target.substring(i))) {
				System.out.println("YES");
				return;
			}
		}
		System.out.println("NO");
	}
}


Measured memory_bytes: 21844
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#include <tuple>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#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,n,m) for(int i = (n); i < (m); i++)
#define MOD 1000000007
#define INF 1000000000
#define LLINF 4000000000000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#pragma endregion

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N, W; cin >> N >> W;
    // dp[i][j] := iまでで価値jを作るときの重さの最小値
    vector<vector<ll>> dp(N + 1, vector<ll>(1000 * N+1, LLINF));
    vector<int> w(N), v(N);
    REP(i, N) {
        cin >> w[i] >> v[i];
    }
    dp[0][0] = 0;
    REP(i, N) {
        REP(j, 1000 * N+1) {
            if (j - v[i] < 0 || dp[i][j - v[i]] + w[i] > W) {
                dp[i + 1][j] = dp[i][j];
            }
            else {
                dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
            }
        }
    }
    REPR(i, 1000*N) {
        if (dp[N][i] != LLINF) {
            cout << i << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    getchar(); getchar();
}

Measured memory_bytes: 80256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

int dp[1001][1001];

int main(){
  int last_city;
  int day_limit;
  while(~scanf("%d %d",&last_city,&day_limit)){
    
    int distance[1001];
    for(int city_i = 0; city_i < last_city; city_i++){
      scanf("%d",&distance[city_i]);
    }

    int badness[1001];
    for(int day = 0; day < day_limit; day++){
      scanf("%d",&badness[day]);
    }

    memset(dp,0x3f,sizeof(dp));
    dp[0][0] = 0;
    for(int day = 0; day < day_limit; day++){
      for(int city_i = last_city - 1; city_i >= 0; city_i--){
        dp[day + 1][city_i + 1]
          = min(dp[day][city_i] + badness[day] * distance[city_i],
                dp[day + 1][city_i + 1]);
        dp[day + 1][city_i]
          = min(dp[day][city_i],
                dp[day + 1][city_i]);

      }
    }

    int res = INF;
    for(int day = 0; day <= day_limit; day++){
      res = min(res,dp[day][last_city]);
    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 5116
N,M,C = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
cnt=0
for i in range(N):
    x=0
    for num,a in enumerate(input().split()):
        x+=B[num]*int(a)
    if(x>(-1)*C):
        cnt+=1
print(cnt)


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

const int maxn = 2e5+ 5;
bool cmp(int a, int b) {
	return a > b;
}
using namespace std;
int a[maxn];
int n, k, l;
int main()
{
	scanf("%d%d", &n, &k);
	int m;
	for (int i = 0; i < n; i++) {
		scanf("%d", &m);
		if (!a[m])
			l++;
		a[m]++;
	}
	sort(a, a + maxn, cmp);
	if (l <= k)
		cout << "0" << endl;
	else {
		int sum = 0;
		for (int i = k; i < l + 1; i++)
			sum += a[i];
		cout << sum << endl;
	}
	return 0;
} 

Measured memory_bytes: 1024
#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<int,int>;
static const double PI = acos(-1);



int main(){
  int n, k;
  cin >> n >> k;
  vector<int> snuke(n);

  REP(i,k){
    int d;
    cin >> d;
    REP(j,d){
      int a;
      cin >> a;
      --a;
      ++snuke[a];
    }
  }
  int ans = 0;
  REP(i,n){
    if(snuke[i] == 0) ++ans;
  }

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

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

int main(){
  int n;
  int temp=0;

  cin >> n;

  for(int i=n;;i*=2)
    {
      if(i % 2 == 0 && i % n == 0)
	{
	  temp = i;
	  break;
	}
    }
  cout << temp << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;

int main(){
  	double A, B;
  	cin >> A >> B;
  	for(int i=1;i<=10000;i++){
  		int a = int(1.08*i);
  		int b = int(1.1*i);
  		//cout << a <<  " " << b <<endl;
		if(a==A+i && b==B+i){
  			cout << i <<endl;
  			return 0;
  		}
  	}
  	cout << -1 <<endl;
  	return 0;
}



Measured memory_bytes: 256