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

#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define print_upto(a,n)        for(int i=0;i<n;i++)    cout<<a[i]<<" "; cout<<endl
#define take(x,n)           for(int i=0;i<n;i++)  cin>>x[i];

#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 ll long long
#define ff first
#define ss second
#define null NULL
#define all(c) (c).begin(),(c).end()
#define nl "\n"

#define ld long double
#define eb emplace_back
#define pb push_back
#define pf push_front
#define mod 1000000007

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


int main() {

	// Use ctrl+shift+b ( second option )
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

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

	ll a, b, c, d;
	cin >> a >> b >> c >> d;

	if (a >= 0 && b >= 0 && c >= 0 && d >= 0) {
		cout << b*d << nl;
	} else if (a <= 0 && b >= 0 && c <= 0 && d >= 0) {
		cout << max(a * c, b * d) << nl;
	} else if ( a <= 0 && b >= 0 && c >= 0 && d >= 0 ) {
		cout << b*d << nl;
	} else if (a >= 0 && b >= 0 && c <= 0 && d >= 0) {
		cout << b*d << nl;
	} else if (a <= 0 && b <= 0 && c >= 0 && d >= 0) {
		cout << b*c << nl;
	} else if (a >= 0 && b >= 0 && c <= 0 && d <= 0) {
		cout << a*d << nl;
	}else{
		cout<<a*c<<nl;
	}


	return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {

	char C[3][3];
	for (int i = 0; i < 3; i++) {
		scanf("%s", C[i]);
	}

	printf("%c%c%c", C[0][0], C[1][1], C[2][2]);



}

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

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

  int n,C;
  cin >> n >> C;

  vector<vector<int>> D(C, vector<int> (C));
  for (int i = 0; i < C; i++) {
    for (int j = 0; j < C; j++) {
      cin >> D[i][j];
    }
  }

  vector<int> mod0(C), mod1(C), mod2(C);
  vector<vector<int>> c(n, vector<int> (n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> c[i][j];
      c[i][j]--;
      if((i + j) % 3 == 0) mod0[c[i][j]]++;
      if((i + j) % 3 == 1) mod1[c[i][j]]++;
      if((i + j) % 3 == 2) mod2[c[i][j]]++;
    }
  }

  ll ans = 1e18;

  for (int i = 0; i < C; i++) {
    for (int j = 0; j < C; j++) {
      for (int k = 0; k < C; k++) {
        if (i == j || i == k || j == k) continue;

        ll sum = 0;

        for(int it = 0; it < C; it++) {
          sum += mod0[it] * D[it][i];
        }

        for(int it = 0; it < C; it++) {
          sum += mod1[it] * D[it][j];
        }

        for(int it = 0; it < C; it++) {
          sum += mod2[it] * D[it][k];
        }

        ans = min(ans, sum);
      }
    }
  }
  cout << ans << '\n';
}

Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<vector>
#include<utility>
#include<stdbool.h>
using namespace std;
typedef long long ll;
#define N (1000000000+7)

int main(void) {
	int n;
	cin >> n;
	if (n <= 111)cout << 111 << endl;
	else {
		if (n <= 222)cout << 222 << endl;
		else {
			if (n <= 333)cout << 333 << endl;
			else {
				if (n <= 444)cout << 444 << endl;
				else {
					if (n <= 555)cout << 555 << endl;
					else {
						if (n <= 666)cout << 666 << endl;
						else {
							if (n <= 777)cout << 777 << endl;
							else {
								if (n <= 888)cout << 888 << endl;
								else cout << 999 << endl;
							}
						}
					}

				}
			}
		}
	}
	return 0;

}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  int A[3][3]; bool ans[3][3];
  for (int i = 0; i < 3; i++){
    for (int j = 0; j < 3; j++){
      cin >> A[i][j];
      ans[i][j] = false;
    }
  }

  int N; cin >> N;
  for (int i = 0; i < N; i++){
    int B; cin >> B;
    for (int j = 0; j < 3; j++){
      for (int k = 0; k < 3; k++){
        if (A[j][k] == B) ans[j][k] = true;
      }
    }
  }

  string flag = "No";
  for (int i = 0; i < 3; i++){
    if (ans[i][0] == true && ans[i][1] == true && ans[i][2] == true){
      flag = "Yes";
    }
    if (ans[0][i] == true && ans[1][i] == true && ans[2][i] == true){
      flag = "Yes";
    }
  }
  
  if (ans[0][0] == true && ans[1][1] == true && ans[2][2] == true) flag = "Yes";
  if (ans[0][2] == true && ans[1][1] == true && ans[2][0] == true) flag = "Yes";

  cout << flag << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int i = 0;
		while(x != 0)
		{
			i++;
			System.out.println("Case " + i + ":" + " " + x);
			x = scan.nextInt();
		}
	}
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n;

int dfs(int m){
	if(m==0||m==1)return 0;
	if(m==2||m==3)return 1;
	int r;
	if(m%3==2)r=(m+1)/3;
	else r=m/3;
	return max(dfs(r),dfs(m-r*2))+1;
}

int main(){
	cin.sync_with_stdio(false);
	cin>>n;
	cout<<dfs(n)<<endl;
	return 0;
}

Measured memory_bytes: 3160
//file_name:ABC57_C.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    ll n;
    scanf("%lld",&n);


    ll ans = 999;

    srep(i,1,100100){
        if(n%i==0){
            ll a,b,c,d;
            b = 0;
            d = 0;
            a = i;
            c = n/i;
            while(a>0){
                b++;
                a/=10;
            }
            while(c>0){
                d++;
                c/=10;
            }
            ll mi = max(b,d);
            ans = min(ans,mi);
        }
    }

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



Measured memory_bytes: 256
N = int(input())
S = input()

# 右全部#にする

w = S.count('.')

ans = 10**9
cost = 0
for c in S:
    if c == '.':
        # 今見てる所以降全部白にする事を考える
        w -= 1
        # まだ見てない白の数 + 今まで白にした黒のコストが答え候補
        if w + cost < ans:
            ans = w + cost
    else:
        # 今見てる所が黒の場合、白の個数は減らない
        if w + cost< ans:
            ans = w + cost
        # 以降の計算に向けてコストを1増やす
        cost += 1

print(ans)

Measured memory_bytes: 3500
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  a *= n;
  cout << min(a, b) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)
#define MP(a,b) make_pair(a,b)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

void solve() {

	ll H,A;
	cin >> H >> A;
	cout << ceil((double)H/A);

}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	return 0;
}

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

int main()
{
    int N,i,a[1000],count=0,count1=0;
    scanf("%d\n",&N);
    for(i=0;i<N;i++)
        scanf("%d",&a[i]);
    for(i=0;i<N;i++)
    {
        if(a[i]%2==0)
        {
            count++;
             if(a[i]%3==0||a[i]%5==0)
                count1++;
        }
    }
    if(count==count1)
        printf("APPROVED");
        else printf("DENIED");
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
    int a, b; cin >> a >> b;
    for (int i = 0; i < 100000; i++) {
        if (int(i * 0.08) == a && int(i * 0.1) == b) {
            cout << i << endl;
            return 0;
        }
    }
    puts("-1");
    return 0;
}

Measured memory_bytes: 256
integer N
character(50) S
integer abc(ichar("a"):ichar("z")),ans(ichar("a"):ichar("z"))
read*,N
ans=0
read*,S
do j=1,len_trim(S)
  ans(ichar(S(j:j)))=ans(ichar(S(j:j)))+1
end do
do i=2,N
  read*,S
  abc=0
  do j=1,len_trim(S)
    abc(ichar(S(j:j)))=abc(ichar(S(j:j)))+1
  end do
  do j=ichar("a"),ichar("z")
    ans(j)=min(ans(j),abc(j))
  end do
end do
S=""
do i=ichar("a"),ichar("z")
  S=trim(S)//repeat(char(i),ans(i))
end do
print"(A)",trim(S)
end

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

int main(void) {
    string S;
    int w;
    int i = 0;
    cin >> S;
    cin >> w;
    while(i < S.size()) {
        cout << S[i];
        i += w;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define all(x) (x).begin() (x).end()
#define rall(x) (x).rbegin() (x).rend()
typedef long long ll;

int main(){
	int n,m; cin>>n>>m;
	int i=-1, j=1e9;
	while(m--){
		int x, y;
		cin>>x>>y;
		i=max(i, x);
		j=min(j, y);
	}	
	int ans = (j-i)+1;
	if(ans<=0)cout<<0<<endl;
	else cout<<ans<<endl;
}


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

const long long md=1e9+7;//mod
const int maxn=300100;
long long fac[maxn],inv[maxn];

// cal x^y in logy order
long long powd(long long x,long long y){
	long long res=1;
	while(y){
		if(y&1) res=res*x%md;
		x=x*x%md;
		y>>=1;
	}
	return res;
}
// calc n! by fermat's little theory
void csh(){
	fac[0]=1;
	for(int i=1;i<=300000;i++)
		fac[i]=fac[i-1]*i%md;
	inv[300000]=powd(fac[300000],md-2);
	for(int i=300000;i>=1;i--)
		inv[i-1]=inv[i]*i%md;
}
//calc combination in xlonx
long long C(int x,int y){
	return fac[x]*inv[y]%md*inv[x-y]%md;
}

int main(){
  long long N, K;
  cin >> N >> K;
  vector<long long> A(N);
  for (int i=0; i<N; i++){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  csh();
  long long ans = 0;
  for (int i=0; i<N; i++){
    if (i<K-1) continue;
    ans += A[i]*C(i,K-1);
    ans %= md;
  }
  for (int i=N-1; i>=0; i--){
    if (N-i<K) continue;
    ans -= A[i]*C(N-1-i,K-1);
    while(ans < 0){
      ans += md*1000000000;
    }
    ans %= md;
  }
  cout << ans << endl;
}


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

int main() {
  int s, s1, s2, s3;
  cin >> s;
  s1 = s / 100;
  s2 = (s - s1 * 100) / 10;
  s3 = s - s1 * 100 - s2 * 10;
  cout << s1 + s2 + s3 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define size 100
#define addsize 50
 
using namespace std;
 
typedef struct {
    int *base;
    int *top;
    int stack_size;
}SqStack;
 
//初始化栈
void InitStack(SqStack &S) {
    S.base = (int*)malloc(size * sizeof(int));
    if (!S.base) {
        cout << "初始化失败!" << endl;
        exit(0);
    }
    S.top = S.base;
    S.stack_size = size;
}
 
//入栈
bool PushStack(SqStack &S, int elem) {
    //先要判断是否满栈
    if (S.top - S.base >= S.stack_size) {
        S.base = (int*)realloc(S.base, (size + addsize) * sizeof(int));
        if (!S.base) {
            return false;
        }
        S.top = S.base + S.stack_size;
        S.stack_size += addsize;
    }
    *S.top++ = elem;
    return true;
}
 
//出栈
bool Popstack(SqStack &S, int &elem) {
    if (S.base == S.top) {
        cout << "该栈为空，出栈失败!" << endl;
        return false;
    }
    elem = *--S.top;
    return true;
}
 
//判断是否为空栈
bool StackEmpty(SqStack S) {
    if (S.base == S.top)
        return true;
    return false;
}
 
//进制转化的函数
void conversion() {
    int ten, N, elem;
    //用个字母来记录超过9的数
    char a = 'A';
    SqStack S;
    InitStack(S);
    //cout << "输入你要转化的数（十进制）和你要转化成（N）进制的数(中间用空格分开)：";
    cin >> ten >> N;
    elem = ten;
    while (ten) {
        PushStack(S, ten%N);
        ten /= N;
    }
    //cout << "10进制数"<<elem<<"转化的" << N << "进制数如下:" << endl;
    int cnt = 0;
    while (!StackEmpty(S)) {
        Popstack(S, elem);
        if (elem > 9)
            printf("%c", a + elem - 10);
        else{ 
            //cout << elem ;
            cnt++;
        }
    }
    cout << cnt << endl;
}
int main(){
    conversion();
    return 0;
}

Measured memory_bytes: 256
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

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

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

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

func main() {
	s := next()

	m := 1<<63 - 1
	for i := 0; i < len(s)-2; i++ {
		ss, _ := strconv.Atoi(s[i : i+3])
		if m > abs(ss-753) {
			m = abs(ss - 753)
		}
	}

	fmt.Println(m)
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  string  s , t ;
  cin >> s >> t ;
  string ans = "Yes";
  
  rep(i,s.size()){
    if(s.at(i) != t.at(i))
      ans = "No";
  }
  
  cout << ans ;


}


Measured memory_bytes: 3600
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		PriorityQueue<Long> pq = new PriorityQueue<Long>(Comparator.reverseOrder());
		for(int i = 0; i < n; i++){
		    pq.add(sc.nextLong());
		}
		
		// 計算
		long result = 0;
		for(int i = 0; i < m; i++){
		    long temp = pq.poll();
		    temp = temp/2;
		    pq.add(temp);
		}
		for(int i = 0; i < n; i++){
		    result += pq.poll();
		}
		// 出力
		System.out.println(result);
		
	}
}


Measured memory_bytes: 60880
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int K = sc.nextInt();
        HashMap<Integer,Long> map = new HashMap<>();
        for(int i=0;i<n;i++){
            int a = sc.nextInt();
            long b = sc.nextLong();
            map.put(a,map.getOrDefault(a,0L)+b);
        }
        ArrayList<Integer> pos = new ArrayList<>();
        for(int i=0;i<31;i++){
            if((K&(1<<i))!=0) pos.add(i);
        }
        Collections.sort(pos,Collections.reverseOrder());
        long ans = 0;
        if(pos.size()==0){
            ans += map.getOrDefault(0,0L);
            System.out.println(ans);
            System.exit(0);
        }
        for(int w:map.keySet()){
            if(w<(1<<pos.get(0))) ans += map.get(w);
        }
        for(int high=0;high<pos.size()-1;high++){
            long cur = 0;
            int mask=0;
            for(int i=0;i<=high;i++) mask |= 1<<pos.get(i);
            mask += (1<<pos.get(high+1))-1;
            for(int w:map.keySet()){
                if((w|mask)==mask) cur+=map.get(w);
            }
            ans=Math.max(ans,cur);
        }
        long temp = 0;
        for(int w:map.keySet()){
            if((w|K)==K) temp += map.get(w);
        }
        ans = Math.max(ans,temp);
        System.out.println(ans);
    }
}


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

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

    if (isupper(a))
        cout << "A" << endl;
    else
        cout << "a" << endl;
    return 0;
}


Measured memory_bytes: 3628
N, M = list(map(int, input().split()))
roads = [set(list(map(int, input().split()))) for _ in range(M)]

res = {}
for i in range(1, N+1):
    res[i] = 0

for x, y in roads:
    res[x] += 1
    res[y] += 1

for val in res.values():
    print(val)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
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(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(10);
	rep(i,n){
		int x;cin >> x;
		x /= 400;
		if(x >= 8) a.at(8)++;
		else a.at(x)++;
	}
	int cnt = 0;
	rep(i,8) if(a.at(i)) cnt++;
	cout << max(cnt, 1) << " " << cnt + a.at(8) << endl;
}


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

int main(){
	string a[3];
	int n[3];
	int i=0;
	int j=0;
	for(i=0;i<3;i++){
		cin>>a[i];
	}
	for(i=0;i<3;i++){
		n[i]=a[i].size();
	}
	for(i=0;i<3;i++){
		if(a[i][0]=='a')cout<<"A";
		if(a[i][0]=='b')cout<<"B";
		if(a[i][0]=='c')cout<<"C";
		if(a[i][0]=='d')cout<<"D";
		if(a[i][0]=='e')cout<<"E";
		if(a[i][0]=='f')cout<<"F";
		if(a[i][0]=='g')cout<<"G";
		if(a[i][0]=='h')cout<<"H";
		if(a[i][0]=='i')cout<<"I";
		if(a[i][0]=='j')cout<<"J";
		if(a[i][0]=='k')cout<<"K";
		if(a[i][0]=='l')cout<<"L";
		if(a[i][0]=='m')cout<<"M";
		if(a[i][0]=='n')cout<<"N";
		if(a[i][0]=='o')cout<<"O";
		if(a[i][0]=='p')cout<<"P";
		if(a[i][0]=='q')cout<<"Q";
		if(a[i][0]=='r')cout<<"R";
		if(a[i][0]=='s')cout<<"S";
		if(a[i][0]=='t')cout<<"T";
		if(a[i][0]=='u')cout<<"U";
		if(a[i][0]=='v')cout<<"V";
		if(a[i][0]=='w')cout<<"W";
		if(a[i][0]=='x')cout<<"X";
		if(a[i][0]=='y')cout<<"Y";
		if(a[i][0]=='z')cout<<"Z";
	}
		
}
	

Measured memory_bytes: 256
#include <cstdio>

#include <algorithm>

using namespace std;

typedef long long ll;

const int N = 310, P = 1000000007;

int n;

int match[N * 2], pre[N], sum[N * 2];
bool ab[N * 2][N * 2];
int con[N * 2][N * 2], spec[N * 2][N * 2];

int main() {
  int k;
  scanf("%d%d", &n, &k);
  while (k--) {
    int a, b;
    scanf("%d%d", &a, &b);
    match[a] = b;
    match[b] = a;
  }
  pre[0] = 1;
  for (int i = 1; i <= n; ++i)
    pre[i] = pre[i - 1] * (ll)(i * 2 - 1) % P;
  for (int l = 1; l <= n * 2; ++l) {
    int myn = n * 2, mex = 1;
    for (int r = l; r <= n * 2; ++r) {
      if (match[r]) {
        myn = min(myn, match[r]);
        mex = max(mex, match[r]);
      }
      ab[l][r] = myn >= l && mex <= r;
    }
  }
  for (int i = 1; i <= n * 2; ++i)
    sum[i] = sum[i - 1] + bool(match[i]);
  int ans = 0;
  for (int len = 2; len <= n * 2; len += 2)
    for (int l = 1; l + len - 1 <= n * 2; ++l) {
      int r = l + len - 1;
      if (!ab[l][r])
        continue;
      con[l][r] = pre[(len - sum[r] + sum[l - 1]) >> 1];
      spec[l][r] = con[l][r];
      for (int i = l + 1; i < r; i += 2)
        spec[l][r] = (P + spec[l][r] - spec[l][i] * (ll)con[i + 1][r] % P) % P;
      ans = (ans + spec[l][r] * (ll)pre[(n * 2 - len - sum[l - 1] - sum[n * 2] + sum[r]) >> 1]) % P;
    }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
#define PI  acos(-1)
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int N;cin>>N;
  string S;cin>>S;
  vector<int> left(N+1,0), right(N+1,0);
  // left[0]=(S.at(0)=='#'?1:0);
  // right[N-1]=(S.at(N-1)=='.'?1:0);
  REP(i,1,N+1){
    left[i]=left[i-1]+((S.at(i-1)=='#'?1:0));
  }
  RREP(i,N-1,-1){
    right[i]=right[i+1]+((S.at(i)=='.'?1:0));
  }
  int ans=INF;
  // debug(left);
  // debug(right);
  REP(i,1,N+1){
    ans=min(ans,left[i-1]+right[i]);
  }
  print(ans);
  
}


Measured memory_bytes: 3732
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define INF 1e9
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int,int> P;
struct edge{int to,cost;};

int d[6700],w,h,m[10][10],sx,sy,gx,gy,dx[]={1,0,-1,0},dy[]={0,1,0,-1},r[][7]={{},{0,0,3,5,2,4,0},{0,4,0,1,6,0,3},{0,2,6,0,0,1,5},{0,5,1,0,0,6,2},{0,3,0,6,1,0,4},{0,0,4,2,5,3,0}};
vector<edge> g[6600];

void dijkstra(int s){
	priority_queue<P,vector<P>,greater<P> > q;
	fill(d,d+6700,INF);
	d[s]=0;
	q.push(P(0,s));
	while(!q.empty()){
		P p=q.top();q.pop();
		int v=p.second;
		if(d[v]<p.first)continue;
		rep(i,g[v].size()){
			edge e=g[v][i];
			if(d[e.to]>d[v]+e.cost){
				d[e.to]=d[v]+e.cost;
				q.push(P(d[e.to],e.to));
			}
		}
	}
}

int main(){
	while(cin>>h>>w&&h){
		rep(i,6600)g[i].clear();
		rep(i,h)rep(j,w)cin>>m[i][j];
		cin>>sy>>sx>>gy>>gx;int count=0;
		rep(y,h)rep(x,w)for(int t=1;t<7;t++)for(int f=1;f<7;f++)rep(d,4){
			edge e;
			int nx=x+dx[d],ny=y+dy[d];
			if(nx>=0&&nx<w&&ny>=0&&ny<h&&t!=f&&t+f!=7){
				switch(d){
				case 0:
					e.to=(7-r[t][f])*1000+f*100+ny*10+nx;
					e.cost=m[ny][nx]*r[t][f];break;
				case 1:
					e.to=(7-f)*1000+t*100+ny*10+nx;
					e.cost=m[ny][nx]*f;break;
				case 2:
					e.to=r[t][f]*1000+f*100+ny*10+nx;
					e.cost=m[ny][nx]*(7-r[t][f]);break;
				case 3:
					e.to=f*1000+(7-t)*100+ny*10+nx;
					e.cost=m[ny][nx]*(7-f);break;
				}
				g[t*1000+f*100+y*10+x].push_back(e);
			}
		}
		dijkstra(1200+sy*10+sx);
		int ans=INF;
		rep(t,7)rep(f,7)ans=min(ans,d[t*1000+f*100+gy*10+gx]);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 0
import javax.print.DocFlavor;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.function.BiConsumer;

public class Main {

    //グローバル変数を定義

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

    void run() {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();

        for(int i=1; i<=k; i++){
            if(i % 2 != 0){
                //aの番
                if(a % 2 != 0){
                    a--;
                }
                b+=(a/2);
                a=(a/2);
            } else {
                //bの番
                if(b % 2 != 0){
                    b--;
                }
                a+=(b/2);
                b=(b/2);
            }
        }

        System.out.println(String.format("%s %s", a, b));
    }
}
//
//class Gauss {
//    //連立方程式の係数
//    //a[N][N](係数行列)とb[1](定数)を一緒にしたもの
//    double a[][];
//    int N;
//
//    Gauss(double[][] a, int N){
//        a = a;
//        N = N;
//    }
////    double a[][]={{1.0,1.0,1.0,1.0,10,0},
////            {2.0,1.0,3.0,2.0,21.0},
////            {1.0,3.0,2.0,1.0,17.0},
////            {3.0,2.0,1.0,1.0,14.0}};
////    int N=a.length;
//
//    //Gaussの消去法で連立方程式を解く
//    void gauss(){
//        //前進消去
//        double s;
//        for(int k=0; k<N-1; k++){
//            for(int i=k+1; i<N; i++){
//                s=a[i][k]/a[k][k];
//                for(int j=k+1; j<=N; j++){
//                    a[i][j] -= s * a[k][j];
//                }
//            }
//        }
//        //後退代入
//        for(int i=N-1; i>=0; i--){
//            s=a[i][N];
//            for(int j=i+1; j<N; j++){
//                s -= a[i][j] * a[j][N];
//            }
//            a[i][N] = s/a[i][i];
//        }
//    }
//    public static void run() {
//        Gauss gs= new Gauss();
//        gs.gauss();
//        //解の表示
//        System.out.println("ガウスの消去法による連立1次方程式の解");
//        for(int i=0; i<gs.N; i++){
//            System.out.println("x["+i+"] = "+gs.a[i][gs.N]);
//        }
//    }
//}


Measured memory_bytes: 24276
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        t: Chars,
    }

    let n = t.len();
    let mut s = Vec::new();

    for i in 0..n {
        if t[i] == '?' {
            if i != 0 && s[i - 1] == 'P' {
                s.push('D');
            } else if i != n - 1 && t[i + 1] == 'D' {
                s.push('P');
            } else {
                s.push('D');
            }
        } else {
            s.push(t[i]);
        }
    }

    let ans = s.iter().collect::<String>();
    println!("{}", ans);
}


Measured memory_bytes: 4024
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		int c,d;
		scanf("%d%d",&c,&d);
		int val=1000000007;
		val=min(val,c);
		val=min(val,a+1-c);
		val=min(val,d);
		val=min(val,a+1-d);
		printf("%d\n",(val-1)%3+1);
	}
}

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

int main() {

  /* input Red card data */
  int N;
  cin >> N;
  string Red[N];
  for(int i=0;i<N;i++){
    cin >> Red[i];
  }
  
  /* input data Blue card*/
  int M;
  cin >> M;
  string Blue[M];
  for(int i=0;i<M;i++){
    cin >> Blue[i];
  }
  
  /* combie input data */
  string Card[M+N];
  for(int i=0;i<N+M;i++){
    if(i<N)
	  Card[i]=Red[i];
    else
      Card[i]=Blue[i-N];
  }
  
  
  /* card counting */
  vector<int> count(N+M);
  vector<int> skip(N+M);
  for(int i=0;i<N+M;i++){
    for(int j=i;j<N+M;j++){
      if((Card[i]==Card[j])&&(skip.at(j)==0)){
        if(j<N)
          count.at(i)++;
        else
          count.at(i)--;
        skip.at(j)=1;
      }
    }
  }
    
  /* output data */
  int output=0;
  for(int i=0;i<N+M;i++)
  {
    output=max(output,count.at(i));
  }
  
  cout << output << endl;
}


Measured memory_bytes: 764
s = input()

start = s[0]
temp = start
ans = 1
flg = False
# print(0,temp)   
for i in range(1,len(s)):
    if not flg:
        if s[i] == temp:
            if i < len(s)-1:
                temp = s[i]+s[i+1]
                flg = True
            else:
                pass
        else:
            ans += 1
            temp = s[i]
    else:
        ans += 1
        flg =False
    # print(i,temp)          


print(ans)


Measured memory_bytes: 3500
#include<stdio.h>
int main()
{
    int i,t,a[100];
    while(scanf("%d",&t)!=EOF)
    {
        for(i=0;i<t;i++)
            scanf("%d",&a[i]);
        for(i=0;i<t-1;i++)
            printf("%d ",a[i]);
        printf("%d\n",a[t-1]);
        for(i=1;i<t;i++)
        {
            int temp=a[i];
            int j;
            for(j=i-1;j>=0&&temp<a[j];j--)
            {
                a[j+1]=a[j];
            }
            a[j+1]=temp;
            for(j=0;j<t-1;j++)
                printf("%d ",a[j]);
            printf("%d\n",a[t-1]);
        }

    }
    return 0;
}



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


int main() {

    int a, b;
    cin >> a >> b;
    if (a == b) {
        cout << 2*a << endl;
    } else if (a > b || b > a) {
        cout << max(a,b)*2-1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//Shejia Zhu
//2018-06-20

import java.util.*;

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

        int count = 0;
        while (!(allOdd(a))) {
            for (int i=0; i<n; i++) {
                if (a[i]!=2 && a[i]%2 == 0) {
                    a[i] /= 2;
                    count++;
                }
                else
                    a[i] *= 3;
            }
        }

        System.out.println(count);
    }

    public static boolean allOdd (int[] a) {
        for (int i: a) {
            if (i%2 == 0)
                return false;
        }
        return true;
    }
}

Measured memory_bytes: 36112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,l,a[100010];
	cin>>n>>l;
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	for(ll i=0;i<n-1;i++){
		ll now=a[i]+a[i+1];
		if(now<l){
			continue;
		}
		cout << "Possible"<<endl;
		for(ll j=0;j<n;j++){
			if(j==i){
				break;
			}
			cout << j+1<<endl;
		}
		for(ll j=n-1;j>i;j--){
			cout << j<<endl;
		}
		return 0;
	}
	cout << "Impossible"<<endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1664
N = int(input())
XY = [[list(map(int, input().split())) for _ in range(int(input()))] for _ in range(N)]

res = 0
for k in range(1 << N):
    bits = [(k >> i) & 1 for i in range(N)]
    flag = True
    for i in range(N):
        if (k >> i) & 1 == 0:
            continue
        for x, y in XY[i]:
            if bits[x - 1] == y:
                continue
            flag = False
    if flag:
        res = max(res, sum(bits))
print(res)


Measured memory_bytes: 43372
# Problem: https://atcoder.jp/contests/agc025/tasks/agc025_a
# Python 1st Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque


def II(): return int(sys.stdin.readline())


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


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


def LLI(rows_number): return [LI() for _ in range(rows_number)]


def digitSum(inputNum):
    result = 0
    inputNumStr = str(inputNum)
    for j in range(0, len(inputNumStr)):
        result = result + int(inputNumStr[j])
    return result


def solver(inputNum):
    result = 10**5
    # algorithm
    for j in range(1, inputNum):
        total = digitSum(j)+digitSum(inputNum-j)
        if total <= result:
            result = total
    return result


if __name__ == "__main__":
    print("{}".format(solver(II())))


Measured memory_bytes: 3064
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

signed main(){
    int n,s;
    cin >> n >> s;
    if(s == n){
        cout << n+1 << endl;
        return 0;
    }
    for(int i = 2;i*i <= n;i++){
        int tmp = n;
        int res = 0;
        while(tmp != 0){
            res += tmp%i;
            tmp /= i;
        }
        if(res == s){
            cout << i << endl;
            return 0;
        }
    }
    int ans = INF;
    for(int p = 1;p*p < n;p++){
        int q = s - p;
        if((n-q)%p == 0){
            int b = (n-q)/p;
            cerr << p << " " << q << " " << b << endl;
            if(q >= 0 && q <= b-1 && p <= b-1 && sqrt(n) < b){
                ans = min(b,ans);
            }
        }  
    }
    if(ans != INF)cout << ans << endl;
    else cout << -1 << endl;

    
    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int N=51;

ll n, m, k, u, v, x, y, t, a, b, ans;
int A[N], B[N];
ll dp[N];

bool check(ll mask){
	for (int i=0; i<N; i++) dp[i]=(1ll<<i);
	for (int i=1; i<N; i++) if (mask&(1ll<<i)){
		for (int j=0; j<N; j++) dp[j]|=dp[j%i];
	}
	for (int i=1; i<=n; i++) if ((dp[A[i]]&(1ll<<B[i]))==0) return 0;
	return 1;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n;
	for (int i=1; i<=n; i++) cin>>A[i];
	for (int i=1; i<=n; i++) cin>>B[i];
	ans=(1ll<<N)-2;
	if (!check(ans)) kill(-1)
	for (int i=N-1; i; i--) if (check(ans^(1ll<<i))) ans^=(1ll<<i);
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 256
/*
   双方向リストの実装
   　insert x: リストの先頭にxをもつ要素を追加
   　delete x: キーxを持つ最初のリストを削除
     deleteFirst : リストの最初の要素を削除
     deleteLast : リストの末尾の要素を削除

     入力
     n
     command1 a
     command2 b
     commandn c

     出力
     すべてのcommandが終了したあとの連結リストのキーを
     順番に出力。
     連続するキーは空白で区切る。
*/

#include <string.h>
#include <stdlib.h>
#include <stdio.h>

typedef struct node {
   int key;
   struct node *next;
   struct node *prev;
} node;

node *nil;


void init()
{
   nil = (node *)malloc(sizeof(node));
   nil->next = nil;
   nil->prev = nil;

}

void insert(int key)
{
   node *x;
   x = (node *)malloc(sizeof(node));
   x->key = key;

   x->next = nil->next;
   nil->next->prev = x;
   nil->next = x;
   x->prev = nil;

}

void deleteNode(node *t)
{
   if (t == nil)
      return;
   t->prev->next = t->next;
   t->next->prev = t->prev;
   free(t);
}

node* searchList(int p)
{
   node *cur = nil->next;

   while ( cur != nil && cur->key != p)
      cur = cur->next;

   return cur;

}

void deleteFirst()
{
   node *t = nil->next;
   deleteNode(t);
}

void deleteLast()
{
   node *t = nil->prev;
   deleteNode(t);
}

void delete(int key)
{
   deleteNode(searchList(key));
}

void printList()
{
   node *cur = nil->next;
   int isf = 0;

   while (1) {
      if (cur == nil) break;

      if (isf++ > 0) printf(" ");

      printf("%d", cur->key);

      cur = cur->next;
   }

   printf("\n");
}

int main()
{
   int n;
   int key;
   char com[12];
   scanf("%d", &n);

   init();

   while (n) {
      scanf("%s%d", com, &key);
      if (com[0] == 'i')
         insert(key);
      else if ( com[0] == 'd' ) {
         if ( strlen(com) > 6 ) {
            if ( com[6] == 'F')
               deleteFirst();
            else if ( com[6] == 'L')
               deleteLast();
         } else {
            delete(key);
         }
      }
      n--;
   }

   printList();

   return 0;
}


Measured memory_bytes: 32952
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

typedef long long ll;

map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    if (N == 0) {
        ans = 0;
    }
    else if(N%2 == 1)
        ans = 0;
    else {
        
        ll po = 0, n = N, denom = 1, prev = 0, cur = 0;
        while(denom <= N) {
            denom *= 5;
            po++;
        }
        // REP(i, po) denom *= 5;
        denom *= 2;
        // cerr << "denom = " << denom << endl;
        while(denom > 5) {
            cur = n / denom;
            ans += po * (cur - prev);
            denom /= 5;
            po--;
            prev = cur;
        }

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


Measured memory_bytes: 3616
from collections import defaultdict
from bisect import bisect_right
 
s=input()
t=input()
slen=len(s)
d=defaultdict(list)
 
for i,c in enumerate(s):
    d[c].append(i)
 
nowplace=-1
roop=0
for c in t:
    if not d[c]:
        print(-1)
        exit()
    i=bisect_right(d[c],nowplace)
    if len(d[c])==i:
        roop+=1
        nowplace=d[c][0]
    else:
        nowplace=d[c][i]
 
print(roop*slen+nowplace+1)

Measured memory_bytes: 7940
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;


#define ll          long long
#define pb          push_back
#define pii         pair<ll ,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#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++)
#define REP(i,n) for (int i = 1; i <= n; i++)

// mp::cpp_int



int solve( ){
  
  ll n,k,mx=0;
  ll a[45]={0};
  cin>>n>>k;
  vector<ll> vv;
  rep(i,0,n)
  {
    ll x;
    cin>>x;
    vv.pb(x);
    int k=0;
    while(x!=0)
    {    
       if(x%2==1){a[k]++;}
      x=x>>1;
       k++;
    }

  } 
  
  vii vva;
  rep(i,0,45)
  {      

      if(((ll)1<<i)>k)break;
        if(a[i]<n-a[i]){vva.pb({(n-a[i])*(ll)1<<i,(ll)1<<i});}
      
  }

sort(all(vva));
ll sum=0;
reverse(all(vva));;
for(int i=0;i<vva.size();i++)
{  

   if(k>=vva[i].SS){k-=vva[i].SS;sum+=vva[i].SS;}
   
}
ll s=0;
rep(i,0,n)
{
   s+=(sum^vv[i]);
}

cout<<s;

return 0;
}
 

int main()
{  int t=1;
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
  
 
  
  clock_t time_req;

    // Without using pow function
    time_req = clock();
    
//cin>>t;
   while(t--)
     {solve();
     }

         time_req = clock() - time_req;
    //cout << "Processor time taken is "
      //<< (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
}


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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int N,M,K;
    cin >>N>>M>>K;

    //-----------------------------------
    bool is=false;

    rep(i,N+1)rep(k,M+1){
        if(i*(M-k)+(N-i)*k == K){
            is=true;
            goto F;
        }
    }
F:
    cout << ((is) ? "Yes" : "No") <<endl;
    return (0);
}

Measured memory_bytes: 256