akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
long long int n,k;
vector< pair<long long int,long long int> > v;
long long int mem[105][100005];
long long int dp(int i, int j)
{
	if(i==0)
	{
		if(j-v[i].first>=0)
		{
			return v[i].second;
		}
		else
		{
			return 0;
		}
	}
	if(mem[i][j]!=-1)
	return mem[i][j];
	long long int ans = 0;
	if(i-1>=0)
	{
		ans = max(ans,dp(i-1,j));
	//	cout<<"1. mem["<<i<<"]["<<j<<"]: "<<ans<<endl;
		if(j-v[i].first>0)
		{
			ans = max(ans,dp(i-1,j-v[i].first)+v[i].second);
	//		cout<<"2. mem["<<i<<"]["<<j<<"]: "<<ans<<endl;
		}
		else if(j-v[i].first==0)
		{
			ans = max(ans,v[i].second);
	//		cout<<"3. mem["<<i<<"]["<<j<<"]: "<<ans<<endl;
		}
	}
	mem[i][j]=ans;
//	cout<<"4. mem["<<i<<"]["<<j<<"]: "<<ans<<endl;
	return ans;
}
int main()
{
	memset(mem,-1,sizeof(mem));
	cin>>n>>k;
	for(long long int i=0;i<n;i++)
	{
		long long int x,y;
		cin>>x>>y;
		v.push_back(make_pair(x,y));
	}
	cout<<dp(n-1,k);
	return 0;
}

Measured memory_bytes: 82304
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long

using namespace std;
const int MAXN = (int)(1e6) + 10;
const int MOD = (int)(1e9) + 7;
const ll INF = (ll)(1e18);

vector <double> a;
double x;
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    // Type your code here
    int n; cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> x; a.emplace_back(x);
    }
    sort(a.begin(),a.end());
    x = a[0];
    for(int i = 1; i < n; i++){
        x = (x + a[i]) / 2.0;
    }
    cout << fixed << setprecision(5) << x;
}


Measured memory_bytes: 256
def solve(n):
    Mrepeat = 10
    seedlist = [[str(i+j-1) for i in range(3)] for j in range(10)]
    seedlist[0] = ['0', '1']
    seedlist[9] = ['8', '9']
    numbers = [[] for i in range(Mrepeat + 1)]
    numbers[0] = [i for i in range(1,10)]
    for i in range(Mrepeat):
        for num in numbers[i]:
            for tmp in seedlist[num % 10]:
                numbers[i+1].append(int(str(num) + tmp))
    ans = []
    for i in numbers:
        ans += i
    return ans[n-1]

def main():
    n = int(input())
    print(solve(n))

if __name__ == '__main__':
    main()

Measured memory_bytes: 31144
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner ;

public class Main {
	public static void main(String[] ragas) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		ArrayList<Integer> list = new ArrayList<Integer>();
		int count = 0;

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

		Collections.sort(list);

		for(int i = 0;i < k;i++) {
			count += list.get(i);
		}

		System.out.println(count);
	}
}


Measured memory_bytes: 39224
#include <algorithm>
#include <cstdio>
#include <cstring>

typedef long long LL;

const int N = 1050;
const int M = 2050;
const int mod = 1000000007;

struct Edge{
  int u, v, w;
  bool operator<(const Edge &e) const {
    return w < e.w;
  }
}e[M];

int fa[N];

int Find(int x) { return fa[x] ? fa[x] = Find(fa[x]) : x; }
bool Union(int x, int y) { if ((x = Find(x)) != (y = Find(y))) { fa[x] = y; return true; } return false; }

LL pow_mod(LL x, int p) {
  LL ans = 1;
  for (; p; p >>= 1, (x *= x) %= mod)
    if (p & 1) (ans *= x) %= mod;
  return ans;
}

int main() {
  int n, m;
  LL x;
  scanf("%d%d%lld", &n, &m, &x);
  if (n <= 2) {
    printf("0\n");
    return 0;
  }
  for (int i = 0; i < m; ++i) scanf("%d%d%d", &e[i].u, &e[i].v, &e[i].w);
  std::sort(e, e + m);
  int s1 = 0, s2 = 0;
  for (int i = 0; i < m; ++i) {
    memset(fa, 0, sizeof fa);
    LL ans = e[i].w * Union(e[i].u, e[i].v);
    for (int j = 0; j < m; ++j)
      ans += e[j].w * Union(e[j].u, e[j].v);
    if (ans < x) ++s1;
    if (ans <= x) ++s2;
    // s2 > s1
  }
  printf("%lld\n", (pow_mod(2, std::min(m, m - s1 + 1)) - pow_mod(2, std::min(m, m - s2 + 1)) + mod) % mod);
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(4100000)
n,m = [int(i) for i in input().split()]
a = {int(input()) for i in range(m)}
dp = {}
def stairs(step):
  if step in a:
    return 0
  if step == 1:
    return 1
  if step == 2:
    return stairs(step-1) + 1
  if step in dp.keys():
    return dp[step]
  else:
    dp[step] = stairs(step-1) + stairs(step-2)
    return dp[step]
print(int(stairs(n)%1000000007))

Measured memory_bytes: 544228
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)

#define eps 1e-6
#define pi 3.141592653589793
using namespace std;

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;
ll fastpower(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y&1)
        res*=x;

        y>>=1;
        x=x*x;
    }
    return res;
}

void swap(ll &a,ll &b)
{
    a ^= b; 
    b ^= a; 
    a ^= b;
}
VPII arr(100005);
int n;
ll dp[100005];
ll knap(int h)
{
    if(h<=0)return 0;
    if(dp[h]!=-1)return dp[h];
    ll ans=INT_MAX;
    for(int i=0;i<n;++i)
    {
        ans=min(ans,arr[i].second+knap(h-arr[i].first));
    }
    return dp[h]=ans;
}
int main(int argc, char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int h;
    cin>>h>>n;
    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;++i)
    cin>>arr[i].first>>arr[i].second;

    cout<<knap(h);
    return 0;
}


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

int main(){
int n,k,x,y; cin >> n >> k >> x >> y;
  if( n <= k){ cout << n*x << endl;}
  else{ cout << k*x+(n-k)*y << endl;}
  
  return 0;
} 

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	// sc.Split(bufio.ScanWords)

	// n := nextInt()
	// slice := strings.Split(nextLine(), "")

	var n int
	var s string

	fmt.Scan(&n, &s)

	slice := strings.Split(s, "")

	count := make([]int, n+1)

	count[0] = 0

	for i := 0; i < n; i++ {
		count[i+1] = count[i]
		if slice[i] == "W" {
			count[i+1]++
		}
	}

	// fmt.Println(count)

	ans := n
	for i := 1; i < n+1; i++ {
		ans = min(ans, count[i-1]+n-i-(count[n]-count[i]))
	}

	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 30;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

int n;
string a, b;
bool can_up = false;

int main() {
	scanf( "%d", &n );
	while ( n-- ) {
		cin >> a;
		cin >> b;
		if ( a.size() > 80 || b.size() > 80 ) {
			printf( "overflow\n" );
			continue;
		}
		if ( a.size() < b.size() ) {
			swap( a, b );
		}
		while ( a.size() > b.size() ) {
			b = "0" + b;
		}
		for ( int i = a.size() - 1; i >= 0; i-- ) {
			a[ i ] += b[ i ] - '0' + can_up;
			can_up = ( a[ i ] - '0' ) / 10;
			a[ i ] = ( ( a[ i ] - '0' ) % 10 ) + '0';
		}
		if ( can_up ) {
			a = "1" + a;
			can_up = false;
		}
		if ( a.size() > 80 ) {
			printf( "overflow\n" );
			continue;
		}
		printf( "%s\n", a.c_str() );
	}
	return 0;
}

Measured memory_bytes: 1220
from bisect import bisect as b

H,W=map(int,input().split())
S=[list(input()) for _ in range(H)]

X=[]
HL=[[] for _ in range(H)]
WL=[[] for _ in range(W)]
for h in range(H):
    for w in range(W):
        if S[h][w]=="#":
            HL[h].append(w)
            WL[w].append(h)

ans=0

for h in range(H):
    for w in range(W):
        if S[h][w]==".":
            if len(HL[h])==0:
                hol=W
            else:
                x=b(HL[h],w)
                N=len(HL[h])
                if x==0:
                    hol=HL[h][x]
                elif x==N:
                    hol=W-1-HL[h][-1]
                else:
                    hol=HL[h][x]-HL[h][x-1]-1

            if len(WL[w])==0:
                ver=H
            else:
                y=b(WL[w],h)
                M=len(WL[w])
                if y==0:
                    ver=WL[w][y]
                elif y==M:
                    ver=H-1-WL[w][-1]
                else:
                    ver=WL[w][y]-WL[w][y-1]-1
            ans=max(ans,ver+hol-1)
print(ans)

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

int main(){
    int x,y;cin >> x >> y;
    if (x == 2){
        if (y == 2){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else if (x == 4 || x == 6 || x == 9 || x == 11){
        if (y == 4 || y == 6 || y == 9 || y == 11){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y==10 || y == 12){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

	return 0;
}

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n){
    cin>>a[i];
    a[i]--;
  }
  rep(i,0,n){
    if(a[a[i]]==i)res++;
  }
  cout<<res/2<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
long long ans;
long long a[10005];
long long n;
long long int m;
bool juruo(int a,int b){
	return a>b;
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1,juruo);
	for(int j=1;j<=m;j++){
		ans+=a[j];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

struct PrimeFactorization {
    vector<pair<int, int>> factors;
    void factor(ll n) {
        int sqrt_n = (int)(sqrt(n) + 0.5);
        primes.clear();
        isPrime.assign(sqrt_n + 1, true);
        for (int k = 2; k <= sqrt_n; ++k) {
            if (!isPrime[k]) continue;
            primes.push_back(k);
            for (int m = k * 2; m <= sqrt_n; m += k) isPrime[m] = false;
        }
        factors.clear();
        for (int i = 0; i < (int)primes.size() && n > 1; ++i) {
            if (n % primes[i] != 0) continue;
            factors.emplace_back(primes[i], 0);
            for (; n % primes[i] == 0; n /= primes[i]) factors.back().second++;
        }
        if (n > 1) factors.emplace_back(n, 1);
        sort(factors.begin(), factors.end());
    }
    pair<int, int> operator [](int i) const { return factors[i]; }
    int size() const { return factors.size(); }
private:
    vector<int> primes;
    vector<bool> isPrime;
} pf;

ll N;
vector<ll> ans;

void dfs(vector<int>& kexp, int d) {
    if (d == pf.size()) {
        // N = (K + 1) * K ^ x   (x >= 1)
        ll k = 1;
        rep(i, pf.size()) {
            rep(j, kexp[i]) k *= pf[i].first;
        }
        if (k == 1) return;

        int xmax = INF;
        rep(i, pf.size()) {
            if (kexp[i] == 0) continue;
            xmax = min(xmax, pf[i].second / kexp[i]);
        }

        ll y = 1;
        ll r = N;
        rep(i, xmax) {
            y *= k;
            r /= k;
            if (r % k == 1) {
                ans.push_back(k);
                break;
            }
        }
        return;
    }

    kexp[d] = 0;
    rep(i, pf[d].second + 1) {
        dfs(kexp, d + 1);
        kexp[d]++;
    }
}

void dfs2(vector<int>& kexp, int d) {
    if (d == pf.size()) {
        // N = x * K + 1   (1 <= x < N)

        ll k = 1;
        rep(i, pf.size()) {
            rep(j, kexp[i]) k *= pf[i].first;
        }
        if (k == 1) return;
        ans.push_back(k);
        return;
    }

    kexp[d] = 0;
    rep(i, pf[d].second + 1) {
        dfs2(kexp, d + 1);
        kexp[d]++;
    }
}

int main() {
    cin >> N;

    if (N == 2) {
        write(1);
        return 0;
    }

    pf.factor(N);
    vector<int> e(pf.size());
    dfs(e, 0);

    pf.factor(N - 1);
    e.resize(pf.size());
    dfs2(e, 0);

    ans.push_back(N);
    sort(all(ans));
    ans.erase(unique(all(ans)), ans.end());
    write(ans.size());
    rep(i, ans.size()) cerr << ans[i] << " ";
}

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

bool is_prime[200000];
int cumsum[200000];

int main() {
    fill(is_prime, is_prime + 200000, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i * i < 200000; i++) {
        if (is_prime[i]) {
            for (int j = 2; i * j < 200000; j++) {
                is_prime[i * j] = false;
            }
        }
    }
    for (int i = 1; i < 200000; i++) {
        if (i % 2 == 1 and is_prime[i] and is_prime[(i + 1) / 2]) {
            cumsum[i]++;
        }
        cumsum[i] += cumsum[i - 1];
    }

    int Q;
    cin >> Q;

    for (int i = 0; i < Q; i++) {
        int l, r;
        cin >> l >> r;

        cout << cumsum[r] - cumsum[l - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1664
#include <algorithm>
#include <iostream>
#include <vector>

int main()
{
    std::vector<std::string> s(3);
    for (int i = 0; i < 3; i++) {
        std::cin >> s[i];
        std::reverse(s[i].begin(), s[i].end());
    }

    int turn = 0;
    while (1) {
        if (s[turn].empty()) {
            std::string players = "ABC";
            std::cout << players[turn] << std::endl;
            return 0;
        }
        char next_turn = s[turn].back();
        s[turn].pop_back();
        switch (next_turn) {
        case 'a':
            turn = 0;
            break;
        case 'b':
            turn = 1;
            break;
        case 'c':
            turn = 2;
            break;
        }
    }
}


Measured memory_bytes: 256
N = gets.chomp.to_i
V = gets.split
C = gets.split

v = []
c = []
d = []
answer = 0

for x in 0...N
  v[x] = V[x].to_i
  c[x] = C[x].to_i
  d[x] = v[x] - c[x]
  if d[x] > 0
    answer += d[x]
  end
end

puts answer

Measured memory_bytes: 3836
#include<bits/stdc++.h>
	using namespace std;
	#define ll long long
	#define vv vector<ll>
	#define pp pair<ll,ll>
	#define ff first
	#define ss second
	#define vp vector<pp>
	#define ld long double
	#define pb push_back
	#define mp make_pair
	const ll mod=7+1e9;
	const ll N=400004;
	bool prime[N];
	const ll H=10;
	void isprime()
	{
		memset(prime,true,N);
		for(ll i=2;i*i<N;i++)
		{
			if(prime[i]==true)
			{
				for(ll j=i*i;j<N;j+=i)
				{
					prime[j]=false;
				}
			}
		}
	}
	ll power(ll a,ll n)
	{
		ll ans=1;
		a=a%mod;
		while(n>0)
		{
			if(n&1)
			{
				ans=(ans*a)%mod;
			}
			n=n>>1;
			a=(a*a)%mod;
		}
		return ans;
	}
	
	bool comp(pair<pair<string,ll>,ll> const &a,pair<pair<string,ll>,ll> const &b)
	{
		if(a.ff.ff==b.ff.ff)
		{
			return a.ff.ss>b.ff.ss;
		}
		return a.ff.ff < b.ff.ff;
	}
	
	
	int main() 
	{
		ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	    ll n,m;
	    cin>>n>>m;
	   vector<ll> t[m];
	    for(ll i=0;i<m;i++)
	    {
	    	ll k;
	    	cin>>k;
	    	while(k--)
	    	{
	    		ll x;
	    		cin>>x;
	    		t[i].pb(x);
			}
		}
		ll p[m];
		for(ll i=0;i<m;i++)
		{
			cin>>p[i];
		}
		ll ans=0;
		for(ll i=0;i<pow(2,n);i++)
		{
			bitset<H> b(i);
			ll flag=0;
			for(ll j=0;j<m;j++)
			{
				ll s=0;
				for(ll k=0;k<t[j].size();k++)
				{
				    if(b[t[j][k]-1]==1)
				    {
				    	s++;
					}
			    }
			    if(p[j]!=s%2)
			    {
			    	flag=1;
				}
		   }
		   if(flag==0)
		   {
		   	 ans++;
		   }
	}
	cout<<ans;
	return 0;
	}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
    int a, b;
    cin >> a >> b;
    if (b < a) {
        cout << a - 1 << endl;
    } else {
        cout << a << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
 
int main() {
  int S,G;
  cin >> S >> G;
  int res = 0;
  int count = 0;
  for(int i = S; i<=G;i++){
    int N = i;
    res = 0;
    res += (N % 10) * 10;
    N /= 10;
    res  += N % 10;
    N/=10;
    if(res == N /10) ++count;
  }
  cout << count << endl;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,count1=0,count2=0;
    cin>>a;
    cin>>b;
    cin>>c;
    if(a==5)
    {
        count1++;
        
    }
    else if(a==7)
    {
        count2++;
        
    }
    if(b==5)
    {
        count1++;
        
    }
    else if(b==7)
    {
        count2++;
        
    }
    if(c==5)
    {
        count1++;
        
    }
    else if(c==7)
    {
        count2++;
        
    }
    if(count1==2 && count2==1)
    {
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }
    return 0;
}


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

#define mod 1000000007
int H, W;
int dp[1010][1010];
// vector<vector<int>>dp(1010, vector<int>(1010, -1));
// int grid[1010][1010];

void print(vector<vector<int>>p)
{
    for(auto val : p)
    {
        for(auto vals : val)
        {
            cout << vals << " " ;
        }
        cout << endl;
    }
    
}
void print(int n_rows, int n_cols)
{
    for(int i = 0; i < n_rows; i++)
    {
        for(int j = 0; j < n_cols;j++)
        {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
}


// TOP DOWN
// int solve(int startrow, int startcol, int endrow, int endcol, vector<vector<int>> grid){

//     // Lets memoise
//     if(dp[startrow][startcol] != -1) return dp[startrow][startcol];


//     int val ;
//     // Base Case 
//     if(startrow > endrow || startcol > endcol) return 0;
//     if(startrow == endrow && startcol == endcol) return 1;
//     if(grid[startrow][startcol] == 0) return 0;
//     val = solve(startrow +1 , startcol, endrow, endcol, grid) + solve(startrow, startcol + 1, endrow, endcol, grid);
//     dp[startrow][startcol] = val%mod;
//     return val%mod;
// }

// BOTTOM UP
void solve(int startrow, int startcol, int endrow, int endcol, vector<vector<int>> grid){

    // if(startrow > endrow || startcol > endcol) return;
    // if(grid[startrow][startcol] == 0) dp[startrow][startcol] = 0;


    for(int row = 0; row < endrow; row++)
        for(int col = 0; col < endcol; col++)
        {
            if(row == 0 && col == 0) dp[0][0] = 1;
            if(grid[row][col] == 0) dp[row][col] = 0;
            else
                if(row >= 1 && col >= 1 && row < endrow && col < endcol)
                    dp[row][col] = (dp[row-1][col] + dp[row][col-1])%mod;
                else if(row >= 1 && row < endrow)
                    dp[row][col] = dp[row-1][col]%mod;
                else if(col >= 1 && col < endcol)
                    dp[row][col] = dp[row][col-1]%mod;
        }
}
int main()
{
    memset(dp, -1, sizeof(dp));
    cin >> H >> W;
    vector<vector<int>> grid(H, vector<int>(W));
    char c;
    for(int i = 0; i < H; i++)
    {
        for(int j = 0; j < W; j++)
        {
            cin >> c;
            // printf("%c", c);
            if(c == '.')
            {
                grid[i][j] = 1;
            }
            else{
                grid[i][j] = 0;
            }
        }
    }

    // print(grid);
    // cout << endl ;
    solve(0,0, H, W, grid);
    // print(H, W);
    cout << dp[H-1][W-1] << endl;

}

Measured memory_bytes: 12160
package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
)

func main() {
	defer writer.Flush()
	var A, B, C, D int
	fmt.Fscanf(reader, "%d %d %d %d\n", &A, &B, &C, &D)
	sMapA := make(map[int]bool)
	sMapB := make(map[int]bool)
	for i := 0; i <= 100; i++ {
		sMapA[i] = false
		sMapB[i] = false
	}
	for i := A; i <= B; i++ {
		sMapA[i] = true
	}
	for i := C; i <= D; i++ {
		sMapB[i] = true
	}
	var count int
	for i := 0; i <= 100; i++ {
		if sMapA[i] && sMapB[i] {
			count++
		}
	}
	if count > 0 {
		count = count -1
	}
	fmt.Fprintf(writer, "%d\n", count)
}


Measured memory_bytes: 640
using System;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		int[] a=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		Array.Sort(a);
		long ans=long.MaxValue,b=0;
		for(int i=a[0];i<=a[n-1];i++){
			b=0;
			for(int j=0;j<n;j++){b+=(a[j]-i)*(a[j]-i);}
			ans=Math.Min(ans,b);
		}
		Console.WriteLine("{0}",ans);
	}
}

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

using namespace std;

#define debug(a) cout << #a << ": " << a << endl
#define fto(i, l, r) for(int i = l; i <= r; ++i)
#define fdto(i, r, l) for(int i = r; i >= l; --i)

typedef long long ll;

const int MAXN = 5005;
const int MAXM = 205;
const int MAXK = 20;

int n, m, k, a[MAXN], b[MAXN][MAXM];
int st[MAXM][MAXK][MAXN];
ll x[MAXN], maxVal[MAXN];

int query(int j, int l, int r) {
    int level = log2(r-l+1);
    return max(st[j][level][l], st[j][level][r-(1<<level)+1]);
}

void solve(int l, int r, int kmin, int kmax) {
    if (l > r) return;

    int mid = (l+r)/2;
    int best = -1;

    fdto(i, min(kmax, mid), kmin) {
        ll val = 0;
        fto(j, 0, m-1)
            val += query(j, i, mid);
        val -= x[mid] - x[i];
        if (val >= maxVal[mid]) {
            maxVal[mid] = val;
            best = i;
        }
    }

//    printf("%d %lld %d\n", mid, maxVal[mid], best);

    solve(l, mid-1, kmin, best);
    solve(mid+1, r, best, kmax);
}

int main() {
    scanf("%d%d", &n, &m);
    fto(i, 1, n-1) scanf("%d", &a[i]);
    fto(i, 0, n-1)
        fto(j, 0, m-1) scanf("%d", &b[i][j]);

    x[0] = 0;
    fto(i, 1, n-1) x[i] = x[i-1] + a[i];

    k = log2(n);
    fto(j, 0, m-1) {
        fto(i, 0, n-1)
            st[j][0][i] = b[i][j];
        fto(level, 1, k) {
            int sz = 1<<level;
            fto(i, 0, n-sz)
                st[j][level][i] = max(st[j][level-1][i], st[j][level-1][i + sz/2]);
        }
    }

    solve(0, n-1, 0, n-1);

    //fto(i, 0, n-1) printf("%lld %d\n", maxVal[i], bestVal[i]);

    ll ans = 0;
    fto(i, 0, n-1)
        ans = max(ans, maxVal[i]);
    printf("%lld", ans);

    return 0;
}


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

int main() {
    int a[5];

    for (int i = 0; i < 5; i++) {
        cin >> a[i];
    }

    int min_mod = 10;
    int min_idx = -1;

    for (int i = 0; i < 5; i++) {
        int mod = a[i] % 10;

        if (mod == 0) {
            continue;
        }

        min_mod = min(min_mod, mod);
        if (min_mod == mod) {
            min_idx = i;
        }
    }

    int ans = 0;
    for (int i = 0; i < 5; i++) {
        if (i == min_idx) {
            ans += a[i];
            continue;
        }

        if (a[i] % 10 > 0) {
            ans += ((a[i] / 10 + 1) * 10);
        } else {
            ans += a[i];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
    	int N = ni();
		int A = ni();
		int B = ni();

		int[] t = nia(N);

		int cnt = 0;

		for (int i=0; i<N; i++) {
			if (t[i] < A || t[i] >= B) {
				cnt++;
			}
		}

		out.println(cnt);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}


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

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

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
int a,b,c;
cin>>a>>b>>c;
if(c>a && c>b){
  cout<<(a*b)/2<<endl;
}
else if(a>c && a>b){
  cout<<(c*b)/2<<endl;
}
else if(b>a && b>c){
  cout<<(a*c)/2<<endl;
}
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3600
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

inf = 10 ** 18
mod = 10 ** 9 + 7

n,x,t = lr()
tmp = (n+x-1)//x
print(tmp*t)

Measured memory_bytes: 72648
let () = Scanf.scanf "%d\n" @@ fun n ->
  let xys =
    Array.init n @@ fun _ ->
      Scanf.scanf "%d %d\n" @@ fun x y -> (x, y) in
  Array.sort (fun (x, y) (x', y') ->
    compare
      (atan2 (float_of_int y) (float_of_int x))
      (atan2 (float_of_int y') (float_of_int x'))) xys;
  let xacc = Array.make (2 * n + 1) 0 in
  let yacc = Array.make (2 * n + 1) 0 in
  for i = 0 to 2 * n - 1 do
    let x, y = xys.(i mod n) in
    xacc.(i + 1) <- x + xacc.(i);
    yacc.(i + 1) <- y + yacc.(i)
  done;
  Printf.printf "%.15f" @@
  sqrt @@
  float_of_int @@
  Array.fold_left (Array.fold_left max) min_int @@
  Array.init n @@ fun i ->
    Array.init (n + 1) @@ fun w ->
      let x = xacc.(i + w) - xacc.(i) in
      let y = yacc.(i + w) - yacc.(i) in
      x * x + y * y


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
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;
}

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int n;
    vvi a;
    a.resize(10);

    REP(i, 10)
    {
        a[0].push_back(i);
    }

    FOR(i, 1, 10)
    {
        REP(j, a[i - 1].size())
        {
            int k = a[i - 1][j] / pow(10, i - 1);
            if (k == 0)
            {
                a[i].push_back(a[i - 1][j] + pow(10, i) * 0);
                a[i].push_back(a[i - 1][j] + pow(10, i) * 1);
            }
            else if (k == 1)
            {
                a[i].push_back(a[i - 1][j] + pow(10, i) * 0);
                a[i].push_back(a[i - 1][j] + pow(10, i) * 1);
                a[i].push_back(a[i - 1][j] + pow(10, i) * 2);
            }
            else if (k == 9)
            {
                a[i].push_back(a[i - 1][j] + pow(10, i) * 8);
                a[i].push_back(a[i - 1][j] + pow(10, i) * 9);
            }
            else
            {
                a[i].push_back(a[i - 1][j] + pow(10, i) * (k - 1));
                a[i].push_back(a[i - 1][j] + pow(10, i) * k);
                a[i].push_back(a[i - 1][j] + pow(10, i) * (k + 1));
            }
        }
    }

    set<int> st;

    REP(i, 10)
    {
        REP(j, a[i].size())
        {
            st.insert(a[i][j]);
        }
    }

    // REP(i, ans.size())
    // cout << st[i] << endl;
    cin >> n;
    int cnt;
    auto itr = st.begin();
    REP(i, st.size())
    {
        if (i == n)
            cout << *itr << endl; // 要素を順に表示
        ++itr;
    }

    return 0;
}

Measured memory_bytes: 12208
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
using namespace std;

void func_A() {
	int A, B;
	int ans;
	cin >> A >> B;


	
	ans=A + B;
	if ((A - B) > ans)
		ans = A - B;
	
	if ((A * B) > ans)
		ans = A * B;

	cout << ans << endl;
}

int main()
{
	func_A();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i,n) cin >> d.at(i);
  int64_t ans=0;
  rep(i,n) {
    rep(j,n) {
      if(i == j) continue;
      ans  += d.at(i) * d.at(j);
    }
  }
  cout << ans / 2;
}

Measured memory_bytes: 256
X,K,D = map(int, input().split())
if X < 0:
    X = -X
div, mod = divmod(X,D)
if K <= div:
    print(X - K*D)
else:
    remain = K - div
    if remain % 2 == 1:
        print(D - mod)
    else:
        print(mod)

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

int main() {
  vector<char> t(3);
  cin >> t.at(0) >> t.at(1) >> t.at(2);
  
  int x = 0;
  for (int i = 0; i < 3; i++) {
    if (t.at(i) == 'o')
      x++;
  }
  
  cout << 700 + 100 * x << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    { 
        static void Main(string[] args)
        {
            //a → 97
            var ls = new List<int>();
            for (int i = 'a'; i <= 'z'; i++)
            {
                ls.Add(0);
            }
            string s = ReadLine();
            for (int i = 0; i < s.Length; i++)
            {
                int tmp = s[i];
                ls[(tmp-97)]++;
            }

            //judgement
            string ans = "Yes";
            for (int i = 0; i < ls.Count; i++)
            {
                if (ls[i] % 2 != 0)
                {
                    ans = "No";
                }
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    ll n, m;
    cin >> n >> m;
    priority_queue<P> q;
    for(int i=0; i<n; i++){
        ll A;
        cin >> A;
        q.push(P{A, 1});
    }
    for(int i=0; i<m; i++){
        ll B, C;
        cin >> B >> C;
        q.push(P{C, B});
    }

    ll ans = 0;
    while(n > 0){
        P p = q.top();
        q.pop();
        if(n >= p.second) ans += (p.first * p.second);
        else ans += (p.first * n);
        n -= p.second;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6384
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 100002;
const int maxm = 40;

int n, digits[maxm+2];
long long k, a[maxn], w[maxm+2], sum[maxm+2];

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

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

	++k;	

	for (int i = 0; i <= maxm; ++i) {
		if (k & (1LL << i))
			digits[i] = 1;

		for (int j = 0; j < n; ++j)
			if (a[j] & (1LL << i))
				++w[i];

		sum[i] = max(w[i], n-w[i]) << i;
		if (i > 0)
			sum[i] += sum[i-1];
	}

	long long ans = 0, acc = 0;
	for (int i = maxm; i >= 0; --i) {
		if (digits[i] == 1) {
			long long cur = acc + (w[i] << i);
			if (i > 0)
				cur += sum[i-1];

			ans = max(ans, cur);
		}

		acc += digits[i] == 0 ? w[i]<<i : (n-w[i])<<i;
	}
		
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf_8 -*-

def complete_bin_tree(A, i):
    key = i - 1
    left = (i * 2) - 1 if (i * 2) - 1 < len(A) else -1
    right = i * 2 if i * 2 < len(A) else -1
    parent = int(i/2) - 1 if int(i/2) > 0 else -1

    print("node " + str(i) + ": key = " + str(A[key]) + ", ", end = "")
    if parent >= 0:
        print("parent key = " + str(A[parent]) + ", ", end = "")
    if left >= 0:
        print("left key = " + str(A[left]) + ", ", end = "")
    if right >= 0:
        print("right key = " + str(A[right]) + ", ", end = "")

    print()


if __name__ == "__main__":
    H = int(input())
    a = [int(x) for x in input().split()]

    for i in range(1, H + 1):
        complete_bin_tree(a, i)

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

using namespace std;

int main()
{
    string w;
    cin >> w;
    int cnt[26] = {};
    for (int i = 0; i < (int)w.size(); i++) {
        cnt[w[i]-'a']++;
    }

    bool b = 1;
    for (int i = 0; i < 26; i++) {
        if (cnt[i] % 2 == 1) {
            b = 0;
            break;
        }
    }
    cout << (b ? "Yes" : "No") << endl;
    return 0;
}

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

int n, s, res = 0;

void dfs(int sum,int now, int cnt) {
	if (now == 10) {
		if (sum == s&&cnt == n) {
			res++;
		}
		return;
	}
	dfs(sum, now + 1, cnt);
	dfs(sum + now, now + 1, cnt + 1);
	return;
}

int main() {
	while (1) {
		res = 0;
		cin >> n >> s;
		if (n == 0 && s == 0) return 0;
		dfs(0, 0,0);
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3016
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           double                      long double
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

 main()

{
    fast
    int n,m,d;
    cin>>n>>m>>d;
    double lob,hor,ses;
    lob=(n-d)*(m-1);
    if(d!=0)lob=lob*2.00;
    hor=n*n;
    ses=lob/hor;
    cout<<fixed<<setprecision(15)<<ses<<endl;
    return 0;

}





































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

using namespace std;

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

    int n;
    cin >> n;
    if(n<9){
        cout << n << endl;
    }else if(9<=n&&n<100){
        cout << 9 << endl;
    }else if(n<999){
        cout << n - 100 + 10 << endl;
    }else if(999<=n&&n<10000){
        cout << 909 << endl;
    }else if(n<99999){
        cout << n - 10000 + 910 << endl;
    }else{
        cout << 90909 << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cctype>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
int main(){
    string alpha;
    int n;
    string taro;
    string hanako;
    int ptaro = 0;
    int phanako = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> taro >> hanako;
        if(taro > hanako) {
            ptaro += 3;
        } else if(taro < hanako) {
            phanako += 3;
        } else {
            ptaro += 1;
            phanako += 1;
        }   
    }
    cout << ptaro << " " << phanako << endl;
    return 0;
}

Measured memory_bytes: 3164
#include <map>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> A(N), B(N);
	for (int i = 0; i < N; ++i) cin >> A[i];
	for (int i = 0; i < N; ++i) cin >> B[i];
	map<int, int> C;
	for (int i = 0; i < N; ++i) {
		++C[A[i]];
		++C[B[i]];
	}
	vector<int> D;
	D.insert(D.end(), A.begin(), A.end());
	D.insert(D.end(), B.begin(), B.end());
	sort(D.begin(), D.end());
	D.erase(unique(D.begin(), D.end()), D.end());
	sort(D.begin(), D.end(), [&](int i, int j) { return C[i] > C[j]; });
	if (C[D[0]] > N) {
		cout << "No" << endl;
	}
	else {
		vector<vector<int> > G(1);
		int cursum = 0;
		for (int i : D) {
			if (cursum + C[i] > N) {
				G.push_back(vector<int>());
				cursum = 0;
			}
			cursum += C[i];
			G.back().push_back(i);
		}
		int L = G.size(); // !!! S <= 3 MUST HOLD !!! //
		for (int i = 0; i < L; ++i) {
			sort(G[i].begin(), G[i].end());
		}
		string S, T;
		vector<vector<int> > TG(L);
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < L; ++j) {
				if (binary_search(G[j].begin(), G[j].end(), A[i])) {
					S += 'A' + j;
				}
				if (binary_search(G[j].begin(), G[j].end(), B[i])) {
					T += 'A' + j;
					TG[j].push_back(B[i]);
				}
			}
		}
		string U;
		if (L == 2) {
			for (int i = 0; i < N; ++i) {
				U += (S[i] == 'A' ? 'B' : 'A');
			}
		}
		else if (L == 3) {
			int sa = 0, sb = 0, sc = 0, ta = 0, tb = 0, tc = 0;
			for (int i = 0; i < N; ++i) {
				if (S[i] == 'A') ++sa;
				if (S[i] == 'B') ++sb;
				if (S[i] == 'C') ++sc;
				if (T[i] == 'A') ++ta;
				if (T[i] == 'B') ++tb;
				if (T[i] == 'C') ++tc;
			}
			vector<vector<int> > mat(3, vector<int>(3));
			for (int i = 0; i <= sa + ta + sb + tb - N; ++i) {
				int g = (sa + ta + sb + tb - N) - i;
				if (sa >= i && tb >= i && sb >= g && ta >= g) {
					mat[0][1] = i;
					mat[1][0] = g;
					mat[0][2] = sa - i;
					mat[2][0] = ta - g;
					mat[1][2] = sb - g;
					mat[2][1] = tb - i;
					break;
				}
			}
			for (int i = 0; i < N; ++i) {
				for (int j = 0; j < 3; ++j) {
					if (mat[S[i] - 'A'][j] != 0) {
						U += 'A' + j;
						--mat[S[i] - 'A'][j];
						break;
					}
				}
			}
		}
		vector<int> ans;
		for (int i = 0; i < N; ++i) {
			ans.push_back(TG[U[i] - 'A'].back());
			TG[U[i] - 'A'].pop_back();
		}
		cout << "Yes" << endl;
		for (int i = 0; i < N; ++i) {
			if (i) cout << ' ';
			cout << ans[i];
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;


int main() {
    int K, N;
    cin >> K >> N;
    vector<long long> X;
    for (int i = 0; i < N; i++) {
        long long x;
        cin >> x;
        X.push_back(x);
    }
    long long ans = 0;
    for(int i = 0 ; i < X.size() ; i++){
        long long d = X[(i+1)%X.size()] - X[i];
        if( d < 0 ) d += K;
        ans = max(ans, d);
    }
    cout << K - ans << endl;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll juli(ll a, ll b)
{
    return a * a + b * b;
}
int main()
{
    ll N, D;
    cin >> N >> D;
    D = D * D;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        ll x, y;
        cin >> x >> y;
        if (juli(x, y) <= D)
            ans++;
    }
    cout << ans;
    getchar();
    getchar();
}

Measured memory_bytes: 3604
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

int main() {
  char C;
  cin >> C;

  char ans = C+1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256