akhauriyash/Code-Regression huggingface dataset:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
AB = [LIST() for _ in range(N)]
AB.sort(key = lambda x: (x[1]))

sum = 0
for i in range(N):
	sum += AB[i][0]
	if sum > AB[i][1]:
		print("No")
		break
else:
	print("Yes")

Measured memory_bytes: 55764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;

int main(){
  int a,b,x;
  cin >> a >> b;
  if(b==100) x = a*1000 + b;
  else if(b>=10) x = a*100 + b;
  else x = a*10 + b;
  
  bool flag=false;
  rep(i,1000){
    if(i*i == x) flag = true;
  }
  
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

int n, k, a[200005], b[200005];

int main() {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
	}
	while (k--) {
		for (int i = 1; i <= n; ++i) {
			b[i] = 0;
		}
		for (int i = 1; i <= n; ++i) {
			int l = i - a[i], r = i + a[i] + 1;
			l = std::max(l, 1), r = std::min(r, n + 1);
			++b[l], --b[r];
		}
		for (int i = 1; i <= n; ++i) {
			b[i] += b[i - 1];
		}
		bool flag = 1;
		for (int i = 1; i <= n; ++i) {
			a[i] = b[i];
			flag &= a[i] == n;
		}
		if (flag) {
			break;
		}
	}
	for (int i = 1; i <= n; ++i) {
		printf("%d ", a[i]);
	}
	putchar('\n');
}

Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

void mod( ll &n, ll m=MOD ){ n%=m,n+=m,n%=m; }

const int MAXN = 1e5+5;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    ll a,b,c,d;
    cin>>a>>b>>c>>d;

    ll lc = ((a-1)/c + 1)*c;
    ll rc = (b/c)*c;

    ll ld = ((a-1)/d + 1)*d;
    ll rd = (b/d)*d;

    ll lcm = (c*d)/__gcd(c,d);

    ll llcm = ((a-1)/lcm + 1)*lcm;
    ll rlcm = (b/lcm)*lcm;

    ll total_nums = (b-a+1);
    ll numc = (rc-lc)/c + 1;
    ll numd = (rd-ld)/d + 1;
    ll numlcm = (rlcm-llcm)/lcm + 1;

    ll ans = total_nums - numc - numd + numlcm;
    cout<<ans;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<deque>
#include<queue>
#include<math.h>
#include<string>
#include<string.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<iomanip>
#include<map>
#include<unordered_map>
 
#include<unordered_map>
#include<algorithm>
#define inf 0x3f3f3f3f
#define sup_inf 2e18
#define pb push_back
 
#define ii pair<int,int>
#define f first		
#define s second
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define iii pair<int, ii >
#define in freopen("entrada","r",stdin);
#define out freopen("myfile.txt", "w", stdout);
#define eps 1e-9
#define id pair<int ,double > 
#define di pair<double, int>
 
#define pi 3.14159265359
#define nl (no<<1)
#define nr ( (no<<1)|1)
#define mid l + ( (r-l)>>1)
 
using namespace std;
 
const int maxn = 4e5 + 10;
const int MAX = 30;

typedef long long ll;
typedef vector< int> vi;
//~ https://codeforces.com/contest/645/problem/D


 


int s_f[MAX], s_v[MAX], n, ce[MAX];


inline bool check ( int x ){
	int tf = 0 ;
	for(int i = 0 ; ( 1 << i) <= x;i++){
		if ( ( 1<<i) & x )
			tf|= s_f[i];
	}
	return ( tf&x) == 0;
}


int gen (int idx , int mask){
	for(int j = 0 ;j < n ;j++){
		if ( ( (1<<j) & s_v[idx] )  && !(mask&(1<<j)) ) {
			mask|= gen ( j, mask|(1<<j));
		}
	}
	return mask;
}

int main (){
	//~ in
	
	cin >> n;
	for(int i = 0 ; i < n;i++){
		ce[i] = (1<<i);
		int m ; cin >> m;
		for(int j = 0;j < m;j++){
			int a, b; cin >> a >> b;
			a-=1;
			if ( b == 1) {
				s_v[i]|=(1<<a);
			}else {
				s_f[i]|=(1<<a);
			}
		}
	}
	
	for(int i = 0;i < n;i++){
		ce[i] |= gen ( i, ce[i]);
	}
	
	int ans = 0;
	
	for(int i = 0 ;i <= (1<<n) - 1;++i){
		int cj = i;
		for(int j = 0 ;(1<<j) <= i;j++){
			if ( (1<<j) & cj ) {
				cj|=ce[j];
			}
		}
		
		if ( check ( cj) ) {
			ans = max ( ans, __builtin_popcount ( cj) );
		}
	}
	
	cout << ans << '\n';
	
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<endl
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 998244353; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 2e18;

int dp[100010][3];
bool ok[100010];
void solve() {
	int N, K; cin >> N >> K;
	vector<int>p(3);
	REP(i, 3)cin >> p[i];
	string S; cin >> S;
	map<char, int>mp;
	mp['r'] = 2;
	mp['s'] = 0;
	mp['p'] = 1;
	ll ans = 0;
	REP(i, N) {
		if (i < K) {
			ans += p[mp[S[i]]];
		}
		else {
			if ((S[i - K] != S[i])||(ok[i-K])) {
				ans += p[mp[S[i]]];
			}
			else ok[i] = true;
		}
	}
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;cin>>q;
	//while(q--)
	solve();
}




Measured memory_bytes: 592
//2020-05-16 16:01:48
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; ++i)
using namespace std;
using ll = long long;
const ll mod = 1e9+7, size = 1e5;
ll power(ll x, ll n, ll M){
    ll res = 1;
    if(n > 0){
        res = power(x, n / 2, M);
        if(n%2 == 0)res = (res * res) % M;
        else res = (((res * res) % M) * x) % M;
    }
    return res;
}
ll mod_inv(ll n, ll M){
    return power(n, M-2, M);
}
struct Combination
{
    ll n, mod;
    vector<ll> factorial;
    Combination(ll n, ll mod):n(n),mod(mod){
        init();
    }
    void init(){
        factorial.push_back(1);
        for (int i=1; i<=n; i++){
            factorial.push_back(factorial[i-1] * i);
            factorial[i] %= mod;
        }
    }
    ll aCb(ll a, ll b){
        if (a < b)return 0;
        ll y = factorial[a] * mod_inv(factorial[b], mod);
        y %= mod;
        y *= mod_inv(factorial[a-b], mod);
        y %= mod;
        return y;
    }
};
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    Combination c = Combination(n, mod);
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    map<ll, ll> m;
    rep(i,n)m[a[i]]++;
    vector<pair<ll, ll>> v;
    for (auto &&i : m)
        v.push_back(i);
    vector<pair<ll, ll>> v_r = v;
    reverse(v_r.begin(), v_r.end());
    rep(i, v.size()-1){
        v[i+1].second += v[i].second;
        v_r[i+1].second += v_r[i].second;
    }

    ll ans = 0;
    ll x = 0;
    for (auto &&i : v){
        x = i.second - x;
        ans += mod * mod + i.first * (mod + c.aCb(i.second, k) - c.aCb(i.second-x, k));
        ans %= mod;
        x = i.second;
    }
    x = 0;
    for (auto &&i : v_r){
        x = i.second - x;
        ans += mod * mod - i.first * (mod + c.aCb(i.second, k) - c.aCb(i.second-x, k));
        ans %= mod;
        x = i.second;
    }
    cout << ans << endl;
}

Measured memory_bytes: 10608
S=input()
A="abcdefghijklmnopqrstuvwxyz"
ans=100
for a in A:
  T=S;
  x=0;
  while(T.count(a)!=len(T)):
    U=""
    for i in range(len(T)-1):
      U+=(T[i+1]if T[i+1]==a else T[i])
    T=U
    x+=1
  ans=min(ans,x)
print(ans)

Measured memory_bytes: 73644
#include <iostream>
#include <unordered_map>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int N,A,B;
    cin >> N >> A >> B;
    int first=0,second=0,third=0;
    for(int i=0;i<N;i++){
        int P;
        cin >> P;
        if(P <= A)first++;
        else if(P > A && P <= B)second++;
        else if(P > B)third++;
    }
    
    cout << min(first,min(second,third));
    
}


Measured memory_bytes: 3160
using System;

namespace B___Golden_Coins
{
    class Program
    {
        static void Main (string[] args)
        {
            var x = int.Parse (Console.ReadLine ());
            var ans = x / 500 * 1000;
            ans += x % 500 / 5 * 5;
            Console.WriteLine (ans);
        }
    }
}

Measured memory_bytes: 11220
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
using namespace std;
#define in read()
#define fur(i,a,b) for(int i=a;i<=b;i++)
#define fdr(i,a,b) for(int i=a;i>=b;i--)
#define int long long
#define xx 1100
inline int read()
{
    int x=0,f=1;char ch=getchar();
    for(;!isalnum(ch);ch=getchar()) if(ch=='-') f=-1;
    for(;isalnum(ch);ch=getchar()) x=x*10+ch-'0';
    return x*f;
}
int sum[xx],w[xx],f[xx<<3];
vector<int>e[xx];
inline void dfs(int g)
{
	fur(i,0,(int)e[g].size()-1) dfs(e[g][i]);
	memset(f,0x3f,sizeof(f));f[0]=0;
	fur(i,0,(int)e[g].size()-1)
	{
		int k=e[g][i];
		fdr(j,w[g],0)
		{
			int tmp=0x3f3f3f3f;
			if(j>=sum[k]) tmp=min(tmp,f[j-sum[k]]+w[k]);
			if(j>=w[k]) tmp=min(tmp,f[j-w[k]]+sum[k]);
			f[j]=tmp;
		}
	}
	fdr(i,w[g],0) sum[g]=min(sum[g],f[i]);
}
signed main()
{
	memset(sum,0x3f,sizeof(sum));
    int n=in;
    fur(i,2,n)
    {
        int x=in;
        e[x].push_back(i);
    }
    fur(i,1,n) w[i]=in;
    dfs(1);
    if(sum[1]<0x3f3f3f3f) printf("POSSIBLE\n");
    else printf("IMPOSSIBLE\n");
    return 0;
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define X first
#define Y second
#define pb push_back
#define make_unique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define int long long

const LL mod = 1e9 + 7;


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

template<class T, class U>
istream& operator >> (istream& in, pair<T, U> & v){ in >> v.X >> v.Y;return in; }

template<class T, class U>
ostream& operator << (ostream& out, pair<T, U> & v){ out << v.X << " " << v.Y;return out; }

void chkmax(int &a, int b) {
    a = max(a, b);
    return;
}

void chkmin(int &a, int b) {
    a = min(a, b);
    return;
}

LL ppow (LL x, LL s) {
    if (!s) return 1;
    if (!(s - 1)) return x % mod;
    if (s % 2) return (x * ppow (x, s - 1)) % mod;
    LL b = ppow (x, s / 2);
    return (b * b) % mod;
}

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("ILUXA.in", "r", stdin);
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(a[0] - a[1]);
    for (int i = 2;i < n;i++) {
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
    }
    cout << dp[n  -1];
    return 0;
}


Measured memory_bytes: 1792
'''
Let g(x) = 序列內數字唯一，且最多 x 個位置不同。
Let f(x) = 序列內數字唯一，且給定 x 個位置時，使這些位置不同的方法數。

題目所求是 C(N, N) f(N)。

其中 g(x) 代表有至少 N - x 個位置是相同。可以分三個部份填數字，注意順序會影響，所以要乘上全排序：
(1) N - x 個位置（數字必需相同）：C(M, N - x) * (N - x)! = P(M, N - x)
(2) 序列 A 其餘位置（可以隨便填，但不能用到 (1) 的數字）：C(M - (N - x), x) * x! = P(M - (N - x), x)
(3) 序列 B 其餘位置（可以隨便填，但不能用到 (1) 的數字）：C(M - (N - x), x) * x! = P(M - (N - x), x)
g(x) = (1) * (2) * (3)

g(x) 是「選定 0 個位置，使這些位置不同的方法數」、「選定 1 個位置，使這些位置不同的方法數」、…、「選定 N 個位置，使這些位置不同的方法數」，即

g(x) = C(x, 0) f(0) + C(x, 1) f(1) + ... + C(x, x) f(x)
     = sum( C(x, i) * f(i) for i in [0, x] )
根據二項式反演，得到
f(x) = sum( (-1) ** (x - i) * C(x, i) * g(i) for i in [0, x] )
'''

class CombMod:
    def __init__(self, V, p):
        self.fact = [1] * V
        self.finv = [1] * V
        for i in range(1, V):
            self.fact[i] = self.fact[i - 1] * i % p
        self.finv[-1] = pow(self.fact[-1], p - 2, p)
        for i in range(V - 2, 0, -1):
            self.finv[i] = self.finv[i + 1] * (i + 1) % p
        self.p = p
        
    def fact(self, a):
        return self.fact[a]
    
    def finv(self, a):
        return self.finv[a]

    def comb(self, a, b):
        return self.fact[a] * self.finv[b] % self.p * self.finv[a - b] % self.p
        
    def perm(self, a, b):
        return self.fact[a] * self.finv[a - b] % self.p
    
    def hcomb(self, a, b):
        return self.comb(a + b - 1, b)


N, M = map(int, input().split())
mod = 10**9 + 7
tool = CombMod(max(N, M) + 10, mod)

ans = 0
for i in range(0, N + 1):
    p1 = tool.perm(M, N - i)
    p2 = tool.perm(M - (N - i), i)
    g_i = p1 * p2 % mod * p2 % mod
    val = pow(-1, N - i, mod) * tool.comb(N, i) % mod * g_i % mod
    ans = (ans + val) % mod
print(ans)


Measured memory_bytes: 48172
#include<stdio.h>
#include<string.h>
int main()
{
	int n,f=0;
	int i,j,k;
	char s[105],ss[105],t[105],s1[105];
	scanf("%s",s);
	scanf("%s",t);
	strcpy(ss,t);
	n=strlen(s);
	for(i=n-1;i>=0;i--)
	{
		int x=1;
		s1[0]=s[n-1];
		for(j=0;j<n-1;j++)
			s1[x++]=s[j];
		s1[x]='\0';
		if(strcmp(s1,ss)==0)
		{
			f=1;
			break;
		}
		strcpy(s,s1);
	}
	if(f==1)
		printf("Yes\n");
	else
		printf("No\n");
}

Measured memory_bytes: 128
# coding:utf-8

import sys

input = sys.stdin.readline
INF = float('inf')


def inpl(): return list(map(int, input().split()))


N = int(input())
A = inpl()
B = [0]
for a in A:
    B.append(B[-1] + a)
del B[0]

ans = INF
for i in range(N - 1):
    ans = min(ans, abs(B[i] - (B[-1] - B[i])))

print(ans)


Measured memory_bytes: 23784
import math

x, y = (int(each) for each in input().split())

turtles = (y-2*x)/2
cranes = (4*x-y)/2
if turtles == math.ceil(turtles) and turtles >= 0 and cranes == math.ceil(cranes) and cranes >= 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9112
#include<bits/stdc++.h>
using namespace std;
#define IL inline
#define rep(i,j,k) for(int i=j;i<=k;++i)
#define repd(i,j,k) for(int i=j;i>=k;--i)
#define pb push_back
#define db double
#define mp make_pair
#define mp3(a,b,c) mp(a,mp(b,c))
#define pii pair<int,int>
#define piii pair<pii,int>
#define fr first
#define se second
#define ll long long 
#define pbc(x) __builtin_popcount(x)
IL int read(){int x;int _w=scanf("%d",&x);return x;}
IL void write(int x){printf("%d\n",x);}
template<typename T>IL void debug(T x){cerr<<x;return;}
const int maxn=1005;
int n;
pii p[maxn];
const char f[]={'L','U','R','D'};
int main(){
	//freopen("input.txt","r",stdin);
	n=read();
	int e=0,o=0;
	int x,y;rep(i,1,n)x=read(),y=read(),p[i]={x,y},((x+y&1)?o++:e++);
	if(min(e,o)!=0){puts("-1");return 0;}
	int tot=32;
	cout<<tot+(bool)e<<endl;
	repd(i,31,0)cout<<(1ll<<i)<<' ';
	if(e)cout<<1<<' ';
	cout<<endl;
	rep(i,1,n){
		ll a1=p[i].fr+p[i].se,a2=p[i].fr-p[i].se;
		ll dx=0,dy=0;
		repd(i,31,-1){
			ll Node=1ll<<i;
			if(i==-1){if(!e)break;else Node=1;}
			int a=0,b=0;
		
			if(a1>=0){a1-=Node;a=1;}
			else a1+=Node;
			if(a2>=0){a2-=Node;b=1;}
			else a2+=Node;
//			cerr<<"a="<<a<<"b="<<b<<endl;
			putchar((a+b)==1?(a?f[1]:f[3]):f[a+b]);
			char type=((a+b)==1?(a?f[1]:f[3]):f[a+b]);
			if(type=='L')dx-=Node;
			if(type=='R')dx+=Node;
			if(type=='U')dy+=Node;
			if(type=='D')dy-=Node;
			//cerr<<"["<<dx<<","<<dy<<"]\n";
			//cerr<<"qwq:"<<a1<<' '<<a2<<endl;
		}
	//	cerr<<"["<<dx<<","<<dy<<"]\n";
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int N=1e5+5;
int n,m,lcm=1,a[N];


signed main(){
	read(n);read(m);
	m*=2;
	for(int i=1,x;i<=n;i++){
		lcm=lcm/__gcd(lcm,read(a[i]))*a[i];
		if(lcm>m){
			write(0);
			return 0;
		}
	}
	for(int i=1;i<=n;i++) if(lcm/a[i]%2==0){
		write(0);
		return 0;
	}
	write((m/lcm+1)/2);
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    unordered_map<int, int> m;

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

    bool all_zero = all_of(begin(a), end(a), [](const auto& ai){ return ai == 0; });
    bool any_zero = any_of(begin(a), end(a), [](const auto& ai){ return ai == 0; });

    if (all_zero) {
        cout << "Yes" << endl;
        return 0;
    }

    if (n % 3 != 0) {
        cout << "No" << endl;
        return 0;
    }

    if (any_zero) {
        auto it = find_if(begin(a), end(a), [](const auto& ai){ return ai != 0; });
        int x = *it;
        if (m[x] == 2*n/3 && m[0] == n/3) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    auto it = find_if(begin(a), end(a), [](const auto& ai){ return ai != 0; });
    int x = *it;

    auto it2 = find_if(begin(a), end(a), [&](const auto& ai){ return ai != x; });
    int y = *it2;

    int z = x ^ y;

    if (m[x] == n/3 && m[y] == n/3 && m[z] == n/3) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
int main(void){

    int k, s;
    cin >> k >> s;
    
    int result = 0;
    for(int x=0; x<=k; x++) {
        for(int y=0; y<=k; y++) {
            if(s-(x+y)<=k && s-(x+y)>=0) {
                result++;
            }
        }
    }

    cout << result << endl;
    
    return 0;
}


Measured memory_bytes: 764
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include<vector>
#include<cstring>
#include<set>
#include <cstdio>
#include<queue>
#include<map>
#define WHITE 0
#define GRAY  1
#define BLACK 2
#define endl '\n'
#define forup(i,a,n) for( int i =a; i < n; i++)
#define llforup(i,a,n) for( ll i =a; i < n; i++)
#define fordown(i,a,n) for( int i =a; i >= n; i--)
#define fornot(i,a,n) for( int i=a;!n;i++)
#define mod  (ll)(1e9+7)
#define ifempty(a)  if(!a)
using namespace std;
typedef long long ll;
inline int readnum()
{
	int p, data = 0; char ch = 0;
	while ((ch != ' - ') && ch < '0' || ch>'9') ch = getchar();//相当于正则表达式的搜索，跳过不需要的字符
	if (ch == '- ')p = -1, ch = getchar();
	else p = 1;
	while (ch >= '0' && ch <= '9') data = data * 10 + ch - '0', ch = getchar();//搜索需要的字符
	return data * p;
}
inline int ReadPossitive()
{
	char ch; int data = 0;
	ch = getchar();
	while (ch == ' ' || ch == '\n')ch = getchar();
	while (ch != ' ' && ch != '\n' && ch != EOF)
	{
		data = data * 10 + ch - '0';
		ch = getchar();
	}
	return data;
}
//E-mail 374656045@qq.com
class DisjointSet {
private:
	vector<int>rank, root;
public:
	DisjointSet() {};//无参数不执行初始化
	DisjointSet(int size)//重载
	{
		rank.resize(size, 0);
		root.resize(size, 0);
		forup(i, 0, size)makeset(i);
	}
	inline void makeset(int x)
	{
		rank[x] = 0;
		root[x] = x;
	}
	
	inline int findroot(int x)
	{
		while (x!=root[x])
		{
			x = root[x];
		}
		return x;
	}
	inline void link(int x, int y)//注意两个参数都是根
	{
		if (rank[x] < rank[y])root[x] = y;//注意要做一点基本的平衡操作
		else//矮树要连接到高树上
		{
			root[y] = x;
			if (rank[x] == rank[y])rank[x]++;
		}
	}
	void unite(int x, int y)
	{
		link(findroot(x), findroot(y));
	}
	bool same(int x, int y)
	{
		return findroot(x) == findroot(y);
	}

};
class solve {
private:
	int n, q;
	int control;
	int x, y;
public:
	solve()
	{
		initial();
		DisjointSet ds(n);
		forup(i, 0, q)
		{
			control = ReadPossitive();
			x = ReadPossitive();
			y = ReadPossitive();
			switch (control)
			{
			case 0:
				ds.unite(x, y); break;
			case 1:
				if (ds.same(x, y))
					printf("%d\n", 1);
				else printf("%d\n", 0);
				break;
			}
		}
	}
	inline void initial()
	{
		n = ReadPossitive(); q = ReadPossitive();
	}
};
int main(void)
{
	ios_base::sync_with_stdio(0); cin.tie(0);//慎用，cin和scanf混用会导致非MSC++WA
#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve solution;
#ifdef DEBUG
	fclose(stdin);//关闭文件 
	fclose(stdout);//关闭文件 
#endif
	return 0;

}




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

#define ll long long
#define ull unsigned long long

using namespace std;

ll N;
ll ans;

void dfs(ll digit, ll base, ll num) {
	for (int ii = 0; ii < 3; ++ii){
		ll nnum = num + base * (3 + 2 * ii);
		ll ndigit = digit + 1;

		//753数かどうかチェック
		bool three = false;
		bool five = false;
		bool seven = false;
		bool valid = true;
		bool smaller = false;
		ll tmp = nnum;
		for (int keta = 0; keta < ndigit; ++keta){
			ll tmp2 = nnum % 10;
			if ((tmp%10) == 3){
				three = true;
			} else if ((tmp%10) == 5) {	
				five = true;
			} else if ((tmp%10) == 7) {	
				seven = true;
			} else {
				valid = false;
				break;
			}
			tmp /= 10;
		}

		if (nnum <= N){
			smaller = true;
		}

		if (three && five && seven && valid && smaller){
			ans++;
		}

		if (smaller){
			dfs(ndigit, base * 10, nnum);
		} else {
			break;
		}
	}
}

int main() {
	cin >> N;
	ans = 0;

	ll digit = 0;
	ll base = 1;
	ll num = 0;
	dfs(digit, base, num);
	
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int N, x;
int A[100010];
long long ans = 0;

int main() {

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

    for (int i = 0; i < N - 1; ++i) {
        int s = A[i] + A[i + 1];
        if (s > x) {
            ans += s - x;
            if (A[i + 1] < s - x) {
                A[i + 1] = 0;
            } else {
                A[i + 1] -= s - x;
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define td(v) v.begin(),v.end()
#define tdr(v) v.rbegin(),v.rend()
#define endl "\n"
#define Matrix vector<vector<int> >
using namespace std;
const int MOD = 1e9+7;
const int MOD2 = 1e9 + 9;
const int INF = 5e18;
 
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
 
 
inline long long mod(long long n, long long m){
    long long ret = n%m;
    if(ret < 0) ret += m;
    return ret;
}
 
int exp(int a, int b){
    int result = 1;
    while (b > 0){
        if (b & 1)
            result = result*a;
 
        b >>= 1;
        a = a*a;
    }
    return result;
}

void solve(){
    string s;
    cin>>s;
    cout<<(s=="ABC" ? "ARC":"ABC")<<endl;
}
signed main(){
    fastio; 
    // int x=0;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

//最大公約数
ll GCD(ll a, ll b)
{
    if (a == b || b == 0) {
        return a;
    } else if (a < b) {
        return GCD(b, a);
    } else {
        return GCD(b, a % b);
    }
}

//最小公倍数
ll LCM(ll a, ll b)
{
    return a * b / GCD(a, b);
}

int main()
{
    int n, m;
    cin>>n>>m;
    string s, t;
    cin>>s>>t;
    ll lcmnum = LCM(n,m);
    bool flag = true;
    REP(i,GCD(n,m)) {
        if (s[i*lcmnum/m] != t[i*lcmnum/n]) {
            flag = false;
            break;
        }
    }

    if (flag) {
        cout<<lcmnum<<endl;
    } else {
        cout<<-1<<endl;
    }

    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <set>
#include <cmath>
#include <sstream>
#define MAX 100010
using namespace std;

int main()
{
    int a[6],k,flag=1;
    for(int i=0;i<5;i++)
        scanf("%d",&a[i]);
    scanf("%d",&k);
    for(int i=0;i<5;i++)
    {
        for(int j=i+1;j<5;j++)
        {
            if(abs(a[i]-a[j])>k)
            {
                flag=0;
                break;
            }
        }
    }
    if(!flag)
        printf(":(");
    else
        printf("Yay!");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define Coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int main()
{
	string ss;
	cin >> ss;
	for(int64 ii = 1;ii < ss.length();ii++)
	{
		if(ss[ii - 1] == ss[ii])
		{
			cout << ii << ' ' << ii + 1 << endl;
			return 0;
		}
	}
	for(int64 ii = 1;ii < ss.length() - 1;ii++)
	{
		if(ss[ii - 1] == ss[ii + 1])
		{
			cout << ii << ' ' << ii + 2 << endl;
			return 0;
		}
	}
	cout << "-1 -1" << endl;
	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25


int main() {
    string s;
    cin >> s;
    if(s.length() % 2 == 0){
        rep(i, s.length()/2){
            string sub = s.substr(i, 2);
            if(sub != "hi"){
                cout << "No" << endl;
                return 0;
            }
            i++;
        }
        cout << "Yes" << endl;
        return 0;
    }else{
        cout << "No" << endl;
    }
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,x;
int d[500000];
int main(){
	scanf("%d",&n);
	for(register int i=2;i<=n;i++)scanf("%d",&x),d[x]++;
	printf("%d\n",d[1]);
	for(register int i=2;i<=n;i++){
		printf("%d\n",d[i]);
	}
	return 0;
}

Measured memory_bytes: 4564
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S,T;
  int A,B;
  string U;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  if(S==U){
    A--;
  }else if (T==U){
    B--;
  }
  cout << A << " " << B;
}


Measured memory_bytes: 256
/*                             //
         frostbyte02
//                             */
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=a; i<=b; i++)
#define LLFOR(i,a,b) for (ll i=a; i<=b; i++)
#define FORD(i,a,b) for (int i=a; i>=b; i--)
#define fi first
#define se second
#define pb push_back
#define fastio {ios_base::sync_with_stdio(false); cin.tie(0);}
#define sqr(x) (x)*(x)
#define sqrmod(x) (((x)%MOD)*((x)%MOD))%MOD

using namespace std;
const int MOD = 1e9+7;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;

int main()                                
{
        fastio
        string s; cin >> s;
        int n = s.size();
        int res = 0;
        FOR(i,1,n-1)
        {
                if (s[i]==s[i-1])
                {
                        if (s[i-1]=='1') s[i] = '0';
                        else s[i] = '1';
                        res++;
                }
        }
        //cout << s << '\n';
        cout << res;
        return 0;  
}


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

int main() {
  int H, W;
  cin >> H >> W;
  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  cout << endl;
  for (int i = 0; i < H; i++) {
    cout << "#";
    string S;
    cin >> S;
    cout << S;
    cout << "#" << endl;
  }
  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  cout << endl;	
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int x[10][10];
  int a,b,c;
  int yoso[3]={5,9,13};
  int tmp[3][2][13]={{{0,-1,0,1,0},{0,0,1,0,-1}},{{0,-1,-1,-1,0,1,1,1,0},{0,-1,0,1,1,1,0,-1,-1}},{{0,-1,-1,-1,0,1,1,1,0,-2,0,2,0},{0,-1,0,1,1,1,0,-1,-1,0,2,0,-2}}};
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      x[i][j]=0;
    }
  }

  while(scanf("%d,%d,%d",&b,&a,&c)!=EOF){
    c--;
    for(int i=0;i<yoso[c];i++){
      if(a+tmp[c][0][i]>=0&&a+tmp[c][0][i]<10&&b+tmp[c][1][i]>=0&&b+tmp[c][1][i]<10){
	x[a+tmp[c][0][i]][b+tmp[c][1][i]]++;
      }
    }
  }
  int cnt=0,max=0;
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      if(x[i][j]==0)cnt++;
      if(x[i][j]>max)max=x[i][j];
    }
  }
  cout << cnt << endl << max << endl;
}

Measured memory_bytes: 1208
///cREATED bY BERNARB.01
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef priority_queue<int,vector<int>,greater<int>> pqil;
typedef priority_queue<int> pqig;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef priority_queue<pii> pqiig;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<int, int> mii;
#define mid ((l+r)/2)
#define PB push_back
#define PP pop_back
#define PF push_front
#define DF pop_front
#define F first
#define S second
#define MP make_pair
#define C continue
#define B break
#define R return
#define sz(v) (int)(v).size()
#define len(s) (int)(s).length()
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define clr(arr, x) memset((arr), (x), sizeof (arr))
#define loop(n) for(int i=0; i<(n); i++)
#define lop(a, n) for(int i=(a); i<(n); i++)
#define jloop(n) for(ll j=0; j<(n); j++)
#define rloop(n) for(ll i=(n)-1; i>=0; i--)
#define sgm(y) (((y)*((y)+1))/2)
const ll INF = 2e17+423;
const ll mod = 1e9+7; //998244353;
const ld pi = acos(-1.0);
const ld cmpf = 1e-9;
//__int128_t
//      -ASCII-
//a -> z | A -> Z | 0 -> 9
//97 122 | 65  90 | 48  57
#define endl '\n'
ll po(ll,ll);















int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n; cin >> n;
  vi a(n), b(n);
  int p[n];
  loop(n) cin >> a[i];
  loop(n) cin >> b[i];
  loop(n) p[i]=i+1;
  int ii=0;
  do{
    ii++;
    int ans = 0;
    loop(n) if(p[i]==a[i]) ans++;
  if(ans==n) B;
  }while(next_permutation(p, p+n));
  int j = 0;
  sort(p, p+n);
  do{
    j++;
    int ans = 0;
    loop(n) if(p[i]==b[i]) ans++;
  if(ans==n) B;
  }while(next_permutation(p, p+n));
  cout << abs(j-ii);
  R 0;
}
/*

*/




























































ll po(ll x, ll n){
  if(n==0) R 1;
  ll y = po(x, n/2);
  y = ((y)*(y));
  if(n%2) y = (y*(x));
  R y;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String args[]){
		Scanner scr = new Scanner(System.in);
		int t = Integer.parseInt(scr.nextLine());
		for(int step=0; step<t; step++){
			String[] str = scr.nextLine().split(" ", 0);
			int n = Integer.parseInt(str[0]);
			int k = Integer.parseInt(str[1]);
			int[] difs = new int[n-1];
			String[] strs = scr.nextLine().split(" ", 0);
			for(int i=1; i<n; i++){
				difs[i-1] = Integer.parseInt(strs[i]) - Integer.parseInt(strs[i-1]);
			}
			//xs[0] = Integer.MAX_VALUE;
			System.out.println(Setter(k, difs));
        }
		scr.close();
	}
	
	private static int Setter(int k, int[] arr){
		if(k>arr.length) return 0;
		Arrays.sort(arr);
		int len=0;
		for(int i=0; i<=arr.length-k; i++){
			len+=arr[i];
		}
		return len;
	}
	
}

Measured memory_bytes: 83376
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#define INF 1000000000
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	int n, a;
	cin >> n >> a;
	int x[n];
	REP(i, n){
		int p;
		cin >> p;
		x[i] = p - a;
	}
	ll count[n+1][5001] = { };
	REP(i, n) count[0][2500] = 1;
	FOR(i, 1, n+1){
		REP(j, 5001){
			count[i][j] = count[i-1][j] + count[i-1][j - x[i-1]];
		}
	}
	cout << count[n][2500] - 1 << endl;
	return 0;
}


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

int main() {
    ll n, a;
    cin >> n;
    vector<ll> nums;
    for (ll i=0; i<n; i++) {
        cin >> a;
        nums.push_back(a);
    }
    ll tot = 0;
    ll minim = 1000000001;
    ll negs = 0;
    for (ll i=0; i<n; i++) {
        tot+=abs(nums[i]);
        minim = min(minim,abs(nums[i]));
        if (nums[i]<0) negs++;
    }
    if (negs%2==0) cout << tot;
    else cout << tot-2*minim;
    return 0;
}

Measured memory_bytes: 4320
N,K=map(int,input().split())
A=[0]+list(map(int,input().split()))
T={}
T[1]=1
t=1
for i in range(2,K+1):
    a=A[t]
    t=a
    K-=1
    if a in T:
        l=list(T.keys())[T[a]-1:]
        print(l[K%len(l)])
        break
    else:
        T[a]=i
else:
    print(A[t])

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

void print(int *a, int n)
{
    for(int i = 0; i < n; i++)
    {
        if(i > 0)
            cout << " ";
        cout << a[i];
    }
    cout << endl;
}

void insert_sort(int *a, int n)
{
    int i, j, key;

    for(i = 1; i < n; i++)
    {
        key = a[i];

        j = i - 1;
        while(j >= 0 && a[j]>key)
        {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = key;
        print(a, n);
    }
}

int main()
{
    int a[100];
    int n;

    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    print(a, n);
    insert_sort(a,n);
    return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
const int N=5e5+5,mod=1e9+7;
typedef long long ll;
int n,m;
ll f[N],invf[N];
ll C(ll n,ll m)
{
    return f[n]*invf[n-m]%mod*invf[m]%mod;
}
int main()
{
    f[0]=f[1]=invf[0]=invf[1]=1;
    for(int i=2;i<N;i++) f[i]=f[i-1]*i%mod,invf[i]=(mod-mod/i)*invf[mod%i]%mod;
    for(int i=2;i<N;i++) invf[i]=invf[i]*invf[i-1]%mod;
    scanf("%d%d",&n,&m);
    ll ans=0;
    for(int i=0,flag=1;i<=n;i++,flag*=-1)
        ans=(ans+C(m,i)*C(n,i)%mod*C(m-i,n-i)%mod*C(m-i,n-i)%mod*f[n-i]%mod*f[n-i]%mod*f[i]%mod*flag)%mod;
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);
}


Measured memory_bytes: 11620
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(int n)
{
	int count = 0;

	while (n > 0)
	{
		n /= 10;

		count++;
	}
	return count;
}
int digit(int n)
{

	int ans = 0;
	while (n > 0)
	{
		ans += n % 10;
		n /= 10;
	}
	return ans;
}
ll combination(ll n, ll r)
{
	if (r * 2 > n)
		r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i)
	{
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int GCD(int x, int y)
{
	return x ? GCD(y % x, x) : y;
}
vector<int> divisor(int n)
{
	vector<int> value;
	FOR(i, 1, pow(n, 0.5) + 1)
	{
		if (i <= sqrt(n))
		{
			if (n % i == 0)
			{
				value.push_back(i);
				if (i * i != n)
				{
					value.push_back(n / i);
				}
			}
		}
	}
	return value;
}

int main()
{
	int n,p;
	cin >> n>>p;
	int even=0,odd=0;
	rep(i,n){
		int a;
		cin>> a;
		if(a%2==0){
			even++;
		}else{
			odd++;
		}
	}
	ll ans=0;
	rep(i,odd+1){
		if(i%2==0){
		 ans+=combination(odd,i);
		}
	}
	//cout<<ans<<endl;
	ans=ans*pow(2,even);
	if(p==1){
		ans=pow(2,n)-ans;
	}
	cout<<ans<<endl;
	
	
}


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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素


template<typename T> class LazyRMQ {
    T def;                       // 初期値かつ単位元
    function<T(T, T)> operation; // 区間クエリで使う処理

    public:
    int n;
    vector<T> data, lazy;

    LazyRMQ(int m, T _def, function<T(T, T)> _operation)
    : operation(_operation) 
    {
        // 2のべき乗にする
        n = 1;
        while(n < m) n <<= 1;
        def=_def;
        data.assign(2*n-1, def);
        lazy.assign(2*n-1, 0);
    }

    void eval(int k, int kl, int kr){
        if(data[k] == def) data[k] = 0;
        if(lazy[k] == 0) return;
        data[k] += lazy[k];
        if(kr - kl > 1){
            lazy[2*k+1] += lazy[k];
            lazy[2*k+2] += lazy[k];
        }
        lazy[k] = 0;
    }

    // [s,t)
    void add(int s, int t, T x, int k, int kl, int kr){
        eval(k, kl, kr);
        if(kr <= s || t <= kl) return;
        if(s <= kl && kr <= t){
            lazy[k] += x;
            eval(k, kl, kr);
            return;
        }
        int kc = (kl+kr)/2;
        add(s, t, x, 2*k+1, kl, kc);
        add(s, t, x, 2*k+2, kc, kr);
        data[k] = operation(data[2*k+1], data[2*k+2]);
    }

    // [s,t)
    void add(int s, int t, T x) {
        add(s, t, x, 0, 0, n);
    }

    // [s,t)
    T find(int s, int t, int k, int kl, int kr){ // 区間クエリー実行
        eval(k, kl, kr);
        if(kr <= s || t <= kl) return def;
        if(s <= kl && kr <= t) return data[k];
        int kc = (kl+kr)/2;
        T vl = find(s, t, 2*k+1, kl, kc);
        T vr = find(s, t, 2*k+2, kc, kr);
        return operation(vl, vr);
    }

    T find(int s, int t) {
        return find(s, t, 0, 0, n);
    }
};

///////////////////////////// 1-indexed
// 区間クエリ                                                  dif
// 区間ｍinクエリ： [](int a, int b){ return min(a, b); }       INF
// 区間ｍaxクエリ： [](int a, int b){ return max(a, b); }      -INF
// 区間和：        [](int a, int b){ return a + b; }            0
/////////////////////////////

int main(void) {
    int N, K, Q;
    cin >> N >> K >> Q;
    LazyRMQ<int> st(N, 0,
                          [](int a, int b) { return a+b; });
    st.add(1,N+1,K);
    rep(q, Q) {
        int a;
        cin >> a;
        st.add(1  , a ,-1);
        st.add(a+1,N+1,-1);
    }
    rep(i,N){
        if(st.find(i+1,i+2)>0) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 5380
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define rep(i,a,b) for(int i=a;i<b;i++)

void b(int a,int count){
  if(a == 1){
    if(count%5==1) cout <<".";
    else if(count%5==2) cout <<",";
    else if(count%5==3) cout <<"!";
    else if(count%5==4) cout <<"?";
    else if(count%5==0) cout <<" ";

  }
  else if(a == 2){
    if(count%3==1) cout <<"a";
    else if(count%3==2) cout <<"b";
    else if(count%3==0) cout <<"c";
  }
  else if(a == 3){
    if(count%3==1) cout <<"d";
    else if(count%3==2) cout <<"e";
    else if(count%3==0) cout <<"f";
  }
  else if(a == 4){
    if(count%3==1) cout <<"g";
    else if(count%3==2) cout <<"h";
    else if(count%3==0) cout <<"i";
  }
  else if(a == 5){
    if(count%3==1) cout <<"j";
    else if(count%3==2) cout <<"k";
    else if(count%3==0) cout <<"l";
  }
  else if(a == 6){
    if(count%3==1) cout <<"m";
    else if(count%3==2) cout <<"n";
    else if(count%3==0) cout <<"o";
  }
  else if(a == 7){
    if(count%4==1) cout <<"p";
    else if(count%4==2) cout <<"q";
    else if(count%4==3) cout <<"r";
    else if(count%4==0) cout <<"s";
  }
  else if(a == 8){
    if(count%3==1) cout <<"t";
    else if(count%3==2) cout <<"u";
    else if(count%3==0) cout <<"v";
  }
  else if(a == 9){
    if(count%4==1) cout <<"w";
    else if(count%4==2) cout <<"x";
    else if(count%4==3) cout <<"y";
    else if(count%4==0) cout <<"z";
  }
  return;
}


int main(){

  int n;
  cin >> n;

  rep(i,0,n){
    string s;
    cin >> s;

    char pre[] = "0\0";
    pre[0]=s[0];
    int count = 0;
    rep(i,0,s.size()){

      if(pre[0] == s[i]){
	count++;
      }
      else{
	int bo = atoi(pre);
	b(bo,count);
	count=1;
	pre[0]=s[i];
      }
    }
    cout << endl;
  }
  return 0;
}

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

int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int main()
{
   int K,_sum;
   cin >> K;
   _sum = 0;
  
  for(int i = 1; i <= K; i++){
    for(int j = 1; j <= K; j++){
      int ij = gcd(i, j);
      for(int k = 1;k <= K; k++){
        _sum += gcd(ij,k);
      }
    }
  }

   cout << _sum << endl;
   return 0;
}

Measured memory_bytes: 3624
#include <cstdio>

int n,k,a;
long long dp[100001];

int main(){
	while(scanf("%d%d",&n,&k), n != 0){
		for(int i = 0; i <= n; i++) dp[i] = 0;
		for(int i = 1; i <= n; i++){
			scanf("%d",&a);
			dp[i] = dp[i-1] + a;
		}
		long long mx = 0;
		for(int i = 0; i <= n - k; i++){
			long long sum = dp[i+k] - dp[i];
			if(sum > mx){
				mx = sum;
			}
		}
		printf("%lld\n",mx);
	}
	return 0;
}

Measured memory_bytes: 3424
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const N=input[0].split(' ')[0]-0;
  const A=input[1].split(' ').map(e=>{
    return e-0;
  });
  var array=new Array(N);
  A.forEach((e,i)=>{
    array[e-1]=i+1;
  });
  console.log(array.join(' '));
}




//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 46044
def BlueCardsCnt(cards, n):
    for i in range(n):
        s = input()
        cards.setdefault(s, 0)
        cards[s] += 1
    return cards

def RedCardsCnt(cards, m):
    for i in range(m):
        s = input()
        cards.setdefault(s, 0)
        cards[s] -= 1
    return cards

N = int(input())
cards = {}
cards = BlueCardsCnt(cards, N)
M = int(input())
cards = RedCardsCnt(cards, M)

max_v = max(cards.values())

if max_v <=0:
    print(0)
else :
    print(max_v)

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

int main(){
  int n, q, query, t, x;
  cin >> n >> q;
  vector<queue<int>> Q(n);
  for(int i = 0; i < q; i++){
    cin >> query;
    if(query == 0){
      cin >> t >> x;
      Q[t].push(x);
    }else if(query == 1){
      cin >> t;
      if(!Q[t].empty()){
        cout << Q[t].front() << endl;
      }
    }else{
      cin >> t;
      if(!Q[t].empty()){
        Q[t].pop();
      }
    }
  }
  return 0;
}


Measured memory_bytes: 4400
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
#define N 300000
int p[N];
int main(){
  int n;
  for(int i=0;i<N;++i) p[i]=1;
  p[0]=p[1]=0;
  for(int i=2;i<N;++i)
    if(p[i])
      for(int j=2;i*j<N;++j)
	p[i*j]=0;
  while(cin>>n,n){
    int cnt = 0;
    for(int i=n+1;i<=n*2;++i) cnt+=p[i];
    cout << cnt << endl;
  }
  return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    double n, m, d;
    cin >> n >> m >> d;
    if (d == 0)
        cout << OF64 << (m - 1) / n << endl;
    else
        cout << OF64 << 2 * (m - 1) * (n - d) / (n * n) << endl;
    return 0;
}

Measured memory_bytes: 256