akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double INF=1e+10;
const long double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		// if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ


int main(){
	int a,b;scanf("%d%d",&a,&b);
	if(a==b)printf("Yes\n");else printf("No\n");
}

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


int main(){
	int n,a;
	double b;
	cin >> n;
	for(int i=1;i<=n;i++){
		b=i;
		b*=1.08;
		a=b;
		if(a==n){
			cout << i << endl;
			return 0;
		}
	}
	
	cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define FOR(i,n) for(int i = 0; i < n; i++)
#define FORa(i,a,b) for(int i = a; i < b; i++)
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define SORT(a,n) sort(begin(a), begin(a) + n)
#define VSORT(v) sort(v.begin(), v.end())
#define MAX 1000000
#define ll long long
#define LOW(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define UP(s) transform(s.begin(),s.end(),s.begin(),::toupper)

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

int main() {
	ll a,b,c,d;
	
	cin >> a >> b >> c >> d;
	cout << max(max(a*c,a*d), max(b*c,b*d)) << endl;
	
  return 0;
}

Measured memory_bytes: 3628
function Main(input) {
  const contest = ['ABC', 'ARC', 'AGC']
  var i = 0
  var r = Number(input[0])
  if (r >= 1200) { i++ }
  if (r >= 2800) { i++ }
  console.log(contest[i])
}


Main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'))


Measured memory_bytes: 22076
#include <bits/stdc++.h>
using namespace std;
#define maxn 100001

int p[maxn];

int main()
{
	int n, i, ret = 0;
	scanf("%d", &n);
	for(i = 1; i <= n; i++)
		scanf("%d", p + i);
	for(i = 1; i <= n; i++)
		ret += p[p[i]] == i;
	ret >>= 1;
	printf("%d", ret);
	return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>

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

int main() {

	int N,M;
	scanf("%d%d", &N,&M);

	
		
	printf("%d\n", N+M/2);

	return 0;
}


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

int main() {

    int x,y;
    for(;;){
    cin>>x>>y;
        if((x+y)==0){
        return 0;
        }
        else if(x<y){
            cout<<x<<" "<<y<<endl;
        }
        else{
            cout<<y<<" "<<x<<endl;
        }

    }


}



Measured memory_bytes: 3068
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}
	
	private void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		for (int p = 0; p < n; p++) {
			double x1 = scan.nextDouble();
			double y1 = scan.nextDouble();
			double x2 = scan.nextDouble();
			double y2 = scan.nextDouble();
			double x3 = scan.nextDouble();
			double y3 = scan.nextDouble();
			
			double a = Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
			double b = Math.sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3));
			double c = Math.sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1));
			
			double r = a * b * c / Math.sqrt((a + b + c) * (-a + b + c) * (a - b + c) * (a + b - c));
			
			a = 2 * (x2 - x1);
			b = 2 * (y2 - y1);
			double e = x2 * x2 - x1 * x1 + y2 * y2 - y1 * y1;
			c = 2 * (x1 - x3);
			double d = 2 * (y1 - y3);
			double f = x1 * x1 - x3 * x3 + y1 * y1- y3 * y3;
			
			
			double px = (e * d - b * f) / (a * d - b * c);
			double py = (a * f - e * c) / (a * d - b * c);
			
			System.out.printf("%.3f %.3f %.3f\n", px, py, r);
		}
	}

}

Measured memory_bytes: 20724
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
const int MOD = 1e9+7;

int main(){
 ll n,t; cin>>n>>t;
 ll time[n];
 ll sum=0;
 FOR(i,0,n)cin>>time[i];
 FOR(i,1,n){
   if(time[i]-time[i-1]>=t)sum+=t;
   else sum+=time[i]-time[i-1];
 }
  sum+=t;
  cout<<sum<<endl;
}


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

const int INF = 100000000;

int main()
{
  int n, m, x, tmp;
  cin >> n >> m >> x;
  int c[n];
  int a[n][m];
  rep(i, n) {
    cin >> c[i];
    rep(j, m) {
      cin >> a[i][j];
    }
  }
  int res = INF;
  for (int i = 0; i < 1<<n; i++) {
    int num = i;
    int cost = 0;
    vector<int> learn(m, 0);
    for (int j = 0; j < n; j++) {
      if (num % 2 == 1) {
        cost += c[j];
        for (int k = 0; k < m; k++) {
          learn[k] += a[j][k];
        }
      }
      num /= 2;
      if (num == 0) break;
    }
    bool jdg = true;
    rep(i, m) {
      if (learn[i] < x) {
        jdg = false;
        break;
      }
    }
    if (jdg) {
      res = min(res, cost);
    }
  }
  if (res == INF) res = -1;
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int ans,i;
string s;
int main()
{
	cin>>s;
	for(i=1;i<s.size();i++)
	{
		if(s[i]!=s[i-1])
		{
			ans++;
		}
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

#define ll long long
#define ar array


int n;
int a[10000001];


void solve(){
    cin >> n;

    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        a[i] = 0;
    }
    
    for (int i = 1; i < n+1; i++)
    {
        for (int j = i; j < n+1; j+=i)
        {
            a[j]++;
        }
        
    }
    
    for (int i = 1; i < n+1; i++)
    {
        ans += (ll)a[i]*(ll)i;
    }
    

    cout << ans << endl;
}





int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    solve();

}

Measured memory_bytes: 42720
from sys import stdin
input = stdin.readline

n = int(input())
ans = 0
c = []
for i in range(n):
	x = input()[:-1]
	if '.' not in x:
		x += '.'
	cnt = len(x) - x.rfind('.') - 1
	x = int(x.replace('.', '')) * 10 ** (9 - cnt)
	#print(x)
	a = b = 0
	while not x & 1:
		a += 1
		x >>= 1
	while not x % 5:
		b += 1
		x //= 5
	c.append((a, b))
c.sort()
#print(c)
s = [0] * 20
j = n - 1
for i in range(n):
	while j >= 0 and c[j][0] >= 18 - c[i][0]:
		s[c[j][1]] += 1
		j -= 1
	#print(s)
	for k in range(18 - c[i][1], 20):
		ans += s[k]
for i in c:
	if 2 * min(i) >= 18:
		ans -= 1
print(ans // 2)

Measured memory_bytes: 88972
#include <stdio.h>

int selectionSort(int a[], int n){
    int i, j, t, sw = 0, minj;
    for ( i = 0; i < n - 1; i++ ){
	  	minj = i ;
	  	for ( j = i; j < n; j++ ){
	  	   if ( a[j] < a[minj] )
	  	   minj = j;
	  	}
	    t = a[i];
	    a[i] = a[minj];
	    a[minj] = t;
	    if ( i != minj)
	    sw++;
	}
	return sw;
}
    
int main() {
	int a[100], n, i, sw;
	
	scanf("%d", &n);
	for ( i = 0; i < n; i++)
        scanf("%d", &a[i]);
        
    sw = selectionSort(a, n);
    
    for( i = 0; i < n; i++){
        if ( i > 0 )
        printf(" "); 
        printf("%d",a[i]);
    }
    printf("\n");
    printf("%d\n",sw);
    
    return 0;
}

Measured memory_bytes: 604
#include <stdio.h>

void core() {
	int N;
	scanf("%d", &N);
	int i=1;
	while( (1+i)*i < N*2 ){
		i++;
	}
	while(N>0){
		if(N-i>=0){
			printf("%d\n",i);
			N-=i;
		}
		i--;
	}
}

int main() {
	core();
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pie acos(-1)
#define loop(i,a,n) for(int i=a;i<n;i++)
#define trav(a,x) for(auto &a:x)
#define vi vector<int>
#define vl vector<ll>
#define pii pair<ll,ll>
#define endl "\n"
#define w 1e5
int l,b;
int a[1000+1][1000+1];
vector<vl>dp(1001,vl(1001));
void add_self(ll &a,ll b)
{
    a+=b;
    if(a>M)
        a=a-M;
}
void solve()
{
    cin>>l>>b;
    string dum[l+1];
    loop(i,1,l+1)
    {
        cin>>dum[i];
        dum[i]=" "+dum[i];
    }
    loop(i,1,l+1)
    {
        loop(j,1,b+1)
        {
            char x=dum[i][j];
            if(x=='.')
            a[i][j]=1;
            else
            a[i][j]=0;
        }
    }
    dp[1][1]=1;
    loop(i,1,l+1)
    {
        loop(j,1,b+1)
        {
            for(int r:{i,i+1})
            {
                int c=j;
                if(r==i)
                c=j+1;
                if(r<=l && c<=b && a[r][c]==1)
                {
                    add_self(dp[r][c],dp[i][j]);
                }
            }
        }
    }
    cout<<dp[l][b];
}
int main() {
	// your code goes here
	io;
    solve();
	return 0;
}


Measured memory_bytes: 13056
from datetime import timedelta
def f(h,m,s):
    return timedelta(hours=h,minutes=m,seconds=s)

t1=f(2,0,0)
while 1:
    h,m,s=map(int,raw_input().split())
    if [h,m,s]==[-1,-1,-1]: break
    t=t1-f(h,m,s)
    t3=t*3
    print "0"+str(t)
    print "0"+str(t3)

Measured memory_bytes: 4420
#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
using namespace std;
#define MAXN 21
int k , n , dp[1 << 21][21];
char ch[1 << 21];
int main() {
    cin >> n >> k;
    for( int i = 0 ; i <= n ; ++ i ) {
        scanf("%s",ch);
        for( int j = 0 ; j < ( 1 << i ) ; ++ j )
            dp[( 1 << i ) | j][i] = ( ch[j] == '1' );
    }
    int re1 = 0 , re2 = 0;
    for( int i = n ; i >= 0 ; -- i ) {
        for( int j = 0 ; j < ( 1 << i ) ; ++ j ) // sta : ( 1 << i ) | j
            for( int k = i ; k > 0 ; -- k ) if( dp[( 1 << i ) | j][k] ) {
                int S = ( j >> k ) , T = ( j & ( 1 << k ) - 1 ) , f = dp[( 1 << i ) | j][k];
                dp[( 1 << i - k ) | S][0] += f;
                int ls = T & ( 1 << k ) - 1 , re = (~T) & ( 1 << k ) - 1;
                if( T ) {
                    int u = 31 - __builtin_clz( ls );
//                    cout << ls << ' ' << u << endl;
                    dp[( 1 << i - k + u + 1 ) | ( S << u + 1 ) | ( 1 << u ) | ( T & ( 1 << u ) - 1 )][u] += f;
                }
                if( re ) {
                    int u = 31 - __builtin_clz( re );
//                    cout << T << ' ' << u << ' ' << k << endl;
                    dp[( 1 << i - k + u + 1 ) | ( S << u + 1 ) | ( T & ( 1 << u ) - 1)][u] += f;
                }
            }
    }
    for( int i = n ; i >= 0 ; -- i )
        for( int j = 0 ; j < ( 1 << i ) ; ++ j ) if( dp[( 1 << i ) | j][0] >= k ) {
            for( int k = i - 1 ; k >= 0 ; -- k ) printf("%1d",( j >> k ) & 1);
            return 0;
        }
}

Measured memory_bytes: 173440
s = input()

if s[0] != 'A':
    print('WA')
    exit(0)

cnt = 0
i = 0
for j, c in enumerate(s):
    if j <= 1 or j == len(s) - 1:
        continue
    if c == 'C':
        cnt += 1
        if cnt == 2:
            print('WA')
            exit(0)
        i = j
if cnt == 0:
    print('WA')
    exit(0)

for j, c in enumerate(s):
    if j == 0 or j == i:
        continue
    if str(c).isupper():
        print('WA')
        exit(0)

print('AC')


Measured memory_bytes: 3064
// ARC103E.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 1e5 + 200;

int n, ai[MAX_N], cost[MAX_N][2];
vector<int> pos[MAX_N];
multiset<int> ms[2];

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &ai[i]), pos[ai[i]].push_back(i);
    for (int i = 1; i <= 1e5; i++)
        for (auto &x : pos[i])
            cost[i][x & 1]++;
    ms[0].insert(0), ms[1].insert(0);
    for (int i = 1; i <= 1e5; i++)
        ms[0].insert(cost[i][0]), ms[1].insert(cost[i][1]);
    int ans = 0;
    for (int i = 1; i <= 1e5; i++)
    {
        // as the odd one;
        ms[0].erase(ms[0].find(cost[i][0])), ms[1].erase(ms[1].find(cost[i][1]));
        ans = max(ans, cost[i][0] + *ms[1].rbegin());
        ans = max(ans, cost[i][1] + *ms[0].rbegin());
        ms[0].insert(cost[i][0]), ms[1].insert(cost[i][1]);
    }
    printf("%d\n", n - ans);
    return 0;
}

Measured memory_bytes: 16256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int A,B,C,D;
	cin >> A >> B >> C >> D;

	while (true)
	{
		C -= B;
		if (C <= 0)
		{
			cout << "Yes" << endl;
			break;
		}
		A -= D;
		if (A <= 0)
		{
			cout << "No" << endl;
			break;
		}
	}
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;

ll n, m, q;
vector<long long> a, b, c, d;

int score(const vector<int> &A) {
  ll res = 0;
  for (int i = 0; i < q; i++) {
    if (A[b[i]] - A[a[i]] == c[i]) {
      res += d[i];
    }
  }

  return res;
}

ll dfs(vector<int> &A) {
  if (A.size() == n) {
    return score(A);
  }

  ll res = 0;
  int prev_last = (A.empty() ? 0 : A.back());
  for (int v = prev_last; v < m; v++) {
    A.push_back(v);
    res = max(res, dfs(A));
    A.pop_back();
  }

  return res;
}

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

  a.resize(q); b.resize(q); c.resize(q); d.resize(q);
  for (int i = 0; i < q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--, b[i]--;
  }

  vector<int> A;
  cout << dfs(A) << endl;

  return 0;
}

Measured memory_bytes: 3612
package main

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

//=====I/O=====

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

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

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

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n,t := scanInt(), scanInt()

	ds := make(dishes, n)

	for i := 0; i < n; i++ {
		ds[i] = dish{scanInt(),scanInt()}
	}

	sort.Sort(ds)

	dp := [3001][6001]int{}

	for i := 0; i < n; i++ {
		for j := 0; j < 6001; j++ {
			dp[i+1][j] = dp[i][j]

			if j - ds[i].a < 0 || t-1 < j - ds[i].a {
				continue
			}

			dp[i+1][j] = max(dp[i+1][j], dp[i][j-ds[i].a]+ds[i].b)
		}
	}

	ans := 0
	for i := 0; i < 6001; i++ {
		ans = max(ans, dp[n][i])
	}

	fmt.Println(ans)
}

type dish struct {
	a int
	b int
}

func min(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res > a[i] { res = a[i] }
	}
	return res
}

func max(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res < a[i] { res = a[i] }
	}
	return res
}

type dishes []dish

func (a dishes) Len() int           { return len(a) }
func (a dishes) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a dishes) Less(i, j int) bool { return a[i].a < a[j].a }


Measured memory_bytes: 146048
r, c = map(int, input().split())
a = [[0] * c for i in range(r + 1)]
for i in range(r):
    a[i] = list(map(int, input().split()))
for j in range(c):
    for i in range(r):
        a[r][j] += a[i][j]
for i in range(r + 1):
    m = 0
    for j in range(c):
        m += a[i][j]
        print(a[i][j], end=" ")
    print(m)


Measured memory_bytes: 6220
#include<cstdio>
#include<iostream>

using namespace std;

int n, a[100000];
bool jud[100000];


int main(void) {

	cin >> n;

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

	int cur = 0, num = 0;

	while(1){
		//printf("a=%d\n", a[cur]);
		

		if (a[cur] == 1) {
			num++;
			cout << num << "\n";
			break;
		}
		else if (jud[a[cur]]) {
			cout << "-1\n";
			break;
		}
		else {
			jud[a[cur]] = true;
			cur = a[cur];
			num++;	
		}
	}

	

	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<queue>
using namespace std;

int main(void)
{
	int N;
	cin >> N;

	vector<int> nine(1, 9), six(1, 6);
	for(; nine.back()<=N;)
		nine.push_back(nine.back() * nine[0]);
	for(; six.back()<=N;)
		six.push_back(six.back() * six[0]);

	priority_queue<pair<int, int>> task;
	vector<int> cnt(N+1, N);
	task.push(make_pair(0, 0));
	while(task.empty() != true){
		auto t = task.top();
		task.pop();

		int p = t.first;
		int c = t.second;

		if(p > N || c >= cnt[p])
			continue;

		cnt[p] = c;

		// 1
		task.push(make_pair(p+1, c+1));
		// 6
		for(int i=0; i<six.size(); i++)
			task.push(make_pair(p+six[i], c+1));
		// 9
		for(int i=0; i<nine.size(); i++)
			task.push(make_pair(p+nine[i], c+1));
	}

	cout << cnt[N] << endl;

	return 0;
}


Measured memory_bytes: 640
package main

import (
    "fmt"
    "os"
    "bufio"
    "strconv"
    // "sort"
)
var sc = bufio.NewScanner(os.Stdin)


func main() {
    sc.Split(bufio.ScanWords)
    // code goes here
    a := nextInt()
    b := nextInt()
    c := nextInt()
    
    x := b/a;
    fmt.Println(Min(c, x));
}



func nextInt() int {
    sc.Scan()
    v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}
func nextInt64() int64 {
    sc.Scan()
    v, e := strconv.ParseInt(sc.Text(), 10, 64)
    if e != nil { panic(e) }
    return v
}
func nextString() string {
    sc.Scan()
    return sc.Text()
}
func nextFloat() float64 {
    sc.Scan()
    v, e := strconv.ParseFloat(sc.Text(), 64)
    if e != nil { panic(e) }
    return v
}
func Max(x, y int) int { if x > y { return x }; return y }
func Min(x, y int) int { if x < y { return x }; return y }
func Abs(x int) int { if x > 0 { return x }; return -x }



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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

map< int, int > prime_factor(int n) {
  map< int, int > ret;
  for(int i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main() {
  int N; cin >> N;
  vector<int> A(N); REP(i, N) cin >> A[i];
  sort(all(A));
  vector<int> res(1000005); REP(i, 1000005) res[i] = 0;
  int ans = 0;

  for(int i = 0; i < N; ++i) {
    if(res[A[i]] > 1) continue;
    for(int k = A[i]; k < 1000005; k += A[i]) {
      res[k]++;
      if(k > A[N - 1] + 1) break;
    }
  }

  REP(i, N) {
    if(res[A[i]] == 1) ans++;
  }

  if(N == 1) cout << 1 << endl;
  else cout << ans << endl;
}


Measured memory_bytes: 7952
#include <iostream>

#include<vector>

#include<string>

#include<algorithm>

#include<cmath>

#include<cstdlib>

#include<utility> 

#include<cstdio> 

#define vii vector< pair<int,int> >

#define vi vector<int>

#define INF 1000000007

#define ff first

#define ss second

#define lli long long int

#define ulli unsigned long long int

using namespace std;

int main() {

 ios_base::sync_with_stdio(false);

    cin.tie(NULL);

  int n,x,t;

  cin>>n>>x>>t;

  int cn=0;

  while(n>0){

    n-=x;

    cn+=t;

  }

  cout<<cn<<endl;

}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;

using namespace std;

struct Edge
{
	int from;
	int to;
	Edge(int to, int from)
		:from(from), to(to)
	{}
	Edge()
	{}
};

ll Map[105][105];
ll INF = (1 << 29) + 1;

int N, M;
bool U[1005];
Edge e[1005];
int P[105][105];

void path(int s, int g)
{
	if (s == g)
	{
		return;
	}
	int p = g;
	int c = p;
	while (c != s)
	{
		c = P[s][p];
		REP(i, M)
		{
			if ((c == e[i].to&&p == e[i].from)
				|| (c == e[i].from&&p == e[i].to))
			{
				U[i] = true;
				break;
			}
		}
		p = c;
	}
}

int main()
{
	cin >> N >> M;

	REP(i, N)
	{
		REP(j, N)
		{
			Map[i][j] = INF;
			P[i][j] = i;
		}
		Map[i][i] = 0;
	}
	REP(i, M)
	{
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		Map[a][b] = Map[b][a] = c;
		e[i] = Edge(a, b);
	}

	REP(k, N)
	{
		REP(i, N)
		{
			REP(j, N)
			{
				if (Map[i][j] > Map[i][k] + Map[k][j])
				{
					Map[i][j] = Map[i][k] + Map[k][j];
					P[i][j] = P[k][j];
				}
			}
		}
	}

	REP(i, N)
	{
		REP(j, N)
		{
			path(i, j);
		}
	}

	int ans = 0;
	REP(i, M)
	{
		if (U[i] == false)
		{
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#[allow(unused_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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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")
    };
}

fn main() {
    input! {
        s: chars,
    }
    let n = s.len();
    for i in 0..n / 2 {
        if s[i] != s[n - 1 - i] {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 4352
using System;

namespace AOJ.Volume2
{
    public class HitAndBlow
    {
        public static int Main()
        {
            while (true)
            {
                var input = Console.ReadLine().Split(' ');
                string correct = input[0];
                string answer = input[1];

                if(correct == "0") { break; }

                int hit = 0;
                string tmp_c = "";
                string tmp_a = "";
                for(int i = 0; i <= 3; i++)
                {
                    if(correct[i] == answer[i]) { hit++; }
                    else
                    {
                        tmp_c += correct[i];
                        tmp_a += answer[i];
                    }
                }

                int blow = 0;
                for(int i = 0; i < tmp_c.Length; i++)
                {
                    if (tmp_a.IndexOf(tmp_c[i]) >= 0) { blow++; }
                }

                Console.WriteLine(string.Format("{0} {1}", hit, blow));
            }
            return 0;
        }
    }
}

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

int main() {
	// your code goes here
	long long r,d,x,i;
	cin >> r >> d >> x;
	for(i=1;i<=10;i++){
		x=r*x-d;
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N = 4
M = 3
A = []
B = []
for i in range(M):
    a, b = map(int, input().split())
    A += [a]
    B += [b]

ans = False


def dfs(v, S):
    global ans
    # print(v, S)
    if len(S) == N:
        ans = True

    for i in range(M):
        if v == A[i] and B[i] not in S:
            t = set(S)
            t.add(B[i])
            dfs(B[i], t)
        if v == B[i] and A[i] not in S:
            t = set(S)
            t.add(A[i])
            dfs(A[i], t)

dfs(1, set([1]))
if ans:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    int l,r,d;
    cin>>l>>r>>d;
    int count = 0;
    for(int i = l;i<=r;i++)
    {
        if(i%d==0)
        {
            count++;
        }
    }
    cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ull unsigned long long
#define lli long long int
#define pb push_back
ll mob=1000000007;
using namespace std;
int main()
{ 
int n;
cin>>n;
unordered_set<string> g;
FOR(i,n){
    string h;
    cin>>h;
    g.insert(h);
    
}
cout<<g.size();



return 0;
}











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

using namespace std;


int digitsSum(int n) {
    int res = 0;
    while (n > 0) {
        res += n % 10;
        n /= 10;
    }
    return res;
}


bool isExponential(int n) {
    auto tmp = to_string(n).length() - 1;
    return n == pow(10, tmp);
}


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

    if (isExponential(n)) {
        cout << 10 << endl;
    } else {
        cout << digitsSum(n) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long x = Long.parseLong(sc.next());
		
		long temp = 100;
		int cnt = 1;
		
		while(true) {
			
			long p = (long) ((long)temp * 0.01);
			temp = p +temp;
			if(temp >= x) {
				System.out.println(cnt);
				return;
			}
			cnt++;
		}

	}

}


Measured memory_bytes: 35620
#include <stdio.h>
int main(){
  int i,x;
  for(i=1;i>0;i++)
    {
      scanf("%d",&x);
	if(x!=0){      
	printf("Case %d: %d\n",i,x);
	}
      else{
	break;
      }
    }
    return 0;
}

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

int main() {
  int N;
  scanf("%d\n", &N);

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

  int all_cost = 0;
  for (int i = 0; i < N-1; i++) all_cost += abs(A[i+1] - A[i]);

  all_cost += abs(A[0]) + abs(A[N-1]);

  for (int i = 0; i < N; i++) {
    int cost = all_cost;
    if (i == 0) {
      cost -= abs(A[0]) + abs(A[1] - A[0]);
      cost += abs(A[1]);
    } else if (i == N-1) {
      cost -= abs(A[N-1]) + abs(A[N-1] - A[N-2]);
      cost += abs(A[N-2]);
    } else {
      cost -= abs(A[i] - A[i-1]) + abs(A[i+1] - A[i]);
      cost += abs(A[i+1] - A[i-1]);
    }

    printf("%d\n", cost);
  }

  return 0;
}

Measured memory_bytes: 4196
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

a,b,k = inpl()
res = []
for i in range(k):
    if a+i <= b and not a+i in res:
        res.append(a+i)
    if b-i >= a and not b-i in res:
        res.append(b-i)
res.sort()
print(*res)

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int ans = 0;
  vector<int> L(2 * N);
  REP(i, 2 * N) cin >> L[i];
  sort(L.begin(), L.end());
  for(int i = 0; i < 2 * N; i += 2) {
    ans += L[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
const int N=5005;
int n,m,a[N],b[205][N],tp[205],s[205][N],c[N],ans;
signed main(){
	scanf("%lld%lld",&n,&m);
	for (int i=2;i<=n;i++) scanf("%lld",&a[i]);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++) scanf("%lld",&b[j][i]);
	for (int l=n;l>=1;l--){
		for (int i=1;i<=m;i++){
			while (tp[i] && b[i][l]>=b[i][s[i][tp[i]]]){
				int x=s[i][tp[i]];
				c[x]-=b[i][x];
				c[s[i][--tp[i]]]+=b[i][x];
			}
			if (tp[i]) c[s[i][tp[i]]]-=b[i][l];
			s[i][++tp[i]]=l;
			c[l]+=b[i][l];
		}
		int sum=c[l];
		ans=std::max(ans,c[l]); 
		for (int i=l+1;i<=n;i++) sum+=c[i]-a[i],ans=std::max(ans,sum);
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 14464
#![allow(unused_imports)]
#![allow(dead_code)]

use std::thread;
use std::io::{ self, Read };
use std::fmt;
use std::iter::Iterator;
use std::cmp::*;
use std::collections::*;
use std::str::*;

#[derive(Default)]
struct Input {
    buf: Vec<String>
}

impl Input {
    fn new() -> Input {
        Input { buf: Vec::new() }
    }

    fn read<T: FromStr>(&mut self) -> T 
    where <T as FromStr>::Err: fmt::Debug {
        self.next().unwrap().parse::<T>().unwrap()
    }

    fn read_2<T: FromStr, U: FromStr>(&mut self) -> (T, U)
    where <T as FromStr>::Err: fmt::Debug,
          <U as FromStr>::Err: fmt::Debug {
        (self.read(), self.read())
    }

    fn read_bytes(&mut self) -> Vec<u8> {
        self.next().unwrap().into_bytes()
    }

    fn read_n<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where <T as FromStr>::Err: fmt::Debug {
        let mut v = Vec::new();
        for _ in 0..n { v.push(self.read::<T>()); }
        v
    }
}

impl Iterator for Input {
    type Item = String;
    fn next(&mut self) -> Option<String> {
        while self.buf.is_empty() {
            let mut s = String::new();
            let _res = io::stdin().read_line(&mut s);
            self.buf = s.split_whitespace().map(|s| s.to_owned()).collect::<Vec<_>>();
            self.buf.reverse();
        }
        self.buf.pop()
    }
}

fn run() {
    let mut ip = Input::new();
    let m: i64 = ip.read();
    println!("{}", 48 - m);
}

fn main() {
    let _ = thread::Builder::new()
        .stack_size(10 * 1024 * 1024)
        .spawn(run).unwrap()
        .join();
}

Measured memory_bytes: 8572
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
 int n,c,k;
  cin >> n >> c >> k;
 vector<int> t(n);
  for(int i=0;i<n;i++) cin >> t[i];
  
  sort(t.begin(),t.end());
  
  int res=0;
  int front=0;
  int cnt=1;
  
  for(int i=1;i<n;i++){
     if(t[i]>t[front]+k||cnt==c){
       res++;
       front=i;
       cnt=1;
     }
     else{
      cnt++;
     }

  }
 cout << res+1 << endl;
}

Measured memory_bytes: 640
use std::io;
use std::str;

pub struct Scanner<R> {
    reader: R,
    buffer: Vec<String>,
}

impl<R: io::BufRead> Scanner<R> {
    pub fn new(reader: R) -> Self {
        Self {
            reader,
            buffer: vec![],
        }
    }

    pub fn token<T: str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            self.reader.read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }

    pub fn tokens<T: str::FromStr>(&mut self) -> Vec<T> {
        assert!(self.buffer.is_empty());
        let mut input = String::new();
        self.reader.read_line(&mut input).expect("Failed read");
        input
            .split_whitespace()
            .map(|x| x.parse().ok().expect("Failed parse"))
            .collect()
    }
}

fn pull_dp(n: usize, max_weight: usize, weights: &[i64], values: &[i64]) -> i64 {
    let mut dp = vec![0; max_weight + 1];
    for i in 0..n {
        let mut new_dp = vec![0; max_weight + 1];
        for w in 0..=max_weight {
            new_dp[w] = dp[w];
            if (w as i64) - weights[i] >= 0 {
                new_dp[w] = new_dp[w].max(dp[w - weights[i] as usize] + values[i]);
            }
        }
        dp = new_dp;
    }
    dp[max_weight]
}

fn max_self(a: &mut i64, b: i64) {
    *a = (*a).max(b);
}

fn push_dp(n: usize, max_weight: usize, weights: &[i64], values: &[i64]) -> i64 {
    let mut dp = vec![0; max_weight + 1];
    for i in 0..n {
        for cur_weight in (0..=(max_weight as i64 - weights[i])).rev() {
            let use_item_weight = dp[cur_weight as usize] + values[i];
            max_self(&mut dp[(cur_weight + weights[i]) as usize], use_item_weight);
        }
    }
    let mut ans = 0;
    for w in 0..=max_weight {
        ans = ans.max(dp[w]);
    }
    ans
}

// f(0, W) = 0
// f(n, W) = f(n - 1, W)
// f(n, W) = f(n - 1, W - weights[n]) + values[n]
fn solve<R: io::BufRead, W: io::Write>(scan: &mut Scanner<R>, out: &mut W) {
    let n: usize = scan.token();
    let max_weight: usize = scan.token();
    let mut weights = Vec::new();
    let mut values = Vec::new();
    for _ in 0..n {
        weights.push(scan.token::<i64>());
        values.push(scan.token::<i64>());
    }
    let ans1 = push_dp(n, max_weight, &weights, &values);
    // let ans2 = pull_dp(n, max_weight, &weights, &values);
    // assert!(ans1 == ans2);
    writeln!(out, "{}", ans1).ok();
}

fn main() {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = Scanner::new(stdin.lock());
    let mut out = io::BufWriter::new(stdout.lock());
    solve(&mut scan, &mut out);
}


Measured memory_bytes: 2868
// Jump, and you will find out how to unfold your wings as you fall.

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxn=1e5+10,mod=1e9+7;
const ll inf=1e18;

int dg[maxn];
vector<int>v[maxn];
bool mark[maxn];
set<int>st;

void dfs(int u){
    mark[u]=1;
    for(int y:v[u]){
	if(dg[y]==4)
	    st.insert(y);
	else if(!mark[y])
	    dfs(y);
    }
}

void Ans(bool b){
    cout<<(b?"Yes\n":"No\n"),exit(0);
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    int n,m,cnt=0,mx=0;cin>>n>>m;
    for(int i=0;i<m;i++){
	int a,b;cin>>a>>b;
	v[a].PB(b);
	v[b].PB(a);
	++dg[a],++dg[b];
    }
    for(int i=1;i<=n;i++){
	if(dg[i]&1)
	    Ans(0);
	if(dg[i]>=4)
	    cnt++;
	mx=max(mx,dg[i]);
    }
    if(mx>=6)
	Ans(1);
    if(cnt==1)
	Ans(0);
    if(cnt>2)
	Ans(1);
    for(int i=1;i<=n;i++){
	st.clear();
	if(!mark[i] && dg[i]==4){
	    dfs(i);
	    if(sz(st)==1)
		Ans(1);
	}
    }
    Ans(0);
}
// Deathly mistakes:
//  * Read the problem curfully.
//  * Check maxn.
//  * Overflows.


Measured memory_bytes: 7424
n = int(input())
lis = []
for _ in range(n):
  lis.append(int(input()))
lis_up = [-1]*n
lis_down = [-1]*n

for i in range(n):
  if i == 0:
    lis_up[i] = lis[i]
  else:
    lis_up[i] = max(lis_up[i-1],lis[i])

for i in range(n-1,-1,-1):
  if i == n-1:
    lis_down[i] = lis[i]
  else:
    lis_down[i] = max(lis_down[i+1],lis[i])
    
for i in range(n):
  if i == 0:
    print(lis_down[i+1])
  elif i == n-1:
    print(lis_up[i-1])
  else:
    print(max(lis_up[i-1],lis_down[i+1]))

Measured memory_bytes: 15636
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n,k;
  cin>>n>>k;
  int h[n];
  int ans = 0;
  REP(i,n){
    cin>>h[i];
    if(h[i]>=k){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
map<char,int> M;

int main(){
  string str;
  cin>>str;
  
  int flg=0;
  for(int i=0;i<str.size();i++){
    if(M.count(str[i])){
      if(i-M[str[i]]>2)flg=1;
    }
    M[str[i]]=i;
  }
  int cnt=(str[0]==str[str.size()-1])+str.size();
  if(M.size()>2) flg=1;
  
  if(flg==0)cout<<"Second"<<endl;
  else cout<<(cnt%2? "First":"Second")<<endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back

using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

const int Nmax=514893;
struct Bit{
	int data[Nmax],s;
	void Init(int n){
		s=n;
		fill(data,data+s,0);
	}
	void Add(int i,int v){
		while(i<s){
			data[i]+=v;
			i+=(i+1)&(-i-1);
		}
	}
	int Get(int i){
		int ret=0;
		while(i>=0){
			ret+=data[i];
			i-=(i+1)&(-i-1);
		}
		return ret;
	}
} bit;

char tmp[Nmax];
int str[Nmax],src[Nmax],dst[Nmax];
int c1[26],c2[26];
queue<int> g[26];

int main(){
	scanf("%s",tmp);
	int n=strlen(tmp);
	REP(i,n){
		str[i]=tmp[i]-'a';
		c1[str[i]]++;
	}
	REP(i,26)
		if(c1[i]&1){
			cout<<-1<<endl;
			return 0;
		}
	ll ans=0;
	int ss=0,ds=0;
	REP(i,n){
		if((++c2[str[i]])*2<=c1[str[i]]){
			src[ss++]=str[i];
			ans+=ds;
		}else{
			dst[ds++]=str[i];
		}
	}
	reverse(dst,dst+n/2);
	REP(i,n/2)
		g[src[i]].push(i);
	bit.Init(n/2);
	REP(i,n/2){
		int x=g[dst[i]].front();g[dst[i]].pop();
		ans+=x-i+bit.Get(x);
		bit.Add(0,1);
		bit.Add(x,-1);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 8268
N = int(input())
a = list(map(int, input().split()))

b = [0]*(10**5+1)
for i in a:
    if i == 10**5:
        b[i-1] += 1
        b[i] += 1
    elif i == 0:
        b[i] += 1
        b[i+1] += 1
    else:
        b[i-1] += 1
        b[i] += 1
        b[i+1] += 1

print(max(b))

Measured memory_bytes: 52420
#include <iostream>
#include <stdio.h>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<math.h>
using namespace std;



int main()
{

	int N, M, i = 0;
	int s[3];
	int c[9];
	int a[3] = {0,0,0}, b[3];

	cin >> N >> M;


	for (auto i = 0; i < M; i++) {
		cin >> s[i] >> c[i];
	}

	if (M == 0 && N == 3) {
		cout << "100";
		return 0;
	}

	if (M == 0 && N == 2) {
		cout << "10";
		return 0;
	}

	if (M == 0 && N == 1) {
		cout << "0";
		return 0;
	}

	for (i = 0; i < M; i++) {

		if (s[i] == 1 && c[i] == 0 && N != 1) { //１桁目が0判定
			cout << "-1";
			return 0;
		}
		b[s[i] -1] = c[i];

		if (a[s[i] -1] != b[s[i]-1] && a[s[i] - 1] != 0) { //同じ桁に別の数字
			cout << "-1";
			return 0;
		}

		a[s[i] -1] = c[i];
	
		

	}

	if (a[0] == 0 && N != 1) {
		a[0] = 1;
	}

	for (i = 0; i < N; i++) {

		cout << a[i];
	}


}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

int N, K;

int main() {
  scanf("%d %d", &N, &K);

  ll count = 0;
  FOR(b, 1, N + 1) {
    int p = N / b;
    int r = N % b;
    int a_count = p * max(0, b - K) + max(0, r - K + 1);
    count += a_count;
  }
  if (K == 0) {
    int zero_a_count = N;
    count -= zero_a_count;
  }
  printf("%lld\n", count);
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class Program
{
    public static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var dp = new int[n, 3];
        var vals = Enumerable.Range(0, n).Select(x => Console.ReadLine().Split(' ').Select(y => int.Parse(y)).ToArray()).ToArray();
        for (int i = 0; i < 3; i++)
        {
            dp[0, i] = vals[0][i];
        }
        for (int i = 1; i < n; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                for (int k = 0; k < 3; k++)
                {
                    if (j == k)
                    {
                        continue;
                    }
                    dp[i, j] = chmax(dp[i, j], dp[i - 1, k] + vals[i][j]);
                }
            }
        }
        Console.WriteLine(dp.Cast<int>().Max());
    }

    public static int chmax(int x, int y)
    {
        return x > y ? x : y;
    }
}

Measured memory_bytes: 27948
import java.util.Scanner;

public class Main {

	static int ans;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		int sum = 0;
		for(int i = 0; i<n.length();i++) {
			int tmp= Character.getNumericValue(n.charAt(i));
//			System.out.println(tmp);
			sum+=tmp;
		}
//		System.out.println(sum);
		if(sum%9==0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
//		System.out.println(ans);
	}
}

Measured memory_bytes: 40504
from bisect import bisect_right
n=int(input())
a=[int(input()) for _ in range(n)]
a=a[::-1]
lis=[a[0]]
for i in range(1,n):
  if lis[-1]<=a[i]:
    lis.append(a[i])
  else:
    inde=bisect_right(lis,a[i])
    lis[inde]=a[i]
print(len(lis))
  

Measured memory_bytes: 7840
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int d[];
        d=new int[6];
        for(int i=0;i<6;i++){
            d[i]=sc.nextInt();
        }
        Dice D1=new Dice(d[0],d[1],d[2],d[3],d[4],d[5]);
        int n=sc.nextInt();
        for(int i=0;i<n;i++){
            int a=sc.nextInt();
            int b=sc.nextInt();
            if(D1.d2==a || D1.d5==a || D1.d6==a){
                while(D1.d1!=a) D1.roll('N');
            }
            else if(D1.d3==a) D1.roll('W');
            else if(D1.d4==a) D1.roll('E');
            if(D1.d2!=b){
                while(D1.d2!=b) D1.slide();
            }
            System.out.println(D1.d3);
        }
    }
}

class Dice{
    int d1,d2,d3,d4,d5,d6,db;
    Dice(int a,int b,int c,int d,int e,int f){
        this.d1=a;
        this.d2=b;
        this.d3=c;
        this.d4=d;
        this.d5=e;
        this.d6=f;
    }
    void roll(char c){
        switch (c){
            case 'N':
                db=d1;
                d1=d2;
                d2=d6;
                d6=d5;
                d5=db;
                break;
            case 'S':
                db=d1;
                d1=d5;
                d5=d6;
                d6=d2;
                d2=db;
                break;
            case 'E':
                db=d1;
                d1=d4;
                d4=d6;
                d6=d3;
                d3=db;
                break;
            case 'W':
                db=d1;
                d1=d3;
                d3=d6;
                d6=d4;
                d4=db;
                break;
        }
    }
    void slide(){
        db=d2;
        d2=d3;
        d3=d5;
        d5=d4;
        d4=db;
    }
}


Measured memory_bytes: 26276
#include<bits/stdc++.h>
using namespace std;
int n,a,b,c,i,j,d;
int main()
{
  for(i=1,cin>>n>>a>>b;i<=n;i++){
    for(c=0,j=i;j!=0;j/=10)c+=j%10;
    if(c>=a&&c<=b)d+=i;
  }
  cout<<d;
}

Measured memory_bytes: 256
def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n

def lcm(m, n):
    return m//gcd(m, n)*n

n = int(input())
ans = 1
for _ in range(n):
    x = int(input())
    ans = lcm(x, ans)
print(ans)


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

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

    int gap = 0;
    for (int i = 0; i < n-1; i++)
    {
        gap = max(gap, a[i+1] - a[i]);
    }
    gap = max(gap, a[0] + k - a[n-1]);
    cout << k - gap << endl;
}

Measured memory_bytes: 4224
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

#define pll pair<long long, long long>

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

	int N, M;

	cin >> N >> M;

	vector<pll> vec;

	vec.assign(N, pll());

	for (int n = 0; n < N; n++)
		cin >> vec[n].first >> vec[n].second;

	auto comp = [](const pll &a, const pll &b) -> bool {
			return a.first < b.first;
	};

	sort(vec.begin(), vec.end(), comp);

	int iter = 0;
	long long result = 0;

	while (1) {
		if (M == 0)
			break;

		if (M < vec[iter].second) {
			result += M * vec[iter].first;
			M = 0;
		}
		else {
			M -= vec[iter].second;
			result += vec[iter].second * vec[iter].first;
		}

		iter++;
	}

	cout << result;
}

Measured memory_bytes: 1792