akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := newIo()
	defer io.Flush()
	N := io.NextInt()
	fmt.Println(calc(N))
}

func calc(n int) string {
	log("n", n)
	if n == 0 {
		return "0"
	}
	if n == 1 {
		return "1"
	}
	i := 0
	plusSum := 0
	minusSum := 0
	for {
		x := int(math.Pow(-2, float64(i)))
		if x > 0 {
			plusSum += x
		} else {
			minusSum += x
		}
		result := ""
		if n < 0 && x < 0 && minusSum <= n {
			nokori := calc(n - x)
			result += "1"
			for j := 0; j < i-len(nokori); j++ {
				result += "0"
			}
			return result + nokori
		}
		if n > 0 && x > 0 && plusSum >= n {
			nokori := calc(n - x)
			result += "1"
			for j := 0; j < i-len(nokori); j++ {
				result += "0"
			}
			return result + nokori
		}
		i++
	}

}

type io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func newIo() *io {
	return &io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}


Measured memory_bytes: 640
n,m = map(int,input().split())
l = []
for i in range(1 << n):
    tmp = str(bin(i))[2:]
    l.append(tmp.zfill(n))
K = [list(map(int,input().split())) for _ in range(m)]
P = list(map(int,input().split()))
#print(P)
ans = 0
#print("----")
for i in range(len(l)):
    #スイッチの状態l[i]
    #付いている電球のリストO
    O = []
    for j in range(m):
        #電球のきになるすいっちの数K[j][0]
        ON = 0
        for ii in range(K[j][0]): #スイッチのリスト
            if l[i][K[j][ii+1] - 1] == "1":
                ON += 1
        if ON % 2 == P[j]:
            O.append(1)
        else:
            O.append(0)
    if sum(O) == m:
        #print(l[i])
        ans += 1
print(ans)



Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
ll powmod(ll x, ll y) {
  ll res = 1;
  for (ll i = 0; i < y; i++) {
    res = (res * x) % mod;
  }
  return res;
}
int main() {
  int n;
  cin >> n;
  ll ans = powmod(10, n) - 2 * powmod(9, n) + powmod(8, n);
  ans = ans % mod;
  ans = (ans + mod) % mod;
  cout << ans << endl;
  return 0;
}


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

using namespace std;

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

   int xx=0, mx=-1;
   for(char x: s){
        if(x=='R') xx++;
        else { xx=0;}
        mx=max(mx, xx);
   }
   cout<<(mx ==-1 ? 0 : mx);
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>
#define SIZE 50001

int *prime, size;
int *sum;

void init();
int goldbach(int n);
int isPrime(int n);

int main(int argc, const char *argv[])
{
	int n = 1;
	init();

	while(scanf("%d", &n)!=EOF && n!=0)
		printf("%d\n", goldbach(n));

	free(prime);
	free(sum);
	return 0;
}

void init()
{
	int i=1, j, n;
	prime = malloc(sizeof(int));

	*prime = 2;
	for(n=3 ; n<SIZE; n+=2){
		if(isPrime(n)){
			prime = realloc(prime, sizeof(int)*(i+1));
			*(prime+(i++)) = n;
		}
	}
	size = i;

	sum = malloc(sizeof(int)*SIZE);
	for(i=0; i<size; i++){
		for(j=i; j<size; j++){
			if(prime[i]+prime[j]>=SIZE) j=size;
			else sum[prime[i]+prime[j]]++;
		}	
	}	
}

int goldbach(int n)
{
	return sum[n];
}

int isPrime(int n)
{
	int i;
	if(n<=1) return 0;
	else if(n==2) return 1;
	else if(n%2==0) return 0;
	else
	 	for(i=3; i*i<=n; i++)
			if(n%i==0) return 0;
	return 1;	
}

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

int main(){
  long long int x,k,d;
  cin >> x >> k >> d;
  long long int ans;
  
  long long int count;
  count = abs(x)/d; //count回移動させると次に符号が変わる
  if(x>0){
    if(count >= k){ //符号変わらない場合
      ans = x - k*d;
    }else{ //符号が途中で切り替わる(+ to -)
      if((k - count)%2==0){
        ans = x -count*d;
      }else{
        ans = abs(x - count*d -d);
      }
    }
  }else if(x < 0){
    if(count >= k){
      ans = abs(x + k*d);
    }else{
      if((k - count)%2==0){
        ans = abs(x +count*d);
      }else{
        ans = x + count*d + d;
      }
    }
  }else{
    if(k%2==0){
      ans = x;
    }else{
      ans = d;
    }
  }

  cout << ans << endl;

}


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

int a[14],b[55],n,f;
void dfs(int s,int k){
  if(f)return;
  if(!s) {
    f=1;
    for(int i=n-1;i>=0;i--) {
      if(i<n-1)cout<<" ";
      cout<<b[i];
    }
    cout<<endl;
    return;
  }
  for(int i=1;i<14;i++) {
    if(a[i]&&(s-i)%i==0) {
      a[i]--;
      b[k]=i;
      dfs(s-i,k+1);
      a[i]++;
    }
  }
}
int main() {
  while(cin>>n&&n){
    memset(a,0,sizeof(a));
    int s=0;
    for(int i=0,x;i<n;i++){
      cin>>x;
      a[x]++;
      s+=x;
    }
    f=0;
    dfs(s,0);
    if(!f)cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define FOR(i,a,b) for (register ll i=(a);i<=(b);i++)
#define For(i,a,b) for (register ll i=(a);i>=(b);i--)
#define mem(i,j) memset(i,j,sizeof(i))
using namespace std;
typedef long long ll;
const ll N=2e5+5;
ll n,E,T,x[N],f[N],Ans,k=1e18;
ll l=1,r=1,q[N];
ll read()
{
	ll x=0,f=1;
	char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') {x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return f*x;
}
int main()
{
	mem(f,0x3f);
	n=read(),E=read(),T=read();
	FOR(i,1,n) x[i]=read();
	f[0]=0;
	FOR(i,1,n)
	{
		while (l<=r&&2*(x[i]-x[q[l]+1])>T)
		{
			k=min(k,f[q[l]]-2*x[q[l]+1]);
			l++;
		}
		f[i]=min(f[i],f[q[l]]+T);
		f[i]=min(f[i],k+2*x[i]);
	//	while (l<=r&&f[q[l]]-x[q[l]]>=f[i]-x[i]) r--;
		q[++r]=i;
	}
	Ans=f[n]+E;
	printf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 3584
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	ll N=in<ll>();
	ll M=(N/11LL)*2LL;
	ll S=N%11LL;
	if(S>0 && S<=6) M++;
	else if(S>6)M+=2;
	out(M);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;



public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for(int i=0;i<n;i++) {
			arr[i] = sc.nextInt();
		}
		n = 0;
		int min;
		for(int i=0;i<arr.length-1;i++) {
			min = i;
			for(int j=i+1;j<arr.length;j++) {
				if(arr[min]>arr[j]) {
					min = j;
				}
			}
			if(min > i) {
				int temp = arr[i];
				arr[i] = arr[min];
				arr[min] = temp;
				n++;
			}
		}
		for(int i=0;i<arr.length;i++) {
			if(i+1==arr.length) {
				System.out.println(arr[i]);
			}else {
				System.out.print(arr[i]+" ");
			}
		}
		System.out.println(n);
	}
}
		


Measured memory_bytes: 26500
#include<bits/stdc++.h>
using namespace std;
#define ft first
#define sd second
using ll = long long;
const int INF = 1e9+7;
const int EPS = -1e6;
const int maxn = 5000+5;

int main(){
    //freopen("input.txt", "r", stdin);
    int N;
    int cnt = 0;
    cin>> N;
    for(int i = 1; i <= N; ++i){
        if(i&1)
            cnt++;
    }
    cout<<cnt*1.0/N;
    return 0;
}



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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

int main(void){
	int n;
	cin >> n;
	
	vector<int> a(n), b(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];

	const int thr = (n + 1) / 2;

	int base = 0;
	rep(i, n) if(i % 2) base |= (1 << i);

	using state = tuple<int, int, int>;
	using pii = pair<int, int>;

	const int inf = 1 << 20;
	int ans = inf;

	rep(mask, 1 << n){
		const int cur_mask = base ^ mask;
		if(__builtin_popcount(cur_mask) != n - thr) continue;
		
		vector<state> tmp;
		rep(i, n) {
			const int parity = (cur_mask >> i) & 1;
			
			if((mask >> i) & 1) {
				tmp.push_back(state(parity, b[i], i));
			} else {
				tmp.push_back(state(parity, a[i], i));
			}
		}

		sort(begin(tmp), end(tmp));
		
		bool ok = true;
		vector<pii> ary;
		
		rep(i, n) {
			const int pos = (i % 2) ? (i / 2) + thr : (i / 2); 
			int val, idx;
			tie(ignore, val, idx) = tmp[pos];
			ary.push_back(pii(val, idx));
		}

		rep(i, n - 1) {
			if(ary[i].first > ary[i + 1].first) {
				ok = false;
			}
		}

		if(ok == false) continue;

		int num = 0;
		vector<int> base_ary(n);
		iota(begin(base_ary), end(base_ary), 0);

		rep(i, n) {
			int tar = i;
			
			rep(j, i + 1, n) {
				if(ary[i].second == base_ary[j]) {
					tar = j;
				}
			}

			while(tar > i) {
				swap(base_ary[tar - 1], base_ary[tar]);
				num++, tar--;
			}
		}

		chmin(ans, num);
	}

	if (ans == inf) {
		ans = -1;
	}

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

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

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

    char c;
    bool f = true;
    map<string, int> mp;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        mp[s]++;
        if (i) {
            f &= c == s[0];
        }
        c = *s.rbegin();
    }
    
    for (auto x : mp) {
        f &= x.second < 2;
    }

    cout << (f ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
edge = []
for i in range(M):
    a, b, c = map(int, input().split())
    edge.append([a, b, c*-1])
d = [float('inf')] * (N+1)
d[1] = 0

for i in range(1, N+1):
    for e in edge:
        if (d[e[0]] != float('inf')) & (d[e[1]] > d[e[0]] + e[2]):
            d[e[1]] = d[e[0]] + e[2]
            update = True
            if (i == N) & (e[1] == N):
                print('inf')
                exit()

print(d[N]*-1)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int w,n,a,b;
    char c;
    std::deque<int> deq;
    cin >> w;
    for (int i=1;i<w+1;i++) {
        deq[i]=i;
    }
    cin >> n;
    for (int j=0;j<n;j++) {
        cin >> a >> c >> b;
        /*
        int a = x.at(0)-48;
        int b = x.at(2)-48;
        int tmp = deq[b];
        deq[b] = deq[a];
        deq[a] = tmp;*/
        swap(deq[a],deq[b]);
    }
    for (int k=1;k<w+1;k++) {
        cout << deq[k] << endl;
    }
    deq.clear();
}



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



using namespace std;

typedef long long lint;

void test_case() {
    long long a;
    long double b;
    cin >> a >> b;
    cout << (long long) (1.*a*b) << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int q=1;
    //cin >> q;
    while(q--) {
        test_case();
    }
    return 0;
}


Measured memory_bytes: 3744
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/
fun main(args: Array<String>) {
    var N = readLine()!!.toInt()
    var S = readLine()!!

    var pre = ""
    var cnt = 0
    S.forEach {
        cnt += if(it == '(') 1 else -1
        if(cnt < 0) {
            pre += "("
            cnt++
        }
    }
    var post = ""
    for(i in 0 until cnt) post += ")"

    println(pre + S + post)
}

Measured memory_bytes: 33692
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;


#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
#define MUL(a,b) a=(a*b)%mod


bool Solve(){
    ll N; cin>>N;
    priority_queue<P> X,Y;
    ll Count=0;
    rep(i,N){
        string S; cin>>S;
        ll C=0, a=0;
        rep(j,S.size()){
            if(S[j]=='(') C++;
            else C--;
            a=min(a,C);
        }
        Count+=C;
        if(C>=0) X.push(mp(a,C));
        else{
            C=0; a=0;
            for(int j=S.size()-1; j>=0; j--){
                if(S[j]==')') C++;
                else C--;
                a=min(a,C);
            }
            Y.push(mp(a,C));
        }
    }
    if(Count) return false;
    ll f=0;
    while(!X.empty()){
        ll a=X.top().first, C=X.top().second;
        X.pop();
        if(a+f<0) return false;
        f+=C;
    }
    f=0;
    while(!Y.empty()){
        ll a=Y.top().first, C=Y.top().second;
        Y.pop();
        if(a+f<0) return false;
        f+=C;
    }
    return true;
}
int main(){
    if(Solve()) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    int x[N],y[M];
    for (int i=0; i<N; i++) {
        cin >> x[i];
    }
    for (int i=0; i<M; i++) {
        cin >> y[i];
    }
    bool flag = false;
    int count,count1;
    for (int Z=X+1; Z<=Y; Z++) {
        count=0;
        count1=0;
        for (int i=0; i<N; i++) {
            if (x[i]<Z) {
                count++;
            }
        }
        for (int i=0; i<M; i++) {
            if (y[i]>=Z) {
                count1++;
            }
        }
        if (count==N && count1==M) {
            flag = true;
            break;
        }
    }
    if (flag) {
        cout << "No War" << endl;
    }
    else cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())

a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse=True)
l = 0
r = max(a) * max(f)

def check(x):
    tot = 0
    for i in range(n):
        need = a[i] - x // f[i]
        tot += need if need >= 0 else 0
    return tot <= k


while l < r:
    m = (l + r) // 2
    if check(m):
        r = m
    else:
        l = m+1

print(r)


Measured memory_bytes: 119884
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>

using namespace std;

typedef long long ll;

int charToInt(char ch){
  if(ch>='0'&&ch<='9')return ch-'0';
  return ch-'a'+10;
}
int intToChar(int a){
  if(a>=0&&a<=9)return a+'0';
  return a-10+'a';
}

int main(){
  int n;
  ll nums[9];
  cin>>n;
  for(int i=0;i<n;i++){
    ll res=0;
    memset(nums,0,sizeof(nums));
    for(int j=0;j<9;j++){
      string s;
      cin>>s;
      for(int k=s.size()-1;k>=0;k--){
  	int a=charToInt(s[k]);
  	int pos=s.size()-1-k;
  	for(int l=0;l<4;l++){
  	  if((a>>l)&1){
  	    nums[j]|=(1LL<<(l+pos*4));
  	  }
  	}
      }
    }
    for(int k=0;k<32;k++){
      ll tgt=0;
      for(int j=0;j<8;j++){
	tgt+=res^nums[j];
    	//tgt+=(nums[j]%2);
    	//tgt%=(1LL<<32);
    	//nums[j]=nums[j]>>1;
      }
      //int sum=(tgt>>k)&1;
      int sum=(tgt>>k)&1;
      if(sum!=((nums[8]>>k)&1))res|=(1LL<<k);
    }
    string ans;
    for(int k=0;k<32;k+=4){
      int cur=((res>>k)&15);
      char ch=intToChar(cur);
      ans=ch+ans;
    }
    for(int k=0;k<ans.size();k++){
      if(ans[k]!='0'||k==ans.size()-1){
    	ans=ans.substr(k);
    	break;
      }
    }
    cout<<ans<<endl;
  }

  return 0;
}

Measured memory_bytes: 0
import sys

def biscuit(N, P, As):
    n_even = 0
    n_odd = 0
    for a in As:
      if int(a) % 2 == 0:
        n_even += 1
      else:
        n_odd +=1
    v = 2**n_even
    #print(n_even, n_odd)
    if n_odd == 0:
      v *= (0 if int(P) == 1 else 1)
    else:
      v *= 2**(n_odd -1)
    return v

N, P = sys.stdin.readline().strip().split()
As = sys.stdin.readline().strip().split()
print(biscuit(N, P, As))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
typedef pair<int,int>pii;

char g[22][22];
int dis[22 * 22][22 * 22];
int dx[] = {1,-1,0,0}, dy[] = {0,0,1,-1};
int n,m;

int get_id(int i,int j)
{
	return i * m + j;
}

void bfs(int i, int j)
{
	int u = get_id(i,j);
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++){
			dis[u][get_id(i,j)] = INT_MAX;
		}
	}

	if(g[i][j] == '#') return;
	queue<int>q;
	q.push(u);
	dis[u][u] = 0;
	while(!q.empty()){
		int v = q.front();
		q.pop();
		int x = v / m, y = v % m;
		//cout << x << " " << y << endl;
			for(int i = 0; i < 4; i++) {
			int nx = x + dx[i], ny = y + dy[i];
			int nv = get_id(nx,ny);
			//cout << nx << ' ' << ny << " " << nv << endl;
			if(nx < 0 || nx >= n || ny < 0 || ny >= m || g[nx][ny] == '#' || nv < 0 || nv >= n * m || dis[u][nv] != INT_MAX) continue;
			q.push(nv);
			dis[u][nv] = dis[u][v] + 1;
		}
	}
	//cout << 1 << endl;
}

int main()
{
	
	std::ios::sync_with_stdio(false);cin.tie(0);
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> g[i][j];
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			bfs(i,j);
		}
	}
	int ans = 0;
	for(int i = 0; i < n * m; i++){
		for(int j = 0; j < n * m; j++){
			if(dis[i][j] != INT_MAX) ans = max(ans,dis[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<bits/stdc++.h>
#define fi first
#define sc second
#define pb push_back
#define mp make_pair
using namespace std;
 
typedef pair<int, int> pi;

 
int main() {   

	int A, B, C, X, ans = 0;
	cin >> A >> B >> C >> X;
	for (int i = 0; i <= A; i++) {
		for (int j = 0; j <= B; j++) {
			for (int k = 0; k <= C; k++) {
				if (i * 500 + j * 100 + k * 50 == X) ans ++;
			}
		}
	}
	cout << ans ;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a,b=map(int,input().split())
p=list(map(int,input().split()))
e,m,d=0,0,0
for x in p:
    if x<=a:e+=1
    if a<x<=b:m+=1
    if b<x:d+=1
print(min(e,m,d))

Measured memory_bytes: 9092
#include<bits/stdc++.h>
using namespace std;
int dp[2][100][4], k;
char s[101];
int main()
{
    scanf(" %s", s + 1); int len = strlen(s + 1);
    scanf("%d", &k);
    dp[1][0][0] = 1;
    for (int i = 1, c; i <= len; i++)
    {
        c = s[i] - '0';
        for (int j = 0; j <= k; j++)
        {
            dp[0][i][j] = dp[0][i - 1][j];
            if (c) dp[0][i][j] += dp[1][i - 1][j];
            if (j) dp[0][i][j] += dp[0][i - 1][j - 1] * 9 + dp[1][i - 1][j - 1] * max(0, c - 1);
            if (j || !c) dp[1][i][j] = dp[1][i - 1][j - (c > 0)]; 
        }
    }
    printf("%d\n", dp[0][len][k] + dp[1][len][k]);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int main() {
	int R, K;
	cin >> R >> K;
	if (R <= 10) K += 100 * (10 - R);
	cout << K << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        int a = int.Parse(ReadLine());
//        string b = ReadLine();
        string[] c = ReadLine().Split(' ');
        int cl = c.Length;
        int[] d = new int[c.Length];
        string ans = "APPROVED";
        
        for(int i=0;i<a;i++){
            int b = int.Parse(c[i]);
            if(b %2==0 && (b%3==0 || b%5==0)){
                
            }else if(b%2 == 0){
                ans = "DENIED";
            }
        }
        WriteLine(ans);
        
    }
}


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

typedef long long ll;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const ll MOD = 1e9 + 7 ;
const double PI = 2 * acos(0.0) ;

int main()
{
    set <char> st ;
    string s ;
    cin >> s ;
    for (int i = 0; i < 3; i++) {
        st.insert(s[i]) ;
    }
    if (st.size() == 1) cout << "No" ;
    else    cout << "Yes" ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll n;
  cin>>n;
  ll a[n];
  for(ll i=0;i<n;i++)
    cin>>a[i];
  sort(a,a+n);
  cout<<a[n/2]-a[n/2-1];
	return 0;
}

Measured memory_bytes: 1024
N,M,K=map(int,input().split())

par=[-1]*N
num=[0]*N

def find(x):
    if par[x-1]<0:
        return x
    else:
        par[x-1]=find(par[x-1])
        return par[x-1]

def union(x,y):
    p,q=find(x),find(y)
    if p==q:
        return
    if p>q:
        p,q=q,p
    par[p-1]+=par[q-1]
    par[q-1]=p   

def size(x):
    return -par[find(x)-1]

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

for _ in range(M):
    a,b=map(int,input().split())
    union(a,b)
    num[a-1]+=1
    num[b-1]+=1

for _ in range(K):
    c,d=map(int,input().split())
    if same(c,d):
        num[c-1]+=1
        num[d-1]+=1

for i in range(N):
    print(size(i+1)-1-num[i],end=" ")

Measured memory_bytes: 6428
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define DEBUG(x)           cout << '>' << #x << ':' << x << endl;
#define forn(i,n)          for(int i=0;i<(int)n;++i)
#define for1(i,n)          for(int i=1;i<=(int)n;++i)
#define forr(i,n)          for(int i=(int)n-1;i>=0;--i)
#define forre(i,a,b)       for(int i=(int)b;i>=(int)a;--i)
#define fore(i,a,b)        for(int i=(int)a;i<=(int)b;++i)
#define input(arr,n)       for(int i=0;i<n;i++)cin>>arr[i]
#define output(arr,n)      for(int i=0;i<n;i++)cout<<arr[i]<<" "
#define for_each(arr)      for(auto& it:arr)cout<<it<<" "
#define ff                 first
#define ss                 second
#define PI                 acos(-1.0)
#define all(a)             a.begin(),a.end()
#define rall(a)            a.rbegin(),a.rend()
#define Unique(a)          sort(all(a)),a.erase(unique(all(a)),a.end())
#define pb(x)              push_back(x)
#define eb(x)              emplace_back(x) 
#define ppb(x)             pop_back(x)
#define pf(x)              push_front(x)
#define ppf(x)             pop_front(x)
#define in(x,y)            insert({x,y})
#define Sort(a)            sort(a.begin(),a.end())
#define mem(arr,a)         memset(arr,a,sizeof arr)
#define ins(a)             insert(a)
#define max2(a,b)          max(a,b)
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max3(b,c,d))
#define min2(a,b)          min(a,b)
#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min3(b,c,d))
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<char> vc;
typedef vector<double> vd;
/*inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void Set(int & n, int b) { n |= two(b); }
inline void Reset(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }*/
/*int fx[]= {0,0,1,-1,-1,1,-1,1};
int fy[]= {1,-1,0,0,-1,1,1,-1};
int fx1[]={0,1,1,1,0,-1,-1,-1};
int fy1[]={1,1,0,-1,-1,-1,0,1};*/

ll a,b,c,n,ans,cn1,cn2,cn3,t;
string s,s1,s2;


int main()
{
    FIO;
  /*  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    cin>>n;
    vector<int>v1,v2(n),v3(n);
    for(int i=1;i<=n;i++){
    	v1.push_back(i);
    }
    for(int i=0;i<n;i++)cin>>v2[i];
    for(int i=0;i<n;i++)cin>>v3[i];
    sort(v1.begin(),v1.end());
    int i=0;
    vector<int>v4;
    bool h1=false,h2=false;
    do{
     if(v1==v2){
     	h1=true;
     	v4.push_back(i);
     }
     if(v1==v3){
     	h2=true;
     	v4.push_back(i);
     }
     ++i;
     if(h1&&h2)
     	break;
     
    }while(next_permutation(v1.begin(),v1.end()));
    
    cout<<abs(v4[0]-v4[1])<<endl;

    
   	
    #ifdef ONLINE_JUDGE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    #endif
   return 0;
}
 

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;

struct Pos{
    int x;
    int y;
    int order;
};
bool asc_x(const Pos& l, const Pos& r) {
    return l.x < r.x;
}
bool asc_y(const Pos& l, const Pos& r) {
    return l.y < r.y;
}

struct Node{
    int x;
    int y;
    int order;
    Node* left;
    Node* right;
};

class Tree{
    Node* root;
    Node* makeTree(vector<Pos>& A, int l, int r, int depth){
        if (l > r) return nullptr;
        if (depth % 2) {
            sort(A.begin() + l, A.begin() + r + 1, asc_y);
        } else {
            sort(A.begin() + l, A.begin() + r + 1, asc_x);
        }
        int mid = (l + r) / 2;
        Node* p = new Node;
        p->x     = A[mid].x;
        p->y     = A[mid].y;
        p->order = A[mid].order;
        p->left  = makeTree(A,       l, mid - 1, depth + 1);
        p->right = makeTree(A, mid + 1,       r, depth + 1);
        return p;
    }
    void find_(Node* n, int sx, int tx, int sy, int ty, int depth, vector<int>& ans){
        if (n == nullptr) return;
        int n_, s, t;
        if (depth % 2) {
            n_ = n->y;
            s  = sy;
            t  = ty;
        } else {
            n_ = n->x;
            s  = sx;
            t  = tx;
        }
        if (n_ >= s) find_(n->left, sx, tx, sy, ty, depth + 1, ans);
        if (n->x >= sx && n->x <= tx && n->y >= sy && n->y <= ty) {
            ans.push_back(n->order);
        }
        if (n_ <= t) find_(n->right, sx, tx, sy, ty, depth + 1, ans);
    }
public:
    Tree(vector<Pos>& A){
        root = makeTree(A, 0, A.size() - 1, 0);
    }
    void find(int sx, int tx, int sy, int ty){
        vector<int> ans;
        find_(root, sx, tx, sy, ty, 0, ans);
        sort(ans.begin(), ans.end());
        for (int i = 0; i < ans.size(); i++) {
            printf("%d\n", ans[i]);
        }
        printf("\n");
    }
};

int main(){
    int n;
    scanf("%d", &n);
    vector<Pos> A(n);
    for (int i = 0; i < n; i++) {
        scanf("%d %d", &(A[i].x), &(A[i].y));
        A[i].order = i;
    }
    Tree T(A);
    int q;
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        int sx, tx, sy, ty;
        scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
        T.find(sx, tx, sy, ty);
    }
    return 0;
}



Measured memory_bytes: 30880
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
///#pragma GCC target("avx2")
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <functional>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <climits>
#include <numeric>

using namespace std;
#define open_streams ifstream fin("olympiad.in");ofstream fout("olympiad.out")
#define close_streams fin.close();fout.close()
#define speed cout.tie(0);cin.tie(0);ios_base::sync_with_stdio(0)
#define ll long long
#define ull unsigned long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define UNIQ(a) a.resize(unique(all(a)) - a.begin())
#define eps 1e-6
//const double PI = M_PI;
const int INF = INT_MAX;
const ll limit = 1LL*1e18;
const int MOD = 1e9 + 711;
const int MOD2 = 1e9 + 933;
//---------------------------------------------------------------------------
const int mod = 1e9 + 7;
const int maxn = 1e6 + 10;





signed main() {
    speed;
    int n;
    cin >> n;
    ll x,ans = 1;
    bool was = false,zero = false;
    for(int i = 0; i < n;++i) {
        cin >> x;
        ll cur = ans*x;
        if( x== 0) {
            zero = true;
        }
        if(cur > limit || cur < ans || cur < x) {
            was = true;
        }
        ans = cur;
    }
    if(zero) {
        cout << 0;
    }
    else if(was) {
        cout << -1;
    }
    else {
        cout << ans;
    }
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define INF 1000000000000000
#define fi first
#define se second
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
int kaijo(int n){
	int ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int comb(int a,int b){
	return kaijo(a)*modpow(kaijo(a-b),MOD-2)%MOD*modpow(kaijo(b),MOD-2)%MOD;
}
int par[111111],siz[111111],n,m,a[111111],b[111111],cnt[111111];
void init(int x){
	rep(i,x){
		par[i]=i;
		siz[i]=1;
	}
}
int find(int x){
	if (par[x]==x)return x;
	return par[x]=find(par[x]);
}
void unite(int x,int y){
	x=find(x);
	y=find(y);
	if(x==y)return;
	if(siz[x]<siz[y]){
		par[x]=y;
		siz[y]+=siz[x];
	}
	else{
		par[y]=x;
		siz[x]+=siz[y];
	}
}
bool same(int x,int y) {
	return find(x)==find(y);
}
int Size(int f){
	return siz[find(f)];
}
signed main(){
	cin>>n>>m;
	init(n);
	rep(i,m){
		cin>>a[i]>>b[i];
		a[i]--,b[i]--;
		unite(a[i],b[i]);
	}
	int i=Size(0),j=Size(1),k=n-min(i,j),l=min(i,j);
	int p=k*(k-1)/2,q=l*(l-1)/2,r=p+q-m;
	cout<<r<<endl;
	return 0;
}


Measured memory_bytes: 3584
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
#include <utility>
#define FR first
#define SE second

using namespace std;

typedef long long ll;
typedef pair<ll,int> pr;

pr calc(int a[4]) {
  ll fir=0;
  for(int i=0;i<4;i++) fir=fir*1000+a[i];
  ll minn=fir;
  int cnt=1;
  for(int i=1;i<4;i++) {
  	ll s=0;
  	for(int j=0;j<4;j++) s=s*1000+a[(i+j)&3];
  	minn=min(minn,s);
  	cnt+=(s==fir);
  }
  return pr(minn,cnt);
}

map <ll,int> mp;

ll rep(pr a[4]) {
  ll s[4],num[4],v=1;
  for(int i=0;i<4;i++) {
    s[i]=mp[a[i].FR];
    num[i]=a[i].FR;
    v*=a[i].SE;
  }
  ll ans=0;
  ans+=s[0]*s[1]*s[2]*s[3];
  if (num[0]==num[1]) ans-=s[0]*s[2]*s[3];
  if (num[0]==num[2]) ans-=s[0]*s[1]*s[3];
  if (num[0]==num[3]) ans-=s[0]*s[1]*s[2];
  if (num[1]==num[2]) ans-=s[0]*s[1]*s[3];
  if (num[1]==num[3]) ans-=s[0]*s[1]*s[2];
  if (num[2]==num[3]) ans-=s[0]*s[1]*s[2];
  if (num[0]==num[1]&&num[2]==num[3]) ans+=s[0]*s[2];
  if (num[0]==num[2]&&num[1]==num[3]) ans+=s[0]*s[1];
  if (num[0]==num[3]&&num[1]==num[2]) ans+=s[0]*s[1];
  if (num[0]==num[1]&&num[1]==num[2]) ans+=2LL*s[0]*s[3];
  if (num[0]==num[1]&&num[1]==num[3]) ans+=2LL*s[0]*s[2];
  if (num[0]==num[2]&&num[2]==num[3]) ans+=2LL*s[0]*s[1];
  if (num[1]==num[2]&&num[2]==num[3]) ans+=2LL*s[0]*s[1];
  if (num[0]==num[1]&&num[1]==num[2]&&num[2]==num[3]) ans-=6LL*s[0];
  return ans*v;
}

ll getans(int a[4],int b[4]) {
  mp[calc(a).FR]--;mp[calc(b).FR]--;
  ll ans=0;
  for(int i=0;i<4;i++) {
  	pr t[4];
  	for(int j=0;j<4;j++) {
  		int now[4];
  		now[0]=a[(j+1)&3];now[1]=a[j];
  		now[2]=b[(i-j+1)&3];now[3]=b[(i-j)&3];
  		t[j]=calc(now);
	  }
	ans+=rep(t);
  }
  mp[calc(a).FR]++;mp[calc(b).FR]++;
  return ans;
}

int num[405][4];

int main() {
  int n;
  scanf("%d",&n);
  for(int i=1;i<=n;i++) {
  	for(int j=0;j<4;j++) scanf("%d",&num[i][j]);
  	pr t=calc(num[i]);
  	mp[t.FR]++;
  }
  ll ans=0;
  for(int i=1;i<n;i++)
    for(int j=i+1;j<=n;j++) 
	  ans+=getans(num[i],num[j]);
  printf("%lld\n",ans/3);
  return 0;
}

Measured memory_bytes: 80000
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
using namespace std;
struct node{
  node *r;
  node *l;
  node *p;
  int key;
};


node *root,*NIL;


void insert(int k){
  node *y;
  node *x;
  node *z;

  z = (node *)malloc(sizeof(node));
  
  z->r = NIL;
  z->l = NIL;
  z->key = k;
  
  y = NIL;
  x = root;
  
  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x -> l;
    else if(z->key > x->key) x = x -> r;
    z->p = y;
  }

    
  if(y == NIL) root = z;
  else if(z->key < y->key) y->l = z;
  else if(z->key > y->key) y->r = z;
}

void inorder(node *z){
  if(z == NIL) return;
  inorder(z->l);
  cout <<" "<< z->key;
  inorder(z->r);
}

void preorder(node *z){
  if(z == NULL) return;
  cout << " " <<z->key;
  preorder(z->l);
  preorder(z->r);
}

int main(){

  int n;
  int x;
  string com;


  // root->p = NIL;
  
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> com;
    if(com == "insert"){
      scanf("%d",&x); 
      // cout << "x = " << x << endl;
      // printf("a\n");
      insert(x);
    }
    else if(com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
}

Measured memory_bytes: 26616
#include <bits/stdc++.h> 
#include <time.h>
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i) 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 1e3+10;
const int N = 1e5+10;
const int E = 1e6+10;  
ll n,k;
string ans;

int main(){
	cin>>n;
	while(n){
		if(n%26==0){
			ans+='z';
			n--;
		}
		else ans+=char(n%26+'a'-1);
		n/=26;
	}
	for(int i=ans.size()-1;i>=0;i--){
		cout<<ans[i];
	}
}

Measured memory_bytes: 3624
n = int(input())
S = []
H = []
C = []
D = []

if n != 52:
    for _ in range(n):
        x,y = map(str,input().split())
        if x == 'S':
            S.append(int(y))
        elif x == 'H':
            H.append(int(y))
        elif x == 'C':
            C.append(int(y))
        elif x == 'D':
            D.append(int(y))

    S.sort()
    H.sort()
    C.sort()
    D.sort()

    ans = []

    for i in range(13):
        if S.count(i+1) == 0:
            ans.append(['S', i+1])
    for i in range(13):
        if H.count(i+1) == 0:
            ans.append(['H', i+1])
    for i in range(13):
        if C.count(i+1) == 0:
            ans.append(['C', i+1])
    for i in range(13):
        if D.count(i+1) == 0:
            ans.append(['D', i+1])

    for v in ans:
        print(' '.join(map(str,v)))



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

int main() {
  string S;
  cin>>S;
  int N = S.size();
  int a=0;
  int b=0;
  
  //10101にする
  for(int i=0; i<N; i++){
    if(i%2==0){
      if(S.at(i)=='0') a++;
    }
    else{
      if(S.at(i)=='1') a++;
    }
  }
  
  //0101にする
  for(int i=0; i<N; i++){
    if(i%2==0) {
      if (S.at(i)=='1') b++;
    }
    else {
      if(S.at(i)=='0') b++;
    }
  }
  
  cout<<min(a,b)<<endl;
}

Measured memory_bytes: 3704
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define ALL(v)     (v.begin()), (v.end())

typedef long long ll;

ll n;
ll s;

ll f(ll b, ll k) {
  ll ret = 0;
  while(k > 0) {
    ret += k % b;
    k = k / b;
  }
  return ret;
}

ll find() {
  if (s > n) return -1;
  if (s == n) return n + 1;
  for (ll b = 2; b * b <= n; b++) {
    if (f(b, n) == s) return b;
  }
  ll m = n - s;
  vector<ll> divs;
  for (ll i = 1; i * i <= m; i++) {
    if (m % i == 0) divs.push_back(i);
  }
  for (int i = divs.size() - 1; i >= 0; i--) {
    ll a1 = divs[i];
    ll a2 = s - a1;
    ll b = m / a1 + 1;
    if (a2 >= 0 && a2 < b) return b;
  }
  return -1;
}

void solve() {
  printf("%lld\n", find());
}

void input() {
  scanf("%lld", &n);
  scanf("%lld", &s);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <iostream>
#include <string.h>
#include <algorithm>
 size_t strlen(const char *s);
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int N=100010;
const int P=1000000007;
int compare_int(const void *a, const void *b)
{
    return *(long long int*)a - *(long long int*)b;//a-b昇順
}
//絶対値
int ze(int a, int b){
	if(a>b){
		return a-b;
	}else{
		return b-a;
	}
}
// a^n mod 
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod 
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

//mod掛け算
long long mt(long long a, long long b, long long mod){
	return (a*b)%mod;
}

//メモ
//	cout<<(n-2)*180<<endl;
//	string s="hoge";
//	cout<<ans<<endl;
//	int  n  ,a  ,b  ,c  ,d  ,e  ,f  ;
//	cin  >>n  >>a  >>b  >>c  >>d  >>e  >>f  ;

/*
	memset(b, '\0', sizeof(b));
初期化*/
/*
	len = strlen(s);
文字列長さ*/
/*
	string s;
	s.size()
*/
/*ソート
	qsort(b, 10, sizeof(int), compare_int);
*/
/*
	char s[N];
	strlen(s)
/*
	if(  <  )puts("YES");
	else puts("NO");
*/

int main(){
	int n, a[N];
	int s=-1,t=-1,u=-1,v=0;
	int ss=0,tt=0,uu=0,vv=0;
	cin  >>n   ;
	rep(i, n){
		a[i]=0;
		cin>>a[i];
		if(s==a[i]){
			ss++;
		}
		else if(s<0){
			s=a[i];
			ss++;
		}
		else{		if(t==a[i]){
			tt++;
		}
		else if(t<0){
			t=a[i];
			tt++;
		}
		else{		if(u==a[i]){
			uu++;
		}
		else if(u<0){
			u=a[i];
			uu++;
		}
		else{
			vv++;
		}
		}
		}
	}
	if(vv>0){
		puts("No");
	}else if(tt==0){
		if(s==0){
			puts("Yes");
		}else{
			puts("No");
		}
	}else if((ss==tt)&&(ss==uu)){
		int b[3]={s,t,u};
		int c[100];
		memset(c, '\0', sizeof(c));
		rep(i,3){
			rep(j,100){
				c[j]+=b[i]%2;
				b[i]=b[i]/2;
			}
//			printf("%d",c[0]);
		}
		rep(i,100){
			if((c[i]!=0)&&(c[i]!=2)){
				vv++;
//				printf("vv%d\n",vv);
			}
		}
		if(vv==0){
			puts("Yes");
		}else{
			printf("No");
		}
	}else if(uu==0){
		if(ss==2*tt){
		int b[3]={s,t,s};
		int c[100];
		memset(c, '\0', sizeof(c));
		rep(i,3){
			rep(j,100){
				c[j]+=b[i]%2;
				b[i]=b[i]/2;
			}
//			printf("%d",c[0]);
		}
		rep(i,100){
			if((c[i]!=0)&&(c[i]!=2)){
				vv++;
//				printf("vv%d\n",vv);
			}
		}
		if(vv==0){
			puts("Yes");
		}else{
			printf("No");
		}
		}else if(2*ss==tt){
					int b[3]={s,t,t};
		int c[100];
		memset(c, '\0', sizeof(c));
		rep(i,3){
			rep(j,100){
				c[j]+=b[i]%2;
				b[i]=b[i]/2;
			}
//			printf("%d",c[0]);
		}
		rep(i,100){
			if((c[i]!=0)&&(c[i]!=2)){
				vv++;
//				printf("vv%d\n",vv);
			}
		}
		if(vv==0){
			puts("Yes");
		}else{
			printf("No");
		}
		
		}else{
			puts("No");
		}
	}else{
		puts("No");
	}




}

Measured memory_bytes: 640
#include <iostream>
#include <string>
using namespace std;
int main(){
    int n; cin >> n;
    string s; cin >> s;
    if(s.size()%2 == 1){
        puts("No");
        return 0;
    }
    if(s.substr(0,s.size()/2) == s.substr(s.size()/2)) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

int main(){

  int n, m, x;
  cin >> n >> m >> x;

  int lcost = 0, rcost = 0;
  int a;
  for (int i = 0; i < m; i++){
    cin >> a;
    if (x < a){
      rcost += 1;
    }
    else {
      lcost += 1;
    }
  }

  cout << min(lcost, rcost) << endl;

  return 0;
}


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

#define OUT(x) cout << (x) << endl;
#define ALL(v) v.begin(), v.end()
#define REP(i, n) for (int i=0; i<n; ++i)

int main() {
    string str;
    cin >> str;
    int dict[30] = {0};
    int n = str.size();
    char ans = 'z';    

    REP(i, n) {
        int num = str[i]-'a';
        dict[num] = 1;
    }
    
    REP(i, n){
        if(dict[i] == 0){
            ans='a'+i;
            cout<<ans<<endl;
            break;
        }
        if(i==25){
            OUT("None");
            break;
        }
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 2e5 + 123;
const int M = 1e6 + 123;
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

int cnt[26];

int main(){
    #ifdef KAZAKH
        freopen("input.txt", "r", stdin);
    #endif
    string s;
    cin >> s;
    int n = sz(s);
    ll ans = (n+1ll) * n / 2;
    for (int i = 0; i < n; i++){
        cnt[s[i] -= 'a']++;
    }
    for (int i = 0; i < 26; i++){
        ans -= (cnt[i]+1ll) * cnt[i] / 2;
    }
    cout << ans+1;
    return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

ll dp[51][51][2501]={0};

int main(){
    int n,a;
    cin >> n >> a;
    vector<int> x(n);
    REP(i,n){
        cin >> x[i];
    }
    dp[0][0][0]=1;
    REP(i,n){
        REP(j,n){
            REP(k,2501){
                if(k+x[i]<=2500){
                    dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
                }
                dp[i+1][j][k]+=dp[i][j][k];
            }
        }
    }
    ll res = 0;
    for(int i=1;i*a<2501&&i<51;i++){
        res += dp[n][i][i*a];
    }
    put(res);
    return 0;
}


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

int main(){
	int k,n;
	int ans=0x7fffffff;
	cin>>k>>n;
	vector<int>a(n);
	rep(i,n){
		cin>>a[i];
	}
	rep(i,n){
		int t_dis=0;
		if(i==0){
			t_dis+=a[n-1]-a[i];
		}
		else{
			t_dis+=a[n-1]-a[i];
			t_dis+=k-a[n-1]+a[i-1];
		}
		if(t_dis<ans)ans=t_dis;
	}
	cout<<ans<<endl;

	return 0;

}

Measured memory_bytes: 1024
N=int(input())
A=list(map(int,input().split()))
B=[]
for i in range(N):
    B.append(A[i]-i-1)
B.sort()
if N%2:
    b=B[N//2]
else:
    b=(B[N//2]+B[N//2-1])//2
ans=0
for k in B:
    ans+=abs(k-b)
print(ans)

Measured memory_bytes: 26360
N = int(input())
S = [input() for _ in range(2)]

MOD = 1000000007
i = 0
C = []
while i < N:
    if S[0][i] == S[1][i]:
        C.append(0)
        i += 1
    else:
        C.append(1)
        i += 2

ans = 3 if C[0] == 0 else 6
for i in range(len(C) - 1):
    if C[i] == 0:
        ans = ans * 2 % MOD
    elif C[i + 1] == 1:
        ans = ans * 3 % MOD
print(ans)


Measured memory_bytes: 3064