akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define FAST ios_base::sync_with_stdio(false);cin.tie(0);
    const double EPS = 1e-9;
    const double PI = acos(-1);
    const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
    //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
    //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
    const int dx[] = {0 , 1 , 0 , -1};
    const int dy[] = {1 , 0 , -1 , 0};
    //#define MOD         1000000007LL
    #define MAX         2000015
    const ll MOD = 1000000000 + 7;
    
    int parent[MAX],sz[MAX];
    
    int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

    void make_set(int v) {
    parent[v] = v;
    sz[v] = 1;
    }
    
    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }
    int main()
    {
        FAST
        int t;
        t = 1;

        while(t--)
        {
           int n , k;
           cin >> n >> k;
           
           for(int i = 1 ; i <= n ; i++)make_set(i);
           
           for(int i = 1 ; i <= k ; i++)
           {
               int a , b;
               cin >> a >> b;
               union_sets(a , b);
           }
           int mx = -1;
           for(int i = 1 ; i <= n ; i++)mx = max(mx , sz[i]);
           
           cout << mx << endl;
        }
    }



Measured memory_bytes: 5188
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    string s;
    cin >> s;
    int yy = (s[0] - '0') * 10 + (s[1] - '0');
    int mm = (s[2] - '0') * 10 + (s[3] - '0');

    if (0 < yy && yy <= 12 && 0 < mm && mm <= 12) {
        std::cout << "AMBIGUOUS" << std::endl;
    } else if (0 < yy && yy <= 12 && (12 < mm || mm == 0)) {
        std::cout << "MMYY" << std::endl;
    } else if (0 < mm && mm <= 12 && (12 < yy || yy == 0)) {
        std::cout << "YYMM" << std::endl;
    } else {
        std::cout << "NA" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	//"sort"
	//"strconv"
)
func min(c int64,b int64) int64{
	if c>b{
		return c;
	}else{
		return b;
	}
}
func abs(c int64) int64{
	if c<0{
		c*=-1;
	}
	return c;
}
func main(){
	var n,i,j int64;
	fmt.Scan(&n);

	a := []int64{};
	for i=0;i<n;i++{
		var k int64;
		fmt.Scan(&k);
		a = append(a,k);
	}
	var ans int64;
	ans = abs(a[0]-a[1]);
	for i = 0; i < n; i++ {
		for j = 0; j < n; j++ {
			if i==j{continue;}
			ans = min(ans,abs(a[i]-a[j]))
		}
	}
	fmt.Println(ans)
}

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

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

#define READ(x) (cin >> (x))

#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))

int main() {
    // get values from input
    cin.tie(0);
    ios::sync_with_stdio(false);

    int A, B, C, D;
    cin >> A >> B >> C >> D;
    // main procedure
    int ttk_1 = ceil((double)C / (double)B);
    int ttk_2 = ceil((double)A / (double)D);

    bool can_win = ttk_1 <= ttk_2;

    // output
    WRITE_N(can_win ? "Yes" : "No");

    return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector<int64_t> a(N);
  for(int i=0;i<N;++i){
    cin>>a.at(i);
  }

  int64_t count=1;
  bool frag=false;
  int64_t ans=0;
  for(int i=0;i<N;++i){
    int j=i;
    while(j<N && a.at(j)!=count){
      ++j;
    }
    if(j==N && count==1){
      ans=-1;
      break;
    }
    else{
      ans += (j-i);
    }
    i=j;
    ++count;
  }

  cout<<ans<<endl;
}

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

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}


long long power(long long x, long long n){
	long long ans = 1;
	for(;n;n>>=1,x*=x,ans%=MOD,x%=MOD)
		if(n&1)ans*=x;
	return ans%MOD;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, ans = 0, u = 1;
	vector<int> x, p, con;
	
	cin>>N;
	
	x.resize(N);
	con.resize(N+1);
	
	for(int i = 0; i < N; i++){
		cin>>x[i];
		if(i) p.push_back(i);
	}
	
	for(int i = 1; i < N; i++){
		u *= i;
		u %= MOD;
	}
	
	// do {
		// vector<int> z(N+1, true);
		
		// for(int i = 0; i < N-1; i++){
			// z[p[i]] = false;
			// int y = p[i];
			
			// while(true){
				// con[y]++;
				// y--;
				// if(z[y]) break;
			// }
		// }
		
	// } while(next_permutation(p.begin(), p.end()));
	
	int o = u, ans2 = 0;
	for(int i = 1; i < N; i++){
		ans2 += (x[i] - x[i-1]) * o %MOD;
		ans2 %= MOD;
		// cout<<o<<endl;
		o += u* power(i+1, MOD-2);
		o %= MOD;
	}
	
	/*
	for(int i = 0; i <= N; i++){
		cout<<"i = "<<i<<" con = "<<con[i]<<endl;
		cout<<"i = "<<i<<" uuu = "<<o<<endl;
		// cout<<u/(i+2)<<endl;
		o += u/(i+2);
		
		ans += (x[i] - x[i-1]) * o;
	}
	
	for(int i = 1; i < N; i++){
		ans += (x[i] - x[i-1]) * con[N-i];
	}
	*/
	cout<<ans2<<endl;
	
	return 0;
}

Measured memory_bytes: 2936
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0);
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
	ll r=1;
	a=a%m;
	while(b>0)
	{
	if(b&1)
		r=(r*a)%m;
	b=b/2;
	a=(a*a)%m;
	}
	return r%m;
}

int main() {
   ll a,b; cin>>a>>b;
   if((a==1&&b==2)||(a==2&&b==1))cout<<3<<endl;
   else if((a==2&&b==3)||(a==3&&b==2))cout<<1<<endl;
   else cout<<2<<endl;
   return 0;
}
/*

*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef long long int ll;
typedef double lf;
const int maxn=505;
int n,a,b,c;
lf dp[maxn][maxn][2];
int tong[5];
int main(){
	cin>>n;//>>a>>b>>c;
	rep(i,1,n){
		int x;scanf("%d",&x);
		tong[x]++;
	}
	a=tong[1];b=tong[2];c=tong[3];
	int p=0;
	rep(k,0,c){
		rep(j,0,n)rep(i,0,n)if(i+j+k<=n){
			dp[i][j][p]=i||j||k?1:0;
			if(i)dp[i][j][p]+=dp[i-1][j][p]*i/n;
			if(j)dp[i][j][p]+=dp[i+1][j-1][p]*j/n;
			if(k)dp[i][j][p]+=dp[i][j+1][p^1]*k/n;
			if(i||j||k)dp[i][j][p]=dp[i][j][p]*n/(i+j+k);
		}
		//rep(i,0,n){rep(j,0,n)cout<<dp[i][j][p]<<"\t";;cout<<endl;}
		//cout<<endl<<endl;
	p^=1;}
	printf("%.10lf",dp[a][b][p^1]);
	return 0;}

Measured memory_bytes: 2176
# 18:32 18:46
a, b, c, x, y = map(int, input().split())

#mxy = max(x, y)
#sxy = min(x, y)
#sum = 0
# if a+b-2*c > 0:
#    sum += c*min(x, y)*2
#    if x > y and a < 2*c:
#        sum += (max(x, y)-min(x, y))*a
#    elif x > y:
#        sum += (max(x, y)-min(x, y))*2*c
#    elif x <= y and a < 2*c:
#        sum += (max(x, y)-min(x, y))*b
#    elif x <= y:
#        sum += (max(x, y)-min(x, y))*2*c
# else:
#    sum = a*x+b*y
# print(sum)
#
amin = a*x+b*y
sum = 0
for i in range(0, max(x, y)*2+1, 2):
    sum = (x-i//2 if x-i//2 > 0 else 0)*a+(y-i//2 if y-i//2 > 0 else 0)*b+c*i
    if sum < amin:
        amin = sum
print(amin)

Measured memory_bytes: 3064
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

#n = int(input)
#h,w = [int(i) for i in readline().split()]
n,k,s = [int(i) for i in read().split()]

ans = [s]*k + [s+1 if s < 10 else s-1]*(n-k)
print(*ans)


Measured memory_bytes: 6524
#include <iostream>
using namespace std;
int main(void){
 int i=0,j,k,tlen,slen=0,stlen=0;
 string s;
 cin >> s;
 for(;(s[i]=='T')&&(i<s.length());i++){}
 while(i<s.length()){
  j=i;
  for(;(s[i]=='S')&&(i<s.length());i++){}
  slen+=i-j;
  k=i;
  for(;(s[i]=='T')&&(i<s.length());i++){}
  tlen=i-k;
  if(slen>tlen){
   stlen+=tlen*2;
   slen=slen-tlen;
  }else{
   stlen+=slen*2;
   slen=0;
  }
 }
 cout << s.length()-stlen;
}

Measured memory_bytes: 640
from itertools import accumulate
from bisect import bisect_right

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = [0] + list(accumulate(A))
b = [0] + list(accumulate(B))

ans = 0
for i in range(N + 1):
    if a[i] > K:
        break
    j = bisect_right(b, K - a[i]) - 1
    ans = max(ans, i + j)

print(ans)

Measured memory_bytes: 50628
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def tsum(l, r):
    return (r + l) * (r - l + 1) // 2

def solve():
    n = II()

    ans = tsum(1, n-1)
    print(ans)



if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;


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

	int R;
	cin >> R;
	cout << fixed << setprecision(10);
	cout << 2* R * 3.14159265 << endl;
}

Measured memory_bytes: 3752
class Selection_sort:
    def __init__(self):
        self.swap_num=0
    
    def sort(self,data):
        for i in range(len(data)):
            mini=i
            for j in range(i+1,len(data)):
                if(data[j][1] < data[mini][1]):
                    mini=j
            if(mini!=i):
                data[i],data[mini]=data[mini],data[i]
                self.swap_num+=1


class Bubble_sort:
    def __init__(self):
        self.swap_num=0
    
    def sort(self,list):
        for i in range(len(list)):
            for j in range(i+1,len(list))[::-1]:
                if(list[j][1] < list[j-1][1]):
                    list[j],list[j-1]=list[j-1],list[j]
                    self.swap_num+=1


def stability_judge(sorted,original):
    n=len(sorted)
    j=-1
    x=sorted[0][1]
    for i in range(n):
        if(x!=sorted[i][1]):
            x=sorted[i][1]
            j=-1
        
        while(1):
            j+=1
            if(x==original[j][1]):
                if(sorted[i][0]!=original[j][0]):
                    return 0
                else:
                    break
    return 1


def cards_print(cards):
    newcards=[]
    for card in cards:
        card[1]=str(card[1])
    newcards=["".join(card) for card in cards]    
    print(" ".join(newcards))




n=int(input())
cards=[list(str) for str in input().split()]
for card in cards:
    card[1]=int(card[1])

b_cards=[i for i in cards]
s_cards=[i for i in cards]


bubble_sort=Bubble_sort()
bubble_sort.sort(b_cards)
#x=stability_judge(b_cards,cards)
cards_print(b_cards)

if(stability_judge(b_cards,cards)):
    print("Stable")
else:
    print("Not stable")



selection_sort=Selection_sort()
selection_sort.sort(s_cards)
cards_print(s_cards)
if(stability_judge(s_cards,cards)):
    print("Stable")
else:
    print("Not stable")


Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
long long s, sm;
const long long MOD = 1e9+7;
long long dp[2001][2001];	
void add(long long& x, long long y) {
	x += y;
	if (x > MOD) x -= MOD;
}
int main() {
	ios_base::sync_with_stdio(NULL);
	cin.tie(nullptr); cout.tie(nullptr);
	cin >> s;
	for (int i = 3; i <= s; i++) dp[1][i]=1;
	for (int i = 2; i <= s/3; i++) 
		for (int j = 3 * i; j <= s; j++) 
			for (int d = 3; d <= j; d++) 
				add(dp[i][j], dp[i - 1][j - d]);
	for (int i = 1; i <= s/3; i++) add(sm, dp[i][s]);
	cout << sm;
}

Measured memory_bytes: 11132
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
typedef long long ll;
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif
#define LAR(a, b) ((a)=max((a), (b)))
#define SML(a, b) ((a)=min((a), (b)))

int a[200]={};

int main(){
	int n, x; scanf("%d%d", &n, &x);
	REP(i, n){
		int b; scanf("%d", &b);
		a[i+1]=a[i]+b;
	}
	int ans = 0;
	REP(i, n+1) if(a[i]<=x) ans++;
	printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll X;
	cin >> X;
	ll x = 100;
	for (int y = 1; ; ++ y) {
		x += x/100;
		if (x >= X) {
			cout << y << endl;
			break;
		}
	}
}


Measured memory_bytes: 3620
import java.util.*;

class Main
{
   public static void main(String[] args)
   {
        Scanner sc = new Scanner(System.in);
	String input = sc.nextLine();
	String[] inputArray = input.split(" ");

	if(inputArray.length == 3){
		int a = Integer.parseInt(inputArray[0]);
		int b = Integer.parseInt(inputArray[1]);
		int c = Integer.parseInt(inputArray[2]);
		if(a < b && b < c){
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
   }
}

Measured memory_bytes: 26172
n = list(input())
time = 100
ans = 0
for i in range(len(n)):
	if n[i] == '1':
		ans += 9 * time
	elif n[i] == '9':
		ans += 1 * time 
	else:
		ans += int(n[i])*time
	time /= 10

print(int(ans))

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	int count=0,n=0;
	char a[5000],b[5000];
	gets(a);



	for(n=0;n<5000;n++)
	{
		if(count>=5)
		{
			b[n-5]='\0';
		}
		
		if(a[n]>='A'&&a[n]<='Z')
		{
			b[n]=a[n]+32;
			count=0;
		}
		
		else if(a[n]>='a'&&a[n]<='z')
		{
			b[n]=a[n]-32;
			count=0;
		}
	
		else if(a[n]==',')
		{
			b[n]=',';
		}
		else if(a[n]==' ')
		{
			b[n]=' ';
			count++;
		}
		else if(a[n]=='.')
		{
			b[n]='.';
		}

		else
		{
			b[n]=a[n];
		}
		
	}
	puts(b);
return 0;


}

Measured memory_bytes: 524
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int s[maxn],t[maxn],x[maxn],d[maxn],id[maxn];
int tr[maxn<<2],lazy[maxn<<2];
void push_down(int id)
{
    if(lazy[id]!=-1){
        tr[id<<1] = tr[id<<1|1] = lazy[id<<1] = lazy[id<<1|1] = lazy[id];
        lazy[id] = -1;
    }
}
void build(int id,int l,int r)
{
    tr[id] = -1,lazy[id] = -1;
    if(l==r) return;
    int mid = (l+r)>>1;
    build(id<<1,l,mid);build(id<<1|1,mid+1,r);
}
void update(int id,int stl,int str,int l,int r,int k)
{
    if(stl==l && str==r){
        tr[id] = k;
        lazy[id] = k;
        return ;
    }
    push_down(id);
    int mid = (stl+str)>>1;
    if(r<=mid) update(id<<1,stl,mid,l,r,k);
    else if(l>mid) update(id<<1|1,mid+1,str,l,r,k);
    else update(id<<1,stl,mid,l,mid,k),update(id<<1|1,mid+1,str,mid+1,r,k);
}
int query(int id,int stl,int str,int pos)
{
    if(stl == str) return tr[id];
    push_down(id);
    int mid = (stl+str)>>1;
    if(pos<=mid) return query(id<<1,stl,mid,pos);
    else return query(id<<1|1,mid+1,str,pos);
}
int main()
{
    fastio();
    int n,q;
    cin>>n>>q;
    rep(i,1,n) cin>>s[i]>>t[i]>>x[i];
    rep(i,1,q) cin>>d[i];
    build(1,1,q);
    rep(i,1,n) id[i] = i;
    sort(id+1,id+n+1,[](int a,int b){return x[a]<x[b];});
    per(i,n,1){
        int L = lower_bound(d+1,d+q+1,s[id[i]]-x[id[i]]) - d;
        int R = lower_bound(d+1,d+q+1,t[id[i]]-x[id[i]]) - d - 1;
        if(R<L || R==0) continue;
        update(1,1,q,L,R,x[id[i]]);
    }
    rep(i,1,q){
        cout<<query(1,1,q,i)<<endl;
    }
    return 0;
}


Measured memory_bytes: 11600
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //NOTE: <a> must be sorted in advance

lng power(lng b, lng n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n

const int MOD = 1000000007; //10^9+7


/*********** variables ************/
int W, a, b;
/**********************************/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> W >> a >> b;
    int d = max(b-a-W, a-b-W);
    cout << max(0, d) << endl;
}


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

def answer(n: int, m: int, x: int, a:list) -> int:
    left = 0
    right = 0
    for i in a:
        if i < x:
            left += 1
        else:
            right += 1
    return min(left, right)

print(answer(n, m, x, a))

Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(int i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(int i=x;i<=y;i++)
#define INF 1000000000005
using namespace std;

ll n,m,ar[N],sum,tut[N];

lli p[N];

int main()
{
	fast;
	cin>>n;
	fo(i,1,n)
	cin>>p[i].fi,p[i].se=i;
	sort(p+1,p+n+1);
	fo(i,1,n)
	cout<<p[i].se<<sp;

}



/*     cd onedrive\desktop\kod
cls

Sinav:21-22 aralik
Aciklama: Muhtemelen 25 aralik
*/

Measured memory_bytes: 2432
using System;

namespace ABC105
{
    class TaskC
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string ans = "";
            if(n==0){
                Console.WriteLine("0");
                return;

            }
            while (n != 0)
            {
                if (n % 2 != 0)
                {
                    ans = "1" + ans;
                    n = n - 1;
                }
                else
                {
                    ans = "0" + ans;
                }
                n /= -2;
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
f=0
    # n=int(input())
    # a=list(map(int,input().split()))
    # c,d=map(int,input().split())
    
s,w=map(int,input().split())
if(s<=w):
    print("unsafe")
else:
    print("safe")





# print("Yes" if f==1 else "No")

Measured memory_bytes: 61564
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

std::vector<std::vector<std::pair<LL, LL>>>G;
std::vector<LL>dist;

void dfs(LL v, LL p, LL d)
{
	if (dist[v] != -1) return;
	dist[v] = d;
	for (auto e : G[v])
	{
		if (e.first != p) dfs(e.first, v, d + e.second);
	}
}

int main()
{
	LL N;
	in >> N;
	std::vector<LL>u(N - 1), v(N - 1), w(N - 1);
	rep(i, N - 1) in >> u[i] >> v[i] >> w[i];

	std::vector<LL>ans(N + 1);
	G.resize(N + 1); dist.resize(N + 1, -1);
	rep(i, N - 1)
	{
		G[u[i]].push_back(std::pair<LL, LL>(v[i], w[i]));
		G[v[i]].push_back(std::pair<LL, LL>(u[i], w[i]));
	}
	dfs(1, -1, 0);
	for (LL i = 1; i <= N; ++i) ans[i] = dist[i] % 2;

	for (LL i = 1; i <= N; ++i) out << ans[i] << std::endl;
}


Measured memory_bytes: 12928
import java.util.*;

public class Main {
    static final int MOD = 998244353;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] counts = new int[100001];
		int max = 0;
		for (int i = 0; i < n; i++) {
		    int x = sc.nextInt();
		    if (i == 0 ^ x == 0) {
		        System.out.println(0);
		        return;
		    }
		    max = Math.max(x, max);
		    counts[x]++;
		}
		long ans = 1;
		for (int i = 1; i <= max; i++) {
		    ans *= pow(counts[i - 1], counts[i]);
		    ans %= MOD;
		}
		System.out.println(ans);
	}
	
	static long pow(long a, long b) {
	    long x = 1;
	    for (int i = 0; i < b; i++) {
	        x *= a;
	        x %= MOD;
	    }
	    return x;
	}
}


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

int main(void){

  string str;
  char ch = 'a';
  int charaarray[26] = {};

  while(getline(cin,str)){
    for ( int i = 0 ; str[i] != '\0' ; i++){

      if ( (str[i] >= 'a') && (str[i] <= 'z')){
        charaarray[str[i] - 'a']++;
      }else if ( (str[i] >= 'A') && (str[i] <= 'Z')){
        charaarray[str[i] - 'A']++;
      }
    }
  }

  for (int i = 0 ; i < 26 ; i++){
    cout << ch++ << " : " << charaarray[i] << endl;
  }  
}

Measured memory_bytes: 3188
#include <set>
#include <cstdio>
#include <vector>
#include <cassert>
#include <cstring>
#include <algorithm>
#define meow(args...) fprintf(stderr, args)
const int N=2e5+5;
int n, k, p[N], bit[N], fl[N], lg[N];
std::set<int> heapl;
std::set<int, std::greater<int>> heapr;
std::vector<int> list[N];
std::pair<int, int> pos[N];
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar(), c-'0'>9&c!='-');
	for(a=(b=c=='-')?0:c-'0'; (c=getchar()-'0')<=9; a=a*10+c);
	return b?-a:a;
}
int main() {
	int (*rd)()=read<int>;
	n=rd(), k=rd();
	std::generate(p, p+n, rd);
	for(int i=1; i<=n; ++i) bit[i]=n;
	for(int i=n; i--; ) {
		int fl=n;
		for(int j=p[i]+1; j; j&=j-1) cmin(fl, bit[j]);
		for(int j=p[i]+1; j<=n; j+=j&-j) cmin(bit[j], i);
		if(fl!=n) list[fl].push_back(i);
	}
	for(int i=0; i<k; ++i) for(int j: list[i]) heapl.insert(j);
	heapl.insert(n);
	for(int i=0; i<=n-k; ++i) {
		while(*heapl.begin()<i) heapl.erase(heapl.begin());
		pos[i].first=*heapl.begin();
		if(i+k<n) for(int j: list[i+k]) heapl.insert(j);
	}
	for(int i=1; i<=n; ++i) bit[i]=-1;
	for(int i=0; i<=n; ++i) list[i].clear();
	heapr.insert(-1);
	for(int i=0; i<n; ++i) {
		int lg=-1;
		for(int j=p[i]+1; j<=n; j+=j&-j) cmax(lg, bit[j]);
		for(int j=p[i]+1; j; j&=j-1) cmax(bit[j], i);
		if(lg!=-1) list[lg].push_back(i);
	}
	for(int i=n-k+1; i<n; ++i) for(int j: list[i]) heapr.insert(j);
	for(int i=n-k; i>=0; --i) {
		for(int j: list[i]) heapr.insert(j);
		while(*heapr.begin()>=i+k) heapr.erase(heapr.begin());
		pos[i].second=*heapr.begin();
	}
	std::sort(pos, pos+n-k+1);
	printf("%d\n", (int)(std::unique(pos, pos+n-k+1)-pos));
	return 0;
}


Measured memory_bytes: 32256
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>

using namespace std;

int main()
{
    double r,s;
    double pi=3.141;
    cin>>r;
    s=2*pi*r;
    cout<<s<<endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 2;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld DINF = 1e12;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

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

  string s;
  cin >> s;
  Yes(s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi");
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

void trace(int A[], int N) {
  int i;
  for ( i = 0; i < N; i++ ) {
    if ( i > 0 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

void insertSort(int A[], int N) {
  int j, i, v;
  for ( i = 1; i < N; i++ ) {
    v = A[i];
    j = i - 1;
    while ( j >= 0 && A[j] > v ) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;
    trace(A, N);
  }
}

int main() {
	int N, i, j;
  int A[100];

  scanf("%d", &N);
  for ( i = 0; i < N; i++ ) scanf("%d", &A[i]);

  trace(A, N);
  insertSort(A, N);

  return 0;
}



Measured memory_bytes: 2712
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  ll k;
  cin>>n >> k;
  map<ll,ll>mp;
  rep(i,n){
    ll a,b;
    cin>>a>>b;
    mp[a]+=b;
  }
  ll cnt = 0;
  for(auto it:mp){
    cnt+=it.se;
    if(cnt>=k){
      cout<<it.fi<<endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 4224
import itertools
import math

N=int(input())
x=[]
y=[]

for _ in range(N):
    x1,y1=map(int,input().split())
    x.append(x1)
    y.append(y1)
    

conut=[i for i in range(N)]
conb=itertools.permutations(conut, N)
total=0
for n,c in enumerate(conb):
    for i in range(N-1):
        n1=c[i]
        n2=c[i+1]
        h=math.sqrt((x[n1]-x[n2])**2 + (y[n1]-y[n2])**2)
        total+=h

print(total/(n+1))




Measured memory_bytes: 3064
#include<stdio.h>
int main(){
  int w,h,i,j,d[510][510],max,u[510],r,s[510],k;
  char m[510][510];
  while(scanf("%d %d",&h,&w),w||h){
    for(i=0;i<h;i++){
      scanf("%s",m[i]);
      for(j=r=0;j<w;j++){
	if(m[i][j]=='.')d[i][j]=++r;
	else            d[i][j]=r=0;
      }
    }
    for(j=0;j<w;j++)d[i][j]=0;
    for(i=max=0;i<w;i++){
      s[u[0]=0]=d[0][i];
      for(j=r=1;j<=h;j++){
	u[r]=j;
	while(s[r-1]>d[j][i]){
	  if(max<s[r-1]*(j-u[r-1]))max=s[r-1]*(j-u[r-1]);
	  r--;
	}
	if(s[r-1]-d[j][i])s[r++]=d[j][i];
      }
    }
    printf("%d\n",max);
  }
  return 0;
}

Measured memory_bytes: 1860
#include <stdio.h>
#include <stdlib.h>
int main() {
	
	char ch;
     scanf("%c",&ch);
	 if('a'<=ch&&ch<'z'){
		printf("%c",ch+1);
	    }
		else{
		if(ch=='z'){ 				
			printf("输入数据有误");
				 }
			}
		
		return 0; 
}


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

using namespace std;

int main() {
  int N;
  cin >> N;
  unordered_set<int> S;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    S.insert(a);
  }
  cout << S.size();

  return 0;
}


Measured memory_bytes: 256
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                    ___/`---'\___
                  .' \\|     |// '.
                 / \\|||  :  |||// \
                / _||||| -:- |||||- \
               |   | \\\  -  /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
             ___'. .'  /--.--\  `. .'___
          ."" '<  `.___\_<|>_/___.' >' "".
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
     =====`-.____`.___ \_____/___.-`___.-'=====
                       `=---='
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    Sourav Verma IPG_2013  ABV_IIITMG Task @ Codeforces 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/    

#include<bits/stdc++.h>

#define ll                    long long int
#define loop(i,a,b)           for(int i=(int)a;i<(int)b;++i)
#define rloop(i,a,b)          for(int i=(int)a;i<=(int)b;++i)
#define loopr(i,a,b)          for(int i=(int)a;i>=(int)b;--i)
#define count_1(n)            __builtin_popcountll(n)
#define pb                    push_back
#define mset(a,b,c)           loop(i,0,b) a[i]=c
#define F                     first
#define S                     second
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1000000007
#define MAX                   1e9
#define MIN                   -1e9
#define itoc(c)               ((char)(((int)'0')+c))
#define vi                    vector<int>
#define vvi                   vector<vi>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define mini                  INT_MIN
#define sv()                  int t; scanf("%d",&t); while(t--)
using namespace std;
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll lcm(int x, int y) { return x * 1ll * y / (int)__gcd(x, y); }
ll hcf(ll a, ll b) {if(b>a) return (hcf(b, a)); if(a%b==0) return b; return (hcf(b, a%b));} 
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}

int main()
{
    //ios_base::sync_with_stdio(false); cin.tie(0);
    string s,s1; cin>>s;
    loop(i,0,s.length()){
        if(s[i]=='B') {
            if(i==0) {s.erase(0,1); i--;}
            else { s.erase(i-1,2);i-=2;}
        }
        else continue;
    }
    cout<<s;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int length (char* s)
{
  int i=0;
  while (*s++ != '\0') {
    i++;
  }
  return i;
}


int main (int argc, char* argv[])
{
  int i;
  char s[21];

  scanf("%s", s);
  for (i=length(s)-1; 0<=i; i--) {
    printf("%c", s[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;

string s[110];
int main(){
	int n,l;
	while(~scanf("%d%d",&n,&l)){
		for(int i=0;i<n;i++){
			cin>>s[i];
		}
		sort(s,s+n);
		
		for(int i=0;i<n;i++)
			cout<<s[i];
		printf("\n");
	}
} 

Measured memory_bytes: 256
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


int main() {

	ll N, K;
	cin >> N >> K;

	ll ans = 0;
	if (K == 0) cout << N * N << endl;
	else {
		fori(i, K + 1, N + 1) {
			ans += (N / i) * (i - K) + max((ll)0, (N - (N / i) * i) - K + 1);
		}

		cout << ans << endl;
	}

}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::Usize1;
use std::collections::*;
use std::cmp::*;
use std::f64::consts::*;

const MOD: u64 = 1000000007;
const INF: usize = std::usize::MAX / 4;

fn main() {
    input! {
        N: usize,
    }

    let mut A = vec![0; N];
    let mut B = vec![0; N];

    for i in 0..N {
        input! {
            a: usize,
            b: usize,
        };
        A[i] = a;
        B[i] = b;
    }

    A.sort();
    B.sort();

    if N % 2 == 1 {
        println!("{}", B[N / 2] - A[N / 2] + 1);
    } else {
        let a = A[N / 2] + A[N / 2 - 1];
        let b = B[N / 2] + B[N / 2 - 1];
        println!("{}", b - a + 1);
    }
}


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

int main() {
  int N, M;
  cin >> N >> M;
  if (N >= M) {cout << 0 << endl; return 0;}
  
  vector<int> X;
  X.reserve(M);
  for (int i = 0; i < M; i++) {
    int x;
    cin >> x;
    X.emplace_back(x);
  }
  
  sort(X.begin(), X.end());
  int sum = (X[M-1] - X[0]);
  
  vector<int> L;
  L.reserve(M);
  for (int i = 0; i < M - 1; i++) {
    int l = X[i+1] - X[i];
    L.emplace_back(l);
  }
  
  sort(L.begin(), L.end(), greater<int>());
  for (int i = 0; i < N - 1; i++) {
    sum -= L[i];
  }
  
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
typedef long long int ll;

int main() {
  string s;
  cin >> s;
  ll c=0;
  rep(i,4){
    if(s[i]=='-') --c;
    else ++c;
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
from math import factorial
from decimal import *

n,k = map(int, input().split())

for i in range(1, k+1):
    if n-k+1 < i:
        print(0)
    else:
        ans = ((factorial(n-k+1) // factorial(i) // factorial(n-k-i+1)) * \
            (factorial(k-1) // factorial(i-1) // factorial(k-i))) \
            % (10**9 + 7)
        print(ans)
#     if i == 0:
#         print(n-k+1)
#     elif i == (k-1):


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    double r; cin >> r;
    cout << (int)r*r << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define F first
#define S second

signed main(){
  int n;
  string s;
  cin>>n>>s;
  int MAX=0;

  r(i,n)if(s[i]=='.'){
    int sum=0;
    int i1=i+1;
    int i2=i-1;
    if(!( i1<n&&s[i1]=='B' || i2>=0&&s[i2]=='B' ))continue;
    if( ( i1<n&&s[i1]=='B' && i2>=0&&s[i2]=='B' ))continue;
    if( i1<n&&s[i1]=='B' ){
      while(i1<n && s[i1]=='B')i1++,sum++;
      while(i2>=0 && s[i2]=='W')i2--;
      if( s[i1]=='W' && (i2<0 || s[i2]!='B') )MAX=max(MAX,sum);
    }
    if( i2<n&&s[i2]=='B' ){
      while(i2>=0 && s[i2]=='B')i2--,sum++;
      while(i1<n && s[i1]=='W')i1++;
      if( s[i2]=='W' && (i1>=n || s[i1]!='B') )MAX=max(MAX,sum);
    }
  }
  cout<<MAX<<endl;
}


Measured memory_bytes: 3212
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define INF_LL 1e18
#define INF 1e9

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

using namespace std;

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

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

vector<int> G[100010];

int dfs(int x){
	if(G[x].size() == 0) return 0;
	vector<ll> depth;
	REP(i, G[x].size()){
		depth.push_back(dfs(G[x][i]));
	}
	sort(all(depth));
	ll res = depth[0]+1;
	FOR(i, 1, depth.size()){
		if(res < depth[i])
			res = depth[i]+1;
		else
			res++;
	}
	return res;
}

int main(void){
	int N;
	cin >> N;
	REP(i, N-1){
		int a;
		cin >> a;
		G[a].push_back(i+2);
	}
	cout << dfs(1) << endl;
}


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

int main(){
    int n; cin>>n;
    int dp[100001];
    dp[0]=0;
    for(int i=1;i<=n;i++){
        int m=dp[i-1]+1;
        for(int j=6;j<=i;j*=6){
            m=min(m,dp[i-j]+1);
        }
        for(int j=9;j<=i;j*=9){
            m=min(m,dp[i-j]+1);
        }
        dp[i]=m;
    }
    cout<<dp[n]<<endl;
}


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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

constexpr double ticks_per_sec = 3000000000; // AtCoder: 3000000000;
constexpr double ticks_per_sec_inv = 1.0 / ticks_per_sec;
inline double rdtsc() { // in seconds
    uint32_t lo, hi;
    asm volatile ("rdtsc" : "=a" (lo), "=d" (hi));
    return (((uint64_t)hi << 32) | lo) * ticks_per_sec_inv;
}
constexpr double TLE = 2; // sec
constexpr double time_limit = TLE * 0.93;

unsigned int randxor()
{
    static unsigned int x=123456789,y=362436069,z=521288629,w=88675123;
    unsigned int t;
    t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) );
}

template<typename hoge>
void my_shuffle(vector<hoge>& v) {
    int sz = v.size();
    for (int i = sz - 1; i >= 1; i--) {
        swap(v[i], v[randxor() % (i + 1)]);
    }
}

int main() {
    double begin_time = rdtsc();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

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

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

    if (n == 1) {
        if (a[0] == b[0]) cout << "No\n";
        else {
            cout << "Yes\n";
            cout << b[0] << newl;
        }
        return 0;
    }

    my_shuffle(b);
    for (int i = 0; i < n; i++) {
        pena += (a[i] == b[i]);
    }
    
    while (rdtsc() - begin_time < time_limit && pena > 0) {
        int i1 = randxor() % n;
        int i2 = randxor() % (n - 1);
        i2 += (i2 >= i1);

        int nex_pena = pena - (a[i1] == b[i1]) + (a[i1] == b[i2]) - (a[i2] == b[i2]) + (a[i2] == b[i1]);
        if (nex_pena < pena) {
            swap(b[i1], b[i2]);
            pena = nex_pena;
        }
    }

    if (pena > 0) {
        vector<int> cntb(n + 1, 0);
        for (int i = 0; i < n; i++) {
            ++cntb[b[i]];
        }
    
        map<int, int> buf;
        vector<int> ans;
        ans.reserve(n);
        for (int i = 1; i <= n && ans.size() < n; i++) {
            if (!cntb[i]) continue;
    
            while (ans.size() < n && cntb[i]) {
                if (a[ans.size()] == i) {
                    buf[-i] = cntb[i];
                    break;
                }
                ans.push_back(i);
                --cntb[i];
            }
        }
    
        while (ans.size() < n) {
            bool f = false;
            for (auto& p : buf) {
                if (-p.first == a[ans.size()]) continue;
                ans.push_back(-p.first);
                f = true;
                break;
            }
    
            if (f) {
                if (--buf[-ans.back()] == 0) buf.erase(-ans.back());
                continue;
            }
    
            cout << "No\n";
            return 0;
        } 
    
        cout << "Yes\n";
        for (int i = 0; i < n; i++) {
            cout << ans[i] << " \n"[i + 1 == n];
        }
    } else {
        cout << "Yes\n";
        for (int i = 0; i < n; i++) {
            cout << b[i] << " \n"[i + 1 == n];
        }
    }
    return 0;
}

Measured memory_bytes: 6292
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String w = sc.next();
		int N = w.length();
		for(char c = 'a' ; c <= 'z' ; c++) {
			int cnt = 0;
			for(int i = 0 ; i < N ; i++) {
				if(w.charAt(i) == c) {
					cnt++;
				}
			}
			if(cnt % 2 != 0) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}



Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

#define MOD 1'000'000'007
using ll = long long;
using namespace std;

int main() {
	int N, M;
	ll cnt = 0, sum = 0;
	cin >> N >> M;
	vector<int> A(N);
	map<int, ll> B;
	B[sum]++;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		sum += A[i];
		B[sum%M]++;
	}
	for (auto iter = B.begin(); iter != B.end(); iter++) {
		cnt += iter->second * (iter->second - 1) / 2;
	}
	cout << cnt << endl;
	return 0;
}

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

#define lim 1000000
#define ran 10101

struct modular_arithmetic{
	int mod;

	modular_arithmetic(){
		mod = 1000000007;
	}
	//No specific settings.
	int add(int x,int y){return (x+=y)<mod?x:x-mod;}
	int sub(int x,int y){return (x-=y)>=0?x:x+mod;}
	int mul(int x,int y){return (int)((long long int)x*y%mod);}
	int pw(int base, int p) {
		int res = 1, mu = base%mod;
		for(;p>0;p/=2) {
			if (p&1) res = mul(res, mu);
			mu = mul(mu, mu);
		}
		return res;
	}
	int rev(int x) {return pw(x, mod-2);}
};
modular_arithmetic ma;

int n;
int f[lim+10], mp[lim+10];
int a[ran];

int main() {
	scanf("%d", &n);
	memset(f, -1, sizeof f);
	for(int i=2;i<=lim;i++) {
		if(f[i]>0) continue;
		for(int j=i+i;j<=lim;j+=i)
			f[j] = i;
	}
	
	for(int i=0;i<n;i++) {
		scanf("%d", &a[i]);
		if(a[i]<2) continue;
		
		int t = a[i], fac = -1, cnt = 0;
		while(t>1) {
			int x = (f[t]>0)?f[t]:t;
			if(fac==x) cnt++;
			else {
				//printf("- %d %d\n", fac, cnt);
				if(fac>0) mp[fac] = max(cnt, mp[fac]);
				fac = x;
				cnt = 1;
			}
			t /= x;
		}
		//printf("- %d %d\n", fac, cnt);
		mp[fac] = max(cnt, mp[fac]);
	}
	
	int s = 1;
	for(int i=2;i<=lim;i++)
		if(mp[i]>0) {
			s = ma.mul(s, ma.pw(i, mp[i]));
			//printf("%d %d\n", i, mp[i]);
		}
	//printf("%d\n", s);
	
	int ans = 0;
	for(int i=0;i<n;i++) {
		ans = ma.add(ans, ma.mul(s, ma.rev(a[i])));
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

 
const int INF=1e9+5;
 
int32_t main()
{
	IOS;
    int n,k;
    scanf("%d", &n);
    scanf("%d", &k);
    vector<int> h(n);
    for(int& x : h) {
        scanf("%d", &x);
    }
    vector<int> dp(n, INF);
    dp[0] = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = i+1; j<= i+k; ++j) {
            if(j < n) {
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }

    printf("%d\n", dp[n-1]);

	return 0;
}

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

int main(){
   int a, b,c[120],d[110],e;
  cin >> a >> b;
  
  for(int i=0;i<a;i++){
    cin >> c[i] >>d[i];
  }
  
  e = 1010 ;
  for(int i=0;i<a;i++){
    if(d[i] <= b){
      e =min(e,c[i]);
    }
  }
  if(e == 1010){
    cout << "TLE" <<endl;
    
    return 0;
  }
  else{
  cout << e << endl;
  
  return 0;
}
  
}
  
  


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
string t;
string ans;
void dfs(int i,string s,int n){
      if(i == 3){
            if(n == 7){
                  ans = s + "=7";
            }
            return;
      }
      dfs(i + 1,s + "+" + t[i + 1],n + (t[i + 1] - '0'));
      dfs(i + 1,s + "-" + t[i + 1],n - (t[i + 1] - '0'));

}
int main(void){
    cin >> t;
    dfs(0,t.substr(0,1),t[0] - '0');
    cout << ans << endl;
}


Measured memory_bytes: 3620
//%std
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
const int N=80+10,K=(2*80-1)*80;
int n,m,val[N][N];
bool f[N][N][2*K+1];
int main()
{
	n=read(),m=read();
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			val[i][j]=read();
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			val[i][j]-=read();
	f[1][1][val[1][1]+K]=f[1][1][-val[1][1]+K]=true;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			for(int p=0;p<=80*(i+j-1)+K;++p)
				if(f[i][j][p])
				{
					if(i!=n)
					{
						f[i+1][j][p+val[i+1][j]]=true;
						f[i+1][j][p-val[i+1][j]]=true;
					}	
					if(j!=m)
					{
						f[i][j+1][p+val[i][j+1]]=true;
						f[i][j+1][p-val[i][j+1]]=true;
					}
				}
	int ans=K;
	for(int x=0;x<=2*K;++x)
		if(f[n][m][x])
			ans=min(ans,abs(x-K));
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 180480
#include <stdio.h>


int main()
{
    char ch[200010];int len=0;
    scanf("%s",ch);while(ch[len]) len++;
    int num[200010];for (int i=0;i<len;i++) num[i]=0;
    int tmp=0;long long ans=0;
    while (tmp<len)
    {
        if (ch[tmp]=='A'){
                if(tmp==0) num[tmp]=1;
                if(tmp!=0) num[tmp]=num[tmp-1]+1;
        }
        if (tmp>=2 && ch[tmp]=='C' &&ch[tmp-1]=='B' && ch[tmp-2]=='A')
        {
            //printf("ok %d\n",num[tmp-2]);
            ans+=num[tmp-2];
            num[tmp]=num[tmp-2];
            ch[tmp]='A';
        }
        tmp++;
    }
    printf("%lld",ans);

}



Measured memory_bytes: 1152
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			StringTokenizer buffer = new StringTokenizer(br.readLine());
			int x = Integer.parseInt(buffer.nextToken());
			System.out.println(x * x * x);
	}
}


Measured memory_bytes: 24152
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

int32_t main(){
	long double n;
	cin>>n;
	cout<<setprecision(6)<<fixed<<(n/3.0)*(n/3.0)*(n/3.0);
}


Measured memory_bytes: 256