akhauriyash/Code-Regression huggingface dataset:
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,x,y,z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
  using u64 = std::int_fast64_t;
public:
  u64 a;
  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
typedef modint<MOD> m;
#pragma endregion

int dp[101][2][101] = {0};
vector<int> vec;
int main() {
  string s;
  cin >> s;
  cin >> K;
  for(auto a : s){
    vec.push_back(a-'0');
  }
  int l = s.size();
  dp[0][0][0] = 1;
  for(int i=0;i<l;i++){
    for(int smaller = 0;smaller < 2; smaller++){
      for(ll k=0;k<=K;k++){
        for(int x=0;x<=(smaller?9:vec[i]);x++){
          if(x != 0){
            dp[i + 1][smaller || x < vec[i]][k+1] += dp[i][smaller][k];
          }else{
            dp[i + 1][smaller || x < vec[i]][k] += dp[i][smaller][k];
          }
        }
      }
    }
  }
  cout << dp[l][0][K] + dp[l][1][K];
}



Measured memory_bytes: 384
#include <iostream>
#include <stdlib.h>
#define MAX 200000
#define SENTINEL 2000000000
using namespace std;
typedef long long llong;

int L[MAX / 2 + 1], R[MAX / 2 + 1];

llong merge(int A[], int n, int left, int mid, int right)
{
	llong cnt = 0;
	int n1 = mid - left;
	int n2 = right - mid;
	for(int i = 0; i<n1; i++) L[i] = A[left + i];
	for(int i = 0; i<n2; i++) R[i] = A[mid + i];
	L[n1] = SENTINEL; R[n2] = SENTINEL;
	int i = 0,j = 0;
	for(int k = left; k < right; k++)
	{
		if(L[i] <= R[j])
		{
			A[k] = L[i++];
		}
		else
		{
			A[k] = R[j++];
			cnt += n1 - i;
		}
		
	}	
	return cnt;
}

llong mergeSort(int A[], int n, int left, int right)
{
	
	if(left + 1 < right)
	{
		int mid = (left + right) / 2;
		llong v1, v2, v3;
		v1 = mergeSort(A, n, left, mid);
		v2 = mergeSort(A, n, mid, right);
		v3 = merge(A, n, left, mid, right);
		return v1 + v2 + v3;
	}
	else return 0;
}



int main() {
	int n, A[MAX];
	cin >> n;
	for(int i =0; i < n; i++ )
	{
		cin >> A[i];
	}
	
	llong ans;
	ans = mergeSort(A, n, 0, n);
	cout << ans << endl;	
	
//	system("pause");
	return 0;
}


Measured memory_bytes: 4648
N = int(input())
S = list(input() for _ in range(N))

import collections
a = collections.Counter(S).most_common()
ans = []
for i in range(len(a)):
  if i == 0:
    ans.append(a[i][0])
  elif a[i - 1][1] == a[i][1]:
    ans.append(a[i][0])
  else:
    break
ans.sort()

for j in ans:
  print(j)

Measured memory_bytes: 45084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int md = 1e9+7;

int n, a[22][22];
int dp[22][1<<22];

int fun(int i, int m){
    if(i == n) return 1;

    int &ans = dp[i][m];
    if(ans != -1) return ans;

    ans = 0;
    for(int j=0; j<n; j++)
    if(a[i][j] && !(m & (1<<j)))
        ans += fun(i+1, m|(1<<j)), ans%=md;
    return ans;
}

int main(){

    cin.tie( nullptr );
    ios_base::sync_with_stdio(0);

    cin >> n;
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            cin >> a[i][j];

    memset(dp, -1, sizeof dp);
    cout << fun(0, 0) << "\n";

    return 0;
}


Measured memory_bytes: 364048
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
struct node{
	int a;
	int b;
}x[100005];

int main()
{
  int n,m;
  scanf("%d%d",&n,&m);
  for(int i=0;i<m;i++)
  {
      scanf("%d%d",&x[i].a,&x[i].b);
  }
  int start=x[0].a;
  int end=x[0].b;
  for(int i=1;i<m;i++)
  {
  	start=max(x[i].a,start);
  	end=min(x[i].b,end);
  }	
  int sum=end-start+1;
  if(sum<0)
  sum=0;
  printf("%d\n",sum);
  return 0; 
}
 

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

using namespace std;

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

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

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

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

    ll N, D, A;
    cin >> N >> D >> A;

    vector<Pll> XH(N);
    for (int i = 0; i < N; i++) {
        ll a, b;
        cin >> a >> b;
        XH[i] = make_pair(a, b);
    }

    sort(XH.begin(), XH.end());

    Vl xs(N);
    Vl hs(N);
    for (int i = 0; i < N; i++) {
        xs[i] = XH[i].first;
        hs[i] = XH[i].second;
    }

    ll ans = 0;
    Vl dredus(N);
    ll redu = 0;
    for (int cur = 0; cur < N; cur++) {
        redu += dredus[cur];
        if (hs[cur] - redu <= 0) continue;
        int right = upper_bound(xs.begin(), xs.end(), xs[cur] + 2 * D) - xs.begin();
        ll cnt = (hs[cur] - redu + A - 1) / A;
        ll r = cnt * A;
        ans += cnt;
        redu += r;
        if (right < N) dredus[right] -= r;
    }

    cout << ans << endl;

    return 0;
}

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

#define MAXN 500010

int n,q,a[MAXN],l[MAXN],r[MAXN];

int main()
{
	scanf("%d%d",&n,l);
	for(int i=1;i<=n;++i)scanf("%d",a+i),l[i]=min(l[i-1],abs(l[i-1]-a[i]));
	r[n+1]=1;
	for(int i=n;i>=1;--i)r[i]=r[i+1]+(r[i+1]<=a[i]/2?0:a[i]);
	scanf("%d",&q);
	while(q--)
	{
		scanf("%d",&n);
		puts(l[n-1]>=r[n+1]?"YES":"NO");
	}
}

Measured memory_bytes: 7808
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    string S;
    cin >> S;
    int ok = 1;
    rep(i,S.size()){
        if(i%2==0){
            if(S[i]=='L')ok = 0;
        }else if(i%2==1){
            if(S[i]=='R')ok = 0;
        }
    }
    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int a,b,c;
	cin >> a >> b >> c;
	cout << (a+b+c+max(a,max(b,c))*9) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int oya;
int D[100001];
int P[100001];
vector<int> V[100001];
int sagasu(int A) {
	if (D[A]) return D[A];
	if (A == oya) return 1;
	int ret = 0;
	for (int i : V[A]) {
		int kari = sagasu(i) + 1;
		if (ret < kari) {
			ret = kari;
			P[A] = i;
		}
	}
	D[A] = ret;
	return ret;
}


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


	int N, M;
	cin >> N >> M;
	int kodomo[100001] = {};
	rep(i, N + M - 1) {
		int a, b;
		cin >> a >> b;
		V[b].pb(a);
		kodomo[b] = 1;
	}

	rep1(i, N) {
		if (kodomo[i] == 0) {
			oya = i;
			break;
		}
	}

	rep1(i, N) {
		sagasu(i);
		co(P[i]);
	}

	Would you please return 0;
}

Measured memory_bytes: 10496
import java.util.*;

public class Main{

public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int[] mountains = new int[10];

for(int i=0; i<10; i++){
mountains[i] = sc.nextInt();
}

Arrays.sort(mountains);
System.out.println(mountains[9]);
System.out.println(mountains[8]);
System.out.println(mountains[7]);
}


}

Measured memory_bytes: 26332
import sys
#input = sys.stdin.buffer.readline

def main():
    N = int(input())
    a = input()
    nl = []
    
    for num in a:
        num = int(num)
        nl.append(num-1)

    if 1 in nl:
        cnt = 0
        for i,num in enumerate(nl):
            cnt += num*(N-1 == i|((N-1)-i))
        print(cnt%2)
    else:
        for i in range(N):
            nl[i] //= 2
        cnt = 0
        for i,num in enumerate(nl):
            cnt += num*(N-1 == i|((N-1)-i))
        print((cnt%2)*2)

if __name__ == "__main__":
    main()


Measured memory_bytes: 116260
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int num;
int cnt=0;
#define MAX 45
int qian[MAX],zhong[MAX];
vector<int> hou;
void restruction(int l ,int r){
	 if(l>=r) return ;
	 int a=qian[cnt++];
	 int pos_in;
	 for(int i =l;i<r;i++){
	 	if(zhong[i]==a) {pos_in=i;break;}
	 }
	 restruction(l,pos_in);
	 restruction(pos_in+1,r);
	 hou.push_back(a);
}
int main(){
scanf("%d",&num);
for(int i=0;i<num;i++){scanf("%d",&qian[i]);}
for(int i=0;i<num;i++){scanf("%d",&zhong[i]);}
restruction(0,num);
vector <int>::iterator it;
cout<<*(hou.begin());
for(it=hou.begin()+1;it!=hou.end();it++){
	cout<<" "<<*it;
}
cout<<endl;
}



Measured memory_bytes: 3224
x = int(input())

AC=0
WA=0
TLE=0
RE=0
for i in range(x):
    s = input()
    if s=="AC":
        AC+=1
    elif s=="WA":
        WA+=1
    elif s=="TLE":
        TLE+=1
    elif s=="RE":
        RE+=1

print("AC x {}".format(AC))
print("WA x {}".format(WA))
print("TLE x {}".format(TLE))
print("RE x {}".format(RE))

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

typedef long long ll;
typedef long long int lli;
const int MOD = 1000000007;
#define rep(i,n) for (int i = 0; i < (n); i++)

using namespace std;

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

	string S; cin >> S;

	for (int i = 0; i < S.size(); i++) {
		for (int j = i; j < S.size(); j++) {
			string A = S;
			A = A.substr(0, i) + A.substr(j, S.size() - j);
			if (A == "keyence") {
				cout << "YES" << endl;
				return 0;
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}

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

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

Measured memory_bytes: 256
s = gets.chomp
t = gets.chomp
q = []
j = 0
s.chars.each_cons(t.size) do |x|
  u = s.dup
  x = x.join.gsub('?', '.')
  if t =~ Regexp.new(x)
    u[j, t.size] = t
    q << u.gsub(/\?/, 'a')
  end
  j += 1
end
if q == []
  puts "UNRESTORABLE"
else
  puts q.sort[0]
end

Measured memory_bytes: 1788
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N = I()
ans = 0
for i in range(1,N+1):
    if i%3 != 0 and i%5 != 0:
        ans += i

print(ans)

Measured memory_bytes: 68012
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

int read(){
	int x=0;
	char ch=getchar();
	while(!isdigit(ch)) ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x;
}

int gcd(int a,int b) { return b?gcd(b,a%b):a; }
int lcm(int a,int b){
	int g=gcd(a,b);
	return a*b/g;
}

int main()
{
	int x=read();
	
	printf("%d\n",lcm(x,360)/x);
	
	return 0;
}

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

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

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

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

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

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

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

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

fn main() {
    input!{
        s: chars
    };

    println!("{}", s.iter().filter(|&c| c == &'1').count());

}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> a(n), b(n); for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
  lint res = accumulate(a.begin(), a.end(), 0LL);
  lint t = res;
  for (int i = 0; i < n; i++) if (a[i] > b[i]) t = min(t, (lint) b[i]);
  res -= t;
  cout << res << '\n';
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define V vector
#define pb push_back
#define mkp make_pair
#define pi pair<int,int>//struct pi {int fi,se;};
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define ln length()
#define sz size()
const int N=100006;
int t[N] ;

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

int32_t main()
{
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    // int t;cin>>t;while(t--)
    {
        int i,j,k,n,m,ans=0,cnt=0,sum=0;
        cin>>n;
        memset(t,-1,sizeof(t));
        int a[n];
        for(i=0;i<n;i++){
            cin>>a[i];
        }
        t[n-1] = 0;
        t[n-2] = abs(a[n-1] - a[n-2]);
        repd(i,n-3,0){
            t[i] = min(abs(a[i+1] - a[i]) + t[i+1] , abs(a[i+2] - a[i]) + t[i+2]);
        }
        cout << t[0]<<endl;

    }
}

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

const int N = 100010, INF = (int) 1e9 + 10;
vector< pair<int,int> > edge[N];
int d[N];

bool DFS(int v, int dis) {
  if ( d[v] != -INF && d[v] != dis ) return 0;
  else if ( d[v] != -INF && d[v] == dis ) return 1;
  d[v] = dis;
  bool ok = 1;
  for ( auto u:edge[v] ) {
    ok &= DFS(u.first,dis+u.second);
  }
  return ok;
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v, w;
    scanf("%d %d %d", &u, &v, &w);
    edge[u].push_back( make_pair(v,w) );
    edge[v].push_back( make_pair(u,-w) );
  }
  fill( d+1, d+n+1, -INF);
  bool ok = 1;
  for (int i = 1; i <= n; i++) {
    if ( d[i] == -INF ) {
      ok &= DFS(i,0);
    }
  }
  puts( ok ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 12032
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    int n;
    cin >> n;

    int mx = 0;
    int sm = 0;

    for (int i = 0; i < n; i++) {
        int l;
        cin >> l;
        sm += l;
        mx = max(mx, l);
    }

    if (mx < sm - mx) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;
class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int MIN = 1000001, MAX = -1000001; long SUM = 0;
		for(int i = 0; i < N; ++i) {
			int a = sc.nextInt();
			MIN = Math.min(MIN, a);
			MAX = Math.max(MAX, a);
			SUM += a;
		}
		System.out.println(MIN + " " + MAX + " " + SUM);
	}
}


Measured memory_bytes: 42104
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	char[] n = sc.next().toCharArray();
    	int sum = 0;
    	for(int i = 0; i < n.length; i++){
        	sum += Character.getNumericValue(n[i]);
        }

      	if(sum%9==0) System.out.println("Yes");
      	else System.out.println("No");
    }
}

Measured memory_bytes: 40656
#include<stdio.h>
#define MAX 25

typedef struct node{
  int p;
  int left;
  int right;
  int sib;
  int deg;
}Node;

int Depth[MAX];
int Height[MAX];
Node node[MAX];

void depth(int x, int y){
  Depth[x]=y;
  if(node[x].left!=-1)depth(node[x].left,y+1);
  if(node[x].right!=-1)depth(node[x].right,y+1);
}

int height(int x, int y){
  int i=0;
  int j=0;

  if(node[x].left==-1 && node[x].right==-1)return 0;
  if(node[x].left!=-1)i=height(node[x].left,y+1);
  if(node[x].right!=-1)j=height(node[x].right,y+1);

  if(i>=j)return i+1;
  else return j+1;


}

int main(){
  int n;
  int i,j;
  int id;
  int a;

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    node[i].p=-1;
    node[i].left=-1;
    node[i].right=-1;
    node[i].sib=-1;
    node[i].deg=0;
  }

  for(i=0;i<n;i++){
    scanf("%d",&id);

    for(j=0;j<2;j++){
      scanf("%d",&a);
      if(j==0){
	if(a!=-1){
	  node[id].left=a;
	  node[id].deg++;
	}
      }

      else {
	if(a!=-1){
	  node[id].right=a;
	  node[id].deg++;
	}
	if(node[id].left!=-1)node[node[id].left].sib=node[id].right;
	if(node[id].right!=-1)node[node[id].right].sib=node[id].left;

    }

    if(a!=-1)node[a].p=id;
  }

  }



  for(i=0;i<n;i++){
    if(node[i].p==-1)depth(i,0);
    Height[i]=height(i,0);
  }


  for(i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,node[i].p,node[i].sib,node[i].deg,Depth[i],Height[i]);

    if(node[i].right==-1 && node[i].left==-1 && node[i].p!=-1)printf("leaf\n");
    else if(node[i].p==-1)printf("root\n");
    else printf("internal node\n");
  }

  return 0;
}



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

typedef long long LL;
typedef unsigned long long ULL;

const int PI = 3.141592653589793;
const int inf = 1000111222;
const int mod = 1000000007;
const int N = 200007;

int main(){

        ios_base::sync_with_stdio(0);
        cin.tie(0); cout.tie(0);

        string s, t;
        cin >> s >> t;
        for (int i = 0; i < s.length(); i++) {
                if (s[i] != t[i]) {
                        cout << "No\n";
                        exit(0);
                }
        }
        cout << "Yes\n";
        return 0;
}



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

int main()
{
  int n,k; 
  cin >> n >> k;
  int l[n];
  rep(i,n) cin >> l[i];
  sort(l,l+n,greater<int>());
  int res = 0;
  rep(i,k)
  {
    res += l[i];
  }
  cout << res << endl;
}

Measured memory_bytes: 256
/* Code by : Suraj (@suraj1611) */

#include<bits/stdc++.h>
#include <string>

using namespace std;

#define ll long long int
#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mx INT_MAX
#define mn INT_MIN
#define md 1000000007
#define pb push_back
#define mp make_pair
#define pf printf
#define sc scanf
#define maxsize 1100005
#define lb cout<<endl;
#define F first
#define S second
#define print(i) cout<<i<<endl
#define print1(i,j) cout<<i<<" "<<j<<endl
#define label cout<<"hello!"<<endl
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll dp[maxsize];

ll power(ll x, ll  y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y%2 == 0) 
        return power(x, y/2)*power(x, y/2); 
    else
        return x*power(x, y/2)*power(x, y/2); 
} 

int main()
{
	IOS
	
	/*#ifndef ONLINE_JUDGE   
	    freopen("in.txt", "r", stdin);
	    freopen("out.txt", "w", stdout);
	#endif*/

	    
	    rep(i,maxsize)
	    dp[i]=mx;
	    ll n,k;
		cin>>n>>k;
		ll a[n];
		rep(i,n)
		cin>>a[i];
		
		dp[0]=0;

		if(k>n)
			k=n;
		rep(i,n)
		{
			rep1(j,k)
			{dp[i+j]=min(dp[i+j],dp[i]+abs(a[i]-a[i+j]));}
		
		}

		cout<<dp[n-1]<<endl;

	/*
	#ifndef ONLINE_JUDGE
    	cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
    #endif*/

    return 0;
}

Measured memory_bytes: 9600
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

N, M = map(int, readline().split())
H = list(map(int, readline().split()))

G = [[] for _ in range(N)]
for _ in range(M):
    A, B = map(int, readline().split())
    G[A-1].append(B)
    G[B-1].append(A)

ans = 0
for i, shimas in enumerate(G):
    is_ok = True
    height = H[i]
    for shima in shimas:
        if height <= H[shima-1]:
            is_ok = False
            break
    if is_ok:
        ans += 1

print(ans)

Measured memory_bytes: 29808
#!/usr/bin/env python
# coding: utf-8

# In[2]:


import collections


# In[13]:


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


# In[14]:


mycnt = collections.Counter(A)
mylist = mycnt.keys()
length = len(mylist)
if length%2 == 0:
    print(length-1)
else:
    print(length)


# In[ ]:






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

long long attack(long long h) {
  if (h == 1)
    return 1;
  return 2 * attack(h >> 1) + 1;
}

int main() {
  long long h;
  scanf("%lld", &h);
  
  long long ans = attack(h);
  printf("%lld\n", ans);

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main()
{
	int N;

	cin >> N;

	switch (N) {
	case 22:
		cout << "Christmas Eve Eve Eve" << endl;
		break;
	case 23:
		cout << "Christmas Eve Eve" << endl;
		break;
	case 24:
		cout << "Christmas Eve" << endl;
		break;
	case 25:
		cout << "Christmas" << endl;
		break;
	}

	return 0;
}


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

int n,a[110];

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}


int main()
{
	n=read();
	for ( int i=1; i<=n; ++i ) a[i]=read();
	bool p=true;
	for ( int i=1; i<=n; ++i) 
		if (a[i]%2==0 && a[i]%3!=0 && a[i]%5!=0) 
		{
			p=false;
			break;
		}
	if (!p) puts("DENIED");
	else puts("APPROVED");
	return 0;
}


Measured memory_bytes: 256
use io::*;
use std::*;

fn solve(a: i64, b: i64) {
    let ans = if (a * b) % 2 == 0 {"Even"} else {"Odd"};
    println!("{}", ans);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
fn main() {
    let con = read_string();
    let mut scanner = Scanner::new(&con);
    let mut a: i64;
    a = scanner.next();
    let mut b: i64;
    b = scanner.next();
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(move || solve(a, b)).unwrap().join().unwrap();
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 8572
import java.util.*;

public class Main{
    public static void main(String args[]) {
        Scanner sn = new Scanner(System.in);
        int K = sn.nextInt();
        String S = sn.next();
        String result = "";
        
        if(K < S.length()){
            for(int i=0; i<K; i++){
                result = result + S.substring(i,i+1);
            }
            result = result + "...";
            System.out.println(result);
        }else{
            System.out.println(S);
        }

        
    }
}

Measured memory_bytes: 39812
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()


int main() {

	ll N; cin >> N;
	vll a(N);
	rep(i, N) cin >> a[i];

	ll ans = 0;
	rep(i, N) {
		while (true) {
			if (a[i] % 2 == 0) {
				a[i] /= 2;
				++ans;
			}
			else break;
		}
	}
	cout << ans << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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 gcd(int a, int b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));}

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

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  sort(a.rbegin(), a.rend());
  ll ans = 0;
  ll count = 0;
  int i = 1;
  ll max_val = a[0];
  ll same_num = 1;
  while(a[i] == max_val){
    same_num++;
    i++;
  }
  ll num = same_num * 2 - 1;
  ans += num * max_val;
  if (num >= n-1){
    cout << max_val * (n-1) << endl;
    return 0;
  }
  count = num;
  while(count < n-1){
        ll add = min(n-1-count, (ll)2);
        count += add;
        ans += add * a[i];
        i++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 4844
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect, heapq
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
A = list(map(int,input().split()))

data = [(ai,i) for i,ai in enumerate(A)]
data.sort(reverse = True)

dp = [[0]*(n+1) for i in range(n+1)]
for i in range(n):
  for l in range(i+1):
    r = i-l
    dp[l+1][r] = max(dp[l+1][r], dp[l][r] + data[i][0] * abs(data[i][1] - l))
    dp[l][r+1] = max(dp[l][r+1], dp[l][r] + data[i][0] * abs(data[i][1] - (n-1-r)))

ans = 0
for i in range(n):
  ans = max(ans,dp[i][n-i])
print(ans)

Measured memory_bytes: 101092
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;
typedef long double LD;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int N = 302;

int n, a[N], hm[4];
LD res[N][N][N];
bool vis[N][N][N];

LD calc(int x, int y, int z) {
  if (vis[x][y][z])
    return res[x][y][z];
  LD prob = 1;
  int sum = 0;
  if (x > 0) {
    sum += x;
    prob += ((LD)x)/n * calc(x-1, y, z); 
  }
  if (y > 0) {
    sum += y;
    prob += ((LD)y)/n * calc(x+1, y-1, z);
  }
  if (z > 0) {
    sum += z;
    prob += ((LD)z)/n * calc(x, y+1, z-1);
  }
  sum = n-sum;
  if (sum > 0)
    prob *= ((LD)n)/(n-sum);
  vis[x][y][z] = true;
  return res[x][y][z] = prob;
}

int main() {
  init_ios();
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    ++hm[a[i]];
  }
  vis[0][0][0] = true;
  cout<<fixed<<setprecision(14);
  cout<<calc(hm[1], hm[2], hm[3])<<"\n";
}

Measured memory_bytes: 455040
import java.util.*;

public class Main {

static int n;
static long[] lazy;
static long[] node;
static long[] min;
static long INF = (1<<31)-1;

static void eval(int k, int l, int r) {
    if (lazy[k]!=0) {
        node[k] += lazy[k];
        min[k] += lazy[k]/(r-l);
        if (r-l>1) {
            lazy[2*k+1] += lazy[k]/2;
            lazy[2*k+2] += lazy[k]/2;
        }
        lazy[k] = 0;
    }
}

static void add(int a, int b, int x, int k, int l, int r) {
    eval(k, l, r);
    if (a<=l && r<=b) {
        lazy[k] += (long)x*(r-l);
        // min[k] += x;
        eval(k, l, r);
    } else if (b<=l || r<=a) {
    } else {
        add(a, b, x, 2*k+1, l, (l+r)/2);
        add(a, b, x, 2*k+2, (l+r)/2, r);
        min[k] = Math.min(min[2*k+1], min[2*k+2]);
    }
}

static void update(int k, int x) {
    min[n-1+k] = x;
    int tmp = n-1+k;
    while (tmp>0) {
        tmp = (tmp-1)/2;
        min[tmp] = Math.min(min[2*tmp+1], min[2*tmp+2]);
    }
}

static long query(int a, int b, int k, int l, int r) {
    eval(k, l, r);
    if (a<=l && r<=b) {
        return min[k];
    } else if (b<=l || r<=a) {
        return INF;
    } else {
        long lv = query(a, b, 2*k+1, l, (l+r)/2);
        long rv = query(a, b, 2*k+2, (l+r)/2, r);
        return Math.min(lv, rv);
    }
}

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

        int n_ = sc.nextInt();
        n = 1;
        while (n<n_) n*=2;
        lazy = new long[2*n-1];
        node = new long[2*n-1];
        min = new long[2*n-1];
        // Arrays.fill(min, INF);
        // for (int i=0;i<n_;i++) {
            // update(i, 0);
        // }
        // System.out.println(Arrays.toString(min));

        int q = sc.nextInt();
        for (int i=0;i<q;i++) {
            int com = sc.nextInt();
            if (com==0) {
                int s = sc.nextInt();
                int t = sc.nextInt();
                int x = sc.nextInt();
                add(s, t+1, x, 0, 0, n);
            } else { // com==1
                int s = sc.nextInt();
                int t = sc.nextInt();
                System.out.println(query(s, t+1, 0, 0, n));
            }
        }
        // System.out.println(Arrays.toString(min));
        // System.out.println(Arrays.toString(lazy));
        // System.out.println(Arrays.toString(node));
    }
}


Measured memory_bytes: 125384
from collections import defaultdict


def main():

    n = int(input())

    v = list(map(int, input().split(' ')))

    odd = defaultdict(int)
    even = defaultdict(int)
    odd[0] = 0
    even[0] = 0

    for i, num in enumerate(v):
        # print(i % 2)
        if (i % 2) == 0:
            even[num] += 1
        elif (i % 2) == 1:
            # print(i, ": ", num)
            odd[num] += 1

    a = sorted(even.items(), key=lambda x: x[1], reverse=True)
    b = sorted(odd.items(), key=lambda x: x[1], reverse=True)

    if a[0][0] != b[0][0]:
        ans = n - a[0][1] - b[0][1]
    else:
        ans = n - max(a[0][1] + b[1][1], a[1][1] + b[0][1])

    print(ans)


main()


Measured memory_bytes: 21140
N=gets.to_i
H=gets.chomp.split.map(&:to_i).reverse
ans=0
t=0
1.upto(N-1) do |i|
  if H[i-1] <= H[i]
    t+=1
  else
    ans = t if ans < t
    t = 0
  end
end
ans = t if ans < t

puts ans


Measured memory_bytes: 11524
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef pair<long long, long long> pLL;
typedef long long ll;
int MOD = 1000000007;
int bucket[110];
void factring(int n){
  while(n > 1){
    for(int i=2; i<=n; i++){
      if(n % i == 0){
        bucket[i]++;
        n /= i;
        break;
      }
    }
  }
}
int main(){
  int N;
  cin >> N;
  
  for(int i=2; i<=N; i++){
    factring(i);
  }
  
  int two = 0;
  int four = 0;
  int fourteen = 0;
  int twentyfour = 0;
  int seventyfour = 0;
  for(int i=2; i<=N; i++){
    if(bucket[i] >= 2) two++;
    if(bucket[i] >= 4) four++;
    if(bucket[i] >= 14) fourteen++;
    if(bucket[i] >= 24) twentyfour++;
    if(bucket[i] >= 74) seventyfour++;
  }
  
  int ans = 0;
  int kaijo = 1;
  if(two - 2 > 0 && four > 1){
    kaijo = four * (four-1);
    ans = kaijo / 2;
    ans = ans * (two - 2);
  }
  if(fourteen > 0 && four > 0){
    ans += fourteen * (four-1);
  }
  if(twentyfour > 0 && two > 0){
    ans += twentyfour * (two-1);
  }
  if(seventyfour > 0){
    ans += seventyfour;
  }
  
  cout << ans << endl;
    
  return 0;
}

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

typedef pair<int, int> pii;

int main(int argc, char *argv[]){
  int n;
  cin >> n;
  pii mat[n];
  int dp[n][n];
  int p[n + 1];

  //????????????
  for (int i = 0; i < n; i++) {
    cin >> mat[i].first >> mat[i].second;
  }
  for (int i = 0; i < n; i++) {
    p[i] = mat[i].first;
  }
  p[n] = mat[n - 1].second;
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      if(i != j)dp[i][j] = 1e9;
      else dp[i][j] = 0;
    }
  }
  //???????????§?????????
  //????????????DP
  for (int l = 2; l <= n; l++) {
    for (int i = 0; i <= n - l; i++) {
      int j = i + l - 1;
      for (int k = i; k < j; k++) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] +
                       p[i]*p[k + 1]*p[j + 1]);
      }
    }
  }
  std::cout << dp[0][n - 1] << std::endl;
            
  return 0;
}



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

bool change[1000];

int main(){
	int n; cin >> n;
	string x;cin >> x;
	int d; cin >> d;
	for(int i=0;i<n&&d>0;i++){
		if(x[i]=='0'){
			x[i]='1';
			d--;
			change[i]=true;
		}
	}
	for(int i=n-1;i>=0&&d>0;i--){
		if(!change[i]&&x[i]=='1'){
			x[i]='0';
			d--;
		}
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 3200
#include<iostream>
using namespace std;
int main(){
    int x,y,r;
    while (1){
        cin >> x >> y;
        if (x > y) {r = x;x = y;y = r;}
        if (x == 0 && y == 0) break;
        cout << x << " " << y << endl;
    }
    return 0;
}


Measured memory_bytes: 3072
t,n,m,r;main(){for(scanf("%d",&t);t--;printf("%d\n",r))for(scanf("%d%d",&n,&m),r=0;m-n;m/=2,n/=2)r+=(n%2+2)%2+(m%2+2)%2,n+=n&1,m-=(m%2+2)%2;}

Measured memory_bytes: 600
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int n,m;
char a[55][55],b[55][55];
int main()
{
	get2(n,m);
	for(int i=1;i<=n;i++)scanf("%s",a[i]+1);
	for(int i=1;i<=m;i++)scanf("%s",b[i]+1);
	bool ok=0;
	for(int i=1;i<=n-m+1&!ok;i++)
	{
		for(int j=1;j<=n-m+1&!ok;j++)
		{
			bool cur=1;
			for(int ii=1;ii<=m&&cur;ii++)
				for(int jj=1;jj<=m&&cur;jj++)
					cur&=(a[i+ii-1][j+jj-1]==b[ii][jj]);
			ok|=cur;
		}
	}
	puts(ok?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
def main():
    n, m = list(map(int, input().split(" ")))
    k_list = []
    s_list = []
    for _ in range(m):
        s = []
        for i, one in enumerate(input().split(" ")):
            if i==0:
                k = int(one)
            else:
                s.append(int(one))
        k_list.append(k)
        s_list.append(s)
    p = list(map(int, input().split(" ")))

    cnt = 0
    for x in range(2**n):
        f = 0
        onoff_list = [1 if bin(x)[2:].zfill(n)[i]=="1" else 0 for i in range(n)]
        for mi in range(m):
            s = s_list[mi]
            on_num = sum([onoff_list[si-1] for si in s])
            if on_num%2==p[mi]:
                f+=1
            else:
                break
        if f==m:
            cnt+=1
    print(cnt)

if __name__=="__main__":
    main()


Measured memory_bytes: 9276
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll n,k;
vector<ll> h;

int main(void) {
    cin >> n>> k;
    rep(i,n){
        ll tmp;
        cin >> tmp;
        h.push_back(tmp);
    }
    sort(h.begin(),h.end());
    ll res=ll(1)<<60;
    rep(i,n-k+1){
        res=min(res,h[i+k-1]-h[i]);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1400
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb push_back
#define res(v) v.resize(unique(v.begin(), v.end()) - v.begin());
#define cnt_res(v) std::distance(v.begin(),std::unique(v.begin(), v.end())); 
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
void solve(){
    int cnt=0,n;
    while(cnt++<5){cin>>n;if(n==0)cout<<cnt;}
}
int32_t main()
{
  ibs;cti;
  solve()
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  // int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int T1, T2, A1, A2, B1, B2;
    cin >> T1 >> T2;
    cin >> A1 >> A2;
    cin >> B1 >> B2;
    int ans = 0;
    if (T1 * B1 > T1 * A1) {
        swap(A1, B1);
        swap(A2, B2);
    }
    int progress1 = T1 * B1 - T1 * A1;
    int progress2 = T2 * B2 - T2 * A2;
    if (progress1 + progress2 < 0 && progress1 < 0 || (progress1 + progress2 > 0 && progress1 >= 0)) {
        cout << 0 << endl;
        return 0;
    }
    if (progress1 + progress2 == 0) {
        cout << "infinity" << endl;
        return 0;
    }
      
    //cout << progress1 << " " << progress2 << endl;
    //cout << progress1 + progress2 << endl;
    /*
    cout << T1 * A1 + T2 * A2 << endl;
    cout << T1 * B1 + T2 * B2 << endl;
    cout << T1 * B1 << endl;
    cout << T1 * A1 << endl;
    cout << T2 * B2 << endl;
    cout << T2 * A2 << endl;
    //*/
    int flag = 1;
    if (abs(progress1) % (progress1 + progress2) == 0) flag = 0;
    cout << abs(progress1) / (progress1 + progress2) * 2 + flag << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        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;
}
const int INF = 100000000;

int main(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    int l = 0, r = 0;
    int cnt = 0, ans = 0;
    if(s[0] == '0'){
        cnt++;
    }
    while(r < n){
        while(1){
            if(r >= n){
                break;
            }
            if(s[r] != s[r -1]){
                if(s[r-1] == '1'){
                    cnt++;
                }
            }
            if(cnt > k){
                break;
            }
            r++;
        }

        ans = max(ans, r - l);
        r++;
        while(cnt > k){
            l++;
            if(s[l-1] == '0' && s[l] == '1'){
                cnt--;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}

int32_t main()
{
	int t;
	t=1;
	while(t--)
	{
		int n;
		cin >> n;
		int a[n];
		for(int i=0;i<n;i++)
		{
			cin >> a[i];
		}
		int ans=0;
		for(int i=1;i<n;i++)
		{
			if(a[i]<a[i-1])
			{
				ans+=(a[i-1]-a[i]);
				a[i]=a[i-1];
			}
			
		}
		cout << ans;
	}
}




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


void solve(long long N, std::vector<long long> A, std::vector<long long> B){
    ll negnum = 0;
    ll negsum = 0;
    vector<ll> pos;
    REP(i, N){
        if(A.at(i) < B.at(i)){
            negnum++;
            negsum += B.at(i) - A.at(i);
        }else if(A.at(i) > B.at(i)){
            pos.push_back(A.at(i) - B.at(i));
        }
    }
    sort(pos.begin(), pos.end(), greater<ll>());
    ll possum = 0;
    ll posnum = 0;
    for(; possum < negsum && posnum < pos.size(); ++posnum){
        possum += pos.at(posnum);
    }
    if(possum >= negsum){
        cout << posnum + negnum << endl;
    }else{
        cout << -1 << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&B[i]);
    }
    solve(N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 2428
#include <bits/stdc++.h>
#define ld long double
#define int long long
using namespace std;
const int N = 2e5 + 50;
const int mod = 1e9 + 7;
const int inf = 1e17;
int dx[] = {0, 1, -1, 0, -1, 1, 1, -1};
int dy[] = {1, 0, 0, -1, -1, 1, -1, 1};
int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  string s;
  cin >> s;
  int a = stoi(s.substr(5, 2));
  int b = stoi(s.substr(8, 2));
  if(a > 4){
  	cout << "TBD";
  }else if(a == 4){
  	if(b <= 30){
  		cout << "Heisei";
  	}else{
  		cout << "TBD";
  	}
  }else{
  	cout << "Heisei";
  }
}

Measured memory_bytes: 256
STDIN.each_line do |line|
	a,b,c,d,e,f = line.split.map(&:to_f)
	x = (b*f-c*e)/(b*d-a*e)
	y = (c-a*x)/b
	puts "#{sprintf("%.3f",x+0.0)} #{sprintf("%.3f",y+0.0)}"
end

Measured memory_bytes: 8672