akhauriyash/Code-Regression huggingface dataset:
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_i64_asc(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_c_asc(const void* a, const void* b) {
    return *((char*)a) < *((char*)b) ? -1 : 1;
}

int compare_c_desc(const void* a, const void* b) {
    return *((char*)a) > *((char*)b) ? -1 : 1;
}

int compare_f(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f2(const void* a, const void* b) {
    return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

int main(void) {
    char s[101], t[101];

    scanf("%s\n%s", s, t);

    qsort(s, strlen(s), sizeof(char), compare_c_asc);
    qsort(t, strlen(t), sizeof(char), compare_c_desc);

    puts(strcmp(s, t) < 0 ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 128
<?php
// Your code here!
$sc = new Scanner();

$n = $sc->nextInt();
$k = $sc->nextInt();


$cA = array_fill(0,$n,true);

for ($i = 0; $i < $k; $i++) {
     // code...
     $d = $sc->nextInt();
     for($j = 0; $j < $d; $j++){
         $A = $sc->nextInt()-1;
         $cA[$A] = false;
     }
}


echo count(array_filter($cA,"checkIf"));

function checkIf($a){
    return ($a == true);
}

class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}
?>


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

int counter[26];
int main(int argc, const char * argv[]) {
    // insert code here...
    char ch;
    int num;
    while ( cin >> ch ){
        // ここで ch がアルファベットなら、数える
        if('a'<=ch&&ch<='z'){
            num = ch-'a';
            counter[num]++;
            
        }else if('A'<=ch&&ch<='Z'){
            num=ch-'A';
            counter[num]++;
        }

        
    }
    
    for (int i=0; i<26; i++) {
       char a='a';
        printf("%c", a + i);
        cout<<" : "<<counter[i]<<endl;
    }
    return 0;
}



Measured memory_bytes: 3100
/***************************************************************
	File name: E.cpp
	Author: huhao
	Create time: Sun 04 Aug 2019 08:22:16 PM CST
***************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=r*10+c-48;
		c=getchar();
	}
	return r*t;
}
const int N=510;
int n,a[N],b[N],r[N],s,k,ans=1;
int cmp(int a,int c)
{
	return b[a]<b[c];
}
void run(int x)
{
	int o=k;
	fr(i,1,n)
	{
		b[i]=a[i]%x;
		r[i]=i;
	}
	sort(r+1,r+n+1,cmp);
	int i=1,j=n;
	while(i<=j)
	{
		int p=min(b[r[i]],x-b[r[j]]);
		b[r[i]]-=p;
		b[r[j]]+=p;
		o-=p;
		if(b[r[i]]==0)
			i++;
		if(b[r[j]]==x)
			j--;
	}
	if(o>=0)
		ans=max(ans,x);
}
int main()
{
	n=read();
	k=read();
	fr(i,1,n)
	{
		a[i]=read();
		s+=a[i];
	}
	fr(i,1,sqrt(s))
		if(s%i==0)
		{
			run(i);
			run(s/i);
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
n, m = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)

cb_dict = {}
for _ in range(m):
    b, c = map(int, input().split())
    new = {c:b}
    if c in cb_dict.keys():
        cb_dict[c] += b
    else:
        cb_dict.update(new)

cb_dict = sorted(cb_dict.items(), key=lambda x:x[0], reverse=True)

now_c = 0
now_b = 0
for i in range(n):
    if A[i] >= cb_dict[now_c][0]:
        break
    else:
        A[i] = cb_dict[now_c][0]
        now_b += 1
        if now_b == cb_dict[now_c][1]:
            now_c += 1
            now_b = 0
        if now_c > len(cb_dict)-1:
            break

ans = sum(A)
print(ans)

Measured memory_bytes: 28768
from bisect import bisect_right

N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

cnt = [0] * N
for i in range(N):
    cnt[i] = N - bisect_right(C, B[i])

cumsum = [0] * (N + 1)
for i in range(N):
    cumsum[i + 1] = cumsum[i] + cnt[N - i - 1]
    
res = 0
for i in range(N):
    res += cumsum[N - bisect_right(B, A[i])]
print(res)



Measured memory_bytes: 24392
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let K: usize = sc.get();
    let mut p: Vec<usize> = sc.vec(N);
    p.sort();
    let ans: usize = p[..K].into_iter().sum();
    println!("{}", ans);
}


Measured memory_bytes: 2156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    ll ans = n / 500;
    ans *= 1000ll;
    n %= 500;
    ans += n / 5 * 5;
    cout << ans << endl;
    return 0;
}

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

ll s, t, p, q, M, y;

int main()
{
    scanf("%lld%lld", &s, &t);
    scanf("%lld%lld%lld", &p, &q, &M);
    scanf("%lld", &y);
    ll Res=0, a=0;
    Res^=y;
    for (int i=2; i<=1e8; i++)
    {
        a=(a*p+q)%M;
        Res^=a;
    }
    printf("%lld\n", Res);
}



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


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

  if (N == 0) {
    cout << X << endl;
    return 0;
  }

  vector<int> p(N);
  rep(i, N) {
    cin >> p[i];
  }

  sort(p.begin(), p.end());

  // Xは1から100
  // pは1から100
  int answer = 10000;
  rep(i, 102) {
    if (find(p.begin(), p.end(), i) != p.end()) {
      continue;
    }
    if (abs(X - answer) > abs(X - i)) {
      answer = i;
    }
  }

  cout << answer << endl;

  return 0;
}

Measured memory_bytes: 3592
N,K=list(map(int,input().split()))
S=input()

S=S+'E'
ans=-1

if(S[0]=='0'):
    stand=1
else:
    stand=0

L=0
R=0

while(R<N):
    if(stand<=K):
        if(S[R]=='1' and S[R+1]=='0'):
            stand+=1
        
        ans=max(ans,R-L+1)
        R+=1
    elif(L==R):
        L+=1
        R+=1
    else:
        if(S[L]=='0' and S[L+1]=='1'):
            stand-=1
        L+=1
        
print(ans)

Measured memory_bytes: 3316
N=int(input())

A=[int(x) for x in input().split()]
B=[int(x) for x in input().split()]
C=[int(x) for x in input().split()]

result=0
buf=A[0]

for i in A:
    if(i-buf==1):
        result+=B[i-1]+C[i-2]
    else:
        result+=B[i-1]
    buf=i

print(result)

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, w;
	cin >> h >> w;
	vector<vector<char>> s(h + 2, vector<char>(w + 2));
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			cin >> s[i][j];
		}
	}
	bool elf = true;
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j < w; ++j) {
			if (s[i][j] == '#') {
				if (s[i - 1][j] == '.' && s[i + 1][j] == '.' && s[i][j - 1] == '.' && s[i][j + 1] == '.') {
					elf = false;
				}
			}
		}
	}
	if (elf) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int x,y,z,tmp;
    scanf("%d %d %d",&x,&y,&z);
    tmp=y;
    y=x;
    x=tmp;
    tmp=z;
    z=x;
    x=tmp;
    printf("%d %d %d",x,y,z);
    return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline

N, W = map(int, input().split())
B = [list(map(int, input().split())) for _ in range(N)]
dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(N):
    w, v = B[i]
    for j in range(W+1):
        if j-w >= 0:
            dp[i+1][j] = max(dp[i][j], dp[i][j-w]+v)
        else:
            dp[i+1][j] = dp[i][j]
print(dp[N][W])


Measured memory_bytes: 119916
let () =
  let f v = ceil(((4.9*.v*.v)/.(9.8*.9.8)+.5.)/.5.) in
  let rec read () =
    try let v = read_float () in
        int_of_float (f v) |> string_of_int |> print_endline;read ()
    with End_of_file -> ()
  in
  read ();;

Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
main(){
  string a,b,c;
  cin>>a>>b>>c;
  queue<char> que[3];
  for(auto x:a)que[0].push(x);
  for(auto x:b)que[1].push(x);
  for(auto x:c)que[2].push(x);
  int s=0;
  map<int,char> mp;
  mp[0]='A';
  mp[1]='B';
  mp[2]='C';
  map<char,int> mmp;
  mmp['a']=0;
  mmp['b']=1;
  mmp['c']=2;
  while(1){
    if(que[s].empty()){
      cout<<mp[s]<<endl;
      return 0;
    }else{
      int t=mmp[que[s].front()];
      que[s].pop();
      s=t;
    }
  }
}


Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n=gets.to_i
l=array(86,1,0)
l[0]=2
l[1]=1
(n-1).times do|i|
  l[i+2]=l[i+1]+l[i]
end
puts l[n]

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    	if(c == '-') f = -1;
    	c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 +c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int64 aI,aO,aT,aJ,aL,aS,aZ;
int64 ans = 0;
void Solve() {
    read(aI);read(aO);read(aT);read(aJ);read(aL);read(aS);read(aZ);
    ans = aO;
    int64 t = min(aI,min(aJ,aL));
    ans += 3 * t;
    aI -= t;aJ -= t;aL -= t;
    ans += (aI / 2) * 2;aI %= 2;
    ans += (aJ / 2) * 2;aJ %= 2;
    ans += (aL / 2) * 2;aL %= 2;
    if(aI + aJ + aL >= 2) {
        if(t) {
            ans -= 3;ans += 4;
        }
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A+B > C+D) {
    cout << "Left" << endl;
  } else if (A+B < C+D) {
    cout << "Right" << endl;    
  } else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    char ch;
    int i,a[26]={0};

    while((ch=getchar())!=EOF){
        if('a'<=ch&&ch<='z'){
            a[ch-'a']++;
        }else if('A'<=ch&&ch<='Z'){
            a[ch-'A']++;
        }
    }
    
    for(i=0;i<26;i++){
        printf("%c : %d\n",'a'+i,a[i]);
    }
    
    return 0;
}


Measured memory_bytes: 2100
#include<stdio.h>
#include<math.h>
#include<queue>
using namespace std;
int p[1229];
void init(){
    int c=0;
    for(int i=2;i<=10000;i++){
        bool flag=true;
        for(int j=2;j<=sqrt(i);j++){
            if(i%j==0){
                flag=false;
                break;
            }
        }
        if(flag){
            p[c]=i;
            c++;
        }
    }
}
int main(){
    init();
    while(true){
        int n,ans=0;
        scanf("%d",&n);
        if(n==0) return 0;
        queue<int> q;
        int c=0;
        for(int i=0;i<1229;i++){
            q.push(p[i]);
            c+=p[i];
            while(c>n&&!q.empty()){
                c-=q.front();
                q.pop();
            }
            if(c==n) ans++;
        }
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 1056
#include <stdio.h>

int main(void){
    int r,c,i,j,x;
    scanf("%d %d",&r,&c);
    int a[r+1][c+1];
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            scanf("%d ",&a[i][j]);
        }
    }
    //c+1??????????±???????
    for(i=0;i<r;i++){
        x=0;
        for(j=0;j<c;j++){
            x+=a[i][j];
        }
        a[i][c]=x;
    }
    //r+1??????????±???????
    for(j=0;j<c;j++){
        x=0;
        for(i=0;i<r;i++){
            x += a[i][j];
        }
        a[r][j]=x;
    }
    //a[r][c]????±???????
    a[r][c]=0;
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            a[r][c]+=a[i][j];
        }
    }
    //Output
    for(i=0;i<r+1;i++){
        for(j=0;j<c+1;j++){
            printf("%d",a[i][j]);        
            if(j<c){
                printf(" ");
            }
        }
        printf("\n");
    }
    return 0; /*0?????????*/
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m,q,a[100005],d;
multiset<int>M;
map<int,int>S;
vector<int>vi;
int main(){
	cin>>n>>m>>q; rep(i,q)cin>>a[q-1-i]; rep(i,n) M.insert(0);
	rep(i,q){
		if(S.find(a[i]) == S.end()){
			S[a[i]] = ++d; vi.pb(a[i]);
		}
		int D = S[a[i]];
		multiset<int>::iterator it=M.lower_bound(D-1); int v = *it;
		M.erase(it);
		M.insert(max(v,D));
	}
	for(int i=1;i<=m;i++) if(S.find(i) == S.end()) vi.pb(i);
	int lim=0;
	for(int i=vi.size()-2;i>=0;i--){
		if(vi[i] > vi[i+1]){
			lim=i+1; break;
		}
	}
	for(multiset<int>::iterator it=M.begin();it!=M.end();++it){
		if((*it) < lim){
			puts("No"); return 0;
		}
	}
	puts("Yes");
}

Measured memory_bytes: 10360
import java.io.*;
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    for(int i=1;i<=n;i++){
      if(i%3==0 || i%10==3){
        System.out.print(" "+i);
      }else{
        int c=i;
        while(c>0){
          c/=10;
          if(c%10==3){
            System.out.print(" "+i);
            break;
          }
        }
      }
    }
    System.out.println();
  }
}



Measured memory_bytes: 28912
//Created by apsp1234

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<string>
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define S second
#define F first
#define pb push_back
#define M1 1000000007
#define M2 998244353
#define plli pair<lli,lli>
#define setit set<lli>::iterator seti
#define mapit map<lli,lli> ::iterator mapi
#define MP make_pair
#define MT make_tuple
#define ct continue
#define PI 3.14159265358979323846
#define maxn 100005
#define L length()
#define B begin()
#define T front()
#define E end()
#define Z size()
#define RB rbegin()
#define RE rend()
// map      iterator->first  iterator.first
// map      mp[key]=value
// set      *s.begin()
// vector   v[j]=value
// pair     p.first p.second
// vector of pairs v[j].first v[j].second
// tuple    get<index>(tuple_name)
// vector of tuples get<index>(v[j])  sort(v.begin(),v.end())
//priority queue .top() .pop() .push()
// __gcd(x,y)
#define mini(x,y) (y + ((x - y) & ((x - y) >>(sizeof(int) * CHAR_BIT - 1))))
#define maxi(x,y) (x - ((x - y) & ((x - y) >> (sizeof(int) * CHAR_BIT - 1))))
#define fr(j,a,b) for(j=a;j<b;j++)

lli power(lli x, lli y, lli p)
{   lli res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)
    {   if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

int main()
{
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lli i, j, q, t, n, y, k, x, m, b;
    cin >> n;
    lli a[n];
    for (j = 0; j < n; j++) {
        cin >> a[j];
    }
    x = 0;
    for (j = 1; j < n; j++) {
        if (a[j] < a[j - 1]) {
            b = a[j - 1] - a[j];
            x = x + b;
            a[j] = a[j - 1];
        }
    }
    cout << x;
}

Measured memory_bytes: 5216
use proconio::input;
use proconio::marker::Chars;
use std::cmp::{max, min};
const alpha: [char; 26] = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];

const Alpha: [char; 26] = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
    'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];
fn main() {
    input!(N: usize);
    input!(a: [usize; N]);
    let mut ans = 0;
    for i in 0..N {
        if (i + 1) % 2 == 1 && a[i] % 2 == 1 {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2116
N,M=map(int,input().split())
L=0
R=N+1
for i in range(0,M,1):
    l,r = map(int,input().split())
    L=max(L,l)
    R=min(R,r)
if R >= L:
    print(R-L+1)
else:
    print(0)

Measured memory_bytes: 43736
#include<iostream>
#include<string>
int main()
{
	std::string str;
	std::getline(std::cin, str);
	for (auto&i : str)
	{
		if ('a' <= i && i <= 'z')
		{
			i += 'A' - 'a';
		}
	}
	std::cout << str << std::endl;
	return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mem(dp, v) memset(dp, v, sizeof dp);
using namespace std;

const int N = 1e3 + 7, inf = 1e9;
ll ar[N], dp[N][N], n, k, t;

int main()
{
    ll n, k;
    ios_base::sync_with_stdio(false);
    cin>>n>>k;
    cout<<(n+k - 1)/k<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  } int t;
  double aa=0;
  for(int i=0;i<n;i++){
    t=a[i]-1;
    if(a[t]==i+1){
      aa+=0.5;
    }
  }
  cout << aa;
}


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

int main(){
  string S,T,U;
  int A,B;
  cin>>S>>T>>A>>B>>U;
  if(S==U){
    cout<<A-1<<" "<<B<<endl;
  }else{
    cout<<A<<" "<<B-1<<endl;
  }
  
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n,q;
	int s[100000],t[50000];
	int i,c=0;
	int left,right,center;

	scanf("%d",&n);
	for(i=0;i<n;++i){
		scanf("%d",&s[i]);
	}

	scanf("%d",&q);
	for(i=0;i<q;++i){
		scanf("%d",&t[i]);
	}
	
	for(i=0;i<q;++i){
		left = 0;
		right = n;
		while(left<right){
			center = (left+right)/2;
			if(s[center]==t[i]){
				c++;
				break;
			}else if(s[center]>t[i]){
				right = center;
			}else{
				left = center+1;				
			}
		}
	
	}
	printf("%d\n",c);
	
	return 0;
}

Measured memory_bytes: 1184
import itertools
N,M=map(int,input().split())
data=[]
for i in range(0,M): #kとｓのimport
  a=list(map(int,input().split()))
  data.append(a)
P=list(map(int,input().split())) #ｐのimport


ans=0
A=[0,1]  
for i in itertools.product(A, repeat=N): #全通り
  S=list(i)

  j=0
  an="continue"
  while an=="continue" and j<M: #スイッチオンか確認
    SS=data[j]
    k=SS[0]
  
    sum=0
    for l in range(1,k+1): #オンの数確認
      if S[SS[l]-1]==0:
        sum=sum+1
        
    if sum%2!=P[j]: #オンの数おかしい 
      an="break"
    
    elif j==M-1: #最後までok
      ans=ans+1
     
      j=j+1
    else: #オンの数正しい
      j=j+1
      
        
print(ans)

Measured memory_bytes: 3064
/*==========================================================================*/
/*
    AUTHOR:    BPZ
	CREATED:   10.09.2020 18:04:20

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  const int maxn = (int)1e7 + 6;
  vector<int> ans(maxn, 0);
 	for (int i = 1; i <= 200; i++) {
 		for (int j = 1; j <= 200; j++) {
 			for (int k = 1; k <= 200; k++) {
 				int pos = pow(i + j, 2) + pow(i + k, 2) + pow(j + k, 2);
 				ans[pos/2]++;
 			}
 		}
 	}
 	for (int i = 1; i <= n; i++) {
 		cout << ans[i] << '\n';
 	}
  return 0;
}


Measured memory_bytes: 42172
# coding: utf-8
from functools import reduce
from queue import Queue
from collections import deque
H, W = list(map(int, input().split(" ")))
current_h, current_w = list(map(int, input().split(" ")))
current_h -= 1
current_w -= 1
goal_h, goal_w = list(map(int, input().split(" ")))
goal_h -= 1
goal_w -= 1

table = [list(input()) for _ in range(H)]

class ZeroOneBFS:

    def __init__(self, table):
        self.table = table
        self.cost_table = []
        for _ in range(H):
            self.cost_table.append([-1 for _ in range(W)])

    def delta(self, h, w):
        res = [(h+1, w),
               (h, w-1), (h, w+1),
               (h-1, w)]
        return res

    def warp(self, h, w):
        res = []
        for dh in range(-2, 3):
            for dw in range(-2, 3):
                if dh == 0 and dw == 0:
                    pass
                else:
                    res.append((h+dh, w+dw))
        return res

    def bfs(self, start_h, start_w):
        dq = deque()
        dq.appendleft((start_h, start_w, 0))
        while dq:
            now_h, now_w, now_c = dq.pop()
            if self.table[now_h][now_w] == "#" or self.cost_table[now_h][now_w] != -1:
                pass
            else:
                self.cost_table[now_h][now_w] = now_c
                for h, w in self.delta(now_h, now_w):
                    if 0 <= h < H and 0 <= w < W and self.table[h][w] != "#":
                        dq.append((h, w, now_c))
                for h, w in self.warp(now_h, now_w):
                    if 0 <= h < H and 0 <= w < W and self.table[h][w] != "#":
                        dq.appendleft((h, w, now_c+1))
        return self.cost_table[goal_h][goal_w]


bfs = ZeroOneBFS(table)
print(bfs.bfs(current_h, current_w))




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


int main(){
  int r;cin>>r;
  if(r<1200)cout<<"ABC"<<endl;
  else if(r>=1200&&r<2800)cout<<"ARC"<<endl;
  else cout<<"AGC"<<endl;
}


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

using namespace std;

int N;
int arr[54][3], chk[54];

int main(){
    scanf("%d", &N);
    for(int i = 1; i <= N; ++i){
        scanf("%d %d", arr[i] + 1, arr[i] + 2);
    }
    int ans = (int)1e9;
    for(int i = 1; i <= N; ++i) for(int j = i; j <= N; ++j){
        int cnt = 0;
        int X = arr[i][1] - arr[j][1], Y = arr[i][2] - arr[j][2];
        if(!X && !Y) continue;
        for(int x = 1; x <= N; ++x) if(!chk[x]){
            int A = arr[x][1] + X, B = arr[x][2] + Y;
            while(1){
                int f = 1;
                for(int y = 1; y <= N; ++y) if(!chk[y] && arr[y][1] == A && arr[y][2] == B){
                    chk[y] = 1; f = 0; break;
                }
                if(f) break;
                A += X, B += Y;
            }
            A = arr[x][1] - X, B = arr[x][2] - Y;
            while(1){
                int f = 1;
                for(int y = 1; y <= N; ++y) if(!chk[y] && arr[y][1] == A && arr[y][2] == B){
                    chk[y] = 1; f = 0; break;
                }
                if(f) break;
                A -= X, B -= Y;
            }
        }
        for(int x = 1; x <= N; ++x){
            cnt += !chk[x];
        }
        ans = min(ans, cnt);
        memset(chk, 0, sizeof(chk));
    }
    printf("%d\n", N == 1 ? 1 : ans);
    return 0;
}


Measured memory_bytes: 256
a,b=map(int, input().split())
c=list(map(int, input().split()))
l =[]
ans = 0

def abc(n):
    return (n+1)/2

cb = list(map(abc,c))

s = sum(cb[:b])
l.append(s)

for i in range(b,a):
    s = s - cb[i-b] + cb[i]
    l.append(s)

L = sorted(l)
print(L[-1])

Measured memory_bytes: 33280
def m():
    N = int(input())
    A = [0] + list(map(int, input().split()))
    length = len(A)
    x = [i - A[i] for i in range(length)]
    y = [i + A[i] for i in range(length)]
    xdict = {}
    ydict = {}
    for i in range(1, length):
        xdict[x[i]] = xdict[x[i]] + 1 if xdict.get(x[i], 0) else 1
        ydict[y[i]] = ydict[y[i]] + 1 if ydict.get(y[i], 0) else 1

    ans = 0
    for k, v in xdict.items():
        ans = ans + ydict[k] * v if ydict.get(k, 0) else ans
    return ans


print(m())


Measured memory_bytes: 167972
import scipy.sparse
H,W = (int(x) for x in input().split())
lines = [input() for i in range(H)]
lil = scipy.sparse.lil_matrix((H*W, H*W), dtype = int)
for i in range(H):
    for j in range(W):
        if i == j == 0: continue
        elif i == 0 and j > 0:
            if lines[0][j] == lines[0][j-1] == ".":
                lil[i*W+j, i*W+j-1] = 1
                lil[i*W+j-1, i*W+j] = 1
        elif i > 0 and j == 0:
            if lines[i][0] == lines[i-1][0] == ".":
                lil[i*W+j, (i-1)*W+j] = 1
                lil[(i-1)*W+j, i*W+j] = 1
        else:
            if lines[i][j] == lines[i][j-1] == ".":
                lil[i*W+j, i*W+j-1] = 1
                lil[i*W+j-1, i*W+j] = 1
            if lines[i][j] == lines[i-1][j] == ".":
                lil[i*W+j, (i-1)*W+j] = 1
                lil[(i-1)*W+j, i*W+j] = 1
lil2 = scipy.sparse.csgraph.dijkstra(lil, directed = False).astype(int)
print(lil2.max())

Measured memory_bytes: 19968
#include<iostream>
#include<vector>
using namespace std;
static const int MAX = 100000;
static const int INF = 1 << 30;
int n, cost[MAX], maxCostIndex;
vector<pair<int, int> > V[MAX];
bool vis[MAX];

void dfs(int u){
  vis[u] = true;
  for ( int i = 0; i < V[u].size(); i++) {
    pair<int, int> s = V[u][i];
    if ( !vis[s.first] ){
      cost[s.first] = cost[u] + s.second;
      if ( cost[s.first] > cost[maxCostIndex]){
        maxCostIndex = s.first;
       }
      dfs(s.first);
    }
  }
}

int getLongest(int s){
  for ( int i = 0; i < n; i++){
    vis[i] = false;
    cost[i] = INF;
  }
  cost[s] = 0;
  maxCostIndex = s;
  dfs(s);
  return maxCostIndex;
}

void diameter(){
  int x = getLongest(0);
  int y = getLongest(x);
  cout << cost[y] << endl;
}

int main(){
  cin >> n;
  int s, t, w;
  for ( int i = 0; i < n-1; i++) {
    cin >> s >> t >> w;
    V[s].push_back(make_pair(t, w));
    V[t].push_back(make_pair(s, w));
  }

  diameter();

  return 0;
}


Measured memory_bytes: 12196
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    EXP_MAX = 41
    cnt = [0] * (EXP_MAX+1)
    for a in A:
        for i in range(EXP_MAX+1):
            cnt[i] += a//(2**i) % 2
    tmp = 0
    ans = 0
    for i in range(EXP_MAX, -1, -1):
        if cnt[i] * 2 < N and tmp + 2**i <= K:
            tmp += 2**i
            ans += 2**i * (N - cnt[i])
        else:
            ans += 2**i * cnt[i]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 69008
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <sstream>

#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for(int i = a; i < b; ++i)
#define rrep(i, a) RREP(i, a, 0)
#define RREP(i, a, b) for(int i = a; i >= b; --i)
#define repll(i, a) REPLL(i, 0, a)
#define REPLL(i, a, b) for(ll i = a; i < b; ++i)
#define rrepll(i, a) RREPLL(i, a, 0)
#define RREPLL(i, a, b) for(ll i = a; i >= b; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<int, P> PP;
const double PI = 3.14159265358979323846;
const double esp = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+18 + 10;

int h, w;
int dp[1401][1401];

int main(){
	std::cin >> h >> w;
	rep(i, h){
		rep(j, w)std::cin >> dp[i][j], dp[i][j] = (1 - dp[i][j]);
	}

	REP(i, 1, h){
		REP(j, 1, w){
			if (dp[i][j] == 0)continue;
			dp[i][j] = std::min(dp[i - 1][j], std::min(dp[i][j - 1], dp[i - 1][j - 1])) + 1;
		}
	}

	int max = 0;
	rep(i, h){
		rep(j, w)max = std::max(max, dp[i][j]);
	}

	std::cout << max * max << std::endl;

	return 0;
}

Measured memory_bytes: 8828
import java.util.*;
public class Main{
  static Scanner sc = new Scanner(System.in);
  public static void main(String [] args){
    int e;
    while(true){
      e = sc.nextInt();
      if(e == 0)break;
      System.out.println(solve(e));
    }
  }
  static int solve(int e){
    int x,y,z;
    int ans = e;
    int m;
    int Cz;
    for(z = 0; z * z * z<= e ;z++){
      Cz = z * z * z;
      for(y = 0; y * y <= e - Cz; y++){
        x = e - (Cz + y * y);
        m = x + y + z;
        if(ans > m) ans = m;
      }
    }
    return ans;
  }
}

Measured memory_bytes: 26420
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int count = 0;
		for (int i = A; i <= B; i++) {
			String s = String.valueOf(i);
			if (s.charAt(0) == s.charAt(4) && s.charAt(1) == s.charAt(3))
				count++;
		}
		System.out.println(count);

	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            Console.WriteLine("ABC" + N);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define mxsize (int)1e6
#define pb push_back
#define nl cout<<"\n"
#define db(x) cout<<x<<" "
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define fk(a,b) for(int k=a;k<b;k++)
#define F first
#define S second
#define UM unordered_map<int,int>
#define MP map<int,int>
void yn(bool check){
    if(check)	cout<<"YES\n";
    else		cout<<"NO\n";
}
void fun(){
    ll n,d;
    cin>>n>>d;
    int ans=0;
    fi(0,n){
        ll x,y;
        cin>>x>>y;
        if(x*x+y*y<=d*d)  ans++;
    }
    cout<<ans<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("/ATOM/input.txt", "r", stdin);
        freopen("/ATOM/output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t--){
        fun();
    }
}

Measured memory_bytes: 3652
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            // Console.WriteLine("Hello World!");
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Console.WriteLine(ab[1] >= ab[0] ? ab[0] : ab[0] - 1);
        }
    }
}


Measured memory_bytes: 13268
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define F first
#define S second
#define pb emplace_back
#define mp make_pair
#define all(c)  c.begin(), c.end()
#define vb vector<bool>
#define vll vector<ll>
#define vp vector<pair<ll,ll>>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define lb "\n"
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define INF 1000000007
#define MAX LLONG_MAX
#define PI 3.14159265358
ll max(ll x,ll y){if(x>y)return x;else return y;}
ll min(ll x,ll y){if(x>y)return y;else return x;}
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
      #ifdef LOCAL
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
ll i,j,k,n,ans,m,t;
cin>>n;
cout<<((1000-(n%1000))%1000);
return 0;
}


Measured memory_bytes: 3616
n=int(input())
a=list(map(int,input().split()))
ans=0
flg=True
i=0
while flg:
    flg=False
    for j in range(n-1,i,-1):
        if a[j]<a[j-1]:
            a[j],a[j-1]=a[j-1],a[j]
            flg=True
            ans+=1
    i+=1
print(' '.join(map(str,a)))
print(ans)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k ;
  cin >> n >> k ;
  int ans = 1 ;
  while(n/k>0){
    ans++ ;
    n /= k ;
  }
  cout <<ans <<endl ;
    
  
  
  
  return 0 ;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solveA();
		// new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numA = 0;
		int numB = 0;

		try {
			scanner = new Scanner(System.in);
			numA = scanner.nextInt();
			numB = scanner.nextInt();
			for (int i = 1; i < 4; i++) {
				if (numA * numB * i % 2 != 0) {
					System.out.println("Yes");
					return;
				}
			}

			System.out.println("No");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 21204
N,M = map(int,input().split(" "))

if N == 1 and M == 1:
	print(1)
elif N == 1 or M == 1:
	print(N * M - 2)
elif N == 2 or M == 2:
	print(0)
else:
	print(((N-2)*(M-2)))


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define endl '\n'
#define fastio cin.sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

int main() {
	fastio;
	string N;
	cin >> N;

	int ans = 0;
	int dp[2][1000001]{};
	while (N.back() == '0') N.pop_back();

	dp[0][sz(N) - 1] = N.back() - 48;
	dp[1][sz(N) - 1] = (10 - (N.back() - 48)) % 10;

	for (int i = sz(N) - 1; i--; ) {
		dp[0][i] = min(dp[1][i + 1] + N[i] - 47, dp[0][i + 1] + N[i] - 48);
		dp[1][i] = min(dp[1][i + 1] + 10 - (N[i] - 47), dp[0][i + 1] + 10 - (N[i] - 48));
	}

	cout << min(dp[0][0], dp[1][0] + 1);

	return 0;
}

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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    unsigned long M;
    vector<vector<unsigned long>> path;
    {
        vector<vector<unsigned long>> edge(N);
        vector<unsigned long> edges(N - 1);
        for(unsigned long i{1}, a, b; i < N; ++i){
            cin >> a >> b;
            edge[--a].push_back(i - 1);
            edge[--b].push_back(i - 1);
            edges[i - 1] = a ^ b;
        }
        cin >> M;
        path.resize(M);
        vector<vector<unsigned long>> queries(N);
        for(unsigned long i{0}, u, v; i < M; ++i){
            cin >> u >> v;
            queries[--u].push_back(i);
            queries[--v].push_back(i);
        }
        [rec_impl = [&path, &edge, &edges, &queries, &N, &M](auto f, unsigned long now, unsigned long prev) -> unsigned long {
            unsigned long mask{0};
            for(const auto& i : edge[now])if((edges[i] ^ now) != prev){
                auto t = f(f, edges[i] ^ now, now);
                for(unsigned long j{0}; j < M; ++j)if(1 & (t >> j))path[j].push_back(i);
                mask ^= t;
            }
            for(const auto& i : queries[now])mask ^= 1UL << i;
            return mask;
        }]{rec_impl(rec_impl, 0, 0);}();
    }
    vector<unsigned long> cnt(N - 1), used(M);
    unsigned long ans{0}, cntr{N - 1};
    const auto& check = [&cnt, &used, &path, &cntr, &M](unsigned long i){
        if(i == M)return;
        if(used[i]){for(const auto& e : path[i])cntr += !(--cnt[e]);}
        else{for(const auto& e : path[i])cntr -= !(cnt[e]++);}
        used[i] ^= 1;
    };
    for(unsigned long i{0}; i < 1UL << M; ){
        ans += (i & 1 ? -1 : 1) * (1UL << cntr);
        check(__builtin_ctzl(++i));
    }
    cout << ans << endl;
    return 0;
}

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

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            var a = inputLongArray[0];
            var b = inputLongArray[1];
            var h = inputLongArray[2];
            var m = inputLongArray[3];

            double rad = 2 * Math.PI * Math.Abs((h + m / 60.0) / 12.0 - m / 60.0);
            double result = Math.Sqrt(a * a + b * b - 2 * a * b * Math.Cos(rad));
            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


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

vector<ll> member;
vector<ll> food;
ll n,k;

bool possible (ll val)
{
	ll all_sum=0;
	for (ll i=0;i<=n-1;i++)
	{
		ll diff=max((ll)0,member[i]-(val/food[n-1-i]));
		all_sum=all_sum+diff;
	}

	if (all_sum>k)
	{
		return false;
	}
	else
	{
		return true;
	}
}

ll search (ll start,ll end)
{
	//cout << start << " ----- " << end << endl; 
	if (start==end)
	{
		return start;
	}
	else
	{
		ll mid=(start+end)/2;
		bool check=possible(mid);
		if (check)
		{
			return search(start,mid);
		}
		else
		{
			return search(mid+1,end);
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);

	cin >> n >> k;
	member.resize(n);
	food.resize(n);

	for (ll i=0;i<=n-1;i++)
	{
		cin >> member[i];
	}

	for (ll i=0;i<=n-1;i++)
	{
		cin >> food[i];
	}

	sort(member.begin(),member.end());
	sort(food.begin(),food.end());

	ll max_val=LLONG_MIN;
	for (ll i=0;i<=n-1;i++)
	{
		ll local=member[i]*food[n-1-i];
		max_val=max(max_val,local);
	}

	cout << search(0,max_val) << endl;
	return 0;
}

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

namespace AtCoder_20190707_1
{    class Program
    {
        static void Main(string[] args)
        {
            int K = int.Parse(Console.ReadLine());

            if(K % 2 == 0)
            {
                Console.WriteLine((K / 2) * (K / 2));
            }
            else
            {
                Console.WriteLine((K / 2) * (K / 2 + 1));
            }
        }
        static int Compare(int[] x, int[] y)
        {
            return x[1].CompareTo(y[1]);            
        }
    }
}

Measured memory_bytes: 11092
p (1..gets.to_i).inject(1){|s,i|
	s*i%998244353
}*gets.chomp.chars.map{|x|
	{"R"=>0,"G"=>1,"B"=>2}[x]
}.inject([[0]*6,1]){|a,c|
	a[0][c+3]>0 ?
		a.tap{a[1]=a[1]*a[0][c+3]%998244353}.tap{a[0][c+3]-=1}
	: a[0][(c+1)%3]>0 ?
		a.tap{a[1]=a[1]*a[0][(c+1)%3]%998244353}.tap{a[0][(c+1)%3]-=1}.tap{a[0][3+(c+2)%3]+=1}
	: a[0][(c+2)%3]>0 ?
		a.tap{a[1]=a[1]*a[0][(c+2)%3]%998244353}.tap{a[0][(c+2)%3]-=1}.tap{a[0][3+(c+1)%3]+=1}
	: a.tap{a[0][c]+=1}
}[1]%998244353


Measured memory_bytes: 52884