akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>
#include <fstream>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(LL i = (a); i < (LL)(n); ++i)
#define REM(i,a,n) for(LL i = ((n) - 1); i >= (a); --i)
#define FLOAT fixed << setprecision(16)
#define SPEEDUP {cin.tie(0); ios::sync_with_stdio(false);}
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const string INFSTR = "\x7f";
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template<class T>
T Compare(T left, T right) { return left > right ? 1 : (left < right ? -1 : 0); }
istream& Ignore(istream& ist) { string s; ist >> s; return ist; }
bool Inside(int i, int j, int h, int w) { return i >= 0 && i < h && j >= 0 && j < w; }
// all_of
// partial_sum, adjacent_difference

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "Flow_Solver.h"
#include "Tree.h"
#include "Suffix_Array.h"
#include "Geometry.h"
#include "Matrix.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

#if 1234567891
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

int N, K;

int main() {
	cin >> N >> K;
	int mx = 0;
	vector<int> db;
	REP(i, 0, N) {
		int a, b;
		cin >> a >> b;
		mx = max(mx, a);
		db.push_back(b);
	}
	sort(db.begin(), db.end(), greater<int>());

	int i = 0;
	int ans = 0;
	while (i < db.size() && db[i] > mx) {
		K -= db[i];
		++ans;
		if (K <= 0) {
			goto end;
		}
		++i;
	}
	
	ans += (K + mx - 1) / mx;


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


Measured memory_bytes: 892
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    def count_(num,x):
        i = 0
        while num > 0:
            i += num % x
            num //= x
        return i
    ans = n

    for j in range(n + 1):
        ans = min(ans,count_(j,6)+count_(n-j,9))
    print(ans)




if __name__ == '__main__':
  main()


Measured memory_bytes: 3060
def main():
    # 入力
    n = int(input())
    if n < 105:
        print(0)
        return

    cnt = 1

    for i in range(106, n+1):
        if i % 2 == 0:
            continue
        tmp_cnt = 0

        # ls = []
        for j in range(3, i):
            if i % j == 0:
                tmp_cnt += 1
                # ls.append(j)
                if tmp_cnt == 7:
                    break

        # print("i:" + str(i) + ", c:" + str(tmp_cnt) + ", l:" + str(ls))
        if tmp_cnt == 6:
            cnt += 1

    print(cnt)


main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define forn(i,n)for(ll i=0;i<(n);i++)
#define forn_rev(i,n)for(ll i=(n)-1;i>=0;i--)
#define for1n(i,n) for(ll i=1;i<=(n);i++)
#define ARRAY_SIZE(a) sizeof(a)/sizeof(*a)
#define MOD 1000000007
#define MAXN 100000

using namespace std;


void bfs(vector<vector<char>> &arr,ll &l,ll r,ll N,ll M){

    queue<pair<ll,ll>> q;
    q.push({l,r});
    while(!q.empty()){
        pair<ll,ll> a=q.front();

        q.pop();
        if(arr[a.first][a.second]=='.') arr[a.first][a.second]='B';
        char ch=arr[a.first][a.second];
        if(a.second>0 && arr[a.first][a.second-1]=='.') {
                q.push({a.first,a.second-1});
                if(ch=='B') arr[a.first][a.second-1]='W';
                else arr[a.first][a.second-1]='B';
        }
        if(a.second<M-1 && arr[a.first][a.second+1]=='.') {
                q.push({a.first,a.second+1});
                if(ch=='B') arr[a.first][a.second+1]='W';
                else arr[a.first][a.second+1]='B';
        }
        if(a.first>0 && arr[a.first-1][a.second]=='.') {
                q.push({a.first-1,a.second});
                if(ch=='B') arr[a.first-1][a.second]='W';
                else arr[a.first-1][a.second]='B';
        }
        if(a.first<N-1 && arr[a.first+1][a.second]=='.') {
                q.push({a.first+1,a.second});
                if(ch=='B') arr[a.first+1][a.second]='W';
                else arr[a.first+1][a.second]='B';
        }

    }

}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);
    ll T=1;
    //cin>>T;
    while(T--)
    {
        string s;
        cin>>s;
        forn(i,s.length()) if(s[i]=='7') {cout<<"Yes";return 0;}
        cout<<"No"<<endl;


    }





    return 0;
}

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

const int N =2e5+10;
int n,a[N];
inline int read()
{
    int x = 0, f = 1; char ch = getchar();
    while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
    while (isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); }
    return x * f;
}
inline bool check(const int &k)
{
    if((a[n-1]<=k&&a[n]<=k)||(a[n]<=k&&a[n+1]<=k))return 1;
    if((a[n-1]> k&&a[n]> k)||(a[n]> k&&a[n+1]> k))return 0;
    for(int i=1;i<n-1;i++){
        if((a[n+i]<=k&&a[n+i+1]<=k)||(a[n-i]<=k&&a[n-i-1]<=k))return 1;
        if((a[n+i]> k&&a[n+i+1]> k)||(a[n-i]> k&&a[n-i-1]> k))return 0;
    }
    return a[1]<=k;
}

int main(){
    n=read();
    for(int i=1;i<n<<1;i++)a[i]=read();
    int l=1,r=(n<<1)-1;
    while(l<r){
        int mid=l+r>>1;
        if(check(mid))
            r=mid;
        else
            l=mid+1;
    }
    printf("%d",l);
}


Measured memory_bytes: 1024
n = int(input())
P = [int(s) for s in input().split()]
count = 0
for i in range(n-2):
  tmp = []
  
  tmp.append(P[i])
  tmp.append(P[i+1])
  tmp.append(P[i+2])
  
  if (tmp[1] < tmp[2] and tmp[0] < tmp[1]) or (tmp[0] > tmp[1] and tmp[2] < tmp[1]):
    count += 1
print(count)



Measured memory_bytes: 3188
INF = float('inf')

N, Ma, Mb = map(int, input().split())
chemicals = [tuple(map(int, input().split())) for _ in range(N)]

sumA, sumB, sumC = map(sum, zip(*chemicals))

#dp[i][j]: Aをiグラム、Bをjグラム作るのに必要なコストの最小値
dp = [[INF] * (sumB + 1) for _ in range(sumA + 1)]
dp[0][0] = 0
for a, b, c in chemicals:
    for i in reversed(range(sumA + 1)):
        for j in reversed(range(sumB + 1)):
            if dp[i][j] == INF: continue
            if i + a <= sumA and j + b <= sumB:
                dp[i + a][j + b] = min(dp[i + a][j + b], dp[i][j] + c)

ans = INF
for i in range(1, min(sumA // Ma, sumB // Mb) + 1):
    ans = min(ans, dp[Ma * i][Mb * i])

if ans == INF:
    print(-1)
else:
    print(ans)


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

int main()
{
    int n, q, c = 0;
    scanf("%d", &n);
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    scanf("%d", &q);
    for (int i = 0; i < q; i++)
    {
        int b, l = 0, m, r = n;
        scanf("%d", &b);
        while (l < r)
        {
            m = (l + r) / 2;
            if (b == a[m])
            {
                c++;
                break;
            }
            else if(b > a[m])
            {
                l = m + 1;
            }
            else
            {
                r = m;
            }
        }
    }
    printf("%d\n", c);
}

Measured memory_bytes: 3388
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 3e6 + 5;
ll a[N];
int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    ll cnt = 0;
    for(int i = 0; i < n; i++){
        ll x;
        cin >> x;
        while(x % 2 == 0){
            x /= 2; cnt++;
        }
    }
    cout << cnt;
return 0;
}


Measured memory_bytes: 256
// 1_5_B
#include<stdio.h>

int main(void)
{
	int height, width, H, W;
	scanf("%d %d", &H, &W);
	if(H == 0 && W == 0){
		return 0;
	}

	for(height = 0; height < H; height++){
		for(width = 0; width < W; width++){
			if(height == 0 || height == H-1 || width == 0 || width == W-1){
				printf("#");
			}else{
				printf(".");
			}
		}
		printf("\n");
	}
	printf("\n");

	main();
}

Measured memory_bytes: 572
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	s = s[:len(s)-1]
	for {
		if len(s)%2 == 0 {
			if s[:len(s)/2] == s[len(s)/2:] {
				fmt.Println(len(s))
				return
			}
		}
		s = s[:len(s)-1]
	}
}


Measured memory_bytes: 512
#include <stdio.h>
int main(void){
    int a, b, c;
    int k;
    int n;
 
    scanf("%d%d%d", &a, &b, &c);
    n = 0;
    for (k = a; k <= b; k++) {
        if (c % k == 0) n++;
    }
    printf("%d\n", n);
    return 0;
}


Measured memory_bytes: 2112
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int K = Integer.parseInt(sc.next());
    int Q = Integer.parseInt(sc.next());
    int[] participant = new int[N];

    for(int i = 0; i < Q; i++) {
    	int n = Integer.parseInt(sc.next());
    	participant[n - 1]++;
    }

    for (int i = 0; i < N; i++) {
    	participant[i] += (K - Q);
    }

    for (int i = 0; i < N; i++) {
    	if (participant[i] <= 0) {
    		System.out.println("No");
    	} else {
    		System.out.println("Yes");
    	}
    }
  }
}

Measured memory_bytes: 61036
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    x,a,b = LI()
    if abs(x-a) > abs(x-b):
        return 'B'

    return 'A'

print(main())



Measured memory_bytes: 8648
#include <stdio.h>

int cnt, n, a, b, c, d;

int main(void)
{
  while(scanf("%d",&n) == 1)
  {
    cnt = 0;
    for(a = 0; a <= 9; a++)
    for(b = 0; b <= 9; b++)
    for(c = 0; c <= 9; c++)
    for(d = 0; d <= 9; d++)
      if (a + b + c + d == n) cnt++;
    printf("%d\n",cnt);
  }
  return 0;
}

Measured memory_bytes: 2592
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int a, b, c; cin >> a >> b >> c;
  string result = (a+b==c||b+c==a||c+a==b) ? "Yes" : "No";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define endl "\n"
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

int SOD(int x) {
  int v = 0;
  while(x) {
    v+=x%10;
    x/=10;
  }
  return v;
}

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

  int N; cin >> N;
  if(N%SOD(N) == 0)cout << "Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[] top={-1,-1,-1};
		for(int i=0;i<10;i++){
			int hight = Integer.parseInt(sc.nextLine());
			for(int j=0;j<3;j++){
				if(top[j]<hight){
                                    int store=top[j];
                                    top[j]=hight;
                                    if(j==0){
                                        hight=top[j+1];
                                        top[j+1]=store;
                                        top[j+2]=hight;
                                    }else if(j==1){
                                        top[j+1]=store;
                                    }
                                    break;
				}
			}
		}
		System.out.println(top[0]);
		System.out.println(top[1]);
		System.out.println(top[2]);
		
	}
}


Measured memory_bytes: 26080
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;

const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;

int n,a[20];

map<pii,LL> dp[20][20];
LL dfs(int l,int r,int tl,int tr)
{
	if(l==r-1)return 0;
	if(dp[l][r].find(mp(tl,tr))!=dp[l][r].end())return dp[l][r][mp(tl,tr)];
	LL ret=Linf;
	for(int m=l+1;m<r;m++)ret=min(ret,dfs(l,m,tl,tl+tr)+dfs(m,r,tl+tr,tr)+(LL)(tl+tr)*a[m]);
	return (dp[l][r][mp(tl,tr)]=ret);
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	printf("%lld\n",dfs(1,n,1,1)+a[1]+a[n]);
	return 0;
}

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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0;i < n;++i) cin >> a[i];
    bool nega = true;
    for (int i = 0;i < n;++i) if (a[i] >= 0) nega = false;
    if (nega) {
        int j = max_element(a.begin(),a.end())-a.begin();
        cout << a[j] << "\n" << n-1 << "\n";
        for (int i = n;i > j+1;--i) cout << i << "\n";
        for (int i = 0;i < j;++i) cout << 1 << "\n";
    } else {
        int la,lb,ra,rb;
        ll x = 0,y = 0;
        for (int i = 0;i < n;i += 2) if (a[i] >= 0) {
            la = i;
            break;
        }
        for (int i = 1;i < n;i += 2) if (a[i] >= 0) {
            lb = i;
            break;
        }
        for (int i = 0;i < n;i += 2) if (a[i] >= 0) {
            ra = i;
            x += a[i];
        }
        for (int i = 1;i < n;i += 2) if (a[i] >= 0) {
            rb = i;
            y += a[i];
        }
        P p = (x > y ? P(la,ra) : P(lb,rb));
        vector<int> b;
        for (int i = n;i > p.second+1;--i) b.push_back(i);
        for (int i = 0;i < p.first;++i) b.push_back(1);
        for (int i = p.first+2;i <= p.second;i += 2) {
            if (a[i] < 0) b.push_back(3);
            else b.push_back(2);
        }
        cout << max(x,y) << "\n" << b.size() << "\n";
        for (int i : b) cout << i << "\n";
    }
    return 0;
}

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

int main() {
  int X,Y;

  cin>>X>>Y;

  if (Y%2==1)
  {
    cout<<"No";

    return 0;
  }

  for (int i = 0; i <= X; i++)
  {
    if (4*(X-i)+2*i==Y)
    {
      cout<<"Yes";

      return 0;
    }
    
    else if (4*(X-i)+2*i<Y)
    {
      cout<<"No";

      return 0;
    }
  } 

  if (2*X>Y)
  {
    cout<<"No";
  }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
	
	long long A,B,M,c,x,y;
	
	cin>>A;
	cin>>B;
	cin>>M;
	
	vector<int> ai(A);
	vector<int> bi(B);
 
    for(int i = 0; i < A; i++) cin>>ai[i];
  	for(int i = 0; i < B; i++) cin>>bi[i];
	
	priority_queue<int, vector<int>, greater<int> >descount;
	
	for(long long k = 0; k < M;k++){
		cin>>x;
		cin>>y;
		cin>>c;
		descount.push(ai[x-1] + bi[y-1] - c);        
	}
	
	int minA = *min_element(ai.begin(),ai.end());
	int minB = *min_element(bi.begin(),bi.end());
	
	int no_descount = minA+minB;
	int descuento = descount.top();
 
	cout<<min(descount.top(),no_descount);
	return 0;
}

Measured memory_bytes: 1660
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int N = in.nextInt();
			System.out.println((int)Math.pow(N, 3));
		}
	}
	
	static boolean permutation_2(String s, String t){
        if(s.length() != t.length()){
            return false;
        }
        
        int[] letters = new int[256]; //文字コードの仮定;
        
        char[] s_array = s.toCharArray();  
        for(char c:s_array){
            letters[c]++;
        }
        
        for(int i=0;i<t.length();i++){
            int c = (int)t.charAt(i);
            if(--letters[c] < 0){
                return false;
            }
        }
        return true;
    }

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

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

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

		public char nextChar() {
			return next().charAt(0);
		}

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

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

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

	}
}


Measured memory_bytes: 21460
N, M = map(int, input().split())
AB = []
for i in range(N):
  AB.append(list(map(int, input().split())))
AB = sorted(AB, key=lambda x:x[0])

cost, num, want = 0, M, M
for i in range(N):
  num = min(want, AB[i][1])
  cost += AB[i][0] * num
  want -= num
  if num == 0:
    break
print(cost)

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

void sort(int n, int a[]) {
	for (int i = 0; i <= n - 2; i++) {
		for (int j = i + 1; j <= n - 1; j++) {
			if (a[i] < a[j]) {
				int temp = a[i];
				a[i] = a[j];
				a[j] = temp;
			}
		}
	}
}

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

	sort(n, a);

	int score_a = 0;
	int score_b = 0;

	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			score_a += a[i];
		}
		else {
			score_b += a[i];
		}
	}

	cout << score_a - score_b << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(long int I=X;I<Y;I++)
#define REP(I,X) for(long int I=X;I>=0;I--)
#define INF 1000000007
using namespace std;

int main(){
  long int N,a;
  cin >> N;
  set<long int> s;
  vector<long int> v;
  FOR(i,0,N){
    cin >> a;
    if(s.count(a)){
      v.push_back(a);
      s.erase(a);
    }
    else s.insert(a);
  }
  sort(v.begin(),v.end());
  if(v.size() < 2)cout << 0 << endl;
  else cout << v[v.size()-1]*v[v.size()-2] << endl;
}


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

// Pow( base, index) return base ** index {{{
// Pow = base ** index ( natural numbers )
long long unsigned int Pow( long long unsigned int base, long long unsigned int index ){
    if( index == 0 ) return 1;
    // O( log(index) )
    if( index % 2 ){
        return base * Pow(base, index - 1);
    }else{
        long long unsigned int Phalf = index / 2;
        long long unsigned int half = Pow(base, Phalf);
        return half * half;
    }
}
// }}}
// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    ll n,k;
    Scll2(n,k);
    ll ans = 0;


    if( k%2 ){
        ans += Pow(n/k,3);
    }else{
        ans += Pow(n/k,3);
        n += k/2;
        ans += Pow(n/k,3);
    }

    printf ("%llu\n", ans);


    return 0;
}



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

int main()
{
    ll n;
    cin >> n;
    
    ll x = n, sum = 0;
    while(x)
    {
        sum += (x%10);
        x/=10;
    }
    if(n % sum == 0)
    {
        cout << "Yes" << endl;
        return 0;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
fn main() {
    let (n,k) = {
        let s = rv::<u64>();
        (s[0]as usize,s[1])
    };
    let a = rv::<u64>();
    let mut x = 0;
    for i in (0..k.next_power_of_two().trailing_zeros()as u64+1).rev() {
        let b=1<<i;
        if x+b>k {continue;}
        let mut c=0;
        for &a in &a { if a&b==0 {
            c+=1;
        }}
        if c>n/2 {
            x|=b;
        }
    }
    println!("{}",a.into_iter().map(|a|a^x).sum::<u64>());
}
fn rl() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s
}
fn rv<T>() -> Vec<T> where T: std::str::FromStr, T::Err: std::fmt::Debug, {
    rl().split_whitespace().map(|x|x.parse::<T>().unwrap()).collect()
}

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

using namespace std;

int main() 
{

    long long int a,b,c,k,cnt =0;
    cin>>a>>b>>c>>k;
    if(k>=a)
    {
        k = k-a;
        cnt=cnt+a;
        if(k>=b)
        {
            k = k-b;
            if(k>=c)
            {
                cnt = cnt-k;
                k = k-c;
                
                cout<<cnt<<endl;
            }
            else cout<<(cnt-(k))<<endl;

        }
        else cout<<a<<endl;
        
    }
    else cout<<k<<endl;


}


Measured memory_bytes: 3624
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s_orig = read::<String>();
    let k = read::<i64>();
    let s = s_orig.chars().collect::<Vec<char>>();
    let mut ib :i64 = 0;
    for i in 0..s_orig.len() {
        ib = i as i64;
        if s[i] != '1' {
            break;
        }
    }

    if k > ib {
        println!("{}", s[ib as usize]);
    } else {
        println!("1");
    }
}

Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n,now;
int main(){
	n=read();m=read();	
	k=1;now=0;
	while(k<m){
		k+=n-1;
		now++;
	}
	printf("%d\n",now);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, D;
  cin >> N >> D;
  
  vector<vector<int>> Xs(N);
  for(int i =0 ; i < N;i ++){
    vector<int> Xi(D);
    for(int j = 0; j < D ; j++){
      cin >> Xi.at(j) ;
    }
    Xs.at(i) = Xi;
  }
  
  int ans = 0;
  for(int i = 0; i < N - 1 ; i++){    
    for(int j = i + 1 ; j < N; j++){
      float len = 0;
      for(int d = 0; d < D; d++){
        len += pow(Xs.at(i).at(d) - Xs.at(j).at(d),2);
      }
      len = sqrt(len);
      if(ceil(len) == floor(len)) ans++; 
    }
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var a = int.Parse(_[0]);
            var b = int.Parse(_[1]);
            var s = a * b;

            Console.WriteLine(s % 2 == 0 ? "No" : "Yes");
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define mp make_pair
#define eb emplace_back

const int MAX_N = 2e5+10;
int N;
ll A[MAX_N];

void solve()
{
	sort(A,A+N,greater<ll>());
	if(N == 2){
		cout << A[0] << '\n';
		return;
	}
	ll ans = A[0];
	int inserted = 2;
	int use = 1;
	while(inserted < N){
		if(inserted == N-1){
			ans += A[use];
			break;
		}
		ans += 2LL*A[use];
		use++;
		inserted += 2;
	}
	cout << ans << '\n';
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N;
	for(int i=0;i<N;++i) cin >> A[i];
	solve();
	return 0;
}


Measured memory_bytes: 5216
import sys
iN,iK = [int(_) for _ in input().split()]
aData = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]

d = {}
for a,b in aData:
    if a in d:
        d[a] += b
    else:
        d[a] = b
iC = 0
for a in sorted(d.keys()):
    iC += d[a]
    if iK <= iC :
        print(a)
        exit()


Measured memory_bytes: 28268
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let p: Vec<i32> = (0..n).map(|_| read()).collect();
    println!("{}", p.iter().sum::<i32>() - p.iter().max().unwrap() / 2);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
//#include<atcoder/all>

using namespace std;
//using namespace atcoder;


int main(){
    long long N,X,M;
    cin>>N>>X>>M;
    set<long long> s;
    long long A=X;
    s.insert(A);
    long long sum=A;
    N--;
    while(N>0){
        A=A*A%M;
        if(s.find(A)!=s.end()){
            long long sum2=A;
            long long c=1;
            long long A2=A;
            while(1){
                A2=A2*A2%M;
                if(A2==A) break;
                c++;
                sum2+=A2;
                //cout<<c<<","<<sum2<<endl;
            }
            sum+=sum2*(N/c);
            //cout<<N<<","<<c<<","<<sum2<<endl;
            N%=c;
            s.clear();
            if(N==0) break;
        }
        s.insert(A);
        sum+=A;
        //cout<<A<<endl;
        N--;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 5912
N = int(input())
A, B = [0]*N, [0]*N
for i in range(N):
    A[i], B[i] = map(int, input().split())

ans = 0
for i in range(N):
    now = N-i-1
    ans += (B[now] - (A[now] + ans) % B[now]) % B[now]

print(ans)


Measured memory_bytes: 10868
#include <iostream>
#include <vector>
#include <map>

using namespace std;

void primals(int x, vector<int> &ret){
  for (int i=2; i<=x; i++){
    if (ret.size() == 0) ret.push_back(i);
    else{
      bool f = true;
      for (int p : ret){
        if (i % p == 0){
          f = false;
          break;
        }
      }
      if (f) ret.push_back(i);
    }
  }
  return;
}
      

void calc_all_divisor(int x, map<int, int> &ret, vector<int> &primals){
  int c = 0;
  while (c < primals.size()){
    if (x % primals[c] != 0){
      c++;
    }
    else {
      ret[primals[c]]++;
      x = x / primals[c];
    }
  }
  return;
}
    

int main(){
  int N;
  cin >> N;
  vector<int> P;
  primals(N, P);

  map<int, int> divisor;
  for (int i=2; i<=N; i++){
    calc_all_divisor(i, divisor, P);
  }
  for (auto e : divisor) cerr << e.first << " " << e.second << "\n";
  int N3 = 0, N5 =0, N15 = 0, N25= 0, N75 = 0;
  for (auto e : divisor){
    if (e.second >= 75 - 1) N75++;
    if (e.second >= 25 - 1) N25++;
    if (e.second >= 15 - 1) N15++;
    if (e.second >= 5 - 1) N5++;
    if (e.second >= 3 - 1) N3++;
  }
  int ans = 0;
  ans += N75;
  ans += N25 * max(0, N3 - 1);
  ans += N15 * max(0, N5 - 1);
  ans += N5 * max(0, N5 - 1) * max(0, N3 - 2) / 2;
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#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 show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n = in();
  vi v(n);
  rep(i,n) cin >> v[i];
  vi c(n);
  rep(i,n) cin >> c[i];

  int ans = 0;
  rep(i,n) {
    ans += max(0, v[i]-c[i]);
  }

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

Measured memory_bytes: 256
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007
#define MAX_TIME 100001

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

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

    bool is_used[c][MAX_TIME];
    rep(i, c)
    {
        fill(is_used[i], is_used[i] + MAX_TIME, false);
    }

    rep(i, n)
    {
        int s, t, c_i;
        cin >> s >> t >> c_i;
        c_i--;
        for (int i = s; i <= t; i++)
        {
            is_used[c_i][i] = true;
        }
    }

    int ans = 0;
    rep(i, MAX_TIME)
    {
        int tmp = 0;
        rep(j, c)
        {
            if (is_used[j][i])
                tmp++;
        }
        ans = max(ans, tmp);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3200
#include<iostream>
#include<string>

int main()
{
std::string str;
std::cin>>str;
if(str.size()<4||str[0]!='Y'||str[1]!='A'||str[2]!='K'||str[3]!='I')
{
std::cout<<"No"<<std::endl;
}
else
{
std::cout<<"Yes"<<std::endl;
}
}

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


int main(){
  
  string t; cin>>t;
  ll a{};
  for(auto i:t){
    a += i-'0';
    a %= 9;
  }
  if(a==0){
    cout<<"Yes"<<endl;
    
  }
  
  else cout<<"No"<<endl;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int a=0,b=0;
  for(int i=0;i<s.size();i++){
    (s[i]=='g'?a:b)++;
  }
  cout<<(a-b)/2<<endl;
  return 0;
}


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

/*
ll gcds(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    ll r=a%b;
    if(r==0){
        return b;
    }
    while(r>0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}


ll lcms(ll a,ll b){
    ll mmr=gcds(a,b);
    a=a/mmr;
    b=b/mmr;
    return a*b*mmr;
}
*/

int main(){
    ll N,K;
    cin>>N>>K;
    vector<ll> H(N);
    for(ll i=0;i<N;i++){
        cin>>H.at(i);
    }
    sort(H.begin(),H.end());
    reverse(H.begin(),H.end());
    ll tasu=0;
    for(ll i=K;i<N;i++){
        tasu+=H.at(i);
    }
    cout<<tasu<<endl;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int n; cin >> n;
  vi32 a(n); cin >> a;

  vi64 sums(n + 1);
  rep(i, n) sums[i + 1] = sums[i] + a[i];

  function<i64(int, int, int)> dist = [&](int l, int m, int r) {
    return abs((sums[r] - sums[m]) - (sums[m] - sums[l]));
  };

  i64 ans = 1e18;
  for (int l = 1, m = 2, r = 3; m + 2 <= n; m++) {
    while (dist(0, l, m) > dist(0, l + 1, m)) {
      l++;
    }
    while (dist(m, r, n) > dist(m, r + 1, n)) {
      r++;
    }
    pair<i64, i64> s = minmax({
      sums[l] - sums[0],
      sums[m] - sums[l],
      sums[r] - sums[m],
      sums[n] - sums[r],
    });
    amin(ans, s.second - s.first);
  }
  cout << ans << '\n';
}


Measured memory_bytes: 2560
# abc079_b.py
# 基本はフィボナッチ数列のメモ化再帰と同じ形で解く。
# いい勉強になるので何度も解きたい問題

def calc_luca(n):
    if n==0:
        return luca[0]
    if n==1:
        return luca[1]
    if luca[n]!=0:
        return luca[n]
    luca[n] = calc_luca(n-1) + calc_luca(n-2)
    return luca[n]
N = int(input())
luca = [0]*(N+1)
luca[0] = 2
luca[1] = 1
print(calc_luca(N))
#print(luca)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

//初項1，末項n，項数nの数列の和を求める
long long int series_sum(long long int n){
    return n*(n+1)/2;
}

int main(){
    string s;
    cin>>s;
    int d=0,m=0,p=0,l=0,r=0;
    ll ans=0;
    vector<int> vec;
    rep(i,s.length()){
        if(d==0&&s[i]=='>'){
            m++;
        }else if(d==1&&s[i]=='<'){
            p++;
        }else if(d==0&&s[i]=='<'){
            d=1;
            vec.push_back(-m);
            p=1;
            m=0;
        }else if(d==1&&s[i]=='>'){
            d=0;
            vec.push_back(p);
            p=0;
            m=1;
        }
    }
    if(p!=0)vec.push_back(p);
    if(m!=0)vec.push_back(-m);
    for(int i=0;i<vec.size();i++){
        if(i==0){
            if(vec[i]<0){
                ans+=series_sum(-vec[i]);
            }
            if(vec[i]>0){
                ans+=series_sum(vec[i]-1);
                ans+=max(vec[i],-vec[i+1]);
            }
        }else{
            if(vec[i]<0){
                ans+=series_sum(-vec[i]-1);
            }
            if(vec[i]>0){
                ans+=series_sum(vec[i]-1);
                if(i+1<vec.size())ans+=max(vec[i],-vec[i+1]);
                else ans+=vec[i];
            }
        }
    }
    out(ans);
}


Measured memory_bytes: 5236
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A>> B>> C>>D;
  if ((A+B)>(C+D))
    cout << "Left" << endl;
  else if ((A+B)==(C+D))
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
}

Measured memory_bytes: 3596
use std::io::{self, BufReader, Read};
use std::str::FromStr;
use std::string::String;

fn main() {
	let mut sc = ::Scanner::new(io::stdin());
	let mut n: i32 = sc.next_as().unwrap();
	let mut v: Vec<char> = vec![];
	let mut base = 1i32;
	while n != 0 {
		if base.abs() & n.abs() != 0 {
			v.push('1');
			n -= base;
		} else {
			v.push('0');
		}
		base *= -2;
	}
	if v.is_empty() {
		v.push('0');
	}
	let mut ans = String::new();
	for c in v.iter().rev() {
		ans.push(*c);
	}
	println!("{}", ans);
}

#[derive(Debug)]
pub struct Scanner<R> {
	reader: BufReader<R>
}

impl<R: io::Read> Scanner<R> {
	
	pub fn new(read: R) -> Scanner<R> {
		Scanner { reader: BufReader::new(read) }
	}

	pub fn next_str(&mut self) -> Option<String> {
		let mut buf = [0; 1];
		let size = self.reader.read(&mut buf).unwrap();
		if size == 0 {
			None{}
		} else {
			let first = self.skip_whitespace(&mut buf);
			if first.is_none() {
				return None{}
			}
			let mut v = vec![buf[0]];
			loop {
				let size = self.reader.read(&mut buf).unwrap();
				if size == 0 || char::from(buf[0]).is_whitespace() {
					break;
				}
				v.push(buf[0]);
			}
			Some(String::from_utf8(v).unwrap())
		}
	}

	pub fn next_line(&mut self) -> Option<String> {
		let mut buf = [0; 1];
		let mut v :Vec<u8> = vec![];
		let mut size = self.reader.read(&mut buf).unwrap();
		if size == 0 {
			return None{}
		}
		loop {
			if size == 0 || char::from(buf[0]) == '\n' {
				return Some(String::from_utf8(v).unwrap())
			}
			v.push(buf[0]);
			size = self.reader.read(&mut buf).unwrap();
		}
	}

	pub fn next_vec<S: FromStr>(&mut self, size: u32) -> Vec<S> {
		let mut v: Vec<S> = vec![];
		for _ in 0..size {
			let token = self.next_str().unwrap();
			v.push(S::from_str(&token).ok().unwrap());
		}
		v
	}

	pub fn next_as<S: FromStr>(&mut self) -> Option<S> {
		if let Some(s) = self.next_str() {
			if let Ok(v) = S::from_str(&s) {
				return Some(v)
			}
		}
		None{}
	}

	pub fn next_i32(&mut self) -> Option<i32> {
		self.next_as::<i32>()
	}

	pub fn next_i64(&mut self) -> Option<i64> {
		self.next_as::<i64>()
	}

	pub fn next_f32(&mut self) -> Option<f32> {
		self.next_as::<f32>()
	}

	pub fn next_f64(&mut self) -> Option<f64> {
		self.next_as::<f64>()
	}

	fn skip_whitespace(&mut self, mut buf: &mut [u8]) -> Option<u8> {
		loop {
			if !char::from(buf[0]).is_whitespace() {
				return Some(buf[0])
			}
			let size = self.reader.read(&mut buf).unwrap();
			if size == 0 {
				return None{}
			}
		}
	}
}


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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n;
	cin >> n;
	VI a(n);
	for(auto& i: a) cin >> i;
	sort(ALL(a));
	LL ans = 0;
	FOR(i, 0, n) FOR(j, i + 1, n)
	{
		int cnt_notok = n - (lower_bound(ALL(a), a[i] + a[j]) - a.begin());
		ans += n - 1 - j - cnt_notok;
	}
	
	cout << ans << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>

using namespace std;
int main() {
	int n, a[200000], b[200000];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(b, b + n);
	for (int i = 0; i < n; i++) {
		if (a[i] == b[n - 1]) {
			cout << b[n - 2] << endl;
		}
		else {
			cout << b[n - 1] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3200
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <queue>
#include <limits>
#include <deque>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define MN 0LL
#define Mx 200000005
#define Mn -Mx
#define MX 20000000000000005
using namespace std;
int readint(){
	char c;
	while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	bool flag=(c=='-');
	if(flag)c=getchar();
	int x=0;
	while(c>='0'&&c<='9'){
		x=x*10+c-48;
		c=getchar();
	}
	return flag?-x:x;
}
inline string tos(int x){
	string s;
	while(x) s=(char)(x%10+'0')+s,x/=10;
	return s;
}
long long a[5005];
int main(){
	ios_base::sync_with_stdio(false);
	long long i,j,n,x,t,ans=0;
	cin>>n>>x;
	for(i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
//	reverse(a,a+n);
	for(i=0;i<n;i++){
		t=x;
		for(j=n-1;j>-1;j--){
			if(i!=j){
				if(t>a[j]) t-=a[j];
			}
		}
		if(t>a[i]) ans++;
	} 
	cout<<ans<<endl;
	return 0;
}


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

int main() {
    string s;
    cin >> s;
    vector<int> indice;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != 'x')
            indice.push_back(i);
    }

    if (indice.size() == 0) {
        cout << 0 << endl;
        return 0;
    }
    for (int l = 0, r = indice.size() - 1; l < r; l++, r--) {
        if (s[indice[l]] != s[indice[r]]) {
            cout << -1 << endl;
            return 0;
        }
    }

    vector<int> x_count;
    int count = 0;
    for (char c: s) {
        if (c == 'x') {
            count++;
        } else {
            x_count.push_back(count);
            count = 0;
        }
    }
    x_count.push_back(count);

    int ans = 0;
    for (int l = 0, r = x_count.size() - 1; l < r; l++, r--) {
        ans += abs(x_count[l] - x_count[r]);
    }

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



Measured memory_bytes: 1528