akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


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

    int max_abc = max(max(a, b), c);

    int diff = max_abc - a;
    diff += max_abc - b;
    diff += max_abc - c;

    if (diff%2==0){
        cout << diff/2 << endl;
    } else {
        cout << (diff+3)/2 << endl;
    }
}



Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	s := []int{a, b, c}
	m := make(map[int]int)

	for _, i := range s {
		m[i]++
	}

	if len(m) == 2 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

// 0-indexed, 半開
template <typename T> struct BIT {
  private:
    int n;
    vector<T> dat;

  public:
    BIT(vector<T> v) : n(v.size()) {
        dat.assign(n + 1, 0);
        for(int i = 0; i < n; i++)
            dat[i + 1] = v[i];
        for(int i = 1; i < n; i++)
            if(i + (i & -i) <= n) dat[i + (i & -i)] += dat[i];
    }
    BIT(int n) : n(n) { dat.assign(n + 1, 0); }
    void add(int k, T a) {
        for(k++; k <= n; k += k & -k)
            dat[k] += a;
    }
    // [0,a)
    T sum(int a) {
        T ret = 0;
        for(; a > 0; a -= a & -a)
            ret += dat[a];
        return ret;
    }
    // [a,b)
    T sum(int a, int b) { return sum(b) - sum(a); }
    int lowerBound(T w) {
        if(w <= 0) return 0;
        int x = 0;
        for(int k = 1 << int(log2(n)); k; k /= 2) {
            if(x + k <= n && dat[x + k] < w) {
                x += k;
                w -= dat[x];
            }
        }
        return x + 1;
    }
};

// [l,r)
struct LR {
    int l, r;
    LR(int l, int r) : l(l), r(r) {}
    inline bool operator<(const LR &x) const { return r - l < x.r - x.l; }
};

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

    int n, m;
    cin >> n >> m;
    V<LR> snuke;
    rep(i, n) {
        int l, r;
        cin >> l >> r;
        snuke.push_back(LR(l, r + 1));
    }
    sort(ALL(snuke));
    BIT<int> bit(m + 1);
    int j = 0;
    FOR(i, 1, m + 1) {
        while(j < n && snuke[j].r - snuke[j].l < i) {
            bit.add(snuke[j].l, 1);
            bit.add(snuke[j].r, -1);
            j++;
        }
        int ans = n - j;
        for(int k = 0; k <= m; k += i)
            ans += bit.sum(k + 1);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 6384
<?php
fscanf(STDIN, "%d%d%d", $N, $K, $C);
$S = trim(fgets(STDIN));
$rest = 10**10;
$c = 1;
for($i = 0; $i < $N; ++$i){
    if($S[$i] == 'o' && $rest > $C){
        $work[$i] = $c++;
        $rest = 0;
    }else{
        $work[$i] = 0;
    }
    ++$rest;
}
$rest = 10**10;
$c = $K;
for($i = $N-1; $i >= 0; --$i){
    if($S[$i] == 'o' && $rest > $C){
        $work2[$i] = $c--;
        $rest = 0;
    }else{
        $work2[$i] = 0;
    }
    ++$rest;
}
for($i = 0; $i < $N; ++$i){
    if($work[$i] > 0 && $work[$i] == $work2[$i])$ret[] = $i+1;
}
echo implode("\n", $ret);


Measured memory_bytes: 34416
def factorization(n):# 計算量O(√N)
    arr = {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt

    if temp!=1:
        arr[temp]=1

    if arr==[]:
        arr[n] = 1

    return arr



x = int(input())
while(True):
    p = factorization(x)
    if (len(p)==1) & (x in p):
        break
    else:
        x += 1

print(x)


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

const int MOD = (int)1e9+7;

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> K(N);
  vector<vector<int>> A(N,vector<int>(M));
  for(int i=0;i<N;i++){
    cin >> K.at(i);
    for(int j=0;j<K.at(i);j++){
      cin >> A.at(i).at(j);
      A.at(i).at(j)--;
    }
  }

  vector<bool> ans(M,true);
  for(int i=0;i<N;i++){
    vector<bool> x(M,false);
    for(int j=0;j<K.at(i);j++){
      x.at(A.at(i).at(j))=true;
    }
    for(int j=0;j<M;j++){
      if(x.at(j)==false)  ans.at(j)=false;
    }
  }

  int sum=0;
  for(int i=0;i<M;i++){
    if(ans.at(i)==true) sum++;
  }
  cout << sum << endl;

  return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(x) cout << x << endl;

int N = 0;
double ANS = 0;
double CNT = 0;
vector<pair<int, int> > VEC;

void calc(const vector<int>& nums){
    double tmp = 0;
    rep(i, N - 1){
        double xy1 = pow((VEC[nums[i] - 1].first - VEC[nums[i + 1] - 1].first), 2.0);
        double xy2 = pow((VEC[nums[i] - 1].second - VEC[nums[i + 1] - 1].second), 2.0);
        double sum = sqrt(xy1 + xy2);
        tmp += sum;
    }
    ANS += tmp;
    CNT++;
}

int main() {
    cin >> N;
    vector<int> nums(N);
    iota(nums.begin(), nums.end(), 1);

    rep(i, N){
        int x, y; cin >> x >> y;
        VEC.push_back(make_pair(x, y));
    }

    do {
        calc(nums);
    } while(next_permutation(nums.begin(), nums.end()));
    ANS = ANS / CNT;
    printf("%.10lf\n", ANS);
}




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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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;}

void YES(bool b) {cout << (b?"YES\n":"NO\n");}
void Yes(bool b) {cout << (b?"Yes\n":"No\n");}
void yes(bool b) {cout << (b?"yes\n":"no\n");}
void Yay(bool b) {cout << (b?"Yay!\n":":(\n");}

long long powmod(long long a,long long b){
    long long c=1;
    while(b>0){
        if(b&1) c=a*c%mod;
        a=a*a%mod;
        b>>=1;
    }
    return c;
}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

map<long long,long long> prime_factor(long long n) {
    map<long long,long long> ret;
    for(long long i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

int main()
{
	ll n,l=1,sum=0;
	map<ll,ll> fac;
	cin >> n;
	vll a(n);
	rep(i,n){
		cin >> a[i];
		map<ll,ll> tmp=prime_factor(a[i]);
		for(auto&& e:tmp) chmax(fac[e.first],e.second);
	}
	for(auto&& e:fac) l=l*powmod(e.first,e.second)%mod;
	rep(i,n){
		sum=(sum+l*powmod(a[i],mod-2))%mod;
	}
	cout << sum << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;
ll limit=1e18;


int main(){
    int n;
    cin>>n;
    ll ans=1;
    vector<ll> v;
    for(int i=0; i<n; i++){
        ll tmp;
        cin>>tmp;
        v.push_back(tmp);
    
        if(tmp==0){  
            cout<<0<<endl;
            return 0;
        }
    }
    for(int i=0; i<n; i++){
        ans*=v[i];
        if(ans>limit){
            cout<<-1<<endl;
            return 0;
        }
    }

    if(ans<=limit && 0<ans){
        cout<<ans<<endl;
    }else{
        cout<<-1<<endl;
    }
    return 0;
}

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

long long gcd(long long a,long long b){
  if (a%b==0 )return b;
  else return gcd(b,a%b);
}
long long dp[100010];
int main() {
  int n; cin>>n;
  int sum=0;
  for(int i=0;i<n;i++){
    long long a; cin>>a;
    if(a%2!=0) sum++;
  }
  if(sum%2==0) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int min(int n, int m){
    if(n>m) return m;
    else return n;
}
int main(void){
    long N,T,i,now;
    scanf("%ld%ld",&N,&T);
    long t[N];
    for(i=0;i<N;i++) scanf("%ld",&t[i]);
    long ans=T;
    for(i=0;i<N-1;i++){
        now = t[i+1]-t[i];
        ans+=min(now,T);
    }
    printf("%ld",ans);
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define h1 7897897897897897
#define h2 7897466719774591
#define b1 98762051
#define b2 98765431
#define inf 1000000000
#define pi 3.1415926535897932384626
#define LMAX 9223372036854775807
#define ll long long
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pii>
#define SET(a, b) memset(a, b, sizeof(a));
#define all(x) (x).begin(), (x).end()
#define flush fflush(stdout)
#define debug printf("Hello\n")
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
int n, m, k, x, y, sum, cnt, q;
ll a[200005];
ll ans;
vi edges[200005];
void dfs(int x, int p) {
  for (auto y: edges[x]) {
    if (y != p) {
      a[y] += a[x];
      dfs(y, x);
    }
  }
}
int main () {
  ios::sync_with_stdio(false);
  cin.tie(0);
  scanf("%d %d", &n, &q);
  FOR(i, 1, n-1) {
    scanf("%d %d", &x, &y);
    edges[x].pb(y);
    edges[y].pb(x);
  }
  FOR(i, 1, q) {
    scanf("%d %d", &x, &y);
    a[x] += y;
  }
  dfs(1, -1);
  FOR(i, 1, n) {
    printf("%lld%c", a[i], i==n?'\n':' ');
  }
  return 0;
}

Measured memory_bytes: 24320
N,*A = `dd`.split.map &:to_i
cs = {}
cs[A[0] + 1] = 1
ans = 0
(1...N).each{ |k|
  i = k+1
  bi = -(A[k] - i)
  bj = A[k] + i
  ans += (cs[bi] || 0)
  cs[bj] = (cs[bj] || 0) + 1
}
p ans

Measured memory_bytes: 38720
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j,p;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    vi a(n),b(n);
    rep(i,n)cin>>a[i];
    rep(p,100000){
      vi num(101,0);
      rep(i,n)num[a[i]]++;
      rep(i,n)b[i]=num[a[i]];
      bool f=true;
      rep(i,n)if(a[i]!=b[i])f=false,a[i]=b[i];
      if(f)break;
    }
    cout<<p<<endl;
    rep(i,n){
      if(i)cout<<" ";
      cout<<a[i];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  long long int ind,N,M,a[101],b[101],c[101],d[101],m;
  cin >> N >> M;
  REP(i,N) cin >> a[i] >> b[i];
  REP(i,M) cin >> c[i] >> d[i];
  REP(i,N){
    m = 9.0E8+1;
    int ans = -1;
    REP(j,M){
      if(m > abs(a[i]-c[j]) + abs(b[i]-d[j])){
        m = abs(a[i]-c[j]) + abs(b[i]-d[j]);
        ans = j+1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int h[n];
  rep(i,n) cin >> h[i];
  int t=0;
  int ans=0;
  rep(i,n-1){
    if(h[i]>=h[i+1]){
      t++;
    }
    else{
      ans=max(ans,t);
      t=0;
    }
  }
  ans = max(ans,t);
  cout << ans << endl;
  return 0;
    

}


Measured memory_bytes: 640
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var N, M, f, t int
	fmt.Scan(&N, &M)
	s := make([]int, M)
	c := make([]int, M)
	for i := 0; i < M; i++ {
		fmt.Scan(&s[i], &c[i])
	}
	if N == 1 {
		f, t = 0, 10
	} else if N == 2 {
		f, t = 10, 100
	} else {
		f, t = 100, 1000
	}
	for i := f; i < t; i++ {
		if calc(i, s, c) {
			fmt.Println(i)
			return
		}
	}
	fmt.Println(-1)

}
func calc(n int, s, c []int) bool {
	w := strconv.Itoa(n)
	for i := 0; i < len(s); i++ {
		s, _ := strconv.Atoi(string(w[s[i]-1]))
		if s != c[i] {
			return false
		}
	}
	return true
}


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

#define ll long long
const ll Max=100010;
int n,m;
ll num[Max],ans,pre;

int main()
{
	scanf("%d%d",&n,&m);
	for(ll i=1;i<=n;i++)
		scanf("%d",&num[i]);

	for(ll i=1;i<=n;i++)
	{
		if(num[i]+pre>m)
			ans+=num[i]+pre-m,pre=num[i]-(num[i]+pre-m);
		else
			pre=num[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){

	int	a, b, c;

	scanf("%d %d %d", &a, &b, &c);

	if (a < b){
		if (a < c){
			if (b < c){
				printf("%d %d %d\n", a, b, c);
			}
			else{
				printf("%d %d %d\n", a, c, b);
			}
		}
		else{
			printf("%d %d %d\n", c, a, b);
		}
	}
	else{
		if (b < c){
			if (a < c){
				printf("%d %d %d\n", b, a, c);
			}
			else{
				printf("%d %d %d\n", b, c, a);
			}
		}
		else{
			printf("%d %d %d\n", c, b, a);
		}
	}


	return 0;
}

Measured memory_bytes: 1024
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
    #include "lib/dump.hpp"
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

signed main() {
    int n;cin>>n;
    vector<int> a(n);
    map<int, int> d;
    rep(i, n) {
        cin>>a[i];
        d[a[i]]++;
    }
    dump(a);

    int s = 0;
    each(el, d){
        int c = el.second;
        if (c>=2) s += c*(c-1)/2;
    }
    dump(s);

    vi ans;
    rep(i, n){
        int c = d[a[i]];
        int res = s;
        if (c>=2){
            res -= c*(c-1)/2;
            if (c>=3) res += (c-1)*(c-2)/2;
        }
        ans.pb(res);
        cout << res << endl;
    }

    return 0;
}


Measured memory_bytes: 12788
N,M=map(int, input().split())
l,r=map(int, input().split())
l_max=l
r_min=r
for i in range(M-1):
  l,r=map(int, input().split())
  if l_max<l:
    l_max=l
  if r_min>r:
    r_min=r
print(r_min-l_max+1 if r_min>=l_max else 0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;

int n;
set<int> s;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    s.insert(n);
    int cnt = 1;
    while (1) {
        cnt++;
        int p = 0;
        if (n % 2 == 0) p = n / 2;
        else p = 3 * n + 1;
        if (s.count(p)) {
            cout << cnt;
            return 0;
        }
        s.insert(p);
        n = p;
    }
    return 0;
}

Measured memory_bytes: 256
//#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;


// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T>
constexpr int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F>
constexpr int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T>
void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C>
void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U>
constexpr void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U>
constexpr void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C>
constexpr void reverse(C& c) { reverse(ALL(c)); }
template<typename C>
constexpr void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred>
constexpr void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9+7)
#pragma endregion


int main()
{
    int a, b;
    while(cin>>a>>b) P(a+b);
    return 0;
}

Measured memory_bytes: 3052
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}







int main(){
    int N, X, T; std::cin >> N >> X >> T;
    std::cout << (N+X-1)/X * T << std::endl;
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define ff first
#define ss second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1e9 + 7;
const int N = int(3e5) + 999;
#define int long long int
#define inf 1e18

int n, k;
vector<int> arr;
int dp[100005][2];

int solve(int k, int move)
{
    if (dp[k][move] != -1)
        return dp[k][move];
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (k >= arr[i])
            ans = ans || (!solve(k - arr[i], !move));
    }
    return (dp[k][move] = ans);
}

int32_t main()
{
    IOS;
    cin >> n >> k;
    memset(dp, -1, sizeof dp);
    arr.resize(n + 1);
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    solve(k, 0);
    if (dp[k][0])
        cout << "First";
    else
        cout << "Second";

    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i < n; i++)
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n-k; i++) {
    long long s0,s1;
    s0 = a[i];
    s1 = a[k + i];
    if(s1 > s0) cout << "Yes";
    else cout << "No";
    cout << endl;
  }
}

Measured memory_bytes: 4056
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int[] d = new int[n];
    for(int i = 0; i<n; i++) {
      d[i] = sc.nextInt();
    }
    
    Arrays.sort(d);
    
    System.out.println(d[n/2] - d[n/2-1]);
    
    
  }
}


Measured memory_bytes: 51216
N, K = gets.split.map(&:to_i)

x = (N - 1)*(N - 2) / 2
if K > x
  puts '-1'
else
  y = x - K
  puts N - 1 + y
  (N - 1).times{|i| puts "1 #{i + 2}"}
  [*2 .. N].combination(2).take(y).each{|a| puts a.join(' ')}
end

Measured memory_bytes: 2300
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

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

    int n; cin >> n;
    int m = n%10;
    if (m==2||m==4||m==5||m==7||m==9) puts("hon");
    else if (m==0||m==1||m==6||m==8) puts("pon");
    else puts("bon");
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pub push_back
#define pob pop_back
#define loops(i, s, n) for (int i = s; i < n; i++)
#define loop(i, n) for (int i = 0; i < n; i++)
#define loopr(i, s, e) for (int i = s; i >= e; i--)
#define eps 1e-9
#define loopitr(mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define pii pair<int, int>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int, int>>
#define even_set 0xAAAAAAAA ... 1010101010
#define odd_set 0x55555555 ... 01010101
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vall(v) v.begin(), v.end()
#define mkp make_pair
#define ret return
#define cont continue
#define nl endl
#define ff first
#define ss second
#define cnt_bits __builtin_popcount
#define test  \
    int T;    \
    cin >> T; \
    while (T)
#define arrinit        \
    int n;             \
    cin >> n;          \
    int arr[n];        \
    loop(i, n)         \
    {                  \
        cin >> arr[i]; \
    }
#define init(arr, n, val)       \
    for (int i = 0; i < n; i++) \
        arr[i] = val;
const int mod = 1000000007;

int main()
{

    fastio;
    ll n, k;
    cin >> n >> k;

    ll dp[k + 1]; // no of ways if i candies have been used so far
    init(dp, k + 1, 0);
    dp[0] = 1;

    loop(i, n)
    {
        ll lim;
        cin >> lim;
        ll temp[k + 1];
        init(temp, k + 1, 0);

        for (ll used = k; used >= 0; used--)
        {
            int l = used + 1;
            int r = used + min(lim, k - used);
            if (l <= r)
            {
                (temp[l] += dp[used]) %= mod;
                if (r + 1 <= k)
                    temp[r + 1] = (temp[r + 1] - dp[used] + mod) % mod;
            }
            // loops(x, 1, min(lim, k-used) + 1)
            // {
            //     dp[x + used] += dp[used];
            //     // dp[used] += (((used -x)>=0)? dp[used- x] : 0 );
            // }
        }

        loops(i, 1, k + 1)
        {
            (temp[i] += temp[i - 1]) %= mod;
            (dp[i] += temp[i]) %= mod;
        }
    }

    cout << dp[k] << endl;
}

Measured memory_bytes: 5128
def solve
  A.reverse.inject([2,2]){|(l,h),a|
    nh=a*(h/a)+(a-1)
    return [-1] if nh < a
    nh=[nh,h].max

    nl = a*((l+a-1)/a)
    return [-1] unless nl <= nh
    [nl, nh]
  }
end

K=gets.to_i
A=gets.split.map &:to_i
puts solve*" "


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

int ctoi(char c) {
    int n = c - '0';
    return n;
}

int pow_int(int x, int n) {
    if (n == 0) {
        return 1;
    }else {
        int y = x;
        for (int i = 0; i < n-1; i++) {
            x *= y;
        }
        return x;
    }
}


int main() {
    int r;
    cin >> r;
    double ans = 2 * r * 3.14159265358979323846;
    cout << ans << endl;
}


Measured memory_bytes: 3788
K,T=map(int,input().split())
N=list(map(int,input().split()))

L=[[i for i in range(2)]for j in range(T)]
for i in range(T):
    L[i][0]=i
    L[i][1]=N[i]

f=-1
c=0
for K in range(K):    
    L1=sorted(L,key=lambda x:x[1])
    if(f!=L1[-1][0]):
        f=L1[-1][0]
        L1[-1][1]-=1
    elif(L1[T-2][1]>0 and L1[T-2][0]!=f):
        f=L1[T-2][0]
        L1[T-2][1]-=1     
    else:
        c+=1
        f=L1[-1][0]
        L1[-1][1]-=1       
print(c)    

Measured memory_bytes: 40684
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  string str;
  int a = 0, b = 0, ab = 0, o = 0;
  while (getline(cin, str)) {
    string s = str.substr(str.find_first_of(",")+1);
    if (s == "A") {
      a++;
    } else if (s == "B") {
      b++;
    } else if (s == "O") {
      o++;
    } else {
      ab++;
    }
  }
  cout << a << endl << b << endl << ab << endl << o << endl;
  return 0;
}

Measured memory_bytes: 1184
N = gets.to_i
S = gets.chomp
dp = Array.new(N,0)
1.upto(N) do |i|
    dp[0]+=1 if S[i] == "E"
end
(N-1).times do |i|
    dp[i+1] = dp[i]
    dp[i+1] -= 1 if S[i+1] == "E"
    dp[i+1] += 1 if S[i] == "W"
end
puts dp.min

Measured memory_bytes: 4868
using System;
namespace kozaiyApp
{
    public class EuclideanAlgorithm
    {
        static void Main()
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int x = 1;
            int y = 1;
            ExtGcd(a, b, ref x, ref y);
            Console.WriteLine("{0} {1}", x, y);
        }

        // 拡張ユークリッドの互除法 
        public static int ExtGcd(int a, int b, ref int x, ref int y)
        {
            int d = a;
            if (b != 0)
            {
                d = ExtGcd(b, a % b, ref y, ref x);
                y -= (a / b) * x;
            }
            else
            {
                x = 1;
                y = 0;
            }
            return d;
        }

    }
}



Measured memory_bytes: 17984
/*--------------------------"SABUJ-JANA"------"JADAVPUR UNIVERSITY"--------*/
/*-------------------------------@greenindia-----------------------------------*/
//
//		  _____       _           _        _
//		 / ____|     | |         (_)      | |
//		| (___   __ _| |__  _   _ _       | | __ _ _ __   __ _
//		 \___ \ / _` | '_ \| | | | |  _   | |/ _` | '_ \ / _` |
//		 ____) | (_| | |_) | |_| | | | |__| | (_| | | | | (_| |
//		|_____/ \__,_|_.__/ \__,_| |  \____/ \__,_|_| |_|\__,_|
//		                        _/ |
//		                       |__/
/*---------------------- Magic. Do not touch.-----------------------------*/
/*------------------------------God is Great/\---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//cout<<fixed<<showpoint<<setprecision(12)<<ans<<endl;
#define int long long int
#define double long double
#define PI acos(-1)

void print1d(const vector<int>& vec) {for (auto val : vec) {cout << val << " ";} cout << endl;}

void print2d(const vector<vector<int>>& vec) {for (auto row : vec) {for (auto val : row) {cout << val << " ";} cout << endl;}}

signed main() {
 
	crap;

	string str;
	cin >> str;

	if(str[2] == str[3] and str[4] == str[5])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;



	return 0;
}






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

using namespace std;
using lli = int_fast64_t;
using ulli = unsigned long long;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = copy(x);cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

constexpr lli MOD = (lli)1e9 + 7;
constexpr lli LIMIT = 1000000000000000000 * 5;

int main() {
	lli N, M, K;
	cin >> N >> M >> K;
	vector<lli> A(N+1), B(M+1);
	for (int i = 0; i < N; i++) {
		cin >> A[i+1];
		A[i + 1] += A[i];
	}

	for (int i = 0; i < M; i++) {
		cin >> B[i+1];
		B[i + 1] += B[i];
	}

	int bc = 0;
	for (int i = 0; i <= M; i++) {
		if (B[i] <= K)bc = i;
	}
	int ans = 0;
	for (int i = 0; i <= N; i++) {
		while (bc != 0&&(A[i] + B[bc]) > K) {
			bc--;
			
		}
		if (A[i] + B[bc] <= K) {
			ans = max(ans, i + bc);
		}
		else {
			break;
		}
	}

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



Measured memory_bytes: 6372
#include <atcoder/lazysegtree>
#include <atcoder/modint>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
struct S { mint a, b; };
using F = int;
S op(S l, S r) { return S{l.a * (9 * r.b + 1) + r.a, l.b * (9 * r.b + 1) + r.b}; }
S e() { return S{0, 0}; }
F id() { return -1; }
S mapping(F f, S x) { return f == id() ? x : S{x.b * f, x.b}; }
F composition(F f, F g) { return f == id() ? g : f; }
main() {
    F n, q;
    cin >> n >> q;
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(vector(n, S{1, 1}));
    while (q--) {
        F l, r, d;
        cin >> l >> r >> d;
        seg.apply(l - 1, r, d);
        cout << seg.all_prod().a.val() << '\n';
    }
}

Measured memory_bytes: 9808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main(){
  string s,t;
  std::cin >> s>>t;
  int a,b;
  std::cin >> a>>b;
  string u;
  std::cin >> u;

  if(u==s)a--;
  if(u==t)b--;
  printf("%d %d\n",a,b);

  return 0;
}


Measured memory_bytes: 256
s = input()

ans = 0
while len(s) != 0:
    if s[0] == s[-1]: s = s[1:-1]
    else:
        if s[0] == 'x': 
            s = s + 'x'
            ans += 1
        elif s[-1] == 'x': 
            s = 'x' + s
            ans += 1
        else:
            print(-1)
            exit()
print(ans)

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


int N, M;  //N頂点M辺
vector<int> visited;
vector<vector<int>> G;


int main() {
  cin >> N >> M;
  G = vector<vector<int>>(N); // サイズを確保する
  for(int i=0; i<M; i++){
    int a, b;
    cin >> a >> b;
    // 頂点番号を 0-indexed とする
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  queue<int> q;
  for(int nv:G[0])q.push(nv);
  while(!q.empty()){
    int v=q.front();
    q.pop();

    for(int nv:G[v]){
      if(nv==N-1){cout << "POSSIBLE" << endl; return 0;}
    }
  }
  cout << "IMPOSSIBLE" <<endl;    
}

Measured memory_bytes: 12400
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N;
  cin >> N;
  
  long long A[N];

  for (long i = 0; i < N; i++) {
      cin >> A[i]; 
  }
  
  long long count = 0;

  for (long i = 0; i < N-1; i++) {
      if (A[i+1] < A[i]){
          count += (A[i] - A[i+1]); 
          A[i+1] = A[i];
      } 
  }
 
  cout << count <<endl;
      
}

Measured memory_bytes: 5124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1001001001;

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	int n, k;
	cin >> n >> k;
	map<int, int> mp;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (mp.count(a)) mp[a]++;
		else mp[a] = 1;
	}

	vector<pair<int, int>> vec;
	for (auto item : mp) {
		vec.push_back(make_pair(item.second, item.first));
	}
	sort(vec.begin(), vec.end());

	int count = 0;
	int ans = 0;
	for (int i = 0; i < vec.size(); i++) {
		if (vec.size() - count <= k) break;
		count++;
		ans += vec[i].first;
	}
	cout << ans << endl;
}

Measured memory_bytes: 11768
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl

//ここからAtCoder向けdefine
#define yes cout << "Yes" << endl
#define no cout << "No" << endl

using namespace std;

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using pint = pair<int,int>;

const int INF = ~(1 << 31);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vi vec[3];
    int n;
    rep(i, 3){
        rep(j, 3){
            cin >> n;
            vec[i].push_back(n);
        }
    }
    vi diff(4);
    diff[0] = vec[0][0] - vec[0][1];
    diff[1] = vec[0][1] - vec[0][2];
    diff[2] = vec[0][0] - vec[1][0];
    diff[3] = vec[1][0] - vec[2][0];
    REP(i, 1, 3){
        if(vec[i][0] - vec[i][1] != diff[0]){ no; return 0; }
    }
    REP(i, 1, 3){
        if(vec[i][1] - vec[i][2] != diff[1]){ no; return 0; }
    }
    REP(i, 1, 3){
        if(vec[0][i] - vec[1][i] != diff[2]){ no; return 0; }
    }
    REP(i, 1, 3){
        if(vec[1][i] - vec[2][i] != diff[3]){ no; return 0; }
    }
    yes;

    return 0;
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long min = (long) 1e9;
		for(int i=0;i< (1 << D);i++){
			long sc = 0;
			long cnt = 0;
			for(int j=0;j<D;j++){
				if(((i >> j) & 1) == 0) continue;
				sc += C[j];
				sc += 100 * (j + 1) * P[j];
				cnt += P[j];
			}
			if(sc >= G){
				min = Math.Min(cnt, min);
				continue;
			}
			for(int j=D-1;j>=0;j--){
				if(((i >> j) & 1) == 1) continue;
				if(P[j] == 1) continue;
				if((j + 1) * (P[j] - 1) * 100 + sc < G) {
					sc += (j + 1) * 100 * (P[j] - 1);
					cnt += (P[j] - 1);
					continue;
				} else {
					long u = 100 * (j + 1);
					cnt += (G - sc + u - 1) / u;
					min = Math.Min(cnt, min);
					break;
				}
			}
			
		}
		Console.WriteLine(min);
		
	}
	
	int D;
	long G;
	long[] P,C;
	public Sol(){
		var d = rla();
		D = (int) d[0]; G = d[1];
		P = new long[D];
		C = new long[D];
		for(int i=0; i<D; i++){
			d = rla();
			P[i] = d[0]; C[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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; }

void Main(){
    int N; cin >> N;
    VL A(N); REP(i,N) cin >> A[i];
    ll X = 0; REP(i,N-2) X ^= A[i+2];
    ll S = A[0]+A[1];

    if(S-X<0 || (S-X)%2){
        cout << -1 << en;
        return;
    }

    ll D = (S-X)/2;
    if(D > A[0]){
        cout << -1 << en;
        return;
    }

    ll Y = 0;
    RREP(i,51){
        if(!((X>>i)&1)) continue;
        ll tmp = Y | 1LL<<i;
        if((D^tmp)>A[0]) continue;
        Y |= 1LL<<i;
    }
    ll ans = A[0]-(D^Y);
    if(ans >= A[0]){
        cout << -1 << en;
        return;
    }

    ll a1 = A[0]-ans, a2 = A[1]+ans;
    ll s=a1+a2, x=a1^a2, d=a1&a2;
    if(!(s==S && x==X && d==D)){
        cout << -1 << en;
        return;
    }
    cout << (ans<A[0] ? ans : -1) << en;

    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3668
defmodule Main do
  def main do
    IO.stream(:stdio, :line)
    |> Enum.take(3)
    |> Enum.map(&String.trim/1)
    |> Enum.map(&String.split(&1, "", trim: true))
    |> process("a")
    |> IO.puts()
  end
  
  defp process([[], _, _], "a"), do: "A"
  defp process([_, [], _], "b"), do: "B"
  defp process([_, _, []], "c"), do: "C"
  defp process([[head | tail], b, c], "a"), do: process([tail, b, c], head)
  defp process([a, [head | tail], c], "b"), do: process([a, tail, c], head)
  defp process([a, b, [head | tail]], "c"), do: process([a, b, tail], head)
end

Measured memory_bytes: 31124
#include <iostream>
#include <string>
#include <map>
using namespace std;
string z(int i){string s="";if(i>25){s+='a'+i/25;i%=25;}s+='a'+i;return s;}
int main(){
	string s;
	map<string,int>m;
	int i=0;
	cout<<"?shiritori"<<endl<<flush;
	for(;i<50;i++){
		cin>>s;
		if(s[0]!='i'||m[s]){cout<<"!OUT"<<endl;return 0;}
		m[s]=1;cout<<string("?")+s[s.size()-1]<<z(i)+"i"<<endl<<flush;
	}
}

Measured memory_bytes: 0
<?php
fscanf(STDIN,"%d", $n);
for ($m=0;$m<$n;$m++) {
    fscanf(STDIN,"%d %d %d",$a[0],$a[1],$a[2]);
    rsort($a);
    echo ($a[0]*$a[0]) === ($a[1]*$a[1]) + ($a[2]*$a[2]) ? "YES" : "NO", PHP_EOL;
}

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

int main(){
  long long int n,i,j,a,kari=0,kotae1=1,kotae2=1;
  cin>>n;
  int f[9],c[n+1];
  f[0]=1;
  for(i=1;i<=8;i++){
    f[i]=f[i-1]*i;
  }
  for(i=0;i<=n;i++){
    c[i]=1;
  }
  for(i=0;i<n;i++){
    cin>>a;
    c[a]=0;
    kari=0;
    for(j=1;j<a;j++){
      if(c[j]==1){
        kari++;
      }
    }
    kotae1+=kari*f[n-i-1];
  }
  for(i=0;i<=n;i++){
    c[i]=1;
  }
  for(i=0;i<n;i++){
    cin>>a;
    c[a]=0;
    kari=0;
    for(j=1;j<a;j++){
      if(c[j]==1){
        kari++;
      }
    }
    kotae2+=kari*f[n-i-1];
  }
  cout<<abs(kotae1-kotae2);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopb(i,a,b) for(int i=a;i>=b;i--)
#define loopm(i,a,b,step) for(int i=a;i<b;i+=step)
#define loopbm(i,a,b,step) for(int i=a;i>=b;i-=step)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define int long long int
#define double long double
#define what_is(x) cerr << #x << " is " << x << endl;
using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int setbits(int x)
{
		return __builtin_popcount(x);
}



const int MOD=1e9+7;
const int INF=1e18;

int mul(int a,int b)
{
	if(a>INF/b) return INF;
	else return a*b;
}

const int N=2e5+5;

int a[N];
  int n;
int f(int x)
{
	int ans=0;
	loop(i,0,n)
	{
		ans+=abs(a[i]-x);
	}
	return ans;
}


#undef int
int main()
{
#define int long long int
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  //  freopen("input.txt","r",stdin);
  
    cin>>n;
    
    loop(i,0,n)
    {
    	cin>>a[i];
    	a[i]-=(i+1);
    }
    
    int lo = -2e9, hi = 2e9;
while (hi - lo > 1){
    int mid = (hi + lo)>>1;
    if (f(mid) < f(mid + 1)) 
       hi=mid;
    else 
        lo=mid;
}
cout<<f(lo+1);
 
    return 0;
}

Measured memory_bytes: 1792