akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template <class T>
struct Edge {
    int rev, from, to;  // rev:逆向きの辺の番号
    T cap, original_cap;
    Edge(int r, int f, int t, T c) : rev(r), from(f), to(t), cap(c), original_cap(c) {}
};
template <class T>
struct Graph {
    vector<vector<Edge<T>>> G;
    Graph(int n = 0) : G(n) {}
    vector<Edge<T>>& operator[](int i) { return G[i]; }
    const size_t size() const { return G.size(); }
    Edge<T>& redge(Edge<T> e) {  // 逆向きの辺を返す
        return G[e.to][e.rev];   // 自己ループはないと仮定（あれば G[e.to][e.rev + 1] とする必要がある）
    }
    void add_edge(int from, int to, T cap) {  // 有向辺を加える
        G[from].push_back(Edge<T>((int)G[to].size(), from, to, cap));
        G[to].push_back(Edge<T>((int)G[from].size() - 1, to, from, 0));
    }
};
/* FordFulkerson: Ford-Fulkersonのアルゴリズムで最大流を求める構造体
    max_flow(G,s,t) ：グラフGの最大流が求まる
    副作用：G は最大流の残余ネットワークになる
    計算量: O(|f*||E|) (f*:最大流) 
*/
template <class T>
struct FordFulkerson {
    const T INF = 1e9;
    vector<int> used;
    FordFulkerson(){};
    T dfs(Graph<T>& G, int v, int t, T f) {  // 増加可能経路を見つけて増加分のフローを返す
        if (v == t) return f;
        used[v] = true;
        for (auto& e : G[v]) {
            if (!used[e.to] && e.cap > 0) {
                T d = dfs(G, e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    G.redge(e).cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
    T max_flow(Graph<T>& G, int s, int t) {
        T flow = 0;
        while (true) {
            used.assign(G.size(), 0);
            T f = dfs(G, s, t, INF);  // f が増加分のフロー
            if (f == 0) {
                return flow;
            } else {
                flow += f;
            }
        }
        return 0;
    }
};
int main() {
    int X, Y, E;
    cin >> X >> Y >> E;
    Graph<int> G(X + Y + 2);
    for (int i = 0; i < X; i++) {  // ソース(0)から X(1~X) への辺
        G.add_edge(0, i + 1, 1);
    }
    for (int i = 0; i < E; i++) {  // X(1~X) から Y(X+1~X+Y) への辺
        int x, y;
        cin >> x >> y;
        G.add_edge(x + 1, y + X + 1, 1);
    }
    for (int i = 0; i < Y; i++) {  // Y(X+1~X+Y) からシンク(X+Y+1)への辺
        G.add_edge(i + X + 1, X + Y + 1, 1);
    }
    FordFulkerson<int> ff;
    cout << ff.max_flow(G, 0, X + Y + 1) << endl;
}


Measured memory_bytes: 3296
package main;

import "fmt"

func main() {
	var sx, sy, tx, ty int
	fmt.Scan(&sx, &sy, &tx, &ty)

	dx := tx - sx
	dy := ty - sy
	ans := ""
	for i := 0; i < dx; i++ {
		ans += "R"
	}
	for i := 0; i < dy; i++ {
		ans += "U"
	}
	// -------
	for i := 0; i < dx; i++ {
		ans += "L"
	}
	for i := 0; i < dy; i++ {
		ans += "D"
	}
	// -------

	ans += "D"
	for i := 0; i < dx; i++ {
		ans += "R"
	}
	ans += "R"
	ans += "U"
	for i := 0; i < dy; i++ {
		ans += "U"
	}
	ans += "L"
	// -------

	ans += "U"
	for i := 0; i < dx; i++ {
		ans += "L"
	}
	ans += "L"
	ans += "D"
	for i := 0; i < dy; i++ {
		ans += "D"
	}
	ans += "R"
	fmt.Println(ans)
}


Measured memory_bytes: 7808
import sys
input=sys.stdin.readline

H,W=map(int, input().split())
C = [[] for i in range(H)]

for h in range(H):
    C[h] = list(input().strip())
#print(*C)

for h in range(H):
    for w in range(W):
        if C[h][w] == "#":
            if h == 0 or (h>0 and C[h-1][w] == "."):
                if w == 0 or (w>0 and C[h][w-1] == "."):
                    if w == W-1 or (w<W-1 and C[h][w+1] == "."):
                        if h == H-1 or (h<H-1 and C[h+1][w] == "."):
                            print("No")
                            exit()
print("Yes")


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define INF 1e6
int H,W,N,sr,sc;
char S[202020],T[202020];
int ss[4][202020], tt[4][202020];
int i,j,k,ans;
char s[] = "DURL";
int p[] = {1, -1,1,-1};

void Ans(int a,int mn,int mx,int pt){
    vector<int> mm(2);
    mm[0] = mx;
    mm[1] = mn;
    for (i = N - 1; i >= 0;i--)
    {
        fornum(k,a,2+a){
            if(T[i]==s[k]){
                mm[k & 1 ^ 1] -= p[k];
                if(mm[0]>mx){
                    mm[0] = mx;
                }
                if(mm[1]<mn){
                    mm[1] = mn;
                }
            }
        }
        fornum(k,a,2+a){
            if(S[i]==s[k]){
                mm[k & 1] -= p[k];
                if(mm[0]<mm[1]){
                    printf("NO");
                    exit(0);
                }
            }
        }
    }
    if(mm[0]<pt||mm[1]>pt){
        printf("NO");
        exit(0);
    }
    //printf("%d,%d,%d\n", mm[0], mm[1],pt);
    
}

int main(){
    scanf("%d%d%d%d%d%s%s", &H,&W,&N,&sr,&sc,S,T);
    Ans(0, 1, H,sr);
    Ans(2, 1, W,sc);
    printf("YES");
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define alpha_size 26

int power(int a, int b) {
  int res = 1ll;
  while (b) {
    if (b & 1) res = res * a;
    a = a * a, b >>= 1;
  }
  return res;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);    
     
    int n, k;
    cin >> n >> k;
    int ans = k;
    if (n == 1){
      cout << ans << endl;
      return 0;
    }
    ans *= power(k - 1, n - 1);
    cout << ans << endl;
}

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

using namespace std;

#define int long long
#define  IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int INF = 1e9;

signed main() {
    int k, n;
    cin >> k >> n;
    vector<int> p(2 * n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
        p[n + i] = p[i];
    }
    vector<int> diff(2 * n + 1);
    for (int i = 2; i <= n; i++) {
        diff[i] = p[i] - p[i - 1];
    }
    diff[n + 1] = k - p[n] + p[1];
    for (int i = n + 2; i <= 2 * n; i++) {
        diff[i] = diff[i - n];
    }
    for (int i = 2; i <= 2 * n; i++) {
        diff[i] += diff[i - 1];
    }
    int ans = INF;
    for (int i = 2; i <= n + 1; i++) {
        ans = min(ans, diff[i + n - 2] - diff[i - 1]);
    }
    cout << ans << "\n";
    return 0;
}

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

int main() {
  int N;
  map<int, int> as;

  cin >> N;
  int a;
  for(int i = 0; i < N; ++i) {
    cin >> a;
    as[a]++;
  }
  int total = 0;
  for(auto a : as) {
    if(a.second - a.first >= 0) {
      total += a.second - a.first;
    } else {
      total += a.second;
    }
  }
  cout << total << endl;
  return 0;
}

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

studentlis = []
for _ in range(N):
    a, b = map(int, input().split())
    studentlis.append([a,b])

checkpointlis = []
for _ in range(M):
    c, d = map(int, input().split())
    checkpointlis.append([c,d])

ans_lis = []


for i in range(len(studentlis)):
    ans = int(10**100)

    tmpstudentlis = studentlis[i]

    x1 = tmpstudentlis[0]
    y1 = tmpstudentlis[1]
    
    for j in range(len(checkpointlis)):
        tmpcheckpointlis = checkpointlis[j]

        x2 = tmpcheckpointlis[0]
        y2 = tmpcheckpointlis[1]
        
        distance = (abs(x1-x2) + abs(y1-y2))

        if distance < ans:
            ans = distance
            num = j

        if j == len(checkpointlis)-1:
            ans_lis.append(num+1)


for i in ans_lis:
    print(i)

Measured memory_bytes: 3064
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
        
    
    return a

from collections import Counter

n = int(input())
if n == 1:
    print(0)
else:
    a = prime_factorize(n)
    c = Counter(a)
    ans = 0
    for v in c.values():
        temp = 1
        while True:
            v -= temp
            if v >= 0:
                ans +=1
                temp += 1
            else:
                break
    print(ans)

Measured memory_bytes: 9444
#include <bits/stdc++.h>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(LLI i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=998244353;
//
LLI modpow(LLI a,LLI b,LLI m){
    LLI ret=1;
    while(b>0){
        if(b&1)(ret*=a)%=m;
        (a*=a)%=m;
        b>>=1;
    }
    return ret;
}

vector<LLI> kaijo[2];
vector<LLI> gyaku[2];
void comb1(int k,LLI n,LLI m){
    kaijo[k].PB(1);
    FOR(i,1,n+1){
        kaijo[k].PB((kaijo[k][i-1]*i)%m);
    }
    FOR(i,0,n+1){
        gyaku[k].PB(modpow(kaijo[k][i],m-2,m));
    }
}
LLI comb2(int k,LLI n,LLI r,LLI m){
    return (((kaijo[k][n]*gyaku[k][n-r])%m)*gyaku[k][r])%m;
}

int main(void){
    LLI n,a,b,k; cin>>n>>a>>b>>k;
    LLI ans=0;
    comb1(0,n,MOD);
    FOR(x,0,n+1){
        LLI y=(k-a*x)/b;
        if(0<=y&&y<=n&&a*x+b*y==k){
            ans=(ans+comb2(0,n,x,MOD)*comb2(0,n,y,MOD))%MOD;
        }
    }
    co(ans);
}


Measured memory_bytes: 12396
#include "bits/stdc++.h"
using namespace std;

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define REVREP(i, n)      for(ll i = n - 1; i >= 0 ; i--)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               2e9
#define INF_LL            1LL<<60
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
ll _accumulate(const VL &v) { return accumulate(ALL(v), (ll)0); }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// 処理
void Solve()
{
	ll N;
	cin >> N;
	map<ll, ll> a;
	REP(i, N) {
		ll _a;
		cin >> _a;
		a[_a]++;
	}

	string ans = "No";
	if (1 == a.size()) {
		if (a[0] == N) ans = "Yes";
	} else if (2 == a.size()) {
		if (a[0] * 3 == N) {
			ans = "Yes";
		}
	} else if (3 == a.size()) {
		ll calRes = 0;
		for (auto one : a) {
			if (one.second * 3 != N) {
				calRes = -1;
				break;
			}
			calRes ^= one.first;
		}
		if (calRes == 0) ans = "Yes";
	}

	cout << ans << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 5120
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        sc.useDelimiter(",");
//        DecimalFormat df = new DecimalFormat("0.00000000");
        int n = Integer.parseInt(sc.next());
        int a;
        boolean ans = true;
        for (int i = 0; i < n; i++) {
            a = Integer.parseInt(sc.next());
            if (a % 2 == 0 && a % 3 != 0 && a % 5 != 0) ans = false;
        }
        out.println(ans ? "APPROVED" : "DENIED");
        out.flush();
    }
}

Measured memory_bytes: 21844
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long k = sc.nextLong();
        long x = n % k;
        long min = x;
        if(min > Math.abs(x - k)){
            min = Math.abs(x - k);
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

typedef struct {
	vector <int> to;
	int cost;
} edge;
int main( void ){
	string S; cin >> S;
	int N = S.size();
	vector<int> vec(N+1, 0);
	rep(i,0,N+1)
		if ( S[i] == '<')
			vec[i+1]=vec[i]+1;
	rep_d(i,N,0)
		if (S[i]=='>')
			vec[i] = max(vec[i], vec[i+1]+1);
	ll sum = 0;
	for(auto v:vec)
		sum += v;
	cout << sum << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 2820
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f40;
const long long mod=1e9+7;
const long double PI = acos(0);
// }}} End Header
int main() {
	ll min = INF, cnt=0;
	string s, t;
	cin >> s >> t;
	for(ll i=0; i+t.length()<=s.length(); i++){
		string k = s.substr(i,t.size());
		//cout << k << endl;
		cnt = 0;
		rep(j,k.size()){
			if(k[j] != t[j]) cnt++; 
		}
		if(cnt <= min) min = cnt;
	}
	cout << min << endl;
	return 0;
}

Measured memory_bytes: 3604
N, M = map(int, input().split())
isAC = [False] * N
numWA = [0] * N
for i in range(M):
  p_str, S = map(str, input().split(' '))
  p = int(p_str) - 1
  if S == 'AC':
    isAC[p] = True
  else:
    if isAC[p]:
      continue
    numWA[p] += 1
    
ac = 0
wa = 0
for i in range(N):
  if isAC[i]:
    ac += 1
    wa += numWA[i]
print(str(ac) + " " + str(wa))
  
  

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

int main() {
	int N; cin >> N;
	int X = N;
	int sum = 0;
	while (N) {
		sum += N % 10;
		N /= 10;
	}

	cout << (X%sum == 0 ? "Yes" : "No") << endl;
	
	return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
import sys
n, y = map(int, input().split())
for a in range(n+1):
    for b in range(n+1-a):
        if 5000*a+9000*b == 10000*n-y and n-a-b >= 0:
            print(str(n-a-b)+' '+str(a)+' '+str(b))
            sys.exit()
        else:
            pass
'''
for a in range(n+1):
    for b in range(n-a+1):
        for c in range(n-a-b+1):
            if 10000*a+5000*b+1000*c == y:
                print(str(a)+' '+str(b)+' '+str(c))
                sys.exit()
            else:
                pass
'''
print("-1 -1 -1")

Measured memory_bytes: 3060
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


int main(int argc, const char * argv[]) {
    for (int i = 0; i < 5; i++) {
        int x; cin >> x;
        if (x == 0) {
            cout << i + 1 << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3156
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    char[] c = s.toCharArray();
    
    String bf = "";
    String af = "";
    
    for(int i=0; i<n/2; i++){
      bf += c[i];
    }
    
    for(int j=n/2; j<n; j++){
      af += c[j];
    }
    
    if(bf.equals(af)){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 23252
a, b = map(int, raw_input().split())
c = raw_input()
m = b - 1
x = -1
w = ""
y = len(c)
ans = ""
for i in range(a):
    x = x + 1
    if x == m:
        z = c[x].lower()
    else:
        z = c[x]
    ans = ans + z
print ans

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		2505

const ll LINF = (ll)1e18+7;		//
const int INF = 1e9+7;			//2,147,483,647 (Max int)
const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//

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

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

	ll A,B;
	A=B=1;

	REP(i,N){
		ll l,r;
		cin >>l>>r;

		ll a = max(ceill((long double)A/l),ceill((long double)B/r));
		A = a*l;B = a*r;
	}

	cout << (ll)(A+B) << endl;


	return 0;
}




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

int cnt=0;

void count(int n){

  if(n<=3){
    cnt++;
    return;
  }

  int a,b,c;

  if(n%3>1){
    a = n / 3 + 1;
    b = a;
  }else{
    a = n / 3;
    b = a;
  }
  c = n - (a + b);

  //cout << a << " " << b <<" " << c << endl;

  int m = max(a,c);
  if(m>=2){
    count(m);
    cnt++;
  }
  return;
}

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

  count(n);

  cout << cnt << endl;

  return 0;
}

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

int main(){
	int a,b;
	cin >> a >> b;
	int ans=6;
	cout << ans - a- b << endl;

	return 0;

}




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

typedef long long ll;

int main() {
    ll N;
    cin >> N;
    vector<ll>A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    unsigned long long  total = 1;
    unsigned long long before;
    if (A[0] == 0) {
        cout << 0 << endl;
        return 0;
    } else {
        for (int i = N-1; i >= 0; i--) {
            before = total; 
            if (A[i] == 0) {
                cout << 0 << endl;
                return 0;
            }
            total *= A[i];
            if (total > 1000000000000000000 || total < before) {
                cout << -1 << endl;
                return 0;
            }
        }
        cout << total << endl;
    }
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, p;
  cin >> n >> p;
  vl cnt(2, 0);
  rep(i, n) {
    ll a;
    cin >> a;
    cnt[a % 2]++;
  }
  vector<vl> c(51, vl(51, 0));
  rep(i, 51) rep(j, 51) {
    if(j == 0)
      c[i][j] = 1;
    else if(i != 0)
      c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
  }
  ll ans = 0;
  rep(i, cnt[1] + 1) if(i % 2 == p) ans += c[cnt[1]][i];
  ans *= 1LL << cnt[0];
  cout << ans << endl;
}

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

typedef long long ll;
#define PI 3.1415926535897932384626433
#define mod 1000000007

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

int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(){
    int x;
    cin >> x;
    for (int i = 1;; i++){
        x -= i;
        if (x <= 0){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define arep(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

const ll INF = 1LL << 50;

template <class T>
class WarshallFloyd {
    private:
        T identity;
        vector<vector<T> > dist;
    public:
        WarshallFloyd(int node_num, T _identity):
        identity(_identity), dist(vector<vector<T>>(node_num, vector<T>(node_num, _identity))) {}
        void add_edge(int from, int to, T cost) {
            dist[from][to] = cost;
        }
        void calc_shortest_path() {
            int n = (int)dist.size();
            for (int k = 0; k < n; k++) {
                for (int i = 0; i < n; i++) {
                    for (int j = 0; j < n; j++) {
                        if (dist[i][k] == identity || dist[k][j] == identity) continue;
                        if (dist[i][j] > dist[i][k] + dist[k][j]) {
                            dist[i][j] = dist[i][k] + dist[k][j];
                        }
                    }
                }
            }
        }
        T get_dist(int from, int to) {
            return dist[from][to];
        }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M, L;
    cin >> N >> M >> L;
    vector<ll> A(M), B(M), C(M);
    WarshallFloyd<ll> graph1(N, INF);
    rep(i, 0, M) {
        cin >> A[i] >> B[i] >> C[i];
        --A[i], --B[i];
        graph1.add_edge(A[i], B[i], C[i]);
        graph1.add_edge(B[i], A[i], C[i]);
    }
    graph1.calc_shortest_path();
    WarshallFloyd<ll> graph2(N, INF);
    rep(i, 0, N) rep(j, i + 1, N) {
        ll min_dist = graph1.get_dist(i, j);
        if (min_dist <= L) {
            graph2.add_edge(i, j, 1);
            graph2.add_edge(j, i, 1);
        }
    }
    graph2.calc_shortest_path();
    int Q;
    cin >> Q;
    vector<ll> S(Q), T(Q);
    rep(i, 0, Q) {
        cin >> S[i] >> T[i];
        --S[i], --T[i];
    }
    rep(i, 0, Q) {
        ll ans = graph2.get_dist(S[i], T[i]);
        if (ans == INF) cout << -1 << endl;
        else cout << ans - 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

bool DEBUG=0;
const int MAXN = 100005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n,K; cin>>n>>K;
	int a[n];
	forn(i,0,n) cin>>a[i];
	sort(a,a+n);
	ll sum=0;
	forn(i,0,K) sum+=a[i];
	cout<<sum<<'\n';
	
	return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define fo(i,m,n) for(int i = m; i <= n; i++)
#define fod(i,m,n) for(int i = m; i >= n; i--)
#define fov(i,x) for(auto &i : x)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> _ii;
i64 n,k,sum = 0;
i64 f[101][2];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n >> k;
	f[1][1] = 1;
	f[1][0] = 0;
	f[0][0] = 1;
	f[0][1] = 1;
	fo(i,2,n)
	{
		f[i][0] = f[i-1][1];
		f[i][1] = f[i-1][0];
		if(i >= k) f[i][1] += f[i-k][0];
	}
	fo(i,1,n) sum += f[i][1];
	cout << sum << '\n';
}


Measured memory_bytes: 3212
#include<cstdio>
#include<cstring>
#include<iostream>
#define in inline
#define re register
#define int long long
#define M 1000000007
using namespace std;
in int read() {
	re int t=0;
	re char v=getchar();	
	while(v<'0'||v>'9'){
	v=getchar();
	}	
	while(v>='0'&&v<='9'){		
	t=(t<<3)+(t<<1)+(v^48);		
	v=getchar();	}
	return t;
}
int f[100002],a[100002],b,c,d,cnt[100002],n;
signed main(){
n=read();
for(re int i=1;i<=n;++i)a[i]=read();
f[0]=1;
for(re int i=1;i<=n;++i){
	if(a[i]==0)f[i]=f[i-1]*(3-cnt[0]);
	else f[i]=f[i-1]*(cnt[a[i]-1]-cnt[a[i]]);
	f[i]%=M;
	++cnt[a[i]];
}
cout<<f[n];
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    ll N;
    cin >> N;

    Vl divs;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            divs.push_back(i);
            if (i * i != N) {
                divs.push_back(N / i);
            }
        }
    }

    unordered_set<ll> Ks;
    for (const auto& d : divs) {
        if (d == 1) continue;
        ll N_tmp = N;
        while (N_tmp % d == 0) {
            N_tmp /= d;
        }
        if (N_tmp % d == 1) Ks.insert(d);
    }

    divs.clear();
    N -= 1;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            divs.push_back(i);
            if (i * i != N) {
                divs.push_back(N / i);
            }
        }
    }

    for (const auto& d : divs) {
        if (d == 1) continue;
        Ks.insert(d);
    }

    cout << Ks.size() << endl;

    return 0;
}

Measured memory_bytes: 384
#include <cstdio>

using namespace std;

int main(){
	char b[10],a[3][3];
	while(~scanf("%s",b)){
		char r=0;
		for(int i=0;i<9;i++)
			a[i%3][i/3]=b[i];
		for(int i=0,j,f;i<3;i++){
			if(a[i][0]=='s')continue;
			for(j=0,f=1;j<3;j++)
				if(a[i][0]!=a[i][j])f=0;
			if(f)r=a[i][0];
		}
		for(int i=0,j,f;i<3;i++){
			if(a[0][i]=='s')continue;
			for(j=0,f=1;j<3;j++)
				if(a[0][i]!=a[j][i])f=0;
			if(f)r=a[0][i];
		}
		if(a[0][0]!='s'&&a[0][0]==a[1][1]&&a[0][0]==a[2][2])r=a[0][0];
		if(a[2][0]!='s'&&a[2][0]==a[1][1]&&a[2][0]==a[0][2])r=a[2][0];
		printf("%c\n", r?r:'d');
	}
	return 0;
}

Measured memory_bytes: 0
s = gets.chomp.chars
size = s.size - 2
count1 = 0
if s.first == "A"
  2.upto(size) do |i|
    if s[i] == "C"
      count1 += 1
    end
  end
end

count2 = 0
s.each do |char|
  unless ("a".."z").include?(char)
    count2 += 1
  end
end

if count1 == 1 && count2 == 2
  puts "AC"
else
  puts "WA"
end


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

int N;

int t[100010];
int x[100010];
int y[100010];

int main()
{
    cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    cin >> N;
    for(int i = 1;i <= N;i++) cin >> t[i] >> x[i] >> y[i];

    int dist, limit;
    for (int i=1; i<=N; ++i) {
        dist = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
        limit = t[i] - t[i - 1];
        if ( !(dist <= t[i] && limit % 2 == dist % 2) ) goto NO;
    }

    puts( "Yes" );
    return 0;
NO:
    puts( "No" );
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  if (n == 1) {
  	cout << "Hello World" << '\n';
  } else {
  	int a, b;
    cin >> a >> b;
    cout << a + b << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  int a[100000];
  cin >> n;
  for(int i = 0; i < n; i++) cin >> a[i];

  vector<int> vec;
  for(int i = 0; i < n; i++){
    int cnt = 1;
    while(a[i] != a[i + 1] && i != n - 1){
      cnt++;
      i++;
    }
    vec.push_back(cnt);
  }

  int ans = 0;
  if(vec.size() <= 2) ans = n;
  else{
    for(int i = 0; i < vec.size() - 2; i++){
      if(vec[i] + vec[i + 1] + vec[i + 2] > ans) ans = vec[i] + vec[i + 1] + vec[i + 2];
    }
  }

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

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, k; scanf("%d%d", &n, &k); std::vector<i64> a(n);
	for(int i = 0; i < n; i++) scanf("%lld", &a[i]);
	sort(begin(a), end(a)); reverse(begin(a), end(a));

	i64 ans = 0;
	for(int i = k; i < n; i++) ans += a[i];
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
using namespace std;
int main(){
  int N;
  double x = 0;
  cin >> N;
  for(int i = 0; i < N; i ++)
 {
  double xi;
  string ui;
  cin >> xi;
  cin >> ui;
  if (ui == "JPY")
    {
    x = x + xi;
  } else {
    x = x + 380000.0 * xi;
    }
  }
  cout << x << endl;
  return 0;
}


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

const int N = 1e5 + 10;
bool mark[N];
int n, ans, q;
vector<int> g[N];

void dfs(int v){
	mark[v] = 1;
	for (int u : g[v])
		if(!mark[u])
			dfs(u);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin >> n >> q;
	for (int i = 0; i < q; i++){
		int v, u, w;
		cin >> v >> u >> w;
		v--;u--;
		
		g[v].push_back(u);
		g[u].push_back(v);
	}
	
	for (int i = 0; i < n; i++){
		if(!mark[i]){
			dfs(i);
			ans++;
		}
	}
	
	cout << ans;
	
}



Measured memory_bytes: 8960
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
  int H, W, N;
  cin >> H >> W >> N;
  int a[N];
  for(int i = 0; i < N; i++) cin >> a[i];

  int answer[H][W];
  int color = 0;
  for(int h = 0; h < H; h++){
    int direction, w;
    if(h%2 == 0){
      direction = 1;
      w = 0;
    }else{
      direction = -1;
      w = W-1;
    }
    for(; (0 <= w)&&(w < W); w+=direction){
      if(a[color] <= 0) color++;
      answer[h][w] = color+1;
      a[color]--;
    }
  }

  for(int h = 0; h < H; h++){
    for(int w = 0; w < W; w++) cout << answer[h][w] << " ";
    cout << "\n";
  }
  return 0;
}

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

double a, b, c, d;

int main() {
  cin >> a >> b >> c >> d;
  if (ceil(c/b) <= ceil(a/d)) {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
int main(){
    string n;
    cin >> n;
    int ans1=0;
    for(int i=0; i<n.size(); i++){
        ans1 += (n[i]-'0');
    }
    int ans2= (n[0]-'0')-1;
    for(int i=0; i<n.size()-1;i++){
        ans2 += 9;
    }
    cout << max(ans1,ans2) << endl;
}




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

int main(void) {
	int X; cin >> X;

	if (X == 3 || X == 5 || X == 7) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }

	return 0;
}



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

def keisan(f):
  sum=0
  while f!=0:
      sum=sum+f%10
      f=f//10
  return sum

total=0

for i in range(n+1):
    k=keisan(i)
    if a<=k and k<=b:
        total+=i
        
print(total)

Measured memory_bytes: 3060
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  std::vector<long long> H(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &H[i]);
  }
  vector<int> sum(N, 0);
  for (int i = 0; i < N - 1; ++i)
  {
    if (H[i + 1] <= H[i])
      sum[i + 1] = sum[i] + 1;
    else
      sum[i + 1] = 0;
  }
  cout << *max_element(sum.begin(), sum.end()) << endl;

  return 0;
}


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

const int NOT_FOUND =-1;

int linersearch(int key,int A[],int n)
{
 int i=0;
 A[n]=key;
 while(A[i]!=key){
	i++;
 }
 if(i==n){
	return NOT_FOUND;
 }
 return i;
}

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

 int S[10001];
 for(int i=0;i<n;i++){
	cin>>S[i];
 }

 int q;
 cin>>q;

 int T[500];
 for(int i=0;i<q;i++){
	cin>>T[i];
 }

 int C=0;
 for(int i=0;i<q;i++){
	if(linersearch(T[i],S,n)!=NOT_FOUND){
		C++;
	}
 }

 cout<< C<<endl;
return 0;
}

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

#define LEN 100005

typedef struct pp {
    char name[100];
    int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
    Q[tail]=x;
    tail = (tail + 1) % LEN;
}

P dequeue() {
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}

int min(int a, int b) { return a < b ? a : b; }

int main(void) {
    int elaps=0, c;
    int i, q;
    P u;
    scanf("%d %d", &n, &q);

    for (i=1; i<=n; i++) {
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head=1;
    tail=n+1;

    while (head!=tail) {
        u=dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if (u.t>0) enqueue(u);
        else printf("%s %d\n", u.name, elaps);
    }
    return 0;
}



Measured memory_bytes: 11892
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b;
  cin >> a >> b;
  int c=b*10;
  bool judge=false;
  for(c;c<(b+1)*10;c++){
    if(c*0.08>=a&&a+1>c*0.08){
      judge=true;
      break;
    }
  }
  if(judge){
   cout << c << endl;
  }
  else{
    cout << "-1" << endl;
  }
}


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

template<class T>
inline bool chmax(T &a,T b){
    if(a<b) return false;
    return true;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    int n,time; cin>>n>>time;
    vector<int> t(n);
    for(int i=0; i<n; i++) cin>>t[i];

    ll sum=0,cnt=0;

    for(int i=0; i<n-1; i++){
        cnt = t[i+1] - t[i];
        if(cnt < time) sum += cnt;
        else sum += time;
    }

    cout<<sum+time<<endl;
    return 0;
}


Measured memory_bytes: 1024
object Main extends App {
  val strAry = io.StdIn.readLine().split(' ')
  val N = strAry(0).toInt
  val K = strAry(1).toInt
  val ar = new Array[Int](N)
  val i = 0
  for (i <- 1 to K){
    val d = io.StdIn.readLine().toInt
    val inStr = io.StdIn.readLine().split(' ')
    for(q <- inStr){
        ar(q.toInt-1) += 1
    }
  }
  var count = 0
  for (i <- 0 to N-1){
    if(ar(i) == 0) {
        count += 1
    }
  }
  println(count)
}

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

int main(){
	int n;
	cin>>n;
	long long s=0;
	for(int i=1; i<=n; i++){
		if(i%3!=0 && i%5!=0){
			s+=i;
		}
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3636
A,B,C=list(map(int,input().split()))
if A==B==C and A%2==0:
    print(-1)
else:
    cnt=0
    while A%2==B%2==C%2==0:
        A,B,C=(B+C)//2,(C+A)//2,(A+B)//2
        cnt+=1
    print(cnt)

Measured memory_bytes: 3060
def solve(A, B, hoge):
    C, D = 0, 0
    turn = 0
    while True:
        if turn % 2 == 0 and hoge == 0:
            n = A + C
            m = min(n, D)
            D -= m
            n -= m
            m = min(n/2, B)
            B -= m
            n -= m*2
            if B > 0 and n > 0:
                B -= 1
                D += 1
        elif turn % 2 == 1 and hoge == 0:
            n = B + D
            m = min(n, A)
            A -= m
            C += m
            n -= m
            m = min(n, C)
            C -= m
            n -= m
        elif turn % 2 == 0 and hoge == 1:
            n = A + C
            m = min(n, B)
            B -= m
            D += m
            n -= m
            m = min(n, D)
            D -= m
            n -= m
        else:
            n = B + D
            m = min(n, C)
            C -= m
            n -= m
            m = min(n/2, A)
            A -= m
            n -= m*2
            if A > 0 and n > 0:
                A -= 1
                C += 1
        if A + C <= 0 or B + D <= 0:
            return turn
        turn += 1

if __name__ == "__main__":
    A, B = map(int, raw_input().split())
    print min(solve(A, B, 0), solve(A, B, 1))



Measured memory_bytes: 4700
class Dice:
    same_dice_index = ((0, 1, 2, 3, 4, 5), (0, 2, 4, 1, 3, 5), (0, 3, 1, 4, 2, 5),
                       (0, 4, 3, 2, 1, 5), (1, 0, 3, 2, 5, 4), (1, 2, 0, 5, 3, 4),
                       (1, 3, 5, 0, 2, 4), (1, 5, 2, 3, 0, 4), (2, 0, 1, 4, 5, 3),
                       (2, 1, 5, 0, 4, 3), (2, 4, 0, 5, 1, 3), (2, 5, 4, 1, 0, 3),
                       (3, 0, 4, 1, 5, 2), (3, 1, 0, 5, 4, 2), (3, 4, 5, 0, 1, 2),
                       (3, 5, 1, 4, 0, 2), (4, 0, 2, 3, 5, 1), (4, 2, 5, 0, 3, 1),
                       (4, 3, 0, 5, 2, 1), (4, 5, 3, 2, 0, 1), (5, 1, 3, 2, 4, 0),
                       (5, 2, 1, 4, 3, 0), (5, 3, 4, 1, 2, 0), (5, 4, 2, 3, 1, 0))

    def __init__(self, str_tpl):
        self.faces = str_tpl

    def is_same(self, dice):
        for i in Dice.same_dice_index:
            for n, j in enumerate(i):
                if dice.faces[n] != self.faces[j]:
                    break
            else:
                return True
        return False


str_tpl1 = tuple(input().split())
dice1 = Dice(str_tpl1)

str_tpl2 = tuple(input().split())
dice2 = Dice(str_tpl2)

if dice1.is_same(dice2):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 7700
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int h,w,k;
  cin>>h>>w>>k;
  int a[h][w],sum=0;
  rep(i,0,h){
    string s;
    cin>>s;
    rep(j,0,w){
      if(s[j]=='.') a[i][j]=0;
      else a[i][j]=1,sum++;
    }
  }
  int ans=0;
  rep(num1,0,1<<h){
    rep(num2,0,1<<w){
      int temp=sum;
      rep(i,0,h) rep(j,0,w) if(((num1>>i)&1 ==1 || (num2>>j)&1==1) && a[i][j]==1) temp--;
      if(temp==k) ans++;
    }
  }
  cout<<ans<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


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

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    int ans[k+1];
    int n = min(a, b);
    int m = 1;
    for(int i = 1; i <= n; i++){
        if(a % i == 0 && b % i == 0){
            ans[m] = i;
            m++;
        }
    }
    cout << ans[m-k] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int h[n]; for (int i = 0; i < n; i++) cin >> h[i];
    int dp[n];
    dp[0] = 0; dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < n; i++) {
        dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]));
    }
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main() {
	int N;
	int ans[10000];
	scanf("%d", &N);
	int i = 0;
	if (N == 0) {
		printf("0\n");
		return 0;
	}
	while (N != 0) {
		if (N % 2 == 0) {
			ans[i] = 0;
		}
		else {
			ans[i] = 1;
			N--;
		}
		N /= -2;
		i++;
	}
	i--;
	for (; i >= 0; i--) {
		printf("%d", ans[i]);
	}
	printf("\n");
		return 0;
}

Measured memory_bytes: 128
#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>

int main(){
  ll N;  cin >> N;
  VL a(N); 
  ll ans = 0;
  rep(i,0,N){
    cin >> a[i];
    ans += a[i] - 1;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  int res = N;
  for(int i = 0; i <=N; ++i){
    int cc = 0;
    int t = i;
    while(t > 0){
      cc += t%6;
      t /= 6;
    }
    t = N - i;
    while(t > 0){
      cc += t%9;
      t /= 9;
    }
    if(res>cc) res = cc;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
c = list(map(int, input().split()))

if len(set(c)) == 1 and c[0] % 2 == 0:
    print(-1)
    exit()

cnt = 0
while c[0] % 2 != 1 and c[1] % 2 != 1 and c[2] % 2 != 1:
    c = [c[1]/2 + c[2]/2, c[0]/2 + c[2]/2, c[0]/2 + c[1]/2]
    cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
typedef pair<ll,ll> P;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

ll H,N;

ll dp[10001];
ll d[1001][2];

int main(){
    cin>>H>>N;
    rep(i,H) dp[i]=INF;
    rep(i,N) cin>>d[i][0]>>d[i][1];
    for(ll i=H;i>0;i--){
        if(dp[i]<INF){
            rep(j,N){
                ll a=d[j][0], b=d[j][1];
                ll K=max(ll(0),i-a);
                dp[K]=min(dp[K],dp[i]+b);
            }
        }
    }
    cout<<dp[0]<<endl;
    

}

Measured memory_bytes: 384
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>


#define ll long long
#define int ll
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

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

const int N = 2e3 + 1;

int n ;
int d[N], cnt[N] , a[N] , f[N][N];
ll ans = 0;

main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	cin >> n;

	for(int i = 1; i <= n; i++){
		cin >> a[i];	
		cnt[a[i]]++;
	}
	for(int i = 1;  i <= 1000 ; i++)
		cnt[i] += cnt[i - 1];
	sort(a + 1 , a + 1 + n);
	ll res = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= 1000 ; j++)
			f[i][j] = f[i - 1][j];
		int x = a[i];
		for(  ; x <= 1000; x += x&-x)
			f[i][x]++;
		for(int j = i - 1; j > 0; j--){
			int x = a[i] - a[j];
			for( ; x > 0 ; x -= x & -x)
				res += f[j - 1][x];				
		}
	}
	res = n * (n - 1) * (n - 2) / 6 - res;
	cout << res;

}

Measured memory_bytes: 30976
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        n: usize,
        a: usize,
        b: usize,
    }
    let mut ans = 0;
    for i in 1..n + 1 {
        let val = i;
        let cs = val.to_string();
        let mut v = 0;
        for c in cs.chars() {
            let parsed_val: usize = c.to_string().parse().unwrap();
            v += parsed_val;
        }
        if v >= a && v <= b {
            ans += val;
        }
    }
    println!("{:?}", ans);
}


Measured memory_bytes: 4352