akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

int main(void)
{
  int D;
  cin >> D;
  if (D == 22) {
    cout << "Christmas Eve Eve Eve" << endl;
  }
  else if (D == 23) {
    cout << "Christmas Eve Eve" << endl;
  }
  else if (D == 24) {
    cout << "Christmas Eve" << endl;
  }
  else if (D == 25) {
    cout << "Christmas" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
 
#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
 
//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif
 
 
//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
 
//ここから編集する
int N;
vector<int> t, v;
int T = 0;
 
int F(int i, int X) {
    if (i == 0) {
        return X;
    }
    if (i == N + 1) {
        return T - X;
    }
    if (X <= t[i - 1]) {
        return 2 * v[i] + (t[i - 1] - X);
    } else if (t[i] <= X) {
        return 2 * v[i] + (X - t[i]);
    } else {
        return 2 * v[i];
    }
 
}
 
int main() {
 
    cin >> N;
    t = vector<int>(N + 1, 0);
    v = vector<int>(N + 1);
 
    REP(i, 1, N + 1) {
        cin >> t[i];
        t[i] *= 2;
    }
    REP(i, 1, N + 1) cin >> v[i];
 
    REP(i, 1, N + 1) {
        t[i] += t[i - 1];
    }
 
//    REP(i, 1, N + 1) T += t[i];
    T = t[N];
 
    vector<int> w(T + 1, INF);
    REP(i, 0, T + 1) {
        REP(j, 0, N + 2) {
//            if(i == 128){
//                printf("F(%d,%d) = %d\n",j,i,F(j,i));
//            }
            w[i] = min(w[i], F(j, i));
        }
    }
 
    ll sum_v = 0LL;
 
    REP(i,1,T+1){
        sum_v += w[i-1] + w[i];
    }
 
//    cout << 1.0 * sum_v * 0.125 << endl;
    printf("%.3lf\n",1.0 * sum_v * 0.125);
 
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

vector<ll> par(100000);
vector<ll> ran(100000);
void init(ll n){
  rep(i,n){
    par.at(i)=i;
    ran.at(i)=0;
  }
}
ll find(ll x){
  if(par.at(x)==x){
    return x;
  }else{
    return par.at(x)=find(par.at(x));
  }
}
void unite(ll x,ll y){
  x=find(x);
  y=find(y);
  if(x==y) return;
  if(ran.at(x)<ran.at(y)){
    par.at(x)=y;
  }else{
    par.at(y)=x;
    if(ran.at(x)==ran.at(y)) ran.at(x)++;
  }
}

int main(){
  ll N,M,ans=0;
  cin >> N >> M;
  vector<ll> P(N);
  rep(i,N){
    cin >> P.at(i);
    P.at(i)--;
  }
  init(N);
  rep(i,M){
    ll x,y;
    cin >> x >> y;
    x--;
    y--;
    unite(x,y);
  }
  rep(i,N){
    if(find(i)==find(P.at(i))){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 5532
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string n_r = Console.ReadLine();
            string S_r = Console.ReadLine();
            string q_r = Console.ReadLine();
            string T_r = Console.ReadLine();

            int n = int.Parse(n_r);
            string[] sS = S_r.Split();
            int[] S = new int[n];
            for (int i1 = 0; i1 < n; i1++)
            {
                S[i1] = int.Parse(sS[i1]);

            }
            int q = int.Parse(q_r);
            string[] sT = T_r.Split();
            int[] T = new int[n];
            for (int i2 = 0; i2 < q; i2++)
            {
                T[i2] = int.Parse(sT[i2]);

            }

            int Count = 0;

            int    left = 0;
            int    right = n;
            int mid;
            int key;
            for (int i = 0; i < q; i++)
            {
                left = 0;
                right = n;
                key = T[i];
                while (left < right)
                {
                    mid = (left + right) / 2;
                    if (S[mid] == key)
                    {
                        Count++;
                        break;
                    }
                    else if (key < S[mid])
                    {
                        right = mid;
                    }
                    else
                    {
                        left = mid + 1;
                    }


                }
                //for (int ii = 0; ii < n; ii++)
                //{
                //    if (S[ii] == T[i])
                //    {
                //        Count++;
                //        break;
                //    }

                //}
            }
            Console.WriteLine(Count);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 17624
#include<bits/stdc++.h>
using namespace std;
 
int N,S,T;
int A[102][102];
int W[102][102];
int Q[102];
const int INF = (1<<29);
 
typedef pair<int,int> P;
const double EPS = 1e-10;
typedef vector<double> vec;
typedef vector<vec> mat; //Ax = b テ」ツ?ョAテ」ツ?ョテゥツδィテ・ツ按?

vec gauss_jordan(const mat &A, const vec &b){
  int n = A.size();
  mat B(n, vec(n+1));
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      B[i][j] = A[i][j];
  for(int i=0;i<n;i++) B[i][n] = b[i];
  for(int i=0;i<n;i++){
    int pivot = i;
    for(int j=i+1;j<n;j++) if(fabs(B[j][i]) > fabs(B[pivot][i])) pivot = j;
    swap(B[i],B[pivot]);
    //ティツァツ」テ」ツ?古」ツ?ェテ」ツ??」ツ?凝」ツ??」ツ?づ」ツ?」テ」ツ?ヲテ」ツつづ、ツクツ?ヲツ?湘」ツ?ァテ」ツ?ッテ」ツ?ェテ」ツ??」ツ??
    if(fabs(B[i][i]) < EPS) return vec();
    
    for(int j=i+1;j<=n;j++) B[i][j] /= B[i][i];
    for(int j=0;j<n;j++)
      if(i != j)
	for(int k=i+1;k<=n;k++)
	  B[j][k] -= B[j][i] * B[i][k];
  }
  vec x(n);
  for(int i=0;i<n;i++) x[i] = B[i][n];
 
  return x;
}
 
void wsf(mat &M, vec &V){
  fill( W[0], W[N], INF );  
  for(int i=0;i<N;i++) W[i][i] = 0;
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      if( A[i][j] ) W[i][j] = A[i][j];
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      for(int k=0;k<N;k++)
        W[j][k] = min( W[j][k], W[j][i] + W[i][k] );


  M = mat(N,vec(N));
  V = vec(N);
  for(int i=0;i<N;i++){
    int k = 0;
    int cs = 0;
    if( i == T ){
      M[i][i] = 1;
      continue;
    } else if( Q[i] ){
      for(int j=0;j<N;j++)
        if( A[i][j] && W[i][T] == A[i][j] + W[j][T] ) {
          M[i][j] = -1;
          k++;
          cs += A[i][j];
        }
    } else {
      for(int j=0;j<N;j++)
        if( A[i][j] ) {
          M[i][j] = -1;
          k++;
          cs += A[i][j];
        }
    }
    M[i][i] = k;
    V[i] = cs;
  }  
}
 
 
int main(){
  while( cin >> N >> S >> T && (N|S|T) ){
    --S;--T;
    for(int i=0;i<N;i++) cin >> Q[i];
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++)
        cin >> A[i][j];
    mat M;
    vec V;
    wsf(M,V);
    if( W[S][T] == INF )
      cout << "impossible" << endl;
    else 
      printf("%.9lf\n",gauss_jordan(M,V)[S]);
  }
}

Measured memory_bytes: 1484
in_a = [int(x) for x in input().split(' ')]
in_b = [int(x) for x in input().split(' ')]
t = int(input())

result = False

p_a = in_a[0]
p_b = in_b[0]
m_a = in_a[1]
m_b = in_b[1]
end_p_a = m_a*t
end_p_b = m_b*t

diff_s = abs(p_a-p_b)

if end_p_a-end_p_b>=diff_s:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 9204
#include<stdio.h>
#define swap(A, B) {A = A + B; B = A - B; A = A - B;}

int main(void){
  int N, i, j;
  scanf("%d",&N);
  
  int a[N];
  for(i = 0; i < N; i++) scanf("%d",&a[i]);
  
  //sort
  for(i = 0; i < N-1; i++){
    for(j = i+1; j < N; j++){
      if(a[i] < a[j]) swap(a[i], a[j])
    }
  }
  
  int ans = 0;
  for(i = 0; i < N; i++){
  	ans = (i%2 == 0)? ans + a[i] : ans - a[i];
  }
  printf("%d\n",ans);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b;
    cin >> a >> b;
    a=a*b;
    b=a%2;
    if(b==0){
        cout << "Even" << endl;
    }
    else{
        cout << "Odd" << endl;
    }
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,k=map(int,input().split())
    S=input()
    lis=[0]
    for i in range(1,n):
        if S[i-1]!=S[i]:
            lis.append(i)
    lis.append(n)
    len_lis=len(lis)
    ans=[]
    for i in range(len_lis-1):
        if S[lis[i]]=='0':
            ans.append(lis[min(i+2*k,len_lis-1)]-lis[i])
        else:
            ans.append(lis[min(i+2*k+1,len_lis-1)]-lis[i])
    print(max(ans))

if __name__=='__main__':
    main()

Measured memory_bytes: 80488
#include <bits/stdc++.h>
using namespace std;
int n;
int a[100002];
int b[100001];
int main(){
	cin>>n;
  for(int i=1; i<=n+1; i++) cin>>a[i];
  for(int i=1; i<=n; i++) cin>>b[i];
  long long ans=0;
  for(int i=1; i<=n; i++){
  	int now=min(b[i], a[i]);
    a[i]-=now;
    b[i]-=now;
    ans+=now;
    now=min(b[i], a[i+1]);
    a[i+1]-=now;
    b[i]-=now;
    ans+=now;
  }
  cout<<ans<<'\n';
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
//*******************
// Mahmoud Magdy    *
//*******************
#define ll long long
#define endl "\n"

void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m ;
    cin>>m;
    return m ;
}
int a[100005],b[100005];
int main()
{
 int n=D(),k=D();
   for(int i=0;i<n;++i){
    a[i]=D();
    b[i]=D();
   }
   sort(a,a+n);
   int mx=a[n-1];
   ll sum=0;
   int c=0;
   sort(b,b+n);
   for(int i=n-1;i>=0;--i){
          if(sum>=k){
    cout<<c<<endl;
    return 0;
    }
    if(mx<=b[i]){
        sum+=b[i];
        c++;
        }
   }
   if(sum>=k)
    cout<<c<<endl;
    else {
        int idx=(k-sum)/mx;
    if(idx>=0){
        if(idx * mx+sum<k)
            idx++;
    }
  cout<<idx+c<<endl;
  }
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
string rotate(string s){
	return s.substr(1)+s[0];
}
int main(){
	string s,t;
	cin>>s>>t;
	int n=s.length();
	for(int i=0;i<n;i++){
		if(s==t){
			cout<<"Yes"<<endl;
			return 0;
		}
		s=rotate(s);
	}
	cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  int N;
  cin >> N;
  ll A[N];
  REP(i, N) { cin >> A[i]; }
  ll sum = 0;
  REP(i, N) {
    if (i % 2 == 0) {
      sum += A[i];
    } else {
      sum -= A[i];
    }
  }
  ll ans = sum;
  cout << ans;
  REP(i, N - 1) {
    ans = 2 * A[i] - ans;
    cout << " " << ans;
  }

  return 0;
}

Measured memory_bytes: 2048
n, m = gets.to_s.split.map{|t|t.to_i}

card_min = 1
card_max =10**5


m.times do
  l, r = gets.to_s.split.map{|t|t.to_i}
  card_min = l if card_min < l
  card_max = r if card_max > r
end

puts [0, card_max - card_min + 1].max

Measured memory_bytes: 1788
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
#define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        1e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
    freopen("gout.txt", "w", stdout);
   
    #endif
}

int an,k;
string n,cur;

void recur(int i,int rm,string cur,int fl)
{
    if(rm==0)
    {
        an++;
        return ;
    }
    if(i==101 )
    {
        if(rm==0)
        {
         an++;
         cout<<cur<<endl;     
            
        }
        return ;
    }

    if(fl==1)
    {
     int c = 101-i;
            if(c < rm) return ;

            if(rm==2) c = (c*(c-1))/2;
            else if(rm==3) c = (c*(c-1)*(c-2))/6;
            an += c * (int)pow(9,rm);
    return ;
    }
    

   

    for(int j=1;j<=9;j++)
    {
        string temp = cur;
        temp[i] = '0'+j;
        if(temp <= n && rm > 0 )
        {
            if(j < (n[i]-'0'))
            recur(i+1,rm-1,temp,1);
            else recur(i+1,rm-1,temp,fl);
        }
    }
     if(n[i] > '0') fl=1;

   recur(i+1,rm,cur,fl);
}

void solve()
{
 
 cin >> n >> k;
 
 while(sz(n)!=101)
 {
   n.insert(n.begin(),'0');
 }

 cur.assign(101,'0');

 an =0 ;

 recur(0,k,cur,0);

 cout<<an<<endl;
 
}


int32_t main()
{
  pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
   // cout << "Time taken by function: "
   //       << duration.count() << " microseconds" << endl; 

 }
      
      

Measured memory_bytes: 3988
// inputに入力データ全体が入る
function Main(input) {
	var ans
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.trim().split("\n");
	s = input[0].split(' ').map((n) => (parseInt(n)))
	while (true) {
		s[2] = s[2] - s[1]
		if (s[2] <= 0 ) {
			ans = 'Yes'
			break;
		}
		s[0] = s[0] - s[3]
		if (s[0] <= 0 ) {
			ans = 'No'
			break;
		}
	}

	//出力
	console.log(ans)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(require('fs').readFileSync('./input.txt', 'utf-8'));

Measured memory_bytes: 29632
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<set>
#include<queue>
#include<cmath>

using namespace std;
#define LL long long

LL MOD=998244353,MAX=222222;
LL N,M,K;

LL fac[222222], finv[222222], inv[222222];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

LL modpow(LL b,LL p){
	LL now=1,x=b;
	while(p>0){
		if(p&1)now=now*x%MOD;
		x=x*x%MOD;
		p>>=1;
	}
	return now%MOD;
}

int main() {
	COMinit();
	cin>>N>>M>>K;
	LL ans=0;
	for(int i=0;i<=K;i++){
		LL tmp=modpow(M-1,N-1-i);
		tmp=tmp*M%MOD;
		tmp=tmp*COM(N-1,i)%MOD;
		ans=(ans+tmp)%MOD;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 8820
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int n, m;
    cin >> n >> m;
    vector<int> key;
    vector<int> cost;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        cost.push_back(a);
        int c[b];
        int num = 0;
        rep(j, b) {
            int temp;
            cin >> temp;
            num += (1 << (temp - 1));
        }
        key.push_back(num);
    }

    ll dp[1 << n];
    rep(i, 1 << n) { dp[i] = mod; }
    dp[0] = 0;

    rep(i, key.size()) {
        int num = key[i];
        int c = cost[i];
        rep(j, 1 << n) {
            int index = j | key[i];
            dp[index] = min(dp[index], c + dp[j]);
        }
    }
    if (dp[(1 << n) - 1] == mod) {
        cout << -1 << endl;
        return 0;
    }
    cout << dp[(1 << n) - 1] << endl;
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


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

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        long a = sc.nextLong();
        long b = sc.nextLong();

        long r = 0;
        if(b > a){
            long tmp = a;
            a = b;
            b = tmp;
        }
        r = a % b;
        while(r != 0){
            a = b;
            b = r;
            r = a % b;
        }
        long gcm = b;

        int ans = 1;
        for(int i=2; i<Math.sqrt(gcm + 100000); i++){
            if(gcm % i == 0){
                ans++;
                while(gcm % i == 0){
                    gcm /= i;
                }
            }
        }
        if(gcm > 1) ans++;
        System.out.println(ans);
    }

    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            }else{
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }else if(b == -1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1000000007;

int main() {
  int n;
  cin>>n;
  int min=1009,max=-1;
  rep(i,n){
    int a;
    cin>>a;
    if(a<min) min=a;
    if(a>max) max=a;
  }
  cout<<max-min<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, d: "List[int]"):
    d = sorted(d)
    low = d[N//2 - 1]
    high = d[N//2]
    print(high - low)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    d = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, d)

if __name__ == '__main__':
    main()


Measured memory_bytes: 15220
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>


int main() {

    int A, B, C, X, Y;
    std::cin >> A >> B >> C >> X >> Y;

    int m = std::min(X, Y);
    long sum = 0;
    if ((A + B) >= 2 * C) {
        sum += 2 * C * m;

        if (A >= 2 * C) {
            sum += 2 * C * (X - m);
        } else {
            sum += A * (X - m);
        }

        if (B >= 2 * C) {
            sum += 2 * C * (Y - m);
        } else {
            sum += B * (Y - m);
        }

    } else {
        sum += A * X;
        sum += B * Y;
    }

    std::cout << sum << "\n";

    return 0;
}


Measured memory_bytes: 256
from collections import Counter
n=int(input())
a=list(map(int, input().split()))
b=[a[i] for i in range(n) if i%2==0]
c=[a[i] for i in range(n) if i%2==1]
b2=Counter(b)
c2=Counter(c)
b3=b2.most_common(2)
c3=c2.most_common(2)
ans=n
for i in b3:
    for j in c3:
        if i[0]!=j[0]:
            ans=min(ans,n-i[1]-j[1])
        else:
            ans=min(ans,n-max(i[1],j[1]))
print(ans)


Measured memory_bytes: 19040
N, M = map(int, input().split())
MOD = 10 ** 9 + 7


factorial = [1, 1]
inverse = [1, 1]
invere_base = [0, 1]
for i in range(2, N + M + 1):
    factorial.append((factorial[-1] * i) % MOD)
    invere_base.append((-invere_base[MOD % i] * (MOD // i)) % MOD)
    inverse.append((inverse[-1] * invere_base[-1]) % MOD)


def nCr(n, r):
    if not (0 <= r <= n):
        return 0
    return factorial[n] * inverse[r] * inverse[n - r] % MOD


def nPr(n, r):
    if not (0 <= r <= n):
        return 0
    return nCr(n, r) * factorial[r] % MOD


ans = pow(nCr(M, N) * factorial[N], 2, MOD)
for r in range(1, N + 1):
    p = nCr(M, r) * nPr(N, r) * pow(nPr(M - r, N - r), 2, MOD) % MOD
    p *= ((-1) ** ((r % 2) ^ 1))
    ans -= p
    ans %= MOD

print(ans)


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

int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  for(auto& e: v) cin >> e;
  
  int ans = 1e9;
  for(auto e: v) {
    int cnt = 0;
    while(e%2==0) {
      e /= 2;
      cnt++;
    }
    ans = min(ans, cnt);
  }
      
  cout << ans << endl;
}

Measured memory_bytes: 3596
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
      	int n = sc.nextInt();
		int[] p = new int[n];
		for(int i=0; i<n; i++){
			p[i] = sc.nextInt();
		}
      	int ans = x;
      	int num = x;
      	for(int i=0; i<n; i++){
          if(ans==p[i]){
            ans++;
            i=-1;
          }
        }
      	for(int i=0; i<n; i++){
          if(num==p[i]&&ans>0){
            num--;
            i=-1;
          }
        }
      	if(Math.abs(ans-x)>=Math.abs(num-x)) {
		    System.out.println(num);
		}else {
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 35584
#include<iostream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include <algorithm>
#include <set>
#include<math.h>
#include<vector>
#include<map>
using namespace std;

int main(){
    int n;
    cin >> n;
    int h[n];
    for(int i = 0;i < n;i++){
        int t;
        cin >> t ;
        h[i] = t;
    }
    int count = 0;
    int z = 0;
    while(1){
        z = 0;
        for(int i =0;i<n;i++){
            if(h[i] == 0){
                z++;
                continue;
            }
            if(i == n-1 && h[i] != 0){
                count++;
                h[i]-=1;
                continue;
            }
            if(h[i] != 0 && h[i+1] == 0){
                count++;
                h[i]-=1;
                continue;
            }
            h[i]-=1;
            
        }
        if(z>=n)break;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int a,b,c; cin >> a >> b >> c;
	int d=abs(a-b);
	int e=abs(b-c);
	int f=abs(c-a);
	int ans=min({e+f,d+f,d+e});
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<map>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<numeric>
#include<iomanip>
#define MAX 500005
#define MOD 1000000007
#define lo long long
#define INF 1e18
#define pp pair<long long, long long>
#define ppp pair<long long, pair<long long, long long> >
#define pb(a) push_back(a)
#define fi first
#define se second
#define PI 3.14159265
using namespace std;


pp a[MAX];
multiset<lo> P, M;
int main() {

	
	lo n;
	cin>>n;


	for(int i=0; i<n; i++) {
		lo x, y;
		cin>>x>>y;
		P.insert(x+y);
		M.insert(x-y);
		a[i].fi = x;
		a[i].se = y;
	}

	lo ans = 0;
	multiset<lo>::iterator it, it1;
	for(int i=0; i<n; i++) {
		lo sum = a[i].fi + a[i].se;
		lo sub = a[i].fi - a[i].se;
		it = P.find(sum);
		P.erase(it);
		it1 = M.find(sub);
		M.erase(it1);

		if(P.size() > 0) {
			ans = max(ans, sum - *P.begin());
		}
		if(M.size() > 0) {
			ans = max(ans, sub  - *M.begin());
		}
		P.insert(sum);
		M.insert(sub);
	}

	cout<<ans<<endl;

}

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

int main(void) {
	string banmen[6]={
		"..rr....",
		"..rr....",
		"ggyybbww",
		"ggyybbww",
		"..oo....",
		"..oo...."
	};
	char t1,t2;
	for(char c;cin>>c;) {
		switch(c) {
			case 'U':
				t1=banmen[2][0];
				t2=banmen[2][1];
				banmen[2][0]=banmen[2][2];
				banmen[2][1]=banmen[2][3];
				banmen[2][2]=banmen[2][4];
				banmen[2][3]=banmen[2][5];
				banmen[2][4]=banmen[2][6];
				banmen[2][5]=banmen[2][7];
				banmen[2][6]=t1;
				banmen[2][7]=t2;

				t1=banmen[0][2];
				banmen[0][2]=banmen[1][2];
				banmen[1][2]=banmen[1][3];
				banmen[1][3]=banmen[0][3];
				banmen[0][3]=t1;
				break;
			case 'F':
				t1=banmen[1][2];
				t2=banmen[1][3];
				banmen[1][2]=banmen[3][1];
				banmen[1][3]=banmen[2][1];
				banmen[3][1]=banmen[4][3];
				banmen[2][1]=banmen[4][2];
				banmen[4][3]=banmen[2][4];
				banmen[4][2]=banmen[3][4];
				banmen[2][4]=t1;
				banmen[3][4]=t2;

				t1=banmen[2][2];
				banmen[2][2]=banmen[3][2];
				banmen[3][2]=banmen[3][3];
				banmen[3][3]=banmen[2][3];
				banmen[2][3]=t1;
				break;
			case 'R':
				t1=banmen[0][3];
				t2=banmen[1][3];
				banmen[0][3]=banmen[2][3];
				banmen[1][3]=banmen[3][3];
				banmen[2][3]=banmen[4][3];
				banmen[3][3]=banmen[5][3];
				banmen[4][3]=banmen[3][6];
				banmen[5][3]=banmen[2][6];
				banmen[3][6]=t1;
				banmen[2][6]=t2;

				t1=banmen[2][4];
				banmen[2][4]=banmen[3][4];
				banmen[3][4]=banmen[3][5];
				banmen[3][5]=banmen[2][5];
				banmen[2][5]=t1;
				break;
			case 'D':
				t1=banmen[3][6];
				t2=banmen[3][7];
				banmen[3][6]=banmen[3][4];
				banmen[3][7]=banmen[3][5];
				banmen[3][4]=banmen[3][2];
				banmen[3][5]=banmen[3][3];
				banmen[3][2]=banmen[3][0];
				banmen[3][3]=banmen[3][1];
				banmen[3][0]=t1;
				banmen[3][1]=t2;

				t1=banmen[4][2];
				banmen[4][2]=banmen[5][2];
				banmen[5][2]=banmen[5][3];
				banmen[5][3]=banmen[4][3];
				banmen[4][3]=t1;
				break;
			case 'B':
				t1=banmen[0][2];
				t2=banmen[0][3];
				banmen[0][2]=banmen[2][5];
				banmen[0][3]=banmen[3][5];
				banmen[2][5]=banmen[5][3];
				banmen[3][5]=banmen[5][2];
				banmen[5][3]=banmen[3][0];
				banmen[5][2]=banmen[2][0];
				banmen[3][0]=t1;
				banmen[2][0]=t2;

				t1=banmen[2][6];
				banmen[2][6]=banmen[3][6];
				banmen[3][6]=banmen[3][7];
				banmen[3][7]=banmen[2][7];
				banmen[2][7]=t1;
				break;
			case 'L':
				t1=banmen[4][2];
				t2=banmen[5][2];
				banmen[4][2]=banmen[2][2];
				banmen[5][2]=banmen[3][2];
				banmen[2][2]=banmen[0][2];
				banmen[3][2]=banmen[1][2];
				banmen[0][2]=banmen[3][7];
				banmen[1][2]=banmen[2][7];
				banmen[3][7]=t1;
				banmen[2][7]=t2;

				t1=banmen[2][0];
				banmen[2][0]=banmen[3][0];
				banmen[3][0]=banmen[3][1];
				banmen[3][1]=banmen[2][1];
				banmen[2][1]=t1;
				break;
		}
	}
	for(int i=0;i<6;i++)cout<<banmen[i]<<endl;
	
	return 0;
}


Measured memory_bytes: 1188
s = list(input())
ans = 0
if len(s)%2==0:
    s = s[:-2]
else:
    s.pop(-1)

while len(s)>0:
    if s[0:int(len(s)/2)]==s[int(len(s)/2):len(s)]:
        ans = len(s)
        break
    else:
        s = s[:-2]
        
print(ans)

Measured memory_bytes: 8952
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

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


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	string s;
	int k;
	cin >> k;
	cin >> s;
	if(s.length() <= k)
	{
		cout << s;
	}
	else
	{
		cout << s.substr(0,k) + "...";
	}
	

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
const ll INF = 1LL << 60;

// 入力
int N;
long long W, weight[110], value[110]; // 品物の個数は 100 個なので少し余裕持たせてサイズ 110 に

// DPテーブル
long long dp[110][100100] = {0};

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];

    // DPループ
    for (int i = 0; i < N; ++i) {
        for (int sum_w = 0; sum_w <= W; ++sum_w) {

            // i 番目の品物を選ぶ場合
            if (sum_w - weight[i] >= 0) {
                chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
            }

            // i 番目の品物を選ばない場合
            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }

    // 最適値の出力
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

int main() {
    int n,cnt = 0;
    cin >> n;
    vector<int> a(n+1);
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; ++i) {
        if(i == a[a[i]]) cnt++;
    }
    cout << cnt/2 << endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int N, A, B, v[111], r[111], G[111][222];
int rec(int pos) {
	int ret = 0; v[pos] = 1;
	for (int i = 0; i < r[pos]; i++) {
		if (!v[G[pos][i]]) {
			int w = rec(G[pos][i]);
			ret = ret > w ? ret : w;
		}
	}
	v[pos] = 0;
	return ret + 1;
}
int main() {
	while (scanf("%d", &N), N) {
		for (int i = 0; i < 100; i++) r[i] = 0;
		for (int i = 0; i < N; i++) {
			scanf("%d%d", &A, &B), A--, B--;
			G[A][r[A]++] = B, G[B][r[B]++] = A;
		}
		int ret = 0;
		for (int i = 0; i < 100; i++) {
			int w = rec(i);
			ret = ret > w ? ret : w;
		}
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
 
# define INF 0x3f3f3f3f
#define MOD 1000000007
#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d%d",&x,&y)
#define siii(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pi(x) printf("%d",x)
#define pii(x,y) printf("%d%d",x,y)
#define piii(x,y,z) printf("%d%d%d",x,y,z) 
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld%lld",&x,&y)
#define slll(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define pl(x) printf("%lld",x)
#define pll(x,y) printf("%lld%lld",x,y)
#define plll(x,y,z) printf("%lld%lld%lld",x,y,z) 
 
#define ll long long
#define mp make_pair
#define pb push_back
#define pp pop_back
#define nl printf("\n");
#define sf scanf
#define pf printf
#define rep(i,n) for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define vint vector<int> 
#define tci int t;scanf("%d",&t);while(t--)
#define tcl ll t;sl(t);while(t--) 
int main() 
{
    string s;
    cin>>s;
    cout<<s[0]<<s.length()-2<<s[s.length()-1];nl;
    return 0;
}   

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

int main() {

  int N,X;
  int m;
  cin >> N >> X;
  int min = 2000;
  int num = 0;
  for(int i = 0;i < N;i++) {
    cin >> m;
    if(m < min) min = m;
    num++;
    X -= m;
  }
  num += (X / min);
  cout << num;
  return 0;
}


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

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($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();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($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 x: f64 = sc.cin();
    put!(x * 6.28318);
}

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()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 2228
#include <stdio.h>
#include <set>
#include <utility>
using namespace std;
typedef pair<int,int> pi;
#define F first
#define S second
int dis(pi a,pi b){return (a.F-b.F)*(a.F-b.F)+(a.S-b.S)*(a.S-b.S);}
int main(){
    int n,ans,d;
    pi temp;
    set<pi> s;
    while(true){
        scanf("%d",&n);
        if(n==0)return 0;
        ans=0;
        s.clear();
        for(int i=0;i<n;i++){
            scanf("%d%d",&temp.F,&temp.S);
            s.insert(temp);
        }
        for(pi i:s)for(pi j:s){
            d=dis(i,j);
            if(d>ans){
                if(s.find({i.F+j.S-i.S,i.S-j.F+i.F})!=s.end()&&s.find({j.F+j.S-i.S,j.S-j.F+i.F})!=s.end())ans=d;
                if(s.find({i.F-j.S+i.S,i.S+j.F-i.F})!=s.end()&&s.find({j.F-j.S+i.S,j.S+j.F-i.F})!=s.end())ans=d;
            }
            
        }
        printf("%d\n",ans);
    }
}


Measured memory_bytes: 2764
#include<iostream>

using namespace std;
int main()
{
	// 整数の入力
	int x1,y1,x2,y2;
	cin >> x1>>y1>>x2>>y2;
	int x3, y3, x4, y4;
	int a, b;

	a = x2 - x1;
	b = y2 - y1;

	x3 = x2 - b;
	y3 = y2 + a;

	x4 = x3 - a;
	y4 = y3 - b;


	cout << x3<<" " << y3 << " " << x4 << " " << y4  << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
typedef vector<int> vint;
int INF=2e+9+1;
int main(){
	int A[3];
	scan(A[0]);scan(A[1]);scan(A[2]);
	int oddeven=0;
	vint a;
	rep(i,3){
		oddeven+=A[i]%2;
		a.push_back(A[i]);
	}
	sort(a.begin(),a.end());
	if(oddeven==0||oddeven==3){
		prin((a[2]-a[1])/2+(a[2]-a[0])/2);
	}
	else{
		if((a[2]-a[0])%2==0) a[1]--;
		else if((a[2]-a[1])%2==0) a[0]--;
		else a[2]--;
		sort(a.begin(),a.end());
		prin((a[2]-a[1])/2+(a[2]-a[0])/2+1);
	}
	return 0;
}


Measured memory_bytes: 256
//075A
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c =0;
    cin >> a>> b>> c;
    if(a==b){
        cout << c;
    }else if(a==c){
        cout << b;
    }else if(b==c){
        cout << a;
    }
    
}

Measured memory_bytes: 256
using System;
using System.Linq;

class B
{
	static long[] Read() => Console.ReadLine().Split().Select(long.Parse).ToArray();
	static void Main()
	{
		var av = Read();
		long a = av[0], v = av[1];
		var bw = Read();
		long b = bw[0], w = bw[1];
		var t = long.Parse(Console.ReadLine());

		if (a < b)
			Console.WriteLine(b + w * t <= a + v * t ? "YES" : "NO");
		else
			Console.WriteLine(a - v * t <= b - w * t ? "YES" : "NO");
	}
}


Measured memory_bytes: 28116
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<char> = itr.next().unwrap().chars().collect();

    let mut sum: Vec<usize> = vec![0; n + 1];
    for i in 0..n {
        sum[i + 1] = sum[i] + (a[i] == 'W') as usize;
    }

    let mut ans = 500000;
    for i in 0..n {
        ans = std::cmp::min(ans, sum[i] + (n - i - 1) - (sum[n] - sum[i + 1]));
    }
    println!("{}", ans);
}


Measured memory_bytes: 10620
L, R = map(int, input().split())
Lmin = L % 2019
Rmin = R % 2019
anlis = []

if R-L >= 2018 or Lmin > Rmin:
    print(0)
    
else:
    for j in range(Lmin+1, Rmin+1):
        for i in range(Lmin, j):
            anlis.append((i * j) % 2019)
    print(min(anlis))

Measured memory_bytes: 75416
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
 
int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
     
    static double dp[21][220011];
    rep(i,21)rep(j,220011)dp[i][j] = INF;
    dp[0][1] = 0;
     
    for(int i=1;i<=n;i++){
        for(int j=1;j<=220010;j++){
            double diff = (double)abs(v[i-1]-j)/v[i-1];
            int sq = sqrt(j);
            for(int k=1;k<=sq;k++){
                if(j%k==0){
                    dp[i][j] = min( dp[i][j], max( dp[i-1][k],   diff ) );
                    dp[i][j] = min( dp[i][j], max( dp[i-1][j/k], diff ) );
                }
            }
        }
    }
    double ans = INF;
    rep(i,220011)ans = min(ans,dp[n][i]);
    printf("%.20lf\n",ans);
}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  string s;
  cin >> s;
  int numChildren[s.length()] = {};
  int nextL = -1;
  int nextR = -1;
  for(int i=0;i<s.length();i++){
    if('R'==s[i]){
      nextR = i;
      if(nextL<i) nextL = s.find("L",i);
      if( (nextL-i)%2==0 ){
        numChildren[nextL]++;
      }
      else{
        numChildren[nextL-1]++;
      }
    }
    else{ // 'L'==s[i];
      if( (nextR-i)%2==0 ){
        numChildren[nextR]++;
      }
      else{
        numChildren[nextR+1]++;
      }
    }
  }
  
  for(auto num: numChildren){
    cout << num << " ";
  }
  cout << endl;
  
  return 0;
}



Measured memory_bytes: 4088
from itertools import cycle, islice

gen = lambda w: cycle(("".join(islice(cycle("#."), w)),
                       "".join(islice(cycle(".#"), w))))

def print_lines(h, w):
    for line in islice(gen(w), h):
        print(line)
    print()

while True:
    s = input()

    if s == "0 0":
        break
    else:
        h, w = list(map(int, s.split()))
        print_lines(h, w)

Measured memory_bytes: 7732
# -*- coding: utf-8 -*-
k = input().split()

s = input()

a = int(k[0])
b =int(k[1])

j = 1
for t in range(a+b+1):
    if t!=a:
        try:
            if int(s[t]) >= 0 and int(s[t]) <= 9:
                pass
            else:
                j = 0
                
        except:
            j = 0
    else:
        if s[t] != "-":
            j =0
if j:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
//AT2165
#include <cstdio>

const int MAXN = (int)1e5;
int n, a[2*MAXN+5];

inline bool check(int x) {
	for (int i = 0; i < n-1; i++) {
		if ((a[n+i] <= x && a[n+i+1] <= x) || (a[n-i] <= x && a[n-i-1] <= x)) return true;
		if ((a[n+i] > x && a[n+i+1] > x) || (a[n-i] > x && a[n-i-1] > x)) return false;
	}
	return a[1] <= x;
}

int main() {
	scanf("%d", &n);
	for (register int i = 1; i < 2*n; i++)
		scanf("%d", a+i);
	int L = 0, R = 2*n-1;
	while (L < R) {
		int mid = (L+R)>>1;
		if (check(mid)) R = mid;
		else L = mid + 1;
	}
	printf("%d", L);
	return 0;
}

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

using namespace std;

int main() {
int n,k,i,j,vl,cs; 
cin>>n;

int vc[n];
for(i=0;i<n;i++)
{
    cin>>vc[i];
}
for(i=0;i<n;i++)
{
    cin>>cs;
    vc[i]-=cs;
}
k=0;
for(i=0;i<n;i++)
{
    if(vc[i]>0)k+=vc[i];
}
cout<<k;
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll n; cin >> n;
  fin(800 * n - (n / 15) * 200)
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 384