akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 200007;

int gettwos(int n){
    int x = 0; 
    while(n){ 
        n /= 2; 
        x += n; 
    } 
    return x; 
}

int getfives(int n){
    int x = 0; 
    while(n){ 
        n /= 5; 
        x += (n/2); 
    } 
    return x; 
}

signed main(){
    int n;
    cin>>n;
    if(n & 1){
        cout<<0<<endl;
        return 0;
    }
    cout<<min(gettwos(n), getfives(n))<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int cmp(const void *a,const void *b){
  return *(int*)b - *(int*)a;
}

int main(void){
  int n,k,i,ans=0;
  scanf("%d %d",&n,&k);
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  qsort(a,n,sizeof(int),cmp);
  for(i=0;i<k;i++){
    ans+=a[i];
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
def main():
    n = int(input())
    a_lst = [int(input()) for _ in range(n)]

    left = [0 for _ in range(n)]
    right = [0 for _ in range(n)]

    biggest = 0
    for i in range(n):
        if biggest < a_lst[i]:
            biggest = a_lst[i]
        left[i] = biggest

    biggest = 0
    for i in range(n - 1, -1, -1):
        if biggest < a_lst[i]:
            biggest = a_lst[i]
        right[i] = biggest

    print(right[1])
    for i in range(1, n - 1):
        print(max(left[i - 1], right[i + 1]))
    print(left[-2])


if __name__ == "__main__":
    main()


Measured memory_bytes: 114456
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;cin>>n;
    string s;cin>>s;
    string t=s.substr(n,n);reverse(all(t));
    s=s.substr(0,n);
    //cout<<s<<" "<<t<<endl;
    map<pair<string,string>,ll> a,b;
    rep(i,1<<n){
        bitset<20> tmp(i);
        string x,y,w,z;
        rep(j,n){
            if(tmp[j]){
                x+=s[j];
                w+=t[j];
            }
            else{
                y+=s[j];
                z+=t[j];
            }
        }
        a[mp(x,y)]++;
        b[mp(w,z)]++;
    }
    ll ans=(ll)0;
    for(auto c=a.begin();c!=a.end();c++){
        auto p=c->first;
        ans+=(c->second)*b[mp(p.second,p.first)];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 89580
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#H, W = map(int, input().split())
#S = list(map(int, input().split()))
N = int(input())
a = []
a.append(0)
for _ in range(N) :
  a.append(int(input()))
#print (a)

index = 1
cnt = 0
for i in range(N) :
  index = a[index]
  cnt += 1
  if index == 2 :
    print (cnt)
    exit()
print(-1)


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

int isPrime(int num) {
	if (num <= 1) return 0;
	for (int i = 2; i < num; i++) {
		if (num%i == 0) return 0;
	}
	return 1;
}

int main() {
	int q, l, r;
	int sum[100010] = { 0 };
	for (int i = 1; i <= 100000; i++) {
		sum[i] = sum[i - 1] + (isPrime(i) && isPrime((i + 1) / 2));
	}
	cin >> q;
	rep(i, q) {
		cin >> l >> r;
		cout << sum[r] - sum[l - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 4004
#include <stdio.h>  /* printf, scanf */
#include  <stdbool.h>   /* bool */

#define MIN_LEN 1
#define MAX_LEN 100

static void Read(int* a, int* b);
static void CalcArea(int a, int b, int* res);
static void CalcPerimeter(int a, int b, int* res);
static void Write(int area, int perimeter);
static bool RangeCheck(int a, int b);

int main()
{
    int a = 0, b = 0;
    int area = 0, perimeter = 0;

    Read(&a, &b);

    if (!RangeCheck(a, b)) {
        return -1;
    }

    CalcArea(a, b, &area);

    CalcPerimeter(a, b, &perimeter);

    Write(area, perimeter);

    return 0;
}

void Read(int* a, int* b)
{
    scanf("%d %d", a, b);
}

void CalcArea(int a, int b, int* res)
{
    *res = a * b;
}

void CalcPerimeter(int a, int b, int* res)
{
    *res = a * 2 + b * 2;
}

void Write(int area, int perimeter)
{
    printf("%d %d\n", area, perimeter);
}

bool RangeCheck(int a, int b)
{
    bool ret = true;

    if ((MIN_LEN > a) || (MAX_LEN < a)) {
        ret = false;
    }

    if ((MIN_LEN > b) || (MAX_LEN < b)) {
        ret = false;
    }

    return ret;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" );
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const ll INF = 1e9+9, LINF = 1e18;


int main()
{
    ll n,m[5]={0};
    cin>>n;
    
    rep(i,n){
        string s;
        cin>>s;
        m[0]+=(s[0]=='M');
        m[1]+=(s[0]=='A');
        m[2]+=(s[0]=='R');
        m[3]+=(s[0]=='C');
        m[4]+=(s[0]=='H');
    }
    n=0;
    for(int i=0;i<3;i++)for(int j=i+1;j<4;j++)for(int k=j+1;k<5;k++)n+=m[i]*m[j]*m[k];
    cout<<n<<endl;
    return 0;
}


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

using namespace std;

typedef long long Long;

const int MOD = round(1e9 + 7);

int getFact(int x) {
  if (x == 0) return 1;
  return 1LL * x * getFact(x - 1) % MOD;
}

int main() {
  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);

#ifdef Local
  freopen("test.in", "r", stdin);
#endif

  int a, b;
  cin >> a >> b;

  int fa = getFact(a);
  int fb = getFact(b);

  Long c = 0;

  if (abs(a - b) <= 1) {
    c = (abs(a - b) == 0 ? 2 : 1);
  }

  cout << c * fa * fb % MOD;

}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
#define PI 3.14159265
#define INF 2147483647
using namespace std;
using ll = long long;
void self_max(int &a,int b){
	a = max(a,b);
}
void self_min(int &a,int b){
	a = min(a,b);
}

int n;
vector<int> to[100005];
std::vector<int> dist;

void dfs(int v, int d = 0, int p = -1){
	dist[v] = d;
	for(int u: to[v]){
		if(u == p) continue;
		dfs(u,d+1,v);
	}
}


vector<int> calDistance(int P){
	dist = vector<int> (n);
	dfs(P);
	return dist;
}



int main(){
	cin >> n;
	int T,A; cin >> T >> A;
	--T; --A;

	// buh tseguudee to array ruu hiine
	rep(i,n-1){
		int a,b; cin >> a >> b;
		--a;
		--b;
		to[a].push_back(b);
		to[b].push_back(a);
	}

	vector<int> distFromA = calDistance(A);
	vector<int> distFromT = calDistance(T);
	int ret = 0;
	rep(i,n){
		if(distFromT[i] < distFromA[i]){
			self_max(ret,distFromA[i]);
		}
	}

	int ans = ret - 1;

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

Measured memory_bytes: 10752
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  
  if (k % 2){
    cout << b - a << endl;
  }
  else
    cout << a - b << endl;

  return 0;
}


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

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

int main()
{
    string s;
    cin >> s;
    if( s == "ABC")
    {
        cout << "ARC" << endl;
    }
    else{
        cout << "ABC" << endl;
    }
    return 0;

}



Measured memory_bytes: 3624
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
A = LI()
B = LI()

ans = 0

right = 0
for i in range(N):
    left = min(A[i]-right,B[i])
    ans += left
    right = min((B[i]-left),A[i+1])
    ans += right

print(ans)


Measured memory_bytes: 21020
#include<stdio.h>
#include<string.h>

int main(void){
    int n,i,j,len1;
    char s[101][11];
    scanf("%d",&n);
    scanf("%s",s[0]);
    for(i=1;i<n;i++){
        scanf("%s",s[i]);
        len1=strlen(s[i-1]);
        if(s[i-1][len1-1]!=s[i][0]){   //
            //printf("%c %c\n",s[i-1][len1-1],s[i][0]);
            printf("No\n");
            return 0;
        }
        for(j=0;j<i;j++){
            if(strcmp(s[j],s[i])==0){
                printf("No\n");
                return 0;
            }
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int main() {
	int a, b, c,sum=0;
	cin >> a >> b >> c;
	for (int i = 0; i < c; i++) {
		if ((i + 1)% a==0) {
			sum += b;
		}
	}
	cout << sum << endl;
}

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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[], int n) {
	for (int i = 0; i < n; i++) {
		cout << a[i] << " ";
	}
	cout << endl;
}
int no = 1, n1;
int recu(int n, int k, int val) {


	if (n == n1) {
		return min(val * 2, val + k);
	}
	return min( recu(n + 1, k, 2 * val), recu(n + 1, k, val + k)              );


}
int digit(int n) {

	int temp = 0;
	while (n) {
		// temp += n % 10;
		n = n / 10;
		temp++;
	}



	return temp;
}

bool check(int a[], int n) {
	for (int i = 0; i < n; ++i)
	{
		/* code */
		if (a[i] % 2)
			return false;
	}
	return true;
}
bool ispalin(int n){


	string  str =to_string(n);
	// cout<<str<<endl;


	for (int i = 0; i < str.size()/2; ++i)
	{
		/* code */
		// watch2(str[i],str[str.size()-i-1]);
		if(str[i]!=str[str.size()-i-1]){
			return false;
		}
	}


	return true;


}

int main() {
	int i,  n, m,k, c = 0, sum = 0;
	c_p_c();
	// cout<<"Sd"<<endl;>
		cin>>n>>m>>k;
		int l = n+k;
		int r= m-k;
		for (int i = n; i <=m; ++i)
		{
			/* code */
			if(i<l || i>r)
				cout<<i<<endl;
		}


}

Measured memory_bytes: 3624
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    return

#B
def B():
    n,X = LI()
    x = LI()
    for i in range(n-1):
        x[i+1] += x[i]
    x.insert(0,0)
    ans = float("inf")
    f = [5]*(n+1)
    for i in range(1,n):
        f[i+1] = f[i]+2
    for k in range(1,n+1):
        i = 0
        a = n
        d = (k+n)*X
        while a > 0:
            d += f[i]*(x[a]-x[max(0,a-k)])
            a -= k
            i += 1
        ans = min(ans,d)
    print(ans)
#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    B()


Measured memory_bytes: 26208
#include<iostream>
using namespace std;
int main(){
    int n, b, r, f, v, a[4][3][10]={};
    cin>>n;
    for (int i=0;i<n;i++){
        cin>>b>>r>>f>>v;
        a[b-1][r-1][f-1] += v;
    }
    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                cout<<" ";
                cout<<a[i][j][k];
            }cout<<endl;
        }if(i<3)cout<<"####################"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3076
n,a,b = map(int, input().split())
x = list(map(int, input().split()))

dp=[0]*n

for i in range(1,n):
    prev=x[i-1]
    nxt =x[i]
    walk = a*(nxt-prev)
    tele = b

    if walk > tele:
        dp[i] = dp[i-1] + tele
    else:
        dp[i] = dp[i-1] + walk

print(dp[n-1])

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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, w; cin >> n >> w;
	vector <pair<int,int>> items(n); //weight, value
	vector <long long int> dp(w+1);
	for (int i = 0; i < n; ++i) cin >> items[i].first >> items[i].second;	
	for (int j = 0; j < n; ++j){
		for (int i = w; i >= 0; --i){
			if (i - items[j].first >= 0) dp[i] = max(dp[i],dp[i - items[j].first] + items[j].second);
		}
	}	
//	for (int i = 0; i <= w; ++i) cout << dp[i] << " \n"[i == w];
	cout <<  *max_element(dp.begin(),dp.end())<< "\n";		
	return 0;
}


Measured memory_bytes: 3960
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

S = one_str()

w_list = [ "dream", "dreamer", "erase", "eraser" ]

flg=True
while len(S) != 0:
    if S[-7:] =="dreamer":
        S = S[:-7]
        continue

    elif S[-6:] =="eraser":
        S = S[:-6]
        continue

    elif S[-5:] =="dream" or S[-5:] =="erase":
        S = S[:-5]
        continue
    
    flg = False
    break


if flg:
    print("YES")
else:
    print("NO")



Measured memory_bytes: 133876
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
const int N = 1e5;
int f(string s){
	int n = s.size();
	for(int i=0 ; i<n/2 ; i++)
		if(s[i]!=s[n-i-1])return 0;
	n = (n-1)/2;
	for(int i=0 ; i<n/2 ; i++)
		if(s[i]!=s[n-i-1])return 0;

	return 1;
}

int main() {
	// ios_base::sync_with_stdio(false);
 //  cin.tie(NULL);
 //  cout.tie(NULL);
	int n,m;
	string s;
  while(cin >> n){
  	int ans = 0;
  	for(int i=1 ; i<=n;i++){
  		for(int j=1 ; j<=n ; j++){
  			int k = n-(i+j);
  			if(i+j+k==n)ans = max(ans,i*j*k);
  		}
  	}
  	double x = (n*1.0)/3;
  	double y = n-2*x;
  	// cout << x <<' '  <<y << endl;
  	// printf("%.6f %.6f\n",ans*1.0,x*x*y );
  	printf("%.6f\n", max(ans*1.0,x*x*y));
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int  n, ans;
map<int, int> m; 
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n;
    rep(i, 0, n) {
        int x; cin >> x;
        m[x]++;
    }
    for(auto t : m) {
        if (t.second < t.first) ans += t.second;
        else ans += t.second - t.first;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <queue>

using namespace std;

int main() {
    long long n, k, *v; cin >> n >> k;
    v = new long long[n];
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }

    long long ans = 0;
    for (int a = 0; a <= min(k, n); a++) {
        for (int b = 0; b <= min(k, n)-a; b++) {
            priority_queue<long long, vector<long long>, greater<long long> > pque;
            int c = k - a - b;
            long long s = 0;
            for (int i = 0; i < a; i++) {
                pque.push(v[i]);
                s += v[i];
            }
            for (int i = 0; i < b; i++) {
                pque.push(v[n-1-i]);
                s += v[n-1-i];
            }
            
            while (!pque.empty() && pque.top() < 0 && c > 0) {
                long long u = pque.top();
                pque.pop();
                s -= u;
                c--;
            }

            ans = max(ans, s);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,mini,count=0;;
  int a[100];
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  for(int i=0; i<n; i++){
    mini = i;
    for(int j=i; j<n; j++){
      if(a[j] < a[mini]) mini = j;
      //cout << a[mini] <<  " ";
    }
    //cout << endl;
    if(a[i]>a[mini]){
      swap(a[i],a[mini]);
      count++;
    }
  }
  for(int i=0; i<n; i++){
    if(i>0) cout << " " << a[i];
    else cout << a[i];
  }
  cout << endl;
  cout << count << endl;
  return 0;
}



Measured memory_bytes: 3068
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>


using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 

long long int N,M,K,l[200030],r[200300],res=0;
string str;


int main()
{
    cout << fixed << setprecision(18);
    cin>>N;
    for(long long int i = 0; i < N; i++){
        cin>>l[i];
    }
    l[N]=0;
    for(long long int i = 1; i <= N; i++){
        res+=max(l[i-1]-l[i],0LL);
    }
    cout<<res<<endl;
    
}    


Measured memory_bytes: 256
//Author: Pakhomovee 
#include <iostream> 
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <deque>
#include <iomanip>
#include <queue>

using namespace std;
using namespace std::chrono;

#define int long long

void solve()
{
	int n;
	cin >> n;
	int d;
	cin >> d;
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		int x, y;
		cin >> x >> y;
		if (x * x + y * y <= d * d)
		{
			++ans;
		}
	}
	cout << ans << endl;
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	auto start = system_clock::now();

	solve();

	auto end = system_clock::now();
	cerr << "Time: " << duration_cast<milliseconds> (end - start).count() << "ms" << endl;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> A(3);
  cin >> A.at(0) >> A.at(1) >> A.at(2);
  int max = 0;
  int key = 0;
  if(A.at(0) > A.at(1) && A.at(0) > A.at(2)){
    max = A.at(0);
    key = 0;
  }
  else if(A.at(1) > A.at(2) && A.at(1) > A.at(0)){
    max = A.at(1);
    key = 1;
  }
  else{
    max = A.at(2);
    key = 2;
  }
  int d;
  cin >> d;
  for(int i = 0;i<d;i++)
    max *= 2;
  A.at(key) = max;
  int www = 0;
  for(int i = 0;i<3;i++)
    www += A.at(i);
  cout << www << endl;
}
  

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

int main(void){
        int i,j,n,m;
        string input;
        bool door = true, user_search;

        cin >> n;
        vector<string> id(n);
        for(i = 0; i < n; i++){
                cin >> id[i];
        }   

        cin >> m;
        for(i = 0; i < m; i++){
                user_search = false;
                cin >> input;
                for(j = 0; j < n; j++){
                        if(input == id[j]){
                                if(door){
                                        cout << "Opened by " << input << endl;
                                        door = !door;
                                }else{
                                        cout << "Closed by " << input << endl;
                                        door = !door;
                                }   
                                user_search = true;
                        }   
                }   
                if(!user_search){
                        cout << "Unknown " << input << endl;
                }   
        }   
        return 0;
}

Measured memory_bytes: 3248
#include <iostream>

using namespace std;
int main()
{
  int n, k, d[110], a[110][110], scnt = 0;
  bool sok[110];
  cin >> n >> k;

  for (int i = 0; i < n; i++)
  {
    sok[i] = false;
  }

  for (int i = 0; i < k; i++)
  {
    cin >> d[i];
    for (int j = 0; j < d[i]; j++)
    {
      cin >> a[i][j];
      sok[a[i][j] - 1] = true;
    }
  }

  for (int i = 0; i < n; i++)
  {
    if (!sok[i]) scnt++;
  }

  cout << scnt << endl;
  return 0;
}


Measured memory_bytes: 3616
// -*- coding:utf-8-unix -*-

use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        h: isize,
        w: isize,
        mut c: [Chars; h as usize],
    }

    for i in 0..h {
        for j in 0..w {
            if c[i as usize][j as usize] != '.' {
                continue;
            }

            let mut bomb = 0;
            for hd in -1..2 {
                let hc = i + hd;
                if hc < 0 || hc >= h {
                    continue;
                }

                for wd in -1..2 {
                    let wc = j + wd;
                    if wc < 0 || wc >= w {
                        continue;
                    }

                    if c[hc as usize][wc as usize] == '#' {
                        bomb += 1;
                    }
                }
            }
            c[i as usize][j as usize] = std::char::from_digit(bomb, 10).unwrap();
        }
    }

    for i in 0..h {
        for j in 0..w {
            print!("{}", c[i as usize][j as usize]);
        }
        println!();
    }
}


Measured memory_bytes: 2172
#include <iostream>

using namespace std;

int main() {
	int A, B, C, K;

	cin >> A >> B >> C >> K;

	int max;

	if (K <= A) {
		max = K;
	}
	else if (K <= A + B) {
		max = A;
	}
	else {
		max = 2 * A + B - K;
	}

	cout << max;

	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main() {
	int N, K, X, Y;
	cin >> N >> K >> X >> Y;
	if (N > K) cout << K * X + (N - K) * Y << endl;
	else cout << N * X << endl;
	return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>

int main (){
	int a;
	int cek=0;
	scanf("%d", &a);
	for (int i=0; i<3; i++){
		if (a%10==7|| a/100==7|| (a-(a/100)*100)/10 ==7){
			cek++;
		}
	}
	if (cek>0){
		printf("Yes");
	}
	else {
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 1728
s = int(input())
a = [s]
for i in range(10**6):
    if a[i]%2 == 0:
        a.append(a[i]//2)
    else:
        a.append(a[i]*3+1)
    if a[i+1] in a[0:i+1]:
        print(i+2)
        break


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

int n,ans,sum,fix;
int two[100],v[123456];

signed main(){
  two[0]=1;for(int i=1;i<100;i++)two[i]=two[i-1]*2;
  cin>>n;
  for(int i=0;i<n;i++)cin>>v[i];
  for(int i=0;i<n;i++)sum^=v[i];
  for(int i=0;i<n;i++)v[i]&=(~sum);
  for(int i=59;i>=0;i--){
    bool f=false;
    for(int j=fix;j<n&&!f;j++) if(v[j]&two[i]) f=true,swap(v[fix++],v[j]);
    if(f) for(int j=0;j<n;j++) if((v[j]&two[i])&&(j!=fix-1)) v[j]^=v[fix-1];
  }
  for(int i=0;i<n;i++)ans^=v[i];
  cout<<ans*2+sum<<endl;
}

/*
解説AC
maspyさんの記事がわかりやすかった
吐き出し方の気持ちを全く理解していなかったのでしっかり頑張ろう　オエ〜
*/


Measured memory_bytes: 1152
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  [s, w] <- getIntList
  if w >= s
    then putStrLn "unsafe"
    else putStrLn "safe"

Measured memory_bytes: 3736
#include<iostream>
#include<cstdio>
const int maxn=1e6;
using namespace std;
int n,q,ans;
struct node{
	int to,next;
}a[maxn];
int tot=0,head[maxn],size[maxn],tree[maxn],tag[maxn];
int id[maxn];
void add(int x,int y)
{
	a[++tot].to=y;
	a[tot].next=head[x];
	head[x]=tot;
}
int cnt=0;
int dfs(int x,int f)
{
	id[x]=++cnt;
	size[x]=1;
	for(int i=head[x];i;i=a[i].next)
	{
		int v=a[i].to;
		if(v!=f)
		{
			size[x]+=dfs(v,x);
		}
	}
	return size[x];
}
void pushdown(int rt,int l,int r)
{
	if(tag[rt]!=0)
	{
		tag[rt*2]+=tag[rt];
		tag[rt*2+1]+=tag[rt];
		int mid=(l+r)/2;
		tree[rt*2]+=(mid-l+1)*tag[rt];
		tree[rt*2+1]+=(r-mid)*tag[rt];
		tag[rt]=0; 
	}
}
void pushup(int rt)
{
	tree[rt]=tree[rt<<1]+tree[rt<<1|1];
}
void modify(int rt,int l,int r,int L,int R,int c)
{
	if(L>r||R<l) return;
	if(L<=l&&R>=r)
	{
		tag[rt]+=c;
		tree[rt]+=(r-l+1)*c;
		return;
	}
	pushdown(rt,l,r);
	int mid=(l+r)/2;
	modify(rt<<1,l,mid,L,R,c);
	modify(rt<<1|1,mid+1,r,L,R,c);
	pushup(rt);
}
void query2(int rt,int l,int r,int x)
{
	
	if(l==r)
	{
		ans=tree[rt];
		return;
	}
	if(tag[rt]) pushdown(rt,l,r);
	int mid=(l+r)>>1;
	if(x<=mid) query2(rt<<1,l,mid,x);
	if(x>=mid+1) query2(rt<<1|1,mid+1,r,x);
}
int main(){
	scanf("%d%d",&n,&q);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v);add(v,u);
	}
	dfs(1,0);
	for(int i=1;i<=q;i++)
	{
		int x,v;
		scanf("%d%d",&x,&v);
		modify(1,1,n,id[x],id[x]+size[x]-1,v);
	}
	for(int i=1;i<=n;i++)
	{
		query2(1,1,n,id[i]);
		printf("%d ",ans);
	}
	return 0;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

void func(long long N, std::vector<long long> A, std::vector<long long> B){

    priority_queue<pair<lli,lli>> q;

    REP(i,0,N){
        if(B[i]<A[i]){
            cout<<-1<<endl;
            return;
        }
        if(B[i] != A[i])q.push({B[i],i});
    }

    lli cnt = 0;
    while(q.size()){
        pair<lli,lli> top = q.top();
        q.pop();
        lli i = top.second;
        lli diff = B[(i+1)%N] + B[(i+N-1)%N];
        lli able = (B[i]-A[i])/(diff);
        if(able == 0){
            cout<<-1<<endl;
            return;
        }
        B[i] -= (able * diff);
        cnt += able;
        if(B[i] != A[i])q.push({B[i],i});
    }

    cout<<cnt<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&B[i]);
    }
    func(N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 10584
from sys import stdin

n = stdin.readline().rstrip()
ex_str = n[0]
for i,a_str in enumerate(str(n)):

    
    if(i>0 and ex_str==a_str):
        print("Bad")
        break
    elif(ex_str!=a_str and i == len(n)-1):
        print("Good")
    ex_str = a_str

Measured memory_bytes: 2940
using System;

public class Test
{
    public static void Main()
    {
    
        var i = 1;
        while (true)
        {
            int x,y;
            string[] str = Console.ReadLine().Split(' ');
            x = int.Parse(str[0]);
            y = int.Parse(str[1]);
            if (x == 0 && y == 0)
            {
               break;
            }

            if (x > y)
            {
                Console.WriteLine("{0} {1}", y, x);
            }
            if (x < y)
            {
                Console.WriteLine("{0} {1}", x, y);
            }

            if (x == y)
            {
                Console.WriteLine("{0} {1}", x, y);
            }

        }

    }
}


Measured memory_bytes: 15868
#include <bits/stdc++.h>
using namespace std;
int main() {
  int k,x;
  int low = -1000000, high = 1000000;
  cin >> k >> x;
  k--;
  int l = max(x - k, low);
  int h = min(x + k, high);
  for (int i = l; i <= h; i++) {
    if (i > l) cout << " ";
    cout << i;
  }
  cout << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int N = sc.nextInt();
        // スペース区切りの整数の入力
        int[] P=new int[N];
        int[] Pn=new int[N];
        for(int i=0;i<N;i++){
            P[i]=sc.nextInt()-1;
            Pn[P[i]]=i;
        }
        int maxSeq=0;
        int seqPoint=-1;
        int seqNum=0;
        for(int i=0;i<N;i++){
            if(seqPoint<Pn[i]){
                seqNum++;
                seqPoint=Pn[i];
            }else{
                if(seqNum>maxSeq){
                    maxSeq=seqNum;
                }
                seqNum=1;
                seqPoint=Pn[i];
            }
        }
        if(seqNum>maxSeq){
            maxSeq=seqNum;
        }
        System.out.println(N-maxSeq);


    }
}

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

const int N=1e5+5;
int n,m,v,p;
long long add;
int a[N],c[N];
pair<int,int> b[N];

bool check(int x){
//	printf("%d\n",x);
	long long lft=add;
	b[x]=make_pair(a[x]+m,n+1);
	for(int i=1;i<=n;i++) c[i]=m;
	for(int i=1;i<=n;i++) if(i!=x) b[i]=make_pair(a[i],i);
	for(int i=1;i<=n;i++) if(i!=x&&lft>0ll){
		if(b[i].first>b[x].first){
			long long dec=min(lft,1ll*c[i]);
			b[i].first+=dec;
			lft-=dec;
			c[i]-=dec;
		}else if(b[i].first<b[x].first){
			long long dec=min(min(lft,1ll*c[i]),1ll*b[x].first-b[i].first);
			b[i].first+=dec;
			lft-=dec;
			c[i]-=dec;
		}
	}
	for(int i=n;i>=1;i--) if(i!=x&&lft>0ll){
		long long dec=min(lft,1ll*c[i]);
		b[i].first+=c[i];
		lft-=c[i];
	}
	sort(b+1,b+1+n);
	reverse(b+1,b+1+n);
	for(int i=1;i<=p;i++) if(b[i].second==n+1) return true;
	return false;
}	

int main(){
	scanf("%d%d%d%d",&n,&m,&v,&p);
	for(int i=1;i<=n;i++) scanf("%d",a+i);
	sort(a+1,a+1+n);
	add=1ll*m*(v-1);
	int l=1,r=n;
	while(l<=r){
		int mid=(l+r)>>1;
		if(check(mid)) r=mid-1;
		else l=mid+1;
	}
	r++;	
	printf("%d\n",n-r+1);
	return 0;
}

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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int X, Y;
    cin >> X >> Y;
    cout << X + Y / 2;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int ans;
  cin >> s;
  if(s == "SUN"){
    ans = 7;
  }
  if(s == "MON"){
    ans = 6;
  }
  if(s == "TUE"){
    ans = 5;
  }
  if(s == "WED"){
    ans = 4;
  }
  if(s == "THU"){
    ans = 3;
  }
  if(s == "FRI"){
    ans = 2;
  }
  if(s == "SAT"){
    ans = 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] arr = new int[n];
            Map<Integer, Integer> countMap = new HashMap<>();
            long ans = 0;
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
                if (i == 0) {
                    countMap.put(i + arr[i], 1);
                    continue;
                }

                int key = i - arr[i];
                ans += countMap.getOrDefault(key, 0);
                countMap.put(i + arr[i], countMap.getOrDefault(i + arr[i], 0) + 1);
            }

            out.println(ans);
        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }

}

Measured memory_bytes: 67680
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<unordered_map>
#include<set>
#include<cmath>
#include<climits>
#include<random>
using namespace std;
 
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
const double eps = 1e-6;
 
/////////////////////////////////////////////
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
////////////////////////////////
 
#define int long long

void solve(){

	int n;
	cin>>n;
	int a[n][n];


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

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

	int nn = (1<<n);
	int dp[nn];
	memset(dp , 0 , sizeof dp);
	for(int i = 1 ; i <= nn ; ++i){

		vector<int> tmp;
		for(int j = 0 ; j < n ; ++j){

			if((1<<j)&i)
				tmp.pb(j);
		}

		for(int k = 0 ; k < tmp.size() ; ++k)
			for(int j = k + 1 ; j < tmp.size() ; ++j){

				dp[i] += a[tmp[k]][tmp[j]];
			}
	}

	for(int mask = 1 ; mask < nn ; ++mask){

		for(int i = mask ; i > 0 ; i= mask&(i-1)){

			dp[mask] = max(dp[mask] , dp[i] + dp[i^mask]);
		}
	}

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

signed main(){
 
    fast;
    int t = 1;
    //cin>>t;
   	for(int i = 1 ; i <= t ; ++i){

   		solve();
   	}
}


Measured memory_bytes: 768
using System;
class program
{
    public static void Main()
    {
        int i = 0, a, b, c;
        
        string[] x = Console.ReadLine().Split(' ');
        a = int.Parse(x[0]);
        b = int.Parse(x[1]);
        c = int.Parse(x[2]);
        while (a <= b)
        {
            if (c % a == 0)
            {
                i++;
               
            }
            a++; 
        }
        Console.WriteLine(i);
    }
}


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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    if(K == 0)
    {
        cout << N * N << endl;
        return 0;
    }
    ll answer = 0;
    for (int i = K + 1; i <= N; i++)
    {
        answer += (N / i) * (i - K);
        answer += max(0LL, (N % i) - K + 1);
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a < b){
            System.out.println("a < b");
        }else if (a > b){
            System.out.println("a > b");
        }else {
            System.out.println("a == b");
        }
    }
}



Measured memory_bytes: 26228
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] s = new String[n];
		for (int i = 0; i < n; i++) {
			s[i] = sc.next();
		}

		int[] result = new int['z' - 'a' + 1];
		Arrays.fill(result, Integer.MAX_VALUE);

		for (int i = 0; i < n; i++) {
			int[] count = new int['z' - 'a' + 1];
			Arrays.fill(count, 0);
			for (char c : s[i].toCharArray()) {
				count[c - 'a']++;
			}

			for (int j = 0; j < result.length; j++) {
				result[j] = Math.min(result[j], count[j]);
			}
		}

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < result.length; i++) {
			for (int j = 0; j < result[i]; j++) {
				sb.append((char) (i + 'a'));
			}
		}

		System.out.println(sb.toString());
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<int> b(30);
    int x = 0;
    for (int i = 0; i < n; i++) {
        int a;
        std::cin >> a;
        x ^= a;
        int t = __builtin_ctz(a);
        b[t]++;
    }

    int ret = 0;
    for (int i = 29; i >= 0; i--) {
        if ((1 << i) & x) {
            if (b[i]) {
                ret++;
                x ^= (1 << (i + 1)) - 1;
            } else {
                std::cout << -1 << std::endl;
                return 0;
            }
        }
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 256