qyliang/CodeNanoFix huggingface dataset:
Buggy code:
W, a, b = map(int,input().split())

if a+W<=b:
  print(b-(a+W))
elif (a<= b)and (b<(a+W)):
  print(b-a)
elif (b<=a) and(a<b+W):
  print(a-b)
elif (b+W)<a:
  print(a-(b+W))

Fixed code:
W, a, b = map(int,input().split())
 
if (a+W)<=b:
  print(b-(a+W))
elif (a<= b)and (b<(a+W)):
  print(0)
elif ((a-W)<=b) and(b<a):
  print(0)
elif b<(a-W):
  print(a-(b+W))
Buggy code:
w,a,b = map(int,input().split())

if b < a:
  print(a-b)
elif a <= b <= a+w:
  print("0")
elif a+w < b:
  print(b - (a+w))

Fixed code:
w,a,b = map(int,input().split())
if b > a+w:
  print(b-a-w)
elif a-w<=b<=a+w:
  print(0)
elif b<a-w:
  print(a-b-w)
Buggy code:
W, a, b = map(int, input().split())
print(max(0, b - (a+W)))

Fixed code:
W, a, b = map(int, input().split())
print(max(0, b - (a+W), a - (b+W)))
Buggy code:
w,a,b=map(int,input().split())
if min(a,b) + w >= max(a,b):
  print(0)
else:
  ans = max(a,b) - min(a,b) + w
  print(ans)

Fixed code:
w,a,b=map(int,input().split())
if min(a,b) + w >= max(a,b):
  print(0)
else:
  ans = max(a,b) - min(a,b) - w
  print(ans)
Buggy code:
w,a,b=map(int,input().split())
minu=min(a,b)
maxi=max(a,b)
print(maxi-(minu+w) if maxi-(minu-w)>0 else 0)

Fixed code:
w,a,b=map(int,input().split())
minu=min(a,b)
maxi=max(a,b)
print(maxi-(minu+w) if maxi-(minu+w)>0 else 0)
Buggy code:
w,a,b=map(int,input().split())
if len(sorted(set(range(a,a+w+1)) | set(range(b,b+w+1)))) !=0:
  print("0")
elif b>=a+w:
  print(b-a-w)
elif a>=b+w:
  print(a-b-w)

Fixed code:
w,a,b=map(int,input().split())
if len(sorted(set(range(a,a+w+1)) & set(range(b,b+w+1)))) !=0:
  print("0")
elif b>=a+w:
  print(b-a-w)
elif a>=b+w:
  print(a-b-w)
Buggy code:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    w, a, b = i_map()

    if a + w < b:
        print(b-a+w)
    elif b + w < a:
        print(a-b+w)
    else:
        print(0)

if __name__ == '__main__':
    main()


Fixed code:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    w, a, b = i_map()

    if a + w < b:
        print(b-a-w)
    elif b + w < a:
        print(a-b-w)
    else:
        print(0)

if __name__ == '__main__':
    main()
Buggy code:
MOD = 10**9 + 7

W,a,b = map(int,input().split())

if a + W < b:
    print(b - a - W)
else: print(0)


Fixed code:
MOD = 10**9 + 7

W,a,b = map(int,input().split())
if a <= b:
    if a + W < b:
        print(b - a - W)
    else: print(0)
else:
    if b + W < a:
        print(a - b - W)
    else: print(0)
Buggy code:
w,a,b=map(int,input().split())
print(max(0,min(b-(a+w),a-(b+w))))

Fixed code:
w,a,b = map(int, input().split())
print(max(0,max(a,b)-min(a,b)-w))
Buggy code:
n,c,k=map(int,input().split())
t=[0]*n
for i in range(n):
    t[i]=int(input())
t.sort()
s=0
lt=0
ln=0
for i in range(n):

    if i==0:
       lt=i
       ln+=1
    else:
        if t[i]-t[lt]>k:
            s+=1
            lt=i
            ln=1

        if ln==c:
            s+=1
            lt=i
            ln=0
        else:
            ln+=1
        print(i, s, lt, ln)


if t[n-1]-t[lt]>k:
    s+=1
    ln+=1
    
if ln>0:
    s+=1

print(s)

Fixed code:
n,c,k=map(int,input().split())
t=[0]*n
for i in range(n):
    t[i]=int(input())
t.sort()
s=0
lt=0
ln=0

if c==1:
    print(n)
    exit()
for i in range(n):

    if i==0:
       lt=i
       ln+=1

    else:
        if t[i]-t[lt]>k:
            s+=1
            lt=i
            ln=0

        ln+=1
        if ln==c:
            s+=1
            lt=i+1
            ln=0

        #print(i, s, lt, ln)


    
if ln>0:
    s+=1

print(s)
Buggy code:
n,c,k = map(int,input().split())
t = [int(input()) for _ in range(n)]
t.sort()
cnt = 0
ans = 0
end = -1
for i,t in enumerate(t):
  if end <= t:
    cnt = 1
    ans +=1
    end = t+k
  else:
    cnt +=1
  if cnt > c:
    cnt = 1
    ans +=1
    end = t+k
  print("i",i,"t",t,"cnt",cnt,"ans",ans,"end",end)
print(ans)

Fixed code:
n,c,k = map(int,input().split())
t = [int(input()) for _ in range(n)]
t.sort()
cnt = 0
ans = 0
end = -1
for i,t in enumerate(t):
  if end < t:
    cnt = 1
    ans +=1
    end = t+k
  else:
    cnt +=1
  if cnt > c:
    cnt = 1
    ans +=1
    end = t+k
#  print("i",i,"t",t,"cnt",cnt,"ans",ans,"end",end)
print(ans)
Buggy code:
n, c, k = map(int, input().split())
t = []
for _ in range(n):
    t.append(int(input()))
t.sort()
passenger = 0
bus_flag = False
bus_launch = 0
ans = 0
for i in range(n):
    if not bus_flag:
        bus_launch = t[i] + k
        bus_flag = True

    if t[i] <= bus_launch:
        passenger += 1
        if passenger == c:
            ans += 1
            bus_flag = False
            passenger = 0
    else:
        ans += 1
        bus_flag = False
        passenger = 0

if passenger != 0:
    ans += 1
print(ans)




Fixed code:
n, c, k = map(int, input().split())
t = []
for _ in range(n):
    t.append(int(input()))
t.sort()
passenger = 0
bus_flag = False
bus_launch = 0
ans = 0
for i in range(n):
    if not bus_flag:
        bus_launch = t[i] + k
        bus_flag = True

    if t[i] <= bus_launch:
        passenger += 1
        if passenger == c:
            ans += 1
            bus_flag = False
            passenger = 0
    else:
        ans += 1
        bus_launch = t[i] + k
        passenger = 1

if passenger != 0:
    ans += 1
print(ans)
Buggy code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n ,c, k = inintm()

T = []
ans = 1

for _ in range(n):
    T.append(inint())

T.sort()

f = T[0]
cnt = 0

for i in range(1,n):
    if T[i] - f < k and cnt <= c:
        continue
    else:
        f = T[i]
        ans += 1

print(ans)
print(T)

Fixed code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n ,c, k = inintm()

T = []
ans = 1

for _ in range(n):
    T.append(inint())

T.sort()

f = T[0]
cnt = 1

for i in range(1,n):
    cnt += 1
    if T[i] - f <= k and cnt <= c:
        continue
    else:
        f = T[i]
        ans += 1
        cnt = 1

print(ans)
Buggy code:
n, c, k = map(int, input().split())
T = sorted([int(input()) for _ in range(n)])

limit = T[0] + k
bus = [0]
ans = 0
for t in T:
    if t <= limit:
        if bus[-1] <= c:
            bus[-1] += 1
        else:
            bus.append(1)
    else:
        limit = t + k
        ans += len(bus)
        bus = [1]

ans += len(bus)

print(ans)

Fixed code:
n, c, k = map(int, input().split())
T = sorted([int(input()) for _ in range(n)])

limit = T[0] + k
bus = [0]
ans = 0
for t in T:
    if t <= limit:
        if bus[-1] < c:
            bus[-1] += 1
        else:
            bus.append(1)
            limit = t + k

    else:
        limit = t + k
        ans += len(bus)
        bus = [1]

ans += len(bus)

print(ans)
Buggy code:
N, C, K = map(int, input().split())
T = list(int(input()) for i in range(N))
T.sort()
bus = 1
passenger = 0
limit = T[0] + K
for i in range(N):
    if T[i] <= limit and passenger < c:
        passenger += 1
    else:
        bus += 1
        limit = T[i]+K
        passenger = 1
print(bus)

Fixed code:
N, C, K = map(int, input().split())
T = list(int(input()) for i in range(N))
T.sort()
bus = 1
passenger = 0
limit = T[0] + K
for i in range(N):
    if T[i] <= limit and passenger < C:
        passenger += 1
    else:
        bus += 1
        limit = T[i]+K
        passenger = 1
print(bus)
Buggy code:
N, C, K = list(map(int, input().split()))
T = []
for i in range(N):
  T.append(int(input()))

bus = []
departure=0

for passenger in T:
  if bus == []:
    bus.append(passenger)
    
  elif passenger <= bus[0]+K and len(bus)<(C-1):
    bus.append(passenger)
  
  else:
    bus.clear()
    departure+=1
    
if bus == []:
  print(departure)
else:
  print(departure + 1)

Fixed code:
N, C, K = list(map(int, input().split()))
T = []
for i in range(N):
  T.append(int(input()))

bus = []
departure=0

T.sort()

for passenger in T:
  if bus == []:
    bus.append(passenger)
    
  elif passenger <= bus[0]+K and len(bus)<=(C-1):
    bus.append(passenger)
  
  else:
    bus.clear()
    departure+=1
    bus.append(passenger)
    
if bus != []:
  print(departure + 1)
else:
  print(departure)
Buggy code:
n,c,k = map(int,input().split())
t = []
for i in range(n):
    t.append(int(input()))

t.sort()

ans = 0
cnt = 0
tmp = 0
s = t[0]

while tmp < n:
    t1 = t[tmp]
    tmp += 1
    cnt += 1
    if cnt == c:
        ans += 1
        cnt = 0
        if tmp < n:
            s = t[tmp]
        else:
            print(ans)
            exit()
    elif t1 - s > k:
        if tmp < n:
            ans += 1
            cnt = 0
            s = t[tmp-1]
        else:
            print(ans)
            exit()

print(ans+1)


Fixed code:
n,c,k = map(int,input().split())
t = []
for i in range(n):
    t.append(int(input()))

t.sort()

ans = 0
cnt = 0
tmp = 0
s = t[0]

while tmp < n:
    t1 = t[tmp]
    cnt += 1
    if t1 - s > k:
        ans += 1
        cnt = 1
        s = t[tmp]
    elif cnt == c:
        if tmp < n - 1:
            s = t[tmp + 1]
            ans += 1
            cnt = 0

    tmp += 1

if cnt > 0:
    ans += 1

print(ans)
Buggy code:
def solve():

    N, C, K = map(int, input().split())
    T = [int(input()) for i in range(N)]

    T = sorted(T)
    i = 0
    k = 0

    ans = 0

    print(T)

    while i < N:
        n = 0
        while k < N and n < C and T[i] <= T[k] <= T[i]+K:
            n += 1
            k += 1
            if n == C:
                ans += 1
                break

        if n != C:
            ans += 1

        i = k



    print(ans)            


if __name__ == "__main__":
    solve()


Fixed code:
def solve():

    N, C, K = map(int, input().split())
    T = [int(input()) for i in range(N)]

    T = sorted(T)
    i = 0
    k = 0

    ans = 0

    #print(T)

    while i < N:
        n = 0
        while k < N and n < C and T[i] <= T[k] <= T[i]+K:
            n += 1
            k += 1
            if n == C:
                ans += 1
                break

        if n != C:
            ans += 1

        i = k



    print(ans)            


if __name__ == "__main__":
    solve()
Buggy code:
N,C,K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()
ans=s=0
while s<N:
    t=T[s]+K
    sm=1
    for i in range(s+1,s+c):
        if T[i]<t:
            sm+=1
        else:
            break
    s+=sm
    ans+=1
print(ans)


Fixed code:
N,C,K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()
ans=s=0
while s<N:
    t=T[s]+K
    sm=1
    for i in range(s+1,min(s+C,N)):
        if T[i]<=t:
            sm+=1
        else:
            break
    s+=sm
    ans+=1
print(ans)
Buggy code:
n,c,k=map(int, input().split())
t=[int(input()) for _ in range(n)]
t.sort()
tmp_lim=t[0]+k
num_bus=0
num_person=1
for i in range(1, n):
    if tmp_lim<t[i] or c<=num_person:
        num_bus+=1
        tmp_lim=t[i]+k
        num_person=1
    else:
        num_person+=1
    print(num_bus, num_person, tmp_lim)
print(num_bus+1)


Fixed code:
n,c,k=map(int, input().split())
t=[int(input()) for _ in range(n)]
t.sort()
tmp_lim=t[0]+k
num_bus=0
num_person=1
for i in range(1, n):
    if tmp_lim<t[i] or c<=num_person:
        num_bus+=1
        tmp_lim=t[i]+k
        num_person=1
    else:
        num_person+=1
    # print(num_bus, num_person, tmp_lim)
print(num_bus+1)
Buggy code:
def resolve():
    '''
    code here
    '''
    N, C, K = [int(item) for item in input().split()]
    Ts = [int(input()) for _ in range(N)]
    Ts.sort()

    res = 0
    temp_psg = 0
    lim = Ts[0] + K

    for i in range(N):
        temp_psg += 1
        if Ts[i] > lim:
            res += 1
            temp_psg = 1
            lim = Ts[i] + K
        else:
            if temp_psg == C:
                res += 1
                temp_psg = 1
                lim = Ts[i] + K
        # print(Ts[i], temp_psg, res, lim)
    print(res)


if __name__ == "__main__":
    resolve()


Fixed code:
def resolve():
    '''
    code here
    '''
    N, C, K = [int(item) for item in input().split()]
    Ts = [int(input()) for _ in range(N)]
    Ts.sort()

    res = 0
    temp_psg = 0
    lim = Ts[0] + K

    for i in range(N):
        temp_psg += 1
        if Ts[i] > lim:
            res += 1
            temp_psg = 1
            lim = Ts[i] + K
        else:
            if temp_psg == C and i < N-1:
                res += 1
                temp_psg = 0
                lim = Ts[i+1] + K
        # print(Ts[i], temp_psg, res, lim)
    
    if temp_psg > 0:
        res += 1
    print(res)


if __name__ == "__main__":
    resolve()
Buggy code:
import sys
import bisect
input = sys.stdin.readline

n, c, k = [int(w) for w in input().split()]
la = [int(input()) for _ in range(n)]
la.sort()
lak = [a + k for a in la]

ind = 0
ans = 0
while ind < n:
    ride = bisect.bisect_right(la, lak[ind]) - ind

    ind += min(ride, k)
    ans += 1

print(ans)


Fixed code:
import sys
import bisect
input = sys.stdin.readline

n, c, k = [int(w) for w in input().split()]
la = [int(input()) for _ in range(n)]
la.sort()
lak = [a + k for a in la]

ind = 0
ans = 0
while ind < n:
    ride = bisect.bisect_right(la, lak[ind]) - ind
    ind += min(ride, c)
    ans += 1

print(ans)
Buggy code:
N,C,K = map(int,input().split())

T = sorted([int(input()) for _ in range(N)])
ans = 1
count = 0
time = 0
start = -1
for i in range(N):
  if start == -1:
    start = i
  if i != N-1:
    if T[i] > T[start] + K or i+1 -start == C:
      ans += 1
      start = -1
  
print(ans)

Fixed code:
N,C,K = map(int,input().split())

T = sorted([int(input()) for _ in range(N)])
ans = 1
count = 0
time = 0
start = -1
for i in range(N):
  if start == -1:
    start = i
  if i != N-1:
    if T[i+1] > T[start] + K or i+1 -start == C:
      ans += 1
      start = -1
  
print(ans)
Buggy code:
import sys
N, C, K = map(int, input().split())
A = list(map(int, sys.stdin.readlines()))+[10**10]
A.sort()
a, c, t = 0, 1, a[0]+k
for i in A[1:]:
    if i <= t and c < C:
        c += 1
    else:
        t, c = i + K, 1
        a += 1
 
print(a)

Fixed code:
import sys
N, C, K = map(int, input().split())
A = list(map(int, sys.stdin.readlines()))+[10**10]
A.sort()
a, c, t = 0, 1, A[0]+K
for i in A[1:]:
    if i <= t and c < C:
        c += 1
    else:
        t, c = i + K, 1
        a += 1
 
print(a)
Buggy code:
N, C, K = map(int, input().split())
T = sorted([int(input()) for _ in range(N)])

in_bus = 0
first = 0
last = 0
bus_count = 0
for i in range(N + 1):
    if (i == 0):
        first = T[i]
        last = T[i] + K
        in_bus += 1
        bus_count += 1
        continue

    if (i == N):
        break

    if (in_bus == C):
        bus_count += 1
        in_bus = 0
        first = T[i]
        last = T[i] + K
        continue

    if (T[i] >= first and last >= T[i]):
        in_bus += 1
    else:
        first = T[i]
        last = T[i] + K
        in_bus = 1
        bus_count += 1


print(bus_count - 1)


Fixed code:
N, C, K = map(int, input().split())
T = sorted([int(input()) for _ in range(N)])

in_bus = 0
first = 0
last = 0
bus_count = 0
for i in range(N):
    if (i == 0):
        first = T[i]
        last = T[i] + K
        in_bus += 1
        bus_count += 1
        continue

    if (in_bus == C):
        bus_count += 1
        in_bus = 1
        first = T[i]
        last = T[i] + K
        continue

    if (T[i] >= first and last >= T[i]):
        in_bus += 1
    else:
        first = T[i]
        last = T[i] + K
        in_bus = 1
        bus_count += 1


print(bus_count)
Buggy code:
N, C, K=map(int, input().split())
X=[]
for _ in range(N):
  X.append(int(input()))
X.sort()
X.append(10**19)
ans=0
tamatta=0
hayaihito=X[0]
for i in range(N):
  if tamatta<C and hayaihito+K>=X[i+1]:
    tamatta+=1
  else:
    tamatta=0
    hayaihito=X[i+1]
    ans+=1
print(ans)

Fixed code:
N, C, K=map(int, input().split())
X=[]
for _ in range(N):
  X.append(int(input()))
X.sort()
X.append(10**19)
ans=0
tamatta=0
hayaihito=X[0]
for i in range(N+1):
  if tamatta<C and hayaihito+K>=X[i]:
    tamatta+=1
  else:
    ans+=1
    tamatta=1
    hayaihito=X[i]
    
print(ans)
Buggy code:
N, C, K = map(int, input().split())
T = sorted([int(input()) for _ in range(N)])

ans = 1
bus = 0
before = T[0]

for i in T:
    if bus+1 > C or i - before > K:
        bus = 1
        ans += 1
    else:
        bus += 1
    before = i
    # print(f"i{i} bus{bus} ans{ans}")
print(ans)

T.reverse()
before = T[0]
bus = 0
ans1 = 1

for i in T:
    if bus+1 > C or before-i < K:
        bus = 1
        ans1 += 1
    else:
        bus += 1
    before = i
    # print(f"i{i} bus{bus} ans{ans}")
print(min(ans, ans1))

Fixed code:
N, C, K = map(int, input().split())
T = sorted([int(input()) for _ in range(N)])

ans = 1
bus = 0
before = T[0]

for i in T:
    if bus+1 > C or i - before > K:
        bus = 1
        ans += 1
        before = i
    else:
        bus += 1
    
    # print(f"i{i} bus{bus} ans{ans}")
print(ans)
Buggy code:
N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]

T.sort()

ans = 0

oko = 0
bus = False
cnt = 0
for i in range(N):
  t = T[i]
  
  if not bus:
    ans += 1
    bus = True
    oko = t + K
    cnt += 1
    continue
    
  if t <= oko:
    if cnt < C:
      cnt += 1
    else:
      bus = True
      oko = t + K
      cnt = 1
      ans += 1
  else:
    cnt = 1
    bus = True
    ans += 1
    
print(ans)
      


Fixed code:
N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]

T.sort()

ans = 0

oko = 0
bus = False
cnt = 0
for i in range(N):
  t = T[i]
  
  if not bus:
    ans += 1
    bus = True
    oko = t + K
    cnt += 1
    continue
    
  if t <= oko:
    if cnt < C:
      cnt += 1
    else:
      bus = True
      oko = t + K
      cnt = 1
      ans += 1
  else:
    cnt = 1
    bus = True
    ans += 1
    oko = t + K
    
print(ans)
Buggy code:
n,c,k=map(int,input().split())
t=[0]*n
for i in range(n):
  t[i]=int(input())
t.sort()
ans=1
temp=t[0]
tempc=1
for i in range(1,n):
  if temp+k>=t[i] or tempc>c:
    ans=ans+1
    temp=t[i]
    tempc=1
  else:
    tempc=tempc+1
print(ans)

Fixed code:
n,c,k=map(int,input().split())
t=[0]*n
for i in range(n):
  t[i]=int(input())
t.sort()
ans=1
temp=t[0]
tempc=1
for i in range(1,n):
  if temp+k<t[i] or tempc>=c:
    ans=ans+1
    temp=t[i]
    tempc=1
  else:
    tempc=tempc+1
print(ans)
Buggy code:
n,c,k = map(int,input().split())
t = []
for i in range(n):
  t.append(int(input()))


sort(t)
ans = 0
now = 0
ter = -1
for i in range(n):
  if ter < t[i]+k:
    ans+=1
    ter = t[i]+k
    now = 1
  else:
    if(c>=now):
      ans+=1
      ter = t[i]+k
      now = 1
    else:
      now += 1
      
print(ans)

Fixed code:
n,c,k = map(int,input().split())
t = []
for i in range(n):
  t.append(int(input()))

t.sort()
ans = 0
now = 0
ter = -1
for i in range(n):
  if ter < t[i]:
    ans += 1
    ter = t[i]+k
    now = 1
  else:
    if(c<=now):
      ans+=1
      ter = t[i]+k
      now = 1
    else:
      now += 1
      
print(ans)
Buggy code:
# AGC011 A Airport Bus
import bisect
from collections import deque

n, c, k = map(int, input().split())
t_list = [int(input()) for _ in range(n)]

t_list.sort()
t_list = deque(t_list)
ans = 0

while len(t_list) > 0:
    _tmp = t_list.popleft() + k
    _idx = bisect.bisect_right(t_list, _tmp)
    if c <= _idx + 1:
        for _ in range(c):
            t_list.popleft()
    else:
        for _ in range(_idx):
            t_list.popleft()
    ans += 1

print(ans)

Fixed code:
# AGC011 A Airport Bus
import bisect
from collections import deque

n, c, k = map(int, input().split())
t_list = [int(input()) for _ in range(n)]

t_list.sort()
t_list = deque(t_list)
ans = 0

while len(t_list) > 0:
    _tmp = t_list.popleft() + k
    _idx = bisect.bisect_right(t_list, _tmp)
    if c-1 <= _idx:
        for _ in range(c-1):
            t_list.popleft()
    else:
        for _ in range(_idx):
            t_list.popleft()
    ans += 1

print(ans)
Buggy code:
n, c, k = map(int, input().split())

t = [0] * n
for i in range(n):
    t[i] = int(input())
t = sorted(t)
ans = 0
i = 0
while i < n:
    j = 0
    while i + j < n and t[i + j] < t[i] + k and j < c:
        j += 1
    i += j
    ans += 1 
print(t, ans)


Fixed code:
n, c, k = map(int, input().split())

t = [0] * n
for i in range(n):
    t[i] = int(input())
t = sorted(t)
ans = 0
i = 0
while i < n:
    j = 1
    while i + j < n and t[i + j] <= t[i] + k and j < c:
        j += 1
    i += j
    ans += 1 
print(ans)
Buggy code:
from collections import deque

n, c, k = map(int, input().split())
t = [int(input()) for _ in range(n)]

t.sort()

q = deque(t)
cnt = 1
ans = 1
curr = q.popleft()

while q:
    tmp = q.popleft()
    if cnt == 0:
        ans += 1
    if tmp - curr < k or cnt < c:
        cnt += 1
    else:
        ans += 1
        cnt = 0
        curr = q[0]

Fixed code:
from collections import deque

n, c, k = map(int, input().split())
t = [int(input()) for _ in range(n)]

t.sort()

q = deque(t)
cnt = 1
ans = 1
curr = q.popleft()

while q:
    tmp = q.popleft()
    if tmp - curr <= k and cnt < c:
        cnt += 1
    else:
        ans += 1
        cnt = 1
        curr = tmp

print(ans)
Buggy code:
n,c,k = map(int,input().split())
list = [int(input()) for _ in range(n)]
sorted_list = sorted(list)
bus = 1
customer = 1
max_hour = sorted_list[0]+k
for i in sorted_list[1:]:
  if i > max_hour or customer >= 3:
    bus+=1
    customer=1
    max_hour = i+k
print(bus+1 if customer != 1 else bus)

Fixed code:
n,c,k = map(int,input().split())
list = [int(input()) for _ in range(n)]
sorted_list = sorted(list)
bus = 1
customer = 1
max_hour = sorted_list[0]+k
for i in sorted_list[1:]:
  if i > max_hour or customer >= c:
    bus+=1
    customer=1
    max_hour = i+k
  else:
    customer += 1
print(bus)