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

using namespace std;


#define MAXN 810
typedef pair<int, int> pii;
int h, w, k;
char a[MAXN][MAXN];
int d[MAXN][MAXN];
int dx[4] = {1,  0, -1,  0};
int dy[4] = {0, -1,  0,  1};

int intceil(int a, int b) {
  return a/b + (a%b>0);
}

void bfs(int i, int j) {
  priority_queue<pair<int, pii>, vector<pair<int, pii>>, greater<pair<int, pii>> > pq;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      d[i][j] = 1e9;
    }
  }
  pq.push({0, {i, j}});
  d[i][j] = 0;
  while(!pq.empty()) {
    auto u = pq.top();
    int cost = u.first;
    i = u.second.first;
    j = u.second.second;
    pq.pop();
    if (cost>k-1) break;
    for (int di = 0; di < 4; ++di) {
      int ni = i+dy[di];
      int nj = j+dx[di];
      if (ni<0 || ni>h-1 || nj<0 || nj>w-1) continue;
      if (a[ni][nj]=='#') continue;
      int nc = cost + 1;
      if (d[ni][nj] > nc) {
        d[ni][nj] = nc;
        pq.push({nc, {ni, nj}});
      }
    }
  }
}


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int I, J, ans=MAXN;
  cin >> h >> w >> k;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> a[i][j];
      if (a[i][j]=='S') {
        I = i;
        J = j;
      }
    }
  }
  bfs(I, J);
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      //cout << d[i][j] << " ";
      if (d[i][j]<MAXN) ans = min(ans, intceil(min(min(i, h-1-i), min(j, w-1-j)), k)+1);
    }
    //cout << endl;
  }
  cout << ans << endl;
  return 0;
}


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

template<typename NodeIdx,typename Cost>
bool bellman_ford(vector<tuple<NodeIdx,NodeIdx,Cost>> &graph, vector<Cost> &d,  NodeIdx start_idx){
    using Edge = tuple<NodeIdx,NodeIdx,Cost> ;
    const Cost INF = numeric_limits<Cost>::max();
    std::fill(d.begin(), d.end(), INF );

    d[start_idx] = 0;
    for (int i=0;i<d.size()*2;i++){
        for (const Edge &e : graph){
            if (d[get<0>(e)] != INF && d[get<1>(e)] > d[get<0>(e)] + get<2>(e) ){
                d[get<1>(e)] = d[get<0>(e)] + get<2>(e);
                if (i == d.size()-1) d[get<1>(e)]= INF;
                if (i== d.size()*2-1 && get<1>(e) == d.size()-1) return true;
            }
        }
        
    }
    return false;
    
}

void solve(long long N, long long M, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c){
    vector<tuple<ll,ll,ll>> graph;
    for (ll i=0;i<M;i++){
        graph.push_back(make_tuple(a[i]-1,b[i]-1,-c[i]));
    }
    vector<ll> d(N);
    bool ret = bellman_ford<ll,ll>(graph,d,0);
    if (ret){
        printf("inf\n");
    }else{
        printf("%lld\n",-d.back());
    }

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(M);
    std::vector<long long> b(M);
    std::vector<long long> c(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        scanf("%lld",&c[i]);
    }
    solve(N, M, std::move(a), std::move(b), std::move(c));
    return 0;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#define int128 __int128
#else
#define int128 long long
#endif

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

ll mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}
	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

struct edge {
	ll to, a, b;
};

vector<edge> g[maxn];

ll cc[maxn], dd[maxn];
ll const magic = 300;

unordered_map<ll, ll>d[55];

//map<pair<ll, ll>, ll> d;
set<pair<ll,pair<ll, ll>>> st;

void check(ll u, ll s, ll new_d) {
	if (d[u].find(s) == d[u].end()) {
		d[u][s] = new_d;
		st.insert({ new_d ,{u, s} });
	} else {
		ll old_d = d[u][s];
		if (old_d > new_d) {
			st.erase({ old_d ,{u, s} });
			d[u][s] = new_d;
			st.insert({ new_d ,{u, s} });
		}
	}
}

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	ll n, m, s;
	cin >> n >> m >> s;
	for (ll i = 0; i < m; i++) {
		ll u, v, a, b; cin >> u >> v >> a >> b;
		g[u].push_back({ v, a, b });
		g[v].push_back({ u, a, b });
	}

	for (ll i = 1; i <= n; i++) {
		cin >> cc[i] >> dd[i];
	}

	st.insert({ 0, {1, s} });
	d[1][s] = 0;

	while (!st.empty()) {
		auto p = *st.begin();
		st.erase(st.begin());

		ll rast = p.X;
		ll u = p.Y.X, cur_s = p.Y.Y;
		if (cur_s < s - 5228) {
			continue;
		}

		if (cur_s < 5228) {
			ll v = u, w = dd[u];
			check(v, cur_s + cc[u], rast + dd[u]);
		}

		for (auto e : g[u]) {
			if (e.a <= cur_s) {
				check(e.to, cur_s - e.a, rast + e.b);
			}
		}
	}

	vector<ll> ans(n + 1, LLONG_MAX);

	for (ll i = 2; i <= n; i++) {
		for (auto p : d[i]) {
			ans[i] = min(ans[i], p.Y);
		}
	}

	for (ll i = 2; i <= n; i++) {
		cout << ans[i] << '\n';
	}

	return 0;
}

/*

*/

Measured memory_bytes: 27280
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    N = II()
    A = []
    match = defaultdict(lambda : -1)
    for i in range(N):
        a = deque(map(lambda x: int(x)-1, input().split()))
        match[i] = a[0]
        A.append(a)
    

    ans = 0
    players = deque(range(N))

    matched = True
    while matched and len(players) > 0:
        matched = False
        next_players = deque()
        next_match = defaultdict(lambda : -1)

        for i in players:
            if match[i] == -1:
                continue
            a = A[i]
            j = a[0]
            b = A[j]

            if match[j] == i:
                a.popleft()
                b.popleft()
                matched = True
                match[i] = -1
                match[j] = -1
                if len(a) > 0:
                    next_match[i] = a[0]
                    next_players.append(i)

                if len(b) > 0:
                    next_match[j] = b[0]
                    next_players.append(j)

        players = next_players
        match.update(next_match)
        ans += 1


        
    print(ans if matched and len(next_players)==0 else -1)








    

    ans = 0

    

    
   
main()

Measured memory_bytes: 103300
#include<iostream>
#include<string>
#include<algorithm>
#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main()
{
    int N;
    cin >> N;
    int ans = 1;
    while (ans <= N){
        ans *= 2;
    }
    cout << ans/2 << endl;
    return 0;
}

Measured memory_bytes: 888
#include <stdio.h>
int main(){
  int a=0,b=0,c=0,d=0;
  scanf("%d%d%d",&a,&b,&c);
  if((a>=b)&&(a>=c))d=10*a+b+c;
  if((b>=a)&&(b>=c))d=10*b+a+c;
  if((c>=a)&&(c>=b))d=10*c+a+b;
  printf("%d",d);
  
  return 0;
}

Measured memory_bytes: 128
local PairingHeap={}

PairingHeap.merge=function(self,a,b)
    if not a then
        return b
    elseif not b then
        return a
    elseif a[1]<b[1] then
        b[4]=a[3]
        a[3]=b
        return a
    else
        a[4]=b[3]
        b[3]=a
        return b
    end
end

PairingHeap.twopassmerge=function(self,a)
    local b=a and a[4]
    if b then
        local newnode=b[4]
        a[4]=false
        b[4]=false
        return self:merge(self:merge(a,b),self:twopassmerge(newnode))
    else
        return a
    end
end

PairingHeap.empty=function(self)
    return not self.root
end

PairingHeap.pop=function(self)
    local root=self.root
    local value=root[2]
    self.root=self:twopassmerge(root[3])
    for i=1,4 do
        root[i]=false
    end
    table.insert(self,root)
    return value
end

PairingHeap.push=function(self,key,value)
    local root=self.root
    if root and root[1]<key then
        root[3]={
            key,
            value,
            false,
            root[3],
        }
    else
        self.root={
            key,
            value,
            root,
            false,
        }
    end
end

PairingHeap.join=function(self,other)
    local a=self.root
    local b=other.root
    if a[1]<b[1]then
        b[4]=a[3]
        a[3]=b
    else
        a[4]=b[3]
        b[3]=a
        self.root=b
    end
    return self
end

PairingHeap.new=function(self)
    local obj={}
    setmetatable(obj,{__index=PairingHeap})
    return obj
end

----------

local xyz={io.read("n","n","n")}
local k=io.read("n")
local abc={}
for i=1,3 do
    abc[i]={}
    for j=1,xyz[i] do
        abc[i][j]=io.read("n")
    end
    table.sort(abc[i],function(a,b)
        return a>b
    end)
end

local pq=PairingHeap:new()
local map={}

local frstky=abc[1][1]+abc[2][1]+abc[3][1]
pq:push(-frstky,{1,1,1,frstky})

for i=1,k do
    local pop=pq:pop()
    print(pop[4])
    for j=1,3 do
        if pop[j]<xyz[j] then
            local key=pop[4]-abc[j][pop[j]]+abc[j][pop[j]+1]
            local val={pop[1],pop[2],pop[3],key}
            val[j]=val[j]+1
            local mapkey=table.concat(val," ")
            if not map[mapkey] then
                map[mapkey]=true
                pq:push(-key,val)
            end
        end
    end
end

Measured memory_bytes: 5652
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
string S;
int A,B;
int main() {
	cin>>S;

	int A0,A1,A2,A3;
	int J,O,I;
	int ans=0;
	for(A0=0;A0<S.size();A0=A3){
		for(A1=A0;S[A1]=='J';A1++);
		for(A2=A1;S[A2]=='O';A2++);
		for(A3=A2;S[A3]=='I';A3++);
		J=A1-A0;
		O=A2-A1;
		I=A3-A2;
		if(J>=O&&O<=I)ans=max(ans,O);
	}
	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 3988
N = int(input())
A = list(map(int,input().split()))

d = [0 for k in range(61)]

for e in A:
    t = bin(e)[2:]
    for k in range(len(t)):
        if t[-k-1] == "1":
            d[k] += 1

MOD = 10**9 + 7
ans = 0
for k in range(61):
    ans += (2**k)*d[k]*(N-d[k])
    ans %= MOD
print(ans)


Measured memory_bytes: 122808
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    a, b, t = map(int, input().split())
    ans = 0
    i = 1
    sec = 0
    while sec <= t+0.5:
        ans += b
        sec = a * i
        i += 1
    print(ans-b)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100005];
vector<int> visited(100005,0);
int mod = 1e9 + 7;

pair<long long,long long> dfs(int i){
	long long white = 1;
	long long oneblack = 0;
	visited[i] = 1;
	for(int j = 0 ; j <adj[i].size() ; j++){
		if(visited[adj[i][j]]==0){
			pair<int,int> get =  dfs(adj[i][j]);
			long long mem_white = white;
			white = white*get.first%mod;
			oneblack = ((mem_white*get.second)%mod + (oneblack*(get.first + get.second)%mod)%mod)%mod;
		}
	}
	pair<long long,long long> p = make_pair((white + oneblack)%mod, white);
	return p;
}

int main() {
	int n ;
	cin>>n;
	for(int i =  0 ; i < n-1; i++){
		int x;
		int y;
		cin>>x>>y;
		adj[x-1].push_back(y-1);
		adj[y-1].push_back(x-1);
	}
	pair<long long,long long> a = dfs(0);
	cout<<(a.first + a.second)%mod;
	return 0 ;
}

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

using namespace std;

typedef long long ll;

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

	int n;
	cin >> n;
	ll a, b;
	vector<pair<ll, ll>> v;
	for (int i = 0; i < n; ++i)
	{
		cin >> a >> b;
		v.push_back({a, b});
	}

	vector<vector<ll>> dp(n, vector<ll>(n, -1));
	function<ll(int, int)> f = [&](int i, int j)
	{
		if (i == j)
			return 0LL;

		if (dp[i][j] != -1)
			return dp[i][j];

		ll r = 1LL<<62;
		for (int k = i; k < j; ++k)
			r = min(r, f(i, k)+f(k+1, j)+v[i].first*v[j].second*v[k].second);

		return dp[i][j]=r;
	};

	cout << f(0, n-1) << "\n";

	return 0;
}



Measured memory_bytes: 3248
//Zory-2018
//*******************头文件*******************
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
//*******************全局常量*******************
const int MAXN=210000;
//*******************全局定义*******************
ll q[MAXN],w[MAXN];
ll bin[35];
int n;
//*******************实现*******************
/*
debug
bool cmp(ll a,ll b)
{
	return (a%bin[f+1])<(b%bin[f+1]);
}*/
//*******************主函数*******************
ll w2[MAXN];
int main()
{
	bin[0]=1;for(int i=1;i<=32;i++) bin[i]=bin[i-1]<<1;

	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&q[i]);
	for(int i=1;i<=n;i++) scanf("%lld",&w[i]);

	ll ans=0;
	for(int f=0;f<=29;f++)
	{
		for(int i=1;i<=n;i++) w2[i]=w[i]%bin[f+1];
        sort(w2+1,w2+1+n);

		ll t=0;
		for(int i=1;i<=n;i++)
		{
			ll now=q[i]%bin[f+1],ss=0;
			ll l,r;
			int bf;

			l=bin[f];r=bin[f+1]-1;
            l=lower_bound(w2+1,w2+n+1,l-now)-w2;
            r=upper_bound(w2+1,w2+n+1,r-now)-w2-1;
			bf=r-l+1;if(bf>0) ss+=bf;

			l=bin[f+1]+bin[f];r=bin[f+2]-1;
            l=lower_bound(w2+1,w2+n+1,l-now)-w2;
            r=upper_bound(w2+1,w2+n+1,r-now)-w2-1;
			bf=r-l+1;if(bf>0) ss+=bf;

			t=(t+ (ss&1) )&1;
		}
		ans+=(t<<f);
	}
	printf("%lld",ans);
}


Measured memory_bytes: 4864
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using Int = int64_t;
const Int INF = 1<<30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int n; cin >> n;
    map<string, int> mp;
    vector<string> name = {"AC", "WA", "TLE", "RE"};
    for(int i = 0; i < n; i++)
    {
        string s; cin >> s;
        mp[s]++;
    }
    for(auto x : name)
    {
        cout << x << " x " << mp[x] << endl;
    }
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

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

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int N; cin >> N;

    vector<int> d(N);
    rep(i,N) cin >> d[i];

    sort(d.begin(), d.end());

    cout << d[N / 2] - d[N / 2 - 1] << endl;

    return 0;
}


Measured memory_bytes: 640
import Control.Applicative
 
main = do
  [w, h, x, y, r] <- (map stoi . words) <$> getLine
  putStrLn (if x + r > w || x - r < 0 || y + r > h || y - r < 0 then "No" else "Yes")
 
stoi :: String -> Int
stoi str = read str :: Int

Measured memory_bytes: 3604
from math import ceil
N,H = map(int,input().split())
katana = []
for i in range(N):
    a,b = map(int,input().split())
    katana.append((a,'a'))
    katana.append((b,'b'))
katana.sort()
katana.reverse()
damage = 0
ans = 0
i = 0
while damage < H:
    if katana[i][1] == 'b':
        ans += 1
        damage += katana[i][0]
        i += 1
    else:
        ans += ceil((H-damage)/katana[i][0])
        break

print(ans)

Measured memory_bytes: 24460
#include <iostream>
#include <string>
using namespace std;
int main() {
	int m = 100000, n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		m *= 1.05;
		if(m%1000)
			m += 1000 - m % 1000;
	}
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e3;
const lli INF = 1e18;
const lli MOD = 1e9+7;

vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	vi m(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}


lli SUM(lli a, lli b, lli mod=MOD){
	return (a+b+mod)%mod;
}

lli PROD(lli a, lli b, lli mod=MOD){
	a%=mod; b%=mod;
	return a*b % mod;
}

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

vvi graph(int n, int m){
	vvi v(n+1);
	fore(i,0,m){
		int a,b; cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	return v;
}

// ---- コーディングはここから！ ('-')7

void solve(){
	int n,mod; cin>>n>>mod;
	vvi v=graph(n,n-1);
	vl dp(n+1,1);
	auto f=[&](auto f, int u, int pr)->void{
		for(auto i:v[u])if(i!=pr)f(f,i,u);
		for(auto i:v[u])if(i!=pr)dp[u] = PROD(dp[u],dp[i]+1,mod);
	};
	f(f,1,1);
	auto g=[&](auto g, int u, int pr, lli up)->void{
		vl pre(1,1),post(1,1);
		for(auto i:v[u])if(i!=pr)pre.pb(PROD(pre.back(),dp[i]+1,mod));
		for(int j = sz(v[u])-1;j>=0; j--){
			int i = v[u][j];
			if(i!=pr)post.pb(PROD(post.back(),dp[i]+1,mod));
		}
		reverse(all(post));
		dp[u]= PROD(dp[u],up,mod);
		int j = 0;
		for(auto i:v[u])
			if(i!=pr){
				g(g,i,u,SUM(PROD(PROD(pre[j],post[j+1],mod),up,mod),1,mod));
				j++;
		}
	};
	g(g,1,1,1);
	fore(i,1,n+1)cout<<dp[i]<<ENDL;

}

int main(){_
	//int t; cin>>t; while(t--)
	solve();
}


Measured memory_bytes: 28744
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>

using namespace std;

int main()
{
    int n,m,x,d;
    while(~scanf("%d%d%d",&n,&m,&x))
    {
        int s[105];
        for(int i=0;i<n;i++)
        {
            s[i]=0;
        }
        for(int i=0;i<m;i++)
        {
            scanf("%d",&d);
            s[d-1]=1;
        }
        int c1=0,c2=0;
        for(int i=x-1;i<n;i++)
        {
            c1=c1+s[i];
        }
        for(int i=x-1;i>=0;i--)
        {
            c2=c2+s[i];
        }
        printf("%d\n",c1<=c2?c1:c2);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(int i=a; i<=b; ++i)

/// easy access -------------
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
typedef pair<int,int> pi;
typedef tuple<bool, int, int> tp;
typedef vector<vector<int>> vv;
///-------------------------
vector<vector<int>> adj;
int n;


int main()
{
    Phuong_; /// <3333
    int n;
    cin >> n;
    cout << !n;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int ans,n,a[25];
signed main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1,x;i<=n;i++) scanf("%d",&x),ans+=max(0,a[i]-x);
	printf("%d",ans);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] p = new int[n];
		for(int i=0; i<n; i++) {
			p[i] = sc.nextInt();
		}
		sc.close();
		int count = 0;
		for(int i=0; i<n; i++) {
			if(p[i] != i+1) continue;
			if(i<n-1 && p[i+1]==i+2) {
				count++;
				swap(p, i, i+1);
				i++;
			} else if(i>0) {
				count++;
				swap(p, i-1, i);
			} else {
				count++;
				swap(p, i, i+1);
			}
		} 
		System.out.println(count);
	}
	
	static void swap(int[] p, int a, int b) {
		int tmp = p[a];
		p[a] = p[b];
		p[b] = tmp;
	}

}

Measured memory_bytes: 48752
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef string::size_type sz;
struct loca
{
    sz be,ed,len;
};
typedef vector<loca>::size_type vsz;
int couterhappy(const string& a)
{
    if(a.size()==0||a.size()==1)
    {
        return 0;
    }
    int sum=0;
    for(sz i=1;i!=a.size()-1;i++)
    {
        if((a[i]=='L'&&a[i-1]==a[i])||(a[i]=='R'&&a[i+1]==a[i]))
        {
            sum++;
        }
    }
    if(a[0]=='R'&&a[1]=='R')
    {
        sum++;
    }
    if(a[a.size()-1]=='L'&&a[a.size()-2]=='L')
    {
        sum++;
    }
    return sum;
}
void myrever(string& s,const loca& a,char c)
{
    for(sz i=a.be;i<=a.ed;i++)
    {
        s[i]=c;
    }
}
bool mycomp(const loca& left,const loca& right)
{
    return (left.len>right.len)?true:false;
}
bool mycomp2(const loca& left,const loca& right)
{
    return (left.len<right.len)?true:false;
}
int main(int argc, const char** argv) 
{
    int n,changetime;
    string target,Lt,Rt,Lt2,Rt2,Lt3,Rt3;
    cin>>n>>changetime;
    cin>>target;
    Lt=target,Rt=target,Lt2=target,Rt2=target,Lt3=target,Rt3=target;
    vector<loca> Linter,Rinter,Linter2,Rinter2,Linter3,Rinter3;
    loca temp;
    sz i=0,j=i;
    while (j!=n&&i!=n)
    {
        j=i;
        temp.be=i;
        while(target[i]==target[j]&&j!=n)
        {
            j++;
        }
        temp.ed=j-1;
        temp.len=temp.ed-temp.be;
        if(target[i]=='L')
        {
            Linter.push_back(temp);
        }
        else
        {
            Rinter.push_back(temp);
        }
        i=j;
    }
    if(Linter.size()<=changetime||Rinter.size()<=changetime)
    {
        cout<<(n-1);
        return 0;
    }
    Linter2=Linter,Rinter2=Rinter,Linter3=Linter,Rinter3=Rinter;
    sort(Linter.begin(),Linter.end(),mycomp);
    sort(Rinter.begin(),Rinter.end(),mycomp);
    sort(Linter2.begin(),Linter2.end(),mycomp2);
    sort(Rinter2.begin(),Rinter2.end(),mycomp2);
    for(vsz i=0;i!=changetime;i++)
    {
        myrever(Lt,Rinter[i],'L');
        myrever(Rt,Linter[i],'R');
        myrever(Lt2,Rinter2[i],'L');
        myrever(Rt2,Linter2[i],'R');
        myrever(Lt3,Rinter3[i],'L');
        myrever(Rt3,Linter3[i],'R');
    }
    int sum[6]={couterhappy(Lt),couterhappy(Rt),couterhappy(Lt2),couterhappy(Rt2),couterhappy(Lt3),couterhappy(Rt3)};
    sort(sum,sum+6);
    cout<<sum[5];
    return 0;
}


Measured memory_bytes: 10544
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define MN 100005
using namespace std;
inline int in(){
    int x=0;bool f=0; char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
int st[MN],sum[MN],a[MN],b[MN],pos[MN],dif[MN];
int n,top,mx,cnt,cur;
ll res,ans[MN];
int main()
{
	n=in();top=0;st[top]=0;
	for (int i=1;i<=n;++i) a[i]=b[i]=in();b[n+1]=0x7fffffff;
	for (int i=1;i<=n;++i) if (!top||a[i]>a[st[top]]) st[++top]=i;
	sort(b+1,b+n+1);cnt=unique(b+1,b+n+1)-b-1;b[cnt+1]=0x7fffffff;
	for (int i=1;i<=n;++i) pos[i]=lower_bound(b+1,b+cnt+1,a[i])-b,++sum[pos[i]],mx=max(mx,pos[i]);
	for (int i=1;i<=cnt;++i) dif[i]=b[i]-b[i-1];
	for (int i=mx;i>=0;--i){
		sum[i]+=sum[i+1];res=1ll*dif[i]*sum[i];
		if (pos[st[top]]==i) cur=st[top],--top;ans[cur]+=res;
	}ans[1]+=ans[0]; 
	for (int i=1;i<=n;++i) printf("%lld\n",ans[i]);return 0;
}

Measured memory_bytes: 4096
#include <iostream>

using namespace std;

int main() {
  int a, b;
  string op;
  
  while(1) {
      cin >> a >> op >> b;
      if(op.compare("?") == 0) break;
      
      if(op.compare("+") == 0) {
          cout << a + b << endl;
      } else if(op.compare("-") == 0) {
          cout << a - b << endl;
      } else if(op.compare("*") == 0) {
          cout << a * b << endl;
      } else if(op.compare("/") == 0) {
          cout << a / b << endl;
      }
  }

  return 0;
}



Measured memory_bytes: 3160
#include<stdio.h>
  #include<iostream>
  #include<algorithm>
  #define N 2

  using namespace std;
  void output_array_int(int*,int,char);
  void input_array_int(int*,int);

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

  int main(){
    int a,b;
    cin>>a>>b;

    cout<<a/b<<" "<<a%b<<" ";
    printf("%.5f\n",(double)a/(double)b);
    return 0;
  }

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

  void output_array_int(int * a,int n,char ch){
    int i;

    for(i=0;i<n;i++){
      cout<<*(a+i);
      if(i<(n-1)){
        cout<<ch;
      }
    }

    cout<<endl;

    return;
  }

  void input_array_int(int *a,int n){
    int i;

    for(i=0;i<n;i++){
      cin>>*(a+i);
    }
  }

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


void prs(int a){
  /*a個の#を出力*/
  for (int i=0;i<a;i++){
    cout << '#';
  }
  cout << endl;
}

int main(){
  int h,w;
  cin >> h >> w;
  prs(w+2);
  for (int i=0;i<h;i++){
    string s;
    cin >> s;
    cout << '#' << s << '#' << endl;
  }
  prs(w+2);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int a[101];
bool dp[100001];
int main(){
    int N;
    cin>>N;
    REP(i,N){
        cin>>a[i];
    }
    REP(i,100001){
        dp[i]=false;
    }
    dp[0]=true;
    REP(i,N){
        for(int j=50000;j>=0;j--){
            if(dp[j]==true){
               dp[j+a[i]]=true;
            }
        }
    }
    int ans=0;
    REP(i,100001){
        if(i%10==0)continue;
        if(dp[i]==true)ans=i;
    }
    cout<<ans<<endl;
    return(0);
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);
    
    
    while (in.hasNext()) {
      String S = in.next();
      String T = in.next();
      boolean rotationEqual = false;

      for (int i = 0; i < S.length(); ++i) {
        if (T.equals(S.substring(i) + S.substring(0, i))) {
          rotationEqual = true;
          break;
        }
      }

      if (rotationEqual) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    }
  }
}

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

int main(void) {
  char str[1001];
  int q;
  scanf("%s %d", str, &q);

  for (int i=0; i<q; i++) {
    char m[10];
    int a, b, j, k;
    scanf("%s %d %d", m, &a, &b);

    if (strcmp(m, "replace")==0) {
      char p[b-a+2];
      scanf("%s", p);

      for (j=a, k=0; j<=b; j++) {
        str[j]=p[k++];
      }
    }

    if (strcmp(m, "reverse")==0) {
      char tmp[1001];
      
      for (j=a, k=0; j<=b; j++) {
        tmp[k++]=str[j];
      }
      tmp[k--]='\0';

      for (j=a; j<b+1; j++) {
        str[j]=tmp[k--];
      }
    }

    if (strcmp(m, "print")==0) {
      for (int i=a; i<=b; i++) {
        printf("%c", str[i]);
      }
      printf("\n");
    }
  }
  return 0;
}


Measured memory_bytes: 2104
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

void solve(int D, int G, vector<int> p, vector<int> c) {
  int ans = 1e9;
  for (int mask = 0; mask < (1 << D); mask++) {
    int s = 0;
    int num = 0;
    int rest_max = -1;
    for (int i = 0; i < D; i++) {
      if (mask >> i & 1) {
        s += 100 * (i + 1) * p[i] + c[i];
        num += p[i];
      } else {
        rest_max = i;
      }
    }
    if (s < G) {
      int s1 = 100 * (rest_max + 1);
      int need = (G - s + s1 - 1) / s1;
      if (need >= p[rest_max]) {
        continue;
      }
      num += need;
    }
    ans = min(ans, num);
  }
  printf("%d\n", ans);
}

int main() {
  int D, G;
  cin >> D >> G;
  vector<int> p(11);
  vector<int> c(11);
  for (int i = 0; i < D; i++) {
    cin >> p[i] >> c[i];
  }
  solve(D, G, p, c);
  return 0;
}


Measured memory_bytes: 256
/// In The Name Of God

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <stdio.h>
#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

using namespace std;

int n;
int a[N], b[N];

vector <int> st;
ll ans;
int get(int l, int r) {
	return upper_bound(all(st), r) - lower_bound(all(st), l);
}
void solve(int k) {
	int m1 = (1 << k), m2 = m1 << 1;
	for (int i = 1; i <= n; i++) {
		st[i - 1] = a[i] & (m2 - 1);
	}
	sort(all(st));
	ll cnt = 0;
	for (int i = 1; i <= n; i++) {
		int cur = b[i] & (m2 - 1);
		cnt += get(m1 - cur, m2 - cur - 1);
		cnt += get(m1 + m2 - cur, m2 << 1);
	}
	if (cnt & 1) ans += m1;
}
int main() {
	#ifdef IOI2018
		freopen ("in.txt", "r", stdin);
	#endif
	scanf ("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf ("%d", &a[i]);
	}
	for (int i = 1; i <= n; i++) {
		scanf ("%d", &b[i]);
	}
	st.resize(n);
	for (int i = 0; i < 29; i++) {
		solve(i);
	}
	printf ("%lld\n", ans);
	ioi
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>
#include <set>
#include <queue>
#include <bitset>
#include <cassert>

using namespace std;

const int MOD = 1000000007;

template<int MOD>
struct MINT {
    long long val;

    constexpr MINT(long long v = 0) noexcept: val(v % MOD) {
        if (val < 0) val += MOD;
    }

    constexpr int getmod() { return MOD; }

    constexpr MINT operator-() const noexcept {
        return val ? MOD - val : 0;
    }

    constexpr MINT operator+(const MINT &r) const noexcept { return MINT(*this) += r; }

    constexpr MINT operator-(const MINT &r) const noexcept { return MINT(*this) -= r; }

    constexpr MINT operator*(const MINT &r) const noexcept { return MINT(*this) *= r; }

    constexpr MINT operator/(const MINT &r) const noexcept { return MINT(*this) /= r; }

    constexpr MINT &operator+=(const MINT &r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }

    constexpr MINT &operator-=(const MINT &r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }

    constexpr MINT &operator*=(const MINT &r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }

    constexpr MINT &operator/=(const MINT &r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }

    constexpr bool operator==(const MINT &r) const noexcept {
        return this->val == r.val;
    }

    constexpr bool operator!=(const MINT &r) const noexcept {
        return this->val != r.val;
    }

    friend constexpr ostream &operator<<(ostream &os, const MINT<MOD> &x) noexcept {
        return os << x.val;
    }

    friend constexpr MINT<MOD> modpow(const MINT<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};


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

    using mint = MINT<MOD>;

    mint res = 0;
    vector<mint> vs;
    mint AA = 0;
    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        mint m = A;
        vs.push_back(m);
        AA = AA + A;
    }

    for (int i = 0; i < N - 1; ++i) {

        AA = AA - vs[i];
        mint tmp = vs[i] * AA;
        res = res + tmp;
    }
    cout << res << endl;
}


Measured memory_bytes: 5364
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let s = read::<String>();
  let mut cost = 700;
  for i in s.chars() {
    if i == 'o' {
      cost += 100;
    }
  }

  println!("{}", cost);

}



Measured memory_bytes: 4352
#include <bits/stdc++.h> 
using namespace std;
#define ll long long
int main()
{
    int n,ac=0,wa=0,re=0,tle=0;
    cin>>n;
    string str[n];
    for(int i=0;i<n;i++)
    {
        cin>>str[i];
    }
    for(int i=0;i<n;i++)
    {
        if(str[i]=="AC")ac++;
        else if(str[i]=="TLE")tle++;
        else if(str[i]=="WA")wa++;
        else if(str[i]=="RE")re++;
    }
        cout<<"AC x "<<ac<<endl;
        cout<<"WA x "<<wa<<endl;
        cout<<"TLE x "<<tle<<endl;
        cout<<"RE x "<<re<<endl;
}

Measured memory_bytes: 6752
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int n, m;
  cin >> n >> m;
  auto x = vector<int>(n);
  auto y = vector<int>(m);
  REP(i, n) cin >> x[i];
  REP(i, m) cin >> y[i];

  ll sum_x = 0;
  ll sum_y = 0;
  REP(i, n - 1) {
    ll left = i + 1;
    ll right = n - left;
    ll tmp = left * right;
    tmp %= MOD;
    tmp *= x[i + 1] - x[i];
    tmp %= MOD;
    sum_x += tmp;
    sum_x %= MOD;
  }
  REP(i, m - 1) {
    ll left = i + 1;
    ll right = m - left;
    ll tmp = left * right;
    tmp %= MOD;
    tmp *= y[i + 1] - y[i];
    tmp %= MOD;
    sum_y += tmp;
    sum_y %= MOD;
  }

  ll ans = sum_x * sum_y % MOD;

  cout << ans << endl;
}


Measured memory_bytes: 1024
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main(){
    fast;
    ll a,k; cin>>a>>k;
    pq<ll, vec<ll>, less<ll>> p;
    for(int q=0; q<a; q++){
        ll z; cin>>z;
        p.push(z);
    }
    for(; k; k--){
        ll c = p.top(); p.pop();
        c>>=1;
        p.push(c);
    }
    ll o =0 ;
    for(; p.size(); p.pop()) o+=p.top();
    cout<<o;
}

Measured memory_bytes: 1400
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	k = readline() |> parseInt
	x = div(k,50)
	y = k%50
	a = Int[i-1 for i in 1:50]
	a.+= x
	for i in 1:y
		a[i] += 51
	end
	a.-=y
	println(50)
	for i in 1:49
		print(a[i], " ")
	end
	println(a[50])
end
main()


Measured memory_bytes: 111736
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int P = scan.nextInt();
		int e = 0;
		int o = 0;
		for (int i = 0; i < N; i++) {
			int z = scan.nextInt();
			if (z % 2 == 0) {
				e++;
			} else {
				o++;
			}
		}
		if (o == 0) {
			if (P == 0) {
				BigInteger a = new BigInteger("2");
				a = a.pow((e + o));
				System.out.println(a.toString());
			} else {
				System.out.println("0");
			}
		} else {
			if (P == 0) {
				BigInteger a = new BigInteger("2");
				a = a.pow((e + o - 1));
				System.out.println(a.toString());
			} else {
				BigInteger a = new BigInteger("2");
				a = a.pow((e + o - 1));
				BigInteger b = new BigInteger("2");
				b = b.pow(N);
				b = b.subtract(a);
				System.out.println(b.toString());
			}
		}
	}

}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	string s;
	ll ans;

	cin >> s;

	ans = s.size();

	REP(i, s.size() - 1) {
		if (s[i] != s[i + 1]) {
			ll x = max((ll)(i + 1), (ll)(s.size() - i - 1));
			if (x < ans) {
				ans = x;
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 512
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

const MOD = 2019;

// 1ms(AC)
// [L, R] を全探索するが、余り 0 が見つかったら探索を打ち切る
// R-L >= 2019 のとき、余り 0 となるような値が必ず存在する => 探索範囲の上限は 2019^2 個まで
long calc1(long L, long R) {
    long ans = int.max;
    for (long i = L; i <= R; i++) {
        for (long j = i + 1; j <= R; j++) {
            ans = min(ans, i * j % MOD);
            if (ans == 0) goto END;
        }
    }
END:
    return ans;
}

// i * j mod 2019
// = (i mod 2019) * (j mod 2019) mod 2019
// なので [0, 2019) の範囲を調べるだけでよい
long calc2(long L, long R) {
    long ans = int.max;
    int[int] i_used;
    foreach (i; L..R+1) {
        if (i_used[i % MOD]++) break;

        int[int] j_used;
        foreach (j; i+1..R+1) {
            if (j_used[j % MOD]++) break;

            ans = min(ans, i * j % MOD);
        }
    }
    return ans;
}

void main() {
    int L, R; scan(L, R);
    writeln(calc2(L, R));
}


Measured memory_bytes: 55292
#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 = 1000000007;

ll powmod(ll x, ll y) {
  ll res = 1;
  rep(i, y) res = res * x % mod;
  return res;
}

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

  ll ans = powmod(10, N) - powmod(9, N) - powmod(9, N) + powmod(8, N);
  ans %= mod;
  ans = (ans + mod) % mod;
  cout << ans << endl;
}

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

int main()
{
    string a;
    int l,aa[5]={0};
    while((cin>>a)!=0){
    	l=a.size();
	if(a[l-1]=='O')aa[3]++;
	else if(a[l-1]=='A')aa[0]++;
	else if(a[l-1]=='B'){
	    if(a[l-2]=='A')aa[2]++;
	    else aa[1]++;
	}
    }   
    cout<<aa[0]<<endl<<aa[1]<<endl<<aa[2]<<endl<<aa[3]<<endl;
    return 0;
}

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

#define InverseColor(color) (color) == '0' ? '1' : '0'

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

    char prevColor1 = colors[0] == '0' ? '1' : '0';
    char prevColor2 = colors[0];
    int count1 = 0;
    int count2 = 0;
    for (auto& color : colors)
    {
        if (color == prevColor1)
        {
            prevColor1 = InverseColor(color);
            count1++;
        }
        else
        {
            prevColor1 = color;
        }

        if (color == prevColor2)
        {
            prevColor2 = InverseColor(color);
            count2++;
        }
        else
        {
            prevColor2 = color;
        }
    }

    cout << min(count1, count2) << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>

int main()
{
	std::string weather[] = { "Sunny", "Cloudy", "Rainy" };
	std::string S, ans;

	std::cin >> S;
	if (S == weather[0])
	{
		ans = weather[1];
	}
	else if (S == weather[1])
	{
		ans = weather[2];
	}else
	{
		ans = weather[0];
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	string s=to_string(n);
	ll ssize=s.size();
	if(s.size()>=6)
	{
	    cout<<(90000+900+10-1);
	}
	else if(ssize>=5)
	{
		cout<<(910+(n-9999))-1;
	}
	else if(ssize>=4)
	{
		cout<<(910-1);
	}
	else if(ssize>=3)
	{
		cout<<(9+(n-99));
	}
	else if(ssize>=2)
	{
		cout<<9;
	}
	else
	{
		cout<<(n);
	}
    return 0;
}


//252908XL

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
#include <set>

long long int gcd(const long long int a, const long long int b) {
	switch (b) {
	case 0: return a;
	default: return gcd(b, a % b);
	}
}
long long int lcm(const long long int a, const long long int b) {
	return a / gcd(a, b) * b;
}
int main() {
	int n; std::cin >> n;
	long long int result = 1;
	for (auto i = 0; i < n; ++i) {
		long long int time; std::cin >> time;
		result = lcm(result, time);
	}
	std::cout << result << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N,K;
  cin >> N >> K;
  ll ans = 0;
  if (K % 2 == 0) {
    ll a = N/K;
    ans += a * a * a;
    ll b;
    ll now;
    for (int i = 0; i < 500000; i++) {
      if (i == 0) {
        now += K/2;
      } else {
        now += K;
      }
      if (now > N) {
        b = i;
        break;
      }
    }
    ans += b * b * b;
  } else {
    ll a = N/K;
    ans += a * a * a;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596