akhauriyash/Code-Regression huggingface dataset:
import math
import random
class Prime:
    seed_primes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
    def is_prime(self,n):
        is_prime_common=self.is_prime_common(n)
        if is_prime_common is not None:return is_prime_common
        if n<2000000:return self.is_prime_brute_force(n)
        return self.is_prime_miller_rabin(n)
    def is_prime_common(self,n):
        if n==1:return False
        if n in Prime.seed_primes:return True
        if any(map(lambda x:n%x==0,self.seed_primes)):return False
    def is_prime_brute_force(self,n):
        for k in range(2,int(math.sqrt(n))+1):
            if n%k==0:return False
        return True
    def is_prime_miller_rabin(self,n):
        d=n-1
        while d&1==0:d>>=1
        witnesses=self.get_witnesses(n)
        for w in witnesses:
            y=pow(w,d,n)
            while d!=n-1and y!=1and y!=n-1:
                y=y*y%n
                d<<=1
            if y!=n-1and d&1==0:return False
        return True
    def get_witnesses(self,num):
        def _get_range(num):
            if num<2047:return 1
            if num<1373653:return 2
            if num<25326001:return 3
            if num<3215031751:return 4
            if num<2152302898747:return 5
            if num<3474749660383:return 6
            if num<341550071728321:return 7
            if num<3825123056546413051:return 9
            return 12
        return self.seed_primes[:_get_range(num)]
    def gcd(self,a,b):
        if a<b:return self.gcd(b,a)
        if b==0:return a
        while b:a,b=b,a%b
        return a
    @staticmethod
    def f(x,n,seed):
        p=Prime.seed_primes[seed%len(Prime.seed_primes)]
        return(p*x+seed)%n
    def find_factor(self,n,seed=1):
        if self.is_prime(n):return n
        x,y,d=2,2,1
        count=0
        while d==1:
            count+=1
            x=self.f(x,n,seed)
            y=self.f(self.f(y,n,seed),n,seed)
            d=self.gcd(abs(x-y),n)
        if d==n:
            return self.find_factor(n,seed+1)
        return self.find_factor(d)
    # nのすべての素因数を見つける
    def find_factors(self,n):
        primes={}
        if self.is_prime(n):
            primes[n]=1
            return primes
        while n>1:
            factor=self.find_factor(n)
            primes.setdefault(factor,0)
            primes[factor]+=1
            n//=factor
        return primes
class Factorial:
    def __init__(self,n,mod):
        self.f=[1]
        for i in range(1,n+1):
            self.f.append(self.f[-1]*i%mod)
        self.i=[pow(self.f[-1],mod-2,mod)]
        for i in range(1,n+1)[::-1]:
            self.i.append(self.i[-1]*i%mod)
        self.i.reverse()
    def factorial(self,i):
        return self.f[i]
    def ifactorial(self,i):
        return self.i[i]
    def comb(self,n,k):
        return self.f[n]*self.i[n-k]%mod*self.i[k]%mod
mod=10**9+7
n,m=map(int,input().split())
*d,=Prime().find_factors(m).values()
if d:f=Factorial(n+max(d),mod)
ans=1
for t in d:
    ans=ans*f.comb(n-1+t,t)%mod
print(ans)

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

float calc(float seg1, float seg2, float v, float time, float end) {
	float res = time;
	res = min(res, end-time);
	if (seg1 <= time && time <= seg2){
		res = min(res, v);
	} else if (seg1 > time) {
		res = min(res, v + (seg1-time));
	} else {
		res = min(res, v + (time-seg2));
	}
	//res = max(res, (float) 0);
	return res;
}

int main() {
	int n; cin >> n;
	vector<int> t(n);
	int total = 0;
	vector<pair<int, int> > time_cum(n);
	for (int i = 0; i < n; ++i) {
		cin >> t[i];
		time_cum[i] = make_pair(total, total+t[i]);
		total += t[i];
	}
	vector<int> v(n);
	for (int i = 0; i < n; ++i) cin >> v[i];
	vector<float> maxspeed(2*total+1, (float) 1000);
	for (float i = 0; i <= total; i += 0.5)
	{
		int j = (int) (i*2);
		for (int k = 0; k < n; ++k)
		{
			float res = calc((float) time_cum[k].first, (float) time_cum[k].second, (float) v[k], i, (float) total);
			maxspeed[j] = min(maxspeed[j], res);
		}
		//cout << maxspeed[j] << endl;
	}

	float ans = 0;
	for (int i = 0; i < 2*total; ++i)
	{
		ans += (maxspeed[i] + maxspeed[i+1]) / 4.0;
	}
	cout << std::setprecision(12) << ans << endl;
	return 0;
}

Measured memory_bytes: 384
object Main {
  def main(args: Array[String]): Unit = {
    val cells       = io.StdIn.readLine().split(" ").map{_.toInt}
    val brack_cells = io.StdIn.readLine().split(" ").map{_.toInt}
    println((cells(0) - brack_cells(0))*(cells(1) - brack_cells(1)))
  }
}

Measured memory_bytes: 25416
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) {
        FastScanner in = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int x = in.nextInt();
        out.println((x==0)?"1":"0");
        out.flush();
	}
	
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		
		String next() {
			while(!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				}catch(IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] readArray(int n) {
			int a[] = new int[n];
			for(int i=0;i<n;i++) a[i] = nextInt();
			return a;
		}
		
		Integer[] readArray(long n) {
		    Integer a[] = new Integer[(int)n];
			for(int i=0;i<n;i++) a[i] = nextInt();
			return a;
		}
		
		long[] readArray(int n,long x) {
			long a[] = new long[n];
			for(int i=0;i<n;i++) a[i] = nextLong();
			return a;
		}
		
	}
	
	static class Pair implements Comparable<Pair> {
		int x, y;
		Pair(int a, int b){ x = a; y = b; }
		int getKey() { return x; }
		int getVal() { return y; }
		@Override
		public int compareTo(Pair o) {
			if(o.getVal() - this.getVal()>0)
				return -1;
			else if(o.getVal() - this.getVal()<0)
				return 1;
			else 
				return 0;
		}
		
	}
	
	static boolean arrayEquals(char a[], char b[]) {
		int n = a.length;
		boolean verdict = true;
		for(int i=0;i<n;i++) {
			if(a[i]!=b[i]) {
				verdict = false;break;
			}
		}
		return verdict;
	}
	
	static long lcm(long a, long b) {
		return (a*b)/gcd(a,b);
	}
	
	static long gcd(long a, long b) {
		if(b==0) return a;
		else return gcd(b,a%b);
	}
	
	static long hashInt(int x,int y) {
		return x*(1_000_000_000L)+y;
	}
}



Measured memory_bytes: 32712
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,q;
  cin>>n>>q;
  stack<int> st[n];
  rep(i,q){
    int num,t,x;
    cin>>num>>t;
    if(num==0){
      cin>>x;
      st[t].push(x);
    }else if(num==1){
      if(st[t].size() ) cout<<st[t].top()<<endl;
    }else{
      if(st[t].size()!=0 )st[t].pop();
    }
  }

  return 0;
}



Measured memory_bytes: 4980
#define _USE_MATH_DEFINES
#define MAX_N 1000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

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

static const double eps = 1e-8;

int main(){
	char name[32];
	int am,pm;
	while(~scanf("%s %d %d",name,&am,&pm)){
		printf("%s %d %d\n",name,am+pm,am*200+pm*300);
	}
}

Measured memory_bytes: 0
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, 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, insort, insort_left
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(str, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
from decimal import *
 
K = INT()

q = deque(list(range(1, 10)))

for i in range(K):
    n = q.popleft()
    r = n%10

    if r != 0:
        q.append(10*n + r-1)

    q.append(10*n + r)

    if r != 9:
        q.append(10*n + r+1)

print(n)

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

using namespace std;


int main()
{
	int N;
	cin >> N;
	vector<int> L(N);
	for (int i = 0; i < N; i++)
	{
		cin >> L[i];
	}
	sort(L.begin(), L.end());

	/*cout << endl;
	for (auto it : L)
	{
		cout << it << " ";
	}
	cout << endl;*/

	int answer = 0;

	for (int i = 0; i < N - 2; i++)
	{
		for (int j = i + 1; j < N - 1; j++)
		{
			for (int k = j + 1; k < N; k++)
			{
				if (L[k] >= L[i] + L[j])
				{
					//cout << L[k] << ">=" << L[i] << " + " << L[j] << " ! break;" << endl;
					break;
				}

				//cout << L[k] << "<" << L[i] << " + " << L[j] << " ! countUP;" << endl;
				answer++;
			}
		}
		
	}

	cout << answer << endl;



	return 0;
}

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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()


void solve(long long N, std::vector<long long> L){
    sort(all(L));
    i64 ans = 0;
    rep(i, N){
        ans += L[2 * i];
    }
    cout << ans << endl;
}

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> L(2*N);
    for(int i = 0 ; i < 2*N ; i++){
        scanf("%lld",&L[i]);
    }
    solve(N, std::move(L));
    return 0;
}


Measured memory_bytes: 256
val Int.absoluteValue: Int
    get() {
        return if (this >= 0) this else -this
    }
val Int.sign: Int
    get() {
        return if (this >= 0) 1 else -1
    }
tailrec fun loop(): Unit {
    val (a, b, c) = readLine()!!.trim().split(' ').map(String::toInt)
    if (a == 0) return
    if (c != 0) {
        val p = (1 .. a).filter { a % it == 0 }
        val q = (1 .. c.absoluteValue).filter { c % it == 0 }.map { b.sign * it }
        println(p.find { i ->
            q.find { j -> i * j + (a / i) * (c / j) == b } != null
        }?.let{i -> q.find{j -> i * j + (a / i) * (c / j) == b}!!.let{j ->
            if (i * i == a) {
                if (j >= c / j) {
                    "$i $j ${a / i} ${c / j}"
                } else {
                    "$i ${c / j} ${a / i} $j"
                }
            }else if (i * i > a){
                "$i ${c / j} ${a / i} $j"
            }else {
                "${a / i} $j $i ${c / j}"
            }
        }} ?: "Impossible")
    }else {
        if (a > 1 || b >= 0) println("$a $b 1 0")
        else println("1 0 1 $b")
    }
    loop()
}
fun main(args:Array<String>?): Unit {
    loop()
}


Measured memory_bytes: 72876
#include<bits/stdc++.h>
using namespace std;
int main(){
  int ans=0;
  char a[4];
  cin>>a;
  for(int i=0;i<4;i++){
    if(a[i]=='+') ans++;
    else ans--;
  }
  cout<<ans<<endl;
  return 0;
}
  


Measured memory_bytes: 256
n,m = map( int, input().split() )
ks = []
for i in range(m):
    ks.append( list( map( int, input().split() ) ) )
p = list( map( int, input().split() ) )

ks_nums = [0]*m
for i in range(m):
    for j in range(ks[i][0]):
        ks_nums[i] += 2**(ks[i][j+1]-1)

ans = 0
success = True
for i in range(2**n):
    for j in range(m):
        cnt = 0
        tmp = i & ks_nums[j]
        for k in range(n):
            if ( tmp >> k ) & 1:
                cnt += 1
        if p[j] != cnt % 2:
            success = False
            break
    if success:
        ans += 1
    else:
        success = True

print(ans)

Measured memory_bytes: 40304
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

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

static const int INF = 100005;//4000より大きい数

int dp[50][500][500];

void MakeDp(int N, int a[], int b[], int c[]) {

	for (int i = 0;i < 402;i++) {//k=0の層をINFで埋める
		for (int j = 0;j < 402;j++) {
			dp[0][i][j] = INF;
		}
	}
	dp[0][0][0] = 0;//重さX，Y0はコスト0で数0で作れる

	int dia, top;
	for (int k = 1;k <= N;k++) {
		for (int i = 0;i < 402;i++) {
			for (int j = 0;j < 402;j++) {
				if (i - a[k] >= 0 && j - b[k] >= 0) dia = dp[k - 1][i - a[k]][j - b[k]] + c[k];
				else dia = INF;
				top = dp[k - 1][i][j];
				dp[k][i][j] = min(dia, top);
			}
		}
	}

}

int SolveDp(int N, int Ma, int Mb) {
	int cnt = 0;
	int ans = INF;
	int roopN = 400 / max(Ma, Mb);
	for (int i = 0;i < roopN;i++) {
		cnt++;
		ans = min(ans, dp[N][Ma*cnt][Mb*cnt]);
		//cout << ans<< endl;
	}

	return (ans == INF ? -1 : ans);
}

int main() {
	int N, Ma, Mb;
	cin >> N >> Ma >> Mb;

	int a[50], b[50], c[50];
	for(int k = 1; k <= N; k++) {
		cin >> a[k] >> b[k] >> c[k];
	}

	MakeDp(N, a, b, c);
	
	int ans;
	ans = SolveDp(N, Ma, Mb);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 40832
#include<stdio.h>
int a,b;
int main(void){
    scanf("%d%d",&a,&b);
    if(a >= 13){
        printf("%d",b);
    }else if(a >= 6&&a<= 12){
        printf("%d",b/2);
    }else{
        printf("0");
    }
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<int> b(n-1);
  for(int i = 0; i < n-1; i++) cin >> b.at(i);
  ll ans = 0;
  for(int i = 0; i < n; i++){
    if(i == 0) ans += b.at(i);
    else if(i == n - 1) ans += b.at(i-1);
    else ans += min(b.at(i-1), b.at(i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}
//char a[55][55];
int dx[] = {1,0,-1,0,1,1,-1,-1};
int dy[] = {0,1,0,-1,1,-1,-1,1};
ll a[100];
int main()
{
	dhoom;
	ll n;
	a[0] = 2;
	a[1] = 1;
	a[2] = 3;
	cin >> n;
	for(int i = 3 ; i <= n ;i++)	
		a[i] = a[i-1] + a[i-2];
	cout << a[n] << endl;
	return 0;
}


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

int main(){
    ll l,ans=1e9;
    cin >> l;
    vector<ll> a(l+1);
    for(int i = 0;i < l;i ++){
        cin >> a[i+1];
    }

    ll dp[200001][5];
    fill(dp[0],dp[200001],1e9);
    dp[0][0] = 0;

    for(int i = 1;i <= l;i ++){
        for(int j = 0;j < 5;j ++){
            ll m=1e9;
            for(int k = 0;k <= j;k ++){
                m = min(dp[i-1][k],m);
            }
            if(j==0||j==4) dp[i][j] = m+a[i];
            else if(j==1||j==3){
                dp[i][j] = m+a[i]%2;
                if(a[i]==0) dp[i][j] += 2;
            }
            else dp[i][j] = m+(a[i]+1)%2;
        }
    }
    for(int i = 0;i < 5;i ++){
        ans = min(ans,dp[l][i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
int cnt=0;
int head[200010];
int n,m;
struct Edge
{
    int from,to,next;
} edge[200010];

int dfs(int s,int k)
{
    if(s==n&&k==2)
        return 1;
    for(int i=head[s]; i!=-1; i=edge[i].next)
    {
        int to=edge[i].to;
        if(dfs(to,k+1))
            return 1;
    }
    return 0;
}

int main()
{
    int d,k;
    while(~scanf("%d%d",&n,&m))
    {
        memset(head,-1,sizeof(head));
        int u,v;
        for(int i=1; i<=m; i++)
        {
            scanf("%d%d",&u,&v);
            edge[cnt].from=u;
            edge[cnt].to=v;
            edge[cnt].next=head[u];
            head[u]=cnt++;
        }
        if(dfs(1,0))
            printf("POSSIBLE\n");
        else printf("IMPOSSIBLE\n");
    }
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,i,n,j,a[200005];
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int cunt=0;
    for(i=0;i<n-1;i++)
    {
        if(a[i]==a[i+1])
        {
            cunt=1;
            break;
        }
    }
    if(cunt==1) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;

}


Measured memory_bytes: 1152
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int k = stdIn.nextInt();
        int count = 1;
        while(n >= k){
          n = n / k;
          count++;
        }
        System.out.println(count);
    }
}

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

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


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

typedef long long ll;

const int MAX = 10;
const int MOD = 1e9 + 7;

int S;
int ten[MAX], num[MAX];

inline int add(int x, int y) {
	x += y;
	if (x >= MOD)
		x -= MOD;
	else if (x < 0)
		x += MOD;
	return x;
}

inline int mul(int x, int y) {
	return (long long)x * y % MOD;
}

int pot(int x, int y) {
	int res = 1;
	for (; y; y /= 2) {
		if (y % 2)
			res = mul(res, x);
		x = mul(x, x);
	}
	return res;
}

int calc(int a, int b, int c, int A, int B) {
	c -= a + b;
	A--;
	B--;
	if (c < 0)
		return 0;
	
	int g = __gcd(a, b);
	if (c % g)
		return 0;
	
	a /= g;
	b /= g;
	c /= g;
	
	int r = -1;
	for (int i = 0; i < b; i++)
		if (a * i % b == c % b) {
			r = i;
			break;
		}
	
	if (a * r > c || r > A)
		return 0;
		
	int lo = a * r + (ll)b * B >= c ? 0 : (c - a * r - (ll)b * B - 1) / (a * b) + 1;
	int hi = min((c - a * r) / (a * b), (A - r) / b);
	
	return max(hi - lo + 1, 0);
}

int solve_small() {
	int res = 0;
	for (int i = 1; i < 10; i++)
		for (int j = i + 2; j < 10; j++) {
			int tmp = 0;
			for (int k = i + 1; k < j; k++)
				tmp += k * num[k];
			res = add(res, calc(i, j, S - tmp, num[i], num[j]));
		}
	return res;
}

int f(int k) {
	if (k < 9 && S > k * num[k])
		return 0;
	return add(mul(9, pot(10, k - 1)), 1 - S / k);
}

int solve_one() {
	int res = 0;
	for (int i = 1; i * i <= S; i++) {
		if (S % i)
			continue;
		res = add(res, f(i));
		if (i * i < S)
			res = add(res, f(S / i));
	}
	return res;
}

int calc_big(int k) {
	int c = S - 2 * k - 1;
	int r = (k + 1 - c % (k + 1)) % (k + 1);
	if ((ll)k * r > c)
		return 0;
	return (c - (ll)k * r) / ((ll)k * (k + 1)) + 1;
}

int solve_two() {
	int res = 0;
	int limit = (S - 1) / 2;
	for (int i = 1; i <= limit; i++) 
		res = add(res, i < 9 ? calc(i, i + 1, S, num[i], num[i + 1]) : calc_big(i));
	return res;
}

int brute(int k) {
	int res = 0;
	for (int x = 1; k * x < S; x++)
		if (!((S - k * x) % (k + 1)))
			res++;
	return res;
}

int main() {
	ten[0] = 1;
	for (int i = 1; i < MAX; i++) {
		ten[i] = ten[i - 1] * 10;
		num[i] = 9 * ten[i - 1];
	}
	
	scanf("%d", &S);
	printf("%d\n", add(solve_small(), add(solve_one(), solve_two())));
	return 0;
}

Measured memory_bytes: 256
h, w, k = map(int,input().split())
c = []
for i in range(h):
  c.append(input())
  
def countb(c):
  num = 0
  for i in range(h):
    num += c[i].count("#")
  return(num)

def printb(c, row, col):
  c = c[:]
  #print(row,col)
  cnt = 0
  while row != 0:
    if row  & 0b1:
     
      c[cnt] = "."*w
    cnt += 1
    row = row >> 1
  
  cnt = 0
  while col != 0:
    #print(col&0b1)
    if col & 0b1:
      for i in range(h):
        c[i] = c[i][:cnt]+"."+c[i][cnt+1:]
    cnt += 1
    col = col >> 1
    
  #print("\n".join(c))
  return countb(c)

ans = 0
for i in range(2**h):
  for j in range(2**w):
    if printb(c,i,j) == k:
      ans += 1
print(ans)


Measured memory_bytes: 9136
#pragma GCC optimize("03")
#include <bits/stdc++.h>
typedef long long ll;
const int inf=INT_MAX;
using namespace std;
string s;
int ans=0,n;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>s;
    for(int i=0;i<s.size();i++)
        {
            if(s[i]==s[s.size()-i-1]) {ans++;}
        }
    if(ans==s.size()) {cout<<"Yes";} else {cout<<"No";}
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

bool ch(ll n, ll k) {
	
	ll a[3] = {};
	rep(i,k) {
		a[n%3]++;
		n /= 3;
	}

	rep(i, 3) if (a[i] == 0) { return false; }
	return true;
}

ll hen(ll n, ll k) {
	ll ans = 0;

	ll i = 0;
	rep(i,k) {
		ans += (3 + n % 3 * 2)*pow(10, i);
		n /= 3;
	}

	return ans;
}




int main() {

	
	ll N;
	cin >> N;

	ll ans = 0;

	rep(k, 10) {
		rep(n, pow(3, k)) {
			if (hen(n, k) <= N) { ans += ch(n, k); }
		}
	}

	cout << ans;

	system("PAUSE");
}

Measured memory_bytes: 504
#include<stdio.h>
#include<string.h>
int main(){
    long long int n,s=0,i,j,a[100],k;
    scanf("%lld",&n);
    k=n;
    i=0;
    while(n!=0){
        a[i]=n%10;
        n=n/10;
        i++;
    }

    for(j=0;j<i;j++)
        s=s+a[j];

    if(k%s==0)
        printf("Yes\n");
    else
        printf("No\n");}


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

int main()
{
  int N;
  std::cin >> N;
  std::vector<int> ps;
  for(int i=0; i<N; i++)
  {
    int p;
    std::cin >> p;
    ps.push_back(p-1);
  }

  int count = 0;
  for(int i=0; i<N; i++) { if(ps[i]!=i) { count += 1; } }

  std::cout << ((count==0 || count==2) ? "YES" : "NO");
}


Measured memory_bytes: 256
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n, q = list(map(int, input().rstrip('\n').split()))
    d = collections.defaultdict(list)
    for i in range(n-1):
        a, b = list(map(int, input().rstrip('\n').split()))
        d[a] += [b]
        d[b] += [a]

    score = collections.defaultdict(int)
    for i in range(q):
        p, x = list(map(int, input().rstrip('\n').split()))
        score[p] += x

    ql = collections.deque()
    ql.append(1)
    fq = collections.defaultdict(list)
    fq[1]
    while True:
        if len(ql) != 0:
            p = ql.popleft()
            for v in d[p]:
                if v not in fq:
                    score[v] += score[p]
                    fq[v]
                    ql.append(v)
        else:
            break
    print(*[score[i] for i in range(1, n + 1)])


if __name__ == '__main__':
    slove()


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

int main(){
    int a,b,c; cin >> a >> b >> c;
    if(a==b && a!=c) cout << "Yes" << endl;
    else if(a==c && a!=b) cout << "Yes" << endl;
    else if(b==c && a!=b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n,a,b,x;
    cin>>n>>a>>b;
    x=n*a;
    if(x<b)
        cout<<x<<endl;
    else if(x>b)
        cout<<b<<endl;
    else
        cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using  namespace std;
int fun(int n,int a[],int x1)
{
	int i;
	for(i=0;i<x1;i++)
	{
		if(a[i]>=n)return 0; 
	}
	return 1;
}
int fun1(int n,int b[],int y1)
{
	int i;
	for(i=0;i<y1;i++)
	{
		if(b[i]<n)return 0; 
	}
	return 1;
}
int main()
{
	int a[1000],q,x,y,x1,y1,b[1000],i;
	cin>>x1>>y1;
	cin>>x>>y;
	for(i=0;i<x1;i++)
	cin>>a[i] ;
	for(i=0;i<y1;i++)
	cin>>b[i] ;
	for(i=x+1;i<=y;i++)
	if(fun(i,a,x1)&& fun1(i,b,y1))
	{
	cout<<"No War"; return 0;
	}
	cout<<"War"; 
	return 0;
} 

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


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	if (a == b)cout << 0 << endl;
	else if (((a + b) & 1)==0)cout << abs((a + b) / 2) << endl;
	else cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(){
    int K;
    string S;

    cin >> K >> S;

    string out = S.substr(0,K);
    
    cout << out;
    if(S.length() > K)cout << "...";
    cout << endl;

    return 0;
}

Measured memory_bytes: 3072
s= input()
t = input()






def solve(S,T):
    s_map  = {}
    t_map = {}

    for s in S:
        if s in s_map:
            s_map[s] += 1
        else:
            s_map[s] = 1

    
    for t in T:
        if t in t_map:
            t_map[t] += 1
        else:
            t_map[t] = 1

    s_l = []
    t_l = []

    for sss in s_map:
        s_l.append(s_map[sss])
    for ttt in t_map:
        t_l.append(t_map[ttt])

    return sorted(s_l) == sorted(t_l)


    

if solve(s,t):
    print("Yes") 
else:
    print("No")



Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

class edge{
    public:
    ll to;
    ll weight;
    edge(ll t, ll w){
        to = t;
        weight = w;
    }
};
vector<edge>path[101010];


int main(){

    ll N;
    cin >> N;
    for(ll i = 1; i < N; i++){
        ll u, v, w;
        cin >> u >> v >> w;
        path[u].push_back(edge(v, w));
        path[v].push_back(edge(u, w));
    }
    vector<ll>ans(N + 1, 2);
    stack<ll>S;
    S.push(1);
    ans[1] = 0;
    while(!S.empty()){
        ll idx = S.top();
        S.pop();
        for(int i = 0; i < path[idx].size(); i++){
            int nxt = path[idx][i].to;
            int w = path[idx][i].weight;
            if(ans[nxt] < 2)continue;
            S.push(nxt);
            ans[nxt] = ans[idx];
            if(w % 2)ans[nxt] = (ans[nxt] + 1) % 2;
        }
    }
    for(int i = 1; i <= N; i++)cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 8704
#include <iostream>

int main() {
	std::string S;
	std::cin >> S;

	int oCounter = 0;
	for (int i = 0; i < S.length(); ++i) {
		if (S[i] == 'o') {
			oCounter++;
		}
	}

	if ((oCounter + 15 - S.length()) > 7) {
		std::cout << "YES";
	} else {
		std::cout << "NO";
	}

	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 REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    ll A,V,B,W,T;
    cin >> A >> V >> B >> W >> T;
    if (W >= V){
        cout << "NO" << endl;
        return 0;
    }

    ll D = (V - W) * T;
    ll d = abs(B - A);
    if (D >= d){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> P;
#define INF 10000000000000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main()
{
	string S;
	bool flag = true;
	ll count = 0;

	cin >> S;

	rep(i, S.size() - 1)
	{
		if (S[i] != S[i + 1])
			count++;
	}

	cout << count << endl;
	
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if (H == 0 && W == 0) {
				break;
			} else {
				for (int i = 0; i < H; i++) {
					for (int j = 0; j < W; j++) {
						System.out.print("#");
					}
					System.out.print("\n");
				}
				System.out.print("\n");
			}
		}
		sc.close();
	}

}


Measured memory_bytes: 37828
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

class Node {
  public:
    vector<int> write_to;
    int cnt;
    bool has_ball;
    Node() { cnt = 0; has_ball = false; }
};

int main()
{
  int n;
  cin >> n;
  vector<int> a(n+1);
  for (int i = 1; i <= n; i++) {
    cin >> a.at(i);
  }
  vector<Node> v(n+1);
  for (int i = 1; i <= n; i++) {
    for (int x = 1; x * i <= n; x++) {
      v.at(x*i).write_to.push_back(i);
    }
  }
  for (int i = n; 1 <= i; i--) {
    if (a.at(i) == 0) {
      v.at(i).has_ball = v.at(i).cnt % 2 != 0;
    } else {
      v.at(i).has_ball = v.at(i).cnt % 2 == 0;
    }
    if (v.at(i).has_ball) {
      for (int x : v.at(i).write_to) {
        v.at(x).cnt++;
      }
    }
  }
  vector<int> result;
  for (int i = 1; i <= n; i++) {
    if (v.at(i).has_ball) {
      result.push_back(i);
    }
  }
  cout << result.size() << '\n';
  if (result.size() == 0) {
    return 0;
  }
  cout << result.at(0);
  for (int i = 1; i < (int)result.size(); i++) {
    cout << ' ' << result.at(i);
  }
  cout << '\n';
  return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

string s;

int main(){
	cin.sync_with_stdio(false);
	cin>>s;
	cout<<s.substr(0,4)<<" "<<s.substr(4,s.length()-4)<<endl;
	return 0;
}


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

int main() {
    int N;
    cin >> N;
    int A[N], B[N], C[N];
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N) cin >> C[i];
    sort(A, A+N);
    sort(B, B+N);
    sort(C, C+N);

    int BonC[N];
    rep(i, N) {
        auto itr = upper_bound(C, C+N, B[i]);
        BonC[i] = N - (int)(itr - C);
    }

    ll accBonC[N] = {};
    accBonC[N] = 0;
    for (int i=N-1; i>=0; i--) {
        accBonC[i] = accBonC[i+1] + BonC[i];
    }

    ll ans=0;
    rep(i, N) {
        auto itr = upper_bound(B, B+N, A[i]);
        ans += accBonC[itr-B];
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 2560
N = int(input())
Ali = [ int(it) for it in input().split() ]
Bli = [ int(it) for it in input().split() ]

Sli = [ Bli[i] - Ali[i] for i in range(N) ]

if ( sum(Sli)>0 ):
  print (-1)
else:
  po = [ it for it in Sli if it>0 ]
  ng = [ it for it in Sli if it<0 ]
  agr = sum(po)
  ng.sort()
  
  for i in range(1000000):
    if (agr<=0):
      print (len(po)+i)
      break
    agr+=ng[i]
    
  


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;

const int MAX_N = 110;
const int BIT_SZ = (1<<(22-6));

ll dp[MAX_N][BIT_SZ+10];



int main() {
	int N;
	while(cin >> N) {
		if(N == 0) break;
		vector<int> M(N), L(N);
		vector<vi> S(N), E(N);
		vector<int> time(N);
		//input
		for(int i = 0; i < N; i++) {
			cin >> M[i] >> L[i];
			S[i].resize(M[i]);
			E[i].resize(M[i]);
			for(int j = 0; j < M[i]; j++) cin >> S[i][j] >> E[i][j];
			for(int j = 0; j < M[i]; j++) {
				for(int b = S[i][j]; b < E[i][j]; b++) time[i] |= (1<<(b-6));
			}
		}
		// init
		for(int i = 0; i < MAX_N; i++) for(int j = 0; j < BIT_SZ+10; j++) {
			dp[i][j] = 0LL;
		}
		
		for(int i = 0; i < N; i++) {
			for(int mask = 0; mask < BIT_SZ; mask++) dp[i+1][mask] = dp[i][mask];
			for(int mask = 0; mask < BIT_SZ; mask++) {
				if(mask & time[i]) continue;
				int nxtMask = mask | time[i];
				dp[i+1][nxtMask] = max({dp[i+1][nxtMask], dp[i][mask]+L[i]});
			}
		}
		ll ans = 0LL;
		for(int mask = 0; mask < BIT_SZ; mask++) ans = max(ans, dp[N][mask]);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 59412
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll x,n;
cin>>x>>n;
ll f=0;
ll counter=1000;
ll a[n]={};
ll ans=1000;
for(ll i=0; i<n; i++){
cin>>a[i];}
for(ll i=110; i>-10; i--){
for(ll k=0; k<n; k++){
if(a[k]==i){
f++;
break;}}
if(f==1){
f=0;
continue;}
else{
if(counter>=abs(x-i)){
ans=i;
counter=abs(x-i);}
f=0;}}
cout<<ans<<endl;}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
using lint = long long;
constexpr int MOD = (int)1e9 + 7;

lint modpow(int n, int r) {
    if (r == 0) return 0;
    if (r == 1) return n;
    lint half = modpow(n, r >> 1);
    half *= half;
    half %= MOD;
    if (r & 1) (half *= n) %= MOD;
    return half;
}

int N, K;
std::vector<lint> res;

signed main() {

    std::cin >> N >> K;

    res.assign(K + 1, 0LL);
    for (int i = K; i >= 1; --i) {
        res[i] = modpow(K / i, N);
        for (int j = 2 * i; j <= K; j += i) {
            res[i] -= res[j];
            if (res[i] < 0) res[i] += MOD;
        }
    }

    lint ans = 0;
    for (int i = 1; i <= K; ++i) (ans += res[i] * i % MOD) %= MOD;
    std::cout << ans << std::endl;

}


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

using namespace std;

char str[1000];
int n;

int main(){
    int i, cnt;
    while(scanf("%d", &n) != EOF){
        cnt = 0;
        scanf("%s", str);
        for(i = 0; i < n; i++){
            if(str[i]=='R') cnt++;
        }
        if(cnt*2 > n) printf("Yes\n");
        else printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 256
<?php
$input = fgets(STDIN);
list($tate,$yoko) = explode(" ", $input);

function area($a,$b){
return $a * $b;
}

function length($a,$b){
return ($a*2) + ($b*2);
}

print area($tate, $yoko);
print " ";
print length($tate, $yoko);

?>

Measured memory_bytes: 15252
#include <iostream>

bool inputNumbers(int&, int&);

int main(){

	int n, x;

	while (inputNumbers(n, x)){
		int count = 0;
		for (int a = 1; a <= n-2; a++)
		{
			for (int b = a + 1; b <= n - 1; b++)
			{
				//このループでa+b+cが実現不可能なら次のループに行く
				if (x - a > n * (n - 1)){
					break;
				}
				for (int c = b + 1; c <= n; c++)
				{
					//このループでa+b+cが実現不可能なら次のループに行く
					if (x - a - b > n){
						break;
					}
					if (a + b + c == x){
						++count;
						break;
					}
				}
			}
		}
		std::cout << count << std::endl;
	}
}


//点数入力を受け付ける関数
//入力数値がすべて0ならfalseを返す
bool inputNumbers(int& n, int& x){
	std::cin >> n >> x ;
	if (n == 0 && x == 0){
		return false;
	}
	else{
		return true;
	}
}


Measured memory_bytes: 3100
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;

using ll = long long int;

const ll m = 1000000007;

ll mul(ll a, ll b) {
	return ((a % m) * (b % m)) % m;
}

ll power(ll a, ll b) {
	if (b == 0) {
		return 1;
	}
	else if (b == 1) {
		return a % m;
	}
	else if (b % 2 == 0) {
		ll tmp = power(a, b / 2) % m;
		return mul(tmp, tmp) % m;
	}
	else {
		ll tmp = power(a, b / 2) % m;
		return mul(mul(tmp, tmp), a) % m;
	}
}

ll divi(ll a, ll b) {
	return mul(a, power(b, m - 2)) % m;
}

ll combi(ll a, ll b) {
	ll big, small;
	if (b>(a - b)) {
		big = b;
		small = (a - b);
	}
	else {
		big = (a - b);
		small = b;
	}

	ll child = 1;
	for (ll i = a; i>big; i--) {
		child = mul(child, i);
	}
	ll mother = 1;
	for (ll i = small; i>0; i--) {
		mother = mul(mother, i);
	}

	return divi(child, mother);
}





// 負の数にも対応した % 演算
ll mod(ll val, ll m) {
	ll res = val % m;
	if (res < 0) res += m;
	return res;
}








int main(int argc, char *argv[])
{
	//input
	int n, a, b;
	cin >> n >> a >> b;


	//calc
	ll total, nCa, nCb;
	total = mod(power(2, n) - 1, m);
	nCa = combi(n, a);
	nCb = combi(n, b);


	//ans
	ll ans;
	ans = mod(mod(total - nCa, m) - nCb, m);
	//ans = mod(ans - nCb, m);
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(){
  int a,b;
  double C;
  scanf("%d %d %lf",&a,&b,&C);
  C=M_PI/180*C;
  printf("%lf\n",0.5*a*b*sin(C));
  printf("%lf\n",a+b+sqrt(a*a+b*b-2*a*b*cos(C)));
  printf("%lf\n",b*sin(C));
  return 0;
}

Measured memory_bytes: 696
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



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

  int n, p;
  cin >> n >> p;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  vector<ll> c(2, 0);
  rep(i, n) c[a[i] % 2]++;
  ll c0 = 1;
  rep(i, c[0]) c0 *= 2;
  ll ans = 0, res = 1, cnt = 0;
  if (p) {
    res *= c[1];
    c[1]--;
    cnt++;
  }
  ans += res;
  while (c[1] >= 2) {
    res *= c[1] * (c[1] - 1);
    c[1] -= 2;
    res /= (cnt + 1) * (cnt + 2);
    cnt += 2;
    ans += res;
  }
  ans *= c0;
  cout << ans << '\n';

  









  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
#include <stack>
#define N 1005
using namespace std;
typedef long long ll;
int main()
{
    int n,y;
    scanf("%d%d",&n,&y);
    int a=1000,b=5000,c=10000;
    int s1=-1,s2=-1,s3=-1,n1,n2,n3;
    if(n*1000>y||n*10000<y)
        s1=-1,s2=-1,s3=-1;
    else
    {
        n3=y/c;
        for(int i=n3; i>=0; i--)
        {
            int flag=0;
            n2=(y-i*10000)/5000;
            for(int j=n2; j>=0; j--)
            {

                n1=(y-i*10000-j*5000)/1000;
                if(i+j+n1==n&&i*c+j*b+n1*a==y)
                {
                    s1=n1,s2=j,s3=i;
                    flag=1;
                    break;
                }


            }
            if(flag)
                break;
        }
    }
    printf("%d %d %d\n",s3,s2,s1);

}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

// Floyd Warshall


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

  int h, w;
  cin >> h >> w;
  vii c(10, vi(10));
  rep(i,10) rep(j,10) cin >> c[i][j];
  vii a(h, vi(w));
  rep(i,h)rep(j,w) cin >> a[i][j];

  rep(k,10)rep(i,10)rep(j,10) {
    c[i][j] = min(c[i][j], c[i][k]+c[k][j]);
  }
  ll ans = 0;
  rep(i,h)rep(j,w) {
    if(a[i][j] >= 0) ans += c[a[i][j]][1];
  }
  cout << ans << endl;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using ll = long long;
const ll MOD=1e9+7;
const long long INF = 1LL<<60;

int main() {
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;

    if (s==u){
        cout << a-1 << " " << b << endl;
    }else{
        cout << a << " " << b-1 << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> x(N);
  vector<int> y(N);
  for(int i=0; i<N; i++){
    int a, b;
    cin >> a >> b;
    x[i] = a+b;
    y[i] = a-b;  
  }
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  cout << max(x[N-1] - x[0], y[N-1] - y[0]) << endl;
}

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

int main()
{
	int N;
	scanf("%d", &N);
	std::map<std::string, int> count;
	for (int i{}; i < N; i++)
	{
		std::string S;
		std::cin >> S;
		count[S]++;
	}
	int max{};
	for (auto& e: count)
		max = std::max(max, e.second);
	for (auto& e: count)
		if (e.second == max)
			std::cout << e.first << '\n';

	return 0;
}

Measured memory_bytes: 25216
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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

int main(){
	int n;
	int a[1000];
	int v[1000];
	int c[1000];
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> v[i];
	}for(int i=0;i<n;i++){
		cin >> c[i];
	}
	for(int i=0;i<n;i++){
		a[i] = v[i]-c[i];
	}
	sort(a,a+n);
	reverse(a,a+n);
	int ans = 0;
	for(int i=0;i<n;i++){
		if(a[i]<0) break;
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

# nまでの自然数が素数かどうかを表すリストを返す
# Sieve of Eratosthenes
def makePrimeChecker(n):
    isPrime = [True] * (n + 1)
    isPrime[0] = False
    isPrime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if isPrime[i]:
            for j in range(i * i, n + 1, i):
                isPrime[j] = False
    return isPrime

# """nを素因数分解"""
# """2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
# print(factorization(m))
## [[2, 3], [3, 1]] 
##  24 = 2^3 * 3^1

a,b = myinput()
if a==1 and b==1:
    print(1)
    exit()

da = factorization(a)
db = factorization(b)
# print(da)
# print(db)

ls_a = []
for i in da:
    ls_a.append(i[0])

ls_b = []
for i in db:
    ls_b.append(i[0])

# print(ls_a)
# print(ls_b)

ls = list( set(ls_a) & set(ls_b) )
ans = len(ls) + 1
print(ans)

Measured memory_bytes: 38644
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;
 
int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll c = a + b;
    ll ans = a * (n/c);
    ans += min(n%c, a);
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<math.h>

using namespace std;

typedef long long ll;

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





signed main() {
	int x, y;

	cin >> x >> y;

	if (x > 9 || y > 9)cout << "-1";
	else cout << x * y;


	return 0;
}


Measured memory_bytes: 256