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

#define int long long

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

using namespace std;
#define m 1000000007

signed main()
{
    // typedef tree<int,null_type,less<int>,rb_tree_tag,
    // tree_order_statistics_node_update> indexed_set;
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    // vector<pair<int,int>> v;
    int a[n];
    loop1(i1,0,n)
    {  
        cin>>a[i1];
        
    }
    pair<int,int> mat[n+1][k+1];
     loop1(i,0,n+1)
    {  
       loop1(j,0,k+1)
    {  
        if(j==0){
        mat[i][j]=make_pair(1,1);}
        else{
         mat[i][j]=make_pair(0,1);   
        }
    }
        
    }
    // ================
    loop1(j,1,k+1)
    {  
       loop1(i,1,n+1)
    {  int x=0;
     
	
			int start=j-a[i-1];
			if(start<0){start=0;}
			if(start==0){
				x=(mat[i-1][j].second)%m;}
				
			else{
				x=((mat[i-1][j].second)-(mat[i-1][start-1].second)+m)%m;}
        
		mat[i][j]=make_pair(x%m,(mat[i][j-1].second+x)%m);
     
    }
        
    }
    cout<<mat[n][k].first;

    
}

Measured memory_bytes: 158080
// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
    "2\n2\n2\n100\n" => "2",
    "5\n1\n0\n150\n" => "0",
    "30\n40\n50\n6000\n" => "213",
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        a: u32,
        b: u32,
        c: u32,
        x: u32
    }

    let mut ans = 0;

    // for i in 0..=a {
    for i in 0..a + 1 {
        for j in 0..b + 1 {
            for k in 0..c + 1 {
                if 500 * i + 100 * j + 50 * k == x {
                    ans += 1;
                }
            }
        } 
    }


    ans.to_string()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int, int> P;


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

	int N;
	cin >> N;
	P p1[N], p2[N];
	rep(i,N){
		cin >> p1[i].first >> p1[i].second;
	}
	rep(i,N){
		cin >> p2[i].first >> p2[i].second;
	}
	sort(p1, p1+N);
	sort(p2, p2+N);
	int ans = 0;
	rep(i,N){
		P maxi = P(-1, -1);
		rep(j,N){
			if(p2[i].first > p1[j].first){
				if(p2[i].second > p1[j].second && maxi.first <= p1[j].second){
					maxi = {p1[j].second, j};
				}
			}
			else break;
		}
		if(maxi != P(-1, -1)){
			++ans;
			p1[maxi.second].second = INF;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque
N=int(input())
if N==1:
    print("a")
    exit()
X=[chr(i+97) for i in range(N)]
q=deque(["a"])
while(len(q)>0):
    r=q.popleft()
    k=len(set(r))
    for i in range(k+1):
        p=r+X[i]
        if len(p)==N:
            print(p)
        else:
            q.append(p)


Measured memory_bytes: 48088
# -*- coding: utf-8 -*-
#ABC089C
import sys

def checkx(i):
	t=0
	while(1):
		if(i%2==0):
			t+=1
			i=i//2
		else:
			return t

n = int(input())
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

sum = 0
for i in range(0,n):
	sum+=checkx(hoge[i])
print(sum)

Measured memory_bytes: 4148
N = int(input())

count = 0
stack = [3, 5, 7]

def is_valid(x):
    three = False
    five = False
    seven = False
    for i in str(x):
        if i == "3":
            three = True
        elif i == "5":
            five = True
        elif i == "7":
            seven = True
    if three and five and seven:
        return True
    else:
        return False

while stack:
    x = stack.pop()
    if is_valid(x):
        count += 1
    for next in (3, 5, 7):
        xx = x * 10 + next
        if xx <= N:
            stack.append(xx)
print(count)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <stack>
#include <map>
#include <functional>
#include <queue>
using namespace std;

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


int main(){
    int n,c ;
    cin >> n >> c ;
    vector<pair<int,pair<int,int> > > p(n,pair<int,pair<int,int> >()) ;
    for (int i = 0; i < n; i++)
    {
        int ts,tt,tc ;
        cin >> ts >> tt >> tc ;
        p.at(i).first = tc ;
        p.at(i).second.first = ts ;
        p.at(i).second.second = tt ;
    }
    sort(p.begin(),p.end()) ;
    vector<pair<int,pair<int,int> > > truep(0,pair<int,pair<int,int> >()) ;
    pair<int,pair<int,int> > next = p.at(0) ;
    for (int i = 1; i < n; i++)
    {
        if (p.at(i).first == next.first && p.at(i).second.first == next.second.second)
        {
            next.second.second = p.at(i).second.second ;
        }else
        {
            truep.push_back(next) ;
            next = p.at(i) ;
        }
        
        
    }
    truep.push_back(next) ;
    vector<vector<int> > table(c+1,vector<int>(200001,0)) ;
    int ans = 0 ;
    for (int i = 0; i < truep.size(); i++)
    {
        table.at(truep.at(i).first).at(truep.at(i).second.first*2-1) = 1 ;
        table.at(truep.at(i).first).at(truep.at(i).second.second*2) = -1 ; 
    }
    int temp = 0 ;
    for (int i = 0; i < 200001; i++)
    {
        for (int channel = 0; channel < c+1; channel++)
        {
            temp += table.at(channel).at(i) ;
        }
        ans = max(temp,ans) ;
    }
    cout << ans << endl ;

}

Measured memory_bytes: 30824
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var s string
	fmt.Fscan(r, &s)

	mp := map[string]int{
		"SUN": 7,
		"MON": 6,
		"TUE": 5,
		"WED": 4,
		"THU": 3,
		"FRI": 2,
		"SAT": 1,
	}
	fmt.Println(mp[s])
}

Measured memory_bytes: 640
#include<algorithm>
#include<cmath>//切り上げceil()
#include<deque>
#include<iomanip>//setprecision()
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<tuple>
#include<utility>
#define rep(i,n) for(ll i=0; i<n; i++)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  ll n,k;   cin >> n >> k;
  long double ans = 0.0;
  for(int i = 1; i <= n; i++){
    ll now = i;
    long double tmp = 1;
    while(now < k){
      now *= 2;
      tmp /= 2;
    }
    ans += double(1.0/n)*tmp;
  }
  cout << setprecision(12) << ans;
  return 0;
}


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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x) cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x) cout << ((x) ? "YES" : "NO") << endl

int main(int argc, const char* argv[]) {
	ll n;
	cin >> n;

	ll a[n];
	bool isodd = false;
	ll minimum = 1000000000;
	ll ret = 0;
	rep(i, n) {
		cin >> a[i];
		if(a[i] < 0) {
			isodd = !isodd;
			a[i] = -a[i];
		}
		debug(isodd);
		if(a[i] < minimum) minimum = a[i];
		ret += a[i];
	}

	if(isodd) {
		ret -= 2 * minimum;
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(){
  int n,k;
  scanf("%d", &n);
  scanf("%d", &k);

  int a[100001];
  int one_id;
  int ans = 0;
  for(int i=1; i<=n; i++){
    scanf("%d", &a[i]);
    if(a[i] == 1){
      one_id = i;
    }
  }

  ans = 1+(n-k)/(k-1);

  if( (n-k)%(k-1) != 0 ){
    ans++;
  }

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

  return 0;
}


Measured memory_bytes: 512
//author-micheal corleone
//the godfather
#include <bits/stdc++.h>
#include <set> 
#include<algorithm>
#include <set> 
#include<algorithm>
#define ll long long int
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define out(n) printf("%lld\n",n)
#define inf 100000000000000
#define endl "\n"
#define precise(x) fixed << setprecision(x) 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
const int MOD =1000000007;
#define f(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
 
using namespace std;

bool sortcol( const vector<int>& v1, 
               const vector<int>& v2 ) { 
 return v1[1] < v2[1]; 
}
 ll mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}
 //ll power(ll x, ll y) 
//{ 
  //  ll temp; 
    //if( y == 0) 
     //   return 1; 
    //temp = power(x, y/2); 
    //temp=temp%MOD;
    //if (y%2 == 0) 
     //   return (temp%MOD)*(temp%MOD); 
    //else
      //  return (x%MOD)*(temp%MOD)*(temp%MOD); 
//} 
 
 
ll ncr(ll n,ll r){if(n==1 || r==0)return 1;if(r>n/2)r=n-r;
	ll ans=1;for(ll i=1;i<=r;i++){ans=((ans * n )/i);n--;}return ans;
}
ll ncrsum(ll n,ll r, ll mod){
    if(n==1 || r==0)return 1;
  //  ll ans=1,sum=1;for(ll i=1;i<=r;i++){ans=((((ans * n)%MOD )*modinv(i,MOD))%mod);n--;sum+=ans;sum%=mod;}return sum;
}
 //diamond[2000005],ans[1000006];
 const int maxn=5e5+1000;
 ll vis[300000];
 
 
 
int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
     ll t;
    // cin>>t;
   
     t=1;	
     for(ll testcase=0;testcase<t;testcase++)
    {
        ll i1,i2,k,j,j1,a1,i31,i3,j2,i5,i4,i6,i7,i,m,n;
        ll x,y,z;
        ll total=0,cnt=0;
        ll flag=0;
        y=0;
        ll res,res1,ans,res2,q,sum;
        ans=0,cnt=0;
        res1=0,res=0,sum=0;
        ll flag1=0;
        ll k1,k2,k3;
        k1=1,k2=0;
        k3=0;
        ll required,days,h,w;
        //cin>>n;
        
        //for(it=mp.begin();it!=mp.end(),it++)
        //{
        //	for(int i=0;i<it->second.size();i++) cout<<it->second[i]<<" ";
		//}
		cin>>n;
		ll a[n];
	    f(i,0,n)
	    {
	    	cin>>a[i];
	    	sum=sum+a[i];
		}
		f(i,0,n)
		{
			sum-=a[i];
			ans+=(sum%MOD*a[i]%MOD)%MOD;
		}
		cout<<ans%MOD<<endl;
    }
}
	

Measured memory_bytes: 5208
H,W = map(int,input().split())
S = [input() for i in range(H)]

rs = [[0]*W for i in range(H)]
ls = [[0]*W for i in range(H)]
ds = [[0]*W for i in range(H)]
us = [[0]*W for i in range(H)]

for i in range(H):
    tmp = 0
    for j in range(W):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            rs[i][j] = tmp
    tmp = 0
    for j in reversed(range(W)):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            ls[i][j] = tmp

for j in range(W):
    tmp = 0
    for i in range(H):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            ds[i][j] = tmp
    tmp = 0
    for i in reversed(range(H)):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            us[i][j] = tmp

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '#': continue
        tmp = rs[i][j] + ls[i][j] + ds[i][j] + us[i][j] - 3
        ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 179588
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i, n) for(ll i=(ll)(n-1);i>=0;i--)
#define FOR(i, a, b) for(ll i=(ll)(a); i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main()
{
	ll N, K;
	cin >> N >> K;
	vector<ll> A(N);
	REP(i, N){
		cin >> A[i];
	}
	REP(i, K){
		bool flag = true;
		vector<ll> B(N, 0);
		REP(k, N){
			int l = max(0LL, k-A[k]);
			int r = min(N-1, k+A[k]);
			B[l]++;
			if(r+1<N)B[r+1]--;
		}
		A[0] = B[0];
		if(A[0] != N)flag = false;
		for(int k=1; k<N; k++){
			B[k] += B[k-1];
			A[k] = B[k];
			if(A[k] != N)flag = false;
		}
		if(flag)break;
	}
	REP(i, N){
		cout << A[i] << " ";
	}
	cout << endl;
}


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

using namespace std;

using ll = long long;

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

    int v1[2], v2[2];

    cin >> v1[0] >> v1[1] >> v2[0] >> v2[1];

    int v3[2] = {v2[0] - v1[0], v2[1] - v1[1]};
    int tmp[2];
    tmp[0] = 0 * v3[0] + (-1) * v3[1];
    tmp[1] = 1 * v3[0] + 0 * v3[1];
    v3[0] = tmp[0] + v2[0];
    v3[1] = tmp[1] + v2[1];

    cout << v3[0] << ' ' << v3[1];

    int v4[2] = {v3[0] - v2[0], v3[1] - v2[1]};
    tmp[0] = 0 * v4[0] + (-1) * v4[1];
    tmp[1] = 1 * v4[0] + 0 * v4[1];
    v4[0] = tmp[0] + v3[0];
    v4[1] = tmp[1] + v3[1];

    cout << ' ' << v4[0] << ' ' << v4[1] << '\n';

    return 0;
}


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

string exp;
int now,ans,p,q,r;

int multi(int x,int y){
	return min(x,y);
}

int myplus(int x,int y){
	return max(x,y);
}

int myminus(int x){
	if(x==2)
		return 0;
	if(x==1)
		return 1;
	if(x==0)
		return 2;
	return false;
}
int calc(){
	if(exp[now]=='0' || exp[now]=='1' || exp[now]=='2'){
		char temp=exp[now];
		now++;
		return temp-'0';
	}
	if(exp[now]=='P'){
		now++;
		return p;
	}else if(exp[now]=='Q'){
		now++;
		return q;
	}else if(exp[now]=='R'){
		now++;
		return r;
	}else if(exp[now]=='-'){
		now++;
		return myminus(calc());
	}else if(exp[now]=='('){
		now++;
		int left=calc(),right;
		if(exp[now]=='*'){
			now++;
			right=calc();
			now++;
			return multi(left,right);
		}
		else if(exp[now]=='+'){
			now++;
			right=calc();
			now++;
			return myplus(left,right);
		}
	}
	return false;
}

void solve(){
	now=0;
	ans=0;
	int k;
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			for(int z=0;z<3;z++){
				p=i;
				q=j;
				r=z;	
				k=calc();
				if(k==2){
					ans++;
				}
				now=0;
			}
	cout<<ans<<"\n";
}


int main()
{
	cin>>exp;
	while(exp!="."){
		solve();
		cin>>exp;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

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

typedef struct {
    int to;
    long long cost;
} edge;

ll inf = 1e18;

void dijkstra(int n, vector<vector<edge> > &G, int s, vector<ll> &dist) {
    dist.resize(n);
    rep(i,n)    dist[i] = inf;
    dist[s] = 0;
    priority_queue<P> que;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();    que.pop();
        int u = p.second;   ll d = p.first;
        if (dist[u] < d)
            continue;
        
        for (auto e: G[u]) {
            int v = e.to;   ll c = e.cost;

            if (dist[v] <= dist[u] + c)
                continue;

            dist[v] = dist[u] + c;
            que.push(P(dist[v], v));
        }
    }
}

int main() {
    int n,m, r;   cin >> n >> m >> r;
    vector<int> s(r);
    rep(i, r) {
        cin >> s[i];
        s[i]--;
    }
    vector<vector<edge> > G(n);
    rep(i, m) {
        int a, b;   long long c;
        cin >> a >> b >> c;
        edge e1 = {b-1, c}, e2 = {a-1, c};
        G[a-1].push_back(e1);
        G[b-1].push_back(e2);
    }

    vector<vector<ll> > d(n, vector<ll>(n));
    vector<ll> dist;
    for (int i = 0; i < r; i++) {
        dijkstra(n, G, s[i], dist);
        rep(j, r)
            d[s[i]][s[j]] = dist[s[j]];
    }

    sort(s.begin(), s.end());
    ll ans = 1e18;
    do {
        ll tmp = 0;
        rep(i, r-1)
            tmp += d[s[i]][s[i+1]];
        ans = min(ans, tmp);
    }   while (next_permutation(s.begin(), s.end()));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4812
#include<stdio.h>
int main()
{
    char S[4]={};
    scanf("%s", S);
    
    if(S[1]=='R')
    {
        if(S[0]=='R' && S[2]=='R')
        {
            printf("3");
            return 0;
        }
        else if(S[0]!='R'&&S[2]!='R')
        {
            printf("1");
            return 0;
        }
        else
        {
            printf("2");
            return 0;
        }
    }
    else if(S[0]!='R' && S[2]!='R')
    {
        printf("0");
        return 0;
    }
    else
    {
        printf("1");
        return 0;
    }
}

Measured memory_bytes: 1648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

ll A,B,C,D;
int main(){
    cin>>A>>B>>C>>D;
    while(A>0&&C>0){
        C-=B;//高橋→青木の順番だった　ロスした
        if(C<=0){cout<<"Yes";break;}
        A-=D;
        if(A<=0){cout<<"No";break;}
    }
    return 0;
}

Measured memory_bytes: 3636
n = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(n-1):
    if p[i] == i+1:
        tmp = p[i]
        p[i] = p[i+1]
        p[i+1] = tmp
        count += 1
if p[-1] == n:
    count += 1
print(count)

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



int main(){

	int a, b;

	cin >> a >> b;

	if(a>b){
		for(int i=0; i<a; ++i){
			cout << b;
		}
		cout << endl;
	}
	else if(b>a){
		for(int i=0; i<b; ++i){
			cout << a;
		}
		cout << endl;
		
	}
	else{
		for(int i=0; i<b; ++i){
			cout << max(a,b);
		}
		cout << endl;
	}

	return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

int main() {
    int N, M;
    cin >> N >> M;
    priority_queue<ll> que;

    rep(i, N) {
        ll A;
        cin >> A;
        que.push(A);
    }

    rep(i, M) {
        ll t = que.top();
        que.pop();
        que.push(t / 2);
    }

    ll ans = 0;
    while (!que.empty()) {
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long;
#define chmin(i, j) i = min(i, j);
#define chmax(i, j) i = max(i, j);
#define rep(i, n) for(int i=0;i<n;i++)
int main() {
  int n, x, y;
  cin >> n >> x >> y;
  x--;y--;
  vector<vector<int>> dis(n, vector<int>(n, 100100100));
  rep(i, n) {
    for(int j=i+1;j<n;j++) {
      int d = j - i;
      int dd = abs(i - x) + 1 + abs(j - y);
      int ddd = abs(i - y) + 1 + abs(j - x);
      vector<int> dist({d, dd, ddd});
      dis[i][j] = *min_element(dist.begin(), dist.end());
    }
  }
  vector<int> ans(n);
  for(int i=0;i<n;i++) {
    for(int j=0;j<n;j++) {
      if(dis[i][j] == 100100100) continue;
      ans[dis[i][j]]++;
    }
  }
  for(int i=1;i<n;i++) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 16000
n = int(input())
counts = {}
for i in range(n):
    str = input()
    if not str in counts:
        counts[str] = 0
    counts[str] += 1

most = -1
answer = []
for k, v in sorted(counts.items(), key=lambda x: x[1], reverse=True):
    if most == -1:
        most = v
    if most > v:
         break
    answer.append(k)

for a in sorted(answer):
    print(a)



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

int main()
{
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> ss(h);
	for (auto &&s : ss)
	{
		cin >> s;
	}

	int ans = (1 << 29);

	for (int S = 0; S < (1 << (h - 1)); S++)
	{
		int tmp = __builtin_popcount(S);

		vector<int> num(tmp + 1, 0);
		for (int j = 0; j < w; j++)
		{
			bool flag = false;
		back:;
			for (int i = 0, ind = 0; i < h; i++)
			{
				if (k < num[ind] + (ss[i][j] == '1'))
				{
					tmp++;
					for (auto &&x : num)
					{
						x = 0;
					}
					if (flag)
					{
						goto next;
					}
					flag = true;
					goto back;
				}

				num[ind] += (ss[i][j] == '1');

				if (S & (1 << i))
				{
					ind++;
				}
			}
		}

		ans = min(ans, tmp);

	next:;
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
  int N ;
  cin >> N ;
  
  if ( (N % 1110)==0 || (N % 1110)==1 || (N % 1110)==2 || (N % 1110)==3 || (N % 1110)==4 || (N % 1110)==5 || (N % 1110)==6 || (N % 1110)==7 || (N % 1110)==8 || (N % 1110)==9  || (N % 1000) % 111 == 0 ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n+1):
  if i==0 or i==n or a[i-1] != a[i]:
    if i!=0:
      ans += cnt // 2
    cnt = 1
  else:
    cnt += 1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
 
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (int i=a; i<b; i++)
// #define endl "\n"
const int mod = 1000000007;
const int INF = 1e9 + 5;

ll power(ll x, ll y) 
{ 
    ll res = 1;     // Initialize result 
   
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = res*x; 
        res%=mod;
        // n must be even now 
        y = y>>1; // y = y/2 
        x = x*x;
        x%=mod;  // Change x to x^2 
    } 
    return res%mod; 
}

int main() {
    ios_base::sync_with_stdio(false);    //Fast I/O
    cin.tie(NULL);
 
    // freopen("input.txt", "r", stdin);    // Read and write from a file
    // freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    vector<int> a(n,0), b(n,0), c(n,0);
    rep(i,0,n){
        cin >> a[i] >> b[i] >> c[i];
    }
    if(n<2){
        cout << max(a[0], max(b[0],c[0]));
        return 0;
    }
    vector<vector <int> > dp(n, vector<int> (3,0));

    dp[0][0]=a[0];dp[0][1]=b[0];dp[0][2]=c[0];
    for(int i=1; i<n; i++){
        dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1]);
        // cout << dp[i][2] << endl;
    }
    
    cout << max(dp[n-1][0], max(dp[n-1][1],dp[n-1][2])) << endl;

    return 0;
}

Measured memory_bytes: 6912
#include<iostream>
using namespace std;
int gcd(int a,int b)
{
	int c=1,temp;
	while(b>0)
	{
		temp = a%b;
		a = b;
		b = temp;
	}
	return a;
}
int main()
{
	int n,a[10000000],ans;
	cin>>n;
	for(int i=0;i<n;i++)
	{	
		cin>>a[i];
	}
	ans = gcd(a[0],a[1]);
	for(int j=2;j<n;j++)
	{
		
		ans = gcd(ans,a[j]);
	}
	cout<<ans;
	return 0;
	
}

Measured memory_bytes: 2688
cnt = [0 for i in range (26)]
alphabet = 'abcdefghijklmnopqrstuvwxyz'
str = open(0).read()
for x in str:
    for k in range(len(alphabet)):
        if x == alphabet[k] or x == alphabet[k].upper():
            cnt[k] = cnt[k] + 1
            break

for i in range(26):
    print(alphabet[i], ':', cnt[i])


Measured memory_bytes: 5576
#include <iostream>
    #include <vector>
    #include <bits/stdc++.h>
    #define rep(i, n) for (int i = 0; i < (n); ++i)
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> P;
     
    #define pb push_back
        #define eb emplace_back
        #define fi first
        #define se second
        #define bg begin()
        #define ed end()
        #define all(x) x.bg, x.ed
        #ifdef LOCAL
        #define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl
        #else
        #define dmp(x) void(0)
        #endif
         
        template <class t, class u>
        void chmax(t &a, u b)
        {
          if (a < b)
            a = b;
        }
        template <class t, class u>
        void chmin(t &a, u b)
        {
          if (b < a)
            a = b;
        }
         
        template <class t>
        using vc = vector<t>;
        template <class t>
        using vvc = vc<vc<t>>;
         
        using vi = vc<int>;
        int gcd(int a, int b)
        {
          if (b == 0)
            return a;
          return gcd(b, a % b);
        }
        int lcm(int a, int b)
        {
          return (a * b) / gcd(a, b);
        }
        int fact(int n)
        {
          if (n == 0)
            return 1;
          return n * fact(n - 1);
        }
        int main()
        {
          int a, b;
          char op;
          cin >> a;
          cin >> op;
          cin >>b;
          if(op=='+') cout << a+b<<endl;
          else cout << a-b <<endl;
        }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {
    ll n;
    cin >> n;
    auto res = prime_factorize(n);

    cout << n << ":";
    for(auto p : res) {
        ll m = p.second;
        rep(i, m) cout << " " << p.first;
    }
    cout << endl;
}



Measured memory_bytes: 3136
sls = list(input())
sdic = {}
for i in range(len(sls)):
  if sls[i] in sdic:
  	sdic[sls[i]] += 1
  else:
    sdic[sls[i]] = 1

if len(sdic) == 2 and list(sdic.values()) == [2,2]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

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);
    return a/g *b;
}

int main(){
    int n;
    cin >> n;
    long long a[n];
    for(int i=0;i<n;++i){
        cin >> a[i];
    }
    sort(a,a+n);
    long long num_max=a[n-1];
    long long num=(long long) pow(10,9);
    long long half=round(a[n-1]/2);
    long long num_min=0;
    for(int i=0;i<n-1;++i){
        if(num>=abs(half-a[i])){
            num_min=a[i];
            num=abs(half-a[i]);
        }
    }
    cout << num_max << " " << num_min << endl;
    }

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

using namespace std;
typedef struct { double x; double y;} point;
 
point getCircumcenter(point a, point b, point c)
{
    double A1 = 2.0f * ( b.x - a.x );
    double B1 = 2.0f * ( b.y - a.y );
    double C1 = pow(a.x,2)-pow(b.x,2) + pow(a.y,2)-pow(b.y,2);
    double A2 = 2.0f * ( c.x - a.x );
    double B2 = 2.0f * ( c.y - a.y );
    double C2 = pow(a.x,2)-pow(c.x,2) + pow(a.y,2)-pow(c.y,2);
    double X = (B1 * C2 - B2 * C1) / (A1 * B2 - A2 * B1);
    double Y = (C1 * A2 - C2 * A1) / (A1 * B2 - A2 * B1);
	point P;
	P.x=X;
	P.y=Y;
    return P;
}

double getTwoPointDictance(point a, point b)
{
	return fabs(sqrt(pow((a.x-b.x),2)+pow((a.y-b.y),2)));
}
double AntiMinusZero(double n)
{
	if(n==0)
	{
		return 0.0f;
	}
	return n;
}

int main()
{
    int n;
    cin>>n;
    point a,b,c;
    while(n--)
	{
        cin>>a.x>>a.y>>b.x>>b.y>>c.x>>c.y;
        point ans = getCircumcenter(a,b,c);
        printf("%.3lf %.3lf %.3lf\n", AntiMinusZero(ans.x), AntiMinusZero(ans.y), getTwoPointDictance( a, ans));
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#include <cmath>
#include <map>
#include <utility>
#include <numeric>

#define _USE_MATH_DEFINES
#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 INF 999999999
#define atcoder 1000000007
#define MAX_N 100

using namespace std;

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

int main() {

	int N;
	long long T[100];
	long long ans,r;

	cin >> N;

	REP(i,N) {
		cin >> T[i];

		if(i == 0) ans = T[0];

		if (i > 0) {
			r = gcd(ans, T[i]);
			ans /= r;
			ans *= T[i];
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#pragma GCC optimize ("O3")
typedef long l;
typedef unsigned long long u;
int x(const void *a,const void *b){return *(l*)a<*(l*)b?-1:*(l*)a==*(l*)b?0:1;}
int main(void){
	l n;
	scanf("%ld",&n);
	l r[n];
	l i;
	for(i=0;i<n;i++)scanf("%ld",&r[i]);
	qsort(r,n,sizeof(l),x);
	u c[n];
	c[0]=r[0];
	for(i=1;i<n;i++)c[i]=c[i-1]+r[i];
	l a=1;
	for(i=n-2;i>=0&&c[i]*2>=(u)r[i+1];i--)a++;
	printf("%ld",a);
	return 0;
}


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>

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

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<P, int> PP;
const double esp = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+17 + 10;

int main(){
	int s;
	std::cin >> s;
	printf("%d:%d:%d\n", s / 3600, s % 3600 / 60, s % 60);
	return 0;
}

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

#define forn(e,n,s) for(int i = e; i < n;i += s)
#define forr(e,n,s) for(int i = e; i >= n; i -= s)
#define PI 3.14159265358979323846264338327950L
#define ll long long

using namespace std;

const int MOD = 1e9+7;

void go(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout<<fixed;
  cout<<setprecision(20);

  #ifndef ONLINE_JUDGE
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
  #endif
}
vector<int> arr,sizeu;
int comps;
int getp(int x){
    return arr[x] = (x!=arr[x] ? getp(arr[x]) : x);
}
void merg(int x,int y){
    int p_a = getp(x);
    int p_b = getp(y);
    if(p_a == p_b) return;
    if(sizeu[p_a] > sizeu[p_b]) swap(p_a,p_b);
    arr[p_b] = p_a;
    sizeu[p_a] += sizeu[p_b];
    comps--;
}



void solve(){
    int n,m; cin>>n>>m;
    arr.resize(n+1);
    sizeu.resize(n+1,1);
    comps = n;
    for(int i = 0; i <= n; i++) arr[i] = i; 
    while(m--){
        int a,b; cin>>a>>b;
        merg(a,b);
    }
    cout<<comps-1;
} 

int main(){
    go(); 

    // code here
    int t = 1; 
    while(t--) solve();
   
}









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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;

const ll maxn = 1e5 + 10, MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}


void init() {

}


int a[maxn];
int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
//    ios_base::sync_with_stdio(0);
    init();
	int n;cin>>n;
	for(int i = 0;i < n;i++) {
        cin>>a[i];
	}
	sort(a,a+n);
	ll s1 = 0,s2 = 0;
	for(int i = n - 1;i >= 0;i -= 2) {
        s1 += a[i];
        if(i >= 0)
            s2 += a[i - 1];
	}
	cout<<s1 - s2<<endl;
    return 0;
}


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

using namespace std;

int main(int argc, char *argv[])
{
	string s;
	cin >> s;
	int ans = 0, c = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'R') {
			c++;
		} else {
			c = 0;
		}
		ans = max(c, ans);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int k = scan.nextInt();
        String s = scan.next();

        String[] strArray = s.split("");
        strArray[k - 1] = strArray[k - 1].toLowerCase();
        s = String.join("", strArray);

        System.out.println(s);
    }
}

Measured memory_bytes: 22740
fun main(args:Array<String>) {
    val n = readLine()!!.toInt()
    val v = readLine()!!.split(" ").map { it.toInt() }
    val c = readLine()!!.split(" ").map { it.toInt() }
    val ans = (0 until n).map { v[it] - c[it] }.filter { it > 0  }.sum()
    println(ans)
}


Measured memory_bytes: 36788
# -*- coding: utf-8 -*-

N = int(input())
p = list(map(int, input().split()))

count = 0
for i in range(1, N+1):
    if p[i-1] == i:
        count += 1

if N - 2 <= count <= N:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 2940
N,M = map(int,input().split())
SC = []
for i in range(M):
    SC.append(list(map(int,input().split())))
for i in range(0,1000):
    si = str(i)
    if len(si) != N:
        continue
    flag = False
    for s,c in SC:
        s = s-1
        if si[s] != str(c):
            flag = True
    if not flag:
        print(i)
        exit()
print(-1)

Measured memory_bytes: 3064
#include <set>
#include <map>
#include <ctime>
#include <cmath>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define PII pair<LL,LL>
#define FOR(i,a,b) for (LL i=(a);i<=(b);++i)
#define ROF(i,b,a) for (LL i=(b);i>=(a);--i)
typedef long long LL;
inline LL read(){
	LL x=0,f=1; char ch=getchar();
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*f;
}

const LL MAXN=2005,base=10000;
const double eps=1e-8,INF=1e20,PI=3.141592653589793238462;
LL n,m,l,r,a[MAXN];
struct BigNum{
	LL l,x[MAXN];
	inline void clear() { l=1; memset(x,0,sizeof(x)); }
	BigNum() { clear(); }
	BigNum(LL a) { for (l=0;a;a/=base) x[++l]=a%base; }
	BigNum operator +(const BigNum &B) const {
		BigNum C; C.l=(B.l>l?B.l:l);
		for (LL i=1;i<=C.l;++i) {
			C.x[i]+=x[i]+B.x[i];
			if (C.x[i]>=base) {
				C.x[i+1]+=C.x[i]/base;
				C.x[i]%=base;
			}
		}
		if (C.x[C.l+1]) C.l++;
		return C;
	}
	BigNum operator -(const BigNum &B) const {
		BigNum C=(*this);
		for (LL i=1;i<=C.l;++i) {
			C.x[i]-=B.x[i];
			if (C.x[i]<0) { C.x[i+1]--; C.x[i]+=base; }
		}
		while (C.l>1&&!C.x[C.l]) C.l--;
		return C;
	}
	BigNum operator *(const BigNum &B) const {
		BigNum C; C.l=l+B.l-1;
		for (LL i=1;i<=l;++i)
			for (LL j=1;j<=B.l;++j) {
				LL k=i+j-1;
				C.x[k]+=x[i]*B.x[j];
				if (C.x[k]>=base) {
					C.x[k+1]+=C.x[k]/base;
					C.x[k]%=base;
				}
			}
		while (C.x[C.l+1]>0) {
			C.l++;
			if (C.x[C.l]>base) {
				C.x[C.l+1]=C.x[C.l]/base;
				C.x[C.l]%=base;
			}
		}
		return C;
	}
	BigNum operator /(const LL &b) const {
		BigNum C=(*this);
		for (LL i=C.l,j=0;i>0;--i) {
			j=j*base+C.x[i];
			C.x[i]=j/b;
			j%=b;
		}
		while (C.l>1&&C.x[C.l]==0) C.l--;
		return C;
	}
};
typedef BigNum NB;
void write(NB &A) {
	printf("%lld",A.x[A.l]);
	for (LL i=A.l-1;i>0;--i) {
		if (A.x[i]<10) printf("000%lld",A.x[i]);
		else if (A.x[i]<100) printf("00%lld",A.x[i]);
		else if (A.x[i]<1000) printf("0%lld",A.x[i]);
		else printf("%lld",A.x[i]);
	}
	printf("\n");
}
LL CC(LL n,LL m){
	LL ret=1;
	FOR(i,1,m) ret=(ret*(n+1-i))/i;
	return ret;
}
LL power(LL n,LL m){
	LL ret=1;
	FOR(i,1,m) ret=ret*(n);
	return ret;
}
int main(){
	//srand(time(0));
	n=read(); m=read(); l=r=0;
	FOR(i,1,n) {
		//a[i]=rand()%2;
		a[i]=read();
		if (a[i]&1) l++; else r++;
	}
	//cout<<l<<' '<<r<<endl;
	LL ans(0);
	if (m==0) {
		for (LL i=0;i<=l;i+=2) {
			ans=ans+CC(l,i);
			//cout<<i<<endl;
			//write(ans);
		}
	}
	else {
		for (LL i=1;i<=l;i+=2) {
			ans=ans+CC(l,i);
			//cout<<i<<endl;
			//write(ans);
		}
	}
	//write(ans);
	ans=ans*power(2,r);
	printf("%lld\n",ans);
	return 0;
}

/*
*/


Measured memory_bytes: 256
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  for(var i = 1; i <= n; i++){
    if(Math.floor(i*1.08) === n)return i;
  }
  return ":(";
}

Measured memory_bytes: 21064
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String ns = sc.next();
    String[] s = ns.split("");
    int start = 0;
    int end = 0;
    for (int i = 0; i < s.length; i++) {
      if (s[i].equals("A")) {
        start = i;
        break;
      }
    }
    for (int i = s.length - 1; i >= 0; i--) {
      if (s[i].equals("Z")) {
        end = i;
        break;
      }
    }
    System.out.println(end - start + 1);
  }
}

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

int main (){
  int N,count = 32,x;
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> x;
    int y = 0;
    while(!(x % 2)){
      y++;
      x /= 2;
    }
    if (count > y)
      count = y;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
A = set(map(int,input().split()))
#A = set(A)
ok = []
for i in range(10):
  if i not in A:
    ok.append(i)
#print(ok)
while True:
  nstr = str(N)
  nstr = list(nstr)
  #print(nstr)
  Flag = True
  for x in nstr:
    x = int(x)
    if x in A:
      Flag = False
      break
  #print(Flag)
  if Flag:
    print(N)
    exit()
  else:
    N += 1
      

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
#define Sort(v) sort((v).begin(), (v).end())
using veci = vector<int>;
using vecs = vector<string>;
using vecd = vector<double>;
using vecl = vector<long long>;
using G = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
ll lINF = LLONG_MAX; ll lmINF = LLONG_MIN;
int INF = INT_MAX; int mINF = INT_MIN;
int main(){
    int n, k;
    cin >> n >> k;
    veci p(n);
    rep(i, n){
        cin >> p[i];
    }
    Sort(p);
    int ans = 0;
    rep(i, k){
        ans += p[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
int main(){
  int n,a,b,c=0,ans=0;
  bool pr1=false,pr2=false,pr3=false;
  cin >> n >> a >> b;
  int p[n];
  for(int i=0;i<n;i++){
    cin >> p[i];
  }
  for(int j=0;j<n;j++){
    for(int i=0;i<n;i++){
      if(a >= p[i] && pr1 == false && p[i] != -1){
        c++;
        pr1 = true;
        p[i] = -1;
      }else{
        if(a+1 <= p[i] && p[i] <= b && pr2 == false){
          c++;
          pr2 = true;
          p[i] = -1;
        }else{
          if(b+1 <= p[i] && pr3 == false){
            c++;
            pr3 = true;
            p[i] = -1;
          }
        }
      }
      if(c >= 3 && pr1 == true && pr2 == true && pr3 == true){
        ans++;
        c = 0;
        pr1 = false;
        pr2 = false;
        pr3 = false;
      }
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())

def correct(a1, a2, a3, b1, b2, b3):
  if a1 + b1 != c11:
    return False
  if a2 + b2 != c22:
    return False
  if a3 + b3 != c33:
    return False
  if a1 + b2 != c12:
    return False
  if a1 + b3 != c13:
    return False
  if a2 + b1 != c21:
    return False
  if a2 + b3 != c23:
    return False
  if a3 + b1 != c31:
    return False
  if a3 + b2 != c32:
    return False
  return True

for i in range(c11 + 1):
  a1 = i
  b1 = c11 - i
  a2 = a1 - c11 + c21
  a3 = a1 - c11 + c31
  b2 = b1 - c11 + c12
  b3 = b1 - c11 + c13
  # print(a1, a2, a3, b1, b2, b3)
  if correct(a1, a2, a3, b1, b2, b3):
    print('Yes')
    exit(0)

# for i in range(c11 + 1):
#   for j in range(c22 + 1):
#     for k in range(c33 + 1):
#       a1 = i
#       b1 = c11 - i
#       a2 = j
#       b2 = c22 - j
#       a3 = k
#       b3 = c33 - k
#       if correct(a1, a2, a3, b1, b2, b3):
#         print('Yes')
#         exit(0)

print('No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  int64_t N;
  cin>>N;
  int x=N;
  string t;
  while(x){
   int r=x%2;
   if(r<0){r+=2;}
   x=(x-r)/(-2);
   t+=(char)('0'+r);
  }
  reverse(t.begin(),t.end());
  if(t==""){t='0';}
  cout<<t<<endl;
  return 0;
}

Measured memory_bytes: 3636
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n, h, w; cin >> n >> h >> w;
	int res = 0;
	while (n--)
	{
		int a, b; cin >> a >> b;
		if (h <= a && w <= b)++res;
	}
	cout << res << endl;
}

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

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

    int line_type = 0;
    int ans = 0;
    rep(i, 1, n)
    {
        int line_type_now = a[i] - a[i - 1];
        if (line_type_now > 0) line_type_now = 1;
        if (line_type_now < 0) line_type_now = -1;
        
        if (line_type != 0)
        {
            if (line_type * line_type_now < 0)
            {
                ++ans;
                line_type = 0;
            }
        }
        else
            line_type = line_type_now;
        // cout << ans << ' ' << line_type << endl;
    }
    cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 640