akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

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

//main code

LL calc(LL num) {
	LL ret = 0;
	for (LL i = 0; i < 45; i++) {
		LL loop = (1LL << (i+1));
		LL cnt = ((num+1) / loop) * (loop / 2); // loop回数 x loop / 2(1周期の半分が1)
		cnt += max((LL)0,((num+1) % loop)  - (loop / 2)); // 端数の部分 - loop/2(0の部分)
		if (cnt % 2 == 1) {
			ret += (1LL << i);
		}
	}
	return ret;

}
int main(int argc, char const* argv[])
{
	LL a,b;
	cin >> a >> b;
	cout << (calc(a-1) xor calc(b)) << endl;
	return 0;
}



Measured memory_bytes: 256
//ABC153 C

#include <bits/stdc++.h>
using namespace std;

int N,K;
long long H[200000];
long long ans = 0;

int main() {
  cin >> N >> K;

  for(int i=0;i<N;i++){
    scanf("%lld",&H[i]);
  }

  sort(H,H+N);
  for(int i=0;i<N-K;i++){
    ans += H[i];
  }

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

}


Measured memory_bytes: 1792
S = str(input())
N = len(S)
a = N//2
b = N%2
N_base1 = "01"*a
N_base2 = "10"*a
N1 = N_base1 + "0"*b
N2 = N_base2 + "1"*b

n1,n2 = 0,0
for i, j, k in zip(S, N1, N2):
    if i != j:
        n1 += 1
    if i != k:
        n2 += 1

print(min(n1,n2))

Measured memory_bytes: 3444
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    S = input()
    N = len(S)

    isKaibun = lambda s: s == s[::-1]
    if isKaibun(S) and isKaibun(S[:N//2]) and isKaibun(S[(N+1)//2:]):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Collection;
import java.io.IOException;
import java.util.stream.Collectors;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int H = in.nextInt();
            int W = in.nextInt();
            List<List<Integer>> list = new ArrayList<>();
            for (int i = 0; i < H; i++) {
                String a = in.next();
                if (a.contains("#"))
                    list.add(a.chars().map(c -> c == '#' ? 1 : 0).boxed().collect(Collectors.toList()));
            }
            int i = 0;
            while (list.get(0).size() > i) {
                boolean f = true;
                for (List<Integer> l : list) {
                    if (l.get(i) != 0) {
                        f = false;
                    }
                }
                if (f) {
                    for (List<Integer> l : list) {
                        l.remove(i);
                    }
                } else {
                    i++;
                }
            }

            list.forEach(l -> {
                String s = l.stream()
                        .map(Object::toString)
                        .map(ss -> ss.replace('0', '.').replace('1', '#'))
                        .collect(Collectors.joining());
                out.println(s);
            });
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 26068
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N, X;
  cin >> N >> X;
  
  vector<int>  m(110);
  int i = 0, sum = 0, MIN = 100000;
  while(i < N){
    cin >> m.at(i);
    sum += m.at(i);
    if (MIN > m.at(i)) MIN = m.at(i);
    i++;
  }
  
  int left = X - sum;
  int same = left / MIN;
  cout << N + same << endl; 
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    int ans = count(s.begin(), s.end(), '1');
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int A, B, C;

int main() {
	cin >> A >> B >> C;
	cout << min(C, B / A) << endl;
	return 0;
}

Measured memory_bytes: 256
/*
Author: Srinjoy
Language: C++ 17
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
#define ZERO(a) memset(a,0,sizeof(a))
#define fileinput(s) freopen(s,"r",stdin)
#define MINUS(a) memset(a,0xff,sizeof(a))
typedef long long ll;
const ll mod = 1000000007;

template<class T>
istream& operator >> (istream& in, vector<T>& v){ for (auto &x : v) { in >> x; } return in; }
 
template<class T>
istream& operator >> (istream& in, pair<T, T> & v){ in >> v.fi >> v.se;return in; }

void printArr(vector<double> arr){
	cout<<"\n------------------------------------\n";

	for(int i=0;i<arr.size();i++) cout<<arr[i]<<" ";
	
	cout<<"\n------------------------------------\n";
}

void printArr(vector<vector<int> > arr){
	cout<<"\n------------------------------------\n";

	for(vector<int> i:arr){
		for(int j:i){
			cout<<j<<" ";
		}
		cout<<endl;
	}
	
	cout<<"\n------------------------------------\n";

}


int main(){
	optimiza_io
	
	int n,k;
	cin>>n>>k;

	setprecision(6);

	vector<int> arr(n);
	cin>>arr;
	vector<double> temp(n);

	for(int i=0;i<n;i++){
		temp[i] = (double)(arr[i]+1)/double(2);
	}

	//printArr(temp);

	double currSum = 0;
	double ret = -999;
	int size=0;

	for(int i = 0; i < arr.size(); ++i)
	{   
		currSum += temp[i];
		++size;

		if(size == k)
		{
			//de(currSum);
			ret = max(ret,currSum);
			currSum -= temp[i - k + 1];
			--size;
		}
	}

	cout<<fixed<<setprecision(8)<<ret<<endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define MP(a, b) make_pair(a, b)

//Union-Find木
struct UnionFind{
private:
    vector<int> parent;
public:
    UnionFind(int N) : parent(N){ //初期化する O(N)
        for(int i=0; i<N; i++) parent[i] = i;
    }
    int root(int a){ //親を返す O(log N)
        if(parent[a] == a) return a;
        return parent[a] = root(parent[a]);
    }
    void unite(int a, int b){ //木を併合する O(log N)
        int rootA = root(a);
        int rootB = root(b);
        if(rootA != rootB) parent[rootA] = rootB;
    }
    bool same(int a, int b){ //属する木が同じかを返す O(log N)
        return root(a) == root(b);
    }
};

int main(){
    iostream::sync_with_stdio(false);
    
    int N;
    cin >> N;
    int a[100000];
    vector<pair<int,int> > b;
    for(int i=0; i<N; i++){
        cin >> a[i];
        b.push_back(MP(a[i], i));
    }
    sort(b.begin(), b.end());

    UnionFind uf(N);

    //素因数分解
    map<int,int> so;
    for(int i=0; i<N; i++){
        for(int j=2; j<=sqrt(a[i])+1; j++){
            if(a[i] % j == 0){
                a[i] /= j;
                auto itr = so.find(j);
                if(itr == so.end()) so[j] = i;
                else uf.unite(i,itr->second);
                j--;
            }
        }
        if(a[i] != 1){
            auto itr = so.find(a[i]);
            if(itr == so.end()) so[a[i]] = i;
            else uf.unite(i,itr->second);
        }
    }

    //判定
    for(int i=0; i<N; i++){
        if(!uf.same(i, b[i].second)){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    
    return 0;
}


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

using namespace std;

long double arr[3000];

long double dp[3000][3000];

long double ans(int idx, int n, int stock) {
	
	if(dp[idx][stock])return dp[idx][stock];
	
	if(idx == n) return 1;

	if(stock) dp[idx][stock] += ((1-arr[idx])*ans(idx+1,n,stock-1));
	
	dp[idx][stock] += (arr[idx]*ans(idx+1,n,stock));

	return dp[idx][stock]; 
}

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

	int n; cin >> n;

	for(int i = 0; i < n; i++) cin >> arr[i];

	long double res = ans(0,n,n/2);

	cout << fixed << setprecision(10) << res << '\n';

	return 0;
}

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

#define ll long long

using namespace std;
int main(){
    int n,m,k;
    int best,maxv=0;
    int a[200005],b[200005];
    ll A[200005],B[200005];
    cin>>n>>m>>k;

    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    for(int i=0; i<m; i++){
        cin>>b[i];
    }
    A[0]=0;
    B[0]=0;
    for(int i=1; i<=n; i++){
        A[i]=a[i-1]+A[i-1];
    }
    for(int i=1; i<=m; i++){
        B[i]=b[i-1]+B[i-1];
    }
    best=m;
    for(int i=0; i<=n; i++){
        for(int j=best; j>=0; j--){
            if(B[j]<=k-A[i]){
                best=j;
                maxv=max(i+j,maxv);
                break;
            }
        }
    }
    cout<<maxv<<'\n';
    return 0;
}

Measured memory_bytes: 8268
def print_list(A):
    print(" ".join(map(str, A)))

def swap(A, i, j):
    temp = A[i]
    A[i] = A[j]
    A[j] = temp

def bubble(A):
    N = len(A)
    sorted = False
    count = 0
    for i in range(N):
        if (sorted):
            break
        sorted = True
        for j in reversed(range(i + 1, N)):
            if A[j] < A[j - 1]:
                swap(A, j, j - 1)
                count += 1
            sorted = False
    print_list(A)
    print(count)
    

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    bubble(A)


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

typedef long long ll;

int n;
int a[200005];
ll pre[200005];
ll suf[200005];

void solveeven(){
    pre[1]=a[1];
    pre[2]=a[2];
    suf[n]=a[n];
    suf[n-1]=a[n-1];
    for(int i=3;i<=n;i++)pre[i]=pre[i-2]+a[i];
    for(int i=n-2;i>=1;i--)suf[i]=suf[i+2]+a[i];
    ll res=max(pre[n-1],suf[2]);
    for(int i=1;i+3<=n;i+=2){
        res=max(res,pre[i]+suf[i+3]);
    }
    cout<<res<<endl;
}

ll dp[200005][3];

void solveodd(){
    dp[1][0]=a[1];
    for(int i=2;i<=n;i++){
        dp[i][0]=dp[i-2][0]+a[i];
        dp[i][1]=max(dp[i-2][1],dp[i-1][0]-a[i-1])+a[i];
        dp[i][2]=max(max(dp[i-2][2],dp[i-2][0]-a[i-2]),dp[i-1][1]-a[i-1])+a[i];
    }
    cout<<max(dp[n-2][0],max(dp[n][2],dp[n-1][1]))<<endl;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    if(n&1){
        solveodd();
    }else{
        solveeven();
    }

    return 0;
}

Measured memory_bytes: 9072
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

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

	int n, m, v, p;
	cin >> n >> m >> v >> p;

	vi a(n);
	trav(x, a) cin >> x;
	sort(all(a));
	reverse(all(a));

	auto works = [&](int ix){
		if(ix < p) return true;
		if(a[ix]+m < a[p-1]) return false;
		if(v <= p) return true;
		ll cnt = 0;
		rep(i,p-1,n) if(i != ix)
			cnt += min(m, a[ix]+m - a[i]);
		return cnt >= ll(m)*(v-p);
	};

	int lo = -1, hi = n;
	while(lo+1 < hi){
		int mi = (lo + hi)/2;
		if(works(mi)) lo = mi;
		else hi = mi;
	}
	cout << hi << endl;
}


Measured memory_bytes: 640
n, x = map(int, input().split())
l = [int(i) for i in input().split()]
d = [0]
cnt = 1
while cnt != n + 1 and d[-1] <= x:
	d.append(d[-1] + l[cnt - 1])
	cnt += 1
if d[-1] <= x: 
	print(cnt)
else:
	print(cnt - 1)


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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string a;
	cin >> a;
	for (int i = 0; i < a.length(); i++)
	{
		if( a[i] == '7' )
		{
			cout << "Yes" << '\n';
			return 0;
		}
	}
	cout << "No" << '\n';
	return 0;
}


Measured memory_bytes: 3652
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#define ll long long int
#define MOD 1000000007LL
using namespace std;
ll n,a,b;
ll h[114514];
bool able(int t){
    ll s=0;
    for(int i=0;i<n;i++){
        if(h[i]>b*t){
            if((h[i]-b*t)%(a-b)==0){
                s+=(h[i]-b*t)/(a-b);
            }else{
                s+=(h[i]-b*t)/(a-b)+1;
            }
        }
    }
    if(s<=t){
        return true;
    }else{
        return false;
    }
}
int main() {
    cin>>n>>a>>b;
    ll m=0;
    for(int i=0;i<n;i++){
        cin>>h[i];
        m=max(m,h[i]);
    }
    ll ng=0;
    ll ok=m;
    while(ok-ng>1){
        ll mid=(ng+ok)/2;
        if(able(mid)){
            ok=mid;
        }else{
            ng=mid;
        }
    }
    cout<<ok<<endl;
}


Measured memory_bytes: 1024
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
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 LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
s = SRL(2)
i = 0
ans = 1
while i < n:
    if s[0][i] == s[1][i]:
        if i == 0: ans *= 3
        elif s[0][i - 1] == s[1][i - 1]:
            ans *= 2
        i += 1
    else:
        if i == 0: ans *= 6
        elif s[0][i - 1] == s[1][i - 1]:
            ans *= 2
        else:
            ans *= 3
        i += 2
    ans %= mod


print(ans)



Measured memory_bytes: 39664
#include <bits/stdc++.h>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef unordered_map<int,int> m32;
typedef map<ll,ll> m64;
typedef unordered_map<ll,set<ll> > m648;
typedef pair<ll,p64 > pp64;
ll MOD = 1e9 + 7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX
v64 dp;

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,w;
    cin >> n >> w;
    ll a[n][2];
    forn(i,n) forn(j,2) cin >> a[i][j];
    ll c = 1e5+5;
    ll dp[c];
    forn(i,c) dp[i]=-1;
    dp[0]=0;
    forn(i,n){
    	rforn(j,c-1){
    		if(j<a[i][1]) continue;
    		if(dp[j-a[i][1]]!=-1 && dp[j-a[i][1]]+a[i][0]<=w){
    			if(dp[j]==-1) dp[j]=dp[j-a[i][1]]+a[i][0];
    			else dp[j]=min(dp[j],dp[j-a[i][1]]+a[i][0]);
    			// cout << j << " " << dp[j] << ln;
    		}
    	}
    }
    // forn(i,110){
    // 	cout << dp[i] << " "; 
    // }
    // cout << ln;
    rforn(i,c-1){
    	if(dp[i]!=-1){
    		cout << i << ln;
    		return 0;
    	}
    }
    // forn(i,n+1){
    // 	forn(j,w+1){
    // 		cout << dp[i][j] << " ";
    // 	}
    // 	cout << ln;
    // }
    // ll ans=0;
    // cout << dp[n][w] << ln;
    // rforn(i,w-1){
    // 	ans = max(dp[n][i],ans); 
    // }
    // cout << ans << ln;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define pri 100000000000007
using namespace std;
int main() {
	ll n;
	cin>>n;
	ll a[n+1],b[n+1]={0};
	
	for(ll i=1;i<=n;i++){cin>>a[i];b[i]=b[i-1]+a[i];}
	ll ans[n+1][n+1];
	for(ll ze=0;ze<n;ze++){
		
		for(ll za=1;za+ze<=n;za++){
		       if(ze==0)ans[za][ze]=0;
		       else{
		                ans[za][ze]=pri;
			    		for(ll j=za;j<za+ze;j++){
		    						ans[za][ze]=min( ans[za][ze],ans[j+1][za+ze-j-1]+ans[za][j-za]+b[za+ze]-b[za-1]);
		          }}
		}
	}
	
	cout<<ans[1][n-1]<<endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define int long long
const int inf=1145141919;
const int dd[]={0,-1,0,1,0};
using namespace std;
struct Node{
	vector<Node*> e;
	int c=0;
	int d=-1;
	bool f=false;
};
struct Query{
	int v;
	int d;
	int c;
};
Node p[100000];
signed main(){
	int n,m,k;
	int i,j;
	cin>>n>>m;
	for(i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;
		v--;
		p[u].e.push_back(p+v);
		p[v].e.push_back(p+u);
	}
	cin>>k;
	Query q[100000];
	for(i=0;i<k;i++){
		cin>>q[i].v>>q[i].d>>q[i].c;
		q[i].v--;
	}
	for(i=k-1;i>=0;i--){
		function<void(Node*,int,int)> saiki=[&](Node *x,int y,int z){
			if(z<0)
				return;
			if(!x->f){
				x->c=y;
				x->f=true;
			}
			if(x->d<z){
				x->d=z;
				for(auto xx:x->e)
					saiki(xx,y,z-1);
			}
			return;
		};
		saiki(p+q[i].v,q[i].c,q[i].d);
	}
	for(i=0;i<n;i++)
		cout<<p[i].c<<endl;
}

Measured memory_bytes: 11636
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=4999999996000000001;



int main(){
    int n,K;
    cin>>n>>K;
    vector<ll> x(n),y(n);
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
    }

    ll ans=INF;
    if(K==2){
        for(int i=0;i<n-1;i++){
            for(int j=i+1;j<n;j++){
                ll ux=max(x[i],x[j]);
                ll lx=min(x[i],x[j]);
                ll uy=max(y[i],y[j]);
                ll ly=min(y[i],y[j]);
                ll buf=(ux-lx)*(uy-ly);
                ans=min(buf,ans);
            }
        }
        cout<<ans<<endl;
        return 0;
    }

    if(K==3){
        for(int i=0;i<n-2;i++){
            for(int j=i+1;j<n-1;j++){
                for(int k=j+1;k<n;k++){
                    ll ux=max(max(x[i],x[j]),x[k]);
                    ll uy=max(max(y[i],y[j]),y[k]);
                    ll lx=min(min(x[i],x[j]),x[k]);
                    ll ly=min(min(y[i],y[j]),y[k]);
                    ll buf=(ux-lx)*(uy-ly);
                    ans=min(buf,ans);
                }
            }
        }
        cout<<ans<<endl;
        return 0;
    }

    for(int i=0;i<n-3;i++){
        for(int j=i+1;j<n-2;j++){
            for(int k=j+1;k<n-1;k++){
                for(int l=k+1;l<n;l++){
                    ll ux=max(max(x[i],x[j]),max(x[k],x[l]));
                    ll uy=max(max(y[i],y[j]),max(y[k],y[l]));
                    ll lx=min(min(x[i],x[j]),min(x[k],x[l]));
                    ll ly=min(min(y[i],y[j]),min(y[k],y[l]));
                    int num=0;
                    for(int m=0;m<n;m++){
                        if(x[m]>=lx && x[m]<=ux && y[m]>=ly && y[m]<=uy) num++;
                    }
                    ll buf=(ux-lx)*(uy-ly);
                    if(num>=K) ans=min(ans,buf);
                }
            }
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 3644
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

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

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



int main(){
    int n;
    cin >> n;

    ll ans = 1;
    rep(i,0,n){
        ll a;
        cin >> a;

        ans = lcm(ans,a);
    }

    P(ans);
	
	return  0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int n,m;

int dice[1024];
int field[1024];

int main(){
	int temp;
	while(scanf("%d %d",&n,&m) && (n || m)){
		for(int i=0;i<n;i++){
			scanf("%d",&field[i]);
		}
		for(int i=0;i<m;i++){
			scanf("%d",&dice[i]);
		}
		int ans = 0;
		int pos = 0;
		while(pos < n - 1){
			pos += dice[ans];
			if(pos < n - 1){
				pos += field[pos];
			}
			ans++;
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 0
N = int(input())
yakusu= 0
for i in range(N+1):
    count = 0
    for j in range(1, i+1):
        if i % j == 0:
            count += 1
        else:
            pass
        if count > 8:
            break
        
    if count == 8 and i % 2 == 1:
        yakusu += 1
    else:
        pass
    
print(yakusu)
        

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

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

const int nmax=1<<17;
const ll mod=1000000007;

//////////
ll gcd(ll a,ll b){
	return (b==0)?a:gcd(b,a%b);
}

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

ll inv(ll a){
	ll n=mod-2;
	ll b=1LL;
	while(n){
		if(n&1) b=b*a%mod;
		a=a*a%mod;
		n>>=1;
	}
	return b;
}

/////////

int p[nmax];
ll tsum[nmax];
ll tcycle[nmax];

int size;
ll sum[2*nmax-1];
ll cycle[2*nmax-1];


void init(int n){
	size=1;
	while(size< n) size*=2;
	for(int i=size;i<2*size-1; i++) cycle[i]=1LL,sum[i]=0LL;
	for(int i=size-1;i<n+size-1;++i){
		sum[i]=(tsum[i-(size-1)]*inv(tcycle[i-(size-1)]))%mod;
		cycle[i]=tcycle[i-(size-1)];
	}
	for(int i=size-2;i>=0;--i){
		sum[i]=(sum[2*i+1]+sum[2*i+2])%mod;
		cycle[i]=lcm(cycle[2*i+1],cycle[2*i+2]);
	}
}

ll lcm_query(int a, int b, int k,int l,int r){
	if(r<=a||b<=l) return 1LL;

	if(a<=l&&r<=b)
		return cycle[k];
	else{
		ll vl =lcm_query(a,b,k*2+1,l,(l+r)/2);
		ll vr =lcm_query(a,b,k*2+2,(l+r)/2,r);
		return lcm(vl,vr);
	}
}

ll sum_query(int a, int b, int k,int l,int r){
	if(r<=a||b<=l) return 0LL;

	if(a<=l&&r<=b)
		return sum[k];
 	else{
		ll vl =sum_query(a,b,k*2+1,l,(l+r)/2);
		ll vr =sum_query(a,b,k*2+2,(l+r)/2,r);
		return (vl+vr)%mod;
	}
}


int main(void){
	int n,q;
	cin >> n >> q;
	n++;
	for(int i=1;i<n;++i) cin >> p[i];

	for(int i=1;i<n;++i){
		vi order;
		int cur=p[i],csum=p[i],cyc=1;
		order.pb(cur);
		while(cur!=i){
			cur=p[cur];
			csum+=cur;
			cyc++;
			order.pb(cur);
		}
		for(auto &j:order) tcycle[j]=cyc,tsum[j]=csum;
	}
	cycle[0]=1LL;

	init(n);

	rep(loop,q){
		int l,r;
		cin >> l >> r;
		r++;
		ll num=lcm_query(l,r,0,0,size)%mod;
		ll den=sum_query(l,r,0,0,size)%mod;
		cout << num*den%mod << endl;
	}
	return 0;
}

Measured memory_bytes: 7748
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(a+b+c >= 22){
		cout << "bust" << endl;
	}else{
		cout << "win" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long GCD_(long long a, long long b) {
    return b ? GCD_(b, a % b) : a;
}
int arr[100005];
long long dp[100005];
int n,k;
long long solve(int i){
   if(dp[i]!=-1) return dp[i];
   if(i == n) return dp[i] = 0;
   long long mn = 1e18;
   for(int j = 1;j<=k && i+j<=n;j++)
      mn = min(mn,solve(i+j) + abs(arr[i] - arr[i+j]));
  return dp[i] = mn;
}
int main(){
    memset(dp,-1,sizeof(dp));
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>arr[i];
    cout<<solve(1);
 return 0;
}


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

int main() {
  string a;
  cin >> a;
  int ansewr = 1;
  if(a=="RRR"){ansewr=3;}
  if(a=="RRS"){ansewr=2;}
  if(a=="RSR"){ansewr=1;}
  if(a=="SRR"){ansewr=2;}
  if(a=="RSS"){ansewr=1;}
  if(a=="SSR"){ansewr=1;}
  if(a=="SRS"){ansewr=1;}
  if(a=="SSS"){ansewr=0;}
  cout << ansewr;
}


Measured memory_bytes: 3640
t=x=y=0
gets.to_i.times do
    a,b,c=gets.split.map &:to_i
    d=(b-x).abs+(c-y).abs
    if d>a-t || d%2!=(a-t)%2
        puts :No
        exit
    end
    t,x,y=a,b,c
end
puts :Yes

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

int main(int argc, const char * argv[]) {
    int a, b;
    
    //入力
    cin >> a >> b;
    
    //出力
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
ans = 0
dis = [[0] * N for _ in range(N)]
info = []
for i in range(M):
    a,b = map(int,input().split())
    info.append([a-1,b-1])
    dis[a-1][b-1] = 1
    dis[b-1][a-1] = 1

def dfs(p):
    visited[p] = True
    for i in range(N):
        if dis[p][i] == 1 and visited[i] is False:
            dfs(i)

def check(start,n):
    global visited
    visited = [False] * N
    a = info[n][0]
    b = info[n][1]
    dis[a][b] = 0
    dis[b][a] = 0
    dfs(start)
    if set(visited) != {True}:
        global ans 
        ans += 1
    dis[a][b] = 1
    dis[b][a] = 1

for i in range(M):
    check(0,i)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allg(v) v.begin(), v.end(), greater<int>()

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s, t;  
  cin >> s >> t;
  
  string str;
  rep(i, 0, s.size())
    str += s;
  
  cout << ( !(str.find(t) == string::npos) ?"Yes" :"No") << "\n";

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll a, b, n, ans = 0;

int main() {
	cin >> a >> b >> n;
	if (b < 1e6) {
		rep(i, min(n + 1, b))ans = max(ans, a * i / b - a * (i / b));
	}
	else {
		for (int i = 0; max((ll)0, i * b - 1) <= n; i++)ans = max(ans, a * max((ll)0, i * b - 1) / b - a * (max((ll)0, i * b - 1) / b));
		ans = max(ans, a * n / b - a * (n / b));
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int a, b;
  int n;
  cin >> a >> b;
  cin >> n;
  bool flag = false;
  for (int i = 0; i < n; i++) {
    int s, f;
    cin >> s >> f;
    if (a < s && s < b) {
      flag = true;
      break;
    }
    if (a < f && f < b) {
      flag = true;
      break;
    }
    if (a == s || b == f) {
      flag = true;
      break;
    }
    if (s < a && a < f){
      flag = true;
      break;
    }
    if (s < b && b < f){
        flag = true;
        break;
    }
  }
  if (flag) {
    cout << 1 << endl;
    return 0;
  }
  cout << 0 << endl;
  return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int a, b; cin >> a >> b;
	string str; cin >> str;
	vector<string> s(a);
	for (int i = 0; i <a; i++) {
		s[i] = str[i];
	}
	if (s[b - 1] == "A")s[b - 1] = "a";
	if (s[b - 1] == "B")s[b - 1] = "b";
	if (s[b - 1] == "C")s[b - 1] = "c";

	for (int i = 0; i < a; i++) {
		cout<<s[i];
	}
	

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

int main(int argc, const char * argv[]) {
  ll N, A, B;
  cin >> N >> A >> B;
  ll a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  ll ans = 0;
  for (int i = 1; i < N; i++) {
    ans += min(A * (a[i] - a[i - 1]), B);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long n,i,j,b;
int main(){
    cin>>n;
    for(i=sqrt(n);i>=1;i--)
      if(n%i==0)break;
    b=n/i;
    while(b)
    {
    	b=b/10;
    	j++;
    }
    cout<<j;


	return 0;
}


Measured memory_bytes: 256
// OUM NAMA MA SWARASATI

#include<stdio.h>

int main(){
    int i,j;
    for(i=1;i<10;i+=1)
        for(j=1;j<10;j+=1){
            printf("%dx%d=%d\n",i,j,i*j);
    }
    return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	string S, T;
	cin >> S >> T;

	for (int i = 0; i < 100; i++)
	{
		if (S == T)
		{
			cout << "Yes" << endl;
			return 0;
		}
		char tmp = S[0];
		for (int j = 0; j < (int)S.size()-1; j++)
			S[j] = S[j+1];
		S[S.size()-1] = tmp;
	}
	cout << "No" << endl;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	string s;
	cin>>s;
	if(s=="SUN"){
		cout<<7<<endl;
	}
	else if(s=="MON"){
		cout<<6<<endl;
	}
	else if(s=="TUE"){
		cout<<5<<endl;
	}
	else if(s=="WED"){
		cout<<4<<endl;
	}
	else if(s=="THU"){
		cout<<3<<endl;
	}
	else if(s=="FRI"){
		cout<<2<<endl;
	}
	else{
		cout<<1<<endl;
	}
	return 0;
}

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

int main()
{
	int N;
	cin >> N;
	string s;
	int lb = 0, ub = N;
	cout << 0 << endl;
	cin >> s;
	if (s == "Vacant") {
		return 0;
	}
	bool blb = s == "Male";
	while (ub - lb > 1) {
		int m = (lb + ub) / 2;
		cout << m << endl;
		cin >> s;
		if (s == "Vacant") {
			break;
		}
		if ((blb == (s == "Male")) ^ ((m - lb) % 2)) {
			lb = m;
			blb = (s == "Male");
		}
		else {
			ub = m;
		}
	}
	return 0;
}


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

int main() {
    string s;
    cin >> s;
    if((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    for(int i=0; i<h; ++i)
        cin >> s[i];

    int ans = 0;
    for(int i=0; i<(1<<(h+w)); ++i){
        bitset<32> bs(i);
        int cnt = 0;
        for(int y=0; y<h; ++y){
            for(int x=0; x<w; ++x){
                if(!bs[y] && !bs[h+x] && s[y][x] == '#')
                    ++ cnt;
            }
        }
        if(cnt == k)
            ++ ans;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    int a;
        cin>>a;
    int n=a;
    int c=0;
        while(n>0){
            c++;
            n/=10;
        }
    if(c==1){
        cout<<a;
        return 0;
    }
    long long ans = 0;
    // cout<<c;
    if(c%2!=0){
        int sm = 1;
        for(int i=1;i<c;i++){
            sm *= 10;
        }
        ans += a-sm+1;
    }
    c=c/2;
    for(int i=0;i<c;i++){
        ans += 9*(long long)pow(10,2*i);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
from collections import defaultdict as dd
from collections import Counter
from pprint import pprint as pp

YN = {True: 'Yes', False: 'No'}
ri = lambda: int(input())
ria = lambda: list(map(int, input().split()))
rian = lambda n: [ria() for _ in range(n)]
rs = lambda: input()
rsa = lambda: input().split()
rsn = lambda n: [rs() for _ in range(n)]

N = ri()
A = ria()

ret = 0
l = 0
lr = 0

acc = 0
while l < len(A) and lr < len(A):
  if acc & A[lr] == 0:
    ret += 1
    acc |= A[lr]
    lr += 1
    if lr == len(A):
      for i in range(len(A) - l):
        ret += i
      break
  else:
    acc ^= A[l]
    l += 1
    if l != lr:
      ret += lr - l

print(ret)

Measured memory_bytes: 26200
#include <bits/stdc++.h>
#include <cstdlib>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
    int ans;
    int n;
    cin >> n;
    if (n % 2 == 0) {
        ans = n / 2;
    } else {
        ans = n / 2 + 1;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int me=300000+10;
long long n,a[me],ans=0;
int main()
{
    scanf("%lld",&n);
    for(int i=1;i<=3*n;i++){
        scanf("%lld",&a[i]);
    }
    sort(a+1,a+1+3*n);
    for(int i=(3*n)-1;i>=n+1;i-=2){
        ans+=a[i];
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 2688
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll dp[maxn],n,k,ans;
const ll mod=1000000007;

inline ll pw(ll a,ll b)
{
	ll ans=1,base=a;
	while(b)
	{
		if(b&1) ans=(ans*base)%mod;
		base=(base*base)%mod; b>>=1;
	}
	return ans;
}

int main()
{
	n=read(); k=read();
	for(int i=k;i>=1;i--)
	{
		dp[i]=pw(k/i,n);
		for(int j=2*i;j<=k;j+=i)
		{
			dp[i]=(dp[i]-dp[j]+mod)%mod;
		}
	}
	for(int i=1;i<=k;i++) ans=(ans+i*dp[i])%mod; cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4364
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    getline(cin, S);
    for (char c : S){
        if (c >= 'A' && c <= 'Z'){
            c += 32;
        } else if (c >= 'a' && c <= 'z'){
            c -= 32;
        }
        cout << c;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>
#include <math.h>
using namespace std;

int main()
{
  int n;
  cin >> n;

  char c[n];
  int rcount = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> c[i];
    if (c[i] == 'R')
    {
      rcount++;
    }
  }
  int result = 0;
  for (int i = 0; i < rcount; i++)
  {
    if (c[i] == 'W')
    {
      result++;
    }

    // cout << c[i] << ",";
  }
  // cout << "\n";
  cout << result << "\n";

  return 0;
}

Measured memory_bytes: 3828
#pragma target("avx")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
  long long n,ans=0;
  cin >> n;
  string s[n];
  for(int i=0;i<n;i++){
    cin >> s[i];
    string tmp=s[i];
    sort(tmp.begin(), tmp.end());
    s[i]=tmp;
  }
  sort(s, s+n);
  long long cnt=1;
  for(int i=1;i<n;i++){
    if(s[i]!=s[i-1]){
      ans+=cnt*(cnt-1)/2ll;
      cnt=1;
    }else{
      cnt++;
    }
  }
  ans+=cnt*(cnt-1)/2ll;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5760
from collections import defaultdict
d = defaultdict(list)
S = input()
for i in range(len(S)):
    d[S[i]].append(i)
ans = 100
for e in d.values():
    e = [-1] + e + [len(S)]
    m = 0
    for j in range(len(e) - 1):
        m = max(m, e[j+1] - e[j] - 1)
    ans = min(ans, m)
print(ans)

Measured memory_bytes: 3316
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

bFood = 21
sut = 0

for i in range(N):
    food = A[i]
    sut = B[food - 1] + sut
    
    if food is bFood + 1: 
        sut = C[food - 2] + sut

    bFood = food

print(sut)

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;

int main(){
	double a, b, c;
	cin >> a >> b >> c;
	double pi = acos(-1.0);
	double rad = c * pi / 180;
	double s = 0.5 * a * b * sin(rad);
	printf("%.8lf ", s);
	double L2 = a*a + b*b - 2*a*b*cos(rad);
	printf("%.8lf %.8lf\n", sqrt(L2)+a+b, 2*s/a);
}


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

static const int MAX = 100000;

struct Node{
        int parent, left, right;
};

Node node[MAX];

int getDepth(int i){
        int j = i;
        int d = 0;
        while(node[j].parent!=-1){
                j = node[j].parent;
                d++;
        }
        return d;
}

int getHeight(int i){
        if(i==-1) return -1;
        else return 1+max(getHeight(node[i].left), getHeight(node[i].right));
}

int main(){
        int n,a,tmp,deg,sib;
        cin>>n;
        for(int i=0;i<n;i++){
                node[i].parent = -1;
                node[i].left = -1;
                node[i].right = -1;
        }
        for(int i=0;i<n;i++){
                cin>>a;
                cin>>node[a].left;
                if(node[a].left!=-1) node[node[a].left].parent = a;
                cin>>node[a].right;
                if(node[a].right!=-1) node[node[a].right].parent = a;
        }

        for(int i=0;i<n;i++){
                cout<<"node "<<i<<": parent = "<<node[i].parent;
                tmp = node[i].parent;
                if(tmp == -1) sib = -1;
                else if(node[tmp].left==i)  sib = node[tmp].right;
                else sib = node[tmp].left;
                cout<<", sibling = "<<sib;
                deg = 0;
                if(node[i].left!=-1) deg += 1;
                if(node[i].right!=-1) deg += 1;
                cout<<", degree = "<<deg;
                cout<<", depth = "<<getDepth(i);
                cout<<", height = "<<getHeight(i);
                if(node[i].parent == -1) cout<<", root";
                else if(node[i].left==-1 && node[i].right==-1) cout<<", leaf";
                else cout<<", internal node";
                cout<<endl;
        }

        return 0;
}


Measured memory_bytes: 3096
aI, aO, _, aJ, aL, _, _ = map(int,input().split())

"""
aO -> +1
aI, aJ, aL -> +3
aI * 2 -> +2
aJ * 2 -> +2
aL * 2 -> +2

aI, aJ, aLを2個作ると、
aI * 2, aJ * 2, aL * 2に分解できる
"""

# aI, aJ, aLを0個作る
ans0 = aO + (aI // 2 + aJ // 2 + aL // 2) * 2
# aI, aJ, aLを1個作る
if min(aI, aJ, aL) > 0:
    ans1 = aO + 3 + ((aI-1) // 2 + (aJ-1) // 2 + (aL-1) // 2) * 2
else:
    ans1 = 0
print(max(ans0, ans1))

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

#define ll long long
#define ld long double
#define COIN const int
#define ite iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define sz(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/

using namespace std;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ll x,x1,x2,a,b,i,j; cin >>x;
	for (i=-200;i<=200;i++) {
		for (j=-200;j<=200;j++) {
			if (pow(i,5)-pow(j,5)==x)
			{
				cout <<i <<" "<<j;
				return 0;
			}
		}
	}
	return 0;
}
/******************************************************************************
******************************************************************************/


Measured memory_bytes: 4068
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

char ss[26];
int main(){
    string s;
    cin >> s;
    for(size_t i = 0; i < s.size(); i++)
    {
        ss[s[i]-'a']++;
    }

    for(size_t i = 0; i < 26; i++)
    {
        if(ss[i]==0){
            printf("%c\n", 'a'+i);
            break;
        }
        if(i==25) cout << "None" << endl;
    }

    
    
    return 0;
}

Measured memory_bytes: 512