ZhenlongDai/ACPR huggingface dataset:
Problem: p03785
Buggy submission (Python (3.4.3), verdict: Wrong Answer):




N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
T.sort()
T.append(T[-1])

fst = T[0]
cnt = 1
ans = 0
flg = 0

for i in range(1,N):
    cnt += 1
    flg = 0
    if T[i]-fst > K:
        fst = T[i]
        cnt = 1
        ans += 1
    
    elif cnt == C:
        fst = T[i+1]
        cnt = 0
        ans += 1
        flg = 1


    

if not(flg):
    ans += 1

print(ans)
        
        




Failing test case input:
6 1 3
7
6
2
13
17
5

Expected output:
6


Actual output:
4


Fixed submission (verdict: Accepted):




N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
T.sort()
T.append(T[-1])

fst = T[0]
cnt = 0
ans = 0
flg = 0

for i in range(N):
    cnt += 1
    flg = 0
    if T[i]-fst > K:
        fst = T[i]
        cnt = 1
        ans += 1
    
    elif cnt == C:
        fst = T[i+1]
        cnt = 0
        ans += 1
        flg = 1


    

if not(flg):
    ans += 1

print(ans)

Problem: p03785
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n, c, k = map(int, input().split())
t = []
for i in range(n):
    t.append(int(input()))
t.sort()
ans = 0
counter = 0
lim = t[0]
for i in range(n):
    if counter < c and (t[i] - lim) < k:
        counter += 1
    else:
        counter = 1
        lim = t[i]
        ans += 1
print(ans + 1)

Failing test case input:
6 4 3
11
9
2
9
17
5

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
n, c, k = map(int, input().split())
t = []
for i in range(n):
    t.append(int(input()))
t.sort()
ans = 0
counter = 0
lim = t[0]
for i in range(n):
    if counter < c and (t[i] - lim) <= k:
        counter += 1
    else:
        counter = 1
        lim = t[i]
        ans += 1
print(ans + 1)

Problem: p03785
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
import math
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, c, k = map(int, input().split())
    T = sorted(list(int(input()) for _ in range(n)), reverse=True)

    res = 0
    cnt = 0
    dep = T[0]
    for i in range(n):
        if T[i] + k >= dep:
            cnt += 1
        else:
            res += math.ceil(cnt / c)
            cnt = 1
            dep = T[i]

    print(res + math.ceil(cnt / c))


if __name__ == '__main__':
    resolve()


Failing test case input:
6 3 6
7
6
2
22
10
6

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, c, k = map(int, input().split())
    T = sorted(list(int(input()) for _ in range(n)))
    res = 0
    cnt = 0
    dep = T[0] + k
    for i in range(n):
        if cnt == c or T[i] > dep:
            res += 1
            cnt = 1
            dep = T[i] + k
        else:
            cnt += 1

    print(res + 1)


if __name__ == '__main__':
    resolve()
Problem: p03785
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,c,k=map(int,input().split())
a=sorted([int(input()) for _ in range(n)],reverse=True)
cnt=0
while len(a) > 0:
    b=a.pop()
    cnt+=1
    if len(a)==0:
        break
    for i in range(c-1):
        if a[-1]<b+k:
            a.pop()
            if len(a)==0:
                break
        
print(cnt)
    

Failing test case input:
5 5 5
1
1
2
6
18

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n,c,k=map(int,input().split())
a=sorted([int(input()) for _ in range(n)],reverse=True)
cnt=0
cnt2=1
while len(a) > 0:
    b=a.pop()
    cnt+=1
    if len(a)==0:
        break
    cnt2=1
    while cnt2<c:
        if a[-1]<=b+k:
            a.pop()
            cnt2+=1
            if len(a)==0:
                cnt2=1
                break
        else:
            cnt2=1
            break
print(cnt)

Problem: p03785
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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)

Failing test case input:
6 3 6
7
6
2
18
10
6

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
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)

Problem: p03785
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
    n, c, k = map(int, input().split())
    t = [int(input()) for _ in range(n)]
    t.sort()
    ans = 0
    passengers = 0
    first = 0
    for i in range(n):
        if i and t[i] > first + k:
            ans += 1
            passengers = 0
        if passengers == 0:
            first = t[i]
        passengers += 1
        if passengers == c:
            ans += 1
            passengers = 0
    if passengers:
        ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Failing test case input:
6 2 3
7
0
2
8
7
6

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
def main():
    n, c, k = map(int, input().split())
    t = [int(input()) for _ in range(n)]
    t.sort()
    ans = 0
    passengers = 0
    first = t[0]
    for tn in t:
        if tn > first + k or passengers == c:
            ans += 1
            passengers = 0
            first = tn
        passengers += 1

    print(ans + 1)


if __name__ == '__main__':
    main()
Problem: p03785
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, C, K = map(int, input().split())
T = [0]*N
cnt = 1
bus = 1
for i in range(N):
    T[i] = int(input())
T.sort()
tmp = T[0]+K
for i in range(1, N):
    if(cnt == 0):
        tmp = T[i]+K
        bus += 1
        cnt += 1
        
    if(T[i] <= tmp):
        cnt += 1
        if(cnt == C):
            cnt = 0
    else:
        cnt = 1
        tmp = T[i]+K
        bus += 1     
print(bus)

Failing test case input:
6 3 3
7
0
2
8
2
6

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
N, C, K = map(int, input().split())
T = [0]*N
cnt = 1
bus = 1
for i in range(N):
    T[i] = int(input())
T.sort()
tmp = T[0]+K
for i in range(1, N):
    if(cnt == 0):
        bus += 1
        cnt = 1
        tmp = T[i]+K
        continue
        
    if(T[i] <= tmp and cnt < C):
        cnt += 1
        if(cnt == C):
            cnt = 0
    else:
        cnt = 1
        bus += 1
        tmp = T[i]+K
print(bus)

Problem: p03785
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,c,k=map(int,input().split())
t=[0 for i in range(n)]
for i in range(n):
    t[i]=int(input())
t.sort()
ans=0
cnt=1
bef=t[0]
for i in range(1,n):
    if cnt==c:
        ans+=1
        cnt=1
        bef=t[i]
    elif bef+k>=t[i] and cnt<k:
        cnt+=1
    else:
        ans+=1
        cnt=1
        bef=t[i]
    if i==n-1:
        ans+=1
print(ans)


Failing test case input:
5 5 1
0
1
2
7
18

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
n,c,k=map(int,input().split())
t=[0 for i in range(n)]
for i in range(n):
    t[i]=int(input())
t.sort()
ans=0
cnt=1
bef=t[0]
for i in range(1,n):
    if cnt==c:
        ans+=1
        cnt=1
        bef=t[i]
    elif bef+k>=t[i] and cnt<c:
        cnt+=1
    else:
        ans+=1
        cnt=1
        bef=t[i]
    if i==n-1:
        ans+=1
print(ans)

Problem: p03785
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,c,k = (int(i) for i in input().split())
t = [int(input()) for i in range(n)]
t.sort()
num,num2,answer = t[0]+k,0,1
for i in range(n):
	num2 += 1
	if t[i]>num or num2>c:
		num,num2=t[i]+k,0
		answer+=1
print(answer)

Failing test case input:
6 1 3
7
6
2
13
17
5

Expected output:
6


Actual output:
5


Fixed submission (verdict: Accepted):
n,c,k = (int(i) for i in input().split())
t = [int(input()) for i in range(n)]
t.sort()
num,num2,answer = t[0]+k,0,1
for i in range(n):
	num2 += 1
	if t[i]>num or num2>c:
		num,num2=t[i]+k,1
		answer+=1
print(answer)
Problem: p03785
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

N,C,K= list(map(int,input().split(" ")))

ans = 1
c = 0
before = 0
passed = 0
nums = [ int(input()) for _ in range(N)]
nums.sort()
for t in nums:
    passed += t -before
    c += 1
    if passed > K or c > C: 
        c = 0
        passed = 0
        ans += 1

    before = t
print(ans)




Failing test case input:
6 6 6
7
9
4
23
19
5

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):

N,C,K= list(map(int,input().split(" ")))

ans = 1
passed = 0
nums = [ int(input()) for _ in range(N)]
nums.sort()
before = nums[0]
c = 1

for t in nums[1:]:

    c += 1
    passed += t - before
    if passed > K or c > C: 
        c = 1
        passed = 0
        ans += 1
    before = t
print(ans)

Problem: p03785
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


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

ans = 1 
count = 0 
ts = T[0] 
T.sort()
for t in T:
    if t-ts > K:
        ans += 1 
        ts = t 
        count = 0 
    else:
        count += 1 
    if count == C: 
        ans += 1 
        ts = t 
        count = 0 
print(ans)

Failing test case input:
6 3 3
7
0
2
8
2
6

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):


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

ans = 1 
count = 0 
T.sort()
ts = T[0] 


for t in T:
    if t-ts > K or count == C: 
        ans += 1 
        ts = t 
        count = 1 
    else:
        count += 1 
print(ans)

Problem: p03785
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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+1)
            exit()
    elif t1 - s > k:
        ans += 1
        cnt = 0
        s = t[tmp-1]

print(ans+1)


Failing test case input:
6 2 3
7
0
1
8
7
6

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
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)
Problem: p03785
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,c,k = map(int,input().split())
t_input = [int(input()) for i in range(n)]

t_s = sorted(t_input)

ans=0
while t_s:
    x = t_s.pop(0)
    time_limit = x+c
    bus_limit = k
    while t_s and t_s[0]<=time_limit and bus_limit!=0:
        t = t_s.pop(0)
        bus_limit-=1
    ans+=1
print(ans)

Failing test case input:
5 3 10
1
7
3
6
12

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n,c,k = map(int,input().split())
t_input = [int(input()) for i in range(n)]

t_s = sorted(t_input)

ans = 1
c_limit = 1
t_limit = t_s[0]+k
for i in range(1,n):
    t = t_s[i]
    
    if t>t_limit or c_limit>=c:
        ans+=1
        c_limit=1
        t_limit = t+k
    else:
        c_limit+=1
print(ans)

Problem: p03785
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n,C,T=map(int,input().split())
t=[int(input()) for i in range(n)]
t.sort()
res=t[0]+T
cnt=1
ans=0
for i in range(n):
  if t[i]<=res and cnt<C:
    cnt+=1
  elif t[i]>res or cnt==C:
    ans+=1
    res=t[i]+T
    cnt=1
print(ans+1)

Failing test case input:
6 3 6
4
0
2
22
10
0

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
n,C,T=map(int,input().split())
t=[int(input()) for i in range(n)]
t.sort()
res=t[0]+T
cnt=1
ans=0
for i in range(1,n):
  if t[i]<=res and cnt<C:
    cnt+=1
  elif t[i]>res or cnt==C:
    ans+=1
    res=t[i]+T
    cnt=1
print(ans+1)

Problem: p03785
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,c,k=map(int,input().split())
s=[]
for i in range(n):
    s.append(int(input()))
s.sort()
ans=1
count=0
a=s[0]
for i in range(1,n):
    if s[i]-a>k:
        a=s[i]
        count=1
        ans+=1
    else:
        count+=1
    if count==c:
        count=0
        ans+=1
        a=s[i]
print(ans)

Failing test case input:
6 3 3
7
6
2
13
10
6

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
n,c,k=map(int,input().split())
s=[]
for i in range(n):
    s.append(int(input()))
s.sort()
ans=1
count=0
a=s[0]
for i in range(n):
    if s[i]-a>k:
        a=s[i]
        count=1
        ans+=1
    else:
        count+=1
    if count==c:
        if i!=n-1:
            count=0
            ans+=1
            a=s[i+1]
    
print(ans)

Problem: p03785
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
5 3 5
1
7
3
6
1

Expected output:
2


Actual output:
5


Fixed submission (verdict: Accepted):
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)
Problem: p03785
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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

for i in range(N):
  tamatta+=1
  if tamatta<C and X[i]+K>=X[i+1]:
    continue 
  tamatta=0
  ans+=1
print(ans)

Failing test case input:
5 5 1
0
1
2
7
18

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
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)

Problem: p03785
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, c, k = map(int, input().split())
t_list = [int(input()) for i in range(n)]

t_sorted = sorted(t_list)

ans = 1
bus = 0
timer = 0
for i in range(1, len(t_sorted)):
    if t_sorted[i] - t_sorted[i - 1] > k:
        ans += 1
    elif t_sorted[i] - t_sorted[i - 1] <= k:
        bus += 1
        timer += t_sorted[i] - t_sorted[i - 1]
        if bus >= c or timer >= k:
            ans += 1
            bus = 0
            timer = 0

print(ans)

Failing test case input:
6 4 3
11
6
2
13
17
5

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
n, c, k = map(int, input().split())
t_list = [int(input()) for i in range(n)]

t_sorted = sorted(t_list)

ans = 1
bus = 1
timer = 0
for i in range(1, len(t_sorted)):
    bus += 1
    timer += t_sorted[i] - t_sorted[i - 1]
    if bus > c or timer > k:
        ans += 1
        bus = 1
        timer = 0

print(ans)

Problem: p03785
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,c,k = map(int,input().split())
t = []
cnt,ans = 0,0
bt = 10**10
btl = []
for i in range(n):
    t.append(int(input()))

t.sort()

for i in range(n):
    if (t[i] >= bt)&(cnt == c):
        ans += 1
        cnt,bt = 0,10**10
    if (bt == 10**10):
        bt = t[i]+k
        cnt += 1
    else:
        cnt += 1
        
if (cnt != 0):
    ans += 1

print(ans)

Failing test case input:
5 14 5
1
4
1
2
12

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n,c,k = map(int,input().split())
t = []
cnt,ans = 0,0
bt = 10**10
btl = []
for i in range(n):
    t.append(int(input()))

t.sort()

for i in range(n):
    if (t[i] > bt)|(cnt == c):
        ans += 1
        cnt,bt = 0,10**10
    if (bt == 10**10):
        bt = t[i]+k
        cnt += 1
    else:
        cnt += 1
        
if (cnt != 0):
    ans += 1

print(ans)
Problem: p03785
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,C,K = [int(s) for s in input().split()]
T = []
for i in range(N):
    T.append(int(input()))
T.sort()
 
pas = 0
leave = T[0]
ans = 1
 
for t in T:
    if pas == C or K < t - leave:
        leave = t
        ans += 1
        pas = 0
    else:
        pas += 1
print(ans)

Failing test case input:
6 1 3
7
6
2
13
17
5

Expected output:
6


Actual output:
5


Fixed submission (verdict: Accepted):
N,C,K = [int(s) for s in input().split()]
T = []
for i in range(N):
    T.append(int(input()))
T.sort()
 
pas = 0
leave = T[0]
ans = 1
 
for t in T:
    if pas == C or K < t - leave:
        leave = t
        ans += 1
        pas = 0
    pas += 1
print(ans)

Problem: p03785
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n, c, k = map(int, input().split())
t = []
for i in range(n):
    t.append(int(input()))
t.sort()
ans = 0
counter = 0
lim = t[0]
for i in range(n):
    if counter < c and (t[i] - lim) < k:
        counter += 1
    else:
        bus = []
        counter = 0
        lim = t[i]
        ans += 1
print(ans + 1)

Failing test case input:
5 10 5
1
4
3
7
12

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n, c, k = map(int, input().split())
t = []
for i in range(n):
    t.append(int(input()))
t.sort()
ans = 0
counter = 0
lim = t[0]
for i in range(n):
    if counter < c and (t[i] - lim) <= k:
        counter += 1
    else:
        counter = 1
        lim = t[i]
        ans += 1
print(ans + 1)

Problem: p03785
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, c, k = map(int, readline().split())
t = [int(readline()) for i in range(n)]
t.sort()
cnt = 0
time = float('inf')
ans = 1
for tt in t:
    if cnt < (c - 1) and time > tt:
        if cnt == 0:
            time = tt + k
        cnt += 1
    else:
        cnt = 0
        time = float('inf')
        ans += 1
print(ans)


Failing test case input:
6 6 0
7
3
8
9
19
5

Expected output:
6


Actual output:
4


Fixed submission (verdict: Accepted):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, c, k = map(int, readline().split())
t = sorted([int(readline()) for i in range(n)])
cnt = 0
ans = 1
time = t[0] + k
for i in range(n):
    if cnt >= c or time < t[i]:
        ans += 1
        cnt = 0
        time = t[i] + k
    cnt += 1
print(ans)
Problem: p03785
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n, c, k = map(int, input().split())
cnt = 0
ans = 0
t_l = []
for _ in range(n):
    t_l.append(int(input()))
t_l.sort()

for t in t_l:
    if cnt == 0:
        t1 = t
    if t <= t1 + k:
        cnt += 1
        if cnt == 3:
            cnt = 0
            ans += 1
    else:
        cnt = 1
        ans += 1
        t1 = t
if cnt != 0:
    ans += 1
print(ans)

Failing test case input:
5 5 5
1
1
3
6
36

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n, c, k = map(int, input().split())
t_l = []
for _ in range(n):
    t_l.append(int(input()))
t_l.sort()
ans = 0
cnt = 0
for t in t_l:
    if cnt == 0:
        t1 = t
    if t <= t1 + k:
        cnt += 1
        if cnt == c:
            cnt = 0
            ans += 1
    else:
        cnt = 1
        ans += 1
        t1 = t
if cnt != 0:
    ans += 1
print(ans)

Problem: p03785
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,C,K=map(int,input().split())
T=[int(input()) for i in range(N)]
T.sort()


n=0
l=0
ans=0
for i in range(N):
  if n==0:
    n=C
    l=T[i]+K
    ans+=1
  else:
    if T[i]<l:
      n-=1
    else:
      n=C
      l=T[i]+K
      ans+=1
  
print(ans)

Failing test case input:
5 10 5
1
4
3
6
12

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
N,C,K=map(int,input().split())
TT=[int(input()) for _ in range(N)]
TT.sort()

B=0
L=0
ans=0
for T in TT:
  if B==0:
    L=T+K
    B=C-1
    ans+=1
  else:
    if L>=T:
      B-=1
    else:
      L=T+K
      B=C-1
      ans+=1
  
print(ans)

Problem: p03785
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,c,k=map(int,input().split())
t=[int(input()) for i in range(n)]
t.sort()

ans=0
x=t[0]
y=0
for i in range(n):
    y+=1
    if y==c:
        ans+=1
        x=t[i]
    elif t[i]-x>k:
        ans+=1
        y=0
        x=t[i]
print(ans+1)

Failing test case input:
6 3 6
4
0
2
22
10
0

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
n,c,k=map(int,input().split())
t=[int(input()) for i in range(n)]
t.sort()
ans=0
x=t[0]
y=0
for i in range(n-1):
    y+=1
    if t[i]-x>k:
        ans+=1
        x=t[i]
        y=1
    elif y==c:
        ans+=1
        x=t[i+1]
        y=0
print(ans+2 if t[-1]-x>k else ans+1)
Problem: p03785
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def solve(N, C, K, Ts):
    Ts.sort()
    count = 0
    ans = 0
    time = 0
    for t in Ts[::-1]:
        if count >= C or t <= time - K:
            ans += 1
            count = 0
            time = 0
        count += 1
        if time == 0:
            time = t
    if count > 0:
        ans += 1
    return ans



if __name__ == "__main__":
    N, C, K = tuple(map(int, input().split(" ")))
    Ts = [int(input()) for _ in range(N)]
    print(solve(N, C, K, Ts))


Failing test case input:
5 5 5
1
1
1
6
18

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
def solve(N, C, K, Ts):
    Ts.sort()
    count = 0
    ans = 0
    time = 0
    for t in Ts[::-1]:
        if count >= C or t < time - K:
            ans += 1
            count = 0
            time = 0
        count += 1
        if time == 0:
            time = t
    if count > 0:
        ans += 1
    return ans


if __name__ == "__main__":
    N, C, K = tuple(map(int, input().split(" ")))
    Ts = [int(input()) for _ in range(N)]
    print(solve(N, C, K, Ts))

Problem: p03785
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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 cnt == c:
        if tmp < n - 1:
            s = t[tmp + 1]
            ans += 1
            cnt = 0
        else:
            print(ans)
            exit()
    elif t1 - s > k:
        ans += 1
        cnt = 1
        s = t[tmp]
    tmp += 1

if cnt > 0:
    ans += 1

print(ans)


Failing test case input:
5 5 5
1
4
3
6
12

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
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)

Problem: p03785
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,c,k = map(int, input().split())
t = [int(input()) for i in range(n)]
t.sort()
now = t[0]
people = 1
ans = 1
for i in t[1:]:
  if i - now > k or people >= c:
    now = i
    people = 1
    ans += 1
  else:
    now = i
    people += 1
print(ans)

Failing test case input:
6 4 3
7
6
2
13
17
5

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
n,c,k = map(int, input().split())
t = [int(input()) for i in range(n)]
t.sort()
now = t[0]
people = 1
ans = 1
for i in t[1:]:
  if i - now > k or people >= c:
    now = i
    people = 1
    ans += 1
  else:
    people += 1
print(ans)
Problem: p03785
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,C,K=map(int, input().split())
l = []
ans = 0
for i in range(N):
    l.append(int(input()))
l.sort()
l = l[::-1]
l.append(float("INF"))
while len(l)>0:
  h=l.pop()
  i=h
  j=1
  while len(l)>0 and j<C and h+K>l[-1]:
    i=l.pop()
    j+=1
  ans+=1
print(ans)

Failing test case input:
5 5 5
0
2
2
7
18

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):

N,C,K=map(int, input().split())
l = []
ans = 0
for i in range(N):
    l.append(int(input()))
l.sort()
l.append(float("INF"))
l = l[::-1]
while len(l)>1:
  h=l.pop()
  i=h
  j=1
  while len(l)>1 and j<C and h+K>=l[-1]:
    i=l.pop()
    j+=1
  ans+=1
print(ans)

Problem: p03785
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,C,K=map(int,input().split())
A=[]
for i in range(N):
    a=int(input())
    A.append(a)
A.sort()
k=K
a=0
c=C
j=1
while j<N:
    k-=A[j]-A[j-1]
    c-=1
    if k>=0 and c>=0:    
        j+=1
    else:     
        a+=1
        c=C
        k=K
        j+=1
print(a+1)   

Failing test case input:
5 3 5
1
2
3
6
12

Expected output:
3

Actual output:
2


Fixed submission (verdict: Accepted):
N,C,K=map(int,input().split())
A=[]
for i in range(N):
    a=int(input())
    A.append(a)
A.sort()
k=K
a=0
c=C-1
j=1
while j<N:
    k-=A[j]-A[j-1]
    c-=1
    if k>=0 and c>=0:    
        j+=1
    else:     
        a+=1
        c=C-1
        k=K
        j+=1
print(a+1)

Problem: p03785
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
    n, c, k = map(int, input().split())
    t = [int(input()) for _ in range(n)]
    t.sort()
    ans = 0
    bus = 0
    for i in range(n):
        if i and t[i] > t[i - 1] + k:
            ans += 1
            bus = 0
        bus += 1
        if bus == c:
            ans += 1
            bus = 0
    if bus:
        ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Failing test case input:
6 6 4
7
6
2
22
10
5

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
def main():
    n, c, k = map(int, input().split())
    t = [int(input()) for _ in range(n)]
    t.sort()
    ans = 0
    passengers = 0
    first = t[0]
    for tn in t:
        if tn > first + k or passengers == c:
            ans += 1
            passengers = 0
            first = tn
        passengers += 1

    print(ans + 1)


if __name__ == '__main__':
    main()
Problem: p03785
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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

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

        


    
if ln>0:
    s+=1

print(s)


Failing test case input:
5 2 3
7
6
2
13
17
5

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
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

        


    
if ln>0:
    s+=1

print(s)

Problem: p03785
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, C, K = map(int, input().split())
bus_count = 0
waiting_count = 0
time_limit = 0
D = [int(input()) for _ in range(N)]
for i in range(N):
    T = D[i]
    waiting_count += 1
    if waiting_count == 1:
        time_limit = T + K
    else:
        if T > time_limit:
            time_limit = T + K
            bus_count += 1
            waiting_count = 1
        if waiting_count == C:
            bus_count += 1
            waiting_count = 0
            time_limit = 0

print(bus_count+1)


Failing test case input:
6 3 3
7
6
2
14
10
6

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
N, C, K = map(int, input().split())
bus_count = 0
waiting_count = 0
time_limit = 0
D = [int(input()) for _ in range(N)]
D.sort()

for i in range(N):
    T = D[i]
    waiting_count += 1
    if T > time_limit and not time_limit == 0:
        time_limit = T + K
        bus_count += 1
        waiting_count = 1
    if waiting_count == C:
        bus_count += 1
        waiting_count = 0
        time_limit = 0
    else:
        if waiting_count == 1:
            time_limit = T + K

if not waiting_count == 0:
    print(bus_count+1)
else:
    print(bus_count)
Problem: p03785
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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,c,k = na()
t = []

for i in range(n):
    u = ni()
    t.append(u)

t.sort()

now = t[0]
p = 1
ans = 1

for i in t:
    if i-now > k or p > c:
        p = 1
        now = i
        ans += 1
    else:
        p += 1

print(ans)

Failing test case input:
6 2 6
7
9
2
22
10
5

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
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,c,k = na()
t = []

for i in range(n):
    u = ni()
    t.append(u)

t.sort()

now = t[0]
p = 1
ans = 1

for i in t:
    if i-now > k or p > c:
        p = 2
        now = i
        ans += 1
    else:
        p += 1

print(ans)

Problem: p03785
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, c, k = list(map(int, input().split()))
t = sorted([int(input()) for i in range(n)], reverse=True)
result = 1
total = 1
tmp = t[0]
for i in range(1, n):
  if total + 1 >= c or tmp-t[i] >= k:
    tmp = t[i]
    result += 1
    total = 1
  else:
    total += 1
print(result)

Failing test case input:
5 5 5
1
1
1
6
18

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n, c, k = list(map(int, input().split()))
t = sorted([int(input()) for i in range(n)], reverse=True)
result = 1
bus = 1
time = t[0]
for i in range(1, n):
  if bus + 1 > c or time-t[i] > k:
    time = t[i]
    result += 1
    bus = 1
  else:
    bus += 1
print(result)

Problem: p03785
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

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

ans = 0
idx = 0
s = T[0]
cnt = 0
for i in range(N):

    if cnt >= C:
        ans += 1
        cnt = 0
        s = T[i]
    else:
        if T[i] - s <= K:
            cnt += 1
        else:
            ans += 1
            cnt = 1
            s = T[i]
if cnt != 0:
    ans += 1
print(ans)

Failing test case input:
4 3 10
1
7
3
6
12

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):

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

ans = 0
idx = 0
s = T[0]
cnt = 1
for i in range(1,N):
    if cnt >= C:
        ans += 1
        cnt = 1
        s = T[i]
    else:
        if T[i] - s <= K:
            cnt += 1
        else:
            ans += 1
            cnt = 1
            s = T[i]
if cnt != 0:
    ans += 1
print(ans)
Problem: p03785
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,C,K = map(int,input().split())
li = []
for t in range(N):
  li.append(int(input()))

count = 0
ans = 0

newLi = sorted(li)

while(len(newLi)):
  for c in range(C - 1):
    if len(newLi) < c + 2:
      continue
    
    if newLi[1] <= newLi[0] + K:
      newLi.pop(1)
    else:
      break

  newLi.pop(0)
  ans += 1

print(ans)

Failing test case input:
5 5 5
1
1
3
6
36

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
N,C,K = map(int,input().split())
li = []
for t in range(N):
  li.append(int(input()))

count = 0
ans = 0

newLi = sorted(li)

while(len(newLi)):
  for c in range(C - 1):
    if len(newLi) < 2:
      break
    
    if newLi[1] <= newLi[0] + K:
      newLi.pop(1)
    else:
      break

  newLi.pop(0)
  ans += 1

print(ans)

Problem: p03785
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
nums ,limit ,wait = map(int, input().split())
nums_ary = [0 for i in range(nums)]
nums_ary.append(1000000)
time = 0
count = 0
check = 0
a = -1

for i in range(nums):
    nums_ary[i] = int(input())

nums_ary.sort()

while a < nums :
    a += 1
    time = nums_ary[a]
    b = 0
    while a <= nums and b < limit-1:
        if not time <= nums_ary[a] < time+wait:
            count += 1
            break
        a += 1
        b += 1
    else:
        count += 1
print(count)

Failing test case input:
5 7 5
0
1
3
11
36

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
nums ,limit ,wait = map(int, input().split())
nums_ary = [0 for i in range(nums)]

for i in range(nums):
    nums_ary[i] = int(input())

nums_ary.sort()
nums_ary.append(10000000000000)
count = 0
i = 0
while i < nums:
    time = nums_ary[i]
    for x in range(limit):
        if not time <= nums_ary[i] <= time + wait:
            count += 1
            break
        i += 1
    else:
        count += 1
print(count)

Problem: p03785
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n, c, k = map(int, input().split())
t = []
for _ in range(n):
    t.append(int(input()))
ans = 0
time_cnt = 0
mem_cnt = 1
t.sort()
for i in range(n - 1):
    time_cnt += t[i + 1] - t[i]
    mem_cnt += 1
    
    if time_cnt > k or mem_cnt > c:
        time_cnt = 0
        mem_cnt = 0
        ans += 1
if mem_cnt == 0:
    ans += 1
elif mem_cnt > 0:
    ans += 1
print(ans)



Failing test case input:
6 1 3
7
6
2
13
17
5

Expected output:
6


Actual output:
5


Fixed submission (verdict: Accepted):
n, c, k = map(int, input().split())
t = []
for _ in range(n):
    t.append(int(input()))
ans = 0
time_cnt = 0
mem_cnt = 1
t.sort()
for i in range(n - 1):
    time_cnt += t[i + 1] - t[i]
    mem_cnt += 1
    
    if time_cnt > k or mem_cnt > c:
        time_cnt = 0
        mem_cnt = 1
        ans += 1
if mem_cnt == 0:
    ans += 1
elif mem_cnt > 0:
    ans += 1
print(ans)
Problem: p03785
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
T.sort()
time = 0
people = 1
ans = 1
for t in T:
    if t <= time + K and people < C:
        people += 1
    else:
        time = t
        people = 1
        ans += 1
print(ans)

Failing test case input:
6 6 6
7
9
8
9
19
5

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
T.sort()
time = T.pop(0)
people = 1
ans = 1
for t in T:
    if t <= time + K and people < C:
        people += 1
    else:
        time = t
        people = 1
        ans += 1
print(ans)

Problem: p03785
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    N,C,K = map(int, input().split())
    times = [int(input()) for n in range(N)]
    times.sort()

    first = 0
    index = 1
    count = 1

    while index <= N-1:
        if times[index] - times[first] <= C:
            index += 1
        else:
            count += 1
            first = index
            index += 1

    print(count)

if __name__ == "__main__":
    main()


Failing test case input:
6 3 6
7
6
2
37
10
6

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
def main():
    N,C,K = map(int, input().split())
    times = [int(input()) for n in range(N)]
    times.sort()

    first = 0
    index = 1
    count = 1
    rider_num = 1

    while index <= N-1:
        if times[index] - times[first] <= K and rider_num < C:
            index += 1
            rider_num += 1
        else:
            count += 1
            first = index
            index += 1
            rider_num = 1

    print(count)

if __name__ == "__main__":
    main()

Problem: p03785
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input==sys.stdin.readline
inf=float("inf")
n,c,k=map(int,input().split())
T=[int(input()) for _ in range(n)]
T.sort()
t=T[0]+k
m=1
ans=0
for i in range(1,n):
    if T[i]==t and m+1<=c:
        ans+=1
        t=inf
        m=0
    elif m+1==c:
        ans+=1
        t=inf
        m=0
    elif T[i]>t:
        ans+=1
        t=T[i]+k
        m=1
    else:
        t=T[i]+k
        m+=1
if m:
    ans+=1
print(ans)


Failing test case input:
5 5 5
1
1
0
6
18

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import sys
input==sys.stdin.readline
n,c,k=map(int,input().split())
t=[int(input()) for _ in range(n)]
t.sort()
inf=float("inf")
ans=0
tl=inf
m=0
for i in range(n):
    if tl<t[i]:
        ans+=1
        m=1
        tl=t[i]+k
    elif m==c:
        ans+=1
        m=1
        tl=t[i]+k
    else:
        m+=1
        if m==1:
            tl=t[i]+k
if m:
    ans+=1
print(ans)
Problem: p03785
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):


def Schedule(schedule):
    
    schedule = sorted(schedule, key=lambda x: x[1])
    N = len(schedule)
    res = 0
    end = -float("inf")

    for i in range(N):
        if end <= schedule[i][0]:  
            end = schedule[i][1]  
            res += 1
    return res



import sys
input = sys.stdin.readline

N, C, K = map(int, input().split())
schedule = []
for i in range(N):
    start = int(input())
    schedule.append((start, start + K))               

print(Schedule(schedule))

Failing test case input:
5 10 5
1
4
3
6
12

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):


def Schedule(schedule):
    
    schedule = sorted(schedule, key=lambda x: x[1])
    N = len(schedule)
    res = 0
    end = -float("inf")
    tmp = 0
    for i in range(N):
        if end < schedule[i][0] or tmp == C-1:  
            end = schedule[i][1]  
            res += 1
            tmp = 0
        else:
            tmp += 1
    return res



import sys
input = sys.stdin.readline

N, C, K = map(int, input().split())
schedule = []
for i in range(N):
    start = int(input())
    schedule.append((start, start + K))               

print(Schedule(schedule))

Problem: p03785
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def solve(N, C, K, Ts):
    count = 0
    ans = 0
    time = 0
    for t in sorted(Ts):
        if count >= C or t >= time + K:
            ans += 1
            count = 0
            time = 0
        count += 1
        if time == 0:
            time = t
    if count > 0:
        ans += 1
    return ans
 
if __name__ == "__main__":
    N, C, K = tuple(map(int, input().split(" ")))
    Ts = [int(input()) for _ in range(N)]
    print(solve(N, C, K, Ts))

Failing test case input:
5 5 5
1
1
3
6
12

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
def solve(N, C, K, Ts):
    Ts.sort()
    count = 0
    ans = 0
    time = 0
    for t in Ts[::-1]:
        if count >= C or t < time - K:
            ans += 1
            count = 0
            time = 0
        count += 1
        if time == 0:
            time = t
    if count > 0:
        ans += 1
    return ans


if __name__ == "__main__":
    N, C, K = tuple(map(int, input().split(" ")))
    Ts = [int(input()) for _ in range(N)]
    print(solve(N, C, K, Ts))
Problem: p00353
Buggy submission (Python3, verdict: Wrong Answer):
m,f,b=map(int,input().split())
ans=0
if m>b:
    ans=0
elif m<b:
    ans=b-m
elif m+f<b:
    ans="NA"
print(ans)


Failing test case input:
430 39 3037

Expected output:
NA


Actual output:
2607


Fixed submission (verdict: Accepted):
m,f,b=map(int,input().split())
ans=0
if m+f<b:
    ans= "NA"
elif m>b:
    ans=0
elif m<b:
    ans=b-m

print(ans)

Problem: p00353
Buggy submission (Python3, verdict: Wrong Answer):
m,f,b=map(int,input().split())
ans=0
if m>b:
    ans=0
elif m<b:
    ans=b-m
elif ans>f:
    ans="NA"
print(ans)


Failing test case input:
1649 39 2286

Expected output:
NA


Actual output:
637


Fixed submission (verdict: Accepted):
m,f,b=map(int,input().split())
ans=0
if m+f<b:
    ans= "NA"
elif m>b:
    ans=0
elif m<b:
    ans=b-m

print(ans)
Problem: p03208
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K = map(int,input().split())
h = []
for _ in range(N):
    h.append(int(input()))
h = sorted(h)
tmp = 0
ans = 1000000000
loop = min(K+1,N-K)
for i in range(loop):
    tmp = h[K+i-1] - h[0+i]
    if(tmp < ans):
        ans = tmp
print(ans)

Failing test case input:
4 3
10
21
21
-2
10

Expected output:
11


Actual output:
23


Fixed submission (verdict: Accepted):
N,K = map(int,input().split())
h = []
for _ in range(N):
    h.append(int(input()))
h = sorted(h)
tmp = 0
ans = 10000000000
loop = N-K+1
for i in range(loop):
    tmp = h[K+i-1] - h[0+i]
    if(tmp < ans):
        ans = tmp
print(ans)

Problem: p03208
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k = map(int,input().split())
h = [int(input()) for i in range(n)]

h.sort()
dh = [h[i+1]-h[i] for i in range(0,n-1)]

dhsum = sum(dh[:k-1])
for i in range(1,n-k+1):
    dhsum = min(dhsum,dhsum-dh[i-1]+dh[i+k-2])

ans = dhsum
print(ans)

Failing test case input:
5 3
14
0
10
0
7

Expected output:
7


Actual output:
4


Fixed submission (verdict: Accepted):
n,k = map(int,input().split())
h = [int(input()) for i in range(n)]

h.sort()
dh = [h[i+1]-h[i] for i in range(0,n-1)]

mindh = dhsum = sum(dh[:k-1])
for i in range(1,n-k+1):
    dhsum = dhsum-dh[i-1]+dh[i+k-2]
    mindh = min(dhsum,mindh)

ans = mindh
print(ans)

Problem: p03208
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())
c = [int(input()) for _ in range(a)]
c.sort()
d = 0
for i in range(2, a):
    if d == 0:
        d = abs(c[i] - c[i-b+1])
    else:
        if abs(c[i] - c[i-b+1]) < d:
            d = abs(c[i] - c[i-b+1])
print(d)


Failing test case input:
5 2
8
8
10
0
11

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
a, b = map(int, input().split())
c = [int(input()) for _ in range(a)]
c.sort()
d = -1
for i in range(b-1, a):
    if d == -1:
        d = abs(c[i] - c[i-b+1])
    else:
        if abs(c[i] - c[i-b+1]) < d:
            d = abs(c[i] - c[i-b+1])
print(d)

Problem: p03208
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter

N, K = list(map(int,input().split()))
H = []
for i in range(N):
    H.append(int(input()))
H = sorted(H,reverse = False)
C = Counter(H)
CH = list(C.values()) 

for i in range(N):
    if i >= K:
        print('0')
        break
    else:
        print(H[K-1]-H[0])
        break

Failing test case input:
5 3
5
7
5
7
7

Expected output:
0

Actual output:
2


Fixed submission (verdict: Accepted):
from collections import Counter

N, K = list(map(int,input().split()))
H = []
for i in range(N):
    H.append(int(input()))
H = sorted(H,reverse = False)
C = Counter(H)
CH = list(C.values()) 

cnt = 0
for i in range(len(CH)):
    if CH[i] >= K:
        cnt += 1
        break
ans = 999999999999999
for i in range(N-K+1):
    ans = min(ans,H[K-1+i] - H[i]) 

if cnt != 0:
    print('0')
else:
    print(ans)
Problem: p03208
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int,input().split())
l=[]
sa=[]
ans=[]
for i in range(n):
    h=int(input())
    l.append(h)
l.sort()
for i in range(1,n):
    sa.append(abs(l[i]-l[i-1]))
for i in range(k-1):
    ans.append(sa[i])
print(sum(ans))

Failing test case input:
5 3
5
7
2
0
6

Expected output:
2


Actual output:
5


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
l=[]
sa=[]
for i in range(n):
    h=int(input())
    l.append(h)
l.sort()
for i in range(n-k+1):
    sa.append(l[i+k-1]-l[i])
print(min(sa))

Problem: p03208
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import itertools
n,k=map(int,input().split())
H=[int(input()) for i in range(n)]
dif=10**9

for i in itertools.combinations(H,3):
  dif=min(dif,abs(max(i)-min(i)))
print(dif)


Failing test case input:
5 5
14
25
15
0
12

Expected output:
25


Actual output:
3


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
H=sorted([int(input()) for i in range(n)])
dif=10**9
for i in range(n-k+1):
  dif=min(dif,abs(H[i+k-1]-H[i]))
print(dif)

Problem: p03208
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int, input().split())
H = [int(input()) for i in range(N)]
H.sort()

print(H[K-1] - H[0])

Failing test case input:
5 3
14
7
10
0
7

Expected output:
3


Actual output:
7


Fixed submission (verdict: Accepted):


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

print(min(H[i+K-1] - H[i] for i in range(N-K+1)))

Problem: p03208
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K = map(int, input().split())
hs = []
for _ in range(N):
    h = int(input())
    hs.append(h)
hs.sort()
print(hs)
ans = 1e9
for i in range(N-K+1):
    ans = min(ans, abs(hs[i]-hs[i+K-1]))
print(ans)

Failing test case input:
5 2
3
6
10
0
11

Expected output:
1


Actual output:
[0, 3, 6, 10, 11]
1


Fixed submission (verdict: Accepted):
N,K = map(int, input().split())
hs = []
for _ in range(N):
    h = int(input())
    hs.append(h)
hs.sort()

ans = 1e9
for i in range(N-K+1):
    ans = min(ans, abs(hs[i]-hs[i+K-1]))
print(ans)

Problem: p03208
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K = [int(x) for x in input().split()]
H = [0]*N
for i in range(N):
  H[i] = int(input())
H.sort(reverse=True)
ans= H[0]-H[K-1]
print(ans)

Failing test case input:
5 3
10
25
19
0
6

Expected output:
10


Actual output:
15


Fixed submission (verdict: Accepted):
N,K = [int(x) for x in input().split()]
H = [0]*N
for i in range(N):
  H[i] = int(input())
H.sort(reverse=True)
ans = 100000000000000000
for i in range(N-K+1):
  ans = min(ans,H[i]-H[i+K-1])
print(ans)