akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//  atcodersfrog1
//
//  Created by KARAN  on 23/01/20.
//  Copyright © 2020 Karan Kunwar. All rights reserved.
//

#include <iostream>
using namespace std;
long int min(long int x,long int y){
    if(x<y){
        return x;
    }
    return y;
}

int main(){
    long int n;
    cin>>n;
    long int arr[n];
    long int dp[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(abs(arr[i]-arr[i-2])+dp[i-2],abs(arr[i]-arr[i-1])+dp[i-1]);
    }
    cout<<dp[n-1];
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main() {
    int x,sum=0;
    cin>>x;
    int a[x];
    for (int i = 1; i <=x ; ++i) {
        cin>>a[i];
    }for (int j = 1; j <=x ; ++j) {
        if(j%2!=0&&a[j]%2!=0)
            sum++;
    }cout<<sum;
}

Measured memory_bytes: 3652
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	i64 N,T;
	cin >> N >> T;
	i64 min_cost = 1001;
	REP(i, N)
	{
		i64 c, t;
		cin >> c >> t;
		if (T >= t && min_cost > c)
		{
			min_cost = c;
		}
	}

	if (min_cost == 1001)
		cout << "TLE" << endl;
	else
		cout << min_cost << endl;
	return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  testDebbug
//
//  Created by Manikanta Nallagatla on 18/02/20.
//  Copyright © 2020 Manikanta Nallagatla. All rights reserved.
//
// testDebug.cpp : Defines the entry point for the console application.
//

#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#include<set>
#include<functional>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include <fstream>
#include <math.h>

using namespace std;



struct TreeNode
{
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};
struct TreeLinkNode
{
    int val;
    TreeLinkNode *left;
    TreeLinkNode *right;
    TreeLinkNode *next;
    TreeLinkNode(int x) : val(x), left(NULL), right(NULL), next(NULL) {}
};
struct ListNode
{
    int val;
    ListNode *next;
    ListNode(int x) : val(x), next(NULL) {}
};

template <class T>
void printv1(T v)
{
    cout << v << endl;
}


template <class T>
void printv2(vector<T> v)
{
    for (auto x : v) {
        cout<<x<<endl;
    }
    cout << endl;
}

template <class T>
void printv3(vector<vector<T>> v)
{
    for (auto x : v) {
        for (auto y : x) {
            cout << y << " ";
        }cout << endl;
    }
}

void printv4(vector<string> v)
{
    for (auto x : v) {
        for (auto y:x )
        {
            cout << char(y+int('0')) << " ";
        }
        cout << endl;
    }
    cout << endl;
}

static auto magic = []() {ios_base::sync_with_stdio(false); cin.tie(nullptr); return false; }();

#define POD 1000000007
#define ll long long int




int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    
    int n,m;
    cin>>n>>m;
    int tmp;
    int sum = 0;
    for(int i = 0;i<m;i++)
    {
        cin>>tmp;
        sum += tmp;
    }
    if(n < sum)
    {
        cout<<-1<<endl;
    }else{
        cout<<n-sum<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3168
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

int main(){
	
	int N, ans;
	
	cin >> N;
	
	string s_origin, s[100];
	
	cin >> s_origin;
	
	bool checker;
	
	ans = 0;
	
	for(int loop = 0; loop < N; loop++){
		cin >> s[loop];
		for(int i = 0; i < s[loop].size(); i++){
			for(int j = 1; j < s[loop].size(); j++){
				checker = true;
				for(int k = 0; k < s_origin.size(); k++){
					if(i + j * k >= s[loop].size()){
						checker = false;
						break;
					}
					if(s[loop][i + j * k] != s_origin[k]){
						checker = false;
						break;
					}
				}
				if(checker){
					//printf("%d %d\n", i, j);
					break;
				}
			}
			if(checker){
				ans++;
				break;
			}
		}
	}
	
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 1220
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
class P
{
    static void Main()
    {
        //奇数が裏
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long res = 0;
        if (a[0] == 1 && a[1] == 1)
        {
            res = 1;
        }
        else if (a[0] == 1)
        {
            res = a[1] - 2;
        }
        else if (a[1] == 1)
        {
            res = a[0] - 2;
        }
        else
        {
            res = (a[0] - 2) * (a[1] - 2);
        }
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 13268
from collections import defaultdict
import numpy as np
d = defaultdict(int)

N, P = map(int, input().split())

if N == 1:
  print(P)
else:
  i = 2
  while i <= P**(1/2):
    if P % i == 0:
      P //= i
      d[i] += 1
    else:
      i += 1
  d[P] += 1
  g = np.prod([k**(v//N) for k, v in d.items()])
  print(g)

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

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

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

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

int main(){
	int N, ans;
	cin >> N;
	int HP[N];
	for(int i = 0; i < N; i++){
		cin >> HP[i];
	}
	ans = gcd(HP[0], HP[1]);
	for(int i = 2; i < N; i++){
		ans = gcd(ans, HP[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<ll, ll> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}



int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	// freopen("settling.in", "r", stdin);
	// freopen("settling.out", "w", stdout);

	const ll oo = 1e18;

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

	vector<int> p(n + 1);
	for(int i = 1; i <= n; i++)
		cin >> p[i];

	vector<ll> c(n + 1);
	for(int i = 1; i <= n; i++)
		cin >> c[i];

	ll ans = -oo;
	vector<bool> used(n + 1);

	for(int i = 1; i <= n; i++){
		if(used[i])
			continue;

		vector<ll> cycle;
		int u = i;
		ll sum = 0;
		while(!used[u]){
			used[u] = true;
			sum += c[u];
			cycle.push_back(c[u]);
			u = p[u];
		}

		int sz = cycle.size();
		for(int i = 0; i < sz; i++){

			//take 0 rem
			if(sum > 0)
				ans = max(ans, sum * 1ll * (k / sz));

			ll cur = cycle[i], add = 0;
			int cnt = 1;
			int rem = k - cnt;
			int rounds = rem / sz;
			if(sum >= 0)
				add = sum * 1ll * rounds;

			ans = max(ans, cur + add);

			for(int j = (i + 1) % sz; j != i && cnt + 1 <= k; j = (j + 1) % sz){
				cnt++;
				cur += cycle[j];
				rem = k - cnt;
				rounds = rem / sz;
				add = 0;
				if(sum >= 0)
					add = sum * 1ll * rounds;

				ans = max(ans, cur + add);
			}
		}
	}


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


Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007LL;

ll mod_inv(ll a, ll m) {
    ll b = m, x = 1, y = 0, s, t;
    while ( b != 0 ) {
        s = y;
        y = x - ( a / b ) * y;
        x = s;
        t = b;
        b = a % b;
        a = t;
    }
    return (x % m + m) % m;
}

ll solve() {
    ll N, M;
    cin >> N >> M;
    ll x, y, xp, yp;
    vector<ll> dx(N-1), dy(M-1);
    for ( int i = 0; i < N; i++ ) {
        cin >> x;
        if ( i > 0 ) dx[i-1] = x - xp;
        xp = x;
    }
    for ( int i = 0; i < M; i++ ) {
        cin >> y;
        if ( i > 0 ) dy[i-1] = y - yp;
        yp = y;
    }

    auto edge_sum = [](vector<ll>& v) {
        ll n = v.size();
        ll n_all = n * (n+1) / 2 % MOD;
        ll s = 0;
        ll inv2 = mod_inv(2,MOD);
        for ( ll i = 0; i < n; i++ ) {
            ll n_ex1 = (n-1-i) * (n-i) / 2 % MOD;
            ll n_ex2 = i * (i+1) / 2 % MOD;
            ll n_c = (n_all + MOD - n_ex1 + MOD - n_ex2) % MOD;
            s += (v[i] * n_c) % MOD;
            s %= MOD;
        }
        return s;
    };

    ll ans = edge_sum(dx) * edge_sum(dy) % MOD;
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1792
solve' x
  | x <= 0    = 0
  | otherwise = x

solve w a b
  | a < b  = b - (a + w)
  | a >= b = a - (b + w)

main = do
  line <- getLine
  let [w, a, b] = fmap (read :: String -> Int) $ words line in
    putStrLn $ show $ solve' $ solve w a b


Measured memory_bytes: 508
a = int(input())
b = int(input())
c = int(input())
x = int(input())
maxa = min([a,x//500])
maxb = min([b,x//100])
maxc = min([c,x//50])
count = 0
for i in range(maxa + 1):
    for j in range(maxb + 1):
        for k in range(maxc + 1):
            if 10*i + 2*j + k == x/50:
                count += 1
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rel register ll
#define rec register char
#define gc getchar
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<23,stdin),p1==p2)?-1:*p1++)
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
char buf[1<<23],*p1=buf,*p2=buf;
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) pc('-'),x=-x;
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=2e5;
typedef ll fuko[yuzu|10];
fuko a;
int main() {
  int i,n=read();
  ll a,b,x=0,t;
  cin>>a>>b;
  for (i=3;i<=n;++i) read(t),x^=t;
  if (x>a+b||(a+b-x)%2) return puts("-1")&0;
  ll w=(a+b-x)/2,m=w;
  if (w>a||(w&x)) return puts("-1")&0;
  for (i=56;~i;--i) if ((x>>i&1)&&(m+(1ll<<i))<=a) m+=1ll<<i;
  printf("%lld\n",!m?-1:a-m); 
}

Measured memory_bytes: 3756
#include <cstdio>

int main()
{
	int h,w;

	while (true) {
		scanf("%d %d", &h, &w);

		if (h == 0 && w == 0)
			break;

		int i,j;

		for (i=0; i<h; i++) {
			for (j=0; j<w; j++) {
				printf("#");
			}
			printf("\n");
		}

		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 2544
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using namespace std;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b ;
    cin >> a >> b;
    int k=1;
    bool flag=true;
    while(k<1001){
       int a1 = floor(k*0.08);
       int a2 = floor(k*0.1);
       k++;
       if(a1==a and a2==b) {
         cout << k-1 << "\n";
         flag=false;
         break;
       }
    }
    if(flag) cout << -1 << "\n";
}    


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef pair<ll,P> PP;
int main() {
	int n; cin >> n;
	int out = 1;
	while (out <= n)out *= 2; out /= 2;
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 256
N = gets.chomp.to_i
A = gets.chomp.split.map(&:to_i)
Q = gets.chomp.to_i
bc = []
Q.times do
  bc.push gets.chomp.split.map(&:to_i)
end

arr = Array.new(10**5+1, 0)
A.each do |a|
  arr[a] += 1
end
sum = A.sum

Q.times do |i|
  b,c = bc[i]
  sa = (c-b) * arr[b]
  sum += sa
  p sum
  arr[c] += arr[b]
  arr[b] = 0
end


Measured memory_bytes: 32500
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 

int n;
int v[100001];
int id[100001];

signed main(){
    FASTER;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>v[i];
        id[v[i]]=i;
    }
    
    
    int ans=0;
    set<int> used;
    
    for(int i=n;i>=1;i--){
        
        int a=0,b=0,x=n+1,y=n+1;
        
        auto it=used.upper_bound(id[i]);
        if(it!=used.end())x=*it,it++;
        if(it!=used.end())y=*it;
        it=used.upper_bound(id[i]);
        if(it!=used.begin())it--,b=*it;
        if(it!=used.begin())it--,a=*it;
            
        ans += (b-a)*(x-id[i])*i;
        ans += (y-x)*(id[i]-b)*i;
        
        used.insert(id[i]);
    }
    
    cout<<ans;
}


Measured memory_bytes: 9708
S = input()
T = input()

min_cnt = float("inf")
for i in range(len(S)-len(T)+1):
    cnt = 0
    dummy = S[i:i+len(T)]
    for j in range(len(dummy)):
        if dummy[j] != T[j]:
            cnt += 1
    if cnt < min_cnt:
        min_cnt = cnt
print(min_cnt)


Measured memory_bytes: 73492
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll X, N; cin >> X >> N;
    set<ll> se;
    for(int i = 0; i < N; ++i){
        ll a; cin >> a;
        se.insert(a);
    }
    for(int i = 0; i <= 100; ++i){
        ll m = X - i;
        if(se.count(m) == 0){
            cout << m << endl;
            break;
        }
        ll M = X + i;
        if(se.count(M) == 0){
            cout << M << endl;
            break;
        }
    }
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


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

s = ''
dx = tx - sx
dy = ty - sy

s += 'R'*dx + 'U'*dy + 'L'*dx + 'D'*(dy+1)
s += 'R'*(dx+1) + 'U'*(dy+1) + 'LU' + 'L'*(dx+1) + 'D'*(dy+1) + 'R'

print(s)


Measured memory_bytes: 3060
using System;
class bable{
  public static void Main(){
    int kosuu = int.Parse(Console.ReadLine());
    double[] value = new double[kosuu];
    string[] s = Console.ReadLine().Split(' ');
    for (int i = 0; i<kosuu; i++) {
      value[i] = double.Parse(s[i]);
    }
    double stb =0;
    for (int i=0; i<kosuu-1; i++) {
      for (int j=0;j<kosuu-1-i;j++){
        if (value[j]>value[j+1]) {
          stb = value[j];
          value[j] = value[j+1];
          value[j+1]=stb;
        }
      }
    }
     double sum = (value[0]+value[1])/2;
     for (int p=2; p<kosuu; p++) {
       sum = (sum+value[p])/2;
     }
      Console.WriteLine("{0}",sum);
    }

  }


Measured memory_bytes: 13268
//Krunal_Mathukiya
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define li long int
#define pb push_back
#define mkp make_pair
#define nikalL return
#define umap unordered_map
#define fr(i,s,n) for(int i=s;i<=n;++i)
#define frr(i,s,n) for(int i=s;i>=n;--i)
#define jaldiKarNe ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
int n;
lli arr[200007];
void TestingChaluKarEyy(){
	lli k;
	cin>>n>>k;
	fr(i,1,n) cin>>arr[i];
	lli start=1,end=1000000000;
	lli mid;
	lli ans=10000000000;
	while(start<=end) {
		mid=(start+end)/2;
		// cout<<start<<" "<<end<<" : "<<mid<<"\n";
		lli cnt=0;
		fr(i,1,n) {
			cnt+=(ceil((long double)arr[i]/mid)-1);
		}
		if(cnt>k) start=mid+1;
		else {
			ans=min(ans,mid);
			end=mid-1;
		}
		
	}
	cout<<ans<<"\n";
}
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	jaldiKarNe;
	int TestingKaravvuChhe=1;
	// cin>>TestingKaravvuChhe;
	while(TestingKaravvuChhe--){
		TestingChaluKarEyy();
	}
}


Measured memory_bytes: 5072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	int n; cin >> n;
	std::vector<int> a(n);
	std::vector<int> b(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		b[i] = a[i];
	}

	sort(b.begin(), b.end());

	int check = 0;

	for (int i = 0; i < n; ++i)
	{
		if(a[i] != b[i]) check++;
	}

	if(check == 2 || check == 0) cout << "YES" << endl;
	else cout << "NO" << endl;

}

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

using namespace std;
using ll = long long;

vector<ll> A, B, C;

ll calc(ll now) {
  return A[now / 1000000] + B[(now%1000000) / 1000] + C[now%1000];
}

int main() {
  ll X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  A = vector<ll>(X);
  B = vector<ll>(Y);
  C = vector<ll>(Z);
  for (int i = 0; i < X; ++i) {
    cin >> A[i];
  }
  for (int i = 0; i < Y; ++i) {
    cin >> B[i];
  }
  for (int i = 0; i < Z; ++i) {
    cin >> C[i];
  }
  sort(A.begin(), A.end(), std::greater<ll>());
  sort(B.begin(), B.end(), std::greater<ll>());
  sort(C.begin(), C.end(), std::greater<ll>());
  ll now = 0;
  cout << calc(now) << endl;
  vector<pair<ll, ll>> queue1 = {make_pair(calc(now + 1), now + 1),
                                 make_pair(calc(now + 1000), now + 1000),
                                 make_pair(calc(now + 1000000), now + 1000000)};
  for (int i = 0; i < K-1; ++i) {
    auto itr = max_element(queue1.begin(), queue1.end(), [](auto l, auto r){return l.first < r.first;});
    cout << (*itr).first << endl;
    now = (*itr).second;
    queue1.erase(itr);

    if(now%1000+1<Z && find_if(queue1.begin(),queue1.end(),[now](auto e){return now+1 == e.second;}) == queue1.end())
      queue1.push_back({calc(now+1), now+1});
    if((now%1000000)/1000+1<Y&& find_if(queue1.begin(),queue1.end(),[now](auto e){return now+1000 == e.second;}) == queue1.end())
      queue1.push_back({calc(now+1000), now+1000});
    if(now/1000000+1<X&& find_if(queue1.begin(),queue1.end(),[&](auto e){return now+1000000 == e.second;}) == queue1.end())
      queue1.push_back({calc(now+1000000), now+1000000});
  }
}


Measured memory_bytes: 512
n,m=map(int,input().split())
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())
ab=[]
for _ in range(m):
  a,b=map(int,input().split())
  ab.append((a-1,b-1))
ans=0
uf=UnionFind(n)
for i in range(m):
  uf.__init__(n)
  for j in range(m):
    if j==i:
      continue
    a,b=ab[j]
    uf.union(a,b)
  if uf.group_count()==2:
    ans+=1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int s;
  int a;
  int ans = 1;
  int check[1000005] = {};

  cin >> s;
  
  a = s;
  while(1){
    check[a]++;
    if(check[a] == 2){
      cout << ans << endl;
      break;
    }

    if(a % 2 == 0){
      a /= 2;
    }else{
      a = 3 * a + 1;
    }
    ans ++;
  }
  return 0;
}



Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <algorithm>

int main()
{
	std::string s;
	std::cin >> s;
	
	int ans = 0;
	
	for (int i = 0; i < s.length(); i++)
	{
		int count = 0;
		while (s[i] == 'A'|| s[i] == 'C' || s[i] == 'G'|| s[i] == 'T')
		{
			++count;
			++i;
		}
		ans = std::max(ans, count);
	}
	std::cout << ans << '\n';
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	public static int MOD = 1_000_000_007;
	public static int MAX = 2000000;
	public static long[] fac = new long[MAX];
	public static long[] finv = new long[MAX];
	public static long[] inv = new long[MAX];
	
	public static void COMinit() {
		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for(int i = 2; i < MAX; i++) {
			fac[i] = fac[i-1] * i % MOD;
			inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
			finv[i] = finv[i-1] * inv[i] % MOD;
		}
	}
	
	public static long combination(int n, int k){
		if(n < k || n < 0 || k < 0) return 0;
		return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int N = (X+Y)/3;
		if((X+Y) % 3 != 0)
			System.out.println(0);
		else {
			COMinit();
			System.out.println(combination(N, N*2-X));
		}

	}

}


Measured memory_bytes: 70868
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define num(a) a-'0'
#define charr(a) (a - 'A' + 1)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define maxs(a,b) if(b>a)a=b
#define mins(a,b) if(b<a)a=b
#define bin1(a) __builtin_popcount(a)
#define debug(x) cerr<<"["<<#x<<":"<<x<<"] "
#define debug2(a,b) debug(a);debug(b)
#define debug3(a,b,c) debug2(a,b);debug(c)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/(__gcd(a,b))
#define print(arr) for(auto it = arr.begin();it < arr.end();it ++){cout << *it << " ";}cout << ln;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define all(a) (a).begin(), (a).end()
#define vi vector<long long>
#define v vector
#define p pair
#define pii p<int,int>
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define ln "\n"
typedef long double ld;
typedef double d;
using namespace std;
using namespace __gnu_pbds;
int modF=1e9+7;
int inf=1e18+5;

/*OUTPUT

*/

void solve(){
	int n;
	cin>>n;
	vi a(n);
	rep(i,0,n){
		cin>>a[i];
	}
	int ans=0;
	rep(i,1,n-1){
		if(a[i+1]>a[i] && a[i]>a[i-1]){
			ans++;
		}
		else if(a[i+1]<a[i] && a[i]<a[i-1]){
			ans++;
		}
	}
	cout<<ans<<ln;
}

signed main(){
	boost_io;
	int t=1;
	// cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll L,A,B,M;
ll i,j,k;

ll dmul[3][3];
ll mul[3][3];
ll ans[3][3];
void calc(ll a){
    if(a==0)
        return;
    ll i, j,k,l;
    if(a&1){
        fornum(i,0,3){
            fornum(j,0,3){
                dmul[i][j] = ans[i][j];
            }
        }
        fornum(i,0,3){
            fornum(j,0,3){
                ans[i][j]=0;
                fornum(k,0,3){
                    ans[i][j] = (ans[i][j] + dmul[i][k] * mul[k][j])%M;
                }
            }
        }
    }
    fornum(i,0,3){
        fornum(j,0,3){
            dmul[i][j] = mul[i][j];
        }
    }
    fornum(i,0,3){
        fornum(j,0,3){
            mul[i][j]=0;
            fornum(k,0,3){
                mul[i][j] = (mul[i][j] + dmul[i][k] * dmul[k][j])%M;
            }
        }
    }    
    calc(a / 2);
}

int main(){
    scanf("%lld%lld%lld%lld", &L, &A, &B, &M);
    //A %= M;
    //B %= M;
    ans[0][0] = 1;
    ans[1][1] = 1;
    ans[2][2] = 1;
    
    ll a = 0;
    ll b = 10;
    fornum(i,0,18){
        ll l = 0;
        ll r = L;
        while(l<r){
            ll c = (r + l) / 2;
            ll C = A + B * c;
            if(C<b){
                l = c + 1;
            }else{
                r = c;
            }
        }
        //printf("%lld,%lld\n", a, r);
        fornum(j,0,3){
            fornum(k,0,3){
                mul[j][k] = 0;
            }
        }
        mul[0][0] = b%M;
        mul[1][0] = 1;
        mul[1][1] = 1;
        mul[2][1] = B%M;
        mul[2][2] = 1;
        if(r==L){
            calc(L - a);
            break;
        }
        calc(r - a);
        a = r;
        b *= 10;
    }
    /*
    fornum(i,0,3){
        fornum(j,0,3){
            printf("%lld ", ans[i][j]);
        }
        printf("\n");
    }*/
    printf("%lld", (A%M * ans[1][0] + ans[2][0]) % M);
    return 0;
}

Measured memory_bytes: 256
/**
 * 	author: MahfuzAhmed
 * 	created: 03.08.2019 
**/

#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define forn(var,from,to) for(int var=(from);i<(to);i++)
#define forx(var,from,to) for(int var=(from;i<=(to);i++)
#define fory(var,from,to) for(int var=(from);i>=(to);i--)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vvi vector<vi>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(p) p.begin(),p.end()
typedef long long ll;
//~ const double pi = 2*acos(0.0);
//~ const long long mod = 1e9+7;
//~ const int MAX_N = 1e6+5;

int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
       
    #ifdef _DEBUG
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    
    string s; cin >> s;
    
    forn(i, 1, s[i]){
        if(s[i-1] == s[i]){
            cout << "Bad\n";
            return 0;
        }
    }
    
    cout << "Good\n";
    
    return 0;
}



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

using namespace std;

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

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        long long ans=0;
        for(int i=1;i<=n;i++)
        {
            long long t;
            scanf("%lld",&t);
            if(i==1)    ans=t;
            else
            {
                ans=ans/gcd(ans,t)*t;
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

template<class T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

template<class T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

ll qu(ll a,ll b,ll c){
    ll c1 = c/2;
    ll c2 = c-c1;
    ll d1 = a*b*c2;
    ll d2 = a*b*c1;
    return max(d1,d2)-min(d1,d2);

}

int main() {
    ll a,b,c;
    cin>>a>>b>>c;
//    ll mi = a*b*c;
//    mi = min(qu(a,b,c),mi);
//    mi = min(qu(a,c,b),mi);
//    mi = min(qu(c,b,a),mi);
//    cout<<mi<<endl;
if(a%2&&b%2&&c%2){
    cout<<min({a*b,b*c,c*a})<<endl;


}else{
    cout<<0<<endl;
}



    return 0;
}


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

int main(void) {
  long long N;
  cin >> N;
  N--;
  string ans = "";
  while (N >= 0) {
    char c = 'a' + (N % 26);
    ans = c + ans;
    N /= 26;
    N--;
  }
  cout << ans << endl;
  return 0;
}

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

const int N = 2e3+5;
int a[N];

int main() {
    int n, x, y;
    cin>>n>>x>>y;

    for (int i=1; i<=n; i++) {
        for (int j=i+1; j<=n; j++) {
            int ans = j-i;
            ans = min(ans, abs(i-x) + abs(j-y) + 1);
            ans = min(ans, abs(j-x) + abs(i-y) + 1);
            a[ans]++;
        }
    }

    for (int i=1; i<n; i++) cout<<a[i]<<"\n";
}


Measured memory_bytes: 256
from collections import deque

H, W = map(int, input().split())
grid = [input() for _ in range(H)]

def BFS(H, W, grid):
    visited = [[True for _ in range(W+2)] for _ in range(H+2)]
    que = deque()
    for i in range(H):
        visited[i+1][1:-1] = map(lambda _:_=="#", grid[i])
        for j in range(W):
            if(grid[i][j] == "#"):
                que.append((i+1, j+1, 0))
    dist = [(0, 1), (-1, 0), (0, -1), (1, 0)]
        
    while que:
        x, y, c = que.popleft()
        for dx, dy in dist:
            nx = x + dx
            ny = y + dy
            
            if(not visited[nx][ny]):
                que.append((nx, ny, c+1))
                visited[nx][ny] = True
    return c
        
print(BFS(H, W, grid))

Measured memory_bytes: 138184
#include <bits/stdc++.h>
#define endl "\n"
#include <set>
 
 
using namespace std;
int main(){
    
ios_base::sync_with_stdio(false);
    cin.tie(NULL);    
 
  int n; cin>>n;
  int dp[n];
  vector <int> a;
  for (int i=0; i<n; i++)
  {
    int temp; cin>>temp;
    a.push_back(temp);
  }
  
  dp[n-1]=0;
  dp[n-2]=abs(a[n-1]-a[n-2]);
  
  for (int i=n-3; i>=0; i--)
  {
    int diff1=abs (a[i+1]-a[i]); int diff2= abs(a[i+2] -a[i]);
    dp[i]= min( dp[i+1]+ diff1, dp[i+2] +diff2);
  }  
  cout<<dp[0]<<endl;
}

Measured memory_bytes: 1144
#import numpy as np
#import collections
#import math

#f = open('./input_E.txt')
#
#N,K = map(int, f.readline().split())
#A = list(map(int, f.readline().split()))

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

A.sort(reverse=True)

def nibu(small,big,KK,AA):
    mid = (small+big)//2
    k_list = [(x-1)//mid for x in AA]
    sum_k = sum(k_list)
    if sum_k <= KK: #達成可能 -> 答えはもっと小さい
        return small,mid # 不可能,可能
    else:
        return mid,big # 不可能,可能


if K==0:
    ans = A[0]
else:    
    lmin = 0
    lmax = A[0]
    
    while lmax - lmin >= 2:
        lmin, lmax = nibu(lmin,lmax,K,A)
    
    ans = lmax
    
print(ans)

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

int main() {
    int n; cin >> n;
    vector<int> b(n), ans;
    for(int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    for(int lp = 0; lp < n; ++lp) {
        const int m = b.size();
        bool found = false;
        for(int j = m - 1; j >= 0; --j) {
            if(b[j] == j + 1) {
                ans.push_back(j + 1);
                b.erase(begin(b) + j);
                found = true;
                break;
            }
        }
        if(!found) break;
    }

    reverse(begin(ans), end(ans));
    if(ans.size() != n) {
        cout << -1 << endl;
    } else {
        for(auto x : ans) {
            cout << x << endl;
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a,b,c,temp;
	
	scanf("%d %d %d",&a, &b, &c);
	
	if(a > b){
	    temp = a;
	    a = b;
	    b = temp;
	    if(a > c){
	        temp = a;
	        a = c;
	        c = temp;
	    }
	}
	if(b > c){
	    temp = b;
	    b = c;
	    c = temp;
	}
	
	printf("%d %d %d\n",a, b, c);
	
	return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
    int n, m;
    cin>>n>>m;
    ll ans=0;
    ans += (n>=2) ? (n*(n-1)/2) : 0;
    ans += (m>=2) ? (m*(m-1)/2) : 0;
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
    int A, B, C;
    scanf("%d %d %d", &A, &B, &C);
    int Q = B / A;
    if (C < Q) Q = C;
    printf("%d\n", Q);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = 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;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

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

    if(k == 0){
        cout << n * n << endl;
        return 0;
    }

    ll ans = 0;
    for(ll i = k+1; i <= n; i++){
        ll tmp = i - k;
        ans += (n / i) * (i-k);

        if((n % i) - (k-1) > 0){
            ans += ((n % i) - (k-1));
        }
    }

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

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

int main(){
    int a,b,c;
    cin >>a>>b>>c;
    if(a<b)swap(a,b);
    if(a<c)swap(a,c);
    cout << 10*a+b+c << endl;
    return 0;
}


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

using namespace std;


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

	vector<int> h(n), dp(n, 1 << 30);    

	for(int &x : h)
		cin >> x;

	dp[0] = 0;
	for(int i = 1; i < n; i++)
	{
		for(int j = 1; j <= min(i, 2); j++)
			dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
	}

	cout << dp[n - 1] << endl;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long LL;

const int maxn=2e5+5;

int n,a[maxn];
LL sum[maxn];

int main()
{
	scanf("%d",&n);
	fo(i,1,n) scanf("%d",&a[i]), sum[i]=sum[i-1]+a[i];
	
	LL ans=1e15;
	fo(i,1,n-1)
	{
		LL x=sum[i], y=sum[n]-sum[i];
		ans=min(ans,abs(x-y));
	}
	
	printf("%lld\n",ans);
}

Measured memory_bytes: 2560
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    s = S()
    c = s.count("0")
    print(2*min(c,len(s)-c))
    return

#B
def B():
    n = I()
    h = LI()
    ans = 0
    m = min(h)
    while m:
        ans += m
        k = max(h)
        for i in range(n):
            if h[i] >= m:
                h[i] -= m
                if h[i]:k = min(k,h[i])
            else:break
        m = k
    print(ans)
    return

#C
def C():
    n,k = LI()
    x = LI()
    ans = float("inf")
    j = bisect.bisect_left(x,0)
    if n == 1:
        print(abs(x[0]))
        quit()
    if j < n:
        if x[j] == 0:
            k -= 1
            x.pop(j)
            n -= 1
    for i in range(n):
        if i < j:
            if abs(i-j) > k:continue
            elif abs(i-j) == k:ans = min(ans,abs(x[i]))
            elif k+i-1 < n:
                ans = min(ans,abs(x[i])+x[k+i-1]-x[i])
        else:
            if abs(i-j)+1 > k:continue
            elif abs(i-j)+1 == k:ans = min(ans,x[i])
            elif i-k+1 >= 0:
                ans = min(ans,abs(x[i])+x[i]-x[i-k+1])

    print(ans)
    return

#D
def D():
    n = I()
    a = LI()
    ans = 0
    p = [1<<i for i in range(100)]
    for i in range(n):
        l = 0
        r = 100
        while r-l > 1:
            m = (l+r)//2
            if a[i]%p[m] == 0:
                l = m
            else:
                r = m
        ans += l
    print(ans)
    return

#E
def E():
    s = LI()
    s.sort()
    ans = s[2]-s[1]
    s[0] += s[2]-s[1]
    s[1] = s[2]
    if s[0]%2 != s[1]%2:
        ans += (s[1]+1-s[0])//2+1
    else:
        ans += (s[1]-s[0])//2
    print(ans)
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    E()


Measured memory_bytes: 39920
h,w=gets.split.map(&:to_i)
dp=[]
s=[]
h.times do |i|
  s << gets.chomp
  dp << []
  if i==0
    w.times do |j|
      if j==0
        if s[0][0]=="."
          dp[0][0]=0
        else
          dp[0][0]=1
        end
      else
        if s[0][j]==s[0][j-1]
          dp[0][j]=dp[0][j-1]
        else
          dp[0][j]=dp[0][j-1]+1
        end
      end
    end
  else
    w.times do |j|
      if j==0
        if s[i][0]==s[i-1][0]
          dp[i][0]=dp[i-1][0]
        else
          dp[i][0]=dp[i-1][0]+1
        end
      else
        if dp[i][j-1]<dp[i-1][j]
          if s[i][j]==s[i][j-1]
            dp[i][j]=dp[i][j-1]
          else
            dp[i][j]=dp[i][j-1]+1
          end
        elsif dp[i][j-1]>dp[i-1][j]
          if s[i][j]==s[i-1][j]
            dp[i][j]=dp[i-1][j]
          else
            dp[i][j]=dp[i-1][j]+1
          end
        else
          if s[i][j]==s[i-1][j]||s[i][j]==s[i][j-1]
            dp[i][j]=dp[i][j-1]
          else
            dp[i][j]=dp[i][j-1]+1
          end
        end
      end
    end
  end
end
puts (dp[-1][-1]-1)/2+1


Measured memory_bytes: 1916
#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 vi = vector<int>;
using vvi = vector<vi>;

int main(){
    vi data = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int N;
    cin >> N;
    cout << data[N-1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <list>
#include <set>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1010101010
#define MOD 1000000007
#define LL long long
using Coord = pair<int, int>;

int main() {
    int n, m;
    cin >> n >> m;
    vector<LL> xn(n);
    vector<LL> ym(m);
    for (auto& e: xn) cin >> e;
    for (auto& e: ym) cin >> e;

    LL xs = 0;
    LL ys = 0;
    for (int i = 0; i < n; i++) {
        xs += xn[i] * (i + 1) - xn[i] * (n - i);
    }

    for (int i = 0; i < m; i++) {
        ys += ym[i] * (i + 1) - ym[i] * (m - i);
    }

    xs %= MOD;
    ys %= MOD;
    
    cout << (xs * ys) % MOD << endl;
}

Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
using namespace std;
static const uint64_t MOD = 1000000007LL;
// uint64_t dp[100005][13];
//
vector<vector<int>> odds(100005);
vector<vector<int>> evens(100005);
vector<int> colors(100005);

void color_rec(int a) {
    for (auto e: odds[a]) {
        if (colors[e])
            continue;
        colors[e] = -colors[a];
        color_rec(e);
    }
    for (auto e: evens[a]) {
        if (colors[e])
            continue;
        colors[e] = colors[a];
        color_rec(e);
    }
}

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

    for (int i = 1; i < n; i++) {
        int u, v;
        long w;
        cin >> u >> v >> w;

        if (w % 2 == 0) {
            evens[u].push_back(v);
            evens[v].push_back(u);
        } else {
            odds[u].push_back(v);
            odds[v].push_back(u);
        }
    }

    colors[1] = 1;
    color_rec(1);

    for (int i = 1; i <= n; i++) {
        if (colors[i] == 1) {
            cout << 1 << endl;
        } else if (colors[i] == -1) {
            cout << 0 << endl;
        } else {
            cout << "X" << endl;
        }
    }
}


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

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        PrintWriter cout = new PrintWriter(System.out);

        int n = cin.nextInt();
        int[] line = new int[n];
        for(int i=1;i<=n;i++) {
            line[cin.nextInt()-1] = i;
        }
        
        for(int x : line) cout.print(x + " ");
        cout.println();
        cout.close();
    }
}

Measured memory_bytes: 59192
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    m = 61
    d = [0]*m
    ans = 0
    p = [pow(2,j,mod) for j in range(m)]
    for i in range(n):
        ai = a[i]
        for j in range(m):
            if ai&(1<<j):
                ans += (i-d[j])*p[j]%mod
                ans %= mod
                d[j] += 1
            else:
                ans += d[j]*p[j]%mod
                ans %= mod
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


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

int main() {
  int A;
  A = 1;
  int B;
  cin >> B;
  int M;
  cin >> M;
  int a;
  int b;
  for (int i = 0; i < M; i++) {
    cin >> a;
    cin >> b;
    if (a > A){
      A = a;
    }
    if (b < B){
      B = b;
    }
  }
  if (A > B){
    cout << 0 << endl;
  }
  if (A <= B){
    cout << B - A + 1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)

vector <int> a,b;
vector <int> x[100005];
int p[100005];
int visit[100005];
void matomeru(int s){
    FOR(i,0,x[s].size()){
        if(visit[x[s][i]] == 1){
            continue;
        }
        a.push_back(x[s][i]);
        visit[x[s][i]] =1;
        matomeru(x[s][i]);
    }
};

void bset(){
    sort(a.begin(),a.end());
    b.push_back(p[a[0]]);
    FOR(i,1,a.size()){
        if(a[i]== a[i-1])
            continue;
        else {
            b.push_back(p[a[i]]);
        }
    }
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n,m,tmp;
    pair<int,int> tmp2;
    cin >> n >> m;
    FOR(i,0,n){
        cin >> p[i+1];
        visit[i+1]=0;
    }
    FOR(i,0,m){
        cin >> tmp2.first >> tmp2.second;
        x[min(tmp2.first,tmp2.second)].push_back(max(tmp2.first,tmp2.second));
        x[max(tmp2.first,tmp2.second)].push_back(min(tmp2.first,tmp2.second));
    }
    int ans =0;
    FOR(i,1,n+1){
        if(visit[i] == 1)
            continue;
        a.erase(a.begin(),a.end());
        b.erase(b.begin(),b.end());
        a.push_back(i);
        matomeru(i);
        bset();
        sort(b.begin(),b.end());

        int j=0,k=0;
        while (1){
            if(a.size()== j || b.size() == k)
                break;
            if(a[j] == b[k]){
                ans++;
                j++;
                k++;
            }else if (a[j] < b[k]){
                j++;
            }else{
                k++;
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 10744