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

using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define REP(i, n) for(int i=1;i<=n;i++)
typedef long long ll;

//べき乗高速化
ll mpow(ll x, ll n, ll M) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}

int main() {
	ll n;
	cin >> n;
	string x;
	cin >> x;
	reverse(x.begin(), x.end());
	ll popcountx = 0;
	rep(i, n) {
		if (x[i] == '1') popcountx++;
	}
	ll X = 0; // mod(popcountx + 1)
	ll Y = 0; // mod(popcountx - 1)
	rep(i, n) {
		if (x[i] == '1') {
			X += mpow(2, i, popcountx + 1);
			X %= popcountx + 1;
			if (popcountx > 1) {
				Y += mpow(2, i, popcountx - 1);
				Y %= popcountx - 1;
			}
		}
	}
	vector<ll> ans;
	rep(i, n) {
		if (x[i] == '0') {
			ll temp = X;
			temp += mpow(2, i, popcountx + 1);
			temp %= popcountx + 1;
			ll count = 1;
			while (temp > 0) {
				temp = temp % __builtin_popcount(temp);
				count++;
			}
			ans.push_back(count);
		} else {
			ll temp = Y;
			if(popcountx == 1){
				ans.push_back(0);
				continue;
			}
			temp -= mpow(2, i, popcountx - 1);
			ll count = 1;
			temp %= popcountx - 1;
			if (temp < 0) {
				temp += popcountx - 1;
			}
			while (temp > 0) {
				temp = temp % __builtin_popcount(temp);
				count++;
			}
			ans.push_back(count);
		}
	}
	reverse(ans.begin(), ans.end());
	for (auto v : ans) {
		cout << v << endl;
	}
	return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define size_of(a) (int)a.size()
#define minit(a,b) memset(a,b,sizeof(a))

typedef pair< int, int > pii;

const int iINF = (int)1e9;

struct Edge {
	int t, d, c, s;
	Edge(int _t, int _d, int _c, int _s) : t(_t), d(_d), c(_c), s(_s) {}

	bool operator > (const Edge& a) const {
		return (this->c == a.c) ? this->d > a.d : this->c > a.c;
	}
};

int n, q, m;
vector< map< string, int > > store;
string need[15];

vector< vector< Edge > > edges;

pii cost[1 << 16][11];

void solve() {
	for_(i,0,1<<16) for_(j,0,11) cost[i][j] = pii(iINF, iINF);
	
	priority_queue< Edge, vector< Edge >, greater< Edge > > que;
	que.push(Edge(0, 0, 0, 0));
	cost[0][0] = pii(0, 0);
	
	while (!que.empty()) {
		Edge e = que.top(); que.pop();
		
		if (cost[e.s][e.t] < pii(e.c, e.d)) continue;
		
		if (e.t > 0) {
			for_(i,0,q) {
				if (e.s >> i & 1) continue;
				if (store[e.t - 1].find(need[i]) == store[e.t - 1].end()) continue;
				
				int val = store[e.t - 1][need[i]];
				int ss = e.s | (1 << i);
				
				if (cost[ss][e.t] > pii(e.c + val, e.d)) {
					cost[ss][e.t] = pii(e.c + val, e.d);
					que.push(Edge(e.t, e.d, e.c + val, ss));
				}
			}
		}
		
		int e_size = size_of(edges[e.t]);
		for_(i,0,e_size) {
			Edge ei = edges[e.t][i];
			
			if (cost[e.s][ei.t] > pii(e.c, e.d + ei.d)) {
				cost[e.s][ei.t] = pii(e.c, e.d + ei.d);
				que.push(Edge(ei.t, e.d + ei.d, e.c, e.s));
			}
		}
	}
	
	pii ans = cost[(1 << q) - 1][0];
	if (ans.first == iINF && ans.second == iINF) cout << "impossible" << endl;
	else cout << ans.first << " " << ans.second << endl;
}

int main() {
	while (cin >> n, n) {
		store.assign(n, map< string, int >());
		
		for_(i,0,n) {
			int k; cin >> k;
			
			for_(j,0,k) {
				string name; int val;
				cin >> name >> val;
				store[i][name] = val;
			}
		}
		
		cin >> q;
		for_(i,0,q) cin >> need[i];
		
		cin >> m;
		edges.assign(n + 1, vector< Edge >());
		
		for_(i,0,m) {
			int s, t, d; cin >> s >> t >> d;
			edges[s].push_back(Edge(t, d, 0, 0));
			edges[t].push_back(Edge(s, d, 0, 0));
		}
		
		solve();
	}
		
	return 0;
}

Measured memory_bytes: 7772
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}


ll i,j,k,ii,jj;
ll n,m;
ll a,b,c,d,e,g,h,r;
ll l,ans,num;
ll x[500005],y[500005],z[500005];
bool dame,flag;
char s[500005],t[500005];
bool used[500005];

int main(){
    cin >> n;
	map<ll,ll> kazu;
	for(i=0;i<n;i++){
		cin >> x[i];
		kazu[x[i]]++;
	}
	sort(x,x+n);
	reverse(x,x+n);
	for(i=0;i<n;i++){
		//pe(x[i]);p(kazu[x[i]]);
		if(kazu[x[i]] <= 0)continue;
		for(j=30;j>=0;j--){
			num = (1 << j);
			//p(num);
			if(num < x[i])break;
			if(num == x[i] * 2){
				if(kazu[x[i]] >= 2){
					kazu[x[i]] -= 2;
					ans++;
					break;
				}
			}else{
				if(kazu[num - x[i]] >= 1){
					kazu[x[i]]--;
					kazu[num-x[i]]--;
					ans++;
					break;
				}
			}
		}
	}
	
	p(ans);
    return 0;
}

Measured memory_bytes: 67072
k=int(input())
l=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[k-1])



Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <array>
#include <bitset>
#include <iomanip>
using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)

double log_two(ll k,ll a){
    double n=1.0;
    k=k/a;
    while(k>0){
        n=n/2.0;
        k=k/2;
    }
    return n;
}

int main(){
    ll N,K;
    cin>>N>>K;
    double ans=0;
    Rep(i,N){
        ans+=log_two(K-1,i);
    }
    cout<<setprecision(15)<<ans/N<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    final int A=sc.nextInt();
    final int B=sc.nextInt();
    if(A<=B*2){
      System.out.println(0);
    }else{
      System.out.println(A-B*2);
    }
  }
}

Measured memory_bytes: 22868
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')

def main():
    N,X=MI()
    A=LI()
    ans = 0
    for i,a in enumerate(A):
        if a>X:
            ans += A[i]-X
            A[i]=X
    for i,a in enumerate(A[1:],start=1):
        if a+A[i-1]>X:
            sub = (a+A[i-1])-X
            A[i]-=min(a,sub)
            ans += min(a,sub)
            if A[i-1]+A[i]>X:
                sub = (A[i]+A[i-1])-X
                A[i-1]-=sub
                ans += sub

    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 17420
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&a!=c)puts("Yes");
	else if(c==b&&a!=c)puts("Yes");
	else if(a==c&&b!=c)puts("Yes");
	else puts("No");
	return 0;
}

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

using namespace std;
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

int main (){
    int H, W, h,w;
    cin >> H >> W >> h >> w;
    cout << H*W - h*W - w*H + h*w << endl;




    return 0;
}

Measured memory_bytes: 256
pypy -cH,W,A,B=`tr \  ,`';M=10**9+7;C=1
for I in range(1,H):Z=C=C*(W+H-B+~I)*pow(I,M-2,M)%M
for I in range(1,H-A):C=C*(B-1+I)*(H-I)*pow(I*(W+H-B+~I),M-2,M)%M;Z+=C
print Z%M'

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

#define pb push_back
#define mp make_pair

typedef long long ll;

const ll mod = 1e9 + 7;


int main()
{
  ll x;
  cin >> x;

  if(x <= 6) cout << 1 << endl;
  else if(x <= 11) cout << 2 << endl;
  else{
    cout << (x/11*2) + (x%11>0) + (x%11>6) << endl;
  }

  return 0;
}


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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

int main(void){
    int n;
    cin >> n;
    vector<int> p(n);
    for(auto &i : p) cin >> i;
    for(auto i : p){
        if(i%2 == 0){
            if((i%3 != 0) && (i%5 != 0)){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{

    int A,B,K;
    scanf("%d %d",&A,&B);
    K=(A+B)/2;
    if(abs(A-K)==abs(B-K)){
    printf("%d\n",K);
    }   
    else{
     printf("IMPOSSIBLE\n");
    }   
    return 0;
    }   


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
  int d,n;
  cin>>d>>n;

  int cnt=0;
  int num=1;
  while(cnt != n){
    if(d==0 && num%100!=0) cnt++;
    else if(d==1){
      if(num%100==0 && num/100%100!=0) cnt++;
    }else if(d==2){
      if(num%10000==0 && num/10000%100!=0) cnt++;
    }
    if(cnt!=n) num++;
  }
  cout << num << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

bool dp[100001][10][10][10];	//dp[i][a][b][c]
bool Prev[100001][10][10][10];

int n, a, b, c;
string s[100000];

int main() {
	int i;
	
	cin >> n >> a >> b >> c;
	rep(i, n) cin >> s[i];
	if (a >= 4) a = 3;
	if (b >= 4) b = 3;
	if (c >= 4) c = 3;
	
	int ia, ib, ic;
	
	dp[0][a][b][c] = true;
	rep(i, n) {
		rep(ia, 10) {
			rep(ib, 10) {
				rep(ic, 10) {
					if (dp[i][ia][ib][ic] == false) continue;
	
					if (s[i] == "AB") {
						if (ib >= 1) {
							dp[i + 1][ia + 1][ib - 1][ic] = true;
							Prev[i + 1][ia + 1][ib - 1][ic] = false;
						}
						if (ia >= 1) {
							dp[i + 1][ia - 1][ib + 1][ic] = true;
							Prev[i + 1][ia - 1][ib + 1][ic] = true;
						}
					}
					if (s[i] == "BC") {
						if (ic >= 1) {
							dp[i + 1][ia][ib + 1][ic - 1] = true;
							Prev[i + 1][ia][ib + 1][ic - 1] = false;
						}
						if (ib >= 1) {
							dp[i + 1][ia][ib - 1][ic + 1] = true;
							Prev[i + 1][ia][ib - 1][ic + 1] = true;
						}
					}
					if (s[i] == "AC") {
						if (ic >= 1) {
							dp[i + 1][ia + 1][ib][ic - 1] = true;
							Prev[i + 1][ia + 1][ib][ic - 1] = false;
						}
						if (ia >= 1) {
							dp[i + 1][ia - 1][ib][ic + 1] = true;
							Prev[i + 1][ia - 1][ib][ic + 1] = true;
						}
					}
				}
			}
		}
	}
	
	a = -1;
	rep(ia, 10) rep(ib, 10) rep(ic, 10) if (dp[n][ia][ib][ic]) { a = ia; b = ib; c = ic; break; }
	if (a == -1) { cout << "No" << endl; return 0; }
	
	string ans_rev;
	for (i = n; i > 0; i--) {
		char plus = (Prev[i][a][b][c] == false) ? s[i - 1][0] : s[i - 1][1];
		char minus = (Prev[i][a][b][c] == false) ? s[i - 1][1] : s[i - 1][0];
		
		if (plus == 'A') a--;
		if (plus == 'B') b--;
		if (plus == 'C') c--;
		if (minus == 'A') a++;
		if (minus == 'B') b++;
		if (minus == 'C') c++;
		ans_rev += plus;
	}
	
	cout << "Yes" << endl;
	for (i = n - 1; i >= 0; i--) cout << ans_rev[i] << endl;
	return 0;
}

Measured memory_bytes: 202196
n = gets.chomp.to_i
r = []

for i in (0..n-1) do 
    r[i] = gets.chomp.to_i
end

min = r[0]
max = r[1]
profit = max - min
for i in (1..n-1) do 
    if r[i] < min then
        min = r[i]
        max = r[i]
        next
    end
    max = r[i] if r[i] > max
    profit = max - min if profit < (max - min)
end

puts profit





Measured memory_bytes: 10592
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string S;
    cin >> S;
    int fCnt, sCnt;
    fCnt = sCnt = 0;
    if(S[0]==S[1] && S[2]==S[3] && S[0]!=S[2])
        cout << "Yes";
    else
    {
        if(S[0]==S[2] && S[1]==S[3] && S[0]!=S[3])
            cout << "Yes";
        else
        {
            if(S[0]==S[3] && S[1] == S[2] && S[0]!=S[1])
                cout << "Yes";
            else
                cout << "No";
        }
    }

    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
ans=[]
for i in range(int(m**0.5)):
  if m%(i+1)==0:
    ans.append(i+1)
    ans.append(m//(i+1))
ans.sort()
for i in range(len(ans)):
  if n*ans[i]>m:
    break
  ans1=ans[i]
print(ans1)
  

Measured memory_bytes: 3060
package main

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

type Drink struct {
	price int
	num   int
}

type Drinks []Drink

func (l Drinks) Len() int {
	return len(l)
}

func (l Drinks) Less(i, j int) bool {
	return l[i].price < l[j].price
}

func (l Drinks) Swap(i, j int) {
	l[i], l[j] = l[j], l[i]
}

func main() {
	var n, m int
	s := wordScanner(100)
	scanInts(s, &n, &m)

	drinks := make(Drinks, n)
	for i := 0; i < n; i++ {
		scanInts(s, &drinks[i].price, &drinks[i].num)
	}

	sort.Sort(drinks)

	var ans int64
	for _, drink := range drinks {
		if drink.num >= m {
			ans += int64(drink.price) * int64(m)
			break
		}
		ans += int64(drink.price) * int64(drink.num)
		m -= drink.num
	}

	fmt.Println(ans)
}

func wordScanner(n int) *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	b := make([]byte, n)
	s.Buffer(b, n)
	return s
}

func scanInts(s *bufio.Scanner, vals ...*int) {
	for i := range vals {
		s.Scan()
		n, _ := strconv.Atoi(s.Text())
		*vals[i] = n
	}
}


Measured memory_bytes: 3840
from collections import deque

s = input()
q = int(input())
queries = [input() for i in range(q)]

ans = deque(s)
flag_reverse = False

for i in range(q):
    query = queries[i].split()
    if query[0] == "1":
        flag_reverse = not flag_reverse
    else:
        if query[1] == "1" and not flag_reverse or query[1] == "2" and flag_reverse:
            ans.appendleft(query[2])
        else:
            ans.append(query[2])

if flag_reverse:
    ans.reverse()

print("".join(ans))

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

int main() {
    string A, B;
    cin >> A >> B;
    if (A.length() > B.length()) {
        cout << "GREATER" << endl;
        return 0;
    } else if (A.length() < B.length()) {
        cout << "LESS" << endl;
        return 0;
    } else {
        for (int i = 0; i < A.length(); i++) {
            if (A[i] > B[i]) {
                cout << "GREATER" << endl;
                return 0;
            } else if (A[i] < B[i]) {
                cout << "LESS" << endl;
                return 0;
            }
        }
    }
    cout << "EQUAL" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<queue>
#define ll long long
using namespace std;
const int maxn = 10;
const int mod = 1e9+7;

int main(){
    int T;
    scanf("%d",&T);
    while(T--){
        printf("ACL");
    }
    return 0;
}

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

int dd(int x1,int y1,int x2,int y2){
  return max(x2-x1,x1-x2)+max(y2-y1,y1-y2);
}

int main(){
  int i,j,k,cnt;
  int n;
  cin>>n;
  int t[n],x[n],y[n];
  for(i=0;i<n;i++)cin>>t[i]>>x[i]>>y[i];
  if(dd(0,0,x[0],y[0])>t[0] || (dd(0,0,x[0],y[0])-t[0])%2==1){
    cout<<"No";
    return 0;
  }
  for(i=0;i<n-1;i++){
    if(dd(x[i],y[i],x[i+1],y[i+1])>t[i+1]-t[i] || ((t[i+1]-t[i])-dd(x[i],y[i],x[i+1],y[i+1]))%2==1){
      cout<<"No";
      return 0;
    }
  }
  cout<<"Yes";
}

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

int main() {
  int i=0,j,k;
  int N;
  string ans="No";
  
  cin >> N;

  for ( i = 1; i < 10; i++)
  {
      if(1<=N/i&&N/i<=9&&N%i==0)
      {
        ans="Yes";
      }
  }

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

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

int main() {
  int a,b,c;
  cin >> a >> b >>c;
  if(a >= b && a >= c) cout << a*10 + b + c << endl;
  else if(b > a && b > c) cout << b*10 + a + c << endl;
  else if(c > a && c > b) cout << c*10 + a + b << endl;
}

Measured memory_bytes: 256
function main(input) {
  input = input.trim();
  const a = input.split(' ');
  if(a[0]=='a'||a[0]=='i'||a[0]=='u'||a[0]=='e'||a[0]=='o'){
    console.log('vowel');
  }else{
    console.log('consonant');
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 30464
using System;

class Program
{
	static void Main(string[] args)
	{
		var S = Console.ReadLine();
		int ans = int.MaxValue;
		for (int i = 0; i < S.Length - 2; i++)
		{
			var temp = int.Parse(S.Substring(i, 3));
			ans = Math.Min(ans, Math.Abs(753 - temp));
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    
   ll A, B, C, D, N;
	cin >> A >> B >> C >> D >> N;
	A *= 8;
	B *= 4;
	C *= 2;
	ll ans = N / 2 * min({A, B, C, D});
	if(N % 2 == 1) ans += min({A/2, B/2, C/2});
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			String s = sc.next();
			if(s.equals("#")){
				break;
			}
			int [][] g = new int[200][2];
			for(int i = 0; i < 200; i++){
				Arrays.fill(g[i], -1);
			}
			g['a'][0] = 'x';
			g['a'][1] = 'y';
			g['x'][1] = 'z';
			g['y'][0] = 'x';
			g['z'][0] = 'w';
			g['z'][1] = 'b';
			g['w'][0] = 'b';
			g['w'][1] = 'y';
			g['b'][0] = 'y';
			g['b'][1] = 'x';
			int now = 'a';
			boolean flg = false;
			for(int i = 0; i < s.length(); i++){
				int ind = s.charAt(i) - '0';
				if(ind >= 2){
					flg = true;
					break;
				}
				int c = g[now][ind];
				if(c == -1){
					flg = true;
					break;
				}
				now = c;
			}
			if(! flg && now == 'b'){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}
		}
	}
	
	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

Measured memory_bytes: 17224
function Main(input) {
	const lines = input.split("\n");
  let x = lines[0] * 1;

  while (true) {
    let flag = 0;
    for (let i = 2; i < x; i++) {
      if (x % i == 0) {
        flag = 1;
        break;
      }
    }
    if (!flag) break;
    x++;
  }
	console.log(x);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
using System;

namespace abc163_c
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine()); //社員番号

            string[] input = Console.ReadLine().Split(' '); //上司の社員番号
            int[] a = new int[n]; //部下数の配列
            for (int i = 0; i < n-1 ; i++)
            {
                a[int.Parse(input[i]) - 1]++; //部下数の判定
            }

            Console.WriteLine(string.Join("\n\r", a)); //配列の中身を改行で区切って表示

        }
    }
}


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

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

typedef long long int ll;

ll INF = 1000000000000000000;
ll MOD = 1e9+7;

int main(){
    ll N;cin >> N;
    vector<string> S(N);
    for(int i = 0;i < N;i++){
        cin >> S[i];
        sort(S[i].begin(),S[i].end());
    }
    sort(S.begin(),S.end());
    ll cnt = 1;
    ll ans = 0;
    for(int i = 0;i < N-1;i++){
        if(S[i+1] == S[i]){
            cnt++;
        }else{
            ans += cnt * (cnt - 1) / 2;
            cnt = 1;
        }
        if(i == N-2 && S[i+1] == S[i]){
            ans += cnt * (cnt - 1) / 2;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int N, max=0, x=0;
  string S;
  cin >> N >> S;
  for(char c:S)
  {
    if(c == 'I')
    {
      x++;
      if(max < x) max = x;
    }
    else if(c == 'D')
    {
      x--;
    }
  }
  cout << max << endl;
  return 0;
}


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

using namespace std;

int n, m, a[50], b[50], c[51], d[51], ans = 0, Max = 0;

int main(){
	cin >> n >> m;
	for (int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
	}
	for (int i = 1; i <= m; i++){
		cin >> c[i] >> d[i];
	}

	for (int i = 0; i < n; i++){
		Max = abs(a[i] - c[1]) + abs(b[i] - d[1]);
		ans = 1;

		for (int j = 2; j <= m; j++){
			if (abs(a[i] - c[j]) + abs(b[i] - d[j]) < Max){
				Max = abs(a[i] - c[j]) + abs(b[i] - d[j]);
				ans = j;
			}
		}

		cout << ans << endl;
	}

	return 0;
}

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

from collections import defaultdict
d=defaultdict(int)

for num in a:
        if num!=0:
                d[num-1]+=1
        d[num]+=1
        d[num+1]+=1

ans=0
for k,v in d.items():
        if v> ans:
                ans=v
print(ans)

Measured memory_bytes: 19024
/*input
3 2
2000000000 -9000000000 4000000000
7000000000 -5000000000 3000000000
6000000000 -1000000000 8000000000
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}


ll a[maxn][3];
vector<ll> v;
int main()
{
	IOS;
	int n,k;
	cin>>n>>k;
	REP(i,n) REP(j,3) cin>>a[i][j];

	ll ans=-INF64;

	REP(mask,8){
		REP(i,3) if(mask&(1<<i)){
			REP(j,n) a[j][i]=-a[j][i]; 
		}

		v.clear();
		REP(i,n){
			ll cur=0;
			REP(j,3) cur+=a[i][j];
			v.pb(cur);
		}
		sort(ALL(v),greater<ll>());
		ll sum=0;
		REP(i,k) sum+=v[i];
		ans=max(ans,sum);
		//cout<<mask<<' '<<sum<<'\n';

		REP(i,3) if(mask&(1<<i)){
			REP(j,n) a[j][i]=-a[j][i]; 
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECUxRE_NO_WARNINGS
#define PI 3.14159265359
#include <map>
#include <algorithm>
#include <vector>
#include <queue>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
typedef long long ll;
using namespace std;

int n, A[2000005], B[2000005];

void CountingSort(int A[], int B[], int k) {
	int C[2000005];
	for (int i = 0;i <= k;i++) C[i] = 0;

	//??????????????§O(n)??§i??\??????????????°?????????????????????????´???§???????????¨?????????
	//C[i]???i???????????°????¨????
	for (int j = 1;j <= n;j++) C[A[j]]++;

	//C[i]???i??\????????°???????????°????¨????(??°?´????:C[n]=n+C[n-1]=n+(n-1)+C[n-2]=...)
	for (int i = 1;i <= k;i++) C[i] = C[i] + C[i - 1];
	//???????????§

	for (int j = n ;j > 0;j--) {
		B[C[A[j]]] = A[j];
		C[A[j]]--;
	}

}

int main() {
	cin >> n;
	for (int i = 1;i <= n;i++) cin >> A[i];
	CountingSort(A, B, 10000);
	for (int i = 1;i <= n;i++) {
		if (i-1) cout << " ";
		cout << B[i];
	}
	cout << endl;
}

Measured memory_bytes: 18696
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int n,x;
  
  cin >> n;
  
  for (x=1;x<50000;x++){
    if (x*108/100==n){
      cout << x << endl;
      return 0;
    }
  }
  
  cout << ":(" << endl;
  
  return 0;
}

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

typedef long long int ll;

int main()
{
    ll a, b, k;
    cin >> a >> b >> k;

    if(a - k < 0){
        k -= a;
        a = 0;
        if(b - k < 0){
            b = 0;
        }
        else{
            b -= k;
        }
    }
    else{
        a = a - k;
    }

    cout << a << " " << b;

    return 0;
}

Measured memory_bytes: 256
def examB():
    N = I()
    St = S()
    if N%2==1:
        ans = "No"
    elif St[:(N//2)]==St[(N//2):]:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)



import sys,copy,bisect,itertools
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Measured memory_bytes: 38384
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline


D = int(readline())
CS = np.array(read().split(), np.int32)
C = CS[:26]
S = CS[26:].reshape((-1, 26))
del CS

last = np.zeros((26, ))


def compute_score(d, mask):
    score = -np.sum(C * (d + 1 - last) * mask)
    return score


ans = []
#SCORE = 0
for d in range(D):
    max_score = -10000000
    best_i = 0
    for i in range(26):
        mask = np.ones((26, ))
        mask[i] = 0
        score = compute_score(d, mask)
        score += S[d][i]

        if max_score < score:
            max_score = score
            best_i = i + 1

    ans.append(best_i)
    #SCORE += max_score
    #print(SCORE)

print('\n'.join(map(str, ans)))

Measured memory_bytes: 27568
#include<bits/stdc++.h>
using namespace std;
int main() {
    long long n;
    cin >> n;
    vector<long long> height(n);
    for(long long i=0; i<n; i++) cin >> height[i];
    vector <long long> dp(n);
    dp[0] = 0;
    dp[1] = abs(height[1]-height[0]);
    for(long long i=2; i<n; i++) {
        dp[i] = min(dp[i-1]+abs(height[i]-height[i-1]), dp[i-2]+abs(height[i]-height[i-2]));
    }
    cout << dp[n-1];
    return 0;
}


Measured memory_bytes: 4860
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

int main(int argc, char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n,t;
    cin>>n;
    t=n;
    map<string,int> mp;
    while(n--)
    {
        string t;
        cin>>t;
        mp[t]++;
    }
    vector<pair<int,string>> aa;
    for(auto x:mp)
    aa.pb({x.second,x.first});

    sort(all(aa),[&](pair<int,string> a,pair<int,string> b){
        if(a.first==b.first)
        return a.second<b.second;

        return a.first>b.first;
    });

    int mx=aa[0].first;

    for(int i=0;i<t && aa[i].first==mx;++i)
    cout<<aa[i].second<<endl;
    return 0;
}

Measured memory_bytes: 28652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define P pair<ll,ll> 
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

ll n,inf=1e9+7;
lvector dist(n);
vector<lvector> G(n);

void dfs(ll v,ll d,ll p,ll a,ll b) {
  dist[v]=d;
  for(ll u:G[v]) {
    if(u==p) continue;
    if(u==a&&v==b) continue;
    if(u==b&&v==a) continue;
    if(dist[u]!=inf) continue;
    dist[u]=d+1;
    dfs(u,d+1,v,a,b);
  }
  return;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m,a,b,ans=0;cin>>n>>m;
  vector<P> v(m);
  dist.resize(n),G.resize(n);
  rep(i,m) {
    cin>>a>>b;
    a--,b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
    v[i]=P(a,b);
  }
  for(P p:v) {
    rep(i,n) dist[i]=inf;
    dfs(0,0,-1,p.first,p.second);
    if(*max_element(dist.begin(),dist.end())==inf) ans++;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
# B - Tap Dance
S = str(input())

res = True
for i, ch in enumerate(S):
    if i%2 == 0:
        if ch == 'L':
            res = False
            break
    else:
        if ch == 'R':
            res = False
            break

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

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define ALL(C) (C).begin(),(C).end()
#define INPUT(P) std::cin>>(P)
#define INPUT2(P1,P2) std::cin>>(P1)>>(P2)
#define INPUT3(P1,P2,P3) std::cin>>(P1)>>(P2)>>(P3)
#define INPUTS(I,N,V) REP(I,N) std::cin>>V[I]
#define OUTPUT(P) std::cout<<P<<std::endl
#define OUTPUT2(P1,P2) std::cout<<P1<<" "<<P2<<std::endl
#define OUTPUT3(P1,P2,P3) std::cout<<P1<<" "<<P2<<" "<<P3<<std::endl
#define OUTPUTS(I,N,V) REP(I,N) std::cout<<V[i]<<std::endl
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using namespace std;
int i,j,k;
int N;
int t;
int cnt;
inline void solve(){
  INPUT(N);
  REP(i,N){
    INPUT(t);
    while(t%2==0){
      t/=2;
      cnt++;
    }
  }
  OUTPUT(cnt);
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

using namespace std;

int main(){
    char n[4];
    cin>>n[0]>>n[1]>>n[2]>>n[3];

    if(n[0]==n[1]&&n[1]==n[2]||n[1]==n[2]&&n[2]==n[3]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

// AtCoder
// #include <atcoder/all>
// using namespace atcoder;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int d (char c) {
    return (26 + 'a' - c) % 26;
}

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    ll a; cin >> a;
    rep (i, s.size() - 1) {
        if (int k = d(s[i]); k <= a) {
            cout << 'a';
            a -= k;
        }
        else cout << s[i];
    }
    cout << (char)('a' + (s.back() - 'a' + a) % 26) << "\n";
    /***************************************************/
    /* Use "submit code (with ACL v1)" when using ACL! */
    /***************************************************/
    return 0;
}

Measured memory_bytes: 3728
#include <iostream>

using namespace std;

struct Node {
    int key;
    Node *left, *right, *parent;
};

Node *root, *NIL;

Node * find(Node *u, int k) {
    while (u != NIL && k != u->key) {
        if (k < u->key) {
            u = u->left;
        }
        else {
            u = u->right;
        }
    }
    
    return u;
}

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = new Node;
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        }
        else {
            x = x->right;
        }    
    }

    z->parent = y;

    if (y == NIL) {
        root = z;
    }
    else if (z->key < y->key) {
        y->left = z;
    }
    else {
        y->right = z;
    }

}

void inorder(Node *u) {
    if (u == NIL) {
        return;
    }
    inorder(u->left);
    cout << " " << u->key;
    inorder(u->right);
}

void preorder(Node *u) {
    if (u == NIL) {
        return;
    }
    cout << " " << u->key;
    preorder(u->left);
    preorder(u->right);
}

int main() {
    int n, i, x;
    string com;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> com;
        if (com == "insert") {
            cin >> x;
            insert(x);
        }
        else if (com == "print") {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
        else if (com == "find") {
            cin >> x;
            Node *u = find(root, x);
            if (u != NIL) {
                cout << "yes" << endl;
            }
            else {
                cout << "no" << endl;
            }
        }
    }
}

Measured memory_bytes: 21840
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
int MAX=1e9;
int MOD=1e9+7;


int main(){
  int a,b;cin>>a>>b;
  cout<<(b%a==0?a+b:b-a)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int n, a, b;

int digit_sum(int t) {
  int sum = 0;
  while (t) {
    sum += t % 10;
    t /= 10;
  }
  return sum;
}

int solve()
{
  int sum = 0;
  do {
    int d = digit_sum(n);
    // cout << n << ";" << d << endl;
    if (d >= a && d <= b)
      sum += n;
  } while (n--);
  return sum;
}

int main()
{
  cin >> n >> a >> b;
  cout << solve() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#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>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//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 dp[100010];

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

  rep(n,100010) dp[n] = INF;
  dp[0] = 0;
  for (int n = 1; n <= 100000; ++n) {
    int power = 1;
    while (power <= n) {
      chmin(dp[n], dp[n-power]+1);
      power *= 6;
    }
    power = 1;
    while (power <= n) {
      chmin(dp[n], dp[n-power]+1);
      power *= 9;
    }
  }

  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 640
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var n = cin.ReadInt;
            var m = cin.ReadInt;
            if(n==m) WriteLine("Yes");
            else WriteLine("No");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 13268
//header{{{
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <boost/hana/functional/fix.hpp>
#include <boost/sort/spreadsort/spreadsort.hpp>
//#include <boost/graph/adjacency_list.hpp>
//#include <boost/graph/dijkstra_shortest_paths.hpp>
//#include <boost/graph/graph_utility.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
  
using namespace std;
//using namespace boost::multiprecision;
//using namespace boost::math;

/*
typedef boost::adjacency_list<boost::listS, boost::vecS, boost::undirectedS,
        boost::no_property, boost::property<boost::edge_weight_t, int> > Graph;
*/


#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define FixPoint boost::hana::fix
#define bsort boost::sort::spreadsort::spreadsort
#define int int_fast64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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


signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(10);

        int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
 
    vector<int> p(a), q(b), r(c);
 
    rep(i,a){
        cin >> p[i];
    }
 
    rep(i,b){
        cin >> q[i];
    }
 
    rep(i,c){
        cin >> r[i];
    }
 
    sort(all(p), greater<>());
    sort(all(q), greater<>());
 
    min_heap<int> pq;
 
    rep(i,x){
        pq.emplace(p[i]);
    }
 
    rep(i,y){
        pq.emplace(q[i]);
    }
 
    rep(i,c){
        if(pq.top() < r[i]){
            pq.pop();
            pq.emplace(r[i]);
        }
    }
 
    int res = 0;
    while(!pq.empty()){
        res += pq.top();
        pq.pop();
    }
 
    cout << res << '\n';

    return 0;
}


Measured memory_bytes: 7652
#![allow(non_snake_case, unused_imports)]

// Input macros
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,VecDeque,BinaryHeap};

// Functions

// Main
fn main(){
    input!{
        N: usize,
        Y: usize,
    }
    for i in 0..N+1{
        for j in 0..N+1-i{
            if N < i+j{
                continue;
            }
            if 10000*i + 5000*j + 1000*(N-(i+j)) == Y{
                println!("{} {} {}", i, j, N-(i+j));
                return;
            }
        }
    }
    println!("-1 -1 -1");
}


Measured memory_bytes: 4352
var std = process.stdin;
std.resume();
std.setEncoding('utf8');
std.on('data', function (chunk) {
    var datas = chunk.split(/\n/);
    
    for (var i = 0; i < datas.length; i++) {
        var data = datas[i].split(' ').map(Number);
        
        if (data[0] === 0 && data[1] === 0) { break; }
        
        console.log(Math.min(data[0], data[1]) + " " + Math.max(data[0], data[1]));
    }
});

Measured memory_bytes: 18396
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>

#define x first
#define y second

#define INF 0x3f3f3f3f

using namespace std;

typedef long long LL;
typedef pair<int,int>PII; 

int main(void) {
	int n;
	cin >> n;
	if(n & 1) cout << n / 2 + 1 << endl;
	else cout << n / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;
string S, C[10] = {"Rainy","Sunny","Cloudy","Rainy"};
int main() {
	int k;
	cin>>S;
	if(S=="Sunny") k=1;
	else if(S=="Cloudy") k=2;
	else k=3;
	cout<<C[(k+1)%3]<<endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=1e5+3;
string s;
int main()
{
    ft
    int i,j,n,m,l=0,r=0;
    cin>>s;
    n=s.size();
    for(i=0;i<n;i++)
    {
        if(s[i]=='0')
        {
            l++;
        }
        else
        {
            r++;
        }
    }
    m=min(l,r);
    cout<<2*m<<"\n";
    return 0;
}



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

int main(){
  int n, m, max=1000000, min=0, ans=0;
  cin >> n >> m;
  vector<int> l(m);
  vector<int> r(m);
  for(int i=0; i<m; i++){
    cin >> l[i] >> r[i];
    if(l[i]>min) min=l[i];
    if(r[i]<max) max= r[i];
  }

  for(int i=min; i<=max; i++){
    ans += 1;
  }

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


Measured memory_bytes: 1024