akhauriyash/Code-Regression huggingface dataset:
face = list(map(int,input().split()))
anface = list(map(int,input().split()))
def Nroll(list):
	a = [list[1],list[5],list[2],list[3],list[0],list[4]]
	return a
def Wroll(list):
	a = [list[2],list[1],list[5],list[0],list[4],list[3]]
	return a
ql = []
ans = "No"
for ii in range(2):
	face = Wroll(face)
	for k in range(4):
		face = Nroll(face)
		for kk in range(4):
			face = Wroll(face)
			if face == anface:
				ans = "Yes"
				break
		else:
			continue
		break
	else:
		continue
	break
print(ans)


Measured memory_bytes: 5600
#coding:utf-8
min_c = 10000
n,T = list(map(int,input().split()))
for i in range(n):
    c,t = list(map(int,input().split()))
    if t <= T and c < min_c:
        min_c = c
if min_c!=10000:
    print (min_c)
else:
    print ('TLE')


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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    vector<int> v;
    int tmp;
    cin >> tmp;
    v.push_back(tmp);
    cin >> tmp;
    v.push_back(tmp);
    cin >> tmp;
    v.push_back(tmp);

    int mn = INF;
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            for (int k = 0; k < 3; k++)
            {
                if (i == j || j == k || k == i)
                    continue;
                mn = min(mn, abs(v[i] - v[j]) + abs(v[k] - v[j]));
            }
        }
    }
    cout << mn << endl;
}


Measured memory_bytes: 256
SA = list(input())
SB = list(input())
SC = list(input())

now = 0

while True:

    if now == 0:

        nex = SA.pop(0)
        #print ("A",nex)

    elif now == 1:

        nex = SB.pop(0)
        #print ("B",nex)

     

    else:

        nex = SC.pop(0)
        #print ("C",nex)



    if nex == "a":
        now = 0
        if len(SA) == 0:
            print ("A")
            break

    elif nex == "b":
        now = 1
        if len(SB) == 0:
            print ("B")
            break   

    elif nex == "c":
        now = 2
        if len(SC) == 0:
            print ("C")
            break

        


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

int main(){
  int N,L;
  cin>>N>>L;
  vector<int> apple(N);
  vector<int> apple2(N);
  int total=0;
  for (int i=0;i<N;i++){
    apple.at(i)=L+i;
    total+=apple.at(i);
    apple2.at(i)=abs(L+i);
    
  }
  sort(apple2.begin(),apple2.end());
  bool flag=0;
  for (int i=0;i<N;i++){
    if(apple2.at(0)==apple.at(i) || apple2.at(0)==-apple.at(i)){
      total-=apple.at(i);
      flag=1;
      break;
    }
  }
  cout<<total<<endl;
  
}
      

Measured memory_bytes: 256
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>

#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

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

using namespace std;

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}
template<typename T>
T lcm( T m, T n )
{
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

long long sum=0;
string S;
int dfs(int current, long long N, long long A){
    if(current==S.length()-1){
        sum+=N+A;
        return 0;
    }

    // 今いる桁までで足す
    dfs(current+1,N+A,S[current+1]-'0');
    // 現在までの桁で足さずさらに先の桁まで見る
    dfs(current+1, N, 10*A+S[current+1]-'0');
    return 0;
}

int main() {
    cin >> S;

    dfs(0, 0, S[0]-'0');
//    long long N;
//    long long ans=0;
//    cin >> N;
//    long long currentT=0, currentA=0;
//
//    for(int i=0; i<N; i++){
//        long long A,T;
//        long long multiA,multiT;
//        int j=1;
//        cin >> T >> A;
//
//        multiA=currentA/A;
//        multiT=currentT/T;
//        if(currentA%A!=0){
//            multiA++;
//        }
//        if(currentT%T!=0){
//            multiT++;
//        }
//
//
//        currentA=A*j;
//        currentT=T*j;
//    }

    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 256
package main

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

// S....M....E
// R...RL...LR
func searchRange(text *string, start, limit int) (int, int, int) {
	middle := -1

	for i := start; i < limit; i++ {
		if (*text)[i] != 'R' {
			middle = i
			break
		}
	}

	end := limit

	for i := middle; i < limit; i++ {
		if (*text)[i] != 'L' {
			end = i
			break
		}
	}

	return start, middle, end
}

func answer() {
	var text string
	fmt.Scan(&text)
	limit := len(text)

	start := 0
	middle := 0
	end := 0
	firstPrinted := false

	writer := bufio.NewWriter(os.Stdout)

	for end < limit {
		start, middle, end = searchRange(&text, start, limit)

		for i := start; i < middle-1; i++ {
			if firstPrinted {
				writer.WriteString(" ")
			}
			writer.WriteString("0")
			firstPrinted = true
		}

		{
			len1 := middle - start
			len2 := end - middle
			count1 := (len1+1)/2 + len2/2
			count2 := len1/2 + (len2+1)/2

			if firstPrinted {
				writer.WriteString(" ")
			}
			writer.WriteString(strconv.Itoa(count1))
			writer.WriteString(" ")
			writer.WriteString(strconv.Itoa(count2))
		}
		firstPrinted = true

		for i := middle + 1; i < end; i++ {
			if firstPrinted {
				writer.WriteString(" ")
			}
			writer.WriteString("0")
			firstPrinted = true
		}
		start = end
		firstPrinted = true
	}

	writer.WriteString("\n")
	writer.Flush()
}

func main() {
	answer()
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int i;
  string S;
  int ny;
  for(i=0;i<N;i+=1){
    cin>>S;
    if(S=="Y"){
      ny+=1;
    }
  }
  if(ny==0){
    cout<<"Three"<<endl;
  }
  else{
    cout<<"Four"<<endl;
  }
}
    
  

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

int main(){
  ll N,M;
  cin >> N >> M;
  vector<ll> A(N),B(N);
  for(int i=0;i<N;i++)cin >> A[i] >> B[i];
  priority_queue<ll> q;
  vector<pair<ll,ll>> p(N);
  for(int i=0;i<N;i++)p[i]=make_pair(A[i],B[i]);
  sort(p.begin(),p.end());
  //reverse(p.begin(),p.end());
  ll ans=0; int j=0;
  for(int i=1;i<=M;i++){
    while(j<N && p[j].first<=i){
      q.push(p[j].second); j++;
    }
    if(!q.empty()){ans+=q.top(); q.pop();}
  }
  cout << ans << endl;
}

Measured memory_bytes: 4472
import sys, random
input = sys.stdin.readline
def main():
    D = int(input())
    c = list(map(int, input().split()))
    s = []
    for _ in range(D):
        si = list(map(int, input().split()))
        s.append(si)
    last_list = [0] * 26
    minus_sat_list = [0] * 26
    for i in range(D):
        for j in range(26):
            minus_sat_list[j] += c[j] * (i+1-last_list[j])
        best_idx = 0
        worst_sat, worst_sat_idx  = 0, -1
        worst2_sat, worst2_sat_idx  = 0, -1
        worst3_sat, worst3_sat_idx  = 0, -1
        worst4_sat, worst4_sat_idx  = 0, -1
        worst5_sat, worst5_sat_idx  = 0, -1
        for j in range(26):
            if (minus_sat_list[j] > worst_sat) or (minus_sat_list[j] == worst_sat and s[i][j] > s[i][worst_sat_idx]):
                worst_sat = minus_sat_list[j]
                worst_sat_idx = j
            elif (minus_sat_list[j] > worst2_sat) or (minus_sat_list[j] == worst2_sat and s[i][j] > s[i][worst2_sat_idx]):
                worst2_sat = minus_sat_list[j]
                worst2_sat_idx = j
            elif (minus_sat_list[j] > worst3_sat) or (minus_sat_list[j] == worst3_sat and s[i][j] > s[i][worst3_sat_idx]):
                worst3_sat = minus_sat_list[j]
                worst3_sat_idx = j
            elif (minus_sat_list[j] > worst4_sat) or (minus_sat_list[j] == worst4_sat and s[i][j] > s[i][worst4_sat_idx]):
                worst4_sat = minus_sat_list[j]
                worst4_sat_idx = j
            elif (minus_sat_list[j] > worst5_sat) or (minus_sat_list[j] == worst5_sat and s[i][j] > s[i][worst5_sat_idx]):
                worst5_sat = minus_sat_list[j]
                worst5_sat_idx = j
        worst_val = s[i][worst_sat_idx] * 2 + worst_sat
        worst2_val = s[i][worst2_sat_idx] * 2 + worst2_sat
        worst3_val = s[i][worst3_sat_idx] * 2 + worst3_sat
        worst4_val = s[i][worst4_sat_idx] * 2 + worst4_sat
        worst5_val = s[i][worst5_sat_idx] * 2 + worst5_sat
        best_val = max(worst_val, worst2_val, worst3_val, worst4_val, worst5_val)
        if best_val == worst_val:
            best_idx = worst_sat_idx
        elif best_val == worst2_val:
            best_idx = worst2_sat_idx
        elif best_val == worst3_val:
            best_idx = worst3_sat_idx
        elif best_val == worst4_val:
            best_idx = worst4_sat_idx
        elif best_val == worst5_val:
            best_idx = worst5_sat_idx
        minus_sat_list[best_idx] = 0
        last_list[best_idx] = i + 1
        print(best_idx+1)
if __name__ == "__main__":
    main()

Measured memory_bytes: 78944
#include <cstdio> 
#include <cstdlib> 
#include <cmath> 
#include <cstring> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <numeric>
#include <cassert>

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

ll mem[2048][2048];

int main(void)
{
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    vector<pair<int, int> > ls; REPV(A, i) ls.push_back(pair<int, int>{A[i], i});
    sort(ls.rbegin(), ls.rend());
    
    REP(i, N+1) REP(j, N+1) mem[i][j] = -1;
    mem[0][0] = 0;
    REP(i, N+1) REP(j, N+1) if (i+j < N) {
        ll &cur = mem[i][j];
        int p = i+j;
        assert(cur != -1);
        // use l
        ll next = cur + (ll)abs(i-ls[p].second)*ls[p].first;
        if (next > mem[i+1][j]) {
            mem[i+1][j] = next;
        }
        // use rs
        next = cur + (ll)abs((N-1-j)-ls[p].second)*ls[p].first;
        if (next > mem[i][j+1]) {
            mem[i][j+1] = next;
        }
    }

    ll ret = 0;
    REP(i, N+1) {
        ret = max(ret, mem[i][N-i]);
    }

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

Measured memory_bytes: 35652
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#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
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
//----------------------------------------------------------------

// int MOD = 998244353;
int MOD = 1000000007;

//----------------------------------------------------------------
signed main(){

	ll n;
	cin >> n;
	cout << n*n*n << endl;


	return 0;
}

//----------------------------------------------------------------

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2017-final.contest.atcoder.jp/tasks/ddcc2017_final_b
// rm -r -f test;oj dl https://abc140.contest.atcoder.jp/tasks/abc140_a

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main(){
    int h, w;
    while(true){
        cin >> h >> w;
        if(h == 0 && w == 0) return 0;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }

}



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

int main(){
	long long  K, A, B;
	cin >> K >> A >> B;
	long ans = 1;
	if (A + 2 >= B || A > K + 1) {
		ans += K;
	}else
	{
		K -= (A - 1);
		if(K % 2 == 0) ans = K / 2 * (B - A) + A;
		else ans = K / 2 * (B - A) + A + 1;
	}
	
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////


int main() {
	ll A, V, B, W, T;
	cin >> A >> V >> B >> W >> T;

	if ((V - W) * T >= abs(A - B)) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }
}

Measured memory_bytes: 3612
#include<stdio.h>
#define N 1000
int main(void){
 int set;
 int i,j,k;
 int a[N];
 int v;
 scanf("%d", &set);
 for(i=0;i<set;i++){
  scanf("%d", &a[i]);
  if(i!=set-1){
   printf("%d ",a[i]);
  }else if(i==set-1){
   printf("%d\n", a[i]);
  }
 }
 for(i=1;i<set;i++){
  v=a[i];
  j=i-1;
  while(j>=0 && a[j]>v){
   a[j+1]=a[j];
   j--;
  }
  a[j+1]=v;
  for(k=0;k<set;k++){
   if(k!=set-1){
    printf("%d ",a[k]);
   }else{
    printf("%d\n",a[k]);
   }
  }
 }
 return 0;
}

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

int main()
{
  int N,A,b=0,ans=0; // b : ビット和
  cin >> N;

  for (int i = 0; i < N; ++i)
  {
    cin >> A; // A[i]を格納
    b = (A | b); // bはA_1～A_Nのビット和
  }

  while((b&1)==0){ // ビット和の最下位ビットが0である限り
    b = b>>1; // ビット和を右に1ビットシフトして
    ans++; // 操作回数を1回増やす
  }

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

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

int main(){
    string s; cin >>s;
    int ans = 0;
    for(int i = 1; i < s.size();i++ ){
        for(int j = 1; j+i < s.size();j ++){
            for (int k =  1; k+j+i < s.size();k ++){
                string a = s.substr(0,i);
                string b = s.substr(i,j);
                string c = s.substr(j+i,k);
                string d = s.substr(k+j+i);
                if(a.size() and b.size() and c.size() and d.size()){
                    if(stoi(a) <=255 and stoi(b) <= 255 and stoi(c) <= 255 and stoi(d) <= 255){
                       if((a.size()> 1  and a.front() == '0') or (b.size()>1 and b.front() == '0') or (c.size() > 1 and c.front() == '0')
                          or (d.size() > 1 and d.front() == '0'))
                           continue;
                      else   ans++;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}





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

int main() {
	int a, b;
	cin >> a >> b;
	int ans = -1;
	for(int x = 1; x < 10000; x++) {
		if((int) (x * 0.08) == a && (int) (x * 0.10) == b) {
			cout << x << endl;
			return 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define MAX 100000

typedef struct card{
  char moji;
  int num,id;
} card;

int partition(card [],int,int);
void quickSort(card [],int,int);
int stable(card [],int);


int main(){
  
  int i,n,q;
  card cards[MAX];

  scanf("%d",&n);
  for(i=0;i<n;i++){
  	scanf("%s%d",&cards[i].moji,&cards[i].num);
  	cards[i].id = i;
  }

  	quickSort(cards,0,n-1);

  if(stable(cards,n))printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n-1;i++)printf("%c %d\n",cards[i].moji,cards[i].num);
  	printf("%c %d\n",cards[i].moji,cards[i].num);


  return 0;

}

void quickSort(card A[],int p,int r)
{
	int q;
	if(p<r){
		q=partition(A,p,r);
		quickSort(A,p,q-1);
		quickSort(A,q+1,r);
	}
}
int partition(card A[],int p,int r)
{
	int x,i,j;
	card temp;

	x = A[r].num;
  i =p - 1;

   for(j=p;j<r;j++){
    if(A[j].num <= x){ 
    	i = i+1;

      temp=A[i];
    A[i] = A[j];
    A[j] = temp;
    } 
  }

  temp = A[i+1];
  A[i+1] = A[r];
  A[r] = temp;

  return i+1;
}

int stable(card A[],int n)
{
	int i;
	for(i=0;i<n-1;i++){
		if(A[i].num==A[i+1].num&& A[i].id>A[i+1].id)return 0;
	}
	return 1;
}

Measured memory_bytes: 1780
from collections import Counter
h,w,n=map(int,input().split())
d={}

for _ in range(n):
    a,b=map(int,input().split())

    for i in range(max(a-2,1),a+1):
        for j in range(max(b-2,1),b+1):
            if h<i+2 or w<j+2:
                continue
            if (i,j) in d:
                d[(i,j)]+=1
            else:
                d[(i,j)]=1
ans=[0]*10
ans[0]=(h-2)*(w-2)
for k,v in d.items():
    ans[v]+=1
    ans[0]-=1

for a in ans:
    print(a)

Measured memory_bytes: 239868
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int calc(int p, int q, int mind, int ca, int a, int cn, int n){
        int s = 0; 
        if(cn <= n){
                mind = max(mind,q/p);
                int maxd = floor((double)(n-cn+1)*q/p);
                for(int i = mind;i <= maxd && pow(i,floor((double)i*p/q))*ca <= a;i++){
                        if(p*i-q==0){
                                s++;
                        }else if(p*i-q > 0){
                                int _p = p*i-q;
                                int _q = q*i;
                                s += calc(_p,_q,i,ca*i,a,cn+1,n);
                        }  
                }  
        }  
        return s; 
}

int main(){
        int p,q,a,n;
        cin >> p >> q >> a >> n; 
        while(p){
                cout << calc(p,q,1,1,a,1,n) << endl;
                cin >> p >> q >> a >> n; 
        }  
}

Measured memory_bytes: 0
N=str(input())
if int(N[-1])==2 or int(N[-1])==4 or int(N[-1])==5 or int(N[-1])==7 or int(N[-1])==9:
  print('hon')
elif int(N[-1])==0 or int(N[-1])==1 or int(N[-1])==6 or int(N[-1])==8:
  print('pon')
else:
  print('bon')

Measured memory_bytes: 9196
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define INF         1e9
#define EPS         1e-9
#define REP(i,n)    for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(lint i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b)   (((a)+(b)-1)/(b))
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP        cout << fixed << setprecision(8)
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }

class one_stroke {
private:
	int h, w;
	pair<int, int>p;
public:
	one_stroke(int h, int w) :h(h), w(w) {}
	pair<int, int>&operator()() {
		static int y = 0, x = 0;
		if (y % 2 == 0) {
			if (x != w - 1) {
				++x;
			} else {
				if (y != h - 1) {
					++y;
				} else {
					y = x = -1;
				}
			}
		} else {
			if (x != 0) {
				--x;
			} else {
				if (y != h - 1) {
					++y;
				} else {
					y = x = -1;
				}
			}
		}
		return (p = make_pair(y, x));
	}
};
signed main() {
	int h = in(), w = in();
	vector<vector<int>>a(h, vector<int>(w));
	REP(i, h) {
		REP(j, w) {
			scanf("%d", &a[i][j]);
		}
	}
	vector<pair<pair<int, int>, pair<int, int>>>op;
	op.reserve(h * w);
	one_stroke os(h, w);
	for (auto p = make_pair(0, 0);;) {
		auto from = p;
		auto to = p = os();
		if (to.first == -1) {
			break;
		}
		if (a[from.first][from.second] % 2 == 1) {
			op.push_back(make_pair(from, to));
			++a[to.first][to.second];
		}
	}
	cout << op.size() << endl;
	REP(i, op.size()) {
		cout << op[i].first.first + 1 << ' ' << op[i].first.second + 1 << ' ' << op[i].second.first + 1 << ' ' << op[i].second.second + 1 << endl;
	}
}

Measured memory_bytes: 6784
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 998244353;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

ll fastPow(ll x, ll n)
{
    if (n == 0)
        return 1;
    if (n % 2 == 0)
        return fastPow(x * x % MOD, n / 2);
    else
        return x * fastPow(x, n - 1) % MOD;
}

ll fac[112346];
void combInit(int mx)
{
    fac[0] = 0;
    fac[1] = 1;
    for (int i = 2; i <= mx; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
    }
}

ll modDiv(ll a, ll b)
{
    return a * fastPow(b, MOD - 2) % MOD;
}

ll comb(ll a, ll b)
{
    if (b == 0)
        return 1;
    if (a < b)
        return 0;
    if (a <= 0 || b < 0)
        return 0;
    if (a == b)
        return 1;

    ll p, c;

    c = modDiv(fac[a], fac[a - b]);
    p = fac[b];

    ll res = modDiv(c, p);

    return res;
}

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

    combInit(210);

    int n, x[210], y[210];

    ll li[210];
    fill(li, li + n + 1, 0);

    cin >> n;
    REP(i, n)
    cin >> x[i] >> y[i];

    ll res = 0;

    bool used[210][210];

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            used[i][j] = i == j;

    V l;

    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
        {
            if (used[i][j])
                continue;

            V v;

            v.push_back(i);
            v.push_back(j);

            int cnt = 2;
            for (int k = j + 1; k < n; k++)
            {
                int a = (x[j] - x[i]) * (y[k] - y[j]);
                int b = (y[j] - y[i]) * (x[k] - x[j]);

                if (a == b)
                {
                    cnt++;

                    v.push_back(k);
                }
            }

            if (cnt > 2)
            {
                for (int k = 0; k < v.size(); k++)
                    for (int m = 0; m < v.size(); m++)
                        used[v[k]][v[m]] = true;

                l.push_back(cnt);
            }
        }

    for (int i = 3; i <= n; i++)
    {
        ll tmp = 0;
        tmp += comb(n, i);

        for (int j : l)
        {
            if (i > j)
                continue;
            tmp += MOD - comb(j, i);
            tmp %= MOD;
        }

        res += tmp;
        res %= MOD;
    }

    cout << res << endl;

    return 0;
}

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

int main(){
    string s;
    cin >> s;
    bool diff = true;
    for (int x = 0; x < s.length() - 1; x++) {
        for (int y = x + 1; y < s.length(); y++) {
            if (s[x] == s[y]) {
                cout << "no";
                diff = false;
                break;
            }
        }
        if (!diff) {
            break;
        }
    }
    if (diff) cout << "yes";
}


Measured memory_bytes: 760
#include<iostream>
#include<queue>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)

int main(){
  ll n;
  cin>>n;
  string s;
  cin >> s;

  int L[300001]; // iをリーダーにしたときに、iより小さい番号の人が向きを変える必要のある数
  int R[300001]; // iをリーダーにしたときに、その右で向きを変える人の数

  // 初期化
  L[0]=0;
  R[0]=0;
  repl(i,1,n){
    if(s[i] == 'E') R[0]+=1;
  }

  int m = L[0]+R[0]; // 最小値
  repl(i,1,n){
    if(s[i-1]=='W') L[i]=L[i-1]+1;
    else L[i]=L[i-1];

    if(s[i]=='E') R[i]=R[i-1]-1;
    else R[i]=R[i-1];

    m = mmin(m, L[i]+R[i]);
  }
  cout<<m<<endl;

  return 0;
}



Measured memory_bytes: 2948
fun main(args: Array<String>) {
  val (n, x) = listOfInt()
  val lList = listOfInt()
  var sum = 0
  var cnt = 1
  for (i in 0 until n) {
    sum += lList[i]
    if (sum > x) break
    cnt++
  }
  println(cnt)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

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

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  if ((b - a - 1) % 2 == 0){
    cout << "Borys" << endl;
  } else {
    cout << "Alice" << endl;
  }
  return 0;
}

Measured memory_bytes: 3612
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
mod = 10 ** 9 + 7; INF = float("inf")

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

class Combination(object):
	def __init__(self, N, mod = 10 ** 9 + 7):
		self.fac = [0] * (N + 1)
		self.inv = [0] * (N + 1)
		self.finv = [0] * (N + 1)
		self.fac[0], self.fac[1] = 1, 1
		self.inv[1] = 1
		self.finv[0], self.finv[1] = 1, 1
		self.mod = mod

		# 前計算
		for i in range(2, N + 1):
			self.fac[i] = self.fac[i - 1] * i % mod
			self.inv[i] = self.inv[mod % i] * (mod - (mod // i)) % mod
			self.finv[i] = self.finv[i - 1] * self.inv[i] % mod

	def cmb(self, N, k):
		return (self.fac[N] * self.finv[k] * self.finv[N - k]) % self.mod

def main():
	S = int(input())
	ans = 0
	C = Combination(S)
	for i in range(1, S + 1):
		n = S - 3 * i; k = i - 1
		if n >= 0:
			ans += C.cmb(S - 2 * i - 1, i - 1)
			ans %= mod
		else:
			break

	print(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 68076
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <string>
#include <set>
#include <sstream>
#include <algorithm>
#include <fstream>
#include <deque>
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int, int>
#define f first
#define s second
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()

const int inf = (int)1e9;
const int mod = inf+7;
	
int n, a[110];

int main(){

	cin >> n;

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

	int minN = 2000;
	int maxX = -2;

	for(int i=0;i<n;i++){
		minN = min(minN, a[i]);
		maxX = max(maxX, a[i]);
	}

	cout << maxX-minN;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
  string s;
  cin >> s;
  int cnt;
  int ans = 0;
  if (s[0] =='R') cnt = 1;
  else cnt = 0;
  rep(i,s.size()-1) {
    if (s[i]=='R'&&s[i+1]=='R') cnt++;
    else {
      ans = max(ans, cnt);
      if (s[i+1]=='R') cnt = 1;
      else cnt = 0;
    }
  }
  ans = max(ans, cnt);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3616
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
const long long md=1e9+7;
long long n,a[303030],ans;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<60;i++)
	{
		long long cnt=0;
		for(int j=0;j<n;j++)
		{
			if(a[j]&(1ll<<i))
			{
				cnt++;
			}
		}
		ans+=(cnt*(n-cnt)%md*((1ll<<i)%md))%md;
		ans%=md;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define hackcyborg shresth_walia
#define ll  long long
#define int long long
#define ld  long double
#define pb push_back
#define mod 1000000007
#define M_PI 3.141592653589
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
long long binpow(long long a, long long b, long long m=mod) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
main()
{   IO
    ll n;
    cin>>n;
    ll a;
    ll s=0;
    map<ll,ll> ar;
    for(int x=0;x<n;x++)
    {
        cin>>a;
        s+=a;
        ++ar[a];
    }
    ll q;
    cin>>q;
    for(int x=0;x<q;x++)
    {
        ll c,d;
        cin>>c>>d;
        s-=c*ar[c];
        s+=d*ar[c];
        ll r=ar[c];
        ar.erase(c);
        ar[d]+=r;
        cout<<s<<"\n";
    }
}


Measured memory_bytes: 7612
A,B = input().split()

A = int(A)
B = int(B)

ans = 0

for i in range(B - A + 1):
    
    i += A
    
    i = str(i)
    
    rot = ""
    
    for j in i:
        
        rot = j + rot
        
    if i == rot :
        
        ans += 1
        
        
print (ans)

Measured memory_bytes: 2940
if __name__ == '__main__':
    N=int(input())
    C=[]
    F=[]
    S=[]
    ans={i:0 for i in range(N)}
    for i in range(N-1):
        c,s,f=list(map(int,input().split()))
        C.append(c)
        S.append(s)
        F.append(f)

    for i in range(N-1):
        t=0
        for j in range(i,N-1):
            if t<S[j]:
                t=S[j]+C[j]
            elif t%F[j]==0:
                t+=C[j]
            else:
                t+=F[j]-t%F[j]+C[j]
        ans[i]=t

    for i in ans.values():
        print(i)






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

const int MAX = 1e9 + 5;
bool t[MAX];

signed main()
{
  int n, q;
  int ans = 0;

  cin >> n;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    t[tmp] = 1;
  }

  cin >> q;
  for (int i = 0; i < q; i++) {
    int tmp;
    cin >> tmp;
    if (t[tmp] == 1) {
      ans++;
      t[tmp] = 0;
    }
  }

  cout << ans << endl;

  return (0);
}

Measured memory_bytes: 6300
#include <stdio.h>
#include <stdlib.h>
 
int
main(int argc, char *argv[])
{
  int n1, n2, n3;
  
  scanf("%d %d %d", &n1, &n2, &n3);
  if (n1*n2*n3 == 5*7*5)
    printf("YES\n");
  else
    printf("NO\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

int main(void){
	long long N, M, LCM;
	string S, T;
	cin >> N >> M;
	cin >> S >> T;

	int n, m, r;
	if(N < M){
		n = M;
		m = N;
	}else{
		n = N;
		m = M;
	}
	r = n % m;
	while(r != 0){
		n = m;
		m = r;
		r = n % m;
	}
	LCM = (N * M) / m ;

//	while(n != m){
//		n -= m;
//		int temp = n;
//		n = m;
//		m = temp;
//	}
//	GCD = n;
//	LCM = (N * M) / GCD;

	int skipN, skipM;
	skipN = LCM / N;
	skipM = LCM / M;
	map<int, int> str;
	for(int index = 0; index < S.size(); index++){
		str[1 + index * skipN] = S[index];
	}
	bool loopBreak = false;
	for(int index = 0; index < T.size(); index++){
		if(str[1 + index * skipM] != 0 && str[1 + index * skipM] != T[index]){
			loopBreak = true;	
			break;
		}
		str[1 + index * skipM] = T[index];
	}

	if(loopBreak){
		cout << -1 << endl;
		return 0;
	}
	cout << LCM << endl;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
int main(){
  int64_t n;
  cin>>n;
  int64_t x=n*2;
  map<int64_t,int> f;
  for(int64_t i=2;i*i<=x;i++){
    while(x%i==0){
      f[i]++;
      x/=i;
    }
  }
  if(x!=1)
    f[x]++;
  vector<long long> m;
  for(auto x:f){
    int64_t d=1;
    for(int i=0;i<x.second;i++)
      d*=x.first;
    m.push_back(d);
  }
  long long a=n*2;
  for(int i=1;i<(1<<(int)m.size());i++){
    int b=i;
    vector<long long> r(m.size());
    for(int d=0;d<(int)m.size();d++){
      r.at(d)=(b%2==1?m.at(d)-1:0);
      b/=2;
    }
    auto c=crt(r,m);
    if(c.second!=0)
      a=min(a,c.first);
  }
  cout<<a<<endl;
}

Measured memory_bytes: 3676
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <ostream& out = cout, class... T> void prints(T&&...){ }
template <ostream& out = cout, class... T> void printd(T&&...){ }
template <ostream& out = cout, class... T> void printde(T&&...){ }
template <ostream& out = cout, class... T> void printb(T&&...){ }
template <ostream& out = cout, class... T> void printArr(T&&...){ }
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a, b;
    cin >> a >> b;
    ll n = a.size(), ans = M;
    vector<ll> l1(n, M), r1(n, M);
    for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ if(b[(i - j + n) % n] == '1'){ l1[i] = j; break; } } }
    for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ if(b[(i + j + n) % n] == '1'){ r1[i] = j; break; } } }
    prints(l1, r1);
    string a2;
    a2.resize(n);
    for(int h = 0; h < 2; h++){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                a2[j] = a[(j - i * (h == 0 ? 1 : -1) + n) % n];
            }
            ll cnt = 0, add = 0;
            vector<pair<ll, ll>> adds;
            for(int j = 0; j < n; j++){
                if(a2[j] != b[j]){
                    // add = max(add, min(((h == 0 ? l1 : r1)[j] - i) * 2, (h == 0 ? r1 : l1)[j] * 2));
                    adds.emplace_back(max(0ll, (h == 0 ? l1 : r1)[j] - i) * 2, max(0ll, (h == 0 ? r1 : l1)[j]) * 2);
                    cnt++;
                }
            }
            sort(adds.begin(), adds.end());
            int n2 = adds.size();
            if(n2){
                vector<ll> maxs(n2 + 1);
                maxs[n2 - 1] = adds[n2 - 1].second;
                for(int j = n2 - 2; j >= 0; j--){
                    maxs[j] = max(maxs[j + 1], adds[j].second);
                }
                prints(adds, maxs);
                add = adds[0].first + maxs[1];
                for(int j = 1; j < n2; j++){
                    add = min(add, adds[j].first + maxs[j + 1]);
                }
            }
            ans = min(ans, cnt + i + add);
            prints(i, cnt + i + add, add);
        }
    }
    cout << (ans >= n * 3 ? -1 : ans) << '\n';
    return 0;
}


Measured memory_bytes: 384
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//define
#define inp(X) cin>>X;
#define inp_long(X) long long X; cin>>X;
#define inp_arr(A,N) long long A[N]; for(int i=0;i<N;i++) {cin>>A[i];}
#define sz(A) A.size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define endl '\n'
#define vect(A) vector<long long> A;
#define inp_vect(A,N); for(int i=0;i<N;i++){long long q; cin>>q; A.push_back(q);}
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);
}
int main()
{
	fio;
	ll n;
	inp(n);
	ll a[n];
	forin(i,0,n-1)
	{
		cin>>a[i];
	}
	ll temp=0;
	ll ans=0;
	forin(i,0,n-2)
	{
		if(a[i]>=a[i+1])
		{
			temp++;
			ans=max(ans,temp);
		}
		else
		{
			ans=max(ans,temp);
			temp=0;
		}
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 1024
import java.util.Scanner;

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

        while(true){
            int height = scan.nextInt();
            int width = scan.nextInt();

            if(height == 0 && width == 0){
                break;
            }

            for(int i = 0; i < height; i++){
                for(int j = 0; j< width; j++){
                    if(((i + j) % 2 == 0)){
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }

                System.out.println("");
            }

            System.out.println("");
        }
    }
}


Measured memory_bytes: 33388
#include <iostream>
#include<algorithm>
#include <vector>
#include<string>
#include<queue>
using namespace std;



int main(){
	int n;
	cin >> n;
	if (n == 100000)cout << 90909 << endl;
	else if (n > 9999)cout << n - 9999 + 9 + 900 << endl;
	else if (n > 999)cout << 909 << endl;
	else if (n > 99)cout << n - 99 + 9 << endl;
	else if (n > 9)cout << 9 << endl;
	else cout << n << endl;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

// Returns a vector of cumulative sums.
// Let c_sums be the return value.
// - c_sums[k] is the sum of xs over [0, k).
// - c_sums[r] - c_sums[l] is the sum of xs over [l, r).
template<class T> vector<T> CumulativeSumVector(const vector<T>& xs) {
  int n = xs.size(); vector<T> c_sums(n + 1);
  for (int i = 0; i < n; i++) c_sums[i + 1] = c_sums[i] + xs[i];
  return c_sums;
}

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

  int n;
  int k;
  cin >> n >> k;
  vector<int64> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
  }

  auto cumulative_xs = CumulativeSumVector(xs);
  vector<int64> ys;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < i; j++) {
      ys.push_back(cumulative_xs[i] - cumulative_xs[j]);
    }
  }

  int64 ans = 0;
  for (int b = 59; b >= 0; b--) {
    int64 z = 1LL << b;
    int c = 0;
    for (int64 y : ys) {
      if (y & z) {
        c++;
      }
    }
    if (c >= k) {
      ans |= z;
      vector<int64> next_ys;
      for (int64 y : ys) {
        if (y & z) {
          next_ys.push_back(y);
        }
      }
      ys = next_ys;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 6512
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, x := nextInt(), nextInt()

	// a[i]: レベルiのバーガーの長さ
	// p[i]: レベルiのバーガーのパティ
	a, p := make([]int, n+1), make([]int, n+1)
	a[0], p[0] = 1, 1
	for i := 1; i <= n; i++ {
		a[i] = a[i-1]*2 + 3
		p[i] = p[i-1]*2 + 1
	}

	var f func(level, x int) int
	f = func(level, x int) int {
		if level == 0 {
			if x == 1 {
				return 1
			}
			return 0
		}
		if x == 1 {
			return 0
		} else if x <= a[level-1]+1 {
			return f(level-1, x-1)
		} else if x == a[level-1]+2 {
			return p[level-1] + 1
		} else if x <= 2*a[level-1]+2 {
			return p[level-1] + 1 + f(level-1, x-a[level-1]-2)
		} else {
			return 1 + 2*p[level-1]
		}
	}

	puts(f(n, x))
}


Measured memory_bytes: 640
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val l = (1..n).map { sc.nextInt() }


  var count = 0

  for (i in 0 until n) {
    for (j in i+1 until n) {
      for (k in j+1 until n) {
        
        if (l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue

        if (isT(l[i], l[j], l[k])) {
          count++
        }
      }
    }
  }

  println(count)

}


private fun isT(a: Int, b: Int, c: Int): Boolean {
  if (a + b > c && b + c > a && c + a > b) return true

  return false
}

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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)

int x[3];
int ans = 0;
int main(){
  REP(i,3) cin >> x[i];
  REP(i,3)REP(j,3)REP(k,3){
    if(i==j || j==k || k==i) continue;
    ans = max(ans,10*x[i]+x[j]+x[k]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.awt.Point;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int[] DR = { 1, 0, -1, 0 };
	static int[] DC = { 0, 1, 0, -1 };
	static int N;
	static int[][] v = new int[8][8];
	static ArrayList<Point> axisPos = new ArrayList<Point>();
	static ArrayList<Integer> axises = new ArrayList<Integer>();

	static boolean dfs(boolean[][] visited, Point pos, int axis, int sum) {
		if (sum > axises.get(axis)) return false;
		if (sum == axises.get(axis)) {
			++axis;
			if (axis == axises.size()) return true;
			pos = axisPos.get(axis);
			sum = 0;
		}
		for (int i = 0; i < 4; ++i) {
			int nr = pos.x + DR[i];
			int nc = pos.y + DC[i];
			if (nr < 0 || N <= nr || nc < 0 || N <= nc || visited[nr][nc] || v[nr][nc] < 0) continue;
			visited[nr][nc] = true;
			if (dfs(visited, new Point(nr, nc), axis, sum + v[nr][nc])) return true;
			visited[nr][nc] = false;
		}
		return false;
	}

	static boolean solve() {
		boolean[][] visited = new boolean[N][N];
		return dfs(visited, axisPos.get(0), 0, 0);
	}

	public static void main(String[] args) throws Exception {
		while (true) {
			N = sc.nextInt();
			if (N == 0) break;
			int sum = 0;
			axisPos.clear();
			axises.clear();
			for (int i = 0; i < N; ++i) {
				for (int j = 0; j < N; ++j) {
					v[i][j] = sc.nextInt();
					sum += v[i][j];
					if (v[i][j] < 0) {
						axisPos.add(new Point(i, j));
						axises.add(-v[i][j]);
					}
				}
			}
			System.out.println(sum == 0 && solve() ? "YES" : "NO");
		}
	}

}

Measured memory_bytes: 12000
#pragma GCC optimize("-O3")

#include <bits/stdc++.h>

using namespace std;

//#define TEST

signed main() {
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
		cin >> a.at(i);

	// 不可能判定
	for (int i = 0; i < n; ++i) {
		if (a[i] > i) {
			cout << -1 << endl;
			return 0;
		}
	}
	for (int i = 0; i < n - 1; ++i) {
		if (a[i] < a[i + 1] - 1) {
			cout << -1 << endl;
			return 0;
		}
	}

	vector<int> b;
	long long ans = 0;
	b.push_back(0);
	for (int i = n - 1; i >= 0; --i) {
		if (*(b.end() - 1) != a[i] + n - 1 - i)
			b.push_back(a[i] + n - 1 - i);
		auto iter = lower_bound(b.begin(), b.end(), n - 1 - i);
		if (iter != b.end() && *iter != n - 1 - i)
			* (iter - 1) = n - 1 - i;
		int sub = n - 1 - i;
		long long dis;
		ans += (dis = b.end() - lower_bound(b.begin(), b.end(), sub) - 1);
#ifdef TEST
		cout << dis << endl;
		for (auto bi : b)
			cout << bi << " ";
		cout << endl;
#endif
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

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

ll f(ll x, ll y) {
  return x-x/y;
}

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

  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = f(b, c) + f(b, d) - f(b, lcm(c, d)) - (f(a-1, c) + f(a-1, d) - f(a-1, lcm(c, d)));
  cout << ans <<endl;
}


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

int main(){
    int N;
    cin >> N;
    vector<vector<int>> A(N, vector<int>(N,0));
    vector<vector<int>> v(N*N);
    vector<int> cnt(N*N, 0);

    auto id = [&](int x, int y){
        return x*N+y;
    };
    for(int i=0;i<N;i++){
        for(int j=0;j<N-1;j++){
            cin >> A[i][j];
            A[i][j]--;
            if(j == 0) continue;
            
            int a = (i < A[i][j-1] ? id(i, A[i][j-1]) : id(A[i][j-1], i));
            int b = (i < A[i][j]? id (i, A[i][j]) : id(A[i][j], i));
            v[a].push_back(b);
            cnt[b]++;
        }
    }

    vector<int> vis(N*N);
    function<bool(int)> dfs = [&](int n){
        bool ok = true;
        vis[n] = -1;
        for(auto x:v[n]){
            //未訪問　=> 再帰
            if(vis[x] == 0) ok &= dfs(x);
            //閉路検出 => false
            else if(vis[x] == -1) return false;
        }
        vis[n] = 1;
        return ok;
    };

    for(int i=0;i<N*N;i++){
        if(!dfs(i)){
            cout << -1 << endl;
            return 0;
        }
    }

    for(int i=0;i<N*N;i++) vis[i] = 0;
    vector<int> u;
    function<void(int)> dfs2 = [&](int n){
        vis[n] = 1;
        for(auto x:v[n]) if(vis[x] == 0) dfs2(x);
        u.push_back(n);
    };
    for(int i=0;i<N*N;i++) if(cnt[i] == 0) dfs2(i);
    reverse(u.begin(), u.end());
    vector<int> dp(N*N);
    for(int i=0;i<u.size();i++){
        for(auto x:v[u[i]]){
            dp[x] = max(dp[x], dp[u[i]] + 1);
        }
    }
    int ans = 0;
    for(int i=0;i<N*N;i++) ans = max(ans, dp[i]);
    cout << ans+1 << endl;
}

Measured memory_bytes: 59120
n, k = map(int, input().split())
p = list(map(int, input().split()))
tmp = sum(p[:k])
res = tmp
# スライドさせていく
for i in range(n - k):
    tmp -= p[i]
    tmp += p[i + k]
    res = max(res, tmp)
# 期待値は　例えば　k=6の時、(1+2+3+4+5+6)/2 =3.5 になり、
# 別の計算方法だと　(6+1)/2=3.5となる
print((res + k) / 2)

Measured memory_bytes: 24812