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

  int n, a, i = 0, counter, min_div = 34;
  cin >> n;
  for (i = 0; i<n;i++)
  {
    cin >> a;
    counter = 0;

    while(true)
    {
      if (a % 2 == 1)
      {
        break;
      }
      else
      {
        a /= 2;
        counter++;
      }
    }

    if(counter <= min_div)
    {
      min_div = counter;
    }
  }

  cout << min_div << endl;

  return 0;
}

Measured memory_bytes: 3548
/*
Hey there stalker....

█▀▀▄░░░░░░░░░░░▄▀▀█
░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
░░▀▄░░░▀░░░░░▀░░░▄▀
░░░░▌░▄▄░░░▄▄░▐▀▀
░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█
░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
░░░█░░░░░░░░░░░▄▀▄░▀▄
░░░█░░░░░░░░░▄▀█░░█░░█
░░░█░░░░░░░░░░░█▄█░░▄▀
░░░█░░░░░░░░░░░████▀
░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀

Like what you see?
*/
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pii         pair<ll ,ll>
#define vi          vector<ll>
#define present(container, element) (container.find(element) != container.end()) /* For set n maps */
#define cpresent(container, element) (find(all(container),element) != container.end()) /* For vectors */
#define all(a)      (a).begin(),(a).end()
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.I(tmp);commands}
#define F           first
#define S           second
#define I           insert
#define sz(x)       (ll)x.size()
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define trav(a, x) 	for(auto& a : x)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lcase(a) (char)tolower(a)
#define ll long long int
#define lld long double
#define endl "\n"
#define PI 3.14159265358979323844
#define MOD 1000000007
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
#define mod 1e9 + 7
const int N = 1e5 + 5;
/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

int main()
{
   IOS

    int TESTS=1;
    //cin >> TESTS;
    while (TESTS--)
    {
    	ll h;
    	cin>> h;
    	ll ans=0,count=1;
    	while(h)
		{
			h>>=1;
		//	what_is(h);

			ans+=count;
			//what_is(ans);
			count<<=1;
			//what_is(count);
		}
		cout<< ans << endl;
    }
    return 0;
}



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

#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;

signed main(void)
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  if(fopen("A.INP", "r")){
    freopen("A.INP", "r", stdin);
    freopen("A.OUT", "w", stdout);
  }
  int h, w; cin >> h >> w;
  int n; cin >> n;
  vector<pair<int, int>> a(n);
  for(auto & x : a){
    cin >> x.fi >> x.se;
  }
  sort(a.begin(), a.end());
  int res = h, o = 0;
  for(auto & x : a){
    if(x.fi == x.se + o) ++o;
    else if(x.fi >= x.se + o + 1)
      res = min(res, x.fi - 1);
  }
  cout << res;
}


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

int main()
{
    int n;
    int count_500 = 0;
    int count_5 = 0;
    int sum = 0;
    cin >> n;
    while(n >= 500)
    {
        n -= 500;
        count_500++;
    }
    while(n >= 5)
    {
        n -=5;
        count_5++;
    }
    sum = (1000 * count_500) + (5 * count_5);
    cout << sum << endl;
}

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

# define x first
# define y second
# define mp make_pair
// everything goes according to my plan
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right

# ifdef Local
# define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
# else
# define debug(...) (__VA_ARGS__)
# define cerr if(0)cout
# endif

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") {
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}
int n;
string s;

char get (char a, char b, char c)
{
    if (b == 'S' && c == 'o' || b == 'W' && c == 'x')
        return a;
    else
        return  (a == 'W' ? 'S' : 'W');
}

void calc (char s0, char s1) {
    string t;
    t.resize(n);
    t[0] = s0;
    t[1] = s1;
    for (int i = 2; i < n; i ++) {
        t[i] = get (t[i-2], t[i-1], s[i-1]);
    }
    char g = get(t[1], t[0], s[0]);
    if (g != t[n-1])
        return;
    g = get (t[n-2], t[n-1], s[n-1]);
    if (g != t[0])
        return;
    cout << t;
    exit (0);
}
int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  cin >> n >> s;
  calc('S','S');
  calc('S','W');
  calc('W','S');
  calc('W','W');
  cout << -1;
  return 0;

}






// Coded by Z..

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

using namespace std;

//#define MD 10

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

Measured memory_bytes: 256
import java.io.*; 
import java.math.*;
import java.util.*;
 
public class Main {
	//static final long MOD = 998244353;
	static final long MOD = 1000000007;
	static final int INF = 1000000007;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		long N = sc.nl();
		long best = Long.MAX_VALUE;
		for (int i = 1; (i*(long)i) <= N; i++) {
			if (N % i == 0) {
				long r = (long)i;
				long c = N/r;
				best = Math.min(best,r+c-2);
			}
		}
		System.out.println(best);
	}
    
    public static long power(long x, long y, long p) { 
        // Initialize result
        long res = 1;
         
        // Update x if it is more   
        // than or equal to p 
        x = x % p;  
      
        while (y > 0) 
        { 
            // If y is odd, multiply x 
            // with result 
            if((y & 1)==1) 
                res = (res * x) % p; 
      
            // y must be even now 
            // y = y / 2 
            y = y >> 1;  
            x = (x * x) % p;  
        } 
        return res; 
    }
    
    public static long dist(int[] point, int[] point2) {
    	return (long)(Math.pow((point2[1]-point[1]),2)+Math.pow((point2[0]-point[0]),2));
    }
    
    public static long gcd(long a, long b) {
    	if (b == 0)
    		return a;
    	else
    		return gcd(b,a%b);
    }
    
    public static int[][] sort(int[][] array) {
    	//Sort an array (immune to quicksort TLE)
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    int[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		Arrays.sort(array, new Comparator<int[]>() {
			  @Override
        	  public int compare(int[] arr1, int[] arr2) {
				  return arr2[1]-arr1[1];
	          }
		});
		return array;
	}
    
    static class FastScanner { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int ni() { 
            return Integer.parseInt(next()); 
        } 
  
        long nl() { 
            return Long.parseLong(next()); 
        } 
  
        double nd() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try { 
                str = br.readLine(); 
            } catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str; 
        }
    }
}

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

sys.setrecursionlimit(10**7)
inf = 10**3
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    c = [S() for _ in range(n)]
    dp = [[0]*(n+1) for _ in range(n+1)]
    dp[0][0] = 1
    for i in range(n):
        ci = c[i]
        if ci == '-':
            for j in range(n+1):
                dp[i+1][j] = dp[i][j]
        elif ci == 'D':
            for j in range(n+1):
                dp[i+1][j] += dp[i][j] * j
                if j > 0:
                    dp[i+1][j-1] += dp[i][j] * j * j
                    dp[i+1][j-1] %= mod
        else: # 'U'
            for j in range(n+1):
                if j < n:
                    dp[i+1][j+1] += dp[i][j]
                dp[i+1][j] += dp[i][j] * j
                dp[i+1][j] %= mod

    return dp[-1][0] % mod


print(main())




Measured memory_bytes: 9592
#include <bits/stdc++.h>
using namespace std;
bool check575(vector<int> &v,int pos) {
    int sum;
    sum=0;
    while(pos<v.size()&&sum<5) sum+=v[pos++];
    if(sum!=5) return 0;
    sum=0;
    while(pos<v.size()&&sum<7) sum+=v[pos++];
    if(sum!=7) return 0;
    sum=0;
    while(pos<v.size()&&sum<5) sum+=v[pos++];
    if(sum!=5) return 0;
    sum=0;
    while(pos<v.size()&&sum<7) sum+=v[pos++];
    if(sum!=7) return 0;
    sum=0;
    while(pos<v.size()&&sum<7) sum+=v[pos++];
    if(sum!=7) return 0;
    return 1;
}
int main() {
    int n;
    string w;
    while(cin>>n,n) {
        vector<int> v;
        for(int i=0;i<n;i++) {
            cin>>w;
            v.push_back(w.size());
        }
        for(int i=0;i<v.size();i++) {
            if(check575(v,i)) {
                printf("%d\n",i+1);
                break;
            }
        }
    }
}

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

const int N = 3e5 + 9;

int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s, t; cin >> s >> t;
	t.pop_back();
	if (s== t) cout << "Yes\n";
	else cout << "No\n";
    return 0;
}

Measured memory_bytes: 3636
#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>
#include <tuple>

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];

//big priority queue
priority_queue <ll> pql;
priority_queue <P> pqp;

//small priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
*/
//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,n,m;
ll a,b,c,d,e,g,h,r,l,w,num,ans;
ll x[500005],y[500005],z[500005];
ll dp[205][300005];

int main(){    
    cin >> n >> w;
	for(i=0;i<n;i++){
		cin >> x[i+1] >> y[i+1];
	}
	dp[0][0] = 0;
	for(i=1;i<=n;i++){
		//dp[i][j] := i番目まで使ってjg以下で価値の最大値
		for(j=0;j<=w;j++){
			if(j-x[i] < 0){
				dp[i][j] = dp[i-1][j];
				//pe(dp[i][j]);
			}else{
				dp[i][j] = max(dp[i-1][j],dp[i-1][j-x[i]] + y[i]);
				//pe(dp[i][j]);
			}
		}
		//el;
	}
	ans = -1;
	for(i=0;i<=w;i++){
		ans = max(ans,dp[n][i]);
	}
	p(ans);
	
    return 0;
}

Measured memory_bytes: 237824
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            long K = in.nextLong();
            long[] A = new long[N];
            for (int i = 0; i < N; i++) {
                A[i] = in.nextLong();
            }

            long[] count = new long[64];
            for (int i = 0; i < N; i++) {
                for (int shift = 0; shift < 64; shift++) {
                    long mask = 1L << shift;
                    count[shift] += (A[i] & mask) == 0 ? 0 : 1;
                }
            }
//            Utils.debug(count);

            long sum = 0L;
            long k = 0L;
//            Utils.debug("k, sum", k, sum);
            for (int shift = 62; shift >= 0; shift--) {
                long mask = 1L << shift;
                if (mask > K) {
//                    Utils.debug("con", shift, "k, sum", k, sum);
                    sum += count[shift] * mask;
                    continue;
                }

                if (k + mask <= K && N - count[shift] > count[shift]) {
                    sum += (N - count[shift]) * mask;
                    k += mask;
                } else {
                    sum += count[shift] * mask;
                    k += 0;
                }
//                Utils.debug(shift, "k, sum", k, sum);
            }

            System.out.println(sum);
        }
    }

}


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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a>b){
        swap(a,b);
    }
    if(b>c){
        swap(b,c);
    }
    if(a>b){
        swap(a,b);
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
        
  
}



Measured memory_bytes: 3100
n,mw=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]
dp=[[0 for _ in range(mw+1)]for _ in range(n+1)]
for i in range(n):
    w,v=l[i]
    for j in range(mw):
        dp[i+1][j]=max(dp[i+1][j],dp[i][j])
        if j+w<=mw:
            dp[i+1][j+w]=max(dp[i+1][j+w],dp[i][j]+v)
print(max(dp[-1]))

Measured memory_bytes: 217912
#include <iostream>
#include <vector>

int main()
{
    long long int n;
    std::cin>>n;
    std::vector<long long int> p(n);
    for (int i=0; i<n; i++) std::cin>>p[i];
    long long min=p[0],count=1;
    for (int i=1; i<n; i++)
    {
        if (p[i]<min)
        {
            count++;
            min=p[i];
        }
    }
    std::cout<<count;
    return 0;
}


Measured memory_bytes: 4824
A,B = map(int, input().split())




def getPrimeFactorsList(num):
  pn = 2 #素数は2から
  pflist = [] #素因数のリスト
  while pn * pn <= num: #√numまで調べる
    while num % pn == 0: #現在の素数で割り切れる範囲でループ
      num = num / pn
      pflist.append(pn)
    pn += 1 #割り切れなくなったら次の素数へ
  if num > 1:
    pflist.append(int(num))
    
  return pflist

pf_A = getPrimeFactorsList(A)
pf_B = getPrimeFactorsList(B)
ans = len(set(pf_A) & set(pf_B)) + 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
template<class T> inline istream& operator >> (istream & c, vector<T> & A) {rep(i, A.size()) c >> A[i];return c;}
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<vector<P>> g(n);
	rep(i, m) {
		int l, r, d;
		cin >> l >> r >> d;
		l--; r--;
		g[l].push_back(P(r, d));
		g[r].push_back(P(l, -d));
	}
	vector<int> memo(n, -inf);
	bool ok = true;
	function<void(int, int)> Dfs = [&](int v, int now) {
		if (memo[v] != -inf) {
			if (memo[v] != now) ok = false;
			return;
		}
		memo[v] = now;
		for (auto c : g[v]) {
			Dfs(c.first, memo[v] + c.second);
		}
		return;
	};
	rep(i, n) {
		if (memo[i] == -inf) Dfs(i, 0);
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 15860
def add_N(S, N):
    code_Z = ord("Z")
    code_A = ord("A")
    code = ord(S) + N
    while code > code_Z:
        code = code - code_Z - 1 + code_A
    return code

N = int(input())
S = input()
length = len(S)

for i in range(0, length):
    print(chr(add_N(S[i], N)), end="")

Measured memory_bytes: 4468
#include<cstdio>
#include<algorithm>
using namespace std;
#define LL long long
#define MAXN 200010
#define INF 1000000000
int Adj[MAXN],V[MAXN*2],nxt[MAXN*2],c;
void AddEdge(int u,int v)
{
	c++;V[c]=v,nxt[c]=Adj[u];Adj[u]=c;
}
int n,siz[MAXN],mx[MAXN],sx[MAXN],l[MAXN],r[MAXN],sum;
char s[MAXN];
LL ans;
void dfs1(int u,int p)
{
	siz[u]=s[u]-'0';
	for(int i=Adj[u];i;i=nxt[i])
		if(V[i]!=p)
		{
			dfs1(V[i],u);
			siz[u]+=siz[V[i]];
			if(mx[V[i]]+1>mx[u]) sx[u]=mx[u],mx[u]=mx[V[i]]+1;
			else if(mx[V[i]]+1>sx[u]) sx[u]=mx[V[i]]+1;
		}
}
void dfs2(int u,int p,int len)
{
	r[u]=mx[u]<len?mx[u]:max(len,sx[u]);
	l[u]=s[u]-'0'?0:(sum-siz[u]?len:INF);
	if(p)
	{
		if(len-1==mx[u]) ans++;
		else if(len-1<mx[u]) ans+=siz[u]<sum;
		else ans+=siz[u]>0;
	}
	for(int i=Adj[u];i;i=nxt[i])
		if(V[i]!=p)
		{
			if(siz[V[i]]) l[u]=min(l[u],mx[V[i]]+1);
			if(mx[u]==mx[V[i]]+1) dfs2(V[i],u,max(len,sx[u])+1);
			else dfs2(V[i],u,max(len,mx[u])+1);
		}
}
int main()
{
	scanf("%d",&n);
	int u,v;
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		AddEdge(u,v);
		AddEdge(v,u);
	}
	scanf("%s",s+1);
	for(int i=1;i<=n;i++) sum+=s[i]-'0';
	dfs1(1,0);
	dfs2(1,0,0);
	for(int i=1;i<=n;i++)
		if(l[i]<=r[i])
			ans+=1LL*r[i]-l[i]+1;
	printf("%lld\n",ans);
}

Measured memory_bytes: 15360
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int k;cin>>k;
	string s;cin>>s;
	if(s.length()<=k)
	{
		cout<<s<<endl;
	}
	else 
	{
		for(int i=0;i<k;i++)
		{
			cout<<s[i];
		}
		cout<<"..."<<endl;
	}
}

Measured memory_bytes: 3028
//q2.cpp

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 10000


int main(){
    int n,m,a[SIZE];
    
    scanf("%d%d",&n,&m);
    
    for(int i=0;i<n;i++){
        scanf("%d",a+i);
    }
    
    for(int i=1;i<=m;i++){
        
        for(int j=0;j<n-1;j++){
            if(a[j]%i > a[j+1]%i){
                swap(a[j],a[j+1]);
            }
        }
        
    }
    
    for(int i=0;i<n;i++){
        printf("%d\n",a[i]);
    }
    
    
    return 0;
}

Measured memory_bytes: 3232
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}





int main(){
    long long A, B, C;
    scanf("%ld %ld.%ld", &A, &B, &C);
    std::cout << (A * (100*B + C)) / 100 << std::endl;
    return 0;
}


Measured memory_bytes: 3708
while True:
  n,m,h,k = map(int,input().split())
  if not n: break
  s_lst = [int(input()) for _ in range(n)]
  i_lst = [i for i in range(n)]
  b_lst = [tuple(map(int,input().split())) for _ in range(m)]
  b_lst = sorted(b_lst,key=lambda x:x[1])
  pare_lst = []
  for bar in b_lst:
    ind = bar[0]
    temp = i_lst[ind]
    i_lst[ind] = i_lst[ind - 1]
    i_lst[ind - 1] = temp
    pare_lst.append((i_lst[ind], i_lst[ind - 1]))
#  print(i_lst)
  new_s_lst = [0] * n
  for i in range(n):
    new_s_lst[i_lst[i]] = s_lst[i]
#  print(s_lst)
  ans = sum(new_s_lst[:k])
#  print(ans)
#  print(pare_lst)
  max_dec = 0
  for pare in pare_lst:
    a = pare[0]
    b = pare[1]
#    print(a,b,s_lst[a],s_lst[b])
    if a < k and b >= k and new_s_lst[a] - new_s_lst[b] > max_dec:
      max_dec = new_s_lst[a] - new_s_lst[b]
    if b < k and a >= k and new_s_lst[b] - new_s_lst[a] > max_dec:
      max_dec = new_s_lst[b] - new_s_lst[a]
  print(ans - max_dec)



Measured memory_bytes: 24740
/*
g++ -std=c++11 -o2 -Wall ABC104A.cpp -o ./out/ABC104A.out
./out/ABC104A.out
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int r;
  cin >> r;
  if (r < 1200) cout << "ABC\n";
  else if (r < 2800) cout << "ARC\n";
  else cout << "AGC\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define T top()
#define E end()
#define PS push
#define Q queue
#define PP pop()
#define L0 (LL)0
#define V vector
#define ST stack
#define FI first
#define MAX 4e18
#define MIN -MAX
#define DQ deque
#define RE rend()
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define SE second
#define DL double
#define G getline
#define IN insert
#define endl "\n"
#define EM empty()
#define EE emplace
#define RB rbegin()
#define MD 1000000007
#define PSB push_back
#define PI acos(-1.00)
#define PPB pop_back()
#define PSF push_front
#define ub upper_bound
#define lb lower_bound
#define PPF pop_front()
#define EB emplace_back
#define LL long long int
#define PQ priority_queue
#define N cout<<"NO"<<endl
#define Y cout<<"YES"<<endl
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define UOSMOY v.C;w.C;ww.C;uu.C;uo.C;vo.C;vu.C;ab.C;bc.C;cc.C;uuu.C;a.C;b.C;c.C;u.C
V<LL>v;
V<LL>w,ab,bc;
set<LL>uo;
map<LL,LL>ww,cc,u;
V<pair<LL,LL> >uu;
map<LL,V<LL> >uuu;
map<pair<LL,LL>,LL> vo;
map<pair<LL,LL>,LL> vu;
LL dxx[]= {-1,0,1,0};
LL dyy[]= {0,1,0,-1};
LL dx[]= {2,1,-1,-2,-2,-1,1,2};
LL dy[]= {1,2,2,1,-1,-2,-2,-1};
int main()
{
//  BRR;
//  file;
    FAST;
    char ch;
    string a,b,c;
    DL x,y,d,e,f,g,h;
    LL n,m,i,j,k,p,q,o,l,s,tt=1,t,z,aa,r=0;
//    cin>>tt;
    while(tt--)
    {
        UOSMOY;
        cin>>n>>m>>o;
        if(m*o>=n)
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }

    }
    return 0;
    //IN
    //AL
}


Measured memory_bytes: 3636
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int n;
	cin >> n;
	map<int, int> mp;
	REP(i, n)
	{
		int a;
		cin >> a;
		mp[a]++;
	}

	int ans = 0;
	REPIT(mp)
	{
		int x = (*it).first;
		int sum = (*it).second;
		if (mp.count(x - 1))
			sum += mp[x - 1];
		if (mp.count(x + 1))
			sum += mp[x + 1];
		if (ans < sum)
			ans = sum;
	}
	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 3200
#include<iostream>
#include<vector>
#include<cstdio>
using namespace std;

int n;
int a[1000000] = {};
long long int cnt = 0 ;
vector <int> g;
int m = 0;

void insertionsort(int a[],int n,int g){
    for(int i = g; i < n; i++){
        int v = a[i];
        int j = i - g;
        while(j >= 0 && a[j] > v){
            a[j+g] = a[j];
            j = j - g;
            cnt++;
        }
        a[j+g] = v;
    }
}

int shellsort(int a[],int n){
    cnt = 0;
    int x = 0;

    //
    for(int i = 1; ;){
        if(i <= n){
            g.push_back(i);
            i =1+3*i;
        }else{
            break;
        }
    }

    m = g.size();
    //大きい値から調べていく
    for(int i = m-1; i >= 0; i--){
        insertionsort(a,n,g[i]);
    }
}

int main(){
    scanf("%d",&n);
    for(int i = 0; i < n; i++) scanf("%d", &a[i]);

    shellsort(a,n);

    printf("%d\n",m);

    for(int i = m-1; i >= 1 ; i--){
        printf("%d",g[i]);
        printf(" ");
    }
    printf("%d\n",g[0]);

    printf("%lld\n",cnt);

    for(int i = 0; i < n;i++){
        printf("%d\n",a[i]);
    }
    return 0;
}


Measured memory_bytes: 7116
#include <iostream>
#include <cstdlib>
#include <cmath>


using namespace std;

int main()
{
	int a, b, c, h=0, x, i;

	cin >> a;	cin >> b;
	c = b-a;

	for (i = 1; i < c; i++)
		h = h + i;


	cout << h-a << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <vector>
#include <queue>
using namespace std;
#define INF 0x3f3f3f3f
struct point {
	int a, b;
}r[105],b[105];
struct edge {
	int x, f, t;
};
vector<edge> G[205];
int s, t, level[205], iter[205];
void addedge(int x,int y,int value){
	G[x].push_back(edge{y,value,(int)G[y].size()});
	G[y].push_back(edge{ x,0,(int)G[x].size() - 1 });
}
void bfs() {
	queue<int> q;
	q.push(s);
	level[s] = 0;
	while (!q.empty()) {
		int t = q.front();
		q.pop();
		int siz = G[t].size();
		for (int i = 0; i < siz; ++i) {
			edge &p = G[t][i];
			if (p.f && level[p.x] < 0) {
				level[p.x] = level[t] + 1;
				q.push(p.x);
			}
		}
	}
}
int dfs(int v, int f) {
	if (v == t) {
		return f;
	}
	int s = G[v].size();
	for (int &i = iter[v]; i < s; ++i) {
		edge &p = G[v][i];
		if (p.f && level[v] < level[p.x]) {
			int d = dfs(p.x, min(p.f, f));
			if (d) {
				p.f -= d;
				G[p.x][p.t].f += d;
				return d;
			}
		}
	}
	return 0;
}
int maxflow() {
	int flow = 0;
	while (1) {
		memset(level, -1, sizeof(level));
		bfs();
		if (level[t] == -1) {
			return flow;
		}
		memset(iter, 0, sizeof(iter));
		int f;
		while ((f = dfs(s, INF)) > 0) {
			flow += f;
		}
	}
}
int main() {
	int n;
	while (cin >> n) {
		for (int i = 1; i <= n; ++i) {
			cin >> r[i].a >> r[i].b;
		}
		for (int i = 1; i <= n; ++i) {
			cin >> b[i].a >> b[i].b;
		}
		s = 0, t = (n << 1) + 1;
		for (int i = 1; i <= n; ++i) {
			for (int j = 1; j <= n; ++j) {
				if (r[i].a < b[j].a && r[i].b < b[j].b) {
					addedge(i, j + n, 1);
				}
			}
		}
		for (int i = 1; i <= n; ++i) {
			addedge(s, i, 1);
			addedge(i + n, t, 1);
		}
		printf("%d\n", maxflow());
		for (int i = 0; i <= 2 * n + 1; ++i) {
			G[i].clear();
		}
	}
	return 0;
}

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

struct ipair {int idx, v; };

int main (){
    int n,center;
    scanf("%d", &n);
    vector<ipair> a(n);
    vector<int> ans(n);

    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a.at(i).v);
        a.at(i).idx = i;
    }

    sort(a.begin(), a.end(), 
    [](const ipair& x, const ipair& y) { return x.v < y.v;} );
    center = (n/2);

    for(int i = 0; i < n; i++)
    {
        if (i < center) ans.at(a.at(i).idx) = a.at(center).v;
        else ans.at(a.at(i).idx) = a.at(center-1).v;
    }

    for (int i = 0; i < n; i++) printf("%d\n", ans.at(i) );

    return 0;
}

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

ll beki(ll x, ll n){
  ll res = 1;
  while(n > 0){
    if(n & 1) res *= x;
    x = x * x;
    n >>= 1;
  }
  return res;
}

int main(){
  int X;
  cin >> X;
  int m = sqrt(X);
  int result = 0;
  for(int i = 1; i <= m; i++){
    int n = i;
    while(n <= X && i != 1) n *= i;
    n /= i;
    result = max(result, n);
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;

const int N = 1e5 + 5 ;
ll n , w, DP[101][N];
pair<ll,ll>items[101];

ll calc(int idx,ll weight){
    if (weight > w){
        return - 1e15;
    }
    if (idx == n){
        return 0;
    }

    if (DP[idx][weight]!=-1)return DP[idx][weight];
    ll take = calc(idx + 1 , weight + items[idx].first) + items[idx].second;
    ll dont = calc(idx + 1 , weight);
    return DP[idx][weight] = max(take,dont);
}

int main(){
    fastIO;
    cin>>n>>w;
    memset(DP,-1,sizeof DP);
    for(int i = 0 ; i<n ; i++){
        cin>>items[i].first>>items[i].second;
    }
    cout<<calc(0,0);
}


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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(int i=0; i<(n); i++)
#define REPj(n) for(int j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/* 
	add utility Algorithm
*/

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int A,B;
    cin >> A >> B;
    cout << (A * B) << endl;

    return 0;
}


Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace yukicode001
{
    class Program
    {
        static void Main()
        {
            string[] s_data = Console.ReadLine().Trim().Split(',');

            var x = s_data
                .Select(i => i);

            foreach(var s in x)
            {
                Console.Write(s + " ");
            }
        }
    }
}


Measured memory_bytes: 2776
//ALDS1_4_C Search - Dictionary
#include <stdio.h>
#include <string.h>
#include <vector>
using namespace std;

#define M 1046527
#define NIL (-1)
#define L 14

class Dictionary
{
public:
    char** H; /* Hash Table */

    Dictionary(){
        H = new char* [M];
        for (int i = 0; i < M; i++)
        {
            H[i] = new char[L];
            H[i][0] = '\0';
        }
    }
    ~Dictionary(){
        delete[] H;
        H=0;
    }

    int getChar(char ch)
    {
        if (ch == 'A')
            return 1;
        else if (ch == 'C')
            return 2;
        else if (ch == 'G')
            return 3;
        else if (ch == 'T')
            return 4;
        else
            return 0;
    }

    /* convert a string into an integer value */
    long long getKey(char str[])
    {
        long long sum = 0, p = 1, i;
        for (i = 0; i < strlen(str); i++)
        {
            sum += p * (getChar(str[i]));
            p *= 5;
        }
        return sum;
    }

    int h1(int key) { return key % M; }
    int h2(int key) { return 1 + (key % (M - 1)); }

    int find(char str[])
    {
        long long key, i, h, ha, hb;
        key = getKey(str); //文字列を数値に変換
        for (i = 0;; i++)
        {
            ha = h1(key);
            hb = h2(key);
            h = (ha + i * hb) % M;
            if (strcmp(H[h], str) == 0)
                return 1;
            else if (strlen(H[h]) == 0)
                return 0;
        }
        return 0;
    }

    int insert(char str[])
    {
        long long key, i, h, ha, hb;
        key = getKey(str); //文字列を数値に変換
        for (i = 0;; i++)
        {
            ha = h1(key);
            hb = h2(key);
            h = (ha + i * hb) % M;
            if (strcmp(H[h], str) == 0)
                return 1;
            else if (strlen(H[h]) == 0)
            {
                strcpy(H[h], str);
                return 0;
            }
        }
        return 0;
    }
};

int main()
{
    int i, n, h;
    char str[L], com[9];
    Dictionary dic;
    
    scanf("%d", &n);

    for (i = 0; i < n; i++)
    {
        scanf("%s %s", com, str);

        if (com[0] == 'i')
        {
            dic.insert(str);
        }
        else
        {
            if (dic.find(str))
            {
                printf("yes\n");
            }
            else
            {
                printf("no\n");
            }
        }
    }

    return 0;
}


Measured memory_bytes: 43136
N, M = map(int, input().split())
H = list(map(int, input().split()))
Flags = [1]*N
cnt = N
for _ in range(M):
    A, B = map(int, input().split())
    if H[A-1] <= H[B-1] and Flags[A-1]:
        cnt -= 1; Flags[A-1] = 0
    if H[A-1] >= H[B-1] and Flags[B-1]:
        cnt -= 1; Flags[B-1] = 0

print(cnt)

Measured memory_bytes: 86312
#include<cstdio>
    int a[55];
    int main()
    {
    	int n,m,x;
    	scanf("%d%d",&n,&m);
    	for(int i=1;i<=2*m;i++)
    	{
    		scanf("%d",&x);
    		a[x]++;
    	}
    	for(int i=1;i<=n;i++)
    	printf("%d\n",a[i]);
    	return 0;
    }

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    string s;
    cin>>s;
    int acnt=0,bcnt=0,ccnt=0,n=s.size();
    rep(i,n){
        if(s[i]=='a') acnt++;
        else if(s[i]=='b') bcnt++;
        else ccnt++;
    }
    int mini=min(min(acnt,bcnt),ccnt);
    int maxi=max(max(acnt,bcnt),ccnt);
    if(maxi-mini<=1) cout<<"YES";
    else cout<<"NO";
}

Measured memory_bytes: 3756
"use strict";
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.trim().split(/ |\n/), cid = 0;


let n = +cin.shift();
let B = {};
let C = {};
cin.forEach((v, i) => {
    const x = Number(v);
    B[i + x] = B[i + x] + 1 || 1;
    C[i - x] = C[i - x] + 1 || 1;
});
let ans = 0;
Object.keys(B).filter(i => C[i]).forEach(i => {
    ans += (B[i] * C[i]);
});
console.log(ans);

Measured memory_bytes: 97800
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl endl

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int ceil_(int a, int b) { return (a + (b - 1)) / b; }
int positive_surplus(int &a) { return (a + MOD) % MOD; }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class CStrangeBank {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int N;
    cin >> N;
    vector<int> check(N + 1, INF);
    check[0] = 0;
    rep(i, N) {
      check[i + 1] = min(check[i + 1], check[i] + 1);
      int k        = 6;
      while (i+ k <= N) {
        check[i+k] = min(check[i+k], check[i] + 1);
        k *= 6;
      }
      k        = 9;
      while (i+ k <= N) {
        check[i+k] = min(check[i+k], check[i] + 1);
        k *= 9;
      }
    }
    cout << check[N] << endl;
  }
};


signed main() {
  CStrangeBank solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 1024
object Main extends App{
  var Array(a,b) = readLine.split(" ").map(_.toInt)
  var sum = 0L
  if((b>21)&&(a>3)){
    for(i <- 22 to b if((i%10>1)&&(i/10>1))) {
      if(a >= (i/10) * (i%10)) {
        sum = sum + 1
      }
    }
  }
  print(sum)
}

Measured memory_bytes: 27172
n = input()

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

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

int x[100010];

int main(){
	int n,k; cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>x[i];
	}
	int ans=500000000;
	for(int i=0;i<=n-k;i++){
		int s=x[i];
		int g=x[i+k-1];
		if(s<=0&&g<=0){
			ans=min(0-s,ans);
		}else if(s>=0&&g>=0){
			ans=min(g-0,ans);
		}else{
			int a=min(g-0,0-s);
			a+=g-s;
			ans=min(ans,a);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n,m,x;
  cin>>n>>m>>x;
  int c[n];
  int a[n][m];
  rep(i,0,n){
    cin>>c[i];
    rep(j,0,m){
      cin>>a[i][j];
    }
  }
  int ans=2e6;
  rep(i,0,1<<n){
    int cur=0;
    int judge[m];
    rep(j,0,m){
      judge[j]=0;
    }
    rep(j,0,n){
      if(1 & i>>j){
        cur+=c[j];
        rep(k,0,m){
          judge[k]+=a[j][k];
        }
      }
    }
    bool p=true;
    rep(j,0,m){
      if(judge[j]<x){
        p=false;
      }
    }
    if(p){
      ans=min(ans,cur);
    }
  }
  if(ans==2e6){
    cout<<-1<<endl;
  }
  else{
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3636
fun main(args: Array<String>) {
    val (n,q) = readLine()!!.split(" ").map { it.toInt() }
    val s = readLine()!!
    val lr = (1..q).map { readLine()!!.split(" ").map { it.toInt()-1 } }

    val ac = IntArray(n)
    for(i in 1..n-1){
        if(s[i-1]=='A' && s[i]=='C') ac[i]=ac[i-1]+1
        else ac[i]=ac[i-1]
    }
    val ans = lr.map {
        val (l,r)=it
        ac[r]-ac[l]
    }
    println( ans.fold(StringBuilder()){ acc ,i-> acc.appendln(i) } )
}



Measured memory_bytes: 65212
n, k = gets.split.map(&:to_i)
cnt = Hash.new(0)

n.times do
  a, b = gets.split.map(&:to_i)
  cnt[a] += b
end

k -= 1
cur = 0
cnt.map { |k, v| [k, v] }.sort.each do |x, c|
  # p [cur, k, c]
  if cur <= k && k < cur + c
    puts x
    break
  end
  cur += c
end


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

using ll = long long;

int main() {
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  a*=4; b*=2;
  c = min(a,min(b,c));
  ll n; cin >> n;
  ll ans = n/2*min(d,2*c);
  if (n&1) ans += c;
  cout << ans << endl;
	
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

ll ans;

int main(void) {
    ll h, w;
    cin >> h >> w;
    if (h==1 || w == 1) ans = 1;
    else {
        ans = h*w;
        if (ans%2!=0) ans = (ans+1)/2;
        else ans /= 2;
    }


    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
use proconio::input;
use std::cmp::Ordering;
use std::cmp::max;

fn cross((lx,ly):(i64,i64),(rx,ry):(i64,i64)) -> i64 {lx*ry-ly*rx}
fn dot((lx,ly):(i64,i64),(rx,ry):(i64,i64)) -> i64 {lx*rx+ly*ry}

fn quad(x:i64,y:i64) -> usize{
    if x>0 && y>=0 {0}
    else if x<=0 && y>0 {1}
    else if x<0 && y<=0 {2}
    else if x>=0 && y<0 {3}
    else {4}
}

fn cmp(&(lx,ly):&(i64,i64),&(rx,ry):&(i64,i64)) -> Ordering {
    let lq = quad(lx,ly);
    let rq = quad(rx,ry);
    if lq!=rq {
        lq.cmp(&rq)
    }
    else {
        (-cross((lx,ly),(rx,ry))).cmp(&0)
    }
}

fn main() {
    input! {
        n:usize,
        xy:[(i64,i64);n]
    };
    let mut xy:Vec<_> = xy.into_iter().filter(|&(x,y)|(x,y)!=(0,0)).collect();
    xy.sort_by(cmp);
    let xy = xy;
    let n = xy.len();
    if n==0 {
        println!("0");
        return;
    }
    let mut l = 0;
    let mut r = 1;
    let mut cnt = 1;
    let (mut xsum ,mut ysum)= xy[0];

    let mut ans = xsum*xsum + ysum*ysum;

    while l<2*n {
        let crs = cross(xy[l%n],xy[r%n]);
        let b = crs>0 || crs==0 && dot(xy[l%n],xy[r%n])>0;
        if cnt==n || cnt!=0 && !b {
            let (x,y) = xy[l%n];
            xsum -= x;
            ysum -= y;
            cnt-=1;
            l+=1;
        }
        else {
            let (x,y) = xy[r%n];
            xsum += x;
            ysum += y;
            cnt+=1;
            r+=1;
        }
        ans = max(ans,xsum*xsum+ysum*ysum);
    }
    println!("{:.12}",(ans as f64).sqrt());
}

Measured memory_bytes: 2212
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX;
const ll MOD = 1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >>S;
  string T="keyence";
  int i;
  for(i=0;i<T.length()&&S[i]==T[i];i++);
  for(;i<T.length()&&S[S.length()-T.length()+i]==T[i];i++);
  cout <<(i==T.length()? "YES":"NO")<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(){
  char arr[256];
  scanf("%s", arr);
  for(int i = 0 ; i < 4 ; i++)
    putchar(arr[i]);
  putchar(' ');
  for(int i = 4 ; arr[i] ; i++)
    putchar(arr[i]); 
  puts("");
  return 0;
}


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

Measured memory_bytes: 256