akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


void solve() {
	int n, m; scanf("%d %d", &n, &m);
	vector<int> b(n); for (int i = 0; i < n; i++) scanf("%d", &b[i]);
	vector<int> p(m); for (int i = 0; i < m; i++) scanf("%d", &p[i]);
	vector<ll> d((1 << n), INF);
	ll ini = 0;
	for (int i = 0; i < n; i++) {
		if (b[i] == 1) ini |= (1 << i);
	}
	d[ini] = 0;
	queue<ll> q; q.push(ini);
	while (!q.empty()) {
		ll cur = q.front();
		q.pop();
		for (int i = 0; i < n - 1; i++) {
			if ((cur >> i & 1) != (cur >> (i + 1) & 1)) {
				ll next = cur;
				next ^= (1 << i);
				next ^= (1 << (i + 1));
				if (d[next] != INF) continue;
				d[next] = d[cur] + 1;
				q.push(next);
			}
		}
	}
	vector<int> c1, c2;
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < p[i]; j++) {
			c1.push_back(i % 2 == 0);
			c2.push_back(i % 2 == 1);
		}
	}
	ll t1 = 0, t2 = 0;
	for (int i = 0; i < n; i++) {
		if (c1[i] == 1) t1 |= (1 << i);
		if (c2[i] == 1) t2 |= (1 << i);
	}
	cout << min(d[t1], d[t2]) << endl;
}

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

	int kkt = 1;
	while (kkt--) {
		solve();
	}
	return 0;
}


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

#define IOS 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ld			long double
#define ll 			long long
#define ull			unsigned long long
#define pb			push_back
#define mp			make_pair
#define F			first
#define S			second
#define lb			lower_bound
#define ub			upper_bound
#define deb(x)			cout<<"#x "<<x<<"\n";
#define trace(x,y)		cout<<"#x "<<x<<" #y "<<y<<"\n";
#define cn			cout<<"\n";
#define mod			1000000007

bool SBF(const pair<int,int>& a, const pair<int,int>& b){return a.F < b.F;}
bool SBS(const pair<int,int>& a, const pair<int,int>& b){return a.S < b.S;}

void solve(){

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

        ll sum = 0;
	int maxL = a[0];
	for(int i=1;i<n;i++){
		if(a[i] < maxL ){
			sum += maxL-a[i];
		}
		maxL = max(maxL, a[i]);
	}
	cout<<sum<<"\n";
}





int main(){
	solve();
}


Measured memory_bytes: 4400
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <tuple>

template <class T>
using MaxHeap = std::priority_queue<T>;

void solve() {
    int n, m;
    std::cin >> n >> m;

    MaxHeap<std::pair<int, int>> ps;
    while (n--) {
        int s, v;
        std::cin >> s >> v;
        ps.emplace(v, s);
    }

    std::vector<int> cs(m);
    for (auto& c : cs) std::cin >> c;
    std::sort(cs.rbegin(), cs.rend());

    int ans = 0;
    for (auto c : cs) {
        while (!ps.empty()) {
            int v, s;
            std::tie(v, s) = ps.top();
            ps.pop();
            if (s <= c) {
                ++ans;
                break;
            }
        }
    }

    std::cout << ans << "\n";
}

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

    solve();

    return 0;
}



Measured memory_bytes: 4168
#include<stdio.h>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)


int main()
{
    int n,a,b;
    scanf("%d\n",&n);
    if(n==1)
    {
        printf("Hello World\n");
        return 0;
    }
    else
    {
        scanf("%d\n%d",&a,&b);
        printf("%d\n",a+b);
        return 0;
    }    
    return 0;
}

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

#define MAX 334

int n;

char buf[MAX];

vector<string> v;

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

inline char gt(int a, int b){
	return v[a%n][b%n];
}

int main(){
	cin >> n;
	for (int i = 0; i < n; i++){
		scanf("%s", buf);
		v.push_back(buf);
	}
	int ans = 0;
	for (int i = 0; i < v.size(); i++){
		for (int j = 0; j < v.size(); j++){
			int mint = min(i, j);
			int x = i - mint;
			int y = j - mint;
			if (mp.count(make_pair(x, y))){
				ans += mp[make_pair(x, y)];
				continue;
			}
			bool ok = true;
			for (int ii = 0; ii < v.size(); ii++){
				for (int jj = 0; jj < v.size(); jj++)
				{
					if (gt(ii + i, jj + j) != gt(jj + i, ii + j)){
						ok = false;
						break;
					}
				}
				if (!ok)break;
			}
			ans += (int)(ok);
			mp[make_pair(x, y)] = ok;
		}
	}
	cout << ans << endl;
	return 0;
}

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


using namespace std;


template <typename integer>
integer _gcd(integer a, integer b) {
    if (b != 0) return _gcd(b, a%b);
    else return a;
}

template <typename integer>
integer gcd (integer a, integer b) {
    if (a > b) return _gcd(a, b);
    return _gcd(b, a);
}

template<typename integer>
integer lcm(integer a, integer b) {
    return (a * b) / gcd(a, b);
}

int f(int a) {
    int ret = 0;
    while (a%2 == 0) {
        a /= 2;
        ret++;
    }
    return ret;
}


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

    vector<long long> a(n);
    for (int i=0; i<n; i++) {
        cin >> a[i];
        a[i] /= 2;
    }

    int t = f(a[0]);
    for (int i=0; i<n; i++) {
        if (f(a[i]) != t) {
            cout << 0 << endl;
            return 0;
        }
        a[i] >>= t;
    }
    m >>= t;

    long long l = 1;
    for (int i=0; i<n; i++) {
        l = lcm(l, a[i]);
        if (l > m) {
            cout << 0 << endl;
            return 0;
        }
    }

    m /= l;
    cout << (m+1)/2 << endl;
    return 0;
}


Measured memory_bytes: 1024
import sys

n, m = map(int, sys.stdin.readline().split())
if n > m:
    n, m = m, n

def main():
    if n == 1:
        if m == 1:
            return 1
        else:
            return m - 2
    else:
        return (n - 2) * (m - 2)
        
if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;

int main()
{
	char str[55];
	scanf("%s",str);
	int len=strlen(str);
	str[len-8]='\0';
	printf("%s\n",str); 
}


Measured memory_bytes: 256
import fractions
a,b,c,d = map(int, input().split())
l = c*d//fractions.gcd(c,d)
left = b - (b//c + b//d - b//l)
right = a-1 - ((a-1)//c + (a-1)//d - (a-1)//l)
print(left - right)

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int N; cin >> N;
    vector<int> A(N),B(N),C(N-1);
    int ans = 0;
    REP(i,N) cin >> A[i];
    REP(i,N){
        cin >> B[i];
        ans += B[i];
    }
    REP(i,N-1) cin >> C[i];

    
    REP(i,N-1){
        if(A[i+1]-A[i] == 1){
            ans += C[A[i]-1];
        }
    }

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

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] A = new int[N];
        int[] B = new int[N];
        int sum = 0;
        A[0] = scanner.nextInt();
        int l = A[0];

        for(int i = 1; i < N; i ++) {
            A[i] = scanner.nextInt();
            l = lcm(l, A[i]);
        }
        for(int i = 0; i < N; i ++) {
           B[i] = l / A[i];
           sum += B[i];
        }

        System.out.println((double)l/sum);
    }

    static int lcm (int a, int b) {
        int temp;
        long c = a;
        c *= b;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return (int)(c/b);
    }

}

Measured memory_bytes: 22740
#include <stdio.h>
#include <string.h>

int main(void)
{
    int n, a[10000];
    int sum, m;
    int i;
    
    
    while (1){
        scanf("%d", &n);
        if (n == 0){
            break;
        }
        
        sum = 0;
        for (i = 0; i < n; i++){
            scanf("%d", &a[i]);
            sum += a[i];
        }
        
        m = 0;
        for (i = 0; i < n; i++){
            if (a[i] <= sum / n){
                m++;
            }
        }
        
        printf("%d\n", m);
    }
    
    return (0);
}



Measured memory_bytes: 2036
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String c = sc.next();
		sc.close();
		char ch = c.charAt(0);
		if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') {
			System.out.println("vowel");
		}else {
			System.out.println("consonant");
		}
	}
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    int wa1=0,wa2=0;
    long long cost1=0,cost2=0;
    for(int i=0;i<n;i++){
        if(i%2==0){
            if(wa1+a[i]<=0){
                cost1+=1-(wa1+a[i]);
                wa1=1;
            }
            else wa1+=a[i];
            if(wa2+a[i]>=0){
                cost2+=wa2+a[i]+1;
                wa2=-1;
            }
            else wa2+=a[i];
        }
        if(i%2){
            if(wa1+a[i]>=0){
                cost1+=(wa1+a[i])+1;
                wa1=-1;
            }
            else wa1+=a[i];
            if(wa2+a[i]<=0){
                cost2+=1-(wa2+a[i]);
                wa2=1;
            }
            else wa2+=a[i];
        }
    }
    cout<<min(cost1,cost2)<<endl;
    return 0;
}

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

const int INF = 1<<30;

int main() 
{
    int n, m, x;
    cin >> n >> m >> x;

    ll C[n];
    vector<vector<ll>> A(n);
    rep(i,n) {
        cin >> C[i];
        rep(j,m) {
            int a;
            cin >> a;
            A[i].push_back(a);
        }
    }

    ll ans = INF;
    rep(bit,1<<n) {
        ll B[m];
        ll res = 0;
        rep(j,m) B[j] = 0;

        rep(i,n) {
            if (bit>>i&1) {
                res+= C[i];
                rep(j,m) B[j] += A[i][j];
            }
        }

        bool isOk = true;
        rep(j,m) {
            if(B[j]<x) isOk = false;
        }        

        if (isOk) ans = min(ans, res);
    }

    if (ans == INF) ans = -1;
    cout << ans << endl;


    
    return 0;
}


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

const	int m = 1000005;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	vector<int> cnt(m);
	for(int x : a){
		if(cnt[x] != 0){
			cnt[x] = 2;
			continue;
		}
		for(int i = x; i < m; i += x) cnt[i]++;
	}
int ans = 0;
for(int x : a){
	if(cnt[x] == 1) ans++;
} 
cout << ans << endl;
}

Measured memory_bytes: 8000
MAX_N = 10 ** 5

N, C = gets.split.map(&:to_i)

imos = Array.new(C) { Array.new(MAX_N+2, 0) }
N.times do
  s, t, c = gets.split.map(&:to_i)
  imos[c-1][s] += 1
  imos[c-1][t+1] -= 1
end
C.times { |i| (MAX_N+1).times { |j| imos[i][j+1] += imos[i][j] } }
C.times { |i| imos[i].map! {|x| x != 0 ? 1 : 0 } }

sums = Array.new(MAX_N+2, 0)
(0..MAX_N+1).each { |i| C.times { |j| sums[i] += imos[j][i] } }
puts sums.max


Measured memory_bytes: 28156
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl
#define YORN(f) cout<<((f)?"YES":"NO")<<endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a + b) % 24 << endl;
    return 0;
}

Measured memory_bytes: 3576
#coding utf-8
N=int(input())
a=list(map(int,input().split())) 
a=[0]+a
b=[0 for i in range(N+1)]
for i in range(N,0,-1):
  y=2
  tmp=0
  x=i*y
  while x<N+1:
    tmp+=b[x]
    y +=1
    x=i*y
  if tmp%2!=a[i]:
    b[i]=1
    
print(b.count(1))
indexes = [i for i,x in enumerate(b) if x==1]
indexes = map(str,indexes)
if b.count(1)!=0:
  print(' '.join(indexes))

Measured memory_bytes: 18988
# -*- coding: utf-8 -*-
"""
B - Collatz Problem
https://atcoder.jp/contests/abc116/tasks/abc116_b

"""
import sys


def solve(s):
    d = {s: s}
    ans = 1
    while True:
        ans += 1
        s = s/ 2 if s%2==0 else s*3+1
        if s in d:
            return ans
        d[s] = s


def main(args):
    s = int(input())
    ans = solve(s)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
//#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define P pair<int,int>
using namespace std;

int a[3];//n枚
double dp[301][301][301];//3枚　2枚　1枚
signed main() {

	int n; cin >> n;
	double ans = 0;
	for (int i = 0; i < n; i++) {
		int b; cin >> b;
		a[b - 1]++;
		ans += b;
	}
	
	dp[a[2]][a[1]][a[0]] = 1;
	for (int i = 300; i >= 0; i--) {
		for (int j = 300; j >= 0; j--) {
			for (int k = 300; k >= 0; k--) {
				if ((i || j || k)&&dp[i][j][k]!=0) {
					
					int u = i + j + k;
					if (i) {
						dp[i - 1][j + 1][k] += dp[i][j][k] * i / u;
					}
					if (j) {
						dp[i][j - 1][k + 1] += dp[i][j][k] * j / u;
					}
					if (k) {
						dp[i][j][k - 1] += dp[i][j][k] * k / u;
					}
					ans += double(n - u) / u*dp[i][j][k];
				}
			}
		}
	}
	printf("%.10lf\n", ans);
}

Measured memory_bytes: 213248
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		
		int c[]=new int[20];
		int cnt[]=new int[51];
		for(int i=0;i<10;i++)
			for(int j=0;j<10;j++)
				c[i+j]++;
		for(int i=0;i<20;i++)
			for(int j=0;j<20;j++)
			cnt[i+j]+=c[i]*c[j];
		while(in.hasNext())
		{
			int n=in.nextInt();
			System.out.println(cnt[n]);
		}
	}
	
	static public void debug(Object... o)
	{
		System.err.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 17216
#include<bits/stdc++.h>
using namespace std;
int main(){
    vector<int>v;
    int n,k;
    cin>>n>>k;
    while(n--){
    	int a;
    	cin>>a;
    	v.push_back(a);
	}
	sort(v.begin(),v.end());
	int ans=0;
	for(int i=0;i<k;i++){
		ans+=v[i];
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3644
def read_input():
    n, k = map(int, input().split())
    llist = list(map(int, input().split()))

    return n, k, llist

def submit():
    n, k, llist = read_input()
    llist.sort()
    print(sum(llist[-k:]))



if __name__ == '__main__':
    submit()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}

int main() {
  int n,m;
  while(cin >> m >> n && n) {
    string s[n];
    for(int i=0; i<n; i++) cin >> s[i];
    queue<P> que;
    bool u[n][m];
    memset(u,0,sizeof(u));
    for(int i=0; i<n; i++) {
      for(int j=0; j<m; j++) {
        if(s[i][j]=='@') {
          que.push(P(i,j));
          u[i][j]=1;
        }
      }
    }
    while(!que.empty()) {
      P p=que.front();que.pop();
      int xx=p.first,yy=p.second;
      for(int i=0; i<4; i++) {
        int x=xx+dx[i],y=yy+dy[i];
        if(!check(n,m,x,y)||u[x][y]||s[x][y]=='#') continue;
        u[x][y]=1;
        que.push(P(x,y));
      }
    }
    int ans=0;
    for(int i=0;i<n;i++)for(int j=0;j<m;j++)ans+=u[i][j];
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3016
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		int ans=0,n=1;
		while(n<s[1]){
			n+=s[0]-1;
			ans++;
		}
		Console.WriteLine("{0}",ans);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13268
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int a, b, c, k;

int main() {
    cin >> a >> b >> c >> k;
    ll ans;
    if(k>a){
        ans = a;
        k-=a;
        if(k>b){
            k-=b;
            ans-=k;
        }
    }else{
        ans = k;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
using namespace std;
bool comp(pair<int, int> a, pair<int, int> b){
    if(a.second == b.second)
        return a.first < b.first;
    return a.second < b.second;
}
int main() {
    int n;
    cin >> n;
    pair<int, int> p[n];
    for(int i = 0; i < n; i++)
        cin >> p[i].first >> p[i].second;
    sort(p, p + n, comp);
    int curr = 0;
    bool f = true;
    for(int i = 0; i < n && f; i++){
        curr += p[i].first;
        if(p[i].second < curr)
        f = false;
    }
    if(f)
    cout << "Yes";
    else
    cout << "No";
    return 0;
}

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


def solve(X: int, Y: int):
    res = 0
    i = X
    while i <= Y:
        res += 1
        i *= 2
    print(res)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(X, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
/*
    Problem 11
    https://atcoder.jp/contests/abc128/tasks/abc128_c
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> S(n);
    vector<int> p(m);
    for (int i = 0; i < m; i++) {
        int k; cin >> k;
        for (int j = 0; j < k; j++) {
            int s; cin >> s;
            S[s - 1].push_back(i);
        }
    }
    for (int i = 0; i < m; i++) cin >> p[i];

    int ans = 0;
    for (int b = 0; b < (1 << n); b++) {
        vector<int> cnt(m);
        for (int i = 0; i < n; i++) {
            if ((b >> i) & 1) {
                for (int s : S[i]) cnt[s]++;
            }
        }
        bool can = true;
        for (int j = 0; j < m; j++) if (cnt[j] % 2 != p[j]) can = false;
        if (can) ans++;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <string.h>

int main(void){
  int a,b;
  int t = 1;
  if(scanf("%d%d",&a,&b)==-1)
    return 0;
  char s[a+b+1];
  if(scanf("%s",s)==-1)
    return 0;


  for(int i=0;i<a+b+1;i++){
    if(i==a){
      if((int)s[i]!= 45){
	t = 0;
	break;
      }
    }else{
      if((int)s[i]<48||(int)s[i]>57){
	t = 0;
	break;
      }
    }
  }
  if(a<1||a>5)
    t = 0;
  if(b<1||b>5)
    t = 0;
  if(strlen(s)!=a+b+1)
    t = 0;
  if(t)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


Measured memory_bytes: 128
a,b,c = map(int, input().split())		# 5 7
k = int(input())

x = max(a,b,c)

y = x * (2**k)

if x==a:
	print(y+b+c)
	exit(0)
if x==b:
	print(a+y+c)
	exit(0)
if x==c:
	print(a+b+y)
	exit(0)



Measured memory_bytes: 3060
//Robs Code

/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <iomanip>

/***********MACROS***************/
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define pii pair<int,int>

using namespace std;

const int N = 1e5 + 1;
int n,m,i,j,k,l,x,y,z,cnt[3],sum[3];

/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	char ch;
	cin >> ch;
	if(ch >= 'a'){
		cout << "a";
	}else{
		cout << "A";
	}
}
//.........

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

int main(){
  ll n,d; cin >>n >>d;
  int cnt = 0;
  rep(i,n){
    ll a,b; cin >>a >>b;
    ll dist = a*a+b*b;
    if(dist<=d*d) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

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

#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(v) int(v.size())
#define pii pair<int, int>
#define mp make_pair
#define f first
#define ll long long
#define ld long double
#define s second
#define vec vector<int>

using namespace std;

const int N = (int) 3e5 + 10;
const int M = (int) 2018 * 2018;
const int K = (int) 15;
const int INF = (int) 1e9 + 7;
const int mod = (int) 998244353;
const ld EPS = (ld) 1e-9;
const ll LINF = (ll) 1e18;

int n, m;
int a[N], mt[N], cnt[N];
set<int> st;

void del(int x) {
	if (x - cnt[x] >= 0) {
		mt[x - cnt[x]]--;
		if (!mt[x - cnt[x]])
			st.erase(x - cnt[x]);
	}
	cnt[x]--;
}

void add(int x) {
	cnt[x]++;
	if (x - cnt[x] >= 0) {
		if (mt[x - cnt[x]] == 0)
			st.insert(x - cnt[x]);
		mt[x - cnt[x]]++;
	}
}

int main() {
	#ifdef sony
		freopen("input.txt", "r", stdin);
		freopen("output1.txt", "w", stdout);
	#endif
	srand(time(0));
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		add(a[i]);
	}
	while (m--) {
		int x, y;
		cin >> x >> y;
		del(a[x]);
		a[x] = y;
		add(a[x]);
		cout << n - sz(st) << endl;
	}
	return 0;	
}

Measured memory_bytes: 13184
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int N, K; cin >> N >> K;

	vector<int> l(N);
	REP(i,N) cin >> l[i];

	SORT(l);
	int ans = 0;
	for(int i=N-1;i>N-K-1;--i) ans += l[i];

	cout << ans << endl;


	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 2e5 + 1;
char s[maxN], t[maxN];

int main()
{
  while (scanf(" %s %s", s, t) != EOF)
  {
    int ans = 0;
    for (int i = 0; s[i]; i++)
      ans += s[i] != t[i];
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 4204
k = int(input())

"""
memo = [[-1 for i in range(k+1)] for j in range(k+1)]
def gcd(a, b):
    if b == 0:
        return a
    else:
        if memo[a][b] == -1:
            memo[a][b] = gcd(b, a % b)
        return memo[a][b]
"""

def my_gcd(a, b):
    if a < b: a, b = b, a
    c = a % b
    if c == 0: return b
    while c!=0:
        c = a % b
        a = b
        b = c
    return a

ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        t = my_gcd(a, b)
        for c in range(1, k+1):
            ans += my_gcd(t, c)
print(ans)


Measured memory_bytes: 9104
#include <algorithm>
#include <bitset>
#include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <vector>
#include <numeric>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPC(i, a) REP(i, 0, a)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr int I_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
  // INFILE();
	string s;
	cin >> s >> s;
	cout << "A" << s[0] << "C\n";
  return 0;
}

template <class T> static void scan(vector<T> &v) {
  map<type_index, const char *const> m = {{typeid(int), "%d"},
                                          {typeid(ll), "%lld"},
                                          {typeid(double), "%lf"},
                                          {typeid(char), "%c"}};

  auto tFormat = m[typeid(T)];

  for (T &n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string> &v, bool isWord) {
  if (isWord) {
    for (auto &n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

static boost::dynamic_bitset<> scan(char trueValue) {
  string s;
  getline(cin, s);

  if (s.size() == 0) {
    getline(cin, s);
  }

  for_each(begin(s), end(s),
           [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
  return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<set>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
#include <iterator>     // std::back_inserter
const double PI = acos(-1);
using namespace std;
using ll =long long;
#define rep(i,n)for(ll i=0;i<(n);i++)
const int mod = 1000000007;
const ll inf = 1e18 + 1;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

/*�R���r�l�[�V����*/

//ll f[101010], rf[101010];
//ll inv(ll x) {
//	ll res = 1;
//	ll k = mod - 2;
//	ll y = x;
//	while (k) {
//		if (k & 1) res = (res * y) % mod;
//		y = (y * y) % mod;
//		k /= 2;
//	}
//	return res;
//}
//void init() {
//	f[0] = 1;
//	for (ll i = 1; i < 101010;i++) f[i] = (f[i - 1] * i) % mod;
//	for(ll i = 0; i < 101010; i++) rf[i] = inv(f[i]);
//}
////---------------------------------------------------------------------------------------------------
//ll C(int n, int k) {
//	ll a = f[n]; // = n!
//	ll b = rf[n - k]; // = (n-k)!
//	ll c = rf[k]; // = k!
//
//	ll bc = (b * c) % mod;
//
//	return (a * bc) % mod;
//}

///*�R���r�l�[�V����*/
//
///*Union Find*/
//#define MAX_N 200000
//#define MAX_M 200000
//vector<ll>par(MAX_N);
//vector<ll>ran(MAX_N);
//void init(ll N) {
//	rep(i, N) {
//		par[i] = i;
//		ran[i] = 0;
//	}
//}
//ll find(ll x) {
//	if (par[x] == x) {
//		return x;
//	}
//	else {
//		return par[x] = find(par[x]);
//	}
//}
////x��y�̑�����W���𕹍�
//void unite(ll x,ll y) {
//	x = find(x);
//	y = find(y);
//	if (x == y)return;
//	if (ran[x] < ran[y]) {
//		par[x] = y;
//
//	}
//	else {
//		par[y] = x;
//		if (ran[x] == ran[y])ran[x]++;
//	}
//}
//bool same(ll x, ll y) {
//	return find(x) == find(y);
//}
///*Union Find*/
///������=�啶��+32

	
int main() {
	string S = "ACL";
	int N;
	cin >> N;
	rep(i, N) {
		cout << S;
	}

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using Graph = vector<vector<int>>;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;

int main (){
  int N;
  cin>>N;
  if(N>=30)cout<<"Yes";
  else cout<<"No";
}


Measured memory_bytes: 3524
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 2000000;
const int inf = 1000000007;
const ll mod = 1000000007;
const ll longinf = 1LL << 60;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
 
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
 
 
 
int n, ans;
int a[2][100005];
 
int main() {
 
	cin >> n;
 
	rep(i, 2) {
		rrep(j, n) {
			int tmp;
			cin >> tmp;
			a[i][j] = a[i][j - 1] + tmp;
		}
	}
 
	rrep(i, n) {
		ans = max(ans, a[0][i] + (a[1][n] - a[1][i - 1]));
	}
 
	cout << ans << endl;
 int justin = 9;
	return 0;
}
//.....

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    S = Scanner.string()
    ans = INF
    for c in string.ascii_lowercase:
        T = S
        N = len(T)
        cnt = 0
        while T.count(c) != N:
            N -= 1
            U = [""] * (N)
            for i in range(N):
                U[i] = T[i]
                if T[i+1] == c:
                    U[i] = T[i+1]
            T = U
            cnt += 1
        ans = min(ans, cnt)
    print(ans)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 40428
n = int(input())
p = list(map(float,input().split()))

dp = [[0.0]*(n+1) for _ in range(n+1)]
dp[0][0] = 1.0

for i in range(n):
    for j in range(n):
        dp[i+1][j+1] += dp[i][j] * p[i]
        dp[i+1][j]   += dp[i][j] * (1 - p[i])
print(sum(dp[n][n//2 + 1:]))


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

int main(){
  ll a, b, c, d;
  scanf("%lld%lld.%lld", &a, &b, &c);
  d = a * (b * 100 + c) / 100;
  cout << d << endl;
  return 0;
}


Measured memory_bytes: 3716
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	string s,l,r;
	vector<string>temp(100);
	int n,count, ans=0;
	cin >> n>>s;
	for (int i = 1; i < n; i++) {
		//l = s.substr(0, i);
		//r = s.substr(i, n - i);

		set<char> x;
		for (int j = 0; j < i; j++) {
			x.insert(s[j]);
		}
		set<char> y;
		for (int j = i; j < n; j++) {
			y.insert(s[j]);
		}

		count = 0;

		for (auto i : x) {
			if (y.find(i) != y.end())count++;
		}
		ans = max(ans, count);
		 
	}

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int x = n / 2;
    if(n & 1) x++;
    cout<<x<<endl;
    return 0;
    
}



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

int main(){
  int a,b,ans;
  char op;

  while(true){
    cin >> a >> op >> b;

    if(op=='?'){
      break;
    }

    if(op=='+'){
      ans=a+b;
      cout << ans << '\n';
    }
    else if(op=='-'){
      ans=a-b;
      cout << ans << '\n';
    }
    else if(op=='*'){
      ans=a*b;
      cout << ans << '\n';
    }
    else if(op=='/'){
      ans=a/b;
      cout << ans << '\n';
    }
  }

  return 0;
}


Measured memory_bytes: 3104
n = int(input())
stock_price = [int(i) for i in input().split()]
stock_num = 0
money = 1000

for i in range(n - 1):
    if stock_price[i] < stock_price[i + 1]:
        num = money // stock_price[i]
        money -= num * stock_price[i]
        stock_num += num
    
    if stock_price[i] > stock_price[i + 1]:
        money += stock_num * stock_price[i]
        stock_num = 0

money += stock_num * stock_price[i + 1]

print(money)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pii pair<int,int>
#define MP make_pair
#define F first
#define S second
#define mod 1000000007

ll mp[10][10];

void f( int n ){
    
    vector<int>v;
    while( n>0 ){
        v.pb(n%10);
        n = n/10;
    }
    
    int n1,x,y;
    n1 = v.size();
    x = v[0]; y = v[n1-1];
    
    mp[x][y]++;
}


int main() {
flash;
    
    ll n; cin>>n;
    for(int i=1;i<=n;i++){ f(i); }
    
    ll ans = 0,x;
    
    for(int i=1;i<=9;i++){
        for(int j=i+1;j<=9;j++){
            ans += 2*mp[i][j]*mp[j][i];
        }
    }
    
    for(int i=1;i<=9;i++){
        x = mp[i][i];
        ans += x*x ;
    }
    
    cout<<ans;
    
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define lf long double
#define F first
#define S second
typedef vector <ll> vi;
typedef pair <ll,ll> ii;
typedef vector <pair <ll,ll> >vii;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
#define mod 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll x,a;
    cin>>x>>a;
    if(x<a)
        cout<<0<<endl;
    else
        cout<<10<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
 
ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 
ll i,j,k,ii,jj;
ll n,m,sum,num;
ll ans;
ll a,b,c,d,e,h,w;
 
ll x[500005];

int main(){
    cin>>n;
	for(i=0;i<n;i++){
		cin>>x[i];
	}
	ll start=0,end=0,sumxor=0,sum=0;
	while(true){
		while(end<n && (sumxor^x[end])==sum+x[end]){			
			sumxor = (sumxor^x[end]);
			sum += x[end];
			end++;
		}

		//pe(start);p(end);

		ans += (end-start);

		if(start==n && end==n)break;

		sumxor ^= x[start];
		sum -= x[start];
		start++;
	}

	p(ans);
	
	return 0;
}

Measured memory_bytes: 8320
# coding: utf-8

n=int(input())
A=list(map(int,input().split()))

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    return gcd(b, a%b)

L = [0]
R = [0]

for i in range(n):
    L.append(gcd(L[i], A[i]))
    R.append(gcd(R[i], A[n-1-i]))
R.reverse()

result = []

for i in range(n):
    result.append(gcd(L[i], R[i+1])) 

print(max(result))




Measured memory_bytes: 14060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var a = sc.nextLong();
		var b = sc.nextLong();
		var n = sc.nextLong();
		sc.close();

		var x = Math.min(n, b - 1);
		var value = (long) Math.floor(a * x / b) - a * (long) Math.floor(x / b);
		System.out.println(value);
	}
}

Measured memory_bytes: 35732
#include <stdio.h>
#define MAX 100
#define NIL -1

struct Node {int p, l, r;};
struct Node T[MAX];
int n;

void preParse(int u)
{
  if (u == NIL)
    return;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u)
{
  if (u == NIL)
    return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}

void postParse(int u)
{
  if (u == NIL)
    return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

int main(void)
{
  int id, l, r, root, i;
  
  scanf("%d", &n);
  
  for (i = 0; i < n; i++)
    T[i].p = NIL;
  
  for (i = 0; i < n; i++) {
    scanf("%d%d%d", &id, &l, &r);
    T[id].l = l;
    T[id].r = r;
    if (l != NIL) T[l].p = id;
    if (r != NIL) T[r].p = id;
  }
  
  for (i = 0; i < n; i++)
    if (T[i].p == NIL)
      root = i;
  
  puts("Preorder");
  preParse(root);
  putchar('\n');
  puts("Inorder");
  inParse(root);
  putchar('\n');
  puts("Postorder");
  postParse(root);
  putchar('\n');
  
  return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using Pint = pair<int, int>;
const ll mod = 1e9+7;

int main(int argc, char const* argv[])
{
  int n, m;
  cin>>n>>m;
  string ans = n==m ? "Yes" : "No";
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define clr(a, x) memset(a, x, sizeof(a))
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define X first
#define Y second
#define fastin                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-6;

int main()
{
#ifndef ONLINE_JUDGE
    // freopen("1.in", "r", stdin);
    // freopen("1.out", "w", stdout);
#endif
    string s;
    while (cin >> s)
    {
        int cnt = 0;
        for (auto t : s)
            if (t == '1') cnt++;
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=300 +117;
const int MM= +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int m,n;
LL dp[2][NN][NN]={};
LL a[NN]={};
LL b[NN]={};
LL fact[NN]={};
LL rev[NN]={};
const int mod=998244353;
LL ksm(LL a,LL b){
	LL ret=1;
	for(;b;b>>=1,a=a*a%mod){
		if(b&1)ret=ret*a%mod;
	}
	return ret;
}
void getfact(int n){
	fact[0]=1;
	for(int i=1;i<=n;++i)fact[i]=fact[i-1]*i%mod;
	rev[n]=ksm(fact[n],mod-2);
	for(int i=n;i>=1;--i)rev[i-1]=rev[i]*i%mod;
}
void upd(LL &a,LL b){
	a=(a+b)%mod;
}
int main(){
	//open();
	n=read();
	int s=0;
	for(int i=1;i<=n;++i){
		a[i]=read();
		b[i]=read();
		s+=b[i];
	}
	getfact(s);
	int now=0;
	dp[now][0][0]=-1;
	int suma=0,sumb=0;
	for(int x=1;x<=n;++x){
		now^=1;
		for(int i=0;i<=suma+a[x];++i){
			for(int j=0;j<=sumb+b[x];++j){
				dp[now][i][j]=0;
			}
		}
		for(int i=0;i<=suma;++i){
			for(int j=0;j<=sumb;++j){
				upd(dp[now][i][j],dp[now^1][i][j]);
				LL mi=1;
				for(int k=0;k<b[x];++k,mi=mi*a[x]%mod){
					upd(dp[now][i+a[x]][j+k],-dp[now^1][i][j]*rev[k]%mod*mi);
				}
			}
		}
		suma+=a[x],sumb+=b[x];
	}
	LL ans=0;
	for(int i=1;i<=suma;++i){
		LL di=ksm(i,mod-2);
		LL mi=di;
		for(int j=0;j<=sumb;++j,mi=mi*di%mod){
			ans+=dp[now][i][j]*mi%mod*suma%mod*fact[j];
			ans%=mod;
		}
	}
	ans=(ans+mod)%mod;
	printf("%lld\n",ans);
	close();
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int a[n], val, ans = 0;
  for ( int i = 0; i < n; i++){
    cin >> a[i];
    val = a[i];
    while(val % 2 == 0){
      val = val/2;
      ans ++;
    }
  }

  cout << ans << endl;

  return 0;
}

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

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

int main()
{
    int N, A, B;
    int c1 = 0, c2 = 0, c3 = 0;
    int t;

    cin >> N >> A >> B;
    for(int i = 1; i <= N; i++) {
        cin >> t;
        if(t <= A) {
            c1++;
        } else if(t <= B) {
            c2++;
        } else {
            c3++;
        }
    }
    cout << min(c1, min(c2, c3)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[505][505];
vector<int>ans;
int main()
{
    int h,w;
    scanf("%d%d",&h,&w);
    for(int i=1;i<=h;i++)
    	for(int j=1;j<=w;j++)
    		scanf("%d",&a[i][j]);
    for(int i=1;i<h;i++)
    {
    	for(int j=1;j<=w;j++)
    	{
    		if(a[i][j]%2)
    		{
    			ans.push_back(i);
    			ans.push_back(j);
    			ans.push_back(i+1);
    			ans.push_back(j);
    			a[i+1][j]++;
			}
		}
	}
	for(int i=1;i<w;i++)
	{
		if(a[h][i]%2)
		{
			ans.push_back(h);
			ans.push_back(i);
			ans.push_back(h);
			ans.push_back(i+1);
			a[h][i+1]++;
		}
	}
	printf("%d\n",ans.size()/4);
	for(int i=0;i<ans.size();i+=4)
		printf("%d %d %d %d\n",ans[i],ans[i+1],ans[i+2],ans[i+3]);
	return 0;
}


Measured memory_bytes: 5232