akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

constexpr ll LNF = 1ll<<60;

constexpr int INF = 1e9+7;

vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */
ll n,a,b,c,d;
map<ll,ll> m;

ll dfs(ll here){
    if(m[here]!=0) return m[here];
    if(here<=0) return 0;
    if(here==1) return d;
    ll t = LNF;
    if(here<LNF/d) t = here*d;
    chmin(t,a+d*(here%2ll)+dfs(here/2ll));
    if(here%2==1){
        chmin(t,a+d+dfs((here+1ll)/2ll));
    }
    chmin(t,b+d*(here%3ll)+dfs(here/3ll));
    if(here%3!=0){
        chmin(t,b+d*(3ll-here%3ll)+dfs((here+2ll)/3ll));
    }
    chmin(t,c+d*(here%5ll)+dfs(here/5ll));
    if(here%5!=0){
        chmin(t,c+d*(5ll-here%5ll)+dfs((here+4ll)/5ll));
    }
    m[here] = t;
    return t;
};

ll solve(){
    cin >> n >> a >> b >> c >> d;
    m.clear();
    return dfs(n);
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int t; cin >> t;
    rep(_,0,t){
        ll ans = solve();
        cout << ans << endl;
    }
}

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

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<ll, ll> pii;
typedef vector< ll > vl;
typedef vector< pii > vpii;

//DONT WASTE YOUR TIME
//prove yourself
//remember....fuck ps&&as hard....show them your are better then them
//Be confident.....dont lose hope.......You can do it.....
//dimaag  khoob h tere meh ....bas concentration ki kami h
//CONCENTRATE
//A,B,C dimaag nhi ...observation h .....zyaada mat sochna unme.....bas observe karna dhyaan se aur implement kar daal jitni jaldi ho sake

//capture it

const ll N= 1e6+55,mod = 1e9+7;

int main() {
 	//freopen("task.in","r",stdin);freopen("task.out","w",stdout);
	ll i,j,k,x,y,z,a,b,c;
	sc(x);sc(a);sc(b);
	x-=a;
	j=x%b;
	pr(j);

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>
#include<chrono>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#define int128 __int128
#else
#define int128 long long
#endif

#define all(x) x.begin(), x.end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));


struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

ll mod = 1e9 + 7;

namespace {
    ll mul(ll a, ll b) {
        ll val = a * b - (ll)((ld)a * b / mod) * mod;
        if (val < 0) val += mod;
        if (val >= mod) val -= mod;
        return val;
    }
    ll poww(ll a, ll b) {
        ll val = 1;
        a %= mod;
        while (b > 0) {
            if (b % 2) val = mul(a, val);
            a = mul(a, a);
            b >>= 1;
        }
        return val % mod;
    }
    ll inv(ll a) {
        return poww(a, mod - 2);
    }
}

ll const maxn = 3e5+5;

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("output.txt", "w", stdout);
    ll n; cin >> n;
    vector<ll>a(n);
    ll sm = 0;
    for (ll i = 0; i < n; i++) cin >> a[i], sm^=a[i];
    vector<ll>b(n);
    for (ll i = 0; i < n; i++) {
        b[i] = (sm ^ a[i]);
        //b[i] = (a[i - 1] ^ a[i]) ^ b[i - 1];
    }
    sm = 0;
    for (ll i = 0; i < n; i++) sm ^= b[i];
    for (ll i = 0; i < n; i++) {
        assert(a[i] == (sm ^ (b[i])));
    }
    for (ll i = 0; i < n; i++) {
        cout << b[i] << " ";
    }


    return 0;
}

/*

*/

Measured memory_bytes: 6364
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define sqr(x) (x) * (x)

using namespace std;
//using namespace __gnu_pbds;

mt19937_64 gen(time(0));

//typedef tree<
//pair <int, int>,
//null_type,
//less<pair <int, int>>,
//rb_tree_tag,
//tree_order_statistics_node_update>
//ordered_set;

//const int inf = 2e9 + 6555;
//const int mod = 1e9 + 7;
//const int maxn = 1e5 + 555;



signed main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif
    string s;
    cin >> s;
    int x = 0;
    for(char c : s)
        x += int(c - '0');
    if (x % 9 == 0) cout << "Yes";
        else cout << "No";
    return 0;
}


Measured memory_bytes: 3684
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    cin >> n;
    vector<int> arr(n, 0);
    vector<int> other;
    int ten = 0;
    for(auto& val: arr) {
        cin >> val;
        if (val % 10 == 0) {
            ten += val;
        } else {
            other.push_back(val);
        }
    }
    int acc = accumulate(other.begin(), other.end(), 0);
    if (acc % 10 == 0 && other.size() > 0) {
        sort(other.begin(), other.end());
        acc -= other[0];
    }
    if ((acc + ten) % 10 == 0) {
        cout << 0 << endl;
    } else {
        cout << acc + ten << endl;
    }
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    string s,t;
    cin>>s>>t;
    bool flag=false;
    string scopy=s;
    vector<string> anscand;
    for(int i=s.length()-t.length();i>=0;i--){
        s=scopy;
        flag=true;
        for(int j=0;j<t.length();j++){
            if(s[i+j]=='?') continue;
            if(t[j]!=s[i+j]) {
                flag=false;
                break;
            }
        }
        if(flag){
            for(int j=0;j<t.length();j++){
                s[i+j]=t[j];
            }
            for(int i=0;i<s.length();i++){
                if(s[i]=='?') s[i]='a';
            }
            anscand.push_back(s);            
        }
        
    }
    sort(anscand.begin(),anscand.end());
    if(!anscand.empty()){
        cout<<anscand[0]<<endl;
    }else{
        cout<<"UNRESTORABLE"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>

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

using namespace std;
typedef long long ll;
typedef pair<int, int>P;

const ll sqrtN = 512;
const ll INF = (1LL << 31) - 1;

struct SqrtDecomposition {
	int N, K;
	vector<ll>data;
	vector<ll>bucketMin;
	SqrtDecomposition(ll n) :N(n) {
		K = (N + sqrtN - 1) / sqrtN;
		data.assign(K*sqrtN,INF);
		bucketMin.assign(K,INF);
	}
	void update(ll x, ll y) {
		ll k = x / sqrtN;
		ll minVal = data[x] = y;
		for (int i = k*sqrtN; i < (k + 1)*sqrtN; ++i)
			minVal = min(minVal, data[i]);
		bucketMin[k] = minVal;
	}
	int find(ll x, ll y) {
		ll minVal = INF;
		for (int k = 0; k < K; ++k) {
			ll l = k * sqrtN, r = (k + 1) * sqrtN;
			if (r <= x || y <= l)continue;
			if (x <= l && y >= r)
				minVal = min(minVal, bucketMin[k]);
			else {
				for (int i = max(x, l); i < min(y, r); ++i)
					minVal = min(minVal,data[i]);
			}
		}
		return minVal;
	}
};

int main()
{
	ll N, Q; cin >> N >> Q;
	SqrtDecomposition decomp(N);
	while (Q--) {
		int c, x, y;
		cin >> c >> x >> y;
		if (c == 0)decomp.update(x, y);
		else cout << decomp.find(x, y + 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 3540
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()
const ll MOD = 1e9 + 7;
ll dp[1000001][2][2];

int main() {
    int N;
    cin >> N;
    dp[0][0][0] = 1;
    REP(i, N) REP(j, 2) REP(k, 2) REP(d, 10) {
        dp[i + 1][j || d == 0][k || d == 9] += dp[i][j][k];
        dp[i + 1][j || d == 0][k || d == 9] %= MOD;
    }
    cout << dp[N][1][1] << endl;
    return 0;
}

Measured memory_bytes: 34876
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        if (b % a == 0) System.out.println(a + b);
        else System.out.println(b - a);

        sc.close();
    }
}

Measured memory_bytes: 21716
#include <stdio.h>
#include <math.h>
int main()
{
	int n,i,j,ans=0,c;
	scanf("%d",&n);
	for(i=1; i<=n; i=i+2){
		c=0;
        for(j=1; j<=i; j++){
            if(i%j==0){
				c++;
            }
        }
        if(c==8){
			ans++;
        }
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
function gcd(a: number, b: number, c: number) {

    const f = (x: number, y: number) => y ? f(y, x % y) : x

    var ans = a
    ans = f(ans, b);
    ans = f(ans, c);
    return ans
}

import * as fs from "fs";
const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const [k] = input[0].split(" ").map((x: string): number => +x);
// const k = 200

var sum = 0
let maps: Map<string, number> = new Map<string, number>()

for (var x: number = 1; x <= k; x++) {
    for (var y: number = 1; y <= k; y++) {
        for (var z: number = 1; z <= k; z++) {
            // let t = [x, y, z]
            // t = t.sort(function (p: number, q: number) {
            //     return p - q
            // })
            // const xyz: string = t[0].toString() + t[1].toString() + t[2].toString()
            // if (!maps.has(xyz)) {
            //     const res = gcd(x, y, z)
            //     maps[xyz] = res
            // }
            // sum += maps[xyz]
            sum += gcd(x, y, z)
        }
    }
}

console.log(sum)

Measured memory_bytes: 34552
#!/usr/bin/env python3

from pprint import pprint
import sys

sys.setrecursionlimit(10 ** 6)
INF = float('inf')


x, n = map(int, input().split())
P = list(map(int, input().split()))

diff = INF
res = None

for i in range(-200, 200):
    if i in P:
        continue
    if abs(x - i) < diff:
        res = i
        diff = abs(x - i)

print(res)


Measured memory_bytes: 71628
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long a1, b1, r1, r2, temp, a2, b2;

		while(scan.hasNext()){
			a1 = scan.nextInt();
			a2 = a1;
			b1 = scan.nextInt();
			b2 = b1;
			while(a2 % b2 != 0){
				if(a2 < b2){
					temp = a2;
					a2 = b2;
					b2 = temp;
				}
				a2 = a2 % b2;
			}
			r1 = b2;
			r2 = (a1*b1) / r1;
			System.out.println(r1+" "+r2);
		}
	}

}

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

int main() {
  int K, N;
  cin >> K >> N;
  vector<int> A(N);
  int max_dis = 0;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    if (i == 0) continue;
    if (A.at(i) - A.at(i-1) > max_dis) {
    max_dis = A.at(i) - A.at(i-1);
    }
  }
  max_dis = max_dis > K - A.at(N-1) + A.at(0)
    ? max_dis : K - A.at(N-1) + A.at(0);
  int ans = K - max_dis;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [usize; n-1]
    }

    let mut buka: Vec<i32> = (0..n+1).map(|_| 0).collect();
    for i in 0..n-1 {
        buka[a[i]] += 1;
    }
    for i in 1..n+1 {
        println!("{}", buka[i]);
    }
}


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

int main(){

    string s;
    cin >> s;
    //cout << (s < t) << endl;
    
    if(s == "zyxwvutsrqponmlkjihgfedcba") cout << -1 << endl;

    int a[26] = {};
    for(int i = 0; i < s.size(); i++){
        a[(int)(s[i] - 'a')] = 1;
    }

    if(s.size() != 26){
        char c;
        for(int i = 0; i < 26; i++){
            if(!a[i]){
                c = i + 'a';
                break;
            }
        }

        cout << s << c << endl;
    }else{

        for(int i = 25; i >= 0; i--){
            for(int j = 0; j < 26; j++){
                if(!a[j] && s[i] < j + 'a'){
                    s[i] = j + 'a';
                    for(int k = 0; k <= i; k++){
                        cout << s[k];
                    }
                    cout << endl;
                    return 0;
                }
            }

            a[(int)(s[i] - 'a')] = 0;
        }

        //cout << s << endl;
    }
    return 0;
}

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

void solve(long long N){
    map<ll, ll> mp;
    for(ll i = 2; i <= N; ++i){
        ll ii = i;
        for(ll j = 2; j <= ii; ++j){
            while(ii % j == 0){
                ii /= j;
                mp[j]++;
            }
        }
    }
    ll ans = 1;
    for(auto i : mp){
        ans = ((ans%MOD) * (i.second+1)%MOD) % MOD;
    }
    cout << ans << endl;
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3676
/*
* @Author: Kabid
* @Date:   2020-04-26 18:01:07
* @Last Modified by:   Kabid
* @Last Modified time: 2020-05-17 22:32:58
*/
#include<bits/stdc++.h>

#define ll long long
#define  in(x) scanf("%d",&x);
#define out(x) printf("%d",x);
#define  ins(x)  scanf("%s",x);
#define outs(x) printf("%s",x);
#define lin puts("");
#define _ putchar(' ');
using namespace std;

int t;       //test cases
int a,b,h,m;
double pi =acos(-1.0);
int main() {
	cin >> a>>b;

cout<<a*b<<endl;



	return 0;
}




Measured memory_bytes: 3596
#include <iostream>

using namespace std;

int main()
{
    int n;
	cin >> n;
	int count = 0;
	int a, b,flag=0;

	for (int i = 0; i < n; i++)
	{
		cin >> a >> b;
		if (a == b)
        {
           count++;
           if (count >= 3)
           {
               flag=1;
           }
        }
			else
                count=0;

	}
	if (flag==1)
		cout << "Yes";
	else
		cout << "No";
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  int n,m; cin >> n >> m;
  int road[n] = {0};
  rep(i,m){
    int a,b;cin >> a >> b;
    road[a-1]++;
    road[b-1]++;
  }
  rep(i,n){
    cout << road[i] << endl;
  }
}

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

int n,c[10][10];

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++){
		int x=i%10,p=i,y=0;
		while(p!=0){
			y=p%10;
			p/=10;
		}
		c[x][y]++;
	}
	int ans=0;
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++){
			ans+=c[i][j]*c[j][i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::stdin;
use std::str::FromStr;
use std::collections::HashSet;
use std::cmp::max;
use std::cmp::min;

fn main(){
    let (h, w, n): (i64, i64, i64) = get_triple();
    let mut abs: Vec<(i64, i64)> = Vec::new();
    for _ in 0..n {
        abs.push(get_pair());
    }

    let mut blacks = HashSet::new();
    let mut visited = HashSet::new();

    for &(a, b) in &abs {
      blacks.insert((a, b));
    }

    let mut anss = vec![0;10];

    for &(u, v) in &blacks {
        for s in max(2, u-1)..min(h, u+2) {
            for t in max(2, v-1)..min(w, v+2) {
                if visited.contains(&(s, t)) { continue; }
                visited.insert((s, t));

                let mut b = 0;
                for x in s-1..s+2 {
                    for y in t-1..t+2 {
                        if blacks.contains(&(x, y)) {
                            b += 1;
                        }
                    }
                }
                anss[b as usize] += 1;
            }
        }
    }

    anss[0] = (h-2) * (w - 2);
    anss[0] -= anss[1..10].iter().fold(0, |acc, x| acc + x);
    for ans in &anss {
        println!("{}", ans);
    }
}


#[allow(dead_code)]
fn get_line() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn get_vec<T: std::str::FromStr>() -> Vec<T> {
    let line = get_line();
    line.split_whitespace().filter_map(|x| x.parse().ok()).collect()
}

#[allow(dead_code)]
fn get_one<T: FromStr + Copy>() -> T {
    let v = get_vec();
    v[0]
}

#[allow(dead_code)]
fn get_pair<T: FromStr + Copy>() -> (T, T) {
    let v = get_vec();
    (v[0], v[1])
}

#[allow(dead_code)]
fn get_triple<T: FromStr + Copy>() -> (T, T, T) {
    let v = get_vec();
    (v[0], v[1], v[2])
}

#[allow(dead_code)]
fn get_chars() -> Vec<char> {
    get_line().chars().collect()
}

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

// You want the "biggest power of 2 that doesn't exceed X"

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	ll h;
	cin >> h;
	if(h == 1) {
		cout << 1;
		return 0;
	}
	// clz = count leading zeroes
	ll b = 1LL << (63 - __builtin_clzll(h));
	while(2 * b <= h) b *= 2;
	cout << 2 * b - 1 << endl;

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>

using namespace std;

int main() {
  long N;
  cin >> N;
  
  vector<long> nums(N);
  for (size_t n = 0; n < N; ++n) cin >> nums[n];
  
  size_t right = 0;
  long sum = nums[0];
  long xo = nums[0];
  long res = 0;
  for (size_t left = 0; left < N; ++left) {
    while (right < N && sum == xo) {
      ++right;
      sum += nums[right];
      xo ^= nums[right];
    }
    res += right - left;
    sum -= nums[left];
    xo ^= nums[left];
    if (left == right) ++right;
  }
  cout << res << endl;
  
  return 0;
}

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

int G[110][110];

int main(){
    int N; cin >> N;
    for( int i = 0; i < N; i++ ){
        int u, k; cin >> u >> k;
        u--;
        for( int j = 0; j < k; j++ ){
            int v; cin >> v;
            v--;
            G[u][v] = 1;
        }
    }

    for( int i = 0; i < N; i++ ){
        for( int j = 0; j < N; j++ ){
            cout << G[i][j] << ( ( j == N - 1 ) ? "\n" : " " );
        }
    }
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;

int N, K;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N >> K;
  vector<pair<int, int> > v;
  map<int, int> mp;
  set<int> st;
  int res = 0;
  for(int i=0; i<N; ++i){
    int x; cin >> x;
    st.insert(x);
    ++mp[x];
  }
  auto it = mp.begin();
  while(it != mp.end()){
    v.push_back({it->first, it->second});
    ++it;
  }
  mp.clear();
  sort(all(v), [&](const pair<int, int> a, const pair<int, int> b){
         return a.second < b.second;
      });
  int p = st.size(), id = 0;
  st.clear();
  while(p > K && id < (int)v.size()){
    res += v[id].second;
    --p;
    ++id; 
  }
  cout << res << "\n";
  return 0;  
}



Measured memory_bytes: 21236
#include<bits/stdc++.h>
#define reg register
#define ll long long
#define inf 0x3f3f3f3f
#define iinf 0x3f3f3f3f3f3f3f3f
#define lowbit(x) x&(-x)
#define isdigit(ch) (ch>='0'&&ch<='9')
#define P (ll)(pow(10,9)+7)
using namespace std;
ll n,k,f[10001];
inline ll qpow(reg ll a,reg int x)
{
    if(x<0)return 1;
    reg ll s=1;
    while(x)
	{
		if(x&1)
		{
			s*=a;
			s%=P;
		}
		a*=a;
		a%=P;
		x>>=1;
	}
    return s;
}
int main()
{
    scanf("%lld%lld",&n,&k);
    f[0]=1;
    for(reg int i=1;i<n;i++)
    {
		for(reg int j=i;j;j--)
		f[j]=(f[j+1]+f[j-1])%P;
		f[0]=f[1];
	}
    printf("%lld",f[n-k]*qpow(2,n-k-1)%P);
    return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

ll N, K;
int A[60][200100];

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

  std::cin >> N >> K;

  for(int i=1;i<=N;++i){
      std::cin >> A[0][i];
  }

  for(int i=0;i<=58;++i){
      for(int j=1;j<=N;++j){
          A[i+1][j] = A[i][A[i][j]];
      }
  }

  int cur = 1;

  for(int i=0;i<=59;++i){
      if(K >> i & 1){
          cur = A[i][cur];
      }
  }

  std::cout << cur << std::endl;
}


Measured memory_bytes: 50512
inputs = Array.new
while line = $stdin.gets
  inputs << line.chomp
end

N, A, B, C, D = inputs[0].split(" ").map(&:to_i)

s = "#" + inputs[1] + "#"
can_b_to_d = !s[B..D].include?("##")
can_a_to_c = !s[A..C].include?("##")

if C > D && can_a_to_c
  # AがBを飛び越える必要がある
  can_a_to_c = s[(B-1)..(D+1)].include?("...")
end

puts can_a_to_c && can_b_to_d ? "Yes" : "No"


Measured memory_bytes: 2812
import java.util.*

fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val v = readLine()!!.split(" ").map{it.toInt()}
    val c = readLine()!!.split(" ").map{it.toInt()}
    var ans = 0
    for(i in 0 until n){
        ans += Math.max(0, v[i] - c[i])
    }
    println(ans)
}

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

int main() {
  int n, l;
  cin >> n >> l;
  int a = n*l + n*(n-1)/2;
  
  if (l>0) cout << a-l << endl;
  else if (l+n-1<0) cout << a-(l+n-1) << endl;
  else cout << a << endl;
}

Measured memory_bytes: 3644
s = input()
on = "RUD"
oe = "LUD"

cnt = 0
for i in range(len(s)):
    if(i%2 == 0 and s[i] in on):
        cnt += 1
    elif(i%2 != 0 and s[i] in oe):
        cnt += 1
    
print("Yes" if cnt == len(s) else "No")

Measured memory_bytes: 3060
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 998244353
#define fi first
#define se second
#define pii pair<int,int>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
//#define LONGLONG_MAX 10000000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    string s;
    cin>>s;
    set<int>s1;
    for(int i=0;i<=n;i++){
        if(s[i]=='0')s1.insert(i);
    }
    int i=n;
    vector<int>ans;
    while(i>0&&!s1.empty()){
        auto it=s1.end();
        it--;
        if(i-*it>m){
            cout<<-1;
            return 0;
        }
        if(it==s1.begin()){
            ans.push_back(i-*it);
            break;
        }
        
        auto it1=it;
        it1--;
        if(i-*it1>m){
            ans.push_back(i-*it);
            i=*it;
        }
        s1.erase(it);
    }
    reverse(ans.begin(),ans.end());
    for(auto i:ans)cout<<i<<' ';
    return 0;
}

Measured memory_bytes: 5072
#include<iostream>
#include<cstdio>
using namespace std;
int main(void){
    int n,count,i,j,ans;
    while(1){
        count=0;
        cin >> n;
        if(n == 0)break;
        while(n != 1){
            if(n%2 == 0){
                n=n/2;
                count++;
            }
            else{
                n=(n*3)+1;
                count++;
            }
        }
        cout << count << endl;
    }
}


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

int main() {
    int a, b, c, x, ans = 0;
    cin >> a >> b >> c >> x;
    for (int i = 0; i < a+1; i++) {
        for (int j = 0; j < b+1; j++) {
            int y = x - 500*i - 100*j;
            if (y >= 0 && y <= c*50) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <math.h>
#include <assert.h>

#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

template <typename T>
void in(T& x) {
    std::cin >> x;
}

template <typename T>
void out(const T H) {
    std::cout << (H);
}

template <typename T1, typename... T2>
void out(const T1 H, const T2... T) {
    std::cout << (H) << " "; out(T...);
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& v) {
    return os << v.first << " " << v.second;
}

template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
    int n = (int) v.size();
    for (int i = 0; i < n - 1; ++i) os << v[i] << ' ';
    return os << v[n - 1];
}

template <typename T>
void eout(const char *s, const T H) {
    std::cerr << s << "=" << H << "\n";
}

template <typename T1, typename... T2>
void eout(const char *s, const T1 H, const T2... T) {
    while (*s != ',') std::cerr << *s++;
    std::cerr << "=" << H << " | "; eout(++s, T...);
}

#define nl                std::cout << "\n"
#define err(args...)      eout(#args, args)

#define inn(x)            int x; in(x)
#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define per(i, n)         for (int i = (n) - 1; i > -1; --i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)

#define sz(v)             ((int) v.size())
#define all(v)            (v).begin(), (v).end()
#define lla(v)            (v).rbegin(), (v).rend()

#define no                std::cout << "NO\n"
#define yes               std::cout << "YES\n"

const int INF           = 2147483647;
const long long int LNF = 9223372036854775807LL;

using ll  = long long int;
using vi  = std::vector<int>;
using vb  = std::vector<bool>;
using ii  = std::pair<int, int>;
using iii = std::pair< ii, int>;
using vii = std::vector<ii>;

const int N  = 505050;
const int MD = 1000*1000*1000 + 7;

int solve();
int main() {
    std::ios_base::sync_with_stdio(0); std::cin.tie(0);
    //std::cout.tie(0);

    //inn(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}

int nod(int i) {
    int c = 0;
    while (i) {
        i /= 10, c++;
    }
    return c;
}
int solve() {
    inn(n);
    int ans = 0;
    rep(i, n + 1) {
        ans +=  (nod(i)&1);
    }
    out(ans);
    return 0;
}


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

int main(void){
    string s; cin >> s;
    if(s[0] == s[1] || s[1] == s[2] ||s[2] == s[3] || s[3] == s[4])
        cout << "Bad";
    else 
        cout << "Good";
    cout << endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ff first
#define ss second
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

void Main() {
  string n;
  cin >> n;
  cout << "ABC" + n << endl;
}

int main() {
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15);  // 小数を10進数表示
  Main();
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

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

int main(){

    string s1;
    string s2;

    cin >> s1 >> s2;

    if(s1.size() > s2.size()){
        cout << "GREATER" << endl;
    }else if(s1.size() < s2.size()){
        cout << "LESS" << endl;
    }else{
        //ここにおなじ桁数のときの比較
        //前から見ていっておおきいのをみればよくね
        int type = 3;
        for(int i=0; i<s1.size(); i++){
            if(s1[i] - '0' > s2[i] - '0'){ type=1; break; }
            else if(s1[i] - '0' < s2[i] - '0'){ type=2; break; }
            else continue;
        }

        if(type==1) cout << "GREATER" << endl;
        else if(type==2) cout << "LESS" << endl;
        else cout << "EQUAL" << endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a[3],b[3],c[3][3];
    for(int i=0;i<3;i++){
        cin>>c[i][0]>>c[i][1]>>c[i][2];
    }
    a[0]=c[0][0]-c[2][0];
    a[1]=c[1][0]-c[2][0];
    a[2]=0;
    b[0]=c[2][0];
    b[1]=c[0][1]-c[0][0]+c[2][0];
    b[2]=c[0][2]-c[0][0]+c[2][0];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(a[i]+b[j]!=c[i][j]){
                cout<<"No"<<endl;
                return 0;
            }
            //cout<<a[i]<<" + "<<b[j]<<" = "<<c[i][j]<<endl;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

int main() {
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> c(h);
	rep(i, h) cin >> c[i];
	int ans = 0;
	for(int b1=0; b1< (1<<h); b1++) {
		vector<string> now1 = c;
		rep(i, h) {
			if (1&(b1>>i)) {
				rep(j, w) {
					now1[i][j] = 'R';
				}
			}
		}
		for(int b2=0; b2< (1<<w); b2++) {
			vector<string> now2 = now1;
			rep(i, h) {
				rep(j, w) {
					if (1&(b2>>j)) now2[i][j] = 'R';
				}
			}
			int cnt = 0;
			rep(i, h) {
				rep(j, w) {
					if(now2[i][j]=='#') cnt++;
				}
			}
			if (cnt == k) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
const int MAX = 1e6;
int a,b,n;

int get_divisor(int n){
    if(n == 1) return 1;
    int ans = 0;
    int i = 1;
    while(i*i < n){
        if(n%i == 0) ans++;
        i++;
    }
    return ans*2 + (i*i == n ? 1 : 0);
}

int main(){
    scanf("%d", &n);
    int ans = 0;
    while(--n){
        ans+=get_divisor(n);
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 3844
from collections import deque
N,M=map(int,input().split())
edge=[[] for i in range(N)]
visited=[-1 for i in range(N)]
dist=[1000000000 for i in range(N)]
last=[-1 for i in range(N)]
i=0
dist[0]=0
for i in range(M):
    A,B=map(int,input().split())
    edge[A-1].append(B-1)
    edge[B-1].append(A-1)
Q=deque()
Q.append(0)
while Q:
    i=Q.popleft()
    if visited[i]==-1:
        for j in edge[i]:
            if dist[j]>dist[i]+1:
                dist[j]=dist[i]+1
                last[j]=i+1
            if visited[j]==-1:
                Q.append(j)
    visited[i]=1
print("Yes")
for i in range(1,N):
	print(last[i])

Measured memory_bytes: 38584
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.util.*
import kotlin.math.*

fun main() {
    var fs = Atcoder.FastReader()
    var s = fs.next().toCharArray()
    var d = fs.next().toCharArray()
    var best = 0
    for (i in 0..s.size-d.size) {
        var counter =0
        var ind = 0
        for (j in i until i + d.size){
            if(s[j] == d[ind]) counter++
            ind++
        }
        best = max(best,counter)
    }
    println(d.size-best)

}

class Atcoder {
    internal class FastReader {
        private var br: BufferedReader = BufferedReader(InputStreamReader(System.`in`))
        private var st: StringTokenizer? = null

        operator fun next(): String {
            while (st == null || !st!!.hasMoreElements()) {
                try {
                    st = StringTokenizer(br.readLine())
                } catch (e: IOException) {
                    e.printStackTrace()
                }

            }
            return st!!.nextToken()
        }

        fun nextInt(): Int {
            return Integer.parseInt(next())
        }

        fun nextLong(): Long {
            return java.lang.Long.parseLong(next())
        }

        fun nextDouble(): Double {
            return java.lang.Double.parseDouble(next())
        }

        fun nextLine(): String {
            var str = ""
            try {
                str = br.readLine()
            } catch (e: IOException) {
                e.printStackTrace()
            }
            return str
        }

        fun readIntArray(n: Int): IntArray {
            val a = IntArray(n)
            for (i in 0 until n) a[i] = nextInt()
            return a
        }

        fun readLongArray(n: Int): LongArray {
            val a = LongArray(n)
            for (i in 0 until n) a[i] = nextLong()
            return a
        }

        fun readDoubleArray(n: Int): DoubleArray {
            val a = DoubleArray(n)
            for (i in 0 until n) a[i] = nextDouble()
            return a
        }
    }
}


Measured memory_bytes: 34388
#include <stdio.h>
#include <stdlib.h>
#define int long long

int power(int a, int n){
	if(n == 0){
		return 1;
	}
	else{
		return a * power(a, n - 1);
	}
}

signed main(){
	int N, M;
	scanf("%lld%lld", &N, &M);
	printf("%lld\n", (100 * N + 1800 * M) * power(2, M));
	return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    abc148e()
}

fun abc148e() {
    val n = readLine()!!.toLong()

    if (n % 2 != 0L) return println(0)


    val answer = Math.min(
        (1..100).map { n / 2 / Math.pow(2.0, it.toDouble()).toLong() }.sum(),
        (1..50).map { n / 2 / Math.pow(5.0, it.toDouble()).toLong() }.sum()
    )

    println(answer)
}


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

int main(){
  int n;
  cin>>n;
  vector<pair<int64_t,int>> p(n);
  for(int i=0;i<n;++i){
    cin>>p[i].first;
    p[i].second=i;
  }
  sort(p.begin(),p.end(),greater<pair<int64_t,int>>());

  vector<vector<int64_t>> dp(n+1,vector<int64_t>(n+1,0));
  for(int j=0;j<=n;++j){
    for(int i=0;i+j<=n;++i){
      int64_t a=p[i+j-1].first;
      int k=p[i+j-1].second;
      if(i==0 && j==0) continue;
      else if(j==0) dp[i][0]=dp[i-1][0]+a*(n-i-k);
      else if(i==0) dp[j][j]=dp[j-1][j-1]+a*(k-j+1);
      else dp[i+j][j]=max(dp[i+j-1][j]+a*(n-i-k),dp[i+j-1][j-1]+a*(k-j+1));
    }
  }

 //for(int i=0;i<=n;++i){
 // for(int j=0;j<=n;++j){
 //    cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
 //  }
 //}
  
  int64_t ans=0;
  for(int i=0;i<=n;++i){
    if(ans<dp[n][i]) ans=dp[n][i];
  }
  
  cout<<ans<<endl;
}



Measured memory_bytes: 34624
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reg(i,a,b) for(int i=(a);i<=(b);i++)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second

int dat[30][30];
int dp[30][30];
int main(void){
	int x,y;
	for(;;){
		scanf("%d%d",&x,&y);
		if(x==0)break;
		memset(dp,0,sizeof(dp));
		memset(dat,0,sizeof(dat));
		rep(j,y)rep(i,x){
			scanf("%d",&dat[i][j]);
		}
		rep(i,x)if(dat[i][0]==0)dp[i][0]=1;
		rep(j,y)rep(i,x){
			if(dat[i][j]==1)continue;
			if(dat[i][j]==2){
				if(dat[i][j+2]!=1)dp[i][j+2]+=dp[i][j];
				continue;
			}
			if(j!=y-1){
				if(i>0 && dat[i-1][j+1]==0){
					dp[i-1][j+1]+=dp[i][j];
				}
				if(i<x-1 && dat[i+1][j+1]==0){
					dp[i+1][j+1]+=dp[i][j];
				}
			}
			if(dat[i][j+1]!=1)dp[i][j+1]+=dp[i][j];
		}
		lli ans=0;
		/*
		printf("\n");
		rep(j,y){
			rep(i,x){
				//printf("(%2d %2d)",dat[i][j],dp[i][j]);
				printf("%2d",dp[i][j]);
			}
			printf("\n");
		}*/
		reg(j,y,y+1){
			//printf("\n");
			rep(i,x){
				//printf("%2d ",dp[i][j]);
				ans+=dp[i][j];
			}
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;



int main() {
  ll n, a, b;
  cin>>n>>a>>b;
  if (a > b) swap(a,b);
  ll d = b-a;
  ll ans = LINF;
  if (d&1) {
    rep(ri,2) {
      ll now = a-1;
      ll x = b-a+1;
      ++now; --x;
      now += x/2;
      mins(ans,now);
      swap(a,b);
      a = n-a+1;
      b = n-b+1;
    }
  } else {
    ans = d/2;
  }
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 764
import java.util.Arrays;
import java.util.Scanner;

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

        int D = scanner.nextInt();

        int[] C = new int[26];
        for (int i = 0; i < C.length; i++) {
            C[i]=scanner.nextInt();
        }

        int[][] S = new int[D][26];
        for (int i = 0; i < S.length; i++) {//days
            for (int j = 0; j <S[i].length ; j++) {//type
                S[i][j]=scanner.nextInt();
            }
        }

//        int[] T = new int[D];

        int[] L = new int[26];//last day
        Arrays.fill(L,-1);

        int ans =0;
        for (int i = 0; i < D; i++) {
            int t = scanner.nextInt()-1;//type

            ans += S[i][t]; //satisfy
            L[t]=i;

            for (int j = 0; j < 26; j++) {
                int dd  = i- L[j];
                ans -= C[j]  * dd;
            }
            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 46560
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll K, X;
    cin >> K >> X;
    constexpr ll MAX = 1e6;
    for (ll i = max(-MAX, X - K + 1); i <= min(MAX, X + K - 1); i++) {
        cout << i << " \n"[i == min(MAX, X + K - 1)];
    }
}

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

int main() {

  int n;
  while( cin >> n, n ) {
    int A = 0, B = 0;
    for(int i=0; i<n; i++) {
      int a, b;
      cin >> a >> b;
      if( a == b ) {
	A += a; B += b;
      }
      else if( a > b ) A += a+b;
      else B += a+b;
    }

    cout << A << " " << B << endl;
  }
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n,a,b,sum;
int main(){
    cin>>n;
    vector<pair<int,int>>t(n);
    for(int i=0;i<n;i++){
        cin>>a>>b;
        t.push_back(make_pair(a,b));
    }
    sort(t.begin(),t.end(),[](const pair<int,int>& x,const pair<int,int>& y)
    {return x.second==y.second?x.first<y.first:x.second<y.second;}
    );
    for(auto x:t){
        sum+=x.first;
        if(sum>x.second){cout<<"No"<<endl;return 0;}
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	cout<<string(s.size(),'x')<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

void fail(void) {
  cout << -1 << endl;
  exit(0);
}

ll calc(ll pat, int k) {
  int r = 51 / k;
  ll x = pat;
  ll y = 0;
  REP(i, 0, r + 1) {
    y |= x & ((1LL << k) - 1);
    x >>= k;
  }
  return pat | y;
}


bool poss(ll pat, ll goal, int ma) {
  for (int i = ma; i >= 1; --i) {
    pat = calc(pat, i);
  }
  return (pat & goal) != 0;
}

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VI a(n), b(n);
  REP(i, 0, n) {
    cin >> a[i];
  }
  REP(i, 0, n) {
    cin >> b[i];
  }
  ll ans = 0;
  VL apat(n), bpat(n);
  REP(i, 0, n) {
    apat[i] = 1LL << a[i];
    bpat[i] = 1LL << b[i];
  }
  for (int i = 49; i >= 1; --i) {
    bool ok = true;
    REP(j, 0, n) {
      if (not poss(apat[j], bpat[j], i - 1)) {
	ok = false;
	break;
      }
    }
    if (not ok) {
      ans |= 1LL << i;
      REP(j, 0, n) {
	apat[j] = calc(apat[j], i);
      }
    }
  }
  // check
  REP(i, 0, n) {
    if ((apat[i] & bpat[i]) == 0) {
      fail();
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
A, B = [int(i) for i in input().split()]


def xor(a,b):
    sum=0
    i=0
    while(a>0 or b>0):
        sum += (2**i) * ((a%2 + b%2)%2)
        a = a//2
        b = b//2
        i += 1
    return sum



def f(n):
    m=(n+1)//2
    if n%2==0:
        if m%2==0:
            return n
        else:
            return n+1
    else:
        if m%2==0:
            return 0
        else:
            return 1

if A==0:
    print(f(B))
else:
    print(xor(f(A-1), f(B)))


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

const int N = 1001;
struct TW 
{
    int w,s,v;

    bool operator  < (const TW &h) const 
    {
        if (s!=h.s)return s < h.s;
        if (w!=h.w)return w < h.w;
        return v  > h.v;
    }
} a[N];
int n;

#define lint long long 
lint f[20001], f_[20001];

int main() 
{
    cin >> n;
    for (int i=1; i<=n; ++i) 
    {
        cin >> a[i].w >> a[i].s >> a[i].v;
        a[i].s += a[i].w;
    }
    sort (a+1, a+1+n);
    for (int i=1; i<=n; ++i) 
    {
        for (int j=a[i].w ; j <= a[i].s; ++j) 
            f_[j] = f[j - a[i].w] + a[i].v;
        for (int j=1; j<=20000; ++j)    
            f[j] = max(f[j], f_[j]);
    }
    lint ans = 0;
    for (int i=1; i<=20000; ++i) 
        ans = max(ans, f[i]);
    cout << ans;
}

Measured memory_bytes: 3864