akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**6)

def read_tokens():
    return input().strip().split(' ')

def read_ints():
    return [int(token) for token in read_tokens()]

h, w, k = read_ints()
a = []
for i in range(h):
    row, = read_tokens()
    a.append(row)

p = []
for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            p.append((i, j))

p.sort()

ans = [[0] * w for _ in range(h)]

cnt = 0

def solve(ifrom, ito, jfrom, jto, p, ans):
    global cnt
    # print(f'{ifrom}, {ito}, {jfrom}, {jto}, {p}, {cnt}')
    assert(len(p) > 0)
    for v in p:
        assert(ifrom <= v[0] < ito)
        assert(jfrom <= v[1] < jto)
        
    if len(p) == 1:
        
        cnt += 1
        for i in range(ifrom, ito):
            for j in range(jfrom, jto):
                ans[i][j] = cnt
        return
    # now >= 2 points
    if p[0][0] == p[-1][0]:
        m = len(p) // 2
        pivot = p[m][1]
        solve(ifrom, ito, jfrom, pivot, p[:m], ans)
        solve(ifrom, ito, pivot, jto, p[m:], ans)
    else:
        # p[0][0] != p[-1][0]
        m = 0
        while p[m][0] == p[0][0]:
            m += 1
        pivot = p[m][0]
        # p1 = [v for v in p if v[0] < pivot]
        # p2 = [v for v in p if v[0] >= pivot]

        solve(ifrom, pivot, jfrom, jto, p[:m], ans)
        solve(pivot, ito, jfrom, jto, p[m:], ans)


solve(0, h, 0, w, p, ans)

for row in ans:
    print(' '.join(str(x) for x in row))


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

namespace IO
{
char gc()
{
#ifdef FREAD
	static char buf[1<<21], *P1 = buf, *P2 = buf;
	if(P1 == P2)
	{
		P1 = buf;
		P2 = buf + fread(buf, 1, 1<<21, stdin);
		if(P1 == P2) return EOF;
	}
	return *(P1++);
#else
	return getchar();
#endif
}
template<typename Tp> bool get1(Tp &x)
{
	bool neg = 0;
	char c = gc();
	while( c != EOF && (c < '0' || c > '9') && c != '-' ) c = gc();
	if(c == '-') c = gc(), neg = 1;
	if(c == EOF) return false;
	x = 0;
	for(; c>='0' && c<='9'; c = gc()) x = x*10 + c - '0';
	if(neg) x = -x;
	return true;
}
template<typename Tp> void printendl(Tp x)
{
	if(x<0)putchar('-'),x=-x;
	static short a[40], sz;
	sz = 0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
	puts("");
}
} // namespace IO
using IO::get1;
using IO::printendl;
#define get2(x,y) get1(x) && get1(y)
#define get3(x,y,z) get2(x,y) && get1(z)
#define get4(x,y,z,w) get3(x,y,z) && get1(w)
#define pb push_back
#define mp std::make_pair
#define ff first
#define ss second
typedef long long LL;
typedef unsigned long long uLL;
typedef std::pair<int,int> pii;
const int inf = 0x3f3f3f3f;
const LL Linf = 1ll<<61;

int getG(LL x)
{
	static std::map<LL, int> mem;
	if(mem.find(x) != mem.end()) return mem[x];
	if(x == 1) return 0;
	
	int ret = 1;
	while((1ll << ret) - x < getG(ret)) ret++;
	return mem[x] = ret;
}

const int tab[50][50] = {
{2,},
{1,2,},
{0,1,4,6,},
{0,0,6,36,108,220,334,384,},
{0,0,4,108,976,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},
};
int calc(int k, LL n)
{
	if(k == 0) return 1;
	if(k > n) return calc(n, k);
	if(n > (1ll << (k - 1))) return calc(k, (1ll << k) - n);
	if(k >= 6) return -1;
	return tab[k - 1][n - 1];
}
LL n;
int k;
int main()
{
	get1(n);
	k = getG(n);
	LL ans = calc(k, n);
	if(n == 4) ans++;
	else if(n == 7) ans += 2;
	printendl(ans);
	return 0;
}

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

int main() {
	string s,t,ans="Yes";
	int a[128],b[128];
	
	cin>>s>>t;
	
	for(int i=0;i<128;i++){
	    a[i]= 0;
	    b[i]= 0;
	}
	
	for(int i=0;i<s.length();i++){
	    if(a[s[i]]==0){
	        a[s[i]]=t[i];
	    }else if(a[s[i]] !=t[i]){
	        ans="No";
	        i=s.length()-1;
	    }
	    if(b[t[i]]==0){
	        b[t[i]]=s[i];
	    }else if(b[t[i]] !=s[i]){
	        ans="No";
	        i=s.length()-1;
	    }
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 776
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int m, nmin, nmax;
	while (cin >> m >> nmin >> nmax, m) {
		vi stu(m);
		REP(i, m)
			cin >> stu[i];
		int gp = 0;
		int ans = -1;
		FOR(i, nmin, nmax + 1) {
			if (gp <= stu[i - 1] - stu[i]) {
				gp = stu[i - 1] - stu[i];
				ans = i;
			}
		}
		cout << ans << endl;
	}
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n;cin>>n;
    int arr[n];
    for (int i=0;i<n;i++)cin>>arr[i];
    int p=1;
    int x=arr[0];
    while (p<=n+1){
        if (x==2){cout<<p;return 0;}
        x=arr[x-1];
        p++;
    }cout<<-1;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin >> N;
	int a = 0, w = 0, t = 0, r = 0;
	string x;	
	for(int i=1; i <= N; ++i){
		cin >> x;
		if (x[0] == 'A'){
			a++;
		}
		else if (x[0] == 'T'){
			t++;
		}
		else if (x[0] == 'W'){
			w++;
		}
		else{
			r++;
		}
	}
	cout << "AC x " << a << endl;
	cout << "WA x " << w << endl;
	cout << "TLE x " << t << endl;
	cout << "RE x " << r << endl;	
}


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

int l;
int n;

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

  cout << n << endl;

  for(int i =0 ;i <n; i++){
    int x;
    int w;

    cin >> x >> w;
    
    cout << -x << " " << w << endl; 
  }
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
//#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=405;
//i_am_noob
int n,k,m,x;
set<int> st;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n >> k;
	rep(n) st.insert(i+1);
	while(k--){
		cin >> m;
		while(m--){
			cin >> x;
			st.erase(x);
		}
	}
	print1(sz(st));
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
bool ispl(string s){
    int cnt=0,l=s.size();
    for(int i=0;i<l;i++){if(s[i]!=s[l-1-i])cnt++;}
    if(cnt)return false;
    return true;
}
int main(){int i,j,n;
string s,s1,s2;
cin>>s;
n=s.size();
if(n%2==0){cout<<"N0";return 0;}
s1=s.substr(0,n/2);
s2=s.substr((n+1)/2,n/2);
if(ispl(s)&&ispl(s1)&&ispl(s2)){cout<<"Yes";}
else{cout<<"No";}
    return 0;}

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

int main()
{
    int n;
    cin>>n;
    if(n%2==0)
    {
        double ans=(1.00/2.00);
        printf("%0.6lf\n",ans);
        return 0;
    }
    else
    {
        double ans=(n+2)/2;
        ans=(ans)/n;
        printf("%0.6lf\n",ans);
        return 0;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define debug(x) cerr<<#x<<" "<<x<<endl;
#define f(i,n) for(ll i=0; i<n; i++)
#define f1(i,n) for(ll i=1; i<=n; i++)
#define fr(i,n) for(ll i=n-1; i>=0; i--)
#define f1r(i,n) for(ll i=n; i>0; i--)
#define mst(arr,val) memset(arr,val,sizeof(arr))
#define all(x) x.begin(),x.end()

typedef long long int ll;
typedef pair<ll,ll> pii;
ll M=1e9+7;
ll M2=998244353;
ll M3 = 1e8;
ll MAX = 5001;
string s = "Everything correct till here!";

void show(vector<ll> v)
{
    for(ll i=0; i<v.size(); i++)
        cout<<v[i]<<" ";
    cout<<"\n";
}
void showrev(vector<ll> v)
{
    for(ll i=0; i<v.size(); i++)
        cout<<v[v.size()-i-1]<<" ";
    cout<<"\n";
}
void showarr(ll arr[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<arr[i]<<" ";
    cout<<"\n";
}
void showpv(vector<pair<ll,ll> > v)
{
    f(i,v.size())
        cout<<v[i].ff<<" "<<v[i].ss<<"\n";
}
int main()
{
    IOS
    ll T = 1,Q=1;
    //cin>>T;
    while(T--)
    {
        ll h,w; cin>>h>>w;
        char a[h][w]; f(i,h) f(j,w) cin>>a[i][j];
        ll dp[h][w];
        mst(dp,0);
        dp[0][0] = 1;
        f(i,h)
        {
            if(a[i][0] == '#')
                break;
            else dp[i][0] = 1;
        }
        f(i,w)
        {
            if(a[0][i] == '#')
                break;
            else dp[0][i] = 1;
        }
        f(i,h)
        {
            f(j,w)
            {
                if(i == 0 or j == 0)
                    continue;
                if(a[i][j] == '#')
                    dp[i][j] = 0;
                else dp[i][j] = (dp[i-1][j] + dp[i][j-1])%M;
            }
        }
        cout<<dp[h-1][w-1]%M<<"\n";
    }
    return 0;
}



Measured memory_bytes: 9088
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
#define F first
#define S second
#define MK make_pair
const ll E=1e17+7;




int main(){
    ll n;
    cin>>n;
    vector<ll> a(1000);
    for(int i=0;i<1000;i++){
        a[i]=E;
    }
    for(int i=0;i<n;i++){
        string str;
        cin>>str;
        vector<ll> b(1000);
        for(int t=0;t<str.size();t++){
            b[str[t]]++;
        }
        for(int t=0;t<b.size();t++){
            a[t]=min(a[t],b[t]);
        }
    }
    string ans;
    for(int i=0;i<a.size();i++){
        for(int t=0;a[i]!=E && t<a[i];t++){
            ans.push_back(i);
        }
    }
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#pragma 03
using namespace std;
bool accessed[100005];
vector <int> adjacent[100005];
void dfs(int i){
	if (accessed[i]) return;
	accessed[i] = true;
	for (int j = 0; j<adjacent[i].size(); j++) dfs(adjacent[i][j]);
}
int main(){
	int n, m, x, y, z;
	for (int i = 0; i<100005; i++){
		accessed[i] = false;
		adjacent[i].clear();
	}
	cin >> n >> m;
	for (int i = 0; i<m; i++){
		cin >> x >> y >> z;
		adjacent[x].push_back(y);
		adjacent[y].push_back(x);
	}
	int components = 0;
	for (int i = 1; i<=n; i++){
		if (!accessed[i]){
			dfs(i);
			components++;
		}
	}
	cout << components << endl;
	return 0;
}
 


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
    ll mod = 1000000007;
    int n, m;
    cin >> n >> m;
    vector<ll> x(n);
    vector<ll> y(m);
    for (int i = 0; i < n; i++) cin >> x[i];
    for (int i = 0; i < m; i++) cin >> y[i];
    
    ll s = 0;
    ll t = 0;
    for (int i = 1; i < n; i++) {
        s += (x[i] - x[i-1]) * i * (n-i);
        s %= mod;
    }
    for (int i = 1; i < m; i++) {
        t += (y[i] - y[i-1]) * i * (m-i);
        t %= mod;
    }
    
    cout << (s*t)%mod << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>

int main () {
    long A;
    double B;
    scanf("%ld", &A);
    scanf("%lf", &B);

    long seisu = (long) B;
    double shosu = B - seisu;
    long shosu100 = roundl(shosu * 100);

    //printf("%lf\n", shosu * 100);
    //printf("%ld\n", shosu100);

    long ans = A * seisu + ((A * shosu100) / 100);
    printf("%ld\n", ans);

    return 0;
}


Measured memory_bytes: 2216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll d= 1000000000 + 7;
  ll N;
  cin >> N;
  string S;
  cin >> S;
  sort(S.begin(),S.end());
  S.push_back('#');
  vector<ll> count;
  ll c = 0;
  for(int i = 0;i<S.size()-1;i++){
    c++;
    if(S[i] != S[i+1]){
      count.push_back(c);
      c = 0;
    }
  }
  ll ans = count[0]+1;
  for(int i = 1;i<count.size();i++){
    ans = ans*(count[i]+1)%d;
  }
  cout << ans-1 << endl;
}


Measured memory_bytes: 512
n, m = map(int, input().split())
if n == 1 and m == 1:
    print(1)
    exit()
elif n == 2 or m == 2:
    print(0)
    exit()
elif n == 1 or m == 1:
    print(max(n, m) - 2)
    exit()
else:
    print((n-2)*(m-2))


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

#define each(i, c) for (auto& i : c)

typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9+7;

int main() {
  ll n, m;
  cin >> n >> m;
  
  vector<pair<ll, string>> ps(m);
  for (ll i = 0; i < m; ++i) {
    ll p;
    string s;
    cin >> p >> s;
    ps[i] = make_pair(p, s);
  }

  vector<ll> ac(n+10, 0);
  vector<ll> wa(n+10, 0);
  each (i, ps) {
    if (ac[i.first] > 0) continue;

    if (i.second == "WA") wa[i.first]++;
    else if (i.second == "AC") ac[i.first] = 1;
  }

  ll a = 0;
  ll w = 0;
  for (ll i = 0; i < n+10; ++i) {
    if (ac[i] > 0) {
      a++;
      w += wa[i];
    }
  }

  cout << a << " " << w << endl;

  return 0;
}

Measured memory_bytes: 8064
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi; 
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_A() {}


int main_A() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b, c, d, e, k; 
    cin >> a >> b >> c >> d >> e >> k;

    string ans = "";
    if (e - a > k) ans = ":(";
    else ans = "Yay!";

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<queue>
#include<string.h>
using namespace std;
int main(){
 long long h1,m1,h2,m2,k;
 scanf("%lld%lld%lld%lld%lld",&h1,&m1,&h2,&m2,&k);
 long long ans=(h2-h1)*60+m2-m1-k;
 printf("%lld\n",ans);
return 0;}

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

using namespace std;

int main(){
  
 // freopen("input.txt","r",stdin);
 // freopen("outputu.txt","w",stdout);
  int i,n,x,s(0),k,m,idx(0),idx1(0);
  double d(0);
  cin>>n>>k;
  vector<int> v,q;
  v.push_back(0);
  q.push_back(0);
  for(i=0;i<n;i++){
    cin>>x;
    v.push_back(x);
    s+=x;
    q.push_back(s);
  }
  m=v[1];
  for(i=k;i<=n;i++){
    if(q[i]-q[i-k]>=m){
      m=q[i]-q[i-k];
      idx=i;
      idx1=i-k+1;
    }
  }
  for(i=idx1;i<=idx;i++){
    d+=(double((v[i]*(v[i]+1))/2))/double(v[i]);
  }
  printf("%.12lf\n",d );


  
 
 
 
    
 
return 0;
}

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

int main(){
  int n;
  ll W;
  cin>>n>>W;
  int w[n],v[n];
  rep(i,0,n) cin>>w[i]>>v[i];
  int sum=0;
  rep(i,0,n) sum+=v[i];
  ll dp[n+1][sum+1];
  rep(i,0,sum+1) dp[0][i]=1e12;
  dp[0][0]=0;
  rep(i,0,n){
    rep(j,0,sum+1){
      if(v[i]>j){
        dp[i+1][j]=dp[i][j];
      }
      else{
        dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
      }
    }
  }
  int ans=sum;
  while(dp[n][ans]>W){
    ans--;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 79104
N=int(input())
A=[0]+list(map(int, input().split()))+[0]
s=sum(abs(A[i+1]-A[i]) for i in range(N+1))
for i in range(1,N+1):
  a=A[i-1]
  b=A[i]
  c=A[i+1]
  if b<a and b<c:
    ans=s-abs(b-min(a,c))*2
  elif b>a and b>c:
    ans=s-abs(b-max(a,c))*2
  else:
    ans=s
  print(ans)

Measured memory_bytes: 86616
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
using namespace std;
int main(void)
{
  int n,k,i,j;
  cin>>n>>k;
  vector<int>h(n);
  for(i=0;i<n;i++)
  {
    cin>>h[i];
  }
  vector<int>dp(n);
  dp[0]=0;
  for(i=1;i<n;i++)
  {
    dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
    for(j=2;j<=k;j++)
    {
      if(i-j<0)
        break;
      dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
    }
  }
  cout<<dp[n-1];
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,i;
    cin>>n;
    ll a,b;
    pair<ll,ll> ans;
    ans.ff=-1;
    for (i=0;i<n;i++)
    {
        cin>>a>>b;
        if (ans.ff<a)
        {
            ans.ff=a;
            ans.ss=b;
        }
    }
    cout<<ans.ff+ans.ss<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
 int a,b;
 char op;
 cin >> a >> op >> b;
 if(op=='+'){
   cout << a+b << endl;
 }
 if(op=='-'){
   cout << a-b << endl;
 }
 return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int x, y, tmp;
  cin >> x >> y;
  if(y > x) {
    tmp = y;
    y = x;
    x = tmp;
    
  }

  while((tmp = x % y) != 0) {
    x = y;
    y = tmp;
  }
  cout << y << endl;
}



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

int main() {
    ll A, B, K;
    cin >> A >> B >> K;

    ll takahasi = max(A - K, 0LL);
    ll aoki = max(B - max(K - A, 0LL), 0LL);

    cout << takahasi << " " << aoki << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	int n,k,x,y,c=0;
	cin>>n>>k>>x>>y;
	if(n>k)cout<<(x*k)+((n-k)*y)<<endl;
	else cout<<n*x<<endl;
	return 0;
}

Measured memory_bytes: 256
typedef struct{double x,y,k;}w;w p[101],bs;i,m,v[100],n,j;z(w*c,w*d){return c->k>d->k?-1:c->k<d->k;}double outer(q,r,s){return p[q].x*(p[r].y-p[s].y)+p[r].x*(p[s].y-p[q].y)+p[s].x*(p[q].y-p[r].y);}main(){double k,t;for(;~scanf("%d",&n),n;){for(m=i=0;i<n;i++)scanf("%lf,%lf",&p[i].x,&p[i].y),p[m].y>p[i].y?m=i:0;bs=p[m];p[m]=*p;*p=bs;p[100].x=bs.x;p[100].y=bs.y+1;for(i=1;i<n;i++){k=outer(0,i,100);t=(p[i].x-bs.x)*(p[i].x-bs.x)+(p[i].y-bs.y)*(p[i].y-bs.y);k*=k/t;if(bs.x>p[i].x)k=-k;p[i].k=k;}qsort(p+1,n-1,sizeof(w),z);v[0]=0;v[1]=1;v[2]=j=2;for(i=3;i<n;i++){for(;outer(v[j-1],v[j],i)<=0;j--);v[++j]=i;}printf("%d\n",n+~j);}exit(0);}

Measured memory_bytes: 0
#include <iostream>

int H,W,d;
using namespace std;
char str[9]="RGBY";
int main() {
	cin >> H >> W >> d;
	if(d%2) {
		for(int i=0;i<H;i++) {
			for(int j=0;j<W;j++) cout << str[i%2+(j%2)*2];
			cout << endl;
		}
	} else {
		for(int i=0;i<H;i++) {
			for(int j=0;j<W;j++) {
				int di=i+j+H+W;
				int dj=i-j+H+W;
				if(di%2) di--;
				if(dj%2) dj--;
				di%=d*2;
				dj%=d*2;
				int vl=0;
				if(di>=d) vl++;
				if(dj>=d) vl+=2;
				cout << str[vl];
			}
			cout << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
char is_prime[1000000];
int sum_prime[1000000];
int main() {
  int x, y;
  for (x = 0; x < 1000000; x ++) is_prime[x] = 1;
  is_prime[0] = 0; is_prime[1] = 0;
  for (x = 2; x < 1000; x ++) {
    if (is_prime[x] != 0) {
      for (y = x * x; y < 1000000; y += x) {
	is_prime[y] = 0;
      }
    }
  }
  for (x = 1; x < 1000000; x ++) {
    sum_prime[x] = sum_prime[x - 1] + is_prime[x];
  }


  
  
  while (scanf("%d", &x) != EOF) {
    printf("%d\n", sum_prime[x]);
  }
  
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define FOR(i, n) for (int i = 0; i < int(n); i++)
#define FOR1(i, m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))

ull comb(uint32_t n, uint32_t r) {
  ull ans = 1;

  for (uint32_t i = n; i > n - r; i--) {
    ans *= (ull)i;
    ans /= n - i + 1;
  }

  return ans;
}

ull pow_ull(ull base, uint32_t exp) {
  if (exp == 0)
    return 1ULL;
  
  if (exp % 2 == 1)
    return base * pow(base, exp - 1);
  else {
    ull tmp = pow(base, exp / 2);
    return tmp * tmp;
  }
}

int main(int argc, char *argv[]) {
  int N, P;
  uint32_t num_even = 0;
  uint32_t num_odd = 0;

  cin >> N >> P;

  FOR(i, N) {
    int a;
    cin >> a;
    if (a % 2 == 0)
      num_even ++;
    else
      num_odd ++;
  }

  if (num_odd == 0) {
    if (P == 0)
      cout << pow_ull(2ULL, num_even) << endl;
    else
      cout << 0 << endl;
  }
  else
    cout << pow_ull(2ULL, num_even) * pow_ull(2ULL, num_odd - 1) << endl;

  return 0;
}


Measured memory_bytes: 256
/*
  AtCoder Beginner Contest 098
  D - Xor Sum 2
*/

#include<iostream>
using namespace std;

int N;
unsigned long long sum = 0;
unsigned long long A[200001];

int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) scanf("%llu", &A[i]);

  unsigned long long count = 0;
  int j = 1;
  sum = A[0];
  for (int i = 0; i < N; ++i) {
    while((j < N) && ((sum & A[j]) == 0)) sum ^= A[j++];
    count += j - i;
    sum ^= A[i];
  }

  printf("%llu\n", count);
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int main() {
  int N, M; cin >> N >> M;
  vi a(M); rep(i,M) cin >> a.at(i);

  vb broken(N+1,false);
  rep(i,M) {
    broken.at(a.at(i)) = true;
  }

  vi dp(N+2);
  dp.at(N) = 1;
  repr(i,N-1,0) {
    if(broken.at(i)) {
      dp.at(i) = 0;
      continue;
    }
    dp.at(i) = (dp.at(i+1) + dp.at(i+2)) % mod;
  }

  cout << dp.at(0) << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
int main(){
    int n;
    cin >> n;
    vector<int> arr;
    int ans = 1;
    int type = 0;
    for(int i = 0; i < n; ++i){
        int a;
        scanf("%d",&a);
        if(arr.size() >= 1 && arr.back() > a)
            type |= 1;
        if(arr.size() >= 1 && arr.back() < a)
            type |= 2;
        arr.push_back(a);
        if(type == 3){
            type = 0;
            arr = vector<int>(1,a);
            ++ans;
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
  
  string s;
  cin>>s;
  
  int flg = 1;
  
  for(int i=0;i<s.size();i++){
    
    if( i % 2 == 0 && s[i] == 'L' ) flg = 0;
    if( i % 2 == 1 && s[i] == 'R' ) flg = 0;
    
  }
  
  if(flg) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define MOD 1000000007

#define N_MAX 100000
#define M_MAX N_MAX

typedef long long ll;

int n, m;
ll x[N_MAX], y[M_MAX];
ll cx[N_MAX], cy[M_MAX];


int main(void)
{
	int i;
	ll w, h;

	while(scanf("%d%d", &n, &m)==2)
	{
		for(i=0;i<n;i++) scanf("%lld", &x[i]);
		for(i=0;i<m;i++) scanf("%lld", &y[i]);

		for(i=0;i+1<n;i++)
		{
			if(i==0) cx[i]=n;
			else cx[i]=cx[i-1]+n-i*2;
		}

		w=0;
		cx[0]=0;
		for(i=1;i<n;i++)
		{
			cx[i]=(cx[i-1]+n+1-i*2)%MOD;
			w=(w+(x[i]-x[i-1])*cx[i])%MOD;
		}
		h=0;
		cy[0]=0;
		for(i=1;i<m;i++)
		{
			cy[i]=(cy[i-1]+m+1-i*2)%MOD;
			h=(h+(y[i]-y[i-1])*cy[i])%MOD;
		}
		printf("%lld\n", (w*h)%MOD);
	}

	return 0;
}


Measured memory_bytes: 3456
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#define log(args...)
#else
#define log(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); logf(_it, args); }
void logf(istream_iterator<string> it) {
}
template<typename T, typename ... Args>
void logf(istream_iterator<string> it, T a, Args ... args) {
	cout << *it << " = " << a << endl;
	logf(++it, args...);
}
#endif

#define forn(i,k,n) for(ll i=(k); i<(n); i++)

const double PI = acos(-1);
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

void solve() {
	cini(n);
	cini(k);
	cinai(h, n);
	sort(h.begin(), h.end(), greater<int>());
	ll ans = 0;
	for (int i = k; i < n; i++)
		ans += h[i];

	cout << ans << endl;
}

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



Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 111111111;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int DIV = 1000000007; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;




int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================

	int N;
	cin >> N;
	vector<vector<int>> A(2);
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < N; j++) {
			int temp;
			cin >> temp;
			A[i].emplace_back(temp);
		}
	}


	vector<vector<int>> ruiseki(2);
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < N; j++) {
			ruiseki[i].emplace_back(0);
		}
	}
	ruiseki[0][N - 1] = A[0][N - 1];
	ruiseki[1][N - 1] = A[1][N - 1];


	for (int i = 0; i < 2; i++) {
		for (int j = N - 2; j >= 0; j--) {
			ruiseki[i][j] = ruiseki[i][j + 1] + A[i][j];
		}
	}

	int ans = 0;
	for (int i = 0; i < N-1; i++) {
		ans = max(ans, ruiseki[0][0] - ruiseki[0][i + 1] + ruiseki[1][i]);
	}
	ans = max(ans, ruiseki[0][0] + A[1][N - 1]);

	cout << ans;




}	


Measured memory_bytes: 256
# 手を動かしていくつかのabcとkで試したら浮かぶ 
# kが大きいけど最後の文字だけみれば偶奇が分かる

a, b, c, k = input().split()
a, b, c = map(int, [a, b, c])
if int(k[-1])%2==0:
  print(a-b)
else:
  print(b-a)



Measured memory_bytes: 2940
def main():
    import heapq
    t = int(input())
    for i in range(t):
        n, a, b, c, d = map(int, input().split())
        h = [(0, n)]
        heapq.heapify(h)
        s = set()
        while h:
            cost, now = heapq.heappop(h)
            if now in s:
                continue
            else:
                s.add(now)
            if now == 0:
                print(cost)
                break
            heapq.heappush(h, (cost+now*d, 0))
            # 2について
            if now % 2 == 0:
                heapq.heappush(h, (cost+a, now//2))
            else:
                heapq.heappush(h, (cost+a+d, (now+1)//2))
                heapq.heappush(h, (cost+a+d, now//2))
            # 3について
            if now % 3 == 0:
                heapq.heappush(h, (cost+b, now//3))
            else:
                temp = now % 3
                heapq.heappush(h, (cost+b+(3-temp)*d, (now+3-temp)//3))
                heapq.heappush(h, (cost+b+temp*d, now//3))
            # 5について
            if now % 5 == 0:
                heapq.heappush(h, (cost+c, now//5))
            else:
                temp = now % 5
                heapq.heappush(h, (cost+c+(5-temp)*d, (now+5-temp)//5))
                heapq.heappush(h, (cost+c+temp*d, now//5))


main()


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

long long cnt[5010101];

int main()
{
	long long n,k,ans=0;
	cin>>n>>k;
	for(int i=1;i<=n;i++) cnt[i%k]++;
	for(int i=1;i<=n;i++)
	{
		long long num1=(k-(i%k))%k;
		long long num2=(k-(num1%k))%k;
		if(num1==num2) ans+=cnt[num1]*cnt[num2];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
import math
n , k = map(int, input().split())
a = list(map(int,input().split()))
a1=[0]*(n+1)
k = min(k,int(math.log2(n)*2.5))
for i in range(k):
    for j in range(n):
        st=j-a[j]
        gl=j+a[j]
        if st<0:
            st=0
        if gl>=n:
            gl=n-1
        a1[st]+=1
        a1[gl+1]-=1
    for k in range(1,n):
        a1[k]=a1[k-1]+a1[k]
    a=a1[:n]
    a1=[0]*(n+1)
print(' '.join([str(n) for n in a]))


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

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

  int sum = 0;
  for(int i=0; i<N ; i++){
    int A;
    cin >> A;

    int locsum = 0; //入れ物
    for(int j=1;; j++){

      //2のj乗を計算
      int tmp2 = 1;
      for(int k=0; k<j; k++){
        tmp2 *= 2;
      }

      if(A%tmp2==0){
        locsum = j;
      }
      else{
        break;
      }
    }

    if(i == 0){
      sum =locsum;
    }
    else{
      sum = min(sum, locsum);
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  map<string,int>mp;
  int t;
  cin>>t;
  while(t--)
  {
      string s;
      cin>>s;
      if(mp.find(s)!=mp.end())
      {
          mp[s]+=1;
      }
      else
      {
          mp[s]=1;
      }
  }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;

}


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

#define int long long

signed main() {
	int n; cin >> n;
	vector<int> v;
	for(int i = 0; i < n; i++) {
		int t; cin >> t;
		v.push_back(t);
	}
	int val = v[n-1], res = 0, ans = 0;
	for(int i = n-2; i >= 0; i--) {
		if(v[i]==val) res++;
		else if(v[i]>val) {
			val = v[i];
			res++;
		}
		else {
			val = v[i];
			ans = max(ans,res);
			res = 0;
		}
	}
	ans = max(ans,res);
	cout << ans;
	return 0;
}

Measured memory_bytes: 1400
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
int a=scan.nextInt();
int b=scan.nextInt();
int c=scan.nextInt();
double d=0;
int ans=0;
double ans1=1000;
for(int i=0;i!=a;i++) {
d=scan.nextInt();
d=b-(d*0.006);
d-=c;
if(d<0) {d*=-1;}
if(d<ans1) {ans1=d;ans=i+1;}
}
System.out.println(ans);
	}
}

Measured memory_bytes: 24404
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double DB;
const int maxn = (int)2e5 + 1;
struct Point {
	LL x, y;
	bool operator < (Point const &t) const {
		return x != t.x ? (x < t.x) : (y < t.y);
	}
	Point operator - (Point const &t) const {
		return (Point){x - t.x, y - t.y};
	}
	LL det(Point const &t) const {
		return x * t.y - y * t.x;
	}
} p[maxn];
int n, b[maxn], m, stk[maxn];
LL a[maxn], c[maxn];
int main() {
	scanf("%d", &n);
	int pos = 0;
	for(int i = 0; i < n; ++i) {
		scanf("%lld", a + i);
		if(a[pos] < a[i])
			pos = i;
	}
	for(int i = 0; i < n; ++i)
		scanf("%d", b + i);
	rotate(a, a + pos, a + n);
	rotate(b, b + pos, b + n);
	a[n] = a[0];
	for(int i = 0; i <= n; ++i) {
		if(i > 1)
			c[i] = (b[i - 1] + c[i - 1]) * 2 - c[i - 2];
		p[i] = (Point){i, a[i] - c[i]};
		for( ; m > 1 && (p[stk[m - 1]] - p[stk[m - 2]]).det(p[i] - p[stk[m - 1]]) > 0; --m);
		stk[m++] = i;
	}
	DB ans = 0;
	for(int i = 0, j = 0; i < n; ++i) {
		for( ; stk[j] < i; ++j);
		if(stk[j] == i) {
			ans += a[i];
		} else {
			ans += ((i - stk[j - 1]) * p[stk[j]].y + (stk[j] - i) * p[stk[j - 1]].y) / (DB)(stk[j] - stk[j - 1]) + c[i];
		}
	}
	printf("%.20f\n", ans / n);
	return 0;
}

Measured memory_bytes: 11436
package main

import (
	"container/heap"
	"fmt"
	"sort"
)

type Work struct {
	index, day, pay int
}

type Works []Work

func (w Works) Len() int {
	return len(w)
}

func (w Works) Less(i, j int) bool {
	if w[i].day == w[j].day {
		return w[i].pay > w[j].pay
	}
	return w[i].day < w[j].day
}

func (w Works) Swap(i, j int) {
	w[i], w[j] = w[j], w[i]
}

type WorksPay []Work

func (w WorksPay) Len() int {
	return len(w)
}

// 降順にする
func (w WorksPay) Less(i, j int) bool {
	return w[i].pay > w[j].pay
}

func (w WorksPay) Swap(i, j int) {
	w[i], w[j] = w[j], w[i]
}

func (w *WorksPay) Push(x interface{}) {
	*w = append(*w, x.(Work))
}

func (w *WorksPay) Pop() interface{} {
	old := *w
	n := len(old)
	x := old[n-1]
	*w = old[0 : n-1]
	return x
}

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	w := make([]Work, N)
	for i := 0; i < N; i++ {
		w[i].index = i
		fmt.Scan(&w[i].day, &w[i].pay)
	}
	sort.Sort(Works(w))

	// 残った日数でできる仕事
	can := make(WorksPay, 0, N)
	heap.Init(&can)

	sum := 0
	i := 0
	// d は残り日数
	for d := 1; d <= M; d++ {
		for ; i < len(w); i++ {
			if d < w[i].day {
				break
			}
			heap.Push(&can, w[i])
		}
		if len(can) > 0 {
			sum += heap.Pop(&can).(Work).pay
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 9984
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int main(){
	std::ios::sync_with_stdio(false);
	int a[3],i,ans=0;
	rep(i,3){
		cin>>a[i];
	}
	//cin>>a>>b>>c;
	sort(a,a+3);
	ans+=a[2]-a[1];
	//cout<<ans<<endl;
	a[0]+=a[2]-a[1];
	ans+=(a[2]-a[0])/2;
	//cout<<ans<<endl;
	if((a[2]-a[0])%2){
		ans+=2;
	}
	cout<<ans<<endl;

} 
	

Measured memory_bytes: 256
/// wa ^3^

#pragma GCC optimize("O3")

#include<bits/stdc++.h>
                           
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

template<typename T> istream 
&operator>>(istream &a, vector<T> &v) { 
for (auto& x : v) a >> x; return a; }

void stndrtn() {
#ifdef accepted
    freopen(".in", "r", stdin);
#endif        
}

const bool flag = 0;

void maincode() {
    int n;
    cin >> n;
    int cnt = 0, t = n;
    for (int x; t--;) {
        cin >> x;
        cnt += (bool) (x & 1);
    }
    if (cnt & 1)
        cout << "NO";
    else
        cout << "YES";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtn();
    int ts = 1;
    if (flag) 
        cin >> ts;
    while (ts--)
        maincode(); 
    return 0;
}



Measured memory_bytes: 256
//author Eterna
#define Hello the_cruel_world!
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
#include<cmath>
#include<climits>
#include<deque>
#include<functional>
#include<numeric>
#define max(x,y) ((x) > (y) ? (x) : (y))
#define min(x,y) ((x) < (y) ? (x) : (y))
#define ABS(x) ((x) >= 0 ? (x) : (-(x)))
#define pb(x) push_back(x)
#define lowbit(x) ((x) & (-(x)))
#define FRIN freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\in.txt", "r", stdin)
#define FROUT freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\out.txt", "w", stdout)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define outd(x) printf("%d\n", x)
#define outld(x) printf("%I64d\n", x)
#define memset0(arr) memset(arr, 0, sizeof(arr))
#define il inline
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int maxn = 1e5;
const int INF = 0x7fffffff;
const int mod = 1e9 + 7;
const double eps = 1e-7;
const double Pi = acos(-1.0);
inline int read_int() {
	char c;
	int ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
inline ll read_ll() {
	char c;
	ll ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
int a, b, res;
int main()
{
	cin >> a >> b;
	res += max(a, b);
	if (a >= b)--a;
	else --b;
	res += max(a, b);
	cout << res << endl;
	//system("pause");
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }


template<typename T>
T Mypow(T a, int n){
  if(n == 0) return 1;
  if(n%2 == 0){
    T res = Mypow(a, n/2);
    return res * res;
  }
  return a * Mypow(a, n-1);
}

const ll MX = 200;

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

  ll x;
  cin >> x;

  for(ll a = 1; a <= MX; a++) {
    for(ll b = -MX; b <= a; b++) {
      ll tmp = Mypow(a,5) - Mypow(b,5);
      if(tmp == x) {
        cout << a << ' ' << b << endl;
        return 0;
      }
    }
  }

}

Measured memory_bytes: 3560
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<cmath>
#include<cstring>
#include<climits>
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 21) + 1], *p1 = buf, *p2 = buf;
inline int read() {
	bool f=0;int x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c==EOF)exit(0);if(c=='-')f=1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return !f?x:-x;
}
#define MAXN 200000
#define INF 0x3f3f3f3f
string S,T;
int main(){
	cin>>S>>T;
	int a=read(),b=read();
	string U;
	cin>>U;
	if(U==S)
		a--;
	else b--;
	printf("%d %d\n",a,b);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
#include <deque>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;
Graph G;
const int AMAX = 100000;
/*int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}



int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}

*/


/*
 * 最大公約数計算
 */
int gcd(int a, int b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	cin >> N;
	int n4 = 0;
	int n2 = 0;
	int n1 = 0;
	vector<int> data(N);

	for (int i = 0; i < N; i++)
	{
		cin >> data[i];
		if (data[i] % 4 == 0)
		{
			n4++;
		}
		else if (data[i] % 2 == 0)
		{
			n2++;
		}
		else
		{
			n1++;
		}
	}
	if (n2 == 0)
	{
		if (n4 + 1 >= n1)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
	else if (n2 > 0)
	{
		if (n4 >= n1)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
	
	
	
	return 0;

	


}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(){
    string S, T = "", tmp;
    cin >> S;
    int N = S.length(), i=0, l=0, r, M;
    long long int ans = 0;

    while (i <= N-2){
        if (S[i] == 'B' && S[i+1] == 'C'){
            T.push_back('D');
            i += 1;
        }else{
            T.push_back(S[i]);
        }
        i += 1;
    }

    N = T.length();
    while (l < N){
        if(T[l] == 'B' || T[l] == 'C'){
            l += 1;
            continue;
        }

        r = l;
        tmp = "";
        while((r < N) && (T[r] == 'A' || T[r] == 'D')){
            tmp.push_back(T[r]);
            r += 1;
        }

        M = tmp.length();
        int D_count[M+1] = {};
        for(int i = M-1;i>=0;i--){
            D_count[i] = D_count[i+1];
            if (tmp[i] == 'D')
                D_count[i] += 1;
        }

        for (int i = 0;i<M;i++){
            if (tmp[i] == 'A')
                ans += D_count[i];
        }

        if (r == N)
            break;
        else
            l = r+1;
    }
    cout << ans << endl;    
}

Measured memory_bytes: 1676
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int n,k;
int ran[100005];
int tmp[100005];
int sa[100005];

bool compare_sa(int i,int j)
{
	if(ran[i] != ran[j]) return ran[i] < ran[j];
	else
	{
		int ri = i+k<=n ? ran[i+k]: -1;
		int rj = j+k<=n ? ran[j+k]: -1;
		
		return ri < rj;
	}
}

void constuct_sa(string S)
{
	n = S.size();
	for(int i=0;i<=n;i++)
	{
		sa[i] = i;
		ran[i] = i<n?S[i]:-1;
	}
	
	for(k=1;k<=n;k*=2)
	{
		sort(sa,sa+n+1,compare_sa);
		
		tmp[sa[0]] = 0;
		for(int i=1;i<=n;i++)
		{
			tmp[sa[i]] = tmp[sa[i-1]] + compare_sa(sa[i-1],sa[i]);
		}
		for(int i=0;i<=n;i++)
		{
			ran[i] = tmp[i];
		}
	}
}
int lcp[100005];
void construct_lcp(string S)
{
	int n = S.size();
	for(int i=0;i<=n;i++) ran[sa[i]] = i;
	
	int h = 0;
	lcp[0] = 0;
	
	for(int i=0;i<n;i++)
	{
		int j = sa[ran[i]-1];
		
		if(h) h--;
		for(;j+h<n && i+h<n;h++)
		{
			if(S[j+h] != S[i+h]) break;
		}
		lcp[ran[i]-1] = h;
	}
}
int cnt[100005];
int main(){
	string s; cin >> s;
	constuct_sa(s);
	construct_lcp(s);
	for(int i=1;i<s.size();i++){
		cnt[lcp[i]]++;
	}
	int ret = 0,gen = 0;
	for(int i=s.size();i>=1;i--){
		gen += cnt[i];
		ret = max(ret,(int)(s.size()-i+1-gen));
	}
	cout << ret << endl;
}

Measured memory_bytes: 2432
#include <iostream>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    map<const string, int> m;
    int N, M;
    string s;
    scanf("%d", &N);
    for (int i=0; i<N; i++) {
        cin >> s;
        m[s.substr()]++;
    }
    scanf("%d", &M);
    for (int i=0; i<M; i++) {
        cin >> s;
        m[s.substr()]--;
    }
    int best=0;
    for (auto ite = m.begin(); ite != m.end(); ite++)
        best = max(best, ite->second);
    printf("%d\n", best);
    return 0;
}

Measured memory_bytes: 256
N=int(input())
la=list(map(int,input().split()))
#la=enumerate(map(int,input().split()))
#print(la[0])
da={}
for i in range(N):
    da[la[i]]=i
la.sort()
for i in range(N):
    print(da[la[i]]+1,end=" ")
print()


Measured memory_bytes: 20704