Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def primes(n):
    """ Input n>=6, Returns a list of primes, 2 <= p < n """
    n, correction = n-n%6+6, 2-(n%6>1)
    sieve = [True] * (n//3)
    for i in range(1,int(n**0.5)//3+1):
      if sieve[i]:
        k=3*i+1|1
        sieve[      k*k//3      ::2*k] = [False] * ((n//6-k*k//6-1)//k+1)
        sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1)
    return [2,3] + [3*i+1|1 for i in range(1,n//3-correction) if sieve[i]]

q = int(input())
pl = primes(10**5)
ql = [p*2-1 for p in pl if p*2-1 in pl and p*2-1<=10**5+1]
for _ in range(q):
  l,r = map(int,input().split())
  fil = list(filter(lambda x: l<=x<=r, ql))
  print(len(fil))

Fixed submission:
import itertools

def prime_boolean_table(n):
    primes = [True] * (n + 1)
    primes[0] = False
    primes[1] = False
    for i in range(2, n + 1):
        if primes[i]:
            for j in range(i + i, n + 1, i):
                primes[j] = False
    return primes

pl = prime_boolean_table(10**5)
ql = [0]*(10**5+1)
for i in range(1,10**5+1):
    if pl[i] and pl[(i+1)//2]:
        ql[i] += 1
ql = list(itertools.accumulate(ql))
q = int(input())
for _ in range(q):
    l,r = map(int,input().split())
    print(ql[r]-ql[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
def primes(n):
    """ Input n>=6, Returns a list of primes, 2 <= p < n """
    n, correction = n-n%6+6, 2-(n%6>1)
    sieve = [True] * (n//3)
    for i in range(1,int(n**0.5)//3+1):
      if sieve[i]:
        k=3*i+1|1
        sieve[      k*k//3      ::2*k] = [False] * ((n//6-k*k//6-1)//k+1)
        sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1)
    return [2,3] + [3*i+1|1 for i in range(1,n//3-correction) if sieve[i]]

q = int(input())
pl = primes(10**5)
ql = [p*2-1 for p in pl if p*2-1 in pl and p*2-1<=10**5+1]
for _ in range(q):
  l,r = map(int,input().split())
  fil = list(filter(lambda x: l<=x<=r, ql))
  print(len(fil))

Fixed submission:
import itertools

def prime_boolean_table(n):
    primes = [True] * (n + 1)
    primes[0] = False
    primes[1] = False
    for i in range(2, n + 1):
        if primes[i]:
            for j in range(i + i, n + 1, i):
                primes[j] = False
    return primes

pl = prime_boolean_table(10**5)
ql = [0]*(10**5+1)
for i in range(1,10**5+1):
    if pl[i] and pl[(i+1)//2]:
        ql[i] += 1
ql = list(itertools.accumulate(ql))
q = int(input())
for _ in range(q):
    l,r = map(int,input().split())
    print(ql[r]-ql[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
n = int(input())
a = list(map(int, input().split()))
i = 0
while(True):
  for x in a:
    if x%2!=0:
      print(i)
      sys.exit()
    else:
      x = x//2
  i += 1


Fixed submission:
import sys
def main():
    n = int(input())
    a = list(map(int, input().split()))
    i = 0
    while(True):
        for x in a:
            if x%2!=0:
                print(i)
                sys.exit()

        a = [x//2 for x in a]
        i += 1

if __name__=="__main__":
    main()
Buggy python submission (verdict: Runtime Error):
n = int(input())
a= [0]*86
a[0]=1
a[1]=2
for i in range(2,87):
  a[i]=a[i-1]+a[i-2]
print(a[n-1])

Fixed submission:
n = int(input())
a= [0]*87
a[0]=2
a[1]=1
for i in range(2,87):
    a[i]=a[i-1]+a[i-2]

print(a[n])
Buggy python submission (verdict: Runtime Error):
import collections
n=int(input())
a=sorted(list(collections.Counter(map(int,input().split())).items()), key=lambda x: x[0])
b=sorted(list(collections.Counter(map(int,input().split())).items()), key=lambda x: x[0])
c=sorted(list(collections.Counter(map(int,input().split())).items()), key=lambda x: x[0])

bc=[0]*len(b)
j=0
tmp=sum(i[1] for i in c)
for i,x in enumerate(b):
  while j<n and x[0]>=c[j][0]:
    tmp-=c[j][1]
    j+=1
  bc[i]=tmp

abc=[0]*len(a)
j=0
tmp=sum(i[1]*j for i,j in zip(b,bc))

for i,x in enumerate(a):
  while j<n and x[0]>=b[j][0]:
    tmp-=b[j][1]*bc[j]
    j+=1
  abc[i]=tmp
ans=sum(i[1]*j for i,j in zip(a,abc))
#print(a,b,c,bc,abc,sep="\n")
print(ans)


Fixed submission:
import collections
n=int(input())
a=sorted(list(collections.Counter(map(int,input().split())).items()), key=lambda x: x[0])
b=sorted(list(collections.Counter(map(int,input().split())).items()), key=lambda x: x[0])
c=sorted(list(collections.Counter(map(int,input().split())).items()), key=lambda x: x[0])
la=len(a)
lb=len(b)
lc=len(c)
bc=[0]*lb
j=0
tmp=sum(i[1] for i in c)
for i,x in enumerate(b):
  while j<lc and x[0]>=c[j][0]:
    tmp-=c[j][1]
    j+=1
  bc[i]=tmp

abc=[0]*la
j=0
tmp=sum(i[1]*j for i,j in zip(b,bc))
for i,x in enumerate(a):
  while j<lb and x[0]>=b[j][0]:
    tmp-=b[j][1]*bc[j]
    j+=1
  abc[i]=tmp
ans=sum(i[1]*j for i,j in zip(a,abc))
#print(a,b,c,bc,abc,sep="\n")
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a1=0
a2=0
a3=0
for i in a:
  if a%4==0:
    a1+=1
  elif a%4==2:
    a2+=1
  else:
    a3+=1
    
if a3==0:
  print("Yes")
else:
  if a2==0:
    if a1>=a3-1:
      print("Yes")
    else:
      print("No")
  else:
    if a1>=a3:
      print("Yes")
    else:
      print("No")

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a1=0
a2=0
a3=0
for i in a:
  if i%4==0:
    a1+=1
  elif i%4==2:
    a2+=1
  else:
    a3+=1
    
if a3==0:
  print("Yes")
else:
  if a2==0:
    if a1>=a3-1:
      print("Yes")
    else:
      print("No")
  else:
    if a1>=a3:
      print("Yes")
    else:
      print("No")
Buggy python submission (verdict: Runtime Error):
n,l = map(int, input().split())
string = [input() for i in range(n)]
string.sort()
print("".join(string))

Fixed submission:
a,b,c = map(int, input().split())
if a*b*c==5*5*7:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
import itertools
def main():
    n,k = map(int, input().split())
    ds =  map(int, input().split())
    canuse = [i for i in range(10)]
    for d in ds: canuse.remove(d)
    canuse = [str(c) for c in canuse]
    digit = len(str(n))
    x = [int("".join(a)) for a in itertools.product(canuse, repeat=digit) if int("".join(a))>=n]
    print(min(x))
if __name__ == "__main__":
    main()

Fixed submission:
import itertools
import sys
def main():
    n,k = map(int, input().split())
    ds =  list(map(int, input().split()))
    for i in range(n, 10**6):
        s = str(i)
        for d in ds:
            if str(d) in s:
                f = False
                break
            else:
                f = True
        if f:
            print(i)
            sys.exit()
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
= int(input())
if N // 2 == 0:
  ans = N / 2 - 1
else:
  ans = (N - 1) / 2
print(ans)

Fixed submission:
N=int(input())
if N%2==0:
    print(N//2-1)
else:
    print((N+1)//2-1)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8

alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

num = int(input())
str = input()
result = ""

for s in str:
  pos = alpha.find(s)
  result += alpha[pos+num]

print(result)

Fixed submission:
# coding: utf-8

week = {"SUN":7,"MON":6,"TUE":5,"WED":4,"THU":3,"FRI":2,"SAT":1}

str = input()

print(week[str])
Buggy python submission (verdict: Runtime Error):
import py

a = input()
a=int(a)
s=input()
if a >= 3200:
  print(s)
else:
    print('red')

Fixed submission:
a=int(input())
s=input()
if a>=3200:
  print(s)
else:
  print('red')

Buggy python submission (verdict: Runtime Error):
a=input()
a=int(x)
s=input()
if y>=3200:
  print(s)
else:
  print("red")

Fixed submission:
a=int(input())
s=input()
if a>=3200:
  print(s)
else:
  print('red')

Buggy python submission (verdict: Runtime Error):
a = input()
s=input()
if a >= 3200:
  print(s)
else:
    print('red')

Fixed submission:
a=int(input())
s=input()
if a>=3200:
  print(s)
else:
  print('red')
Buggy python submission (verdict: Runtime Error):



n = input()
print(3*n*n)






Fixed submission:
# *-* coding=utf-8 *-*


n = int(input())
print(3*n*n)

Buggy python submission (verdict: Runtime Error):
# *-* coding=utf-8 *-*


n = input()
print(3*n*n)






Fixed submission:
# *-* coding=utf-8 *-*


n = int(input())
print(3*n*n)
Buggy python submission (verdict: Runtime Error):
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

if D2 == 1:
    print 1
else:
    print 0


Fixed submission:
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

if D2 == 1:
    print(1)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
M1,D1 = map(int,input().split())
M2,D2 = map(int,input().split())

if D2 == 1:
    print 1
else:
    print 0


Fixed submission:
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

if D2 == 1:
    print(1)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
M1,D1 = map(int,input().split())
M2,D2 = map(int,input().split())

if D2 == 1:
  print 1
else:
  print 0


Fixed submission:
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

if D2 == 1:
    print(1)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
M1,D1=map(int,input().split())
M2,D2=map(int,input().split())

if d2==1:
  print 1
else:
  print 0


Fixed submission:
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

if D2 == 1:
    print(1)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
M1,D1=map(int,input.split())
M2,D2=map(int,input.split())

if d2==1:
  print 1
else:
  print 0

Fixed submission:
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

if D2 == 1:
    print(1)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
for _ in range(M):
    a, b = map(int, input().split())
if M[1]==1:
  print 1
else:
  print 0

Fixed submission:
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

if D2 == 1:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
payment = input()
price = float(payment) / 1.08


if (price - int(price)) == 0:
  print(int(price))
else:
  print(':(')


Fixed submission:
targetDay = input().split()
nextDay	  = input().split()

if targetDay[0] != nextDay[0]:
	print(1)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from functools import reduce
n = int(input())
d = [int(s) for s in input().split()]
if d[0] != 0:
    print(0)
    quit(0)
c = Counter(d)
if c[0] != 1:
    print(0)
    quit(0)
print(reduce(lambda x, y: x * y, (c[x - 1] for x in d[1:]), 1) % 998244353)



Fixed submission:
from collections import Counter
from functools import reduce
n = int(input())
d = (int(s) for s in input().split())
if next(d) != 0:
    print(0)
    quit(0)
c = Counter(d)
if c[0] != 0:
    print(0)
    quit(0)
print(reduce(lambda x, y: x * y, (c[k - 1] ** x if k > 1 else 1 for k, x in c.items()), 1) % 998244353)

Buggy python submission (verdict: Runtime Error):
from functools import reduce
from collections import Counter
n = int(input())
d = [int(s) for s in input().split()]
c = Counter(d)
ds = [0] * (max(c.keys()) + 1)
for k, v in c.items():
  ds[k] = v
print(reduce(lambda x, y: x * y, (x ** y for x, y in zip(ds[:-1], ds[1:])), 1) if ds[0] == 1 and d[0] = 0 else 0)



Fixed submission:
from collections import Counter
from functools import reduce
n = int(input())
d = (int(s) for s in input().split())
if next(d) != 0:
    print(0)
    quit(0)
c = Counter(d)
if c[0] != 0:
    print(0)
    quit(0)
print(reduce(lambda x, y: x * y, (c[k - 1] ** x if k > 1 else 1 for k, x in c.items()), 1) % 998244353)

Buggy python submission (verdict: Runtime Error):
from functools import reduce
from collections import Counter
n = int(input())
c = Counter(int(s) for s in input().split())
ds = [0] * max(c.keys() + 1)
for k, v in c.items():
  ds[k] = v
print(reduce(lambda x, y: x * y, (x ** y for x, y in zip(ds[:-1], ds[1:])), 1) if ds[0] == 1 else 0)

Fixed submission:
from collections import Counter
from functools import reduce
n = int(input())
d = (int(s) for s in input().split())
if next(d) != 0:
    print(0)
    quit(0)
c = Counter(d)
if c[0] != 0:
    print(0)
    quit(0)
print(reduce(lambda x, y: x * y, (c[k - 1] ** x if k > 1 else 1 for k, x in c.items()), 1) % 998244353)
Buggy python submission (verdict: Runtime Error):
from functools import reduce
from math import gcd

if __name__ == '__main__':
    n = int(input())
    a = [int(s) for s in input().split()]
    print(reduce(gcd, a))


Fixed submission:
from functools import reduce

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


if __name__ == '__main__':
    n = int(input())
    a = [int(s) for s in input().split()]
    print(reduce(gcd, a))
Buggy python submission (verdict: Runtime Error):
import sys

mp = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]

if __name__ == '__main__':
    n, m = map(int, input().split())
    a = sorted(input().split(), reverse=True)

    dp = [-10007] * (n + 1)
    dp[0] = 0
    for i in a:
        step = mp[int(i)]
        for j in range(step, n + 1):
            dp[j] = max(dp[j - step] + 1, dp[j])

    i = n
    while i > 0:
        for x in a:
            step = mp[int(x)]
            if dp[i - step] == dp[i] - 1:
                sys.stdout.write(x)
                i -= step
                break
    print()


Fixed submission:
import sys

mp = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]

if __name__ == '__main__':
    n, m = map(int, input().split())
    a = sorted(input().split(), reverse=True)

    dp = [-10007] * (n + 1)
    dp[0] = 0
    for i in a:
        step = mp[int(i)]
        for j in range(step, n + 1):
            dp[j] = max(dp[j - step] + 1, dp[j])

    i = n
    while i > 0:
        for x in a:
            step = mp[int(x)]
            if i >= step and dp[i - step] == dp[i] - 1:
                sys.stdout.write(x)
                i -= step
                break
    print()

Buggy python submission (verdict: Runtime Error):
import sys
from collections import deque, defaultdict

mp = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]

if __name__ == '__main__':
    n, m = map(int, input().split())
    a = sorted(input().split())
    x = min(a, key=lambda x: mp[int(x)])
    key_x = mp[int(x)]
    quo, rem = divmod(n, key_x)
    buf = deque([x] * quo)

    dp = defaultdict(str)
    dp[0] = ''
    while rem not in dp:
        rem += key_x
        buf.pop()
        for k, v in list(dp.items()):
            for i in a:
                index = mp[int(i)]
                dp[k + index] = max(dp[k + index], i + v)
            del dp[k]

    for c in dp[rem]:
        if c > x:
            sys.stdout.write(c)
        else:
            buf.append(c)
    print(''.join(buf))


Fixed submission:
import sys

mp = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]

if __name__ == '__main__':
    n, m = map(int, input().split())
    a = sorted(input().split(), reverse=True)

    dp = [-10007] * (n + 1)
    dp[0] = 0
    for i in a:
        step = mp[int(i)]
        for j in range(step, n + 1):
            dp[j] = max(dp[j - step] + 1, dp[j])

    i = n
    while i > 0:
        for x in a:
            step = mp[int(x)]
            if i >= step and dp[i - step] == dp[i] - 1:
                sys.stdout.write(x)
                i -= step
                break
    print()
Buggy python submission (verdict: Runtime Error):
from collections import Counter
from collections import deque

if __name__ == '__main__':
    n = int(input())
    vs0 = []
    vs1 = []
    for i,v in enumerate(map(int, input().split())):
        if i % 2 == 0:
            vs0.append(v)
        else:
            vs1.append(v)
    vs0 = deque(sorted(Counter(vs0).items(), key=lambda t: t[0]))
    vs1 = deque(sorted(Counter(vs1).items(), key=lambda t: t[0]))
    t0 = vs0.pop()
    t1 = vs1.pop()
    if t0[0] != t1[0]:
        vs0 = (t[1] for t in vs0)
        vs1 = (t[1] for t in vs1)
        print(sum(vs0) + sum(vs1))
    else:
        if len(vs1) == 0:
            if len(vs0) == 0:
                print(t1[1])
            else:
                vs0 = (t[1] for t in vs0)
                print(sum(vs0))
        elif len(vs0) == 0:
            vs1 = (t[1] for t in vs1)
            print(sum(vs1))
        else:
            t00 = vs0.pop()
            t11 = vs1.pop()
            a = t00 + t1
            b = t11 + t0
            print(sum(vs0) + sum(vs1) + (a if a < b else b))



Fixed submission:
from collections import Counter
from collections import deque

if __name__ == '__main__':
    n = int(input())
    vs0 = []
    vs1 = []
    for i,v in enumerate(map(int, input().split())):
        if i % 2 == 0:
            vs0.append(v)
        else:
            vs1.append(v)
    vs0 = deque(sorted(Counter(vs0).items(), key=lambda t: t[1]))
    vs1 = deque(sorted(Counter(vs1).items(), key=lambda t: t[1]))
    t0 = vs0.pop()
    t1 = vs1.pop()
    if t0[0] != t1[0]:
        vs0 = (t[1] for t in vs0)
        vs1 = (t[1] for t in vs1)
        print(sum(vs0) + sum(vs1))
    else:
        if len(vs1) == 0:
            if len(vs0) == 0:
                print(t1[1])
            else:
                vs0 = (t[1] for t in vs0)
                print(sum(vs0))
        elif len(vs0) == 0:
            vs1 = (t[1] for t in vs1)
            print(sum(vs1))
        else:
            t00 = vs0.pop()
            t11 = vs1.pop()
            a = t00[1] + t1[1]
            b = t11[1] + t0[1]
            vs0 = (t[1] for t in vs0)
            vs1 = (t[1] for t in vs1)
            print(sum(vs0) + sum(vs1) + (a if a < b else b))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

def solve(d, g, pcs):
    queue = deque()
    queue.append((0, d, g, pcs, 0))
    while True:
        count, d, g, pcs, n = queue.popleft()
        #print(count, d, g, pcs)
        if g <= 0:
            return count
        if n > 0:
            p, c = pcs[n - 1]
            l = pcs.copy()
            if p == 1:
                l = pcs.copy()
                l[n - 1] = (0, 0)
                queue.append((count + 1, d, g - c - 100 * n, l, 0))
            elif p > 1:
                l = pcs.copy()
                l[n - 1] = (p - 1, c)
                queue.append((count + 1, d, g - 100 * n, l, n))
        else:
            for i in range(1, d + 1):
                p, c = pcs[i - 1]
                if p == 1:
                    l = pcs.copy()
                    l[i - 1] = (0, 0)
                    queue.append((count + 1, d, g - c - 100 * i, l, 0))
                elif p > 1:
                    l = pcs.copy()
                    l[i - 1] = (p - 1, c)
                    queue.append((count + 1, d, g - 100 * i, l, i))


if __name__ == "__main__":
    d, g = map(int, input().split())
    pcs = [tuple(int(s) for s in input().split()) for _ in range(d)]
    print(solve(d, g, pcs))


Fixed submission:
from collections import deque

def solve(count, i, g, pcs, rem):
    if g <= 0:
        return count
    if pcs == []:
        index, p = rem
        if index == 0:
            return count
        plus = g // (100 * index) + (1 if g % (100 * index) != 0 else 0)
        return count + plus if plus < p else float("Inf")
    p, c = pcs[0]
    l = pcs[1:]
    a = solve(count, i + 1, g, l, (i, p))
    b = solve(count + p, i + 1, g - c - 100 * i * p, l, rem)
    return a if a < b else b



if __name__ == "__main__":
    d, g = map(int, input().split())
    pcs = [tuple(int(s) for s in input().split()) for _ in range(d)]
    print(solve(0, 1, g, pcs, (0, 0)))
Buggy python submission (verdict: Time Limit Exceeded):
class query:
    def __init__(self, a, b, c, d):
        self.a = a
        self.b = b
        self.c = c
        self.d = d
    def isEternal(self):
        if self.a < self.b:
            return "No"
        if self.a % self.b > self.c:
            return "No"
        if self.d < self.b:
            return "No"
        d = self.b - self.c
        if d <= 0:
            return "Yes"
        if self.b % d == 0 and self.d % d == 0:
            return "Yes"
        s = self.a % self.b
        db = self.d % self.b
        if db == 0:
            return "Yes"
        for i in range(self.b - 1):
            s += db
            if s >= self.b:
                return "Yes"
            if s > self.c:
                return "No"
        return "Yes"

if __name__ == "__main__":
    t = int(input())
    querys = [query(*[int(s) for s in input().split()]) for _ in range(t)]
    for q in querys:
        print(q.isEternal())


Fixed submission:
def gcd(a, b):
    r = a % b
    while r != 0:
        a, b, r = b, r, b % r
    return b

class query:
    def __init__(self, a, b, c, d):
        self.a = a
        self.b = b
        self.c = c
        self.d = d
    def isEternal(self):
        if self.a < self.b:
            return "No"
        if self.d < self.b:
            return "No"
        if self.b <= self.c:
            return "Yes"
        g = gcd(self.d, self.b)
        if self.b - g + self.a % g > self.c:
            return "No"
        return "Yes"

if __name__ == "__main__":
    t = int(input())
    querys = [query(*[int(s) for s in input().split()]) for _ in range(t)]
    for q in querys:
        print(q.isEternal())
Buggy python submission (verdict: Time Limit Exceeded):
def solve(array, k):
    ans = 0
    length = len(array)
    i = 0
    while i < length - 1:
        if array[i] == array[i + 1]:
            i += 1
        elif i + k >= length:
            ans += 1
            break
        else:
            ans += 1
            i += k - 1
            array[i] = min(array[:i + 1])
    return ans
    
if __name__ == "__main__":
    n, k = map(int, input().split())
    array = [int(s) for s in input().split()]
    print(solve(array, k))

Fixed submission:
def solve(n, k):
    div, mod = divmod(n - 1, k - 1)
    return div + (0 if mod == 0 else 1)

if __name__ == "__main__":
    n, k = map(int, input().split())
    array = [int(s) for s in input().split()]
    print(solve(n, k))

Buggy python submission (verdict: Time Limit Exceeded):
def solve(array, k):
    ans = 0
    length = len(array)
    i = 0
    while i < length - 1:
        if array[i] == array[i + 1]:
            i += 1
        elif i + k >= length:
            ans += 1
            break
        else:
            ans += 1
            i += k - 1
            array[i] = min(array[:i + 1])
    return ans
    
if __name__ == "__main__":
    n, k = map(int, input().split())
    array = [int(s) for s in input().split()]
    print(solve(array, k))

Fixed submission:
def solve(n, k):
    div, mod = divmod(n - 1, k - 1)
    return div + (0 if mod == 0 else 1)

if __name__ == "__main__":
    n, k = map(int, input().split())
    array = [int(s) for s in input().split()]
    print(solve(n, k))

Buggy python submission (verdict: Runtime Error):
def solve(array, k):
    if len(array) <= 1:
        return 0
    if array[0] == array[1]:
        return solve(array[1:], k)
    if len(array) <= k:
        return 1
    return 1 + solve([min(array[:k])] + array[k:], k)

if __name__ == "__main__":
    n, k = map(int, input().split())
    array = [int(s) for s in input().split()]
    print(solve(array, k))

Fixed submission:
def solve(n, k):
    div, mod = divmod(n - 1, k - 1)
    return div + (0 if mod == 0 else 1)

if __name__ == "__main__":
    n, k = map(int, input().split())
    array = [int(s) for s in input().split()]
    print(solve(n, k))
Buggy python submission (verdict: Runtime Error):
n,x=map(int,input().split())
m=[int(input()) for _ in range(n)]
print((x - sum(m)) // min(m) + m)

Fixed submission:
n,x=map(int,input().split())
m=[int(input()) for _ in range(n)]
print((x - sum(m)) // min(m) + n)

Buggy python submission (verdict: Runtime Error):
n,x=map(int,input())
m=[int(input()) for _ in range(n)]
print((x - sum(m)) // min(m) + m)

Fixed submission:
n,x=map(int,input().split())
m=[int(input()) for _ in range(n)]
print((x - sum(m)) // min(m) + n)