akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int n;
    scan(n);
    auto a = iota(n).map!(i => readln.split.to!(long[])).array;

    debug {
        //writeln(a);
    }

    auto score = new long[](1 << n);

    foreach (s ; 1 .. 1 << n) {
        foreach (j ; 0 .. n) {
            if (s & (1 << j)) {
                score[s] = score[s ^ (1 << j)];
                foreach (i ; 0 .. n) {
                    if (s & (1 << i)) {
                        score[s] += a[i][j];
                    }
                }
                break;
            }
        }
    }

    debug {
        writeln(score);
    }

    auto dp = new long[](1 << n);

    foreach (s ; 1 .. 1 << n) {
        for (int t = s; t > 0; t = (t - 1) & s) {
            dp[s] = max(dp[s], dp[s ^ t] + score[t]);
        }
    }

    auto ans = dp[(1 << n) - 1];

    writeln(ans);
}







void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


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

using namespace std;

#define repl(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) repl(i,0,n)
#define maxch(a,b) a=max(a,b)

int n;
int a[333];
int dp[333][333];

int main(int argc, char const *argv[])
{
  while(1){
    cin>>n;
    if(n==0)break;
    rep(i,n)cin>>a[i];
    memset(dp,0,sizeof(dp));
    rep(i,n-1)dp[i][i+2]=abs(a[i]-a[i+1])<=1?2:0;
    repl(len,3,n+1)rep(i,n-len+1){
      int j=i+len;
      repl(k,i,j){
        maxch(dp[i][j],dp[i][k]+dp[k][j]);
      }
      if(dp[i+1][j-1]==(j-1)-(i+1)&&abs(a[i]-a[j-1])<=1){
        maxch(dp[i][j],dp[i+1][j-1]+2);
      }
    }
    cout<<dp[0][n]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3512
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
	string s1,s2,s3;
	cin>>s1>>s2>>s3;
	cout<<s1[0]<<s2[0]<<s3[0]<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()
key = 0
 
if N%2 == 1:
  key += 1
else:
  for i in range(N//2):
    if S[i] != S[(N//2)+i]:
      key += 1
    
if key >= 1:
  print('No')
else:
  print('Yes')


Measured memory_bytes: 38384
<?php
list($n) = ints();
$b = ints();
while (count($b) > 0) {
    for ($i = count($b) - 1; $i >= 0; --$i) {
        if ($i + 1 === $b[$i]) {
            $a[] = $b[$i];
            unset($b[$i]);
            $b = array_values($b);
            continue 2;
        }
    }
    exit('-1');
}
echo implode(PHP_EOL, array_reverse($a));
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

int main(){
	int n;
	cin >> n;
	int count =0;
	for (size_t i = 1; i <= n; i++)
	{	
		if(((int)log10(i)) %2 == 0) count++;
	}

	cout << count;
	
}

Measured memory_bytes: 256
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*
int inv[1000001]={0};int invf[1000001]={0};
void findinverse(){
	inv[0]=1;
	inv[1] = 1;
	for(int i = 2; i <=1e6 ; ++i)
		inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;
	invf[0]=1;invf[1]=1;
	for(int i=2;i<=1e6;i++){
		invf[i]=invf[i-1]*inv[i]%mod;
	}
}*/
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> orderedMultiset;
int solve()
{
	int n;
	cin>>n;
	vi a,b;
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		a.pb(x+y);
		b.pb(x-y);
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	int ans=max(a.back()-a[0],b.back()-b[0]);
	cout<<ans<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}



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

#define lsb(x) (x & (-x))

#define int long long

const int N = (int)(2e5) + 10;

int a[N], bit[N], pos[N], h[N];

int n;

void update(int idx, int val) {
    while (idx <= n) {
        bit[idx] = max(bit[idx], val);
        idx += lsb(idx);
    }
}

int query(int idx) {
    int ans = 0;
    while (idx > 0) {
        ans = max(ans, bit[idx]);
        idx -= lsb(idx);
    }
    return ans;
}

signed main()
{
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> h[i];
        pos[h[i]] = i;
    }
    for (int i = 1; i <= n; ++i)
        cin >> a[h[i]];
    
    int ans = 0;

    for (int i = 1; i <= n; ++i) {
        int total_height = query(pos[i]) + a[i];
        update(pos[i], total_height);
        ans = max(ans, total_height);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007

int main()
{  
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string a,b;
    cin>>a>>b;
    
    int n=a.length();
    int m=b.length();
    
    int dp[n+1][m+1];
    
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            if(i==0)dp[i][j]=0;
            else if(j==0)dp[i][j]=0;
            else
            {
                if(a[i-1]==b[j-1])dp[i][j]=1+dp[i-1][j-1];
                else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    string s="";
    int i=n,j=m;
    while(i>0 && j>0)
    {
        if(a[i-1]==b[j-1]){s=a[i-1]+s;i-=1;j-=1;}
        else 
        {
            if(dp[i-1][j]>dp[i][j-1])i-=1;
            else j-=1;
        }
    }
    cout<<s<<"\n";
}

Measured memory_bytes: 35456
taka, aoki, times= map(int,input().split())
if taka + aoki > times:
    if taka < times:
        print(0,aoki - (times - taka))
    elif taka > times:
        print(taka - times, aoki)
    else:
        print(0,aoki)
else:
    print(0,0)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int f1[505050];
int f2[505050];
char s[505050];
bool jud(int l,int f)
{
	return f==0||l%(l-f)!=0;
}
int main()
{
	int l,t=0,cnt;
	int ans;
	scanf("%s",s+1);
	l=strlen(s+1);
	f1[1]=0;
	for(int i=2;i<=l;i++)
	{
		f1[i]=f1[i-1];
		while(f1[i]&&s[i]!=s[f1[i]+1])
			f1[i]=f1[f1[i]];
		if(s[f1[i]+1]==s[i])
			f1[i]++;
	}
	t=l-f1[l];
	if(l%t!=0)
		t=l;
	cnt=l/t;
	if(cnt==1)
	{
		printf("1\n1\n");
		return 0;
	}
	if(t==1)
	{
		printf("%d\n1\n",l);
		return 0;
	}
	for(int i=1;i<=l/2;i++)
		swap(s[i],s[l-i+1]);
	f2[1]=0;
	for(int i=2;i<=l;i++)
	{
		f2[i]=f2[i-1];
		while(f2[i]&&s[i]!=s[f2[i]+1])
			f2[i]=f2[f2[i]];
		if(s[f2[i]+1]==s[i])
			f2[i]++;
	}
	ans=0;
	for(int i=1;i<l;i++)
		if(jud(i,f1[i])&&jud(l-i,f2[l-i]))
			ans++;
	printf("2\n%d\n",ans);
	return 0;
}

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

def hoge(x):
    if x%2==0:
        return x//(-2),0
    else:
        return x//(-2)+1,1


def base10_to_minus2(x):
    shou,amari=hoge(x)
    if shou:
        return base10_to_minus2(shou)+str(amari)
    return str(amari)

print(base10_to_minus2(n))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,c=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if(a[k]>=a[i]+a[j])
                   break;
                else
                    c++;
            }
        }
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
N, W = map(int, input().split())
inf = 1 << 60
# dp[i][j] = i個目までの商品を価値jで運んだときの重さの最小値
dp = [[inf for j in range(100001)] for i in range(N + 1)]
dp[0][0] = 0

for i in range(1, N + 1):
    wi, vi = map(int, input().split())
    for v in range(0, 100001):
        dp[i][v] = min(dp[i][v], dp[i - 1][v])
    for v in range(vi, 100001):
        dp[i][v] = min(dp[i][v], dp[i - 1][v - vi] + wi)

ans = [(i,v) for i,v in enumerate(dp[N])]
ans = list(filter(lambda e: e[1] <= W, ans))
ans = ans[-1][0]
print(ans)


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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll N, K, ans=0;

signed main(){
    cin >> N >> K;
    COMinit();
    if(K<=N-1) {
        for(int i=0;i<=K;i++) {
            ans += COM(N, i)*COM(N-1, i)%MOD;
            ans %= MOD;
        }
    }
    else {
        for(int i=0;i<=N-1;i++) {
            ans += COM(N, i)*COM(N-1, i)%MOD;
            ans %= MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lim
#define mod 1e9+7
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
int main()
{
	ll a, b;
	cin>>a>>b;
	if(a<=0&&b>=0)
	{
		cout<<"Zero";
		return 0;
	}
	b=min(b,0LL);
	if(a>0)
	{
		cout<<"Positive";
		return 0;
	}
	a=b-a+1;
	if(a%2==0)
	{
		cout<<"Positive";
		return 0;
	}
	else cout<<"Negative";
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;
int main() {
	long long int a=0,b=0,c=0,d=0,n=0,ans=0,count=0,h,w ,end=0,idx,m;
	string s;
	vector<long long int> x,l,xc,lc;
	vector<long long int>::iterator position;
	bool q=false;
	cin >> n>>m;
	if (n > m) {
		count = m; 
		d = n;
	}
	else {
		count = n;
		d = m;
	}
		for (int i = 0; i < d; i++)
		{
			cout << count;
		}
		cout << endl;
	
	
}

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

using pii = pair<int, int>;
vector<int> G[100003];
int cnt[100003];
void go(int idx,int p) {
	
	for (auto &to : G[idx]) {
		if (p == to) continue;
		go(to, idx);
		cnt[idx] ^= cnt[to] + 1;
	}
}
int main() {
	int n; scanf("%d", &n);
	for (int i = 0; i < n-1; i++) {
		int a, b; scanf("%d %d", &a, &b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	go(1,1);
	if (cnt[1] == 0) printf("Bob");
	else printf("Alice");
}

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


int main() {

    int n;
    cin >> n;
    rep(i, n) {
        char s; cin >> s;
        if (s == 'Y') {
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
    return 0;
}

Measured memory_bytes: 256
MAX_V = 100100
MAX_N = 101
INF = pow(2, 60)

N, W = map(int, input().split())
w = [0 for _ in range(N)]
v = [0 for _ in range(N)]
for i in range(N):
    w[i], v[i] = map(int, input().split())

dp = [[INF for _ in range(MAX_V)] for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
    for sum_v in range(MAX_V):
        # print(i, sum_v, sum_v - v[i] >= 0)
        if sum_v - v[i] >= 0:
            dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v - v[i]] + w[i])
        dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v])
        # print(dp[i + 1][sum_v])

ans = max([i for i in range(len(dp[N])) if dp[N][i] <= W])
# for l in dp:
#     print([n for n in l if not n == INF])

print(ans)


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

int main(int args, char *argv[])
{
  int N;
  cin >> N;
  long long x[5] = {0};

  for (int i = 0; i < N; i++)
  {
    string s;
    cin >> s;
    if (s[0] == 'M')
    {
      x[0]++;
    }
    if (s[0] == 'A')
    {
      x[1]++;
    }
    if (s[0] == 'R')
    {
      x[2]++;
    }
    if (s[0] == 'C')
    {
      x[3]++;
    }
    if (s[0] == 'H')
    {
      x[4]++;
    }
  }

  long long ret = 0;
  for (int i = 0; i < 5; i++)
  {
    for (int j = i + 1; j < 5; j++)
    {
      for (int k = j + 1; k < 5; k++)
      {
        ret += x[i] * x[j] * x[k];
      }
    }
  }

  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll n,u,v;
ll Solve(ll a ,ll b){
    if(n==1) return min(a,b);
    vector<ll> tmp;
    while(a>0){
        tmp.push_back(a);
        a=(a-1)/n;
    }
    
    sort(tmp.begin(),tmp.end());
    while(b>0){
        if(binary_search(tmp.begin(),tmp.end(),b)){
            return b;
        }
        b=(b-1)/n;
    }
    return 0;
}
int main(){
    
    ll q;
    cin>>n>>q;
    while(q--){
        cin>>u>>v;
        u--;v--;
        cout<<Solve(u,v)+1<<endl;;
    }
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <queue>

typedef long long ll;
using namespace std;

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

	ll sum = 0;

	vector<int> mod_10;
	priority_queue<pair<int,int> > not_mod_10; // remainder, quot

	for (int i = 0; i < 5; i++) {
		if (arr[i] % 10 == 0)
			mod_10.push_back(arr[i]);
		else
			not_mod_10.push(make_pair(arr[i] % 10, arr[i] / 10));
	}

	for (int y : mod_10)
		sum += y;

	while (!not_mod_10.empty()) {
		pair<int, int> top = not_mod_10.top();
		not_mod_10.pop();
		int remainder = top.first;
		int quot = top.second;

		if (!not_mod_10.empty()) {
			sum += (quot + 1) * 10;
		}
		else {
			sum += quot * 10 + remainder;
		}
	}

	cout << sum;
}

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


int main() {
	int n,ans;
	ans=0;
	cin >> n;
	vector<char>s(n);
	for (int i = 0; i < n; i++) {
		cin >> s.at(i);
	}
	for (int i = 0; i < (n-2); i++) {
		if (s.at(i) == 'A') {
			if (s.at(i+1) == 'B') {
				if (s.at(i+2) == 'C') {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
}

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

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

    vector<long long int> c(n);
    for(int i=0; i<n; i++){
        cin >> c[i];
    }
    sort(c.begin(), c.end());
    reverse(c.begin(), c.end());

    long long int ans = 0;
    for(int i=0; i<n; i++){
        ans += c[i] * (i+2);
        ans %= MOD;
    }
    for(int i=0; i<n-1; i++){
        ans *= 4;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
package main

import (
	"fmt"
	"sort"
)

func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func main() {
	var N, X int
	fmt.Scan(&N, &X)
	x := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&x[i])
	}
	x = append(x, X)

	sort.Ints(x)
	diff := make([]int, N)
	for i := 0; i < N; i++ {
		diff[i] = x[i+1] - x[i]
	}
	ans := diff[0]
	for i := 0; i < N; i++ {
		ans = gcd(ans, diff[i])
	}

	fmt.Println(ans)
}


Measured memory_bytes: 5504
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import sys


def get_ints():
    return map(int, sys.stdin.readline().strip().split())


def main():
    n, x, t = get_ints()
    a, b = divmod(n, x)
    if b == 0:
        print(a * t)
    else:
        print((a + 1) * t)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  string s;
  cin >> s;
  ll cnt0=0;
  ll cnt1=0;
  ll k=s.size();
  rep(i,k){
    if(s[i]=='1'){
      cnt1++;
    }
    else{
      cnt0++;
    }
  }
  cout << 2*min(cnt1,cnt0) << endl;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

std::string S;
int ans;

int main()
{
	in >> S;

	ans = S.length();
	rep(i, S.length() - 1)
	{
		if (S[i] != S[i + 1]) { ans = std::min(ans, std::max<int>(i + 1, S.length() - (i + 1))); }
	}

	out << ans << std::endl;
	return 0;
}

Measured memory_bytes: 512
open Batteries

module IntSet = Set.Make (struct
  let compare = Pervasives.compare

  type t = int
end)

let read_two () = Scanf.sscanf (read_line ()) "%d %d" (fun a b -> (a, b))

let read_three () =
  Scanf.sscanf (read_line ()) "%d %d %d" (fun a b c -> (a, b, c))

let read_four () =
  Scanf.sscanf (read_line ()) "%d %d %d" (fun a b c d -> (a, b, c, d))

let read_list () =
  read_line () |> String.split_on_char ' '
  |> List.map (fun s -> int_of_string s)

let rec read_list_nl n =
  if n = 0 then [] else (read_line () |> int_of_string) :: read_list_nl (n - 1)

(* a**x *)
let pow a x =
  let rec aux acc = function 0 -> acc | n -> aux (acc * a) (n - 1) in
  aux 1 x

let rec pow2 n = if n mod 2 = 0 then 1 + pow2 (n / 2) else 0

let rec f d a n = if n > d then 0 else 1 + f d a (n + a)

let rec total acc = function [] -> acc | x :: rest -> total (acc + x) rest

let () =
  let _ = read_int () in
  let ans =
    read_list () |> List.map pow2
    |> List.fold_left (fun x acc -> if acc > x then x else acc) 32
  in
  print_int ans;
  print_newline ()


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  ll a,b,x, result=0;
  cin>>a>>b>>x;
  if(x==1){
    result=(b-a+1);
  }else if(a==0){
    result=b/x+1;
  }else{
    result = b/x-(a-1)/x;
  }


  cout<<result;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

//RMQ
struct SegTree {
    int N;
    vector<int> dat;
    SegTree() {}
    SegTree(int n) {
        N = 1;
        while(N < n) N *= 2;
        dat.resize(2 * N, INF);
        // for(int i = 0; i < 2*N-1; i++)
        //     dat[i] = INF;
    }
    // update k th element
    void update(int k, int a) {
        k += N-1; // leaf
        dat[k] = a; 
        while(k > 0) {
            k = (k - 1) / 2;
            dat[k] = min(dat[k*2+1], dat[k*2+2]);
        }
    }
    // min [a, b)
    int query(int a, int b) { return query(a, b, 0, 0, N); }
    int query(int a, int b, int k, int l, int r) {
        if(r <= a or b <= l) return INF;
        if(a <= l and r <= b) return dat[k];
        int m = (l + r) / 2;
        return min(query(a, b, k*2+1, l, m), query(a, b, k*2+2, m, r));
    }
};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    SegTree r(2 * n);
    rep(i, 0, n){
        cin >> a[i];
        r.update(i, a[i]);
        r.update(i + n, a[i]);
    }
    int ans = 1e18;
    rep(i, 0, n){
        int sum = i * x;
        rep(j, 0, n){
            int tmp = r.query(n + j - i, n + j + 1);
            sum += tmp;
        }
        chmin(ans, sum);
    }
    cout << ans << endl;
}

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

namespace AtCoders {
	class Program {
		static void Main(string[] args) {
		var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long H = inputArray[0];
			long N = inputArray[1];

			var magics = createLongTuppleList(N);

			//動的計画法を使用する
			//d[i,h] iはi番目までの魔法を使えることを表す jは魔物のHPがhであることを表す
			//d[i+1,h]=Min(d[i,h],d[i+1,h-A(i+1)]+B(i+1))となる

			var dp =new long[N, H+1];



			for (int i = 0; i < N; i++) {



				var magic = magics[i];
				for (int h = 0; h <= H; h++) {
					//i=1のみの場合を最初に設定
					if (i == 0) {
						var kaisu = h / magic.Item1;
						if (h% magic.Item1!=0) {
							kaisu++;
						}
						dp[i, h] = kaisu * magic.Item2;
						continue;
					}

					//i番目の魔法を活用する場合
					var useIMagic = magic.Item1 >= h ? dp[i, 0] + magic.Item2 : dp[i, h - magic.Item1] + magic.Item2;
					var notUseIMagic = dp[i - 1, h];

					dp[i, h] = Math.Min(useIMagic, notUseIMagic);

				}
			}

			//答えの出力
			var ans = dp[N-1, H];
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}


Measured memory_bytes: 106560
#include<iostream>

int main(){
	int x, y;
	int tmp;
	std::cin >> x;
	std::cin >> y;
	while (x != 0 || y != 0){
		if (x > y){
			tmp = x;
			x = y;
			y = tmp;
		}
		std::cout << x << " " << y << '\n';
		std::cin >> x;
		std::cin >> y;
	}
}

Measured memory_bytes: 1160
package main

import "fmt"

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var x, n int
	fmt.Scan(&x, &n)
	num := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&num[i])
	}

	p := map[int]bool{}
	for i := 0; i < n; i++ {
		p[num[i]] = true
	}
	ans := -99
	for i := 0; i <= 101; i++ {
		if p[i] {
			continue
		}
		if abs(x-i) < abs(x-ans) {
			ans = i
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1840
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
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...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, 0, n) {
        cin >> a[i];
    }
    vector<int> ord(n);
    iota(ord.begin(), ord.end(), 0);
    sort(ord.begin(), ord.end(), [&](int i, int j) {
        return a[i] < a[j];
    });
    REP(i, 0, n) {
        cout << ord[i] + 1 << " \n"[i + 1 == n];
    }
    return 0;
}


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

#define  BeatMeScanf  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  tc(x)        int x; cin >> x; while(x--)
#define  ll           long long
#define  vi           vector<int>
#define  pii          pair<int,int>
#define  mii          map<int,int>
#define  inf          1<<28
#define  mem(x,y)     memset(x, y, sizeof(x))
#define  ps(x,y)      fixed<<setprecision(y)<<x
#define  show(val)    cout<< #val << " -> " << val << endl
#define  Case         cout<< "Case "<< ++cs << ": "
#define  all(v)       (v).begin(), (v).end()
#define  rall(v)      (v).rbegin(), (v).rend()
#define  MOD          1000000007
#define  MAX          100005
#define  PI           3.14159265358979323846264338327950L

int main()
{
    BeatMeScanf;
    string s, t;
    cin >> s >> t;
    int sz = t.size()-1;

    t.erase(t.begin()+sz);

    if(s==t) cout << "Yes" << '\n';
    else cout << "No" << '\n';

    return 0;
}



Measured memory_bytes: 3624
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<complex>
#include<iomanip>

using namespace std;

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)
#define pi 3.14159265358979
#define ll long long

int main(void){

	int n;
	for(;;){

		cin >> n;
		if(n==0) break;

			if(n%3==0) n=n/3;

			double s=n*tan(pi/(3*n))/(1+sqrt(3.0)*tan(pi/(3*n)));

			printf("%.10f\n",s);

	}

	return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

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

    vector<ll> rui(n+1);  // rui[i+1] : a[i]までの和
    rep(i, n) {
        rui[i+1] = rui[i] + a[i];
    }
    sort(rui.begin(), rui.end());

    vector<ll> count(n+1);  // count[i] : ruiのi番目(iは0-index)に小さい数の個数
    ll t = rui[0];
    int k = 0;
    rep(i, n+1) {
        if(t < rui[i]) {
            t = rui[i];
            k++;
            count[k]++;
        } 
        else {
            count[k]++;
        }
    }

    ll ans = 0;
    rep(i, n+1) {
        ans += count[i]*(count[i] - 1)/2;
    }

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

Measured memory_bytes: 4992
import math
N = int(input())
ax = list(map(int,input().split()))

M = 0
boxin = []
bx = [0 for _ in range(N+1)]
for cnt in range(N, 0, -1):
    a = ax[cnt-1]
    tmp = 0
    for tmp_cnt in range(cnt*2, N+1, cnt):
        if bx[tmp_cnt] != 0:
            tmp += 1
    
    if tmp % 2 != a:
        bx[cnt] = 1
        boxin.append(cnt)

box = len(boxin)
print(box)
if box != 0:
    boxin.reverse()
    print(' '.join(map(str, boxin)))

Measured memory_bytes: 20224
N, K = map(int, input().split())
D = list(map(int, input().split()))
num = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
num = str(list(set(num) ^ set(D)))

ans = str(N)
clear = 0

while clear == 0:
    for i in range(len(ans)):
        if not ans[i] in num:
            break
        if i == len(ans) - 1:
            clear += 1  
    ans = str(int(ans) + 1)

print(int(ans) - 1)

Measured memory_bytes: 9008
#include<bits/stdc++.h>
using namespace std;
int n,m,q;
vector<int> a,b,c,d;
int MAX=0;
int dfs(vector<int> &A){
  if(A.size()==n){
    int sum=0;
    for(int i=0;i<q;i++){
      if(A[b[i]]-A[a[i]]==c[i]){
        sum+=d[i];
      }
    }
    return sum;
  }

  int last=(A.empty()?1 : A.back());
  for(int i=last;i<=m;i++){
    A.push_back(i);
    MAX=max(MAX,dfs(A));
    A.pop_back();
  }
  return MAX;
}






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

a=b=c=d=vector<int>(q);
for(int i=0;i<q;i++){
  cin>>a[i]>>b[i]>>c[i]>>d[i];
  a[i]--;
  b[i]--;
}
vector<int> A;
cout<<dfs(A)<<endl;
}

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



int sc1(){int x; scanf("%d",&x); return x;}

long long sc2(){long long x;scanf("%lld",&x);return x;}

#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  Int              sc1()
#define  LL               sc2()
#define  For(n)           for(int i=0;i<n;i++)
#define  Forj(n)          for(int j=0;j<n;j++)
#define  Fork(n)          for(int k=0;k<n;k++)
#define  For1(n)          for(int i=1;i<=n;i++)
#define  ll               long long
#define  vi               std::vector<int>
#define  vll              std::vector<ll>
#define  qui              qu
#define  pb               push_back
#define  mpsi             std::map<string, int>







int main()
{
	//freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
	int n=Int;
	double arr[n+1];

	For(n) cin>>arr[i];
	double ans=0;
	for(int i=0;i<n;i++)
	{
		ans+=(1.0/(double)arr[i]);
		// cout<<ans<<endl;
	}
	ans=1.0/ans;    
	cout<<fixed<<setprecision(7);
	cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>

using namespace std;

#define MOD 1000000007L
#define IMOD 1000000005L

void mul(int64_t& n, int64_t m) {
    n = (n * (m % MOD)) % MOD;
}

int64_t pow(int64_t n, int64_t p) {
    if (p == 0) {
        return 1;
    }
    if (p == 1) {
        return n;
    }

    int64_t r = pow(n, p/2);
    if (p % 2 == 0) {
        return r * r % MOD;
    } else {
        return (r * r % MOD) * n % MOD;
    }
}

void divide(int64_t& n, int64_t m) {
    if (n == 0) {
        return;
    }

    mul(n, pow(m, IMOD));
}

void add(int64_t& n, int64_t m) {
    n = (n + m) % MOD;
}

long solve(int32_t n) {
  vector<int> f(n + 1, 0);
  vector<bool> p(n, true);
  p[0] = false;
  p[1] = false;
  
  for (int32_t i = 2; i <= n/2; ++i) {
    if (!p[i]) {
      // not prime
      continue;
    }
    
    f[i] += 1;
    for (int32_t j = i + 1; j <= n; ++j) {
      int d = 0;
      int jj = j;
      while (jj % i == 0) {
        jj /= i;
        ++d;
      }
      f[i] += d;
      if (d > 0) {
        p[j] = false;
      }
    }
  }
  for (int32_t i = n/2 + 1; i <= n; ++i) {
    if (p[i]) {
      f[i] += 1;
    }
  }
  
  long ans = 1;
  for (auto ff : f) {
    mul(ans, ff + 1);
  }
  
  return ans;
}

int main() {
  int n;

  cin >> n;
  cout << solve(n) << endl;

  return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		
		out.println(180*(N-2));
		
		sc.close();

	}

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

}


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

long long comb(long long n, long long r) {
	if (n == r) {
		return 1;
	}

	return n * (n - 1) / 2;
}

int main()
{
	long long n;
	cin >> n;
	vector<long long> v(n);
	map<long long, long long> m;
	for (long long i = 0; i < n; ++i) {
		cin >> v[i];
		if (m.find(v[i]) == m.end()) {
			m[v[i]] = 1;
		}
		else {
			++m[v[i]];
		}
	}

	map<long long, long long> newm;
	long long sum = 0;
	for (auto& i : m) {
		if (2 <= i.second) {
			newm[i.first] = comb(i.second, 2);
			sum += newm[i.first];
		}
		else {
			newm[i.first] = 0;
		}
	}

	if (sum != 0) {
		for (auto& a : v) {
			if (2 < m[a]) {
				cout << sum - newm[a] + comb(m[a] - 1, 2) << endl;
			}
			else {
				cout << sum - newm[a] << endl;
			}
		}
	}
	else {
		for (long long i = 0; i < n; ++i) {
			cout << 0 << endl;
		}
	}

	return 0;
}

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

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int n;
	cin >> n;
	int lis = 0;
	for(int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		if(x == lis + 1) lis += 1;
	}
	cout << (lis ? n - lis : -1) << '\n';
}


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

int main(){
  int N, M, X;
  cin >> N >> M >> X;
  int cl=0, cr=0;
  for(int i=0; i<M; i++){
    int A; cin >> A;
    if(A<X) cl++;
    if(A>X) cr++;
  }
  if(cl>cr){
    cout << cr << endl;
    return 0;
  }
  cout << cl << endl;
  return 0;
}

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

int main()
{
    int m, f, r;
    for(int i=0; ; i++){
        cin >> m >> f >> r;
        if(m==-1 && f==-1 && r==-1)  break;
        int a = m+f;
        if(a>=80) cout << 'A' << endl;
        else if(a>=65 && a<80) cout << 'B' << endl;
        else if(a>=50 && a<65) cout << 'C' << endl;
        else if(a>=30 && a<50 && r>=50) cout << 'C' << endl;
        else if(m==-1 || f==-1) cout << 'F' << endl;
        else if(a>=30 && a<50) cout << 'D' << endl;
        else if(a<30) cout << 'F' << endl;
    }
}

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main(void)
{
    int A, B, M, H;
    long double H_a, M_a, angle, ans; 

    scanf("%d", &A);
    scanf("%d", &B);
    scanf("%d", &H);
    scanf("%d", &M);

    H_a = M*0.5*(M_PI/180) + H*30*(M_PI/180);
    M_a = M*6.0 * (M_PI/180);

    angle = H_a - M_a;

    ans = sqrt(A*A + B*B - 2*A*B*cos(angle));

    printf("%.10Lf\n", ans);

    return 0;
}

Measured memory_bytes: 2664
import java.util.Scanner;

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

	private void solveA() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();

		int NA = N * A;

		if (NA > B) {
			System.out.println(B);
		} else {
			System.out.println(NA);
		}
	}

	private void solveB() {
		Scanner sc = new Scanner(System.in);

		String N = sc.nextLine();

		int iN = Integer.parseInt(N);

		String[] str = N.split("");

		int I = 0;
		for (int i = 0; i < str.length; i++) {
			int I2 = Integer.parseInt(str[i]);
			I += I2;
		}
		if (iN % I == 0) {
			System.out.println("Yes");
		} else if (iN % I != 0) {
			System.out.println("No");
		}

	}

	private void solveC() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();

		int NX = N * X;
		int NKY = (N - K) * Y;

		if (N <= K) {
			System.out.println(NX);
		} else {
			System.out.println(K * X + (N - K) * Y);
		}
	}

	private void solveD() {
		Scanner sc = new Scanner(System.in);

		String W = sc.nextLine();
		String[] str = W.split("");

		String word = "abcdefghijklmnopqrstuvwxyz";
		String[] w = word.split("");

		int math = 0;

		for (int i = 0; i < w.length; i++) {
			for (int j = 0; j < str.length; j++) {
				if (w[i].equals(str[j])) {
					math++;
				}
			}
			if (math % 2 != 0) {
				break;
			}
		}
		if (math % 2 == 0) {
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

	}

	private void solveE() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveF() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

}

Measured memory_bytes: 20692
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
lst1 = list(map(int,readline().split()))
ans = 10**9
for i in lst1:
    res = 0
    while True:
        if i%2 == 0:
            i //= 2
            res += 1
        else:
            ans = min(ans,res)
            break

print(ans)



Measured memory_bytes: 38512
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
 }
int main(){
  int n, ans;
  cin >> n;
  vector<int> a(n), b(n);
  for(int i=0; i<n; i++)
    cin >> a[i] >> b[i];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if(n%2==1)
    cout << (b[n/2]-a[n/2])+1;
  else
    cout << (b[n/2]+b[n/2-1]-a[n/2]-a[n/2-1])+1;
  return 0;
}

Measured memory_bytes: 4916
class PriorityQueue
  def initialize(&comp)
    @heap = []
    @node_num = 0
    if !block_given?
      @comp = lambda { |x, y| x <= y }
    else
      @comp = comp
    end
  end

  def push(x)
    i = @node_num # 自分のノード番号
    @node_num += 1
    while i > 0
      par = (i - 1) / 2 # 親のノード番号
      break if @comp.call(@heap[par], x) # 逆転してないなら抜ける
      # 親ノードを下ろして自分を上に
      @heap[i] = @heap[par]
      i = par
    end
    @heap[i] = x
  end

  alias_method(:<<, :push)

  def pop
    # 最(小|大)値
    ret = @heap[0]
    # 根にもってくる値
    @node_num -= 1
    x = @heap[@node_num]
    # 根から下ろしていく
    i = 0
    while i * 2 + 1 < @node_num
      # 子どうしを比較
      a, b = i * 2 + 1, i * 2 + 2
      a = b if b < @node_num && !@comp.call(@heap[a], @heap[b])
      break if @comp.call(x, @heap[a])
      @heap[i] = @heap[a]
      i = a
    end
    @heap[i] = x
    return ret
  end

  def get
    @node_num == 0 ? nil : @heap[0]
  end

  def empty?
    return get.nil?
  end
end

n, m = gets.split.map(&:to_i)
jobs = Array.new(m) { [] }
n.times do
  a, b = gets.split.map(&:to_i)
  next if a > m
  jobs[m - a] << b
end

q = PriorityQueue.new { |x, y| x > y }
ans = 0
(m - 1).downto(0) do |i|
  jobs[i].each do |b|
    q << b
  end
  if !q.empty?
    ans += q.pop
  end
end

p ans


Measured memory_bytes: 12156
/*
** author:mahmoud magdy
*/
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl "\n"

inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m;
    cin>>m;
    return m;
}
void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

int main()
{
    fast();
    int n=D();
    set<int>st;
    for(int i=0;i<n;++i){
        st.insert(D());
    }
    if(st.size()==n)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 12980
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    while(n--){
        char a[1000] = {0};
        char b[1000] = {0};
        scanf("%s%s",a,b);
        int len_a = strlen(a),len_b = strlen(b);
        char ans[1000] = {0};
        reverse(a,a+len_a);
        reverse(b,b+len_b);
        for(int i = 0; i < max(len_a,len_b); i++){
            if(ans[i] != 0){
                if(a[i] == 0 || b[i] == 0)
                    ans[i] += a[i] + b[i] - '0';
                else ans[i] += a[i] + b[i] - '0' - '0';
            }
            else if(a[i] == 0 || b[i] == 0) ans[i] += a[i] + b[i];
            else ans[i] += a[i] + b[i] - '0';
            if(ans[i] >= 58){
                ans[i+1]+='1';
                ans[i] -= 10;
            }
        }
        int len_ans = strlen(ans);
        reverse(ans,ans+len_ans);
        if(len_ans > 80){
            printf("overflow\n");
            continue;
        }
        for(int i = 0; ans[i] != 0; i++) printf("%c",ans[i]);
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1012
// abc129_b
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
	int N;
	cin >> N;
	vector<int> vc(N);
	int sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> vc[i];
		sum += vc[i];
	}
	int min = sum;
	int tmp = vc[0];
	for (int i = 1; i < N - 1; i++) {
		tmp += vc[i];
		int sub = abs(tmp - (sum - tmp));
		if (min > sub) {
			min = sub;
		}
	}

	cout << min << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	as := make([]int, n)
	for i := range as {
		sc.Scan()
		as[i], _ = strconv.Atoi(sc.Text())
	}
	var bs int
	for i := 2; i < n; i++ {
		bs ^= as[i]
	}
	a, b := as[0], as[1]
	if a+b < bs || (a+b-bs)%2 == 1 {
		fmt.Println(-1)
		return
	}
	base := (a + b - bs) / 2
	for i := 0; i <= 50; i++ {
		k := base & (1 << uint(i))
		if k > 0 {
			if bs&(1<<uint(i)) > 0 {
				fmt.Println("-1")
				return
			}
		}
	}
	for base < b {
		var sk int
		for i := 0; i <= 50; i++ {
			k := bs & (1 << uint(i))
			if k > 0 {
				sk += k
			}
			if base+sk >= b {
				base += k
				break
			}
		}
		if base+sk < b {
			fmt.Println(-1)
			return
		}
	}
	ans := base - b
	if ans >= 0 && ans < a {
		fmt.Println(ans)
	} else {
		fmt.Println(-1)
	}
}

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

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1848
#include<bits/stdc++.h>
#define debug puts("&&&&&&&&")
#define read(x) scanf("%lld",&x)
using namespace std;
typedef long long LL;
const int maxn=1e6+5;
const int maxx=1e10+2;
LL a[maxn];
LL b[maxn];
LL n;
map<LL,int>ma;
LL sqr(LL a) {
    return a*a;
}
int main() {
    while(cin>>n) {
        ma.clear();
        for(LL i=1;i<=n;i++) {
            LL t;
            cin>>t;
            for(LL j=2;j*j*j<=t;j++) {
                while(t%(j*j*j)==0) {
                    t/=(j*j*j);
                }
            }
            ma[t]++;a[i]=t;
            LL ans=1;
           for (LL j=2;j*j*j<=t;j++)
            if (t%j==0)
            {
                ans*=(t%(j*j)==0)?j:j*j;
                while (t%j==0) t/=j;
            }
            if (sqr((LL)sqrt(t))==t) ans*=(LL)sqrt(t);
            else ans*=t*t;
            b[i]=ans;
        }
        LL ans1=0;
        if(ma[1]){
            ans1++;
            ma[1]=0;}
        for(int i=1;i<=n;i++) {
            ans1+=max(ma[a[i]],ma[b[i]]);
            ma[a[i]]=ma[b[i]]=0;
        }
        cout<<ans1<<endl;
    }
    return 0;
}


Measured memory_bytes: 17664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1e9+7;
#define w(x) int x;cin>>x;while(x--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vll vector<ll>
#define ppi pair<Sint,int>
#define ppl pair<ll,ll>
#define F first
#define S second 
#define LB lower_bound
#define UB upper_bound
#define mset multiset
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll binpow(ll x, ll y, ll p){  ll res = 1;x = x % p;if (x == 0)return 0;while (y > 0)  { if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p;}return res;}  
ll gcd(ll a, ll b){ if (b == 0) return a; return gcd(b, a % b); } 
bool parity(ll x,ll y){ bool f = ((x ^ y) < 0);return !f;}

int N,W;
ll dp[101][100001];


ll knapsack(ll curr,ll weight,vll &v,vll &wt)
{

    if(weight<0)
        return -1e12;
    if(curr>=N)
        return 0;

    if(dp[curr][weight]!=-1)
        return dp[curr][weight];

    ll res1=knapsack(curr+1,weight-wt[curr],v,wt)+v[curr];

    ll res2=knapsack(curr+1,weight,v,wt);

    if(res1>res2)
        dp[curr][weight]=res1;
    else
        dp[curr][weight]=res2;
    
    return dp[curr][weight];
}

int main()
{
    IOS

    cin>>N>>W;
    
    for(int i=0;i<=100;i++)
        for(int j=0;j<=100000;j++)
            dp[i][j]=-1;

    vll wt(N);
    vll v(N);

    for(int i=0;i<N;i++)
        cin>>wt[i]>>v[i];
    
    cout<<knapsack(0,W,v,wt);
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  VI a(N);
  rep(i, N) { cin >> a.at(i); }
  if (N == 2) {
    cout << max(a.at(0), a.at(1)) << endl;
    return 0;
  }
  ll maxi = max(max(a.at(0), a.at(1)), a.at(2));
  ll left = a.at(0);
  ll emax = max(a.at(0), a.at(1));
  for (int i = 4; i < N + 1; i++) {
    if (i % 2 == 0) {
      left += a.at(i - 2);
      emax = max(emax + a.at(i - 1), left);
    } else {
      maxi = max(emax, maxi + a.at(i - 1));
    }
  }
  if (N % 2 == 0) {
    cout << emax << endl;
  } else {
    cout << maxi << endl;
  }
  return 0;
}


Measured memory_bytes: 4844
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;

template<class T>
void in(vector<T>& V) {
	for (auto itr = V.begin(); itr != V.end(); itr++)cin >> *itr;
	return;
}

template<class T>
void out(vector<T>& V) {
	for (T& itr : V)cout << itr << endl;
	return;
}

int N;
string S;

int main(){
	cin >> N >> S;
	vector<vector<bool>> DP1;
	DP1.resize(N + 2, vector<bool>(26, false));
	for (int n = 1; n <= N; n++) {
		for (int c = 0; c < 26; c++) {
			DP1[n][c] = DP1[n - 1][c] | (S[n-1]-'a' == c);
		}
	}
	vector<vector<bool>> DP2;
	DP2.resize(N + 2, vector<bool>(26, false));
	for (int n = N; n >= 1; n--) {
		for (int c = 0; c < 26; c++) {
			DP2[n][c] = DP2[n + 1][c] | (S[n-1]-'a' == c);
		}
	}
	int ans = 0;
	for (int n = 1; n < N; n++) {
		int temp = 0;
		for (int c = 0; c < 26; c++) {
			if (DP1[n][c] && DP2[n + 1][c])temp++;
		}
		ans = max(ans, temp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/*
https://atcoder.jp/contests/dp/tasks/dp_d
*/

#include <iostream>

using namespace std;

long long int dp[100000000];


long long int knapsack(long long int* w,long long int* v, int N ,long long int W){
	
	for(int i=0;i<N;i++){
		for(long long int j = W;j>=0;j--){
			if(w[i]<=j) 
				dp[j] = max(dp[j],v[i]+dp[j-w[i]]);
		}
	}

	return dp[W];
}


int main(){

	int N;
	long long int W;

	cin >> N >> W;

	long long int w[N];
	long long int v[N];

	for(int i=0;i<N;i++){
		cin >> w[i] >> v[i];
	}
	
	
	cout << knapsack(w,v,N,W) << endl;


	return 0;
}	


Measured memory_bytes: 4360
#include<stdio.h>
#include<iostream>
using namespace std;
int a,b,n,s;
int main(int argc, char* argv[])
{
    cin>>n;
    int flag=1;
    while(n--)
    {
        cin>>s>>a>>b;
        int mi=a+b;
        if(s<mi) flag=0;
        else if(s==mi) continue;
        else
        {
            if((s-mi)%2) flag=0;
        }
    }
    if(flag) printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    vector<string> d = {"Sunny", "Cloudy", "Rainy"};
    string s;
    cin >> s;
    for (int i = 0; i < 3; ++i) if (s == d.at(i)) cout << d.at((i + 1) % 3) << '\n';
    return 0;
}


Measured memory_bytes: 256