Harryxun/stf_run huggingface dataset:
import sys
import math
import heapq
import bisect
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

# j - i == S[j] - S[i] # MOD K
# S[i] - i == S[j] - j

N,K=LI()
As=LI()

Cum=[0]*(N+1)
for i in range(N):
    Cum[i+1] = Cum[i] + As[i]

REM2IDX = {}
for i in range(1,N+1):
    rem = (Cum[i] - i) % K
    if not rem in REM2IDX: REM2IDX[rem] = []
    REM2IDX[rem].append(i)

res = 0
for i in range(0,N+1):
    rem = (Cum[i] - i) % K
    cnt = len(REM2IDX[rem])
    l = bisect.bisect_right(REM2IDX[rem], i)
    r = bisect.bisect_right(REM2IDX[rem], i+K-1)
    res += (r-l)

print(res)


### FIXED CODE ###

import sys
import math
import heapq
import bisect
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

# j - i == S[j] - S[i] # MOD K
# S[i] - i == S[j] - j

N,K=LI()
As=LI()

Cum=[0]*(N+1)
for i in range(N):
    Cum[i+1] = Cum[i] + As[i]

REM2IDX = {}
for i in range(0,N+1):
    rem = (Cum[i] - i) % K
    if not rem in REM2IDX: REM2IDX[rem] = []
    REM2IDX[rem].append(i)

res = 0
for i in range(0,N+1):
    rem = (Cum[i] - i) % K
    cnt = len(REM2IDX[rem])
    l = bisect.bisect_right(REM2IDX[rem], i)
    r = bisect.bisect_right(REM2IDX[rem], i+K-1)
    res += (r-l)

print(res)
def greedy(N,L,ices):
    counts = 0
    while True:
        for i in range(len(ices)):
            if 0 < i < N-1:
                if ices[i] > ices[i-1] and ices[i] > ices[i+1]:
                    ices[i] += 1
                    if ices[i] >= L:
                        ices[i] = 0
            elif i == 0:
                if ices[i] > ices[1]:
                    ices[i] += 1
                    if ices[i] >= L:
                        ices[i] = 0
            elif i == N-1:
                if ices[i] > ices[N-2]:
                    ices[i] += 1
                    if ices[i] >= L:
                        ices[i] = 0
    if ices.count(0) == N:
        print(counts)
        return
    counts += 1


N,L = input().rstrip().split()
ices = []
while True:
    ice = input().rstrip()
    ices.append(ice)
    if len(ices) == N:
        break

greedy(N,L,ices)

### FIXED CODE ###

def orderN(N,L,ices):
    upPeak = L - ices[0]
    downPeak = L - ices[0]
    peaks = []
    for i in range(len(ices)):
        if i < N-1:
            if ices[i] < ices[i+1]:
                peaks.append(downPeak)
                downPeak = L - ices[i+1]
                upPeak += L - ices[i+1]
            elif ices[i] > ices[i+1]:
                peaks.append(upPeak)
                upPeak = L - ices[i+1]
                downPeak += L - ices[i+1]
        elif i == N-1:
            peaks.append(upPeak)
            peaks.append(downPeak)
    print(max(peaks))

N,L = map(int,input().strip().split())
ices = [int(input().strip()) for _ in range(N)]


orderN(N,L,ices)
S = input().split()
T = input().split()

sl = []
tl = []
ans = 0
for s in S:
  sl.append(s)

for t in T:
  tl.append(t)

for i in range(3):
  if sl[i] == tl[i]:
    ans += 1
print(ans)

### FIXED CODE ###

S = input()
T = input()

sl = []
tl = []
ans = 0
for s in S:
  sl.append(s)

for t in T:
  tl.append(t)

for i in range(3):
  if sl[i] == tl[i]:
    ans += 1
print(ans)
s = input()

dp3 = 1
dp2 = 0
dp1 = 0
dp0 = 0

for i in reversed(range((len(s)))):
    m = 1
    m1 = 1
    m2 = 0
    m3 = 0
    m4 = 0
    if s[i] == '?':
        m = 3
        m1 = 3
        m2 = 1
        m3 = 1
        m4 = 1

    if s[i] == 'C':
        m2 = 1

    if s[i] == 'B':
        m3 = 1

    if ss[i] == 'A':
        m4 = 1

    t_dp3 = m * dp3
    t_dp2 = m1 * dp2 + m2 * dp3
    t_dp1 = m1 * dp1 + m3 * dp2
    t_dp0 = m1 * dp0 + m4 * dp1
    dp3 = t_dp3
    dp2 = t_dp2
    dp1 = t_dp1
    dp0 = t_dp0

n = 10 ** 9 + 7
ans = dp0 % n
print(ans)

### FIXED CODE ###

s = input()

dp = [[0 for _ in range(4)] for _ in range(len(s) + 1)]
dp[len(s)][3] = 1
n = 10 ** 9 + 7

for i in reversed(range((len(s)))):
    m = 1
    m1 = 1
    m2 = 0
    m3 = 0
    m4 = 0
    if s[i] == '?':
        m = 3
        m1 = 3
        m2 = 1
        m3 = 1
        m4 = 1

    if s[i] == 'C':
        m2 = 1

    if s[i] == 'B':
        m3 = 1

    if s[i] == 'A':
        m4 = 1

    dp[i][3] = (m * dp[i+1][3]) % n
    dp[i][2] = (m1 * dp[i+1][2] + m2 * dp[i+1][3]) % n
    dp[i][1] = (m1 * dp[i+1][1] + m3 * dp[i+1][2]) % n
    dp[i][0] = (m1 * dp[i+1][0] + m4 * dp[i+1][1]) % n

ans = dp[0][0]
print(ans)
inport numpy as np

N,A,B = map(int,input().split(" "))
i = np.arange(N+1)  # the number of people who use train
j = N-i  # the number pf people who use taxi
cost = A+i + B*j

return np.min(cost)

### FIXED CODE ###

import numpy as np

N,A,B = map(int,input().split(" "))
costs = A*N , B

print(min(costs))
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial, ceil, floor
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

N, = map(int, input().split())
L = [[int(v) for v in input().split()] for _ in range(N)]

m = {}
for i in range(N):
    for j in range(i, N):
        if i != j:
            x, y = L[i]
            x2, y2 = L[j]

            key = (x - x2, y - y2)

            if m.get(key) == None:
                m[key] = 0
            m[key] += 1

print(N - max(m.values()))

### FIXED CODE ###

import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial, ceil, floor
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

N, = map(int, input().split())
L = [[int(v) for v in input().split()] for _ in range(N)]

m = {}
for i in range(N):
    for j in range(N):
        if i != j:
            x, y = L[i]
            x2, y2 = L[j]

            key = (x - x2, y - y2)

            if m.get(key) == None:
                m[key] = 0
            m[key] += 1

if m == {}:
    print(1)
    exit()
print(N - max(m.values()))
s=input()
if s.isupper(){
  print("A")}else{
  print("a")}
  

### FIXED CODE ###

s = input()
if s.isupper():
  print("A")
else:
  print("a")
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
g = [[] for i in range(n)]

for i in range(n-1):
    u,v,w = na()
    g[u-1].append((v-1,w))
    g[v-1].append((u-1,w))

dp = [0]*n

def f(a,b,c):
    dp[b] = c
    for i,j in g[b]:
        if i != a:
            f(b,i,c+j)

f(0,0,0)

for k in dp:
    print(k%2)

### FIXED CODE ###

import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
g = [[] for i in range(n)]

for i in range(n-1):
    u,v,w = na()
    g[u-1].append((v-1,w))
    g[v-1].append((u-1,w))

dp = [0]*n

def f(a,b,c):
    dp[b] = c
    for i,j in g[b]:
        if i != a:
            f(b,i,c+j)

f(0,0,0)

for k in dp:
    print(k%2)
N, M = map(int, input().split())

import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


print(combinations_count(N, 2) + combinations_count(M, 2))

### FIXED CODE ###

N, M = map(int, input().split())

import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

ans = 0

if N >= 2:
    ans += combinations_count(N, 2)

if M >= 2:
    ans += combinations_count(M, 2)

print(ans)
a, b = map(int, input().split())

def primes(max_number):
    pr = list(range(3, max_number+1, 2))
    lpr = len(pr)
    for i,n in enumerate(pr):
        if n:
            if n*n > max_number:
                break
            for j in range(i+n, lpr, n):
                pr[j] = 0
    yield 2
    yield from[i for i in pr if i]

if b > a:
    a, b = b, a
cnt = 0
for i in list(primes(a)):
    if a%i == 0 and b%i == 0:
        cnt += 1
print(cnt+1)

### FIXED CODE ###

import math
a, b = map(int, input().split())

def is_prime(num):
    if num == 2:
        return True
    elif num <  3 or num % 2 == 0:
        return False
    for i in range(3, int(math.sqrt(num)) + 1, 2):
        if num % i == 0:
            return False
    return True

if b > a:
    a, b = b, a
c = []
for i in range(1, int(math.sqrt(b))+1):
    if a%i == 0 and b%i == 0:
        if is_prime(i):
            c.append(i)
    k = b//i
    if a%k == 0:
        if is_prime(k):
            c.append(k)
print(len(set(c))+1)
N, Y = map(int, input().split())

ans = '-1 -1 -1'
count_max = Y / 1000  # all 1000

if Y % 10000 == 0:
    print('{} 0 0'.format(Y//10000))
    exit()


for i in reversed(range(Y // 10000)):
    count_tmp1 = count_max - 9 * i
    price_tmp1 = Y - 10000 * i
    if count_tmp1 < N or price_tmp1 < 0:
        continue

    if count_tmp1 == N:
        ans = '{} {} {}'.format(i, 0, N - i)
        #ans_list.append(ans)
        break

    if price_tmp1 % 5000 == 0:
        ans = '{} {} {}'.format(i, price_tmp1 // 5000, 0)
        break

    is_continue = True
    for j in reversed(range(price_tmp1 // 5000)):
        count_tmp2 = count_tmp1 - 4 * j
        price_tmp2 = price_tmp1 - 5000 * j
        if count_tmp2 < N or price_tmp2 < 0:
            continue
        if count_tmp2 == N:
            ans = '{} {} {}'.format(i, j, N - i -j)
            is_continue = False
            break
    if not is_continue:
        break
print(ans)

### FIXED CODE ###

S = input()

print('2018' + S[4:])
n, x = input().split()
l_list = input().split()
i = 0
ans = 0
y = 1
for l in l_list:
    if i > int(x):
        print(ans)
        y = 0
        break
    i += int(l)
    ans += 1
if y:
  print(ans)

### FIXED CODE ###

x, a = input().split()
print(0) if (x < a) else print(10)
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0

assert K > 100

print(114514)

### FIXED CODE ###

input_line = input().split()

num_array = int(input_line[0])
num_equal = int(input_line[1])

input_line = input() # 無視

equalized = 1
i = 0
while equalized < num_array:
    equalized += (num_equal - 1)
    # print(i, equalized)
    i += 1

print(str(i))
def Ics(X, Y):
    m = len(X)
    n = len(Y)
    maxl = 0
    c = (m + 1)*[(n + 1)*[0]]
    for i in range(m + 1):
        c[i][0] = 0
    for j in range(1, n + 1):
        c[0][j] = 0
    for i in range(1, m + 1):
        for j in range(1, n + 1):
            if(X[i] == Y[j]):
                c[i][j] = c[i - 1][j - 1] + 1
            elif(c[i - 1][j] <= c[i][j - 1]):
                c[i][j] = c[i- 1][j]
            maxl = max(maxl, c[i][j])
    return maxl

q = int(input().rstrip())
t = []
for i in range(n):
    s1 = input().rstrip()
    s2 = input().rstrip()
    t.append(Ics(s1, s2))
print(*t, sep="\n")

### FIXED CODE ###

def Ics(X, Y):
    m = len(X)
    n = len(Y)
    c1 = [0] * (n + 1)
    for i in range(m):
        d = X[i]
        c2 = c1[:]
        for j in range(n):
            if (d == Y[j]):
                c1[j + 1] = c2[j] + 1
            elif (c1[j + 1] < c1[j]):
                c1[j + 1] = c1[j]
    return (c1[-1])

q = int(input().rstrip())
t = []
for i in range(q):
    s1 = input().rstrip()
    s2 = input().rstrip()
    t.append(Ics(s1, s2))
print(*t, sep = "\n")
from itertools import accumulate as ac
N,K=map(int,input().split())
n=int(N**0.5)
mod=10**9+7
list_a=[1]*n
list_b=[N//j-N//(j+1) for j in range(1,N_s)]+[(N//n-n)]
list_p=[p for p in list_b]
list_aa=list(ac(list_a))
list_bb=list(reversed(list(ac(reversed(list_b)))))

for i in range(K-1):
    temp=sum(list_a)
    list_a=[(temp+list_bb[j])%mod for j in range(n)]
    list_b=[(list_p[j]*list_aa[j])%mod for j in range(n)]
    list_aa=list(ac(list_a))
    list_bb=list(reversed(list(ac(reversed(list_b)))))
    
print((sum(list_a+list_b))%mod)

### FIXED CODE ###

from itertools import accumulate
N,K=map(int,input().split())
N_s=int(N**0.5)
list_a=[1]*N_s
list_b=[N//j-N_s for j in range(1,N_s+1)]
list_p=[N//j-N_s for j in range(1,N_s+1)]
for p in range(1,len(list_p)):
        list_p[p-1]=list_p[p-1]-list_p[p]
        
for p in range(1,len(list_b)):
    list_b[p-1]=list_b[p-1]-list_b[p]

list_bb=list(reversed(list(accumulate(reversed(list_b)))))
list_aa=list(accumulate(list_a))

mod=10**9+7

for i in range(K-1):
    temp=sum(list_a)
    list_an=[(temp+list_bb[j])%mod for j in range(N_s)]
    list_bn=[(list_p[j-1]*list_aa[j-1])%mod for j in range(1,N_s+1)]

    list_bbn=list(reversed(list(accumulate(reversed(list_bn)))))
    list_aa=list(accumulate(list_an))
    list_a=list_an
    list_b=list_bn
    list_bb=list_bbn
    
print((sum(list_a)+sum(list_b))%mod)
from scipy.special import comb
n = int(input())
A = list(map(int, input().split()))
maxA = max(A)
tmp = 0
r = 0
for a in A:
    if maxA == a:
        continue
    combA = comb(maxA, a)
    if tmp < combA:
        tmp = combA
        r = a

print(maxA, r)

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
maxA = max(A)
halfA = maxA // 2
tmp = 10 ** 9
r = 0
for a in A:
    if a == maxA:
        continue
    half = abs(halfA - a)
    if tmp > half:
        tmp = half
        r = a

print(maxA, r)
def A(w, v, n,V):
    mem=[0 for i in range(V+1)]
    if n == 0 or V == 0:
        return 0
 
    for i in range(n):
        for j in range(V,w[i]-1,-1):
            m=v[i]+ mem[j - w[i]]
          	if m>mem[j]:
            	mem[j]=m
    return mem[V]
n,V=input().split()
n,V=int(n),int(V)
 
w=[0]*n
v=[0]*n
for i in range(n):
  x,y=input().split()
  w[i],v[i]=int(x),int(y)
 
print(A(w,v,n,V))

### FIXED CODE ###

def fragOptimalJump(h,n):
    dp=[0]*(n+1)
    dp[2]=abs(h[1]-h[2])
    for i in range(3,n+1):
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
    return dp[n]
  
N=int(input())
read = [int(n) for n in input().split()]
H=[0]+read
print(fragOptimalJump(H,N))
ab, bc, ca = map(int, input().split())
5 12 13
S = int((ab * bc) /2)

print(S)

### FIXED CODE ###

ab, bc, ca = map(int, input().split())
S = int((ab * bc) /2)
print(S)
S1=str(input())
S2=str(input())
for i in range(len(S1)):
  S1.append(S1[0])
  del S1[0]
  if S1 == S2:
    print('Yes')
    return
print('No')


### FIXED CODE ###

S1=str(input())
S2=str(input())
NG = True
for i in range(len(S1)):
  if S1 == S2[i:len(S1)]+S2[0:i]:
    print('Yes')
    NG = False
    break
if NG:
  print('No')
import numpy as np

N = int(input())
As = list(map(int, input().split()))

B = np.zeros(2 * 10**9, dtype = int)

ans = 0

for index, A in enumerate(As):
    if(index - A >= 0):
        ans += B[index-A]

    B[index+A] += 1
#    print(list(B[:20]))

print(ans)


### FIXED CODE ###

from collections import defaultdict
import numpy as np
import collections

N = int(input())
As = list(map(int, input().split()))

B = defaultdict(int)

ans = 0

for index, A in enumerate(As):
    ans += B[index-A]
    
    B[index+A] += 1
#    print(B)
#    print(list(B[:20]))

print(ans)
if __name__ == "__main__":
    N, A, B = map(int, input().split())
    S = "b" * A + "r" * B 
    S = S * 1000
    ret = S[:N].count("b")
    print(ret)

### FIXED CODE ###

import math

if __name__ == "__main__":
    N, A, B = map(int, input().split())
    ret =  math.floor(N / (A + B)) * A
    if N % (A + B) >= A:
        ret = ret + A
    else:
        ret = ret +  N % (A + B)
    print(ret)
# -*- config: utf-8 -*-


a = 0
b = 0
c = 0

a = input('>>>')
b = input('>>>')
c = input('>>>')

if a+b == c:
    j=1
if a+c == b:
    j=1
if b+c == a:
    j=1

if(j == 1):
    print 'YES'
else:
    print 'NO'



### FIXED CODE ###

# -*- config: utf-8 -*-
 
 
 
 
a,b,c = map(int,raw_input().split())
j = 0
 
 
if a + b == c or a + c == b or b + c== a:
    j=1
 
if(j == 1):
    print 'Yes'
else:
    print 'No'
n,m = map(int,input().split())
a = list(range(m+2))
a[0] = 0
a[m+1] = n+1
ans = 1
for i in range(m):
  a[i+1] = int(input())
for i in range(m+1):
  if a[i]+1 == a[i+1] and i != 0:
    ans = 0
    break
  else:
    x = a[i+1]-a[i]-1
    if x == 0 or x == 1:
      ans = ans%1000000007
    elif x == 2:
      ans = ans*2%1000000007
    else:
      ans = ans * int(1/(5**0.5) * (((1+(5**0.5))/2)**x - ((1-(5**0.5))/2)**x)) %1000000007

print(ans)


### FIXED CODE ###

n,m = map(int,input().split())
b = [] 
for i in range(n+1):
  if i == 0 or i == 1:
    b.append(1)
  else:
    b.append(b[i-2]+b[i-1])

ans = 1
if m != 0:
  a = list(range(m))
  for i in range(m):
    a[i] = int(input())
    if i == 0:
      ans = ans*b[a[i]-1]%1000000007
    else:
      if a[i] == a[i-1]+1:
        ans = 0
      else:
        ans = ans*b[a[i]-a[i-1]-2]%1000000007
  ans = ans*b[n-a[m-1]-1]%1000000007
  print(ans)
else:
  print(b[n]%1000000007)
import numpy as np


s = input()
t = input()
ls = len(s)
lt = len(t)

dp = np.array([[""]*(ls+2)]*(lt+2), dtype=object)
dp2 = np.zeros(((ls+2), (lt+2)))

for i in range(ls):
    flag = 0
    for j in range(lt):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j] + s[i]
            dp2[i+1][j+1] = dp2[i][j] + 1
        else:
            if dp2[i][j+1] > dp2[i+1][j]:
                dp[i+1][j+1] = dp[i][j+1]
                dp2[i+1][j+1] = dp2[i][j+1]
            else:
                dp[i+1][j+1] = dp[i+1][j]
                dp2[i+1][j+1] = dp2[i+1][j]
print(dp[ls][lt])



### FIXED CODE ###

s = input()
t = input()
ls = len(s)
lt = len(t)


dp = [[0 for i in range(lt+1)] for j in range(ls+1)]
answer = ''

for i in range(ls):
    for j in range(lt):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j] + 1
        else:
            dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j])


i = ls-1
j = lt-1
while (0 <= i) & (0 <= j):
    if s[i] == t[j]:
        answer += s[i]
        i -= 1
        j -= 1
    elif dp[i+1][j+1] == dp[i+1][j]:
        j -= 1
    else:
        i -= 1
if len(answer) == 0:
  print('')
else:
  print(answer[::-1])
x = input()

500yen = x//500*1000
5yen = (x - x//500)//5*5

print(500yen + 5yen)

### FIXED CODE ###

x = int(input())

a = x//500*1000
b = x%500//5*5

print(a+b)
import sys
args = sys.argv

s = int(args[0])
w = int(args[1])

if s <= w:
    print('unsafe')
else:
    print('safe')

### FIXED CODE ###

inputs = input().split(' ')

s = int(inputs[0])
w = int(inputs[1])

if s <= w:
    print('unsafe')
else:
    print('safe')
A, B = (int(x) for x in input().split())
if B % A == 0:
  return A + B
else:
  return B - A

### FIXED CODE ###

A, B = (int(x) for x in input().split())
if B % A == 0:
  print(A + B)
else:
  print(B - A)
import numpy as np
n=[]
line=''
while line != [0,0]:
    line=list(map(int,input().split()))
    n.append(line)
n=np.array(n)

### FIXED CODE ###

n=[]
line=''
while line != [0,0]:
    line=list(map(int,input().split()))
    n.append(line)
for i in range(len(n)-1):
    print('%d %d'%(n[i][0] if n[i][0]<=n[i][1] else n[i][1],n[i][0] if n[i][0]>=n[i][1] else n[i][1]))
N, M = map(int, input().split())
H = list(map(int, input().split()))
preH = [0 for i in range(N)]

for i in range(M):
    preH.append(list(map(int, input().split())))
ans = [True]*n

for i in range(M):
    A,B = preH[i] #一行ずつ処理

    if(H[A-1]>=H[B-1]):
        ans[A-1] = False
    if(H[B-1]>=H[A-1]):
        ans[B-1] = False

print(ans.count(True))

### FIXED CODE ###

N, M = map(int, input().split())
H = list(map(int, input().split()))
preH =[]
for i in range(M):
    preH.append(list(map(int, input().split())))
ans = [True]*N

for i in range(M):
    A,B = preH[i]


    if(H[A-1]<=H[B-1]):
        ans[A-1] = False
    if(H[B-1]<=H[A-1]):
        ans[B-1] = False

print(ans.count(True))
n = int(input())
ns = map(int, input().split())
print(sum(ns)-len(ns))

### FIXED CODE ###

n = int(input())
ns = list(map(int, input().split()))
print(sum(ns)-len(ns))
import sys
import collections
from functools import lru_cache

xy = []
d = collections.defaultdict(list)

@lru_cache(maxsize=None)
def alg_memoization_recursion(f):
    mt = 0
    for v in d[f]:
        mt = max(mt, alg_memoization_recursion(v) + 1)
    return mt


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    for i in range(m):
        x, y = list(map(int, readline().split()))
        d[x-1] += [y-1]
    mt = 0
    for i in range(n):
        mt = max(mt, alg_memoization_recursion(i))
    print(mt)


if __name__ == '__main__':
    solve()


### FIXED CODE ###

import sys
import collections
from functools import lru_cache

xy = []
d = collections.defaultdict(list)
@lru_cache(maxsize=None)
def alg_memoization_recursion(f):
    mt = 0
    for v in d[f]:
        mt = max(mt, alg_memoization_recursion(v) + 1)
    return mt


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    sys.setrecursionlimit(10 ** 5 + 1)
    n, m = list(map(int, readline().split()))
    for i in range(m):
        x, y = list(map(int, readline().split()))
        d[x-1] += [y-1]
    mt = 0
    for i in range(n):
        mt = max(mt, alg_memoization_recursion(i))
    print(mt)


if __name__ == '__main__':
    solve()
N,K=input().split()
n,k=int(N),int(K)

for i in range(0,1000000):
  
    if n-k**i>1:
        print(i)
        break
    if n=k**i-1:
        print(i-1)
        break

### FIXED CODE ###

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

cnt = 0
while (n) :
    cnt += 1
    n //= k

print (cnt)