akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

void solve(){
    i64 N,W;
    cin >> N >> W;
    vector<i64> w(N),v(N);
    rep(i,0,N) cin >> w[i] >> v[i];

    static i64 dp[100][101][400];
    dp[0][1][0]=v[0];
    rep(i,0,N-1){
        rep(j,0,i+2){
            rep(k,0,400){
                dp[i+1][j][k]=max(dp[i+1][j][k],dp[i][j][k]);
                if(k+w[i+1]-w[0]>=400) continue;
                dp[i+1][j+1][k+w[i+1]-w[0]]=max(dp[i+1][j+1][k+w[i+1]-w[0]],dp[i][j][k]+v[i+1]);
            }
        }
    }
    i64 ans=0;
    rep(i,0,N+1) rep(j,0,400) if(j+w[0]*i<=W) ans=max(ans,dp[N-1][i][j]);
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 29952
import java.util.Scanner;

class Main
{
  public static int calc(int a, String op, int b){
    if(op.equals("?")) return 0;
    else{
      if(op.equals("+")) System.out.println(a+b);
      else if(op.equals("-")) System.out.println(a-b);
      else if(op.equals("*")) System.out.println(a*b);
      else if(op.equals("/")) System.out.println(a/b);
      return 1;
    }
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a, b;
    String op;
    while(true){
      a  = sc.nextInt();
      op = sc.next();
      b = sc.nextInt();
      if(calc(a, op, b) == 0) break;
    }
  }
}

Measured memory_bytes: 26212
N = int(input())
L = list(map(int, input().split()))

count = 0
for i in range(N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[k] + L[i] > L[j]:
                    count += 1
print(count)

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

int main() {
  int n;
  cin >> n;
  int a[n], b[n];
  rep(i, n) cin >> a[i];
  int l = 0, r = n-1;
  rep(i, n) {
    if (i % 2) b[r--] = a[n-1-i];
    else b[l++] = a[n-1-i];
  }
  rep(i, n) cout << b[i] << " ";
  cout << endl;
  return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

string s;

void input(){
    cin >> s;
}

bool check(string a, char b){
    for(int i=0;i<a.size();i++){
        if(a[i] != b) return false;
    }
    return true;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    set<char> chars;
    for(int i=0;i<s.size();i++) chars.insert(s[i]);
    
    if(chars.size() == 1){
        cout << 0 << endl;
        return 0; // すべて同じ文字
    }

    int ans = INF;
    int cnt;
    for(auto key=chars.begin();key!=chars.end();key++){
        string tmp = s;
        bool flg = true; // すべての文字が同じでない -> true
        cnt = 1; // 必ず1回は縮める

        while(flg){
            string vacant;
            flg = false;
            for(int i=0;i<tmp.size()-1;i++){
                if(tmp[i] == *key || tmp[i+1] == *key){
                    vacant += *key;
                }
                else{
                    vacant += tmp[i];
                    flg = true; // 異なる文字が混じっているのでtrueにする
                }
            }

            if(flg){
                tmp = vacant;
                cnt++;
            }
        }

        ans = min(ans, cnt);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,k;
  cin >> n >> k;
  vector<bool>judge(n);
  for(int i=0;i<n;i++){
    judge.at(i)=true;
  }
  for(int i=0;i<k;i++){
    int d;
    cin >> d;
    for(int i=0;i<d;i++){
      int a;
      cin >> a;
      judge.at(a-1)=false;
    }
  }
  int cnt=0;
  for(int i=0;i<n;i++){
    if(judge.at(i)){
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3568
#include<stdio.h>

int main(void){

int N, K, i;
char s[50];


scanf("%d", &N);
scanf("%d", &K);

scanf("%s", s);

if(s[K-1] == 'A'){
    s[K-1] = 'a';
}
else if(s[K-1] == 'B'){
    s[K-1] = 'b';
}
else{
    s[K-1] = 'c';
}

printf("%s\n", s);

return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i <= (n); ++i)
#define rip(i,n) for (int i = 1; i <= (n); ++i)
using namespace std;
int main() {
	int n, d;
	int s = 0;
	int ans = 0;
	cin >> n >> d;
	s = 2 * d + 1;
	if (n % s == 0) {
		ans = n / s;
	}
	else {
		ans = n / s + 1;
	}
	cout << ans << endl;
	return 0;
	
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

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

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; }

const ll INF=(ll)1e19;
//const int INF=(1<<30);

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  cout << a*b/2 << endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sort(a) sort(all(a))
#define ff first
#define ss second
#define vi vector<int>
#define pii pair<int, int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define mod (int)1e9+7
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define repf(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
#define N 100005
int main()
{
	FAST
    int t=1;
    // cin>>t;
    while(t--)
    {
		int n;
		cin>>n;
		cout<<n+n*n+n*n*n;	
    }
    return 0;
} 


Measured memory_bytes: 3560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.Scanner;
import java.util.StringTokenizer;
 
public class Main {
	public static void main(String args[])throws IOException  {
 
	
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		
		int n=in.nextInt();
		char [] inputChars = Integer.toString(n).toCharArray();
		int count=0;
		for(int i= 0;i<inputChars.length;i++){
			if(inputChars[i] =='2')count++;
		}
		out.print(count);
		out.close();
	}
	
	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;
 
		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}
 
		public int nextInt() {
			return Integer.parseInt(nextString());
		}
 
		public long nextLong() {
			return Long.parseLong(nextString());
		}
 
		public double nextDouble() {
			return Double.parseDouble(nextString());
		}
 
		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}
 
		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}
 
		public int[] nextIntArray1Index(int n) {
			int[] res = new int[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextInt();
			}
			return res;
		}
 
		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}
 
		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}
 
		public long[] nextLongArray1Index(int n) {
			long[] res = new long[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextLong();
			}
			return res;
		}
 
		public double[] nextDoubleArray(int n) {
			double[] res = new double[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextDouble();
			}
			return res;
		}
 
		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}
 
	
}


Measured memory_bytes: 22484
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
int main() {
	int A, B;
	cin >> A >> B;
	if (B % A == 0) {
		cout << A + B << endl;
	}
	else {
		cout << B-A << endl;
	}
	return 0;
}

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

typedef long long ll;

const int maxn = 1e5+10;

int cor[maxn][14], qwq[maxn], qaq[maxn], c[maxn];

std::vector <int> pb[maxn];

int n, m, a, b, q;

void l(int v1, int deep, int dd)
{
    if(deep==-1)  return;
    if(cor[v1][deep] ) return;
    cor[v1][deep]=dd;
    for(int i =0;i<pb[v1].size();i++)
        l(pb[v1][i], deep-1, dd);
}

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

int main()
{
    n=read(), m=read();
    for(int i=1;i<=m;i++) a=read(), b=read(), pb[a].push_back(b), pb[b].push_back(a);
    for(int i=1;i<=n;i++) pb[i].push_back(i);
    q=read();
    for(int i=1;i<=q;i++) qwq[i]=read(), qaq[i] = read(), c[i] = read();
    for(int i=q;i>=1;i--)  l(qwq[i], qaq[i], c[i]);
    for(int i=1;i<=n;i++) std::cout<<cor[i][0]<<std::endl;
    return 0;
}

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

using namespace std;

int main() {
   ios_base::sync_with_stdio(false);
   int H, W;
   cin >> H >> W;
   vector<string> S(H);
   for (int i = 0; i < H; ++i) {
      cin >> S[i];
   }
   --H, --W;
   vector<int> A(W);
   int ans = max(H + 1, W + 1);
   for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
         A[j]++;
         if (S[i][j] ^ S[i][j + 1] ^ S[i + 1][j] ^ S[i + 1][j + 1]) {
            A[j] = 0;
         }
      }
      vector<int> L(W), R(W);
      vector<int> st;
      for (int j = 0; j < W; ++j) {
         while (st.size() && A[j] <= A[st.back()]) {
            st.pop_back();
         }
         L[j] = st.empty() ? 0 : st.back() + 1;
         st.emplace_back(j);
      }
      st.clear();
      for (int j = W - 1; j >= 0; --j) {
         while (st.size() && A[j] <= A[st.back()]) {
            st.pop_back();
         }
         R[j] = st.empty() ? W - 1 : st.back() - 1;
         st.emplace_back(j);
      }
      for (int j = 0; j < W; ++j) {
         ans = max(ans, (A[j] + 1) * (R[j] - L[j] + 2));
      }
   }
   cout << ans << "\n";
   return 0;
}


Measured memory_bytes: 4608
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(readLine())
    var n = scanner.nextInt()
    val digits = readLine()!!.split(" ")

    while (true) {
        val nstr = n.toString()
        if (digits.any { it in nstr }) {
            n++
            continue
        } else {
            print(nstr)
            break
        }
    }
}

Measured memory_bytes: 45708
#include <stdio.h>

int main()
{
	int i, N, A[200001];
	scanf("%d", &N);
	for (i = 2; i <= N; i++) scanf("%d", &(A[i]));
	
	int count[200001] = {};
	for (i = 2; i <= N; i++) count[A[i]]++;
	for (i = 1; i <= N; i++) printf("%d\n", count[i]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 3260
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
board = [a, b, c]

n = int(input())
l = [int(input()) for i in range(n)]

result = [[False] * 3, [False] * 3, [False] * 3]


for x in l:
  for i in range(3):
    for j in range(3):
      if x == board[i][j]:
        result[i][j] = True
        
ans = False

for i in result:
  if all(i):
    ans = True

for i in range(3):
  if result[0][i] and result[1][i] and result[2][i]:
    ans = True

if result[1][1]:
  if result[0][0] and result[2][2]:
    ans = True
  if result[0][2] and result[2][0]:
    ans = True

if ans:
  print('Yes')
else:
  print('No')




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

//FILE *in = freopen("input.txt", "r", stdin);

int n;
char data[100];

int mul[3][3] = {{0, 0, 0},{0, 1, 1},{0, 1, 2}};
int plu[3][3] = {{0, 1, 2},{1, 1, 2},{2, 2, 2}};

int P, Q, R;
int pos;

int back() {
	switch(data[pos++]) {
	case '0':
		return 0;
		break;
	case '1':
		return 1;
		break;
	case '2':
		return 2;
		break;
	case 'P':
		return P;
		break;
	case 'Q':
		return Q;
		break;
	case 'R':
		return R;
		break;
	case '-':
		return 2-back();
		break;
	case '(':
		int A = back();
		char c = data[pos++];
		if(c == ')')
			return A;
		int B = back();
		if(data[pos] == ')') {
			pos++;
			switch(c){
			case '*':
				return mul[A][B];
				break;
			case '+':
				return plu[A][B];
				break;
			default:
				printf("=_=;\n");
				break;
			}
		}
		else{
			printf("?_?\n");
		}
		break;
	}
	return -1;
}

void process() {
	int cnt = 0;
	for(P = 0; P <= 2; P++) {
		for(Q = 0; Q <= 2; Q++) {
			for(R = 0; R <= 2; R++) {
				pos = 0;
				int res = back();
				if(res == 2) {
					++cnt;
				}
			}
		}
	}
	printf("%d\n", cnt);
}

int main() {
	data[0] = '(';
	while(true){
		gets(data+1);
		n = strlen(data) + 1;
		data[n-1] = ')';
		data[n] = 0;
		if(data[1] == '.') break;
		process();
	}
	return 0;
}

Measured memory_bytes: 928
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main(void) {
	int n;
	cin >> n;
	int ans = 100000;
	for (int a = 1; a <= n / 2; a++) {
		int b = n - a;
		int t = a;
		int u = n - a;
		int sum_a = 0;
		int sum_b = 0;
		while (t > 0) {
			sum_a += t % 10;
			t /= 10;
		}
		while (u > 0) {
			sum_b += u % 10;
			u /= 10;
		}
		ans = min(ans, sum_a+sum_b);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]

correct = []
if N & 1:
    correct.append(0)
    for i in range(2, N//2 * 2 + 1, 2):
        correct.append(i)
        correct.append(i)
else:
    for i in range(1, N//2 * 2, 2):
        correct.append(i)
        correct.append(i)
if sorted(A) == correct:
    print(2 ** (N//2) % (int(1e9) + 7))
else:
    print(0)

Measured memory_bytes: 13880
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int a,b; cin>>a>>b;
    if(a>b) rep(i,0,a) cout<<b;
    else rep(i,0,b) cout<<a;
    cout<<endl;
}

Measured memory_bytes: 256
n = gets.to_i
nums = gets.chomp.split("").map(&:to_i)
array = Array.new(10) { Array.new }
nums.each_with_index do |num, index|
  array[num] << index
end

count = 0

0.upto(9) do |digit_1|
  0.upto(9) do |digit_2|
    0.upto(9) do |digit_3|
      if array[digit_1].empty?
        next
      else
        digit_1_index = array[digit_1].first
      end

      digit_2_index = array[digit_2].bsearch { |i| i > digit_1_index }
      next if !digit_2_index

      digit_3_index = array[digit_3].bsearch { |i| i > digit_2_index }
      next if !digit_3_index

      count += 1
    end
  end
end
puts count


Measured memory_bytes: 3836
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
 
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
 
#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
//#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
 
// mp::cpp_int
 
const int hell=1000000007;
const int MOD=1000000007;
const int MOD1=1000000007;
 
int power(int a,int b)
{
  if(b==0)return 1;
  if(b==1)return a%hell;
  int t=power(a,b/2);
  t*=t;
  t%=hell;
   if(b&1)
   {
       t*=a;
       t%=hell;
   }
   return t;
 
}
 
 /*
void EE(int a, int b, int& x, int& y)
{
    if(a%b == 0)
    {
        x=0;
        y=1;
        return;
    }
    EE(b,a%b,x,y);
    int temp = x;
    x = y;
    y = temp - y*(a/b);
}
*/
 
 
int inverse(int a)
{
   return power(a,hell-2);
}
 
 
int pw(int a,int b)
{
  int x=a;
  rep(i,1,b){
    a=a*x;
    }
  return a;
}
 
 
int gcd(int a,int b)
{   
  
  if(b==0)return a;
  return gcd(b-a%b,a%b);
}
int dig(int a)
{
  int sum=0;
  while(a!=0)
  {
    sum+=a%10;
    a/=10;
  }
  
} 

int fac[2010]={0};
void factorial()
{
  fac[0]=1;
  rep(i,1,2010)fac[i]=(i*fac[i-1])%hell;
}

int dp[2010][2010];

int solve()
{  
factorial();
int n,k;
cin>>n>>k;
int mn=min(k,n-k+1);

rep(i,1,2005)
{
   dp[i][0]=0;
   dp[i][1]=1;
   dp[i][i]=1;
  rep(j,2,i)
  {
         dp[i][j]=(dp[i-1][j-1]+dp[i-1][j])%hell;
  }
}



rep(i,1,mn+1)
{ 
  int ans1=fac[n-k+1];
   int ans2=fac[i]*fac[n-k+1-i];
   ans2%=hell;
   ans1*=inverse(ans2);
   ans1%=hell;
  int ans=(dp[k][i])%hell;
  ans*=ans1;
  ans%=hell;
  cout<<ans<<endl;
}
rep(i,mn+1,k+1)
{
  cout<<0<<endl;
}

  return 0;
}
 
 
signed main()
{  int t=1;
 
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   cin.exceptions(cin.failbit);                                                                    
 

 
//pri();
 
  clock_t time_req;
 
    // Without ung pow function
                                                                                                                   
 
  //cin>>t;
 
    int k=1;
   while(t--)
     {
      // cout<<"Case #"<<k<<":"<<" ";k++;
      solve();
      //cout<<endl;
     }
 
         time_req = clock() - time_req;
    //cout <<endl<< "Processor time taken is "
     // << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;
 
 
    return 0;
}

Measured memory_bytes: 30336
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <iomanip>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ls x<<1
#define rs x<<1|1
#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define fun function
#define vi vector<int>
#define lowbit(x) x&(-x)
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);

using namespace std;

const int INF = 0x3f3f3f3f;


int main() {
	IOS;
#ifdef xiaofan
	freopen("1.in","r",stdin);
	freopen("1.out","w",stdout);
#endif

	int a,b;
	cin>>a>>b;
	int cnt=0;
	while(a){
		a/=b;
		cnt++;
	}
	cout<<cnt<<endl;



	return 0;
}



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

int main(){
    int n,m;
    cin>>n>>m;
    int a[m],c[m];
    for(int i=0;i<m;i++){
        int b,t;
        cin>>a[i]>>b;
        int id=0;
        for(int j=0;j<b;j++){
            cin>>t;
            id^=(1<<(t-1));
        }
        c[i]=id;
    }
    int dp[1<<n];
    fill(dp,dp+(1<<n),INF);
    dp[0]=0;
    for(int i=0;i<m;i++){
        for(int j=(1<<n)-1;j>=0;j--){
            dp[j|c[i]]=min(dp[j|c[i]],dp[j]+a[i]);
        }
    }
    if(dp[(1<<n)-1]==INF)cout<<-1<<endl;
    else cout<<dp[(1<<n)-1]<<endl;
}


Measured memory_bytes: 256
def calculate(age, price):
  if age >= 13:
    return price
  elif age >= 6:
    return int(price / 2)
  else:
    return 0
  
  
import sys
 
a=0
b=0
is_arg_ok = False
try:
  num_list = input().split(' ')
  age = int(num_list[0])
  price = int(num_list[1])
  is_arg_ok = True
  
except:
  print('age,price must be numbers')
  sys.exit(1)

calculated_price = calculate(age, price)
print(calculated_price)
sys.exit(0)



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

 main()
{
  long long n,s,t,u,r;
  cin>>n;
  s = n/3;
  t = n/5;
  u = n/15;
  r = n*(n+1)/2 - s*(s+1)*3/2 - t*(t+1)*5/2 + u*(u+1)*15/2;
  cout<< r <<endl;
}
  

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

int dx[] = {0, -1, 1, 0};
int dy[] = {-1, 0, 0, 1};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    int res = 0;
    for( int i = 105; i <= n; i += 2 ) {
        int cnt = 0;

        for( int j = 1; j <= i; ++j ) {
            if( !( i % j ) ) ++cnt;
            
        }
        if( cnt == 8 ) ++res;
    }

    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;
int main(){
  int n,x,t; cin >> n >> x >> t;
  int takoyaki = n/x;
  if(n%x!=0) takoyaki++;
  cout << t*takoyaki << endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N;
int main(){
  cin >> N;
  int t = sqrt(N);
  cout << t * t << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,i,flag[30][2]={},cnt,max=0,j;
  char s[110];
  scanf("%d",&n);
  scanf("%s",s);
  for(i=1;i<n-1;i++){
    for(j=0;j<30;j++)
      flag[j][0]=flag[j][1]=0;
    cnt=0;
    for(j=0;j<i;j++)
      flag[s[j]-'a'][0]=1;
    for(j=i;j<n;j++)
      flag[s[j]-'a'][1]=1;
    for(j=0;j<30;j++)
      if(flag[j][0]&&flag[j][1])
        cnt++;
    if(cnt>max)
      max=cnt;
  }
  printf("%d\n",max);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
using namespace std;
const int INFN=2e5+5;
int n,m,fa_set[INFN],sum[INFN];
int find_set(int x) {
        return x==fa_set[x] ? x : fa_set[x]=find_set(fa_set[x]);
}
int fzx_max(int x,int y) {
        return x>y ? x : y;
}
signed main()
{
        scanf("%d %d",&n,&m);
        for (int i=1; i<=n; i++) {fa_set[i]=i; sum[i]=1;}
        for (int i=1; i<=m; i++) {
                int x=0,y=0;
                scanf("%d %d",&x,&y);
                x=find_set(x); y=find_set(y);
                if (x==y) continue;
                fa_set[x]=y;
                sum[y]+=sum[x];
                sum[x]=0;
        }
        int ans=0;
        // for (int i=1; i<=n; i++) if (fa_set[i]==i) cout<<sum[i]<<endl;
        for (int i=1; i<=n; i++) if (fa_set[i]==i) ans=fzx_max(ans,sum[i]);
        cout<<ans<<"\n";
        return 0;
}


Measured memory_bytes: 5240
#include <stdio.h>
#include <stdlib.h>
int main(void){

      int A,B,C,i;

      scanf("%d%d%d",&A,&B,&C);

      if(A < B){
            for(i = A; i <= B; i++){
                  if( i == C){
                        printf("Yes");
                        exit(0);
                  }
            }
      }else if(A > B){
            for(i = A; i >= B; i--){
                  if(i == C){
                        printf("Yes");
                        exit(0);
                  }
            }
      }
            printf("No");
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
using  namespace std;  
int i,j,k,n,m;
char a[1000],b[1000]; 
int main()
{
	cin>>a>>b;
	n=strlen(a);
	for(i=0;i<=n;i++)
	{
		if(a[i]!=0)		cout<<a[i];
		if(b[i]!=0)		cout<<b[i];
	}
	cout<<"\n";
	return 0;
} 

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

public class Main {

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

	    int N=gi();
	    int K=gi();
	    int[] A=new int[200001];

	    int k=0;
	    for(int i=0; i<N;i++) {
	    	int ind=gi();
	    	if (A[ind]==0)k++;
	    	A[ind]++;
	    }

	    Arrays.parallelSort(A);

	    int i=0;
	    int a=0;
	    while(k>K) {
	    	if(A[i]==0) {
	    		i++;
	    		continue;
	    	}
	    	a+=A[i];
	    	i++;
	    	k--;

	    }
	    System.out.print(a);
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 60412
#include <bits/stdc++.h>
using namespace std;
int n;
int adj[201][201];
int cnt=1;

int vis[201];

int bfs(int u){
	vis[u]=cnt;
	queue<int> q;
	q.push(u);
	int t=0;
	while(!q.empty()){
		int x = q.front();
		q.pop();
		t=max(t,vis[x]);
		for(int i=0;i<n;i++){
			if(adj[x][i]){
				if(vis[i]==vis[x]){
					return INT_MAX;
				}
				else{
					if(vis[i]==0){
						vis[i]=vis[x]+1;
						q.push(i);
					}
				}
			}
		}
	}
	cnt=t+1;
	return t;
}

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif

	cin >> n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			char c;
			cin >> c;
			adj[i][j]=c-'0';
		}
	}
	int ans=-1;
	for(int i=0;i<n;i++){
		memset(vis,0,sizeof(vis));
		cnt=1;
		for(int c=0;c<n;c++){
			if(vis[(i+c)%n]==0){
				int z = bfs((i+c)%n);
				if(z==INT_MAX){
					cout << "-1";
					return 0;
				}
				else{
					ans=max(ans,z);
				}
			}
		}
	}
	cout << ans;



}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-

R,C,K = map(int, input().split())

items = [[0 for _ in range(C+1)] for _ in range(R+1)]
for i in range(K):
  r,c,v = map(int, input().split())
  items[r][c] = v

DP_prev = [0 for _ in range(C+1)]
for r in range(1,R+1):
  DP1 = [0 for _ in range(C+1)]
  DP2 = [0 for _ in range(C+1)]
  DP3 = [0 for _ in range(C+1)]
  for c in range(1,C+1):
    item = items[r][c]
    DP1[c] = max(DP_prev[c]+item,DP1[c-1])
    DP2[c] = max(DP1[c],DP2[c-1],DP1[c-1]+item)
    DP3[c] = max(DP2[c],DP3[c-1],DP2[c-1]+item)
  DP_prev = DP3
        
print(DP_prev[C])

Measured memory_bytes: 169244
#include <stdio.h>

int main(void)
{
    int x, y;
    while (1) {
        scanf("%d %d\n", &x, &y);
	if (x == 0 && y == 0) {
   	    break;
	} else if (x >= y) {
	    printf("%d %d\n", y, x);
	} else {
            printf("%d %d\n", x, y);
        }
    }
    return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int t=1;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n+5];
        map<ll,ll>cnt;
        for(ll i=1; i<=n; i++)
        {
            cin>>a[i];
            cnt[a[i]]++;
        }

        ll ans=0;
        vector<ll>v;
        sort(a+1,a+n+1);

        for(ll i=n; i>=1; i--)
        {


            if(cnt[a[i]]>=4)
            {
                ans=max(ans,(a[i]*a[i]));

            }
            if(v.size()>=2) {
                ans=max(ans,v[0]*v[1]);
            }
            if(cnt[a[i]]>=2&&v.size()<2) v.push_back(a[i]);
            cnt[a[i]]=0;
        }
        cout<<ans<<endl;
        v.clear();
        cnt.clear();
    }
}


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

int main() {
	double x, h;
	while(1){
		cin >> x >> h;
		if(x==0 && h==0) break;
		double S = 2*x*sqrt(x*x/4+h*h)+x*x;
		std::cout << std::fixed;
		std::cout << std::setprecision(6) << S << endl;
	}
	return 0;
}


Measured memory_bytes: 3212
#include<stdio.h>
int main(){
  int cnt=0,n,q,S[100000],T[50000],i,j=0,le=0,ri,mi;
  scanf("%d",&n);
  for(i=0;i<=n-1;i++)scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i=0;i<=q-1;i++){
    scanf("%d",&T[i]);
  
  ri=n;
   le=0;
  while(le<ri){
    mi=(le+ri)/2;
    if(T[i]==S[mi]){
      cnt++;
      break;

    }
    else if(T[i]>S[mi]){
      le=mi+1;
      
    }
    else if(T[i]<S[mi]){
      ri=mi;
      
    }
   
  }
  }
  
  
  printf("%d\n",cnt);
  return 0;
}



Measured memory_bytes: 2440
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
 
int main() {
  ll n;
  cin>>n;
  map <string,ll> mp;
  rep(i,n){
    string s;
    cin>>s;
    sort(all(s));
    mp[s]++;
  }
  ll ans=0;
  for(auto x:mp){
    ans+=(x.second)*(x.second-1)/2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 11252
N=int(input())
A,B=map(int,input().split())
P=list(map(int,input().split()))
e=0
n=0
h=0
for i in range(N):
    if P[i]<=A:
        e+=1
    elif P[i]<=B:
        n+=1
    else:
        h+=1
print(min(e,n,h))

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
	long long x;
	cin >> x;
	if (x % 11 == 0) {
		cout << x / 11 * 2;
	}
	else {
		if (x % 11 > 6) {
			cout << x / 11 * 2 + 2;
		}
		else {
			cout << x / 11 * 2 + 1;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define drep(n,m) for(int i=0;i<n;i++)for(int j=0;j<m;j++)
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

ll gcd(ll a,ll b){
    if(a<b){
        int t=a;a=b;b=t;
    }
    int c=a%b;
    while(c!=0){
        a=b;
        b=c;
        c=a%b;
    }
    return b;
}

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

int main() {
   ll a,b;
   while(cin>>a&&cin>>b){
       cout<<gcd(a,b)<<" ";
       cout<<lcm(a,b)<<endl;
   }
   
    
    return 0;
}



Measured memory_bytes: 3000
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Linq.Enumerable;
using static System.Math;

class Program
{
    static void Main()
    {
        var (a, b, c, d) = ReadLine().Split(' ').Select(int.Parse).ToArray();
        
        var ans = ((Abs(a - c) <= d) || (Abs(a - b) <= d && Abs(b - c) <= d)) ? "Yes" : "No";

        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


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

#define ii pair<int, int>
#define x first
#define y second

using namespace std;

int h, w, a[100][100], c;
vector<ii> v;
bool avail[100][100];
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(){
    
    cin >> h >> w;
    string s;
    for (int i = 1; i <= h; i++){
        cin >> s;
        for (int j = 1; j <= w; j++){
            if (s[j-1] == '#'){
                a[i][j] = 1;
                v.push_back(ii(i, j));
            }
            else a[i][j] = 0;
        }
    }
    bool check = true;
    
    for (int i = 0; i < v.size(); i++){
        if (!avail[v[i].x][v[i].y]){
            avail[v[i].x][v[i].y] = true;
            c = 1;
            queue<ii> q;
            q.push(v[i]);
            while(!q.empty()){
                ii u = q.front();
                q.pop();
                int xx, yy;
                for (int i = 0; i < 4; i++){
                    xx = u.x + dx[i];
                    yy = u.y + dy[i];
                    if (0 < xx && xx <= h && 0 < yy && yy <= w && a[xx][yy] == 1){
                        if (!avail[xx][yy]){
                            c++;
                            avail[xx][yy] = true;
                            q.push(ii(xx, yy));
                        }
                    }
                }
            }
            if (c == 1){
                check = false;
                break;
            }
        }
    }
    
    if (check) cout << "Yes"; else cout << "No";
    
    
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>

using namespace std;

int main() {
    string s;
    cin >> s;
    int a = count(s.begin(), s.end(), '0');
    int b = count(s.begin(), s.end(), '1');
    cout << min(a, b) * 2 << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };



void solve() {
    ll a, b, c, d, e , m, n, k, x, y, l,r, h, w;
    string s, t;
    ll ans = 0;
    double dans = 0;
    string sans = "Yes";
    vector<ll> ar;
    vector<string> sr;
    vector<vector<char>> arr;

    cin >> n;
    rep(i,n){
        ll tmp;
        cin >> tmp;
        ar.push_back(tmp);
    }

    ll _max = 0;
    rep(i,n-1){
        Rep(j,i,n){
            _max = max(_max, abs(ar[i]-ar[j]));
        }
    }

    ans = _max;

    std::cout << ans << endl;

    // std::cout << sans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

Measured memory_bytes: 256
import numpy as np
from itertools import combinations

N = int(input())

P = [np.array(list(map(int,input().split())), dtype=float) for _ in range(N)]

d2 = lambda v: np.sum(np.square(v))

def radius(A,B,C):
    a = d2(B-C)
    b = d2(C-A)
    c = d2(A-B)

    r = float('inf')
    if c > d2(A+B - 2*C):
        r = min(r, c)

    if a > d2(B+C - 2*A):
        r = min(r, a)

    if b > d2(C+A - 2*B):
        r = min(r, b)

    if r != float('inf'):
        return np.sqrt(r)/2

    U = a*(b+c-a)*A + b*(c+a-b)*B + c*(a+b-c)*C
    v = a*(b+c-a) + b*(c+a-b) + c*(a+b-c)
    U /= v
    r = np.linalg.norm(U-A)
    return r

if N == 2:
    print(np.linalg.norm(P[0]-P[1])/2)
else:
    print(max(radius(a,b,c) for a,b,c in combinations(P,3)))


Measured memory_bytes: 14448
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////
const int V_MAX = 10001;
const int E_MAX = 30001;

static VI adj[V_MAX];
static VI cadj[V_MAX];
static VI ord1;
static bool visited[V_MAX] = {};
static int grp[V_MAX];

stack<int> S;

static int V,E;

void dfs(int v){ // 1 dfs
	if (visited[v]) return;
	visited[v] = true;
	REP(i,adj[v].size()){
		if (!visited[adj[v][i]]) dfs(adj[v][i]);
	}
	
	S.push(v);
}

void dfs2(int v,int u){
	visited[v] = true;
	grp[v] = u;
	REP(i,cadj[v].size()){
		if (!visited[cadj[v][i]]) dfs2(cadj[v][i],u);
	}
}

int scc(){
	memset(visited,0,sizeof(visited));
	//S.clear();
	REP(i,V){
		if (!visited[i]) dfs(i);
	}
	
	memset(visited,0,sizeof(visited));
	int cind = 0;
	while(!S.empty()){
		int s = S.top(); S.pop();
		if (!visited[s]){
			dfs2(s,cind);
			cind++;
		}
	}	
	return cind;
}

int main(){

	SCD2(V,E);
	
	REP(i,E){
		int s,t; SCD2(s,t); // 0-indexed
		adj[s].PB(t);
		cadj[t].PB(s);
	}
	
	scc();
	
	//output
	int Q; SCD(Q);
	
	REP(i,Q){
		int u,v; SCD2(u,v);
		if (grp[u] == grp[v]) PRINTD(1);
		else PRINTD(0);
	}
	
	
	return 0;
}



Measured memory_bytes: 4752
n,k = map(int,input().split())
a = list(map(int,input().split()))

beauty = [a[0]]
base = [a[0]]

for ai in a[1:]:
    for i in range(len(base)):
        base[i] += ai
        beauty.append(base[i])
    beauty.append(ai)
    base.append(ai)

ans = 0
for bi in range(41,-1,-1):
    cand = []
    for i in beauty:
        if((i>>bi)&1):
            cand.append(i)
    if(len(cand) >= k):
        ans += 1<<bi
        beauty = cand

print(ans)

Measured memory_bytes: 112904
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    if(K%2 == 1){
        //Nの中のKの倍数の個数
        cout << (N / K) * (N / K) * (N / K) << endl;
        return 0;
    }
    ll cnt = 0;
    ll cnt0 = 0;
    for(int i = 1; i <= N; i++){
        cnt += (i % K == K / 2);
        cnt0 += (i % K == 0);
    }
    ans += cnt * cnt * cnt;
    ans += cnt0 * cnt0 * cnt0;
    cout << ans << endl;

}


Measured memory_bytes: 3588
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <bitset>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <cmath>

using namespace std;

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

#ifdef WIN32
#define LLIO "%I64d"
#else
#define LLIO "%lld"
#endif

struct FastIO {
    inline FastIO& operator >> (int& x) {
        x = 0; char f = 0, ch = getchar();
        while(ch > '9' || ch < '0') f |= (ch == '-'), ch = getchar();
        while(ch <= '9' && ch >= '0') x = x * 10 + ch - 48, ch = getchar();
        return x = (f ? -x : x), *this;
    }
    inline FastIO& operator >> (long long& x) {
        x = 0; char f = 0, ch = getchar();
        while(ch > '9' || ch < '0') f |= (ch == '-'), ch = getchar();
        while(ch <= '9' && ch >= '0') x = x * 10 + ch - 48, ch = getchar();
        return x = (f ? -x : x), *this;
    }
    inline FastIO& operator >> (double& x) {
        x = 0; char f = 0, ch = getchar();
        double d = 0.1;
        while(ch > '9' || ch < '0') f |= (ch == '-'), ch = getchar();
        while(ch <= '9' && ch >= '0') x = x * 10 + ch - 48, ch = getchar();
        if(ch == '.') {
            ch = getchar();
            while(ch <= '9' && ch >= '0') x += d * (ch ^ 48), d *= 0.1, ch = getchar();
        }
        return x = (f ? -x : x), *this;
    }
}rin;
const int mod = 1e9 + 7;
ll f[2500][2500];
ll jc[10000007], inv[10000007];
ll ksm(ll x, int p) {
	ll ans = 1;
	while(p) {
		if(p & 1) ans = ans * x % mod;
		x = x * x % mod;
		p >>= 1;
	}
	return ans;
}
ll C(int n, int m) {
	if(m > n) return 0;
	return jc[n] * inv[m] % mod * inv[n - m] % mod;
}
int main() {
	jc[0] = inv[0] = 1;
	for(int i = 1 ; i <= 10000000 ; ++ i) jc[i] = jc[i - 1] * i % mod;
	inv[10000000] = ksm(jc[10000000], mod - 2);
	for(int i = 9999999 ; i >= 1 ; -- i) inv[i] = inv[i + 1] * (i + 1) % mod;
	int n, k; rin >> n >> k;
	if(k == 1) {puts("1"); return 0;}
	f[1][0] = 1;
	for(int i = 1 ; i <= n ; ++ i) {
		for(int j = 0 ; j <= i ; ++ j) {
			if(i > j) f[i][j] = f[i][j] + f[i - 1][j];
			if(j) f[i][j] = (f[i][j] + f[i][j - 1] * C(n * k - i - (j - 1) * (k - 1) - 1, k - 2) % mod) % mod;
		}
	}
	printf(LLIO "\n", f[n][n] * jc[n] % mod);
	return 0;
}


Measured memory_bytes: 196864
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <fstream>
#include<map>
#include <cassert>
#include<sstream>
using namespace std;
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
long long mod = 1e9 + 7;
typedef pair<int,int>p;
signed main()
{
	int n;
	cin >> n;
	int a[20];
	int b[20];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	vector<int>vec;
	int num = 1;
	for (int i = 0; i < n / 2; i++) {
		num *= 2;
	}
	int ans = INT_MAX;
	if (n == 1) {
		cout << 0;
		return 0;
	}
	for (int fst = 0; fst < num*((n%2)?2:1); fst++) {
		for (int scd = 0; scd < num; scd++) {
			int bit1 = 0;
			int tmp = fst;
			while (tmp != 0) {
				bit1 += tmp % 2;
				tmp /= 2;
			}
			int bit2 = 0;
			tmp = scd;			
			while (tmp != 0) {
				bit2 += tmp % 2;
				tmp /= 2;
			}
			if (bit1 != bit2)continue;
			vector<p>odd;
			vector<p>even;
			int left = 0;
			int right = 0;
			 tmp = fst;
			for (int i = 0; i < n; i += 2) {
				if (tmp % 2) {
					even.push_back(p(b[i], i));
				}
				else {
					odd.push_back(p(a[i], i));
				}
				tmp /= 2;
			}
			tmp = scd;
			for (int i = 1; i < n; i += 2) {
				if (tmp % 2) {
					odd.push_back(p(b[i], i));
				}
				else {
					even.push_back(p(a[i], i));
				}
				tmp /= 2;
			}
			sort(odd.begin(), odd.end());
			sort(even.begin(), even.end());
			bool judge = false;
			for (int i = 0; i < even.size(); i++) {
				if (even[i].first < odd[i].first)judge = true;
			}
			for (int i = 1; i < odd.size(); i++) {
				if (even[i - 1].first > odd[i].first)judge = true;
			}
			if (judge)continue;
			vector<int>vec;
			tmp = 0;
			for (int i = 0; i < n; i++) {
				if (i % 2 == 0)vec.push_back(odd[i/2].second);
				else vec.push_back(even[i/2].second);
			}
			for (int i = 0; i < n; i++) {
				for (int j = i+1; j < n; j++) {
					if (vec[j] < vec[i])tmp += 1;
				}
			}
			ans = min(ans,tmp);
		}
	}
	if (ans == INT_MAX)cout << -1;
	else cout << ans;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int[] cnt = new int[N];
		int[] count = new int[N];
		int[][] U = new int[N][3];
		for(int i=0; i<N; i++){
			for(int j=0; j<3; j++){
				U[i][j]=sc.nextInt();
			}
		}
		for(int i=0; i<3; i++){
			for(int l=0; l<N; l++){
				cnt[l]=U[l][i];
			}
			for(int j=0; j<N; j++){
				for(int k=0; k<N; k++){
					if(j!=k){
						if(cnt[j]==U[k][i]){
							U[k][i]=0;
						}
					}
				}
			}
		}
		for(int i=0; i<N; i++){
			for(int j=0; j<3; j++){
				count[i]+=U[i][j];
			}
		}
		for(int i=0; i<N; i++){
			System.out.println(count[i]);
		}
		// TODO Auto-generated method stub

	}

}

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

double w, h, x, y;

int main() {
  cin >> w >> h >> x >> y;
  cout << fixed;
  if(w == x * 2 && h == y * 2){
    cout << setprecision(6) << (w * h) / 2.0 << ' ' << 1 << endl;
  }else{
    cout << setprecision(6) << (w * h) / 2.0 << ' ' << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	const int N=101;
	int n,a[N],peg=0;
	int main(){
		n=read<int>();
		for(int i=1;i<=n;i++){
			a[i]=read<int>();
			if(a[i]%2==0 && a[i]%3!=0 && a[i]%5!=0) peg|=1;
		}
		puts(peg?"DENIED":"APPROVED");
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

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

void swap(int a, int b) {
	int tmp = a;
	a = b;
	b = tmp;
}

int main(void) {
	string s;
	cin >>s;
	int l = s.size();

	if (l%2==1) {
		cout << "No" << endl;
		return 0;
	}

	for (int i = 0; i < l/2;i++) {
		if (s[i*2]!= 'h' || s[i * 2+1] != 'i') {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;


	return 0;
}

Measured memory_bytes: 3624