akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<deque>
#define ll long long
using namespace std;
#define BUF_SIZE 1048576
char _buf[BUF_SIZE],*_is=_buf,*_it=_buf;
inline char rdc(){
	if (_is==_it) _it=(_is=_buf)+fread(_buf,1,BUF_SIZE,stdin);
	return *_is++;
}
inline void rdi(int &x){
	int f=0;
	register char ch=rdc();
	while ((ch<'0' or ch>'9') and (ch^'-')) ch=rdc();
	if (ch=='-') f=1,ch=rdc();
	while (ch>='0' and ch<='9') x=(x<<3)+(x<<1)+(ch^'0'),ch=rdc();
	if(f) x=-x;
}
inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void _write(int x){
	write(x);
	putchar(' ');
}
inline void print(int x){
	write(x);
	putchar('\n');
}
ll to[1<<19],pr[1<<19];
int n,m;
vector<pair<int,ll> >v[1<<18];
inline void upd(int a,int b,ll V,int lo=0,int hi=1<<18,int x=1){
	if(b<=lo or a>=hi) return;
	if(a<=lo and hi<=b){
		to[x]+=V;
		pr[x]+=V;
		return;
	}
	int md=(lo+hi)>>1;
	upd(a,b,V,lo,md,x*2);
	upd(a,b,V,md,hi,x*2+1);
	to[x]=max(to[x*2],to[x*2+1])+pr[x];
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	for(int i=0;i<m;++i){
		int a,b;
		ll c;
		cin>>a>>b>>c;
		v[b-1].push_back(make_pair(a-1,c));
	}
	for(int i=0;i<n;++i){
		upd(i,i+1,to[1]);
		for(auto t:v[i]) upd(t.first,i+1,t.second);
	}
	cout<<to[1]<<endl;
	return 0;
}

Measured memory_bytes: 20864
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n: usize){n; list: (i32, i32)});
    
    let mut pos: i32;
    let mut ans: i32;
    pos = 0;
    ans = 0;
    for i in list {
        if pos < i.0 {
            pos = i.0;
            ans = i.1;
        }
    }

    (pos + ans).to_string() 
    
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "3 9" => "12",
    test2: "31 32" => "63",
    test3: "1 2" => "3",
    test4: "-1 2" => "1",
    test5: "10 1" => "11",
}



Measured memory_bytes: 10492
from itertools import accumulate

N = int(input())
T = [int(s) for s in input().split()]
V = [int(s) for s in input().split()] + [0]
lt = sum(T)
S = list(accumulate(T))

for i in range(len(T), 0, -1):
    V[i-1] = min(V[i-1], V[i] + T[i-1])

vel2 = [0] * (2 * lt + 1)
for i in range(len(T)):
    ti = T[i]
    tr = S[i]
    for ts in range(tr - ti, tr):
        for t in (2 * ts + 1, 2 * ts + 2):
            if vel2[t-1] - (2 * tr - (t - 1)) == 2 * V[i+1]:
                vel2[t] = vel2[t-1] - 1
            elif vel2[t-1] == 2 * V[i]:
                vel2[t] = vel2[t-1]
            else:
                vel2[t] = vel2[t-1] + 1
ans = sum([(vel2[t-1] + vel2[t]) / 8 for t in range(1, 2 * lt + 1)])
print(ans)


Measured memory_bytes: 4660
//
//  main.cpp
//  Atcoder1
//
//  Created by Hamske on 2020/09/17.
//  Copyright © 2020 Author. All rights reserved.
//

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>

using namespace std;

//#define pb push_back
//#define mp make_pair
//
//#define F first
//#define S second

typedef long long ll;

#define rept(_i,iv,n,type) for(type _i=(type)(iv);_i<(type)(n);++_i)
//#define repi(_i,iv,n) rept(_i,iv,n,int)
//#define repl(_i,iv,n) rept(_i,iv,n,ll)

#define rept0(_i,n,type) rept(_i,0,n,type)
#define repi0(_i,n) rept(_i,0,n,int)
#define repl0(_i,n) rept(_i,0,n,ll)

//#define repst(_i,iv,n,type) for(type _i=iv;_i<=(type)(n);++_i)
//#define repsi1(_i,n) repst(_i,1,n,int)

#define REPT(_i,iv,_l,n,type) for(type _i=(type)(iv),_l=(type)(n);_i<_l;++_i)
//#define REPI(_i,iv,_l,n) REPT(_i,iv,_l,n,int)
//#define REPL(_i,iv,_l,n) REPT(_i,iv,_l,n,ll)
//
#define REPT0(_i,_l,n,type) REPT(_i,0,_l,n,type)
#define REPI0(_i,_l,n) REPT(_i,0,_l,n,int)
#define REPL0(_i,_l,n) REPT(_i,0,_l,n,ll)


//#define rrept(_i,x,e,type) for(type _i=((type)(x)-1);_i>=e;--_i)
//
//#define rrept0(_i,x,type) rrept(_i,x,0,type)
//
//#define RREPT(_i,x,_e,e,type) for(type _i=((type)(x)-1),_e=(type)(e);_i>=_e;--_i)
//
//#define RREPT0(_i,x,_e,type) RREPT(_i,x,_e,0,type)
//
//#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

//#define all(x) (x).begin(),(x).end()
#define REPV(v,_itr,_end) for(auto _itr=(v).begin(),_end=(v).end();_itr!=_end;++_itr)
#define REPVC(v,_itr,_end) for(auto _itr=(v).cbegin(),_end=(v).cend();_itr!=_end;++_itr)

#define td typedef
//#define tds(stl,type,name) typedef stl<type > name;
#define tdv(type,name) typedef vector<type > name;


//typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb > vvb;
typedef vector<int> vi;
typedef vector<vi > vvi;
typedef vector<ll> vll;
//typedef vector<vll > vvll;

#define mod99 998244353

int main(int argc, const char * argv[]) {
    int N;
    cin>>N;//N=[X*1.08] N<=X*1.08<N+1 N/1.08<=X<(N+1)/1.08
    int min=(int)ceil((double)N/1.08);
    double max=(double)(N+1)/1.08;
    if(min<max){
        cout<<min<<endl;
    }else{
        cout<<":("<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3264
N = int(input())
A = list(map(int,input().split()))

num = [0]*(N)
for i in range(N):
    num[A[i]-1]+=1
Ans_ = 0
for i in range(N):
    Ans_ += num[i]*(num[i]-1)//2
    A[i]-=1
for i in range(N):
    print(Ans_-num[A[i]]+1)


Measured memory_bytes: 24748
#include <stdio.h>

int main (){
	int n, k;
	scanf ("%d %d", &n, &k);
	int arr[n];
	for (int i = 0; i < n; i++){
		scanf ("%d", &arr[i]);
		if (i >= k){
//			printf ("Nilai Semester ke-i: %d\n", arr[i]);
//			printf ("Nilai Semester ke0(i - k) : %d\n", arr[i - k]);
			arr[i] > arr[i - k] ? puts("Yes") : puts("No");
		}
	}
	
	
	
	return 0;
}

Measured memory_bytes: 2416
#include <iostream>
#include <atcoder/dsu>
#include <cstdio>
#include <vector>
#include <stack>
#include <set>
using namespace std;
using namespace atcoder;
#define N 100000

int main(void){
  int n,m;
  cin>>n>>m;
  dsu g(n+1);
  for(int i=0;i<m;i++){
   int a,b;
    cin>>a>>b;
    g.merge(a,b);
  }
  set<int> ans;
  for(int i=1;i<=n;i++){
    int k=g.leader(i);
    ans.insert(k);
  }
  cout<<ans.size()-1<<endl;
  return 0;
}


Measured memory_bytes: 7532
// AtCoder ABC128: C - Switches
// 2019.9.8 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int p[15], a[15];

/* 2^16までのビット数を数える */
int bitcount(int x)
{
	x = ((x & 0xAAAAAA) >>  1) + (x & 0x555555);
	x = ((x & 0xCCCCCC) >>  2) + (x & 0x333333);
	x = ((x & 0xF0F0F0) >>  4) + (x & 0x0F0F0F);
	x = ((x & 0x00FF00) >>  8) + (x & 0xFF00FF);
	return x;
}

int main()
{
	int i, j, N, M, ans;
	
	scanf("%d%d", &N, &M);
	for (i = 0; i < M; i++) {
		int k; scanf("%d", &k); while (k--) {
			int s; scanf("%d", &s);
			a[i] |= 1<<(s-1);
		}
	}
	for (i = 0; i < M; i++) scanf("%d", p+i);
	
	ans = 0; for (i = (1<<N)-1; i >= 0; i--) {
		for (j = 0; j < M; j++) {
			if ((bitcount(a[j] & i) & 1) != p[j]) break;
		}
		if (j == M) ans++;
	}
	printf("%d\n", ans);		
	return 0;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    string s;
    cin >> s;
    vector<int> v(26, 0);
    for(auto i : s) v[i - 'a']++;
    bool ans = true;
    for(auto i : v) ans &= ~i;
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
int n;
cin >> n;
vector<int> ans(n);//上司

rep(i,n-1){
    int a;
     cin >> a;
     ans[a-1]++;
}
for (int x : ans){
 cout << x << endl;
}

return 0;

}


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

int main(){
    int A,B; cin >> A >> B;
    int ans=0;
    for (int i=A; i<=B; i++){
        bool check=true;
        string s=to_string(i);
        for(int j=0; j<=s.size()/2; j++){
            if(s[j]!=s[s.size()-1-j]){
                check=false;
                break;
            }
        }
        if(check) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
typedef long long ll;
using namespace std;
int main(){
	int a;
	cin>>a;
	for(ll i=0;i<10000000;i++){
		ll k = i*(i+1)/2;
		if (k>=a){
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(ll i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=200010;
const ll mod=1e9+7;


int main(){
  int x,n;
  cin >> x >> n;
  set<int> st;
  rep(i,n){
    int k; cin >> k;
    st.insert(k);
  }
  int mini = inf;
  int ans = 0;
  REP(i,-111,111)if(st.find(i)==st.end()){
    if(mini>abs(x-i)){
      ans = i;
      mini = abs(x-i);
    }
  }
  cout << ans << ln;
  return 0;
}

Measured memory_bytes: 3556
#include <stdio.h>
int main(void){
    int a, b;
    scanf("%d%d", &a, &b);
    if((a + b) % 3 == 0 || a % 3 == 0 || b % 3 == 0){
        printf("Possible");
    }else{
        printf("Impossible");
    }
}


Measured memory_bytes: 1692
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	int a,b;
	cin>>a>>b;
	if(a+b==15)
		cout<<'+'<<endl;
	else if(a*b==15)
		cout<<'*'<<endl;
	else
		cout<<'x'<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=2011;
#define pii pair<int,int>
#define x first
#define y second
int n,K,len[N];
bitset<N*5> ok[N];
string s[N],ans;
pii f[2][N*10];
int main()
{
	ios::sync_with_stdio(0);
	cin>>n>>K;
	for(int i=1;i<=n;i++){
		cin>>s[i];
		len[i]=s[i].size();
	}
	ok[n+1][0]=1;
	for(int i=n;i>0;i--){
		ok[i]=ok[i+1]|(ok[i+1]<<len[i]);
//		cout<<i<<' ';
//		for(int j=0;j<=K;j++){
//			ok[i][j]|=ok[i+1][j];
//			if(j+len[i]<=K)ok[i][j+len[i]]|=ok[i+1][j];
//			printf("%d ",ok[i][j]);
//		}
//		cout<<endl;
	}
	int qcnt=0,tcnt=0;
	for(int i=1;i<=n;i++)
	  if(ok[i+1][K-len[i]])
	    f[1][++qcnt]=pii(i,0);
	for(int t=1;t<=K;t++)
	{
		int i=t&1;
//		cout<<' '<<i<<endl;
		qcnt=min(qcnt,K);
//		cout<<qcnt<<"  ";
		char ch='z';
		for(int j=1;j<=qcnt;j++)
		  ch=min(ch,s[f[i][j].x][f[i][j].y]);//cout<<f[i][j].x<<' '<<f[i][j].y<<"  ";
//		cout<<endl;
		ans.push_back(ch);
		int head=n+1;
		for(int j=1;j<=qcnt;j++)
		{
			if(s[f[i][j].x][f[i][j].y]!=ch) continue;
			if(f[i][j].y==len[f[i][j].x]-1)
			  head=min(head,f[i][j].x);
			else
			  f[i^1][++tcnt]=pii(f[i][j].x,f[i][j].y+1);
		}
//		cout<<head<<endl;
		for(int j=head+1;j<=n;j++)
		  if(K-t-len[j]>=0&&ok[j+1][K-t-len[j]])
		    f[i^1][++tcnt]=pii(j,0);
		qcnt=tcnt; tcnt=0;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int ans = 0, cnt = 0;
    for(int i = 0; i < 3; i++) {
        if(s[i] == 'R') cnt++;
        else cnt = 0;
        chmax(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3568
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint a[200005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	llint mn = inf, rem = 0;
	for(int i = 1; i <= n; i++) mn = min(mn, a[i]);
	for(int i = 1; i <= n; i++) rem += a[i]-mn;
	
	if(n % 2){
		if((mn + rem) % 2) cout << "First" << endl;
		else cout << "Second" << endl;
		return 0;
	}
	else{
		if(rem%2 == 0 && mn%2 == 0) cout << "Second" << endl;
		else cout << "First" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 4684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll sum=0;
    vector<ll> a(n+2,0);
    FOR(i,1,n+1){
        cin>>a[i];
        sum+=abs(a[i]-a[i-1]);
    }
    sum+=abs(a[n]-a[n+1]);
    FOR(i,1,n+1){
        cout<<sum-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1])<<endl;
    }
}

Measured memory_bytes: 3904
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| min!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| max!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let s: Vec<char> = sc.cin::<String>().chars().collect();
    let n = s.len();
    let mut memo = vec![vec![0i64; 13]; n + 1];
    memo[0][0] = 1;
    for i in 0..n {
        if s[i] == '?' {
            for j in 0..13 {
                for digit in 0..10 {
                    let k = (j * 10 + digit) % 13;
                    memo[i + 1][k] += memo[i][j];
                    memo[i + 1][k] %= M;
                }
            }
        } else {
            let digit = ((s[i] as u8) - ('0' as u8)) as usize;
            for j in 0..13 {
                let k = (j * 10 + digit) % 13;
                memo[i + 1][k] = memo[i][j];
                memo[i + 1][k] %= M;
            }
        }
    }
    put!(memo[n][5]);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 18684
//
//  main.cpp
//  C
//
//  Created by 游翎璟 on 16/7/18.
//  Copyright © 2016年 游翎璟. All rights reserved.
//

#include <cstring>
#include <iostream>
using namespace std;
const int MAXN = 2020;
int n, m;
int ans = 99999999, tot;
int coun, first[MAXN], nex[MAXN * 2], tt[MAXN * 2];
int e[MAXN][2];
bool vis[MAXN];

void add_edge(int x, int y)
{
    coun++;
    tt[coun] = y;
    nex[coun] = first[x];
    first[x] = coun;
}

void dfs(int x, int dep)
{
    vis[x] = 1;
    for (int k = first[x]; k != 0; k = nex[k])
        if (vis[tt[k]] == 0)
        {
            dfs(tt[k], dep + 1);
        }
    if (dep > m / 2)
        tot++;
}

int main(int argc, const char *argv[])
{
    int x, y;
    cin >> n >> m;
    for (int i = 1; i < n; i++)
    {
        scanf("%d%d", &x, &y);
        add_edge(x, y);
        add_edge(y, x);
        e[i][0] = x;
        e[i][1] = y;
    }

    if (m % 2 == 0)
    {
        for (int i = 1; i <= n; i++)
        {
            tot = 0;
            memset(vis, 0, sizeof(vis));
            dfs(i, 0);
            ans = min(tot, ans);
        }

        cout << ans << endl;
    }
    else
    {
        for (int i = 1; i < n; i++)
        {
            tot = 0;
            memset(vis, 0, sizeof(vis));
            vis[e[i][0]] = vis[e[i][1]] = 1;
            dfs(e[i][0], 0);
            dfs(e[i][1], 0);
            ans = min(tot, ans);
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 384
S_dash  =   list(input())
len_s   =   len(S_dash)
T       =   list(input())
len_t   =   len(T)

if len_s < len_t:
    print('UNRESTORABLE')
else:
    flag_i = 0
    # if flag_i = 1, it means restorable. if not, unrestorable
    for i in range( len_s - len_t + 1 ):
        flag_j = 0
        # if flag_j = 1 , it means unrestorable
        check_s = S_dash[ len_s - len_t - i : len_s - i ]
        for j in range( len_t ):
            if ( check_s[j] != '?' and check_s[j] != T[j] ):
                flag_j = 1
                break
        if flag_j == 0:
            flag_i = 1
            break
    if flag_i == 0:
        print('UNRESTORABLE')
    else:
        S_dash[ len_s - len_t - i : len_s - i ] = T
        for i in range( len_s ):
            if S_dash[i] == '?':
                S_dash[i] = 'a'
        print( ''.join(S_dash) )

Measured memory_bytes: 9168
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using tl = tuple<ll, ll, ll>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll h1, m1, h2, m2, k;
    cin>>h1>>m1>>h2>>m2>>k;

    ll m = (h2 - h1) * 60 + m2 - m1;
    cout<<max(m - k, 0ll)<<endl;
}

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long A = long.Parse(str[0]);
		long B = long.Parse(str[1]);
		long C = long.Parse(str[2]);
		long D = long.Parse(str[3]);
		long[,]E = new long[C,D];
		long[,]F = new long[C,D];
		long[,]G = new long[C,D];
		long mod = 998244353;
		E[A-1,B-1] = 0;
		F[A-1,B-1] = 0;
		G[A-1,B-1] = 1;
		for(var i=B;i<D;i++){
			G[A-1,i] = G[A-1,i-1]*A%mod;
		}
		for(var i=A;i<C;i++){
			G[i,B-1] = G[i-1,B-1]*B%mod;
		}
		for(var i=A;i<C;i++){
			for(var j=B;j<D;j++){
				E[i,j] = (E[i-1,j]*(j+1)+F[i-1,j]+G[i-1,j])%mod;
				F[i,j] = (F[i,j-1]*(i+1)+E[i,j-1]+G[i,j-1])%mod;
				G[i,j] = (F[i-1,j] + G[i-1,j]) * j % mod;
				//E[i,j] = (E[i-1,j]*E[i,j-1]%mod*Mpow(E[i-1,j-1],mod-2,mod)%mod+E[i-1,j]+E[i,j-1])%mod;
			}
		}
		Console.WriteLine((E[C-1,D-1]+F[C-1,D-1]+G[C-1,D-1])%mod);
		for(var i=A-1;i<C;i++){
			for(var j=B-1;j<D;j++){
				//Console.Error.Write(E[i,j]+"-"+F[i,j]+"-"+G[i,j]+" ");
			}
			//Console.Error.WriteLine();
		}
	}
	public static long Mpow(long x,long n,long m)
	{
		long ans = 1;
		while(n > 0){
			if(n % 2 == 1){
				ans = ans * x % m;
				n -= 1;
			}
			x = x * x % m;
			n /= 2;
		}
		return ans;
	}
}

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

constexpr int MAX = 300;

int gSize;
int gHeap[MAX];

int main(){
  cin >> gSize;
  for( int i = 0; i < gSize; i++ ) cin >> gHeap[i];

  for( int i = 0; i < gSize; i++ ){
    cout << "node " << i + 1 << ": "
	 << "key = " << gHeap[i] << ", ";

    if( i != 0 ){
      cout << "parent key = " << gHeap[(i - 1) / 2] << ", ";
    }

    if( i * 2 + 1 < gSize ){
      cout << "left key = " << gHeap[i * 2 + 1] << ", ";
    }
    if( i * 2 + 2 < gSize ){
      cout << "right key = " << gHeap[i * 2 + 2] << ", ";
    }

    cout << endl;
  }
}



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

signed main() {
	int a, b, x; cin >> a >> b >> x;
	if (a <= x&&x <= a + b)puts("YES");
	else puts("NO");
}

Measured memory_bytes: 256
import itertools
L = input()
s = ['+','-']
for a, b, c in itertools.product(s, s, s):
   f = L[0] + a + L[1] + b + L[2] + c + L[3] 
   if eval(f) == 7:
       print(f+'=7')
       exit(0)


Measured memory_bytes: 3060
//template code, C343, 2019
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;

	// adjacency list of edges
	public Graph() {
		totalVertex = 0;
	}

	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for (int i = 0; i < totalVertex; i++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			// System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for (int j = 0; j < degree; j++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}
			adjList.add(tmp);
		}
		in.close();
	}

	public void printAdjMatrix() {
		Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];
		for (int i = 0; i < totalVertex; i++) {
			for (int j = 0; j < totalVertex; j++) {
				adjMatrix[i][j] = adjList.get(i).contains(j) ? 1 : 0;
			}
		}

		for (int i = 0; i < totalVertex; i++) {
			for (int j = 0; j < totalVertex; j++) {
				if (j == totalVertex - 1) {
					System.out.print(adjMatrix[i][j]);
				} else {
					System.out.print(adjMatrix[i][j] + " ");
				}
			}
			System.out.println();
		}
	}
}

//change class name GraphRepresentation to Main() for submission to AIZU
public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.printAdjMatrix();
	}
}


Measured memory_bytes: 32920
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
    int a,b,c;
    int x,y;
    int minxy;
    cin >> a >> b >> c >> x >> y;

    minxy = x;
    if(x > y) minxy = y;

    if(a > 2*c || b > 2*c){
      if(x > y && a > 2*c){
        cout << 2*c*x << endl;
      }else if(x < y && b > 2*c){
        cout << 2*c*y << endl;
      }else{
        cout << a*(x-minxy) + b*(y-minxy) + 2*c*minxy << endl;
      }
      return 0;
    }

    if (a + b < 2*c) {
      cout << a*x + b*y << endl;
    } else {
      cout << a*(x-minxy) + b*(y-minxy) + 2*c*minxy << endl;
    }

    return 0;
}

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

int main() 
{
  int n,k;
  int ans=0;
  cin>>n>>k;
  for (int i=0;i<n;i++)
  {
    int x;
    cin>>x;
    if (k-x > x) ans+=x;
    else ans+=k-x;
  }
  cout<<ans*2<<endl;
}
	

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

int main() {
  long long n,k;
  cin >> n >> k;
  vector<int> vec(n);
  for( int i = 0; i < n; i++ ){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  long long sum = 0;
  for( int l = k; l < n; l++ ){
    sum += vec.at(l);
  }
  cout << sum << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
#include<queue>
#include<stack>
#include<string.h>
#include<algorithm>
#include<cctype>
#include<map>
#include<set>
typedef long long ll;
using namespace std;
int main()
{
	int n,beg=1;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int u;
		scanf("%d",&u);
		if(u==beg)beg++;
	}if(beg==1)printf("-1\n");
	else printf("%d\n",n-(beg-1));
}

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

typedef long long ll;
ll MOD = 1000000007;

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

    cout << a[n/2] - a[n/2-1]<< endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.Iterator;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		int ans = 0;
		TreeSet<Integer> ts = new TreeSet<>();
		while (ans <= Math.min(a, b)) {
			ans++;
			if (a % ans == 0 && b % ans == 0) {
				ts.add(ans);
			}
		}
		Iterator<Integer> ite = ts.iterator();
		for (int i = 0; i < ts.size() - k; i++) {
			ite.next();
		}
		System.out.println(ite.next());
	}
}


Measured memory_bytes: 21716
package main
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
    "strings"
    "math"
)

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func main() {
    l := getStdinIntArr()
    X, N := l[0], l[1]
    if N == 0 {
        fmt.Println(X)
    } else {
        p := getStdinIntArr()
        i := -1
        var flag bool = true
        for flag {
            i++
            if !contains(p, int(math.Abs(float64(X - i)))) {
                flag = false
                fmt.Println(int(math.Abs(float64(X - i))))
            } else if !contains(p, int(math.Abs(float64(X + i)))) {
                flag = false
                fmt.Println(int(math.Abs(float64(X + i))))
            }
        }
    }
}

func contains(s []int, e int) bool {
    for _, v := range s {
        if e == v {
            return true
        }
    }
    return false
}

// slice[start:end+1] = val
func fill(slice []int, val, start, end int) ([]int, error) {
    if len(slice) < start || len(slice) < end {
        return nil, fmt.Errorf("Error")
    }
    for i := start; i < end; i++ {
        slice[i] = val
    }
    return slice, nil
}

func getStdin() string {
    return readLine()
}
func getStdinInt() int {
    str := getStdin()
    res, _ := strconv.Atoi(str)
    return res
}
func getStdinIntArr() []int {
    str := getStdin()
    list := strings.Split(str, " ")
    res := make([]int, len(list))
    for idx, v := range list {
        res[idx], _ = strconv.Atoi(v)
    }
    return res
}
func getStdinArr() []string {
    str := getStdin()
    list := strings.Split(str, " ")
    return list
}
func getStdinIntArr64() []int64 {
    str := getStdin()
    list := strings.Split(str, " ")
    res := make([]int64, len(list))
    for idx, v := range list {
        res[idx], _ = strconv.ParseInt(v, 10, 64)
    }
    return res
}
func readLine() string {
    buf := make([]byte, 0, 0)
    for {
        l, p, e := sc.ReadLine()
        if e != nil {
            panic(e)
        }
        buf = append(buf, l...)
        if !p {
            break
        }
    }
    return string(buf)
}

Measured memory_bytes: 2184
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int [] arr = new int[n];
		for (int i=0;i<n;i++) {
			arr[i] = sc.nextInt();
		}
		boolean breakFlag = false;
		for (int i=0;i<n;i++) {
			if (breakFlag) break;
			for (int j=i+1;j<n;j++) {
				if (Math.abs(arr[i] - arr[j]) % (n - 1) == 0) {
					System.out.println(arr[i]+ " " + arr[j]);
					breakFlag = true;
					break;
				}
			}
		}
	}
}



Measured memory_bytes: 30576
#include<cstdio>
#include<cstring>
const int N=10007,P=998244353;
char s[N],t[N];int f[N][N],fac[N],ifac[N];
int inc(int a,int b){return a+=b-P,a+(a>>31&P);}
int mul(int a,int b){return 1ll*a*b%P;}
int pow(int a,int k){int r=1;for(;k;k>>=1,a=mul(a,a))if(k&1)r=mul(a,r);return r;}
int C(int n,int m){return mul(mul(fac[n],ifac[m]),ifac[n-m]);}
int main()
{
    scanf("%s%s",s+1,t+1),fac[0]=1;
    int n=strlen(s+1),p=0,q=0,ans=0;
    for(int i=1;i<=n;++i) p+=s[i]=='1'&&t[i]=='1',q+=s[i]=='1'&&t[i]=='0';
    for(int i=1;i<=n;++i) fac[i]=mul(fac[i-1],i);
    ifac[n]=pow(fac[n],P-2);
    for(int i=n;i;--i) ifac[i-1]=mul(ifac[i],i);
    for(int i=0;i<=q;++i) f[0][i]=mul(fac[i],fac[i]);
    for(int i=1;i<=p;++i) for(int j=1;j<=q;++j) f[i][j]=inc(mul(mul(j,j),f[i][j-1]),mul(mul(i,j),f[i-1][j]));
    for(int i=0;i<=p;++i) ans=inc(ans,mul(mul(mul(mul(f[p-i][q],fac[i]),fac[i]),C(p,i)),C(p+q,i)));
    printf("%d",ans);
}


Measured memory_bytes: 389632
program C_solution

implicit none
integer :: n,c(499),s(499),f(499)
integer :: i,j,k,t(500)

read(*,*) n
do i=1, n-1
  read(*,*) c(i),s(i),f(i)
enddo

do i = 1, n
    t(i) = 0
    if ( i <= n-1 ) then
      do j = i , n-1
        t(i) = max( s(j), ((t(i)-1)/f(j))*f(j) + f(j) ) + c(j)
      enddo
    endif
  write(*,*) t(i)
  enddo


end program

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

int main(void) {
  int one,two,three;
    int a=0,b=0,c=0;
    cin>>one>>two>>three;
    vector<int> vec(3);

    a=abs(one - three);
    b =  abs(two- one);
    c =  abs(two- three);
    vec[0] = a+b;
    vec[1] = b+c;
    vec[2] = a+c;



    int min = *std::min_element(vec.begin(), vec.end());



    cout<<min<<endl;

    return 0;
}


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

namespace AtCoder
{
    class B
    {
        public static void Main()
        {
            var nab = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
            long n = nab[0];
            long a = nab[1];
            long b = nab[2];

            Console.WriteLine(n / (a + b) * a + Math.Min(n % (a + b), a));
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long double pi = (acos(-1));
#define pb push_back
#define vs vector<string>

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    ll N,K;
    cin>>N>>K;
    cout<<1+(N-2)/(K-1)<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }

using ll = long long;
const ll mod = LLONG_MAX;

int main(){
 string s;
 cin>>s;
 bool flag=false;

 //alphabet決め打ち
 for(int i=0;i<26;i++){
   char alpha='a'+i;
   int cnt=0,left=0;
   for(int right=0;right<s.size();right++){
     if(s[right]==alpha)cnt++;

     if((right-left+1)/2> cnt && (right-left+1)%2==0){
       left=right+1;
       cnt=0;
     }
     else if((right-left+1)/2>= cnt && (right-left+1)%2==1){
       left=right+1;
       cnt=0;
     }

     if((right-left+1)>=2 &&(right-left+1)/2 +1<=cnt ){
       cout<<left+1<<" "<<right+1<<endl;
       flag=true;
       goto E;
     }
   }
 }
 cout<<"-1 -1"<<endl;

 E:;



}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <complex>
#define repi(i,x,n) for(int i = x; i < n; i++)
#define rep(i,n) repi(i,0,n)
#define int long long
using namespace std;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,p;
    int a[100],sum=0;
    while(1){
        sum=0;
        rep(i,100) a[i]=0;
        cin>>n>>m>>p;
        if(m==0 && n==0 && p==0) break;
        rep(i,n){
            cin>>a[i];
            sum+=a[i];
        }
        sum*=(100-p);
        if(a[m-1]==0) cout<<0<<endl;
        else cout<<sum/a[m-1]<<endl;
        
    }
    return 0;
}





Measured memory_bytes: 3024
#include<stdio.h>
using namespace std;
int main() {
	long long s[87],n;
	s[0]=2;
	s[1]=1;
	for(int i=2;i<87;i++){
		s[i]=s[i-1]+s[i-2];
	}
	scanf("%lld",&n);
	printf("%lld\n",s[n]);
	return 0;
}

Measured memory_bytes: 128
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;

enum INF = long.max/3;
enum MOD = 10L^^9+7;

//辞書順順列はiota(1,N),nextPermituionを使う


void end(T)(T v)
if(isIntegral!T||isSomeString!T||isSomeChar!T)
{
    import core.stdc.stdlib;
    writeln(v);
    exit(0);
}

T[] scanArray(T = long)()
{
    static char[] scanBuf;
    readln(scanBuf);
    return scanBuf.split.to!(T[]);
}

dchar scanChar()
{
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    return cast(dchar)c;
}

T scanElem(T = long)()
{
    import core.stdc.stdlib;
    static auto scanBuf = appender!(char[])([]);

    scanBuf.clear;

    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        scanBuf ~= cast(char) c;
        c = getchar;
    }
    return scanBuf.data.to!T;
}

dchar[] scanString(){
    return scanElem!(dchar[]);
}


void main()
{
  auto n=scanElem;
  auto k=scanElem;
  auto x=scanElem;
  auto y=scanElem;
  writeln(min(n,k)*x+max(0,n-k)*y);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int n;
vi a,lis,ans;
vvi e;
stack<P> back;

void dfs(int v) {
	
	int k = lower_bound(all(lis), a[v]) - lis.begin();
	back.push(make_pair(k, lis[k]));
	lis[k] = a[v];
	ans[v] = lower_bound(all(lis), INF) - lis.begin();

	rep(i, e[v].size())if (ans[e[v][i]] == INF)dfs(e[v][i]);

	int kk = back.top().first;
	int liskk = back.top().second;
	back.pop();
	lis[kk] = liskk;

	return;
}

int main() {

	cin >> n;
	a.resize(n);
	rep(i, n)cin >> a[i];
	e.resize(n, vi(0));
	rep(i, n - 1) {
		int u, v;
		cin >> u >> v;
		u--;v--;
		e[u].push_back(v);
		e[v].push_back(u);
	}

	lis.assign(n, INF);
	ans.assign(n, INF);

	dfs(0);

	rep(i, n)cout << ans[i] << endl;

}

Measured memory_bytes: 30720
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
const ll MOD = 1000000007;

double X[3002][3002];

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

	X[0][0] = 1;

	for (int i = 1;i <= N;i++) {
		cin >> p;
		for (int j = 0;j <= 3000;j++) {
			X[i][j + 1] += X[i - 1][j] * p;
			X[i][j] += X[i - 1][j] * (1.0 - p);
		}
	}

	double ans = 0;
	for (int i = N / 2 + 1;i <= N;i++) {
		ans += X[N][i];
	}
	printf("%.11f\n", ans);
}

Measured memory_bytes: 70528
#!/usr/bin/env python3
x, n = map(int, input().split())

if n == 0:
    print(x)
else:
    arg = list(map(int, input().split()))

    ans = 0
    
    for i in range(100):
        numm = x - i
        nump = x + i

        if not(numm in arg):
            ans = numm
            break
        
        elif not (nump in arg):
            ans = nump
            break

    print(ans)


Measured memory_bytes: 9184
#include<stdio.h>


int main(void){
  long long n;
  scanf("%lld",&n);

  int keta;
  long long a = n;
  while(a > 10){
    a /= 10;
    keta ++;
  }

  long long ans = 0;
  long long temp , tas , waru;
  for(int i = 0;i < (1<<keta);i ++){
    tas = n;
    temp = i;
    waru = 10;
    while(temp > 0){
      if(temp%2 == 1){
        ans += tas%waru;
        tas = tas/waru;
        waru = 1;
        //printf("%lld\n",ans);
      }
      temp /= 2;
      waru *= 10;
    }
    ans += tas;
    //printf("%lld\n",ans);
  }

  printf("%lld\n",ans);

  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

#define M 100005

int n;
vector<int>v[M];
int Sg[M];

void DFS(int x,int p){
	for(int i=0;i<v[x].size();i++){
		int to=v[x][i];
		if(to==p)continue;
		DFS(to,x);
		Sg[x]^=(Sg[to]+1);
	}
}

int main(){
	scanf("%d",&n);
	for(int i=1,x,y;i<n;i++){
		scanf("%d %d",&x,&y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	DFS(1,0);
	int ans=Sg[1];
	if(ans==0)puts("Bob");
	else puts("Alice");
	return 0;
}

Measured memory_bytes: 13952