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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

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

    int n, m, k;
    cin >> n >> m >> k;
    vector<string> grid(n);
    for (auto& row : grid) {
        cin >> row;
    }

    vector<pii> region;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (grid[i][j] == '#') {
                region.emplace_back(i, j);
            }
        }
    }

    using state = tuple<int, int, int, int, vector<pii>>;
    queue<state> q;
    q.emplace(0, 0, n, m, region);

    vector<vi> ans(n, vi(m, -1));
    int label = 1;
    while (!q.empty()) {
        state s = q.front();
        q.pop();
        int x1, y1, x2, y2;
        vector<pii> pts;
        tie(x1, y1, x2, y2, pts) = s;
        assert(!pts.empty());
        if (pts.size() == 1) {
            for (int i = x1; i < x2; ++i) {
                for (int j = y1; j < y2; ++j) {
                    ans[i][j] = label;
                }
            }
            ++label;
        } else {
            int px1, py1, px2, py2;
            tie(px1, py1) = pts[0];
            tie(px2, py2) = pts[1];

            if (px1 == px2) {
                // vertical line split
                if (py1 > py2) {
                    swap(px1, px2);
                    swap(py1, py2);
                }
                vector<pii> left, right;
                for (auto& p : pts) {
                    int yy = p.second;
                    if (yy < py2) {
                        left.push_back(p);
                    } else {
                        right.push_back(p);
                    }
                }
                q.emplace(x1, y1, x2, py2, left);
                q.emplace(x1, py2, x2, y2, right);
            } else {
                if (px1 > px2) {
                    swap(px1, px2);
                    swap(py1, py2);
                }

                vector<pii> top, bot;
                for (auto& p : pts) {
                    int xx = p.first;
                    if (xx < px2) {
                        top.push_back(p);
                    } else {
                        bot.push_back(p);
                    }
                }
                q.emplace(x1, y1, px2, y2, top);
                q.emplace(px2, y1, x2, y2, bot);
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cout << ans[i][j] << ' ';
        }
        cout << '\n';
    }
    cout << '\n';

    /*
    vector<vi> dp(n + 1, vi(m + 1, 0));
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            dp[i][j] = (grid[i - 1][j - 1] == '#') + dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1];
        }
    }
    */
    
    return 0;
}


Measured memory_bytes: 5432
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  string str;
  cin>>str;
  map<char,int> mp;
  for (int i = 0; i < str.size(); i++)
  {
    mp[str[i]]++;
  }
  int MAX = 0;
  int MIN = INF;
  for (auto &&i : mp)
  {
    chmax(MAX,i.second);
    chmin(MIN,i.second);
  }
  if(mp.size() < 3) MIN = 0;
  if(MAX - MIN > 1)
  {
    cout<<"NO"<<endl;
  }
  else
  {
    cout<<"YES"<<endl;
  }
  
  
  
   
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <bitset>

using namespace std;

int N, M;
int k[10];
int s[10][10];
int p[10];

int ans = 0;

void check(vector<int> v) {
		bitset<10> bst;
		bst.set();
		for (int i = 0; i < M; i++) {
				int on = 0;
				for (int j = 0; j < k[i]; j++) {
						if(v[s[i][j]-1]) on++;
				}
				if (on % 2 != p[i]) bst[i] = false;
		}

		if (bst.all()) ans++;
}

void dfs(int depth, vector<int> v) {
		if (depth == N) check(v);
		else {
				for (int i = 0; i <= 1; i++) {
						v[depth] = i;
						dfs(depth+1, v);
				}
		}
}

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

		for (int i = 0; i < M; i++) {
				cin >> k[i];
				for (int j = 0; j < k[i]; j++) {
						cin >> s[i][j];
				}
		}

		for (int i = 0; i < M; i++) cin >> p[i];

		vector<int> v(N, 0);
		dfs(0, v);

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


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val cnt = mutableListOf<Pair<Int, Int>>()
    val ab = (1..n).map {
        val x = readLine()!!.split(" ").map { it.toInt() }
        Pair(x[0], x[1])
    }.sortedBy { it.second }.sortedBy { it.first }
    var m = 0
    for (i in 0 until n - 1) {
        for (j in i + 1 until n) {
            val x = ab[j].first - ab[i].first
            val y = ab[j].second - ab[i].second
            cnt.add(Pair(x, y))
        }
    }
    for ((i, j) in cnt) {
        m = Math.max(m, cnt.count { it == Pair(i, j) })
    }
    println(n - m)
}

Measured memory_bytes: 60712
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) sort(v.begin(), v.end())
typedef long long ll;
using Graph = vector<vector<int>>;

int main(){
  int n, k;
  cin >> n >> k;
  vector<char> s(n);
  rep(i,n){
    cin >> s.at(i);
  }
  rep(i,n){
    if(i==k-1){
      s.at(i) = tolower(s.at(i));
    }
  }
  rep(i,n){
    cout << s.at(i);
  }
  cout << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
// #include <atcoder/all>

using boost::multiprecision::cpp_int;
using namespace std;
// using namespace atcoder;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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; }

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  ll res = LLONG_MAX;
  rep(i, max(x, y)+1){
    ll cost = 2*c*i + max(0ll, (x-i))*a + max(0ll, (y-i))*b;
    chmin(res, cost);
  }

  cout << res << endl;
}


Measured memory_bytes: 3632
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[100001];
        long ans = 0L;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            array[a]++;
            ans += a;
        }
        int q = sc.nextInt();
        for (int i = 0; i < q; i++) {
            int b = sc.nextInt();
            int c = sc.nextInt();
            ans = ans + (long)array[b] * (long)(c - b);
            System.out.println(ans);
            array[c] += array[b];
            array[b] = 0;
        }
    }
}

Measured memory_bytes: 61844
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, c, k;
  int t;
  cin >> n >> c >>k;
  vector<int> vec;
  REP(i,n){
      cin >> t;
      vec.push_back(t);
  }
  SORT(vec);
  int cnt = 0;
  int start = -INF;
  int ans = 0;
  for (auto v:vec){
          if (cnt<c && (v-start)<=k){
              cnt++;
          }else{
              cnt = 1;
              start = v;
              ans++;
          }
  }
  cout << ans << endl;
}

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

	int s1 = s / 100;
	int s2 = s % 100;

	if((s1==0 || s1>12) && (s2>0 && s2<=12))
		cout << "YYMM" << endl;
	else if((s1>0 && s1<=12) && (s2==0 || s2>12))
		cout << "MMYY" << endl;
	else if((s1>0 && s1<=12) && (s2>0 && s2<=12))
		cout << "AMBIGUOUS" << endl;
	else cout << "NA" << endl;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
using namespace std;
char A[9];
#define I(s)strtol(s.c_str(),NULL,10)
string S(int i,int L){sprintf(A,"%0*d",L,i);return A;}
int main(){
	for(int a,L;scanf("%d%d",&a,&L),L;){
		vector<int>v;v.push_back(a);
		for(;;v.push_back(a)){
			string t=S(a,L),s;
			sort(t.begin(),t.end());
			s=t;
			reverse(s.begin(),s.end());
			a=I(s)-I(t);
			vector<int>::iterator it=find(v.begin(),v.end(),a);
			if(it!=v.end()){
				printf("%d %d %d\n",it-v.begin(),a,v.size()-(it-v.begin()));
				break;
			}
		}
	}
}

Measured memory_bytes: 1116
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
import java.util.Stack;

public class Main {
	
	public static int[] next(int[] prev) {
		int[] curr = new int[prev.length];
		for(int i = 0; i < prev.length; i++) {
			int x = prev[i];
			int l = Math.max(0, i - x), r = Math.min(prev.length - 1, i + x);
			curr[l]++;
			if(r + 1 < prev.length) {
				curr[r + 1]--;
			}
		}
		for(int i = 1; i < curr.length; i++) {
			curr[i] += curr[i - 1];
		}
		return curr;
	}
	
    public static void main(String[] args) throws IOException {
    	BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    	String[] input = reader.readLine().split(" ");
    	int n = Integer.parseInt(input[0]), k = Integer.parseInt(input[1]);
    	int[] arr = new int[n];
    	input = reader.readLine().split(" ");
    	for(int i = 0; i < n; i++) {
    		arr[i] = Integer.parseInt(input[i]);
    	}
    	while(k-->0) {
    		arr = next(arr);
    		if(arr[0] == n) {
    			break;
    		}
    	}
    	StringBuffer strbf = new StringBuffer();
    	for(int i = 0; i < n; i++) {
    		strbf.append(arr[i] + " ");
    	}
//    	System.out.println(k);
    	System.out.println(strbf.toString());
    }
}


Measured memory_bytes: 67580
ans="No"
A=3
t=[0]*A
x=[0]*A
y=[0]*A
for i in range(A):
    t[i], x[i], y[i] = map(int, input().split())
#print(x[1])

N=int(input())
S=[]
for _ in range(N):
  S.append(input())
#print(S[0])
S1=[int(s) for  s in S]
for i in range(A):
  if t[i] in S1:
    t[i]=0
  if x[i] in S1:
    x[i]=0
  if y[i] in S1:
    y[i]=0
#print(t[0])
if t.count(0)==3:
  ans="Yes"
if x.count(0)==3:
  ans="Yes"
if y.count(0)==3:
  ans="Yes"
if t[0]==0 and x[1]==0 and y[2]==0:
  ans="Yes"
if t[2]==0 and x[1]==0 and y[0]==0:
  ans="Yes"
if t[0]==0 and x[0]==0 and y[0]==0:
  ans="Yes"
if t[1]==0 and x[1]==0 and y[1]==0:
  ans="Yes"
if t[2]==0 and x[2]==0 and y[2]==0:
  ans="Yes"
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
#define endl '\n'

using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    double a,b,c,d;
    cin >> a >> b >> c >> d;
    double t1 = c / b;
    double t2 = a / d;
    if(ceil(t1)<=ceil(t2)){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 3732
W, H, N = map(int, input().split())
wide = [0, W]
height = [0, H]
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        wide[0] = max(wide[0], x)
    elif a == 2:
        wide[1] = min(wide[1], x)
    elif a == 3:
        height[0] = max(height[0], y)
    else:
        height[1] = min(height[1], y)
        
if wide[1] - wide[0] < 0 or height[1] - height[0] < 0:
    print(0)
else:
    print((wide[1] - wide[0]) * (height[1] - height[0]))

Measured memory_bytes: 3064
n = int(input())

l = []
ans = 'Yes'

for i in range(n):
    w = input()

    if l.count(w) >= 1:
        ans = 'No'
        break
    
    if i > 0:
        befor = l[i - 1]

        if w[0] != befor[-1]:
            ans = 'No'
            break

    l.append(w)

print(ans)

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

#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vpii        vector< pii >
#define vi          vector<ll>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			1'010'000'000'000'000'017LL
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define sz(x)       (ll)x.size()
#define rep(i,a,b)	for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )

using namespace std;

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


void Main()
{
	ll a;
	cin >> a;
	ll result = a + pow(a, 2) + pow(a, 3);
	cout << result << endl;
}


int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	Main();
	return 0;
}


Measured memory_bytes: 4020
n = int(input())
d, x = map(int, input().split())
A = [int(input()) for _ in range(n)]
cnt = 0
for i in range(n):
    j = 0
    while j * A[i] + 1 < d + 1:
        cnt += 1
        j += 1
print(x + cnt)

Measured memory_bytes: 3060
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

class UF
{
private:
	int         num;
	vector<int> par;
	vector<int> siz;
public:
	//vector<int> val;
public:
	UF(int n) : num(n) {
		par.resize(n);
		siz.resize(n);
		//val.resize(n);
		int i;
		for (i = 0; i < n; i++) {
			par[i] = i; siz[i] = 1;
			//val[i]=0;
		}
	}

	int find(int x) {
		if (x == par[x]) return x;
		return par[x] = find(par[x]);
	}

	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (siz[x] < siz[y]) {
			par[x] = y;
			siz[y] = siz[x] + siz[y];
			//val[y]=val[x]+val[y];
		}
		else {
			par[y] = x;
			siz[x] = siz[x] + siz[y];
			//val[x]=val[x]+val[y];
		}
	}

	bool same(int x, int y) {
		return find(x) == find(y);
	}

	int size(int x) {
		return siz[find(x)];
	}

	int ngroup() {
		//int ngroup( int& ans ) {
		int count = 0;
		int i;
		for (i = 0; i < num; i++) {
			if (par[i] == i) {
				count++;
				//ans += (val[i]? siz[i]: siz[i]-1);
			}
		}
		return count;
	}
};

void solve()
{
	int n;
	scanf("%d", &n);

	vector<pair<int, int> > x, y;
	int i;
	for (i = 0; i < n; i++) {
		int x0, y0;
		scanf("%d%d", &x0, &y0);
		x.push_back(make_pair(x0, i));
		y.push_back(make_pair(y0, i));
	}
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());

	vector<pair<int, pair<int, int> > > z;
	for (i = 1; i < n; i++) {
		z.push_back(make_pair(x[i].first - x[i - 1].first, make_pair(x[i].second, x[i - 1].second)));
		z.push_back(make_pair(y[i].first - y[i - 1].first, make_pair(y[i].second, y[i - 1].second)));
	}
	sort(z.begin(), z.end());

	UF uf(n);
	ll ans = 0;
	for (i = 0; i < (int)z.size(); i++) {
		int d=z[i].first;
		int a = z[i].second.first;
		int b = z[i].second.second;
		if (!uf.same(a, b)) {
			ans += d;
			uf.unite(a, b);
		}
	}
	printf("%lld\n", ans);

	return;
}


int main(int argc, char* argv[])
{
#if 1
	solve();
#else
	int T; scanf("%d", &T);
	while (T--) {
		solve();
	}
#endif
	return 0;
}


Measured memory_bytes: 7016
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int dy[] = {1, 0, -1, 0};
    int dx[] = {0, 1, 0, -1};

    for(;;){
        int w, h;
        cin >> w >> h;
        if(w == 0)
            return 0;

        int tx, ty, kx, ky;
        cin >> tx >> ty >> kx >> ky;

        vector<vector<bool> > grid(h+2, vector<bool>(w+2, true));
        for(int i=1; i<=h; ++i){
            for(int j=1; j<=w; ++j){
                int a;
                cin >> a;
                grid[i][j] = (a == 1);
            }
        }

        vector<vector<int> > minCost((h+2)*(w+2), vector<int>((h+2)*(w+2), INT_MAX));
        minCost[ty*(w+2)+tx][ky*(w+2)+kx] = 0;
        queue<pair<int, int> > q;
        q.push(make_pair(ty*(w+2)+tx, ky*(w+2)+kx));

        bool ok = false;
        while(!q.empty()){
            int a = q.front().first;
            int b = q.front().second;
            int cost = minCost[a][b];
            q.pop();
            if(cost >= 100)
                break;

            int ay0 = a / (w+2);
            int ax0 = a % (w+2);
            int by0 = b / (w+2);
            int bx0 = b % (w+2);
            if(ay0 == by0 && ax0 == bx0){
                cout << cost << endl;
                ok = true;
                break;
            }

            for(int i=0; i<4; ++i){
                int ay = ay0;
                int ax = ax0;
                int by = by0;
                int bx = bx0;
                if(!grid[ay+dy[i]][ax+dx[i]]){
                    ay += dy[i];
                    ax += dx[i];
                }
                if(!grid[by-dy[i]][bx-dx[i]]){
                    by -= dy[i];
                    bx -= dx[i];
                }
                if(cost + 1 < minCost[ay*(w+2)+ax][by*(w+2)+bx]){
                    minCost[ay*(w+2)+ax][by*(w+2)+bx] = cost + 1;
                    q.push(make_pair(ay*(w+2)+ax, by*(w+2)+bx));
                }
            }
        }

        if(!ok)
            cout << "NA" << endl;
    }
}

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

using namespace std;
long long n,k,a[1000000],f[1000000];
int main()
{
    cin>>n>>k;
    for(long i=0;i<n;i++)
    {
        cin>>a[i];
    }
    vector<long long> f(n, INT_MAX);
    f[0]=0;
    f[1]=abs(a[1]-a[0]);
    for(long i=2;i<n;i++)
    {
        for(long j=1;j<=k;j++)
        {
            if(i<j)
                break;
            f[i]=min(f[i],f[i-j]+abs(a[i]-a[i-j]));
        }
    }
    cout<<f[n-1];
    return 0;
}


Measured memory_bytes: 5120
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    n = f.read_int()
    a = f.read_int_list()
    ans = 0
    for ai in a:
        while ai%2 == 0:
            ans += 1
            ai /= 2

    return ans


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


Measured memory_bytes: 6928
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main(){
    int a, b, c;
    while(cin >> a >> b >> c){
        int A[100][100], B[100][100];
        long long ans[100][100] = {0};
        rep(i,a){
            rep(j,b){
                cin >> A[i][j];
            }
        }
        rep(i,b){
            rep(j,c){
                cin >> B[i][j];
            }
        }
        rep(i,a){
            rep(j,c){
                rep(k,b){
                   ans[i][j] += A[i][k] * B[k][j];
                }
            }
        }
        rep(i,a){
            rep(j,c){
                if(j) cout << ' ';
                cout << ans[i][j];
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 1320
# ABC160_D
from collections import deque,Counter
n,x,y=map(int,input().split())
G=[[] for i in range(n)]
dist=[-1]*n
for i in range(n-1):
    a=i
    b=i+1
    G[a].append([b,1])
    G[b].append([a,1])
G[x-1].append([y-1,1])
G[y-1].append([x-1,1])


ans=[]
for i in range(n-1):
    q=deque()
    q.append(i)
    dist=[-1]*n
    dist[i]=0
    while q:
        cur=q.popleft()
        for nx,nx_dist in G[cur]:
            if dist[nx]==-1:
                dist[nx]=dist[cur]+nx_dist
                q.append(nx)
    for j in range(i+1,n):
        ans.append(dist[j])

ans=Counter(ans)
for i in range(n-1):
    print(ans[i+1])


Measured memory_bytes: 119836
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, k) = (v[0], v[1]);
    let s = read::<String>().chars().collect::<Vec<_>>();
    let mut spans = vec![1];

    for i in 1..n {
        if s[i] == s[i - 1] {
            let l = spans.len();
            spans[l - 1] += 1;
        } else {
            spans.push(1);
        }
    }

    let mut ans = spans.iter().map(|&x| x - 1).sum::<usize>();
    ans += k * 2;
    ans = min(ans, n - 1);

    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 3332
def resolve():
    N=int(input())
    C, S, F = [0] * (N-1), [0] * (N-1), [0] * (N-1)
    for d in range(N-1):
        C[d], S[d], F[d] = map(int, input().split())

    for l in range(N-1):
        time=0
        for i in range(l,N-1):
            if time<=S[i]:
                time=S[i]+C[i]
                continue
            else:
                time=S[i]+F[i]*(-(-(time-S[i])//F[i]))+C[i]
        print(time)
    print(0)





resolve()

Measured memory_bytes: 41580
import java.util.*

fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map{it.toInt()}
    val b = a.zip(1 .. n).sortedBy{it.first}
    print(b[0].second)
    for(i in 1 until n){
        print(" " + b[i].second)
    }
    println()
}

Measured memory_bytes: 82972
/* dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll ,ll>
#define vll          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	ll n,a,b;
	cin>>n>>a>>b;
	if(n==2){cout<<"Borys";return 0;}
	if(abs(a-b)%2==0)cout<<"Alice";else cout<<"Borys";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String a=sc.next();

		if(a.length()==2) {
			System.out.println(a);
		}
		else {
			String x=a.charAt(2)+""+a.charAt(1)+""+a.charAt(0);
			System.out.println(x);
		}
	}
}

Measured memory_bytes: 22740
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
  int N; cin >> N;
  map<pair<int, int>, long long int>ps;
  for (int i = 0; i < N; ++i) {
    long long int x, y, w; cin >> x >> y >> w;
    ps[make_pair(x, y)] += w;
    ps[make_pair(x - 1, y)] += w;
    ps[make_pair(x, y - 1)] += w;
    ps[make_pair(x - 1, y - 1)] += w;
  }
  long long int ans = 0;
  for (auto p : ps) {
    if (p.second > ans)ans = p.second;
  }
  cout << ans <<" / "<<1<< endl;
  return 0;
}

Measured memory_bytes: 28100
#include <bits/stdc++.h>
    using namespace std;
    
    
    int main(){
      int n , a, b;
      cin >> n;
      a = n / 100;
      b = n % 100;
      if(a > 0 && a <= 12 ){
          if(b > 0 && b <= 12){
              cout << "AMBIGUOUS" << endl;
          }else{
              cout << "MMYY" << endl;
          }
      }else{
          if(b > 0 && b <= 12){
              cout << "YYMM" << endl;
          }else{
              cout << "NA" << endl;
          }
      }
      return 0;
    }

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
#define EPS (long double) 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;

int main() {
	int n;
	cin>>n;
	vector<int> a(n);
	REP(i, n) cin>>a[i];
	vector<int> b;
	for(int i = n - 1; i >= 0; --i) {
		if(i % 2 == 0) b.pb(a[i]);
	}
	for(int i = 0; i < n; ++i) {
		if(i % 2 == 1) b.pb(a[i]);
	}
	if(n % 2 == 1) {
	REP(i, n) {
		cout<<b[i];
		if(i != n - 1) cout<<" ";
		else cout<<endl;
	}
	} else {
		REP(i, n) {
			cout<<b[n - i - 1];
			if(i != n - 1) cout<<" ";
			else cout<<endl;
		}
	}
}


Measured memory_bytes: 3828
// Winners don't quit and Quitters don't win
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 998244353
#define MAX 100005
ll gcd_(ll a,ll b){
	if(a==0){
		return b;
	}
	else{
		return gcd_(b%a,a);
	}
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,i,j,k,s=0;
    cin>>n;
    for(i=1;i<=n;++i){
    	for(j=1;j<=n;++j){
    		for(k=1;k<=n;++k){
    			s+=gcd_(i,gcd_(j,k));
			}
		}
	}
	cout<<s;
}

Measured memory_bytes: 3600
def solve(n, k, s):
    v = []
    if s[0] == "0":
        v.append(0)
    i = 0
    while i < n:
        num = 1
        while (i+1 < n) and (s[i+1] == s[i]):
            num += 1
            i += 1
        v.append(num)
        i += 1
    if s[n-1] == "0":
        v.append(0)
    m = len(v)
    w = [0] * m
    w[0] = v[0]
    for i in range(m-1):
        w[i+1] = w[i] + v[i+1]
    best = w[0]
    for left in range(0, m, 2):
        right = min(left + 2*k + 1, m)
        if left == 0:
            cur = w[right-1]
        else:
            cur = w[right-1] - w[left-1]
        best = max(best, cur)
    return best

n, k = map(int, input().split())
s = input()
print(solve(n, k, s))

Measured memory_bytes: 7884
gets
hs = gets.split.map(&:to_i)

ng = false
(1..hs.size-1).each do |i|
  break if ng = (hs[i-1] > hs[i])
  hs[i] -= 1 if hs[i-1] < hs[i]
end

puts ng ? 'No' : 'Yes'


Measured memory_bytes: 8580
//shara's here
#include <bits/stdc++.h>
using namespace std;
typedef int q;
typedef double w;
typedef string s;
typedef long long ll;
int main(){
    q x;
    cin>>x;
    q a[x];
    q sum=0;
    q maxi=INT_MIN;
    for(int i=0;i<x;i++){
        cin>>a[i];
        sum+=a[i];
        maxi=max({maxi,a[i]});
    }
    sum-=maxi;
    if(maxi<sum){cout<<"Yes";}
    else cout<<"No";







return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/


Measured memory_bytes: 256
n = int(input())
ps = [int(input()) for _ in range(n)]
maxpro = -999999999
minp = 1000000000
for i, p in enumerate(ps[:-1]):
  if p >= minp: continue
  pro = max(ps[i + 1:]) - p
  maxpro = max(pro, maxpro)
  minp = p
print(maxpro)

Measured memory_bytes: 18548
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for(int i = 0; i < n; i++) a[i] = sc.nextInt();
        Arrays.sort(a);
        long max1 = 0, max2 = 0;
        int i = n-1;
        while(max2 == 0 && i > 0){
            if(a[i] == a[i-1]){
                if(max1 == 0) max1 = a[i];
                else max2 = a[i];
                i--;
            }
            i--;
        }
        System.out.println(max1 * max2);
    }
}

Measured memory_bytes: 48580
import java.util.Scanner;
class Main{
   public static void main(String[] args){
      Scanner sc=new Scanner(System.in);
      int A=sc.nextInt();
      int B=sc.nextInt();
      int K=sc.nextInt();
      for(int i=1;i<=K/2;i++){
         A=A/2;
         B=(A+B)/2;
         A=A+B;
     }if(K%2==1){
         A=A/2;
         B=A+B;
     }System.out.println(A+" "+B);
  }
}    



Measured memory_bytes: 23124
def main():
    w, h, n = map(int, input().split())
    coord = [[1] * w for _ in range(h)]

    for _ in range(n):
        xi, yi, a = map(int, input().split())
        if a == 1:
            for y in range(h):
                for x in range(0, xi):
                    coord[y][x] = 0
        elif a == 2:
            for y in range(h):
                for x in range(xi, w):
                    coord[y][x] = 0
        elif a == 3:
            for y in range(0, yi):
                coord[y] = [0] * w
        else:
            for y in range(yi, h):
                coord[y] = [0] * w

    print(sum(map(sum, coord)))


if __name__ == '__main__':
    main()


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

int n,x[N],y[N],r[N],c[N],ans,len[N],cn;
vector<int> v[N];

void func(bool erased[N],int cnt,int x){
  ans=max(ans,cnt);
  if(cn==1000000) return ;
  cn++;
  for(int i=0;i<n;i++){
    int f=0;
    if(erased[i]) continue;
    for(int j=0;j<len[i];j++)
      if(!erased[v[i][j]]) f=1;
    if(f) continue;
    for(int j=i+1;j<n;j++){
      if(c[i]!=c[j]) continue;
      if(erased[j]) continue;
      int f2=0;
      for(int k=0;k<len[j];k++)
	if(!erased[v[j][k]]) f2=1;
      if(f2) continue;
      erased[i]=erased[j]=true;
      func(erased,cnt+2,x+1);
      erased[i]=erased[j]=false;
    }
  }
}

int main(){
  while(1){
    cin>>n;
    if(!n) break;
    cn=0;
    for(int i=0;i<n;i++){
      cin>>x[i]>>y[i]>>r[i]>>c[i];
      for(int j=i-1;j>=0;j--){
	int xl=x[i]-x[j],yl=y[i]-y[j];
	int rl=r[i]+r[j];
	if(sqrt(xl*xl+yl*yl)<rl)v[i].push_back(n-j-1);
      }
    }
    reverse(x,x+n);
    reverse(y,y+n);
    reverse(r,r+n);
    reverse(c,c+n);
    reverse(v,v+n);
    for(int i=0;i<n;i++) len[i]=v[i].size();
    bool erased[N]={};
    ans=0;
    func(erased,0,0);
    cout<<ans<<endl;
    for(int i=0;i<n;i++) v[i].clear();
  }
  return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;

struct UnionFind{
	int size;
	vector<int> parent;
	
	UnionFind(){}
	UnionFind(int size){
		this->size = size;
		parent.resize(size+1);
		init();
	}
	void init(){
		for(int i = 0; i <= size; i++) parent[i] = i;
	}
	int root(int i){
		if(parent[i] == i) return i;
		return parent[i] = root(parent[i]);
	}
	bool same(int i, int j){
		return root(i) == root(j);
	}
	void unite(int i, int j){
		int root_i = root(i), root_j = root(j);
		if(root_i == root_j) return;
		parent[root_i] = root_j;
	}
};

llint n, m;
llint a[100005];
UnionFind uf(100005);
map<llint, vector<llint> > mp;
vector<llint> avec;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	for(int i = 1; i <= n; i++) cin >> a[i];
	llint u, v;
	for(int i = 1; i <= m; i++){
		cin >> u >> v;
		u++, v++;
		uf.unite(u, v);
	}
	
	if(2*(n-m-1) > n){
		cout << "Impossible" << endl;
		return 0;
	}
	
	llint ans = 0;
	for(int i = 1; i <= n; i++){
		mp[uf.root(i)].push_back(a[i]);
	}
	if(mp.size() == 1){
		cout << 0 << endl;
		return 0;
	}
	for(auto it = mp.begin(); it != mp.end(); it++){
		vector<llint> &vec = it->second;
		sort(vec.begin(), vec.end());
		ans += vec[0];
		for(int i = 1; i < vec.size(); i++) avec.push_back(vec[i]);
	}
	sort(avec.begin(), avec.end());
	
	for(int i = 0; i < (n-m-2); i++) ans += avec[i];
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 7932
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine();
            if (a.Contains("A") && a.Contains("B"))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.Write("No");
            }
        }
    }
}


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

int main()
{
    double x1, y1, x2, y2, x3, y3, xp, yp;
    while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>xp>>yp)
    {
        double s = ((y3-y1)*(xp-x1)+(x1-x3)*(yp-y1))/((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1));
        double t = ((y1-y2)*(xp-x1)+(x2-x1)*(yp-y1))/((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1));
        if( s>=0 && t>=0 && s+t<=1 ){cout << "YES\n";}
        else{cout << "NO\n"; }
    }

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; ++i)
    cin >> H[i];
  vector<int> move(N);
  int ans = 0;
  for (int i = 1; i < N; ++i) {
    if (H[i] <= H[i - 1])
      move[i] = move[i - 1] + 1;
    else
      move[i] = 0;
    ans = max(move[i], ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
import numpy as np
import itertools


def pd(s):
    #print(s)
    pass


# input
H, W, M = map(int, input().split())
ms = [
    [int(i) for i in input().split()]
    for m in range(M)
]
pd(f"{H=} {W=} {M=}")
pd(f"{ms=}")

rows = [0]*(H+1)
cols = [0]*(W+1)
bombs = {}
for m in ms:
    h = m[0]
    w = m[1]
    rows[h] += 1
    cols[w] += 1
    bombs[f"{h},{w}"] = True

rmax = max(rows)
cmax = max(cols)
rmax_hs = [i for i, v in enumerate(rows) if v == rmax]
cmax_wh = [i for i, v in enumerate(cols) if v == cmax]

for m in itertools.product(rmax_hs, cmax_wh):
    h = m[0]
    w = m[1]
    if f"{h},{w}" not in bombs:
        print(rmax + cmax)
        exit()
print(rmax + cmax - 1)


Measured memory_bytes: 139384
module Main where

main :: IO ()
main = do
    _ <- getLine
    ns <- (map read) . words <$> getLine
    print . mixObjs . msort $ ns


mixObjs = mixObjsCore Nothing
    where
        mixObjsCore :: Maybe Float -> [Float] -> Float
        mixObjsCore keep (l1:[l2]) = case keep of
            Nothing -> mix l1 l2
            (Just x) -> if l2 < x
                then
                    mixObjsCore Nothing $ (mix l1 l2) : [x]
                else
                    mixObjsCore Nothing $ (mix l1 x) : [l2]
        mixObjsCore keep (l1:l2:ls) = case keep of
            Nothing -> mixObjsCore keep $ (mix l1 l2) : ls
            (Just x) -> if l2 < x
                then
                    mixObjsCore (Just x) $ (mix l1 l2) : ls
                else
                    mixObjsCore (Just l2) $ (mix l1 x) : ls
        mix x y = (x+y)/2


msort :: Ord a => [a] -> [a]
msort [] = []
msort [x] = [x]
msort xs = merge (msort ys) (msort zs)
    where
        xlen_h = div (length xs) 2
        (ys, zs) = splitAt xlen_h xs

merge :: Ord a => [a] -> [a] -> [a]
merge xs [] =  xs
merge [] ys =  ys
merge (x:xs) (y:ys)
    | x < y     = x:merge xs (y:ys)
    | otherwise = y:merge (x:xs) ys


Measured memory_bytes: 892
/////////////////////////////////////////
///       Please Give Me AC!!!!!      ///
/////////////////////////////////////////

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define forin(in) for(int i=0; i<(int)in.size(); i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


int main() {
    const int MOD = 1000000007;
    int S; cin>> S;
    vector<int> dp(S);
    dp[0] = 0; dp[1] = 0; dp[2] = 1;
    for(int i = 3; i < S; i++){
        dp[i] = (dp[i - 1] + dp[i - 3]) % MOD;
    }

    cout<< dp[S - 1] << endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,P;
ll hoge[101][2];
int A[101];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>P;
	
	hoge[0][0]=1;
	
	FOR(i,N) {
		cin>>A[i];
		if(A[i]%2==0) {
			hoge[i+1][0]=hoge[i][0]*2;
			hoge[i+1][1]=hoge[i][1]*2;
		}
		else {
			hoge[i+1][0]=hoge[i][0]+hoge[i][1];
			hoge[i+1][1]=hoge[i][0]+hoge[i][1];
		}
	}
	
	cout<<hoge[N][P]<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
mod reader {
    use std::fmt::Debug;
    use std::str::FromStr;
    use std::collections::VecDeque;
    use std::io::{self, Read};

    fn _read_line() -> String {
        let mut buf = String::new();
        io::stdin().read_to_string(&mut buf);
        buf
    }

    fn _read_vec_deque_string() -> VecDeque<String> {
        _read_line().split_whitespace().map(|s| s.to_string()).collect()
    }

    pub struct Reader {
        buf: VecDeque<String>
    }

    impl Reader {
        pub fn new() -> Reader {
            Reader {buf: VecDeque::new()}
        }

        fn update_buf(&mut self) {
            if self.buf.is_empty() {
                self.buf = _read_vec_deque_string();
            }
        }

        pub fn next<T>(&mut self) -> T where T: FromStr, T::Err: Debug {
            self.update_buf();
            self.buf.pop_front().unwrap().parse::<T>().unwrap()
        }

        pub fn nextN<T>(&mut self, n: usize) -> Vec<T> where T: FromStr, T::Err: Debug {
            let mut vec: Vec<T> = Vec::with_capacity(n);
            for i in 0..n {
                vec.push(self.next());
            }
            vec
        }
    }
}

fn diff(t: &(i64, i64, i64)) -> i64 {
    let t = vec![t.0, t.1, t.2];
    return t.iter().max().unwrap() - t.iter().min().unwrap();
}

fn f(h: i64, w: i64) -> i64 {
    let mut ans = h * w;
    for i in 1..h {
        let s1 = i * w;
        let (s2, s3) = g(h - i, w);
        ans = std::cmp::min(ans, diff(&(s1, s2, s3)));
        let (s2, s3) = g(w, h - i);
        ans = std::cmp::min(ans, diff(&(s1, s2, s3)));
    }
    ans
}

fn g(h: i64, w: i64) -> (i64, i64) {
    if h == 1 {
        return (0, 100000000000);
    }
    if h % 2 == 0 {
        (h / 2 * w, h / 2 * w)
    } else {
        (h / 2 * w, (h / 2 + 1) * w)
    }
}

fn main() {
    let mut reader = reader::Reader::new();

    let h = reader.next();
    let w = reader.next();

    println!("{}", std::cmp::min(f(h, w), f(w, h)));
}
 

Measured memory_bytes: 4352
n = gets.to_i
strings = gets.chomp.split("")
alphabets = %W(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)
ans = []
strings.each do |s|
  index = alphabets.find_index(s) + n
  index -= 26 if index >= 26
  ans << alphabets[index]
end
puts ans.join


Measured memory_bytes: 2300
// A

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int countDivisors(int n){
  int cnt = 0;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i) cnt++;
      else cnt = cnt + 2;
    }
  }
  return cnt;
}

int main(){
  int N;
  cin>>N;
  int ans(0);
  for (int i(1);i<=N;i++){
		if (countDivisors(i) == 8 && i%2 == 1){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

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

const int MOD = 1e9+7;
const int INF = 1e9;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    vector<ll> L(N);
    rep(i,N)cin>>L[i];
    sort(all(L));
    //print(L);
    ll ans = 0;
    for(int i = 0; i < N; ++i){
        for(int j = i+1; j < N; ++j){
            int a = L[i];
            int b = L[j];
            //cの範囲は、l<c<r;
            /*
            int r = a+b;
            int l = b-a;
            */
            for(int k = j+1; k < N; ++k){
                if(a+b<=L[k]){
                    break;
                }
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}


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

int main() {
  
  int N, M;
  int sum;
  
  cin >> N >> M;
  
  if(N > 1){
    sum += N*(N-1)/2;
  }
  
  if(M > 1){
    sum += M*(M-1)/2;
  }
  
  cout << sum;
  
  return 0;
  
}

Measured memory_bytes: 256
import math
x=int(raw_input())

prime=[True]*(x+1)
prime[0:2]=[False]*2
for i in range(2,x+1):
    if prime[i]:
        for j in range(i*2,x+1,i):
            prime[j]=False

prime_num=[0]*(x+1)

for i in range(0,x+1):
    if prime[i]:
        j=i
        while True:
            prime_num[i]+=x/j
            j*=i
            if j>x:
                break


print reduce(lambda p,x:p*(x+1),prime_num,1)%(10**9+7)



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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

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

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  string s;
  cin >> s;

  for (int i = 0; i < s.length(); ++i) {
    cout << s[i];
    if (i == 3) cout << ' ';
  }
  cout << "\n";

  return 0;
}

Measured memory_bytes: 256