akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define ll long long  
#define ld long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define S second
#define F first
#define die() return 0;
 
 
#define md          1000000007
#define fmd         998244353 
#define M           100011
#define N            18
ll exp(ll a,ll b){if(b<0)return 0;ll r=1;while(b){if(b&1)r=r*a%md,r%=md;a=a*a%md;b/=2;}return r;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll F[M],IV[M];

ll chose(ll n,ll k){
	if(n<0||k<0||k>n)return 0;
	ll r=F[n];r=r*IV[n-k];r%=md;r*=IV[k];return r%md;
}
int solve(){
    ll n,i,j,k,m,x,y,z;
    cin>>n;
    vector<int> a(n+1);
    map<int,int> mp;
    k=-1;
    for(i=0;i<n+1;++i){
    	cin>>a[i];
    	if(mp.find(a[i])!=mp.end()){
    		k=i-mp[a[i]]-1;
    	}
    	mp[a[i]]=i;
    }
    vector<ll> ans;
	for(i=1;i<=n;++i){
		ll p=chose(n-1,i-2)+chose(n-1,i);
		p=p+(2*chose(n-1,i-1)-chose(n-1-k,i-1)+md)%md;
		ans.pb(p%md);

	}
	ans.pb(1);
	for(auto x:ans)cout<<x<<"\n";




 
	die();
 
}
void prec(){
	F[0]=IV[0]=1;
	for(int i=1;i<M;++i){
		F[i]=F[i-1]*i%md,F[i]%=md;
		IV[i]=IV[i-1]*exp(i,md-2)%md,IV[i]%=md;
	}
} 
 
int main(){
 
 
#ifndef ONLINE_JUDGE
    double _tBeg=clock();
#endif
 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
    int t;
    t=1;;
    prec();
    // cin>>t;
 
    while(t--){
 
        solve();
    }
 
 
 
 
 
 
#ifndef ONLINE_JUDGE
    double _tEnd=clock();
    // printf("\ntotal time %.6f\n",(_tEnd-_tBeg)/CLOCKS_PER_SEC);
#endif
 
    die();
}

Measured memory_bytes: 10776
import java.io.BufferedReader;
import java.io.CharArrayReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class Main {

    private static Scanner sc;

    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            long n = sc.nextLong()-1;
            List<String> list = new ArrayList<>();
            while(n >= 0){
                list.add(String.valueOf((char)('a' + (n%26))));
                n = (n / 26)-1;
            }
            Collections.reverse(list);
            System.out.println(String.join("", list));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 32704
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N,M=get_i
ab=array(N)
N.times do|i|
    ab[i]=get_i
end
cd=array(M)
M.times do|i|
  cd[i]=get_i
end
ab.each do|a,b|
    min=INF
    res=-1
    cd.each_with_index do|(c,d),i|
      d=(a-c).abs+(b-d).abs
      if min>d
          res=i
          min=d
      end
    end
    puts res+1
end

Measured memory_bytes: 14120
N = int(input())
s3 = ((N//3-1)*3+6)*(N//3)//2
s5 = ((N//5-1)*5+10)*(N//5)//2
s15= ((N//15-1)*15+30)*(N//15)//2
st = (N+1)*N//2

ans= st-s3-s5+s15
print(ans)


Measured memory_bytes: 9184
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


def warsharll_floyd(c):
    n = len(c)
    for k in range(n):  # iからjへ向かう途中に中継する頂点
        for i in range(n):  # 始点
            for j in range(n):  # 終点
                # 現時点のiからjへ向かうコスト と kを経由してjに向かうコストの小さい方
                c[i][j] = min(c[i][j], c[i][k] + c[k][j])
    return c


def main():
    h, w = LI()
    c = LIR(10)
    a = LIR(h)
    # a[i][j]を1に変える最小コストを考える
    # costs[i] : i を 1 に変えるコスト
    costs = warsharll_floyd(c)
    ans = 0
    for i in range(h):
        for j in range(w):
            if a[i][j] in {-1, 1}:
                continue
            else:
                ans += costs[a[i][j]][1]
    print(ans)


main()


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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n>>m;

	res=n%500;
	//res+=n/500;

	//cout<<res<<endl;

	if(res<=m) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

}


Measured memory_bytes: 256
#include <stdio.h>

#define MIDTERM 0
#define FINAL 1
#define RETRY 2

void print_result(int midterm, int final, int retry)
{
    int sum;

    sum = midterm + final;
    if (midterm == -1 || final == -1)
    {
        printf("F\n");
        return;
    }
    else if (sum >= 80)
    {
        printf("A\n");
        return;
    }
    else if (sum >= 65 && sum < 80)
    {
        printf("B\n");
        return;
    }
    else if (sum >= 50 && sum < 65)
    {
        printf("C\n");
        return;
    }
    else if (sum >= 30 && sum < 50)
    {
        if (retry >= 50)
        {
            printf("C\n");
            return;
        }
        else
        {
            printf("D\n");
            return;
        }
    }
    else if (sum < 30)
    {
        printf("F\n");
        return;
    }
}

int main(void)
{
    int score[50][3];
    int student;
    int i, j;

    for (;;)
    {
        scanf("%d %d %d", &score[i][MIDTERM], &score[i][FINAL], &score[i][RETRY]);
        if (score[i][MIDTERM] == -1 &&
            score[i][FINAL] == -1 &&
            score[i][RETRY] == -1)
            break;
        i++;
    }
    student = i;

    // Check if the input was successful
    // for (i = 0; i < student; i++)
    // {
    //     printf("%d: %d %d %d\n", i, score[i][MIDTERM], score[i][FINAL], score[i][RETRY]);
    // }

    for (i = 0; i < student; i++)
    {
        print_result(score[i][MIDTERM], score[i][FINAL], score[i][RETRY]);
    }
    return (0);
}


Measured memory_bytes: 2120
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[100010];
int main(){
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	long long ans=1145141919114514;
	long long sum=0,fugo=0,cnt=0;
	for(int i=0;i<n;i++){
		sum+=a[i];
		if(fugo==0&&sum>=0){
			cnt+=sum+1;
			sum=-1;
		}
		if(fugo==1&&sum<=0){
			cnt+=1-sum;
			sum=1;
		}
		fugo=1-fugo;
	}
	ans=min(ans,cnt);

	sum=0,fugo=1,cnt=0;
	for(int i=0;i<n;i++){
		sum+=a[i];
		if(fugo==0&&sum>=0){
			cnt+=sum+1;
			sum=-1;
		}
		if(fugo==1&&sum<=0){
			cnt+=1-sum;
			sum=1;
		}
		fugo=1-fugo;
	}
	ans=min(ans,cnt);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    while(t--){
	   int n,m,k;
	   cin>>n>>m>>k;
	   vector<int> a(n);
	   for(auto &it : a) cin>>it;
	   vector<int> b(m);
	   for(auto &it : b) cin>>it;
	   
	   vector<ll> prefix_A(n+1);
	   vector<ll> prefix_B(m+1);
	  for(int i=0;i<n;i++){
		   prefix_A[i+1] = prefix_A[i] + a[i];
	   }
	   for(int i=0;i<m;i++){
		   prefix_B[i+1] = prefix_B[i] + b[i];
	   }
	   int total=0;
	   for(int i=0;i<=n;i++){
		   int other = k-prefix_A[i];
		   if(other<0)
			   continue;
		   int l=lower_bound(prefix_B.begin(),prefix_B.end(),other)-prefix_B.begin();
		   if(l>m or prefix_B[l]>other)
			   --l;
		   total=max(total,i+l);
	   }
	   if(k==1 and a[0]>k)
		   cout<<0;
	   else if(a[0]==k)
		   cout<<1;
	   else	   
	   cout<<total<<endl;



    }
    return 0;
} 


Measured memory_bytes: 7952
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
 vector<ll> side(3);
  rep(i,3){
    cin >> side.at(i);
  }
  sort(side.begin(),side.end());
  if(side.at(0)%2==0) cout << 0 << endl;
  else if(side.at(1)%2==0) cout << 0 << endl;
  else if(side.at(2)%2==0) cout << 0 << endl;
  else cout << side.at(0)*side.at(1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 55;

int n;
int x[N], y[N];

map<int, map<int, int> > mp;

bool c[N] = {};
void dfs(int i, int p, int q)
{
    c[i] = true;
    if (mp[x[i] + p].find(y[i] + q) != mp[x[i] + p].end())
    {
        if (!c[mp[x[i] + p][y[i] + q]])
            dfs(mp[x[i] + p][y[i] + q], p, q);
    }
    if (mp[x[i] - p].find(y[i] - q) != mp[x[i] - p].end())
    {
        if (!c[mp[x[i] - p][y[i] - q]])
            dfs(mp[x[i] - p][y[i] - q], p, q);
    }
}

int qry(int p, int q)
{
    int ans = 0;
    memset(c, false, sizeof c);
    for (int i = 1; i <= n; ++i)
    {
        if (!c[i])
        {
            ++ans;
            dfs(i, p, q);
        }
    }
    return ans;
}

int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> x[i] >> y[i];
        mp[x[i]][y[i]] = i;
    }
    int ans = n;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            if (i == j)
                continue;
            ans = min(ans, qry(x[i] - x[j], y[i] - y[j]));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6016
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
string s;
cin>>s;

int cnt=0;
for(int i=0;i<n-2;i++)
{
    if(s.substr(i,3)=="ABC")cnt++;
}
cout<<cnt;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

double a, b, x;
double PI = 3.14159265358979;

signed main() {
	cin >> a >> b >> x;
	
	x = x / (a * a);
	
	double h, w;
	if (x >= b / 2) {
		h = b - x;
		w = a / 2;
	}
	else {
		h = b;
		w = 2 * a * x / b;
	}
	double ans = atan2(h, w) * 180 / PI;
	printf("%.14f\n", ans);
	return 0;
}

Measured memory_bytes: 256
# n, k = map(int, input().split())
# from collections import OrderedDict
# d = OrderedDict()
# a = list(input().split())
# b = list(map(int, input().split()))
# print(r + max(0, 100*(10-n)))
# print("Yes" if 500*n >= k else "No") 
# s = input()
# a = int(input())
# b = int(input())
# c = int(input())
s = input()
print("Yes" if ('A' in s and 'B' in s) else "No")

Measured memory_bytes: 61804
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::cmp::{min,max};

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin 
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn main() {
    input!(x:usize);
    if x == 7 || x == 5 || x == 3 {
        println!("YES");
    }
    else {
        println!("NO");
    }
}


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

int main() {
  vector<vector<vector<int> > > house(4, vector<vector<int> >(3, vector<int>(10, 0)));
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int b, f, r, v;
    cin >> b >> f >> r >> v;
    house.at(--b).at(--f).at(--r) += v;
  }

  for (int i = 0; i < 4; ++i) {
    for (int j = 0; j < 3; ++j) {
      for (int k = 0; k < 10; ++k) {
        cout << " " << house.at(i).at(j).at(k);
      }
      cout << endl;
    }
    if (i != 3) cout << "####################" << endl;
  }

  return 0;
}


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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;

void solve() {
    i64 n;
    cin >> n;
    i64 l = (i64) sqrt(n);
    vector<i64> ans(n + 1);
    for (i64 x = 1; x <= l; x++) {
        for (i64 y = 1; y <= l; y++) {
            for (i64 z = 1; z <= l; z++) {
                i64 t = x * x + y * y + z * z + x * y + y * z + z * x;
                if (t <= n) ans[t]++;
            }
        }
    }
    for (i64 i = 1; i <= n; i++) {
        cout << ans[i] << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
int main() {
	long long int b, c, d;
	cin >> b >> c >> d;
	string a;
	cin >> a;
	long long int ac = 0, bc = 0;
	for (int i = 0; i < b; i++) {
		if (a[i] == 'a') {
			if (ac + bc < d + c) {
				cout << "Yes" << endl;
				ac++;
			}
			else {
				cout << "No" << endl;
			}
		}
		if (a[i] == 'b') {
			if (ac + bc < d + c&&bc+1<=d) {
				cout << "Yes" << endl;
				bc++;
			}
			else {
				cout << "No" << endl;
			}
		}
		if (a[i] == 'c') {
			cout << "No" << endl;
		}
	}
	return 0;
}

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

const int ene = 2*1e5+10;

vector<int>v[ene];
int p[ene];
int dp[ene];
queue<int>q;

int main()
{
    int n,m;
    cin >> n >> m;
    for(int i = 0; i < m; i++)
    {
        int a,b;
        cin >> a >> b;
        v[a].push_back(b);
        p[b]++;
    }
    for(int i = 1; i <= n; i++)
    {
        if(p[i]==0)
        {
            q.push(i);
        }
    }
    while(!q.empty())
    {
        int s = q.front();
        q.pop();
        for(int i = 0; i < v[s].size(); i++)
        {
            int syn = v[s][i];
            p[syn]--;
            if(p[syn] == 0)q.push(syn);
            dp[syn] = max(dp[s]+1,dp[syn]);
        }
    }
    int wynik = 0;
    for(int i = 0;i <= n; i++) wynik = max(dp[i], wynik);
    cout << wynik;
    return 0;
}


Measured memory_bytes: 8832
n=int(raw_input())
a=[]
for i,j in enumerate(map(int,raw_input().split())):
    a.append([j,i])
a.sort(reverse=True)
now=0
nx=0
ans=[0]*n
cnt=0
idx=10**6
while now<n:
    while nx<n and a[now][0]==a[nx][0]:
        idx=min(idx,a[nx][1])
        cnt+=1
        nx+=1
    if nx==n:
        ans[idx]+=cnt*a[now][0]
    else:
        ans[idx]+=(a[now][0]-a[nx][0])*cnt
    now=nx
for i in xrange(n):
    print ans[i]

Measured memory_bytes: 22380
#include<iostream>
#include<stack>
#include<stdio.h>
#include<vector>
#include<stdlib.h>
using namespace std;

typedef std::stack<int> Intstack;
int main(){
    Intstack G;
    int x,a,i,b;
    x = 0;
    a = 0;
    i = 0;
    b = 0;
    char s[100];
    while(scanf("%s",s) != EOF){
        
        if(s[0] == '+'){
            a = G.top();
            G.pop();
            a += G.top();
            G.pop();
            G.push(a);
        }
        else if(s[0] == '-' ){
            b = G.top();
            G.pop();
            a = G.top() -b;
            G.pop();
            G.push(a);
        }
        else if(s[0] == '*'){
            a = G.top();
            G.pop();
            a = a * G.top();
            G.pop();
            G.push(a);
        }
        else{
            x = atoi(s);
            G.push(x);
        }
        i++;
    }
    
    x = G.top();
    G.pop();
    cout << x << endl;
}


Measured memory_bytes: 3220
import java.util.Scanner;
import java.util.ArrayList;
 
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
      ArrayList<String> list = new ArrayList<String>();
      int x_1,x_2,x_3,x_4,x_5;
      int i = 0;
      String an = scan.nextLine();
      String atai[] = an.split(" ",0);
      int num[] = new int[2];
      while(i < 2){
        num[i] = Integer.parseInt(atai[i]);
        i++;
      }
      x_1 = num[0];
      x_2 = num[1];
//      System.out.println(A+","+B+","+H+","+M);
      check(num);
        scan.close();
    }
  
  public static void check(int[] num){
   //System.out.println(num[0]);
    int X, Y;
    int s;
    X = num[0];
    Y = num[1];
     s= Y%2;
    if(X*4 < Y){
      System.out.println("No");
    }else if( s != 0){
      System.out.println("No");
    }else if(X*2 > Y){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }
   return;  
  }
}


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


public class Main {
	
	
	long gcd(long a, long b){
		return a==0 ? b : gcd(b%a, a);
	}
	
	long lcm(long a, long b){
		return a*b / gcd(a, b);
	}
	
	void io(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			final long a = sc.nextInt();  final long b = sc.nextInt();
			System.out.println(gcd(a, b) + " " + lcm(a, b));
		}
	}
	
	public static void main(String[] args) {
		new Main().io();
	}
	
	void debug(Object... os){
		System.out.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
template<class T> inline void chmax(T& a, T b) {if (a<b) a=b; }
inline void print() { cout << endl; }
template <class Head, class... Tail> inline void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...);}
template <class T> inline void print(vector<T>& vec) { for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " "; } cout << endl;}
template <class T> inline void print(vector<vector<T>>& df) { for (auto& vec : df) { print(vec); }}
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;


int main() {
    int N; cin >> N;
    if(N==0) {
        print(0);
        return 0;
    }
    string s = "";
    while(N!=0) {
        int r = (N%(-2));
        if(r < 0) r += 2;

        N = (N-r) / (-2);
        s += char('0' + r);
    }

    reverse(s.begin(), s.end());

    print(s);
}

Measured memory_bytes: 888
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int mincost(int a[],int n,int dp[])
{
    if(n==0||n==1)return 0;
    else if(n==2)return abs(a[1]-a[2]);
    else if(dp[n]!=-1)return dp[n];
    else
    {
        dp[n]=min(abs(a[n]-a[n-1])+mincost(a,n-1,dp),abs(a[n]-a[n-2])+mincost(a,n-2,dp));
    return dp[n];

    }
}
int main()
{
    int n;
    cin>>n;
    int a[n+1],dp[n+1];
    for(int i=1;i<=n;i++){cin>>a[i];dp[i]=-1;}
    cout<<mincost(a,n,dp);
    return 0;
}


Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
class Program
{

    static void Main()
    {
        string N = Console.ReadLine();
        long p = 0;

        for(int i=0;i<N.Length;i++)
        {
            char c = N[i];
            if(c=='1')
            {
                p += 1;
            }
            else if(c=='2')
            {
                p += 2;
            }
            else if (c == '3')
            {
                p += 3;
            }
            else if (c == '4')
            {
                p += 4;
            }
            else if (c == '5')
            {
                p += 5;
            }
            else if (c == '6')
            {
                p += 6;
            }
            else if (c == '7')
            {
                p += 7;
            }
            else if (c == '8')
            {
                p += 8;
            }
            else if (c == '9')
            {
                p += 9;
            }
        }
        if(p%9==0)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }

}



Measured memory_bytes: 26632
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    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.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n,m,d = lr()
ans = 0
if n-d > d:
    if d > 0:
        ans+=2*(n-d-d)
        ans+=d*2
    else:
        ans+=n
else:
    ans+=2*(n-d)
ans = ans*(m-1)/(n*n)
print(ans)


Measured memory_bytes: 72780
N, A, B = map(int, input().split())
X = list(map(int, input().split()))
ans = (X[-1] - X[0]) * A
for x1, x2 in zip(X, X[1:]):
    if (x2 - x1) * A > B:
        ans -= (x2 - x1) * A - B
print(ans)

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

int main()
{
 	int X;
    cin >> X;
  
	int i500 = X / 500;
    int i5 = (X % 500) / 5;
  
    cout << i500 * 1000 + i5 * 5 << endl;
  
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = [list(reversed(list(map(lambda x: int(x) - 1, input().split())))) for _ in range(N)]
    d = 0
    r = N
    cur = list(range(N))
    w = [a.pop() for a in A]
    while r:
        d += 1
        nxt = []
        for i in cur:
            o = w[i]
            if o == -1:
                continue
            if w[o] == i:
                nxt.append(i)
                nxt.append(o)
                w[i] = -1
                w[o] = -1
        if not nxt:
            return -1
        cur = []
        for i in nxt:
            if A[i]:
                w[i] = A[i].pop()
                cur.append(i)
            else:
                r -= 1
    return d


print(main())


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

int N;

int cnt_color[8];

void color(int x){
  if(x <= 399)
    ++cnt_color[0];
  else if(x <= 799)
    ++cnt_color[1];
  else if(x <= 1199)
    ++cnt_color[2];
  else if(x <= 1599)
    ++cnt_color[3];
  else if(x <= 1999)
    ++cnt_color[4];
  else if(x <= 2399)
    ++cnt_color[5];
  else if(x <= 2799)
    ++cnt_color[6];
  else if(x <= 3199)
    ++cnt_color[7];
}

int main(){
  ios_base::sync_with_stdio(false); 
  cin >> N;
  int legends = 0;
  for(int i=0; i<N; ++i){
     int x; cin >> x;
     if(x < 3200) color(x);
     else ++legends;
  }
  int res_min = 0, res_max = 0;
  if(legends == 0){
     for(int i=0; i<8; ++i)
       res_min += (cnt_color[i] > 0);
     res_max = res_min;
  }
  else{
    for(int i=0; i<8; ++i)
     res_min += (cnt_color[i] > 0);
    if(res_min == 0)
      res_min = 1;
    for(int i=0; i<8; ++i){
      res_max += (cnt_color[i] > 0);
    }
    res_max += legends;
  }
  cout << res_min << " " << res_max << "\n";
  return 0;
}


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

string str,t;
vector<pair<int, int> >lec;
vector<vector<pair<int, int> > >stu,pro;
int n,m,k;

void ini(int x){
    cin>>n;
    for(int p=0;p<n;p++){
        cin>>str;
        int f=0,s=0;
        for(int i=0;i<4;i++){
            t=str.substr(i*2+i,2);
            if(i<2)
                for(int j=0;j<2;j++)
                    f=f*10+t[j]-'0';
            else
                for(int j=0;j<2;j++)
                    s=s*10+t[j]-'0';
        }
        if(x==0)lec.push_back(make_pair(f,s));
        if(x==1)pro[k].push_back(make_pair(f,s));
        if(x==2)stu[k].push_back(make_pair(f,s));
    }
}
void in(int x){
    cin>>m;
    if(x==1)pro.resize(m);
    else stu.resize(m);
    for(k=0;k<m;k++)
        ini(x);
}
int main(){
    ini(0);
    in(1);
    in(2);
    int ans=0;
    for(int i=0;i<lec.size();i++){
        int p=0,s=0;
        for(int j=0;j<pro.size();j++){
            for(int k=0;k<pro[j].size();k++){
                if(pro[j][k].first<=lec[i].first&&pro[j][k].second>=lec[i].second){
                    p++;
                }
            }
        }
    n1:;
        for(int j=0;j<stu.size();j++){
            for(int k=0;k<stu[j].size();k++){
                if(stu[j][k].first<=lec[i].first&&stu[j][k].second>=lec[i].second){
                    s++;
                }
            }
        }
        ans+=min(p,s);
    n2:;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1416
#include<bits/stdc++.h>
#define pb push_back
using namespace std;

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

    int n, x, q;
    cin >> n;

    vector<int> v;
    for (int i = 0; i < n; i++) { cin >> x; v.pb(x); }

    cin >> q;
    sort(v.begin(), v.end());
    int ans = 0;
    while (q--) {
        cin >> x;
        ans += binary_search(v.begin(), v.end(), x) ? 1 : 0;
    }
    cout << ans << "\n";
    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int, int>
#define pll pair <ll, ll>
#define gcd __gcd
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

const ll L = 1e5+5;

ll h[L];
ll m[L];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll N;
    cin >> N;

    for(ll i=0; i<N; i++)
    {
        cin >> h[i];
    }

    m[0] = 0;
    m[1] = abs(h[1]-h[0]);

    for(ll i=2; i<N; i++)
    {
        m[i] = min(m[i-1]+abs(h[i]-h[i-1]), m[i-2]+abs(h[i]-h[i-2]));
    }

    cout << m[N-1] << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define re    return
#define pii   pair<int,int>
#define hell  1000000007
#define rep(i,a,b)  for (__typeof(b) i=(a)-((a)>(b));i!=(b)-((a)>(b));i+=1-2*((a)>(b)))
#define boost ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define pb  push_back
#define ff          first
#define ss          second
#define sz(x)       (int)x.size()
#define all(a)      (a).begin(),(a).end()

//v.resize(distance(v.begin(),unique(v.begin(),v.end())));

typedef long long  ll;
using namespace std;

const ll INF=(1LL<<60)-1;
const int nax=2e5+20;

ll s[nax];
ll x[nax];

int main(){
   
    boost;
    
    int n; cin >> n;
  
    rep(i,1,n+1){
      	ll oo; cin >> oo;
      	s[i] = s[i-1]+oo;
      	x[i] = x[i-1]^oo;
	}
	
    int l = 1;
    ll ans = 0;
    
    for(int r = 1; r <= n; r++){
    	while((s[r]-s[l-1]) != (x[r]^x[l-1])) l++;
    		ans += r-l+1;
	}
	
	cout << ans;
	
   	return 0;
}

Measured memory_bytes: 3328
#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, M;
std::vector<ll> A, B;

ll f(int x){
    ll c = 0;

    for(int i=0;i<N;++i){
        c += A.end() - std::lower_bound(A.begin(), A.end(), x - A[i]);
    }

    return c;
}

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

    std::cin >> N >> M;

    A.resize(N);

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

    std::sort(A.begin(), A.end());

    B.resize(N + 1);

    B[N] = 0;

    for(int i=N-1;i>=0;--i){
        B[i] = A[i] + B[i+1];
    }

    int lb = 0, ub = 200100;
    while(ub - lb > 1){
        int m = (lb + ub) / 2;
        ll c = f(m);

        if(c < M){
            ub = m;
        }else{
            lb = m;
        }
    }

    ll score = 0;
    ll c = 0;

    for(int i=0;i<N;++i){
        int j = std::lower_bound(A.begin(), A.end(), ub - A[i]) - A.begin();
        score += A[i] * (N - j) + B[j];
        c += N - j;
    }

    score += (M - c) * lb;

    std::cout << score << std::endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

ll comb(ll a,ll b){
  if(b == 1) return a;
  return a*comb(a-1,b-1)/b;
}

int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  vector<ll> v(n);
  map<ll,ll> mp;
  rep(i,n){
    cin >> v[i];
    mp[v[i]] ++;
  }
  stack<pair<ll,int>> q;
  for(auto p : mp) q.push(p);
  sort(v);
  reverse(v);
  ll maxsum = 0;
  rep(i,a) maxsum += v[i];
  double maxave = (double)maxsum/a;
  cout << setprecision(10) << maxave << endl;
  ll qts = q.top().second;
  if(a <= qts){
    ll ans = 0;
    ll reach = min(b,qts);
    for(ll i=a;i<=reach;i++){
      ans += comb(qts,i);
    }
    cout << ans << endl;
    return 0;
  }
  ll ans = 0;
  while(!q.empty()){
    auto now = q.top();
    q.pop();
    if(a > now.second){
      a -= now.second;
      b -= now.second;
      continue;
    }
    ans = comb(now.second,a);
    cout << ans << endl;
    return 0;
  }
}

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


int main() {
  
  string S;
  cin >> S;

  int n = S.size();
  long long ans = 0;

  for(int bit = 0;bit < (1<<n-1);bit++) {

    vector<int> vec(n-1,0);

    for(int i = 0;i < n-1;i++) {
      if(bit & (1<<i)) vec.at(n-i-2) = 1;
    }

    string str;

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

      str.push_back(S.at(i));
      if(i == n-1) {
        ans += stoll(str);
      }else {
        if(vec.at(i)) {
          ans += stoll(str);
          str.erase(str.begin(),str.end());
        }
      }

      
    }
  }

  
  cout << ans <<  endl;

}

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

using namespace std;

int main ()
{
   int a,b;
   cin>>a>>b;
if((a*b*1)%2!=0)cout<<"Yes";
else if((a*b*2)%2!=0)cout<<"Yes";
else if((a*b*3)%2!=0)cout<<"Yes";
else cout<<"No";
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n, m;
int stair[100000];
int song[100000];

int mapto[300];
int convert(const char *str) {
  int ret = mapto[(int)str[0]];
  if (str[1] == '#') { ret++; }
  return ret;
}

int main() {
  mapto[(int)'C'] = 0;
  mapto[(int)'D'] = 2;
  mapto[(int)'E'] = 4;
  mapto[(int)'F'] = 5;
  mapto[(int)'G'] = 7;
  mapto[(int)'A'] = 9;
  mapto[(int)'B'] = 11;
  int test;
  scanf("%d", &test);
  while (test--) {
    scanf("%d %d", &n, &m);
    REP(i, n) {
      char str[100];
      scanf(" %s ", str);
      stair[i] = convert(str);
    }
    REP(i, m) {
      char str[100];
      scanf(" %s ", str);
      song[i] = convert(str);
    }
    queue<pair<int, int> > que;
    que.push(make_pair(n - 1, m - 1));
    que.push(make_pair(n - 2, m - 1));
    while (!que.empty()) {
      int y = que.front().first;
      int index = que.front().second;
      que.pop();
      if (y == -1 && index == -1) {
        puts("Yes");
        goto next;
      }
      if (y >= n || y < 0 || index == -1) { continue; }
      assert(y >= 0);
      if (song[index] == stair[y]) {
        que.push(make_pair(y - 1, index - 1));
      } else if (song[index] == (stair[y] + 1) % 12) {
        que.push(make_pair(y - 2, index - 1));
      }  else if (song[index] == (stair[y] + 11) % 12) {
        que.push(make_pair(y + 1, index - 1));
      }
    }
    puts("No");
next:;
  }
}

Measured memory_bytes: 1300
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int a[110];
int main()
{
	int n;lint x,sum=0;cin>>n>>x;
	rep(i,n) cin>>a[i];
	sort(a,a+n);
	rep(i,n){
		sum+=a[i];
		if(sum>x){
			cout<<i<<endl;return 0;
		}
	}
	if(sum==x) cout<<n<<endl;else cout<<n-1<<endl;
}


Measured memory_bytes: 888
N,K=map(int,input().split())
S=input()
if N == 1:
  print(0)
  exit()
if N == 2:
  if K>=1:
    print(1)
  else:
    print(0)
    exit()


ans = 0
d = 0
for i,s in enumerate(S[:-1]):
  if S[i] == S[i+1]:
    ans += 1
#print(ans)
ans += 2*K
print(min(ans,N-1))
    

Measured memory_bytes: 9296
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,ll>
#define mk make_pair
#define pb push_back
#define eb emplace_back
#define ins insert
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=1005;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int k,a[MAXN],n,res[MAXN],len;
inline bool check(){int Mn=a[1],Mx=a[1];Rep(i,1,k)Mn=min(Mn,a[i]),Mx=max(Mx,a[i]);return Mn*2>=Mx;}
inline void Merge(int*x,int*y,int*z,int l1,int l2){
	int l=0,i=1,j=1;
	for(;i<=l1&&j<=l2;)if(x[i]<=y[j])z[++l]=x[i++];else z[++l]=y[j++];
	for(;i<=l1;z[++l]=x[i++]);for(;j<=l2;z[++l]=y[j++]);
}
inline vector<int>Solve(int le){
	int l1=0,l2=0,l3=0;static int x[MAXN],y[MAXN],z[MAXN],b[MAXN],vis[MAXN];
	Rep(i,1,k)vis[i]=0,b[i]=a[i];
	Rep(i,0,k-le-1)vis[res[len-i]]=1;
	Rep(i,1,k){if(!vis[i])b[i]--;if(b[i]<0)return vector<int>(1,k+1);}
	int Mn=b[1],Mx=b[1];Rep(i,1,k)Mn=min(Mn,b[i]),Mx=max(Mx,b[i]);
	if(Mn*2>=Mx){vector<int>tmp;Rep(i,1,k)if(!vis[i])tmp.pb(i);return tmp;}
	else if(Mn*2+1==Mx){
		Rep(i,1,k)if(!vis[i]&&b[i]==Mx)x[++l1]=i;
		Rep(i,1,k)if(!vis[i]&&b[i]==Mn)x[++l1]=i;
		Rep(i,1,k)if(!vis[i]&&b[i]!=Mx&&b[i]!=Mn)y[++l2]=i;
		Merge(x,y,z,l1,l2),l3=l1+l2;int p1=0,p2=0;vector<int>tmp(z+1,z+l3+1);
		Rep(i,len-(k-le-1),len){if(b[res[i]]==Mx)p1=i;if(b[res[i]]==Mn&&!p2)p2=i;}
		Rep(i,1,l3){if(b[z[i]]==Mx)p1=i+len;if(b[z[i]]==Mn&&!p2)p2=i+len;}
		if(p1<p2)return tmp;return vector<int>(1,k+1);
	}else return vector<int>(1,k+1);
}
inline bool cmp(vector<int>a,vector<int>b){for(int i=0;i<a.size();i++){if(i>=b.size()||a[i]>b[i])return 1;if(a[i]<b[i])return 0;}return 0;}
inline void Ins(){
	vector<int>ext(1,k+1);
	for(int i=1;i<=k&&i+len<=n;i++)if(len-k+i+1>0){
		vector<int>now=Solve(i);
		if(cmp(ext,now))ext=now;
	}for(auto o:ext)cout<<o<<' ',res[++len]=o,a[o]--;
}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	k=read();
	Rep(i,1,k)a[i]=read(),n+=a[i];
	if(!check())return puts("-1"),0;
	while(len<n)Ins();
	return 0;
}




Measured memory_bytes: 3676
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> v(n);
	rep(i, n) cin >> v[i];

	int r = 0;
	int now_sum = 0;
	int now_xor = 0;
	ll ans = 0;
	rep(l, n) {
		while (r < n && (now_sum + v[r]) == (now_xor^v[r])) {
			now_sum += v[r];
			now_xor ^= v[r];
			r++;
		}
		ans += r - l;
		now_sum -= v[l];
		now_xor ^= v[l];
	}

	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#define ll long long
#define rep(i, a, b) for(int i = a; i < b; i++)
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if(a > b) cout << a-1 << "\n";
  else cout << a << "\n";
}


Measured memory_bytes: 3580
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var A = cin.ReadLong;
            var B = cin.ReadLong;

            var gcd = GCD(A, B);
            var facts = Factorize(gcd);
            Console.WriteLine(facts.Keys.Count + 1);
        }

        static long GCD(long a, long b)
        {
            return a == 0 ? b : GCD(b % a, a);
        }

        static Dictionary<long, int> Factorize(long n)
        {
            var ret = new Dictionary<long, int>();
            for (long i = 2; i * i <= n; i++)
            {
                if (n % i != 0)
                {
                    continue;
                }

                ret[i] = 0;
                while (n % i == 0)
                {
                    n /= i;
                    ret[i]++;
                }
            }

            if (n > 1)
            {
                if (ret.ContainsKey(n))
                {
                    ret[n]++;
                }
                else
                {
                    ret[n] = 1;
                }
            }

            return ret;
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13280
H, W = map(int, input().split())
A = []
for i in range(H):
    A.append(input())

red = [["." for w in range(W)] for _ in range(H)]
blue = [["." for w in range(W)] for _ in range(H)]

for i in range(H):
    if i % 2 == 0:
        red[i] = ["#" for w in range(W)]
        red[i][-1] = "."
    else:
        red[i][0] = "#"

for i in range(H):
    if i % 2 == 0:
        blue[i][-1] = "#"
    else:
        blue[i] = ["#" for w in range(W)]
        blue[i][0] = "."

for i in range(H):
    for j in range(W):
        if A[i][j] == '#':
            red[i][j] = "#"
            blue[i][j] = "#"

for i in range(H):
    print("".join(red[i]))

print("")

for i in range(H):
    print("".join(blue[i]))


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

string s;
int c['z' - 'a' + 1], c2['z'-'a'+1];
bool flag = false;
int index;

int main() {
	cin >> s;

	for (int i = s.length() - 1;i >= 0; i--) {
		c[s[i] - 'a']++;
		if (!flag) {
			for (int j = (int)(s[i] - 'a') + 1; j < 26; j++) {
				if (c2[j] > 0) {
					flag = true;
					index = i;
					break;
				}
			}
		}
		if (!flag)c2[s[i] - 'a']++;
	}

	if (s.length() == 26) {
		if (s == "zyxwvutsrqponmlkjihgfedcba") {
			cout << -1 << endl;
		}
		else {
			//ここしかない
			for (int i = (int)(s[index]-'a'+1); i < 26; i++) {
				if (c2[i] > 0) {
					s[index] = (char)(i + 'a');
					break;
				}
			}
			//
			for (int i = 0; i <= index; i++) {
				cout << s[i];
			}
			cout << endl;
			return 0;
		}

	}
	else {

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

		cout << s << endl;
	}
}

Measured memory_bytes: 384