akhauriyash/Code-Regression huggingface dataset:
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {
	
	int n, m;
	scanf("%*d%*c%d%*c%d", &n, &m);
	printf("%s\n", (n > 4) ? "TBD" : "Heisei");
	
	Please AC;
}


Measured memory_bytes: 256
import sys
N = int(input())

lst = []
for i in range(N):
    a = list(map(int, input().split()))
    lst += [a]

#print (lst)

#中心座標(px, py)
for px in range(101):
    for py in range(101):
#        print ('px, py ', px, py)
        j = 0
        while lst[j][2] == 0:
            j += 1
        h = lst[j][2] + abs(px-lst[j][0]) + abs(py -lst[j][1])
#        print ('j, h ', j, h)
        k = 0
        while k < N:
            if lst[k][2] == max(h - abs(px-lst[k][0]) - abs(py -lst[k][1]), 0):
                k += 1
#                print ('A')
            else:
#                print ('B')
                k = 10 ** 9
        if k == N:
            print (px, py, h)
            sys.exit()
        else:
            pass
#            print ('C')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
#define vi vector<int>
#define pb push_back
#define log(x,b) (log(b)/log(x))
#define rep(i,x,y) for(int i=(x);i<(y);i++)
using namespace std;
const int mod=1e9+7;

int32_t main()
{
    int n;
    cin>>n;
    int f=1;
    for(int i=1;i<=n;i++){
        f*=i;
        f%=mod;
    }
    cout<<f<<endl;

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int a, b;
  vector<int> v(3);
  
  cin >> a >> b;
  
  v.at(0) = (a + b);
  v.at(1) = (a - b);
  v.at(2) = (a * b);
  
  sort(v.begin(), v.end());
  
  cout << v.at(2) << endl;
}
    
    
    
    

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Library
//

int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int n; string s; cin >> n >> s;
    int ans = 0;
    for(int i = 0; i < n; ++i){
        set<char> st1;
        for(int j = 0; j < i; ++j){
            st1.insert(s[j]);
        }
        int tmp = 0;
        set<char> st2;
        for(int j = i; j < n; ++j){
            auto it1 = st1.find(s[j]);
            auto it2 = st2.find(s[j]);
            if(it1 != st1.end() && it2 == st2.end()){
                st2.insert(s[j]);
                ++tmp;
            }
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
int main()
{
	int n;
	std::cin >> n;
	for (int i = 0; i < n; i++)
	{
		long double xa, ya, ra, xb, yb, rb;
		std::cin >> xa >> ya >> ra >> xb >> yb >> rb;
		long double d = hypot(xa - xb, ya - yb);
		if (d < std::abs(ra - rb))
		{
			std::cout << 2 * (ra < rb ? -1 : 1) << std::endl;
		}
		else if (d <= ra + rb)
		{
			std::cout << 1 << std::endl;
		}
		else
		{
			std::cout << 0 << std::endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3184
def main():
    re_dict_nums = dict()
    done_list = [0 for _ in range(9)]
    cnt = 0
    for _ in range(3):
        for s in map(int, input().split(' ')):
            re_dict_nums[s] = cnt
            cnt += 1
    for n in range(int(input())):
        try:
            done_list[re_dict_nums[int(input())]] = 1
        except KeyError:
            pass
    flag = False
    if done_list[4] == 1:
        if (done_list[0] == 1 and done_list[8] == 1) or (done_list[1] == 1 and done_list[7] == 1) or (
                done_list[2] == 1 and done_list[6] == 1) or 0 not in done_list[3:6]:
            flag = True
    if flag is False:
        if (0 not in done_list[:3]) or (0 not in done_list[6:]) or (
                done_list[0] == 1 and done_list[3] == 1 and done_list[6] == 1) or (
                done_list[2] == 1 and done_list[5] == 1 and done_list[8] == 1):
            flag = True
    if flag:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


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



int main(void){
    long long N = 500000;
    int q;
    cin >> q;
    vector<int> prime(N+10);
    vector<int> is2017(N+10);
    vector<int> sum(N+10);
    for(int i = 0; i < N; i++){
		prime[i] = 1;
        is2017[i] = 0;
	}
	for(int i = 2; i < sqrt(N); i++){
		if(prime[i]){
			for(int j = 0; i * (j + 2) < N; j++){
				prime[i *(j + 2)] = 0;
			}
		}
	}
    for(int i=3;i<N;i+=2){
        if(prime[i] && prime[(i+1)/2]){
            is2017[i] = 1;
        }
    }
    sum[0] = 0;
    for(int i=1;i<N;++i){
        sum[i] = sum[i-1]+is2017[i];
    }
    for(int i=0;i<q;++i){
        int l, r;
        cin >> l >> r;
        cout << sum[r]-sum[l-1] << endl;
    }
}


Measured memory_bytes: 6528
from collections import deque

n = int(input())
ab = [list(map(int, input().split())) for i in range(n-1)]
tree = [list() for i in range(n)]
already = [1] * n 
k = 0
ans = [0] * (n-1)
queue = deque([0])
parent_colors = deque([0])

for index,(a,b) in enumerate(ab):
  a -= 1
  b -= 1
  tree[a].append((index,b))
  tree[b].append((index,a))
while len(queue):
  now = queue.popleft()
  
  if already[now]:
    already[now] = 0
    color = 1
    parent_color = parent_colors.popleft()
    for index,i in tree[now]:
      if already[i]:
        if color == parent_color:
          color += 1
        ans[index] = color
        parent_colors.append(color)
        color += 1
        queue.append(i)
         
print(max(ans))
for i in ans:
  print(i)


Measured memory_bytes: 90968
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define LLI long long
#define LLU unsigned long long
#define pi 2*acos(0.0)

#define scan(x) scanf("%d",&x)


int dir[8][2]={{-1,0}
              ,{1,0}
              ,{0,-1}
              ,{0,1}
              ,{-1,-1}
              ,{-1,1}
              ,{1,-1}
              ,{1,1}};


using namespace std;


int main()
{
    int mou[10];
    for(int i=0 ;i < 10 ; i++)
    {
        scan(mou[i]);
    }

    sort(mou,mou+10);

    printf("%d\n%d\n%d\n",mou[9],mou[8],mou[7]);

	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, M;
    cin>>N>>M;
    string S,T;
    cin>>S>>T;
    ll g=gcd(N,M);
    rep(i,0,g){
        if(S[N/g*i]!=T[M/g*i]){
            cout << -1<<"\n";
            return 0;
        }
    }
    cout << lcm(N,M)<<"\n";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  stack<char> stk;
  int l = 0;
  rep(i, n){
    if(s.at(i) == '('){
      stk.push(s.at(i));
    }else{
      if(!stk.empty()){
        stk.pop();
      }else{
        l++;
      }
    }
  }
  cout << string(l, '(') << s << string(stk.size(), ')') << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

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

#define rep(i, n) for(int i = 0; i < n; i++)
#define repext(i, a, b) for (int i = a; i < b; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (int i = b - 1; i >= a; i--)
#define vec_all(vec) vec.begin(), vec.end()

// vectorデバッグ
template<typename T>
void dump_vec(vector<T> vec) {
    rep(i, vec.size()) {
        cout << vec[i] << endl;
    }
}

template<typename T>
T gcd(T a, T b) {
    if (a < b) {
        swap(a, b);
    }

    while (b != 0) {
        a = a % b;
        swap(a, b);
    }

    return a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

template<typename T>
pair<T, T> ext_euclid(T a, T b) {
    if (b == 1) {
        return pair<T, T>(0, 1);
    } else if (b == -1) {
        return pair<T, T>(0, -1);
    }

    assert(gcd(a, b) == 1);

    T q = a / b;
    T r = a % b;

    pair<T, T> next = ext_euclid<T>(b, r);

    return pair<T, T>(next.second, next.first - q * next.second);
}

template<typename T>
T ceil_div(T a, T b) {
    if (a % b != 0) {
        return a / b + 1;
    } else {
        return a/ b;
    }
}

// --- notice ---
// intの和はllにしろ

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

    ll base = 1;
    rep(i, n - 1) {
        base = max(ceil_div<ll>(base * t[i], t[i + 1]), ceil_div<ll>(base * a[i], a[i + 1]));
    }

    cout << base * (t[n - 1] + a[n - 1]) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, m;
	cin >> n >> m;

	if (m % n == 0) {
		cout << m / n << "\n";
	} else {
		int g = 1;
		--n;
		m -= n;
		int max_g = 1;
		while (m > n) {
			m -= n;
			++g;
			if (m % g == 0) {
				max_g = max(max_g, g);
			}

			if (g % m == 0) {
				max_g = max(max_g, m);
			}
		}

		cout << max_g << "\n";
	}

	return 0;

}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

bool f(P a, P b) {
    return a.first<b.first && a.second<b.second;
}


int main(){
    int n;
    cin >> n;
    vector<P> r(n);
    vector<P> b(n);
    rep(i, n) cin >> r[i].first >> r[i].second;
    rep(i, n) cin >> b[i].first >> b[i].second;
    sort(whole(r));
    sort(whole(b));
    vector<bool> used(n);
    
    int ans = 0;
    rep(i, n) {//b
        int id = -1;
        int maxy = -1;
        rep(j, n) {//r
            if (used[j]) continue;
            if (!f(r[j], b[i])) continue;
            if (r[j].second>maxy) {
                id = j;
                maxy = r[j].second;
            }
        }
        if (id != -1) {
            ans++;
            used[id] = true;
        }
    }
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int x = sc.nextInt();
        int n = sc.nextInt();

        Set<Integer> set = new HashSet();

        for (int i = 0; i < n; i++) {
            set.add(sc.nextInt());
        }

        int abs = 1000;
        int ans = 0;
        for (int i = 0; i <= 101; i++) {
            if (set.contains(i)) {
                continue;
            }
            int d = Math.abs(x - i);
            if (d < abs) {
                abs = d;
                ans = i;
            }
        }
        System.out.println(ans);

        // out.println("Hello World");
        out.flush();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 35928
def main():
    grid = [list(map(int, input().split())) for i in range(3)]
    all = sum(sum(grid, []))
    a = [0] * 3
    b = [0] * 3
    for i1 in range(0, grid[0][0] + 1):
        a[0] = i1
        b[0] = grid[0][0] - i1
        for j2 in range(0, grid[1][1] + 1):
            a[1] = j2
            b[1] = grid[1][1] - j2
            for k3 in range(0, grid[2][2] + 1):
                a[2] = k3
                b[2] = grid[2][2] - k3
                if (sum(a) * 3) + (sum(b) * 3) == all:
                    print("Yes")
                    exit()
    print('No')





if __name__ == '__main__':
    main()

Measured memory_bytes: 9220
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = n - 1; i >= 0; --i)
#define pb push_back

typedef long long ll;

int main() {
	int a, b; cin >> a >> b;
	int ans = 0;
	
	ans = max(ans, a + (a-1));
	ans = max(ans, b + (b-1));
	ans = max(ans, a + b);

	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int a,b,c,z,y;
    scanf("%d %d %d", &a, &b, &c);

    z=b-a;

    y=c-b;


    if(z==y)
    {
        printf("YES");
    }
    else{
        printf("NO");
    }
    return 0;
}

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


using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(ll i=ll(m); i<ll(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;


struct BIT {
	ll N;
	vector<ll> dat;
	void init(ll _N) {
		N = _N;
		dat = vector<ll>(N + 1, 0);
	}
	void add(ll k, ll val) {
		k++;
		while (k <= N) {
			dat[k] += val;
			k += k & -k;
		}
	}
	ll getSum(ll k) {
		k++;
		ll ret = 0;
		while (k) {
			ret += dat[k];
			k -= k & -k;
		}
		return ret;
	}
};



int main() {
	

	ll n, d, a;
	cin >> n >> d >> a;

	vector<pair<ll, ll>> v;

	BIT bit;
	bit.init(n + 10);

	REP(i, n) {
		ll b, c;
		cin >> b >> c;
		v.push_back({ b,c });
	}

	sort(ALL(v));
	vector<ll> e(n);
	REP(i, n)e[i] = v[i].first;
	ll ans = 0;
	REP(i,n) {
		if ((bit.getSum(n + 1) - bit.getSum(max(i-1, 0LL)))*a >= v[i].second)continue;
		v[i].second -= (bit.getSum(n + 1) - bit.getSum(max(i - 1, 0LL)))*a;
		if (v[i].second <= 0)continue;
		ll b = (v[i].second + a - 1) / a;
		ans += b;
		int c = upper_bound(ALL(e), v[i].first + d + d) - e.begin();
		c--;
		if (c == i)continue;
		bit.add(c, b);
	}

	cout << ans << endl;


}

Measured memory_bytes: 8048
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int a, b, c;

int main() {
    cin >> a >> b >> c;
    int cnt = b/a;
    if(cnt < c) cout << cnt << endl;
    else cout << c << endl;
}

Measured memory_bytes: 256
use std::io::{Read, stdin};
use std::str::FromStr;

struct UnionFind {
    par: Vec<usize>,
    rank: Vec<usize>,
}

impl UnionFind {
    fn new(n: usize) -> UnionFind {
        let mut p = vec![0; n];
        for i in 0..n { p[i] = i; }
        UnionFind {
            par: p,
            rank: vec![0; n],
        }
    }

    fn find(&mut self, x: usize) -> usize {
        if self.par[x] == x {
            x
        } else {
            let par = self.par[x];
            self.par[x] = self.find(par);
            self.par[x]
        }
    }

    fn unite(&mut self, x: usize, y: usize) {
        let ux = self.find(x);
        let uy = self.find(y);
        if ux != uy {
            if self.rank[ux] < self.rank[uy] {
                self.par[ux] = uy;
            } else {
                self.par[uy] = ux;
                if self.rank[ux] == self.rank[uy] { self.rank[ux] += 1; }
            }
        }
    }

    fn same(&mut self, x: usize, y: usize) -> bool {
        self.find(x) == self.find(y)
    }
}


fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut edges: Vec<[usize; 2]> = Vec::new();
    for _i in 0..m {
        let a: usize = read();
        let b: usize = read();
        edges.push([a - 1, b - 1]);
    }
    let mut cnt = 0;
    for i in 0..m {
        let mut unf = UnionFind::new(n);
        for j in 0..m {
            if j != i {
                unf.unite(edges[j][0], edges[j][1]);
            }
        }
        for j in 1..n {
            if !unf.same(0, j) {
                cnt += 1;
                break;
            }
        }
    }

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


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

Measured memory_bytes: 4352
n,m = map(int,input().split())
b = [int(input()) for _ in range(m)] + [n+1]
now = 0
A = [0,1]
if b[0] == 0:
  print(0)
else:
  for i in range(1,n+1):
    if b[now] == i:
      A.append(0)
      now += 1
    else:
      A.append( (A[-1]+A[-2]) % (10**9+7) )
  print(A[-1])

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

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {


		int N = nextInt();
		int P = nextInt();
		int[] A = nextInts();
		long odd = 0;
		long even = 0;
		for(int i=0;i<N;i++){
			if(A[i]%2==0){
				even++;
			}else{
				odd++;
			}
		}
		long ans = 0;
		if(P==0){
			for(int i=0;i<=odd;i+=2){
				long p=1;
				long d=1;
				for(int k=1;k<=i;k++){
					p*=odd-k+1;
					d*=k;
					long x;
					while((x=gcd(p,d))!=1){
						p/=x;
						d/=x;
					}
				}
				ans+=(long)Math.pow(2, even)*(p/d);
			}
		}else{
			for(int i=1;i<=odd;i+=2){
				long p=1;
				long d=1;
				for(int k=1;k<=i;k++){
					p*=odd-k+1;
					d*=k;
					if(k%2==0){
						p/=2;
						d/=2;
						long x;
						while((x=gcd(p,d))!=1){
							p/=x;
							d/=x;
						}
					}
				}

				ans+=(long)Math.pow(2, even)*(p/d);
			}
		}
		System.out.println(ans);
	}


public static long gcd(long a, long b) {
	long x, y;
	if (a < b) {
		x = b;
		y = a;
	} else {
		x = a;
		y = b;
	}
	long r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static String concatStringArray(String[] s){
		StringBuffer sb = new StringBuffer();
		for(String x:s){
			sb.append(x);
		}
		return sb.toString();
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21332
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
// #define LOCAL
const int MAXN=2e5+10;
const ll MOD=7;
ll _gcd(ll a,ll b){if(b==0)return a;return _gcd(b,a%b);}
ll gcd(ll a,ll b){a=abs(a),b=abs(b);if(a<b)swap(a,b);return _gcd(a,b);}
ll qpow(ll a,ll n){ll rt=1;while(n){if(n&1)rt=(rt*a)%MOD;a=a*a%MOD;n>>=1;}return rt;}
ll factor[MAXN];
void cal_factor(){factor[0]=1;for(int u=1;u<MAXN;u++){factor[u]=(factor[u-1]*u)%MOD;}}
ll C(ll n,ll k){return factor[n]*qpow(factor[n-k],MOD-2)%MOD*qpow(factor[k],MOD-2)%MOD;}
void solve(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin>>t;
    const int MIN=(1<<31);
    while(t--){
        int n;
        cin>>n;
        vector<pair<int,int>>cml;
        set<int>pos;
        ll ans=0;
        for(int u=0;u<n;u++){
            int k,l,r;
            cin>>k>>l>>r;
            cml.push_back({l-r,k});
            ans+=r;
            pos.insert(u+1);
        }
        sort(cml.begin(),cml.end());
        reverse(cml.begin(),cml.end());
        vector<int>csm;
        for(int u=0;u<n;u++){
            if(cml[u].first<0)break;
            if(*pos.begin()<=cml[u].second){
                auto p=pos.upper_bound(cml[u].second);
                p--;
                csm.push_back(*p);
                ans+=cml[u].first;
                pos.erase(p);
                cml[u].first=MIN;
            }
        }
        sort(csm.begin(),csm.end());
        for(int v:csm){
            if(*pos.begin()<=v){
                pos.insert(v);
                pos.erase(pos.begin());
            }
        }
        sort(cml.begin(),cml.end());
        for(int u=0;u<n;u++){
            if(cml[u].first==MIN)continue;
            auto p=pos.upper_bound(cml[u].second);
            if(p==pos.end())ans+=cml[u].first;
            else pos.erase(p);
        }
        cout<<ans<<"\n";
    }
}
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    solve();
}

Measured memory_bytes: 15040
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] array = new int[n];
		for(int i=0;i<n;i++) {
			array[i] = sc.nextInt();
		}
		sc.close();

		Arrays.sort(array);

		System.out.println(array[n/2]-array[n/2-1]);
	}
}

Measured memory_bytes: 59316
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
int f[4][5];
int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, 0, n)cin >> a[i], a[i] -= i + 1;
	ll s = 0;
	sort(all(a));
	int b = a[n / 2];
	rep(i, 0, n) {
		s += abs(a[i] - b);
	}
	printf("%lld\n", s);
	return 0;
}


Measured memory_bytes: 1024
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  long x; readV(x);

  auto ans = x/11*2, m = x%11;
  if (m >= 1 && m <= 6) ++ans;
  else if (m > 6) ans += 2;

  writeln(ans);
}


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std; 
long long dp[11]; 
inline long long stoii(string s)
{
	long long res=0;
	for(int i=0; i<s.size(); i++)
		res*=10, res+=(s[i]-'0');
	return res;	
}
int main() 
{  
    string s;
    cin>>s;
    memset(dp, 0, sizeof(dp));
    dp[0]=1, dp[1]=1, dp[2]=2, dp[3]=4, dp[4]=8, dp[5]=16, dp[6]=32, dp[7]=64, dp[8]=128, dp[9]=256, dp[10]=512;
    long long ans=0;
    int len=s.size();
    for(int i=1; i<=len; i++)
    	for(int j=0; (j+i)<=len; j++)
    		ans+=(long long)(stoii(s.substr(j, i))*dp[j]*dp[len-i-j]);
	cout<<ans;
    return 0;  
}  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(ll i = (ll)a; i <= (ll)b; i++)
#define DEC(i, a, b) for(ll i = (ll)a; i >= (ll)b; i--)
typedef pair<ll, ll> pi;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll n, m, k, ans, mod = 998244353, fac[200005], inv[200005];

ll qexp(ll a, ll b) {
    a %= mod;
    ll res = 1, base = a;
    while (b) {
        if (b & 1) {
            res *= base;
            res %= mod;
        }
        base *= base;
        base %= mod;
        b >>= 1;
    }
    return res % mod;
}

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

inline ll choose(ll n, ll k) {
	if (n < k or n < 0 or k < 0) return 0;
	return mul(fac[n], mul(inv[k], inv[n-k]));
}

int main() {
	fastio; cin >> n >> m >> k;
	fac[0] = 1; FOR(i, 1, n) fac[i] = (fac[i-1] * i) % mod;
	FOR(i, 0, n) inv[i] = qexp(fac[i], mod-2);
	FOR(i, 0, k) {
		ans += mul(mul(choose(n-1, i), m), qexp(m-1, n-i-1));
		ans %= mod;
	}
	cout << ans;
}


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

using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define INF 2e9
#define MOD 1e9+7
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define bit(n) (1LL<<(n))

template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int ni() {
    int i;
    cin >> i;
    return i;
}

vector<int> to[100];
bool visited[100];

void dfs(int v, int v1, int v2) {
    visited[v] = true;
    REP(i, to[v].size()) {
        if ((v == v1 && to[v][i] == v2) || (v == v2 && to[v][i] == v1)) continue;
        if (!visited[to[v][i]]) dfs(to[v][i], v1, v2);
    }
}

int main() {
    int N = ni(), M = ni();

    REP(i, M) {
        int v1 = ni()-1, v2 = ni()-1;
        to[v1].push_back(v2);
        to[v2].push_back(v1);
    }

    ll ans = 0;
    REP(i,N) {
        REP(j, SZ(to[i])) {
            dfs(i, i, to[i][j]);
            bool ok = false;
            REP(k, N) {
                if (!visited[k]) ok = true;
                visited[k] = false;
            }
            if (ok) ans++;
        }
    }
    ans /= 2;

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

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

using namespace std;

typedef long long int lli;

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

    int n, m, a;
    lli sum = 0;
    priority_queue<int> pqu;

    cin >> n >> m;
    for (int i=0; i<n; i++) {
        cin >> a;
        pqu.push(a);
        sum += a;
    }

    // cout << sum << endl;

    for (int i=0; i<m; i++) {
        int x = pqu.top(); pqu.pop();
        sum = sum - x + x/2;
        pqu.push(x/2);
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
 
using namespace std;
 
// abc151E - Max-Min Sums
 
const int cap = 1e5 + 1;
const int mod = 1e9 + 7;
int N, K, A[cap], F[cap];
 
int mod_inv(int64_t a, int64_t m) {
    int64_t m0 = m; 
    int64_t y = 0, x = 1; 
  
    if (m == 1) 
      return 0; 
  
    while (a > 1) 
    { 
        // q is quotient 
        int64_t q = a / m; 
        int64_t t = m; 
  
        // m is remainder now, process same as 
        // Euclid's algo 
        m = a % m, a = t; 
        t = y; 
  
        // Update y and x 
        y = x - q * y; 
        x = t; 
    } 
  
    // Make x positive 
    if (x < 0) 
       x += m0; 
  
    return x; 
}
 
int mod_div(int y, int z) {
    return (mod_inv(y, mod) * int64_t(z)) % mod;
}
 
int comb(int x) {
    return K == 2 ? 1 : mod_div(F[K - 2], mod_div(F[x - K + 2], F[x]));
}
 
int main() {
    scanf("%d %d", &N, &K);
    for (int i = 1; i <= N; ++i)
        scanf(" %d", &A[i]);
    if (K == 1) {
        printf("0\n");
        return 0;
    }
 
    sort(A + 1, A + N + 1);
    
    F[0] = 1;
    int64_t p = 1;
    for (int i = 1; i < N; ++i) {
        p = (p * i) % mod;
        F[i] = int(p);
    }
 
    int ans = 0;
    for (int64_t i = K, cnt = 0; i <= N; ++i) {
        cnt = (cnt + comb(i - 2)) % mod;
        ans = (ans + cnt * A[i]) % mod;
    }
 
    for (int64_t i = N - K + 1, cnt = 0; i > 0; --i) {
        cnt = (cnt + comb(N - i - 1)) % mod;
        ans = (ans - cnt * A[i]) % mod;
    }
 
    ans += (ans < 0) * mod;
    printf("%d\n", ans);
    
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(void)
{
  string S;
	cin >> S;
	ll l = S.size();
	S += 'a';
	ll count;
	ll sum = 0;
	ll comp = 0;
	rep(i, l)
	{
		count = 0;
		while(S[i+count]==S[i+count+1]) count++;
		if(S[i]=='<')
		{
			rep(j, count+1) sum += j+1;
			comp = count+1;
		}
		else
		{
			if(comp<=count+1)
			{
			    rep(j, count+1) sum += j+1;
			    sum -= comp;
			}
			else rep(j, count) sum += j+1;
		}
		i += count;
	}
	cout << sum << endl;
}


Measured memory_bytes: 900
import java.util.*;
class Main{
  
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int k = Integer.parseInt(sc.next());
    Set<Integer> ng = new HashSet<>();
    for(int i=0;i<k;i++)ng.add(Integer.parseInt(sc.next()));
    int money = n;
    boolean flag = true;
    while(true){
      int tmp = money;
      flag = true;
      while(tmp > 0){
        int digit = tmp%10;
        if(ng.contains(digit)){
          flag = false;
          break;
        }
        tmp/=10;
      }
      if(flag){
        System.out.println(money);
        return;
      }else{
        money++;
      }
    }
  }
}


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

int main() {
	int N;
	ll r=0;
	string S;
	vector<ll> p;
	map<char,ll> m;
	cin >> N;

	m['M']=0, m['A']=0, m['R']=0, m['C']=0, m['H']=0;
	rep(i,N) {
		char t;
		cin >> S;
		t = S.at(0);
		if(m.count(t))
			++m.at(t);
	}

	for(auto x : m)
		p.push_back(x.second);
	
	rep(i,p.size()-2)
		for(int j=i+1; j<p.size()-1; ++j)
			for(int k=j+1; k<p.size(); ++k)
				r += p.at(i)*p.at(j)*p.at(k);

	cout << r << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int search(int *, int , int);

int main(){

int i,n,q,A[10000],key,sum = 0;

scanf("%d",&n);
for(i=0;i<n;i++){
  scanf("%d",&A[i]);
  }

scanf("%d",&q);
for(i=0;i<q;i++){
  scanf("%d",&key);
  if(search(A, n, key) != n) sum++;
  }
  printf("%d\n",sum);

return 0;
}

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

Measured memory_bytes: 640
def F(a): return [P[a][i]-P[0][i] for i in [0,1,2]]

def D(X):
  a,b,c,d,e,f,g,h,i=X
  return a*e*i+d*h*c+g*b*f-a*h*f-d*b*i-c*e*g

def G(a):
  X=A[:]; X[a::3]=V;
  return 1.0*D(X)/D0

P=[map(int,raw_input().split()) for _ in [0]*5]
A=[0]*9
V=F(1)
for i in [0,1,2]: A[i::3]=F(i+2)

f=0
D0=D(A)
if D0!=0:
  r1,r2,r3=G(0),G(1),G(2)
  if r1>=0 and r2>=0 and r3>=0 and r1+r2+r3>=1: f=1
print ["HIT","MISS"][f]

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

int main()
{
	int K, S;
	cin >> K >> S;
	
	int res = 0;
	for (int x = 0; x <= K; x++)
		for (int y = 0; y <= K; y++) {
			int z = S - x - y;
			if (z >= 0 && z <= K)
				res++;
		}

	cout << res << endl;
}


Measured memory_bytes: 384
#include<iostream>
#define N 101
using namespace std;

int n,d[N][N],m[N],f[N],s[N],ti;
void dfs(int t){
  if(s[t]==1) return;
  ti++,m[t]+=ti,s[t]=1;
  for(int i=1;i<=n;i++) if(d[t][i]==1 && s[i]==0)dfs(i);
  ti++,f[t]+=ti;
}

int main(){
  int nx,s,fst;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>fst>>nx;
    for(int j=0;j<nx;j++){
      cin>>s;
      d[fst][s]=1;
    }
  }
  for(int i=1;i<=n;i++) dfs(i);
  for(int i=1;i<=n;i++) cout<<i<<" "<<m[i]<<" "<<f[i]<<endl;
  
  return 0;
}

Measured memory_bytes: 1204
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on
immutable string YES = "Yes";
immutable string NO = "No";
void main()
{
    auto input = stdin.byLine.map!split.joiner;

    long A;
    A = input.front.to!long;
    input.popFront;

    long B;
    B = input.front.to!long;
    input.popFront;

    long C;
    C = input.front.to!long;
    input.popFront;

    long K;
    K = input.front.to!long;
    input.popFront;

    solve(A, B, C, K);
}

void solve(long A, long B, long C, long K)
{
    long cnt;
    while (B <= A)
        B *= 2, cnt++;
    while (C <= B)
        C *= 2, cnt++;
    writeln(cnt <= K ? YES : NO);
}


Measured memory_bytes: 3696
#include <iostream>
#include <cstdio>

using namespace std;
typedef long long int ll;
const int maxn = 100005;
ll a[maxn];

int main()
{
    ll n, k, q;
    ll i, m;
    scanf("%lld%lld%lld", &n, &k, &q);
    for(i = 0;i < q;i++)
    {
        scanf("%lld", &m);
        a[m]++;
    }
    for(i = 1;i <= n;i++)
    {
        if((q-a[i]) >= k)
            printf("No\n");
        else printf("Yes\n");
    }


    return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <string.h>
int ara[500];
int main()
{
    int a,i,j,len=0,l;
    char s[500];
    char alpha[]={'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','\0'};
    scanf("%s",s);
    l=strlen(s);
    for (i=0;i<l;i++){
        for(j=0;j<26;j++){
            if(s[i]==alpha[j]){
                ara[j]++;
            }
        }
    }

    for(j=0;j<26;j++){
        if(ara[j]%2==0){
            len++;
        }
    }
    if(len==26) printf("Yes\n");
    else printf("No\n");


    return 0;
}


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

int main() {
    //d日分のコンテスト
    int d;
    cin >> d;
    //満足度低下指数
    vector<int> c(26);
    for (int i = 0; i < 26; i++) cin >> c.at(i);
    //満足度増加量
    vector<vector<int>> s(d, vector<int>(26));
    for (int i = 0; i < d; i++) {
        for (int j = 0; j < 26; j++) {
            cin >> s.at(i).at(j);
        }
    }
    
    //ｄ日目にどのテストをするか
    vector<int> t(d);
    for (int i = 0; i < d; i++) cin >> t.at(i);
    //d日目までの満足度
    vector<int> v(d);
    //最後に開催された日
    vector<int> last(26);
    //トータルの満足度
    int incr = 0;
    int decr = 0;
    //D日分の満足度増減を調べる
    for (int i = 0; i < d; i++){
        //満足度の増加は、i日目に開催されたtest = tの満足度増加量で決まる
        incr += s.at(i).at(t.at(i) - 1);
        //最後に開催された日にちのカウンターにi日目のテストを追加
        last.at(t.at(i) - 1) = i + 1;
        //満足度低下のカウンター
        //それぞれのタイプに対して、低下量を足しあげる
        for (int j = 0; j < 26; j++){
           decr += c.at(j) * ((i + 1) - last.at(j));
        }
        //最終的な満足度を計上
        v.at(i) = incr - decr;
    }
    
    for (int i = 0; i < v.size(); i++){
        cout << v.at(i) << endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
const ll mod[] = { 999999937, 1000000007 }, base = 10000103;

struct RollingHash
{
	int n;
	vector<ll> hs[2], pw[2];
	RollingHash() {};
	RollingHash(const string& s)
	{
		n = s.size();
		REP(i, 2)
		{
			hs[i].assign(n + 1, 0);
			pw[i].assign(n + 1, 0);
			hs[i][0] = 0;
			pw[i][0] = 1;
			REP(j, n)
			{
				pw[i][j + 1] = pw[i][j] * base%mod[i];
				hs[i][j + 1] = (hs[i][j] * base + s[j]) % mod[i];
			}
		}
	}

	ll hash(int l, int r, int i)
	{
		return ((hs[i][r] - hs[i][l] * pw[i][r - l]) % mod[i] + mod[i]) % mod[i];
	}

	bool match(int l1, int r1, int l2, int r2)
	{
		return (hash(l1, r1, 0) == hash(l2, r2, 0)) && (hash(l1, r1, 1) == hash(l2, r2, 1));
	}
};

int n, m;
short dp[1 << 12][5555];
vs v;
//vector<set<int>> match;
vector<vi> match;

int solve(int bit, int p)
{
	if (bit == (1 << n) - 1) return 1;
	if (dp[bit][p] >= 0) return dp[bit][p];
	int res = 0;
	REP(i, match[p].size())
	{
		if ((bit >> match[p][i]) & 1) continue;
		chmax(res, solve(bit | (1 << match[p][i]), p + v[match[p][i]].size()));
	}
	return dp[bit][p] = res;
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	while (cin >> n >> m, n)
	{
		MS(dp, -1);
		v.clear(), match.clear();
		v.resize(n);
		string s;
		REP(i, n) cin >> v[i];
		REP(i, m)
		{
			string t; cin >> t;
			s += t;
		}
		RollingHash hs(s);
		match.resize(s.size());
		REP(i, n)
		{
			RollingHash pat(v[i]);
			ll pat1 = pat.hash(0, v[i].size(), 0);
			ll pat2 = pat.hash(0, v[i].size(), 1);
			REP(j, (int)s.size() - (int)v[i].size() + 1)
			{
				ll hs1 = hs.hash(j, j + v[i].size(), 0);
				ll hs2 = hs.hash(j, j + v[i].size(), 1);
				if (pat1 == hs1 && pat2 == hs2) match[j].push_back(i);
			}
		}
		int len = 0;
		for (auto i : v) len += i.size();
		ll ans = 0;
		REP(i, (int)s.size() - len + 1)
		{
			ans += solve(0, i);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 48160
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  long long n,k;
  cin>>n>>k;
  long long ans=1;
  long long m;
  long long cnt;
  long long on=0,en=0;
  if(k%2==1){
    cnt = n/k;
    REP(i,3){
      ans *= cnt;
    }
  }else{
    m = k/2;
    cnt = n/m;
    if(cnt%2==0){
      on=en=cnt/2;
    }else{
      on=(cnt+1)/2;
      en=cnt-on;
    }
    REP(i,3){
      ans *= on;
    }
    ans += en*en*en;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------

ll f(ll x, ll y, ll z){
	return x*x + y*y + z*z + x*y + y*z + z*x;
}

bool is_square_number(ll n){
	return ( (ll)( sqrt(n) ) * (ll)( sqrt(n) ) == n );
}

// main -----------------------------------------------

int main() {
	ll n;
	cin >> n;
	vector<ll> ans(n+1, 0);
	PREP(x, 1, 101){
		PREP(y, 1, 101){
			PREP(z, 1, 101){
				ll q = f(x, y, z);
				if(q > 0 && q <= n){
					ans[q] ++;
				}
			}
		}
	}
	PREP(i, 1, n+1){
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3608
import math
a,b=map(int, input().split()) 
x=[list(map(int,input().split()))for _ in range(a)]
c = 0

for i in x:
    for j in x:
        ans = 0
        for k in range(b):
            ans += abs(i[k]-j[k])**2
        q = math.sqrt(ans)
        if q.is_integer() == True:
            c += 1
d = (c-a)//2
print(d)

Measured memory_bytes: 9064
N, T = map(int, input().split())
ct = [list(map(int, input().split())) for _ in range(N)] 
mi = float("inf")

for c, t in ct:
    if t <= T:
        mi = min(c, mi)

if mi == float("inf"):
    print("TLE")
else:
    print(mi)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long count = 0;
		while(h > 1){
			count++;
			h /= 2;
		}
		long ans = 2;
		for(int i = 0; i < count; i++){
			ans *= 2;
		}
		System.out.println(ans - 1);
	}
}


Measured memory_bytes: 23764
from math import sqrt

n, m = map(int, input().split())
l = []
for i in range(1, int(sqrt(m)) + 1):
	if m % i == 0:
		l.append(i)
		l.append(m // i)

ans = 1
for d in l:
	if d * n <= m:
		ans = max(ans, d)

print(ans)

Measured memory_bytes: 38640
#!/usr/bin/env python3

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

A, B = map(int, input().split())
S = input()

num = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']

flag = "Yes"
for i in range(A):
    if S[i] not in num:
        flag = "No"

if S[A] != '-':
    flag = "No"

for j in range(B):
    if S[j+A+1] not in num:
        flag = "No"

print(flag)

Measured memory_bytes: 9144
import Foundation

func readInts () -> [Int]{
   return readLine()!.split(separator: " ").map { Int($0)! }
}

func main(){
    let xy = readInts()
    for i in 0...xy[0] {
        if i*2 + (xy[0]-i)*4 == xy[1]{
            print("Yes")
            return
        }
    }
    print("No")
}

main()


Measured memory_bytes: 13588
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author dwij
 */


#include <bits/stdc++.h>


using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define endl '\n'

/**********************************************/




class CManagement {
public:
    void solve(istream &in, ostream &out) {
        int n;
        in >> n;
        map<int, int> mp;
        for (int i = 0; i < n - 1; ++i) {
            int k;
            in >> k;
            mp[k]++;
        }

        for (int j = 1; j <= n; ++j) {
            out << mp[j] << endl;
        }


    }
};


int main() {
    CManagement solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 13040