Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

a,b=(int(x) for x in input().split())
l = range(a+1)
count = 0
m = [0 for x,y,z in itertools.product(l,l,l)if (x+y+z) == b]
#m = [0 for x in l for y in l for z in l if (x+y+z) == b]
print(len(m))

Fixed submission:
import itertools
a,b=(int(x) for x in input().split())
l = range(a+1)
count = 0
m = [x+y for x,y in itertools.product(l,l) if (x+y)<=b]
for i in m:
  if b-i <= a:
    count+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
a,b=(int(x) for x in input().split())
l = range(a+1)
count = 0
m = [x+y for x,y in itertools.product(l,l)]
for z in l:
  for f in m:
    if f+z == b:
      count+=1
print(count)

Fixed submission:
import itertools
a,b=(int(x) for x in input().split())
l = range(a+1)
count = 0
m = [x+y for x,y in itertools.product(l,l) if (x+y)<=b]
for i in m:
  if b-i <= a:
    count+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
a,b=(int(x) for x in input().split())
count = 0
l = range(a+1)
m = [0 for x in l for y in l for z in l if (x+y+z) == b]

print(len(m))

Fixed submission:
import itertools
a,b=(int(x) for x in input().split())
l = range(a+1)
count = 0
m = [x+y for x,y in itertools.product(l,l) if (x+y)<=b]
for i in m:
  if b-i <= a:
    count+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
a,b=(int(x) for x in input().split())
count = 0
l = range(a+1)

for x in l:
  for y in l:
    for z in l:
      if (x+y+z) == b:
        count+=1

print(count)

Fixed submission:
import itertools
a,b=(int(x) for x in input().split())
l = range(a+1)
count = 0
m = [x+y for x,y in itertools.product(l,l) if (x+y)<=b]
for i in m:
  if b-i <= a:
    count+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
a,b=(int(x) for x in input().split())
count = 0
for x in range(a+1):
  for y in range(a+1):
    for z in range(a+1):
      if (x+y+z) == b:
        count+=1

print(count)

Fixed submission:
import itertools
a,b=(int(x) for x in input().split())
l = range(a+1)
count = 0
m = [x+y for x,y in itertools.product(l,l) if (x+y)<=b]
for i in m:
  if b-i <= a:
    count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
N,R=map(int,input().split())
if (N>=10):
  print (R)
else :
  print (R+100*(10-K))

Fixed submission:
N, R=map(int,input().split())
if (N>=10):
  print (R)
else :
  print (R+100*(10-N))
Buggy python submission (verdict: Runtime Error):
A,B,C=map(int,input().split())
if (A=B=C):
  print(No)
  else:
    if (A=B):
      print (Yes)
    if (A=C):
      print (Yes)
    if (B=C):
      print (Yes)
    else:
      print (No)

Fixed submission:
A,B,C=map(int,input().split())
if (A==B==C):
  print ('No')
elif (A != B and A != C and B != C):
  print ('No')
else:
  print ('Yes')
Buggy python submission (verdict: Runtime Error):
H,N=map(int,input().split())
A=list(map(int,input().split()))
if H<=sum(a):
  print('Yes')
else:
  print('No')

Fixed submission:
H,N=map(int,input().split())
A=list(map(int,input().split()))
if H<=sum(A):
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
import sys

def main():

    sys.stdin = open('input155a.txt')

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

    answer = 'Yes' if check(a, b, c) else 'No'
    print(answer)

def check(a, b, c):

    for _ in range(3):
        a, b, c = b, c, a
        if a == b and b != c:
            return True

    return False


if __name__ == '__main__':
    main()


Fixed submission:
import sys

def main():
    
    # sys.stdin = open('input155a.txt')
    
    a, b, c = map(int, input().split())

    if a == b & b == c:
        print('No')
        
    elif a != b & b != c & c != a:
        print('No')
    
    else:
        print('Yes')
     

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
from itertools import accumulate

def main():
    
    # sys.stdin = open('input154d.txt')

    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    
    s = [0] + p
    s = list(accumulate(s))

    maxp = 0
    index = 0
    for i in range(k, n):
      nowp = s[i] - s[i - k]
      if maxp < nowp:
        maxp = nowp
        index = i

    sump = 0
    for j in range(i-k, i):
      sump += p[j] * (p[j] + 1) / 2 / p[j]

    print(sump)
        
if __name__ == '__main__':
    main()


Fixed submission:
import sys
from itertools import accumulate

def main():
    
    # sys.stdin = open('input154d.txt')

    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    
    s = [0] + p
    s = list(accumulate(s))

    # print(p)
    # print(s)
    maxp = 0
    idx = 0
    for i in range(n - k + 1):
      nowp = s[i + k] - s[i]
      # print(i)
      # print(nowp)
      if maxp < nowp:
        maxp = nowp
        idx = i

    # print(idx)

    sump = 0
    for j in range(idx, idx+k):
      sump += p[j] * (p[j] + 1) / 2 / p[j]

    print(sump)
        
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys
from itertools import accumulate

def main():
    
    # sys.stdin = open('input154d.txt')

    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    
    s = [0] + p
    s = list(accumulate(s))
    print(p)
    print(s)

    maxp = 0
    index = 0
    for i in range(k, n):
      nowp = s[i] - s[i - k]
      if maxp < nowp:
        maxp = nowp
        index = i

    sump = 0
    for j in range(i-k, i):
      sump += p[j] * (p[j] + 1) / 2 / p[j]

    print(sump)
        
if __name__ == '__main__':
    main()


Fixed submission:
import sys
from itertools import accumulate

def main():
    
    # sys.stdin = open('input154d.txt')

    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    
    s = [0] + p
    s = list(accumulate(s))

    # print(p)
    # print(s)
    maxp = 0
    idx = 0
    for i in range(n - k + 1):
      nowp = s[i + k] - s[i]
      # print(i)
      # print(nowp)
      if maxp < nowp:
        maxp = nowp
        idx = i

    # print(idx)

    sump = 0
    for j in range(idx, idx+k):
      sump += p[j] * (p[j] + 1) / 2 / p[j]

    print(sump)
        
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys

def main():
    # sys.stdin = open('input149c.txt')

    x = int(input())

    r = false
    while not r:
        r = true
        for i in range(2,x):
            if x % i == 0:
                r = false
                break

        if r == false:
            x += 1
        
    print(x)

if __name__ == '__main__':
    main()


Fixed submission:
import sys

def main():
    # sys.stdin = open('input149c.txt')

    x = int(input())

    r = False
    while not r:
        r = True
        for i in range(2,x):
            if x % i == 0:
                r = False
                break

        if r == False:
            x += 1
        
    print(x)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys

def main():
    # sys.stdin = open('input149c.txt')

    x = int(input())

    r = false
    while not r:
        r = true
        for i in range(2,x):
            if x % i == 0:
                r = false
                break

        if r == false:
            x += 1
        
    print(x)

if __name__ == '__main__':
    main()


Fixed submission:
import sys

def main():
    # sys.stdin = open('input149c.txt')

    x = int(input())

    r = False
    while not r:
        r = True
        for i in range(2,x):
            if x % i == 0:
                r = False
                break

        if r == False:
            x += 1
        
    print(x)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys

def main():

    # sys.stdin = open('input148d.txt')

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

    ni = n
    comp = True
    while comp:
        comp = False
        for j in range(n):
            if a[j] != j + 1:
                a.pop(j)
                n -= 1
                comp = True
                break

   
    if n == 0:
        print(-1)
    else:
        print(ni - n)
            
if __name__ == '__main__':
    main()


Fixed submission:
import sys

def main():

    # sys.stdin = open('input148d.txt')

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

    i = 1
    r = 0
    for j in range(n):
        if a[j] == i:
            i += 1
        else:
            r += 1

   
    if r == n:
        print(-1)
    else:
        print(r)
            
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys

#if sys.platform =='ios':
sys.stdin=open('input133d.txt')

#+++++

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

sum = 0
for s in a:
    sum += s

asum = 0
for i in range(n):
    if i % 2 == 1:
        asum += a[i]

x1 = sum - 2 * asum

ret = []
ret.append(x1)

for i in range(1, n):
   xi = 2 * a[i - 1] - ret[i - 1] 
   ret.append(xi)

for i in ret:
    print(i, end =" ")


Fixed submission:
import sys

if sys.platform =='ios':
    sys.stdin=open('input133d.txt')

#+++++

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

sum = 0
for s in a:
    sum += s

asum = 0
for i in range(n):
    if i % 2 == 1:
        asum += a[i]

x1 = sum - 2 * asum

ret = []
ret.append(x1)

for i in range(1, n):
   xi = 2 * a[i - 1] - ret[i - 1] 
   ret.append(xi)

for i in ret:
    print(i, end =" ")
Buggy python submission (verdict: Time Limit Exceeded):
import sys

def main():
    
    # sys.stdin = open('input_b.txt')
    input = sys.stdin.readline

    n, k = map(int, input().split())
    h = tuple(map(int, input().split()))

    dp = [0] + [float('inf')] * (n - 1)
    
    for i in range(1, n):
        for j in range(max(0, i - k), i):
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]))

    print(dp[-1])



if __name__ == '__main__':
    main()


Fixed submission:
import sys
import numpy as np

def main():

    # sys.stdin = open('input_b.txt')
    input = sys.stdin.readline

    n, k = map(int, input().split())
    h = tuple(map(int, input().split()))

    # dp = [0] + [float('inf')] * (n - 1)
    dp = np.zeros(n, dtype=int)
    h = np.array(h)


    for i in range(1, n):
        start = max(0, i-k)
        
        dp[i] = min(dp[start: i] + np.abs(h[i] - h[start : i]))

    print(dp[n-1])



if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def main():
    
    # sys.stdin = open('input_b.txt')

    n, k = map(int, input().split())
    h = tuple(map(int, input().split()))

    dp = [0] + [float('inf')] * (n - 1)
    
    for i in range(1, n):
        for j in range(max(0, i - k), i):
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]))

    print(dp[-1])



if __name__ == '__main__':
    main()


Fixed submission:
import sys
import numpy as np

def main():

    # sys.stdin = open('input_b.txt')
    input = sys.stdin.readline

    n, k = map(int, input().split())
    h = tuple(map(int, input().split()))

    # dp = [0] + [float('inf')] * (n - 1)
    dp = np.zeros(n, dtype=int)
    h = np.array(h)


    for i in range(1, n):
        start = max(0, i-k)
        
        dp[i] = min(dp[start: i] + np.abs(h[i] - h[start : i]))

    print(dp[n-1])



if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def main():
    
    # sys.stdin = open('input_b.txt')

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

    dp = [0] + [float('inf')] * (n - 1)
    
    for i in range(1, n):
        for j in range(max(0, i - k), i):
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]))

    print(dp[-1])



if __name__ == '__main__':
    main()


Fixed submission:
import sys
import numpy as np

def main():

    # sys.stdin = open('input_b.txt')
    input = sys.stdin.readline

    n, k = map(int, input().split())
    h = tuple(map(int, input().split()))

    # dp = [0] + [float('inf')] * (n - 1)
    dp = np.zeros(n, dtype=int)
    h = np.array(h)


    for i in range(1, n):
        start = max(0, i-k)
        
        dp[i] = min(dp[start: i] + np.abs(h[i] - h[start : i]))

    print(dp[n-1])



if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
x=input().split()
n=int(x[0])
k=int(x[1])
def fast_expo(b,n,p):
    if n==0:
        return 1
    if n==1:
        return b%p
    if n%2==0:
        return fast_expo(((b%p)*(b%p))%p,n//2,p)
    else:
        return (b*fast_expo(((b%p)*(b%p))%p,n//2,p))%p
def combi(n,p):
    X=1
    Y=1
    Z=[1]*(n+1)
    for i in range(n):
        X=(X*(n-i))%p
        Y=(Y*(i+1))%p
        Z[i+1]=(X*fast_expo(Y,p-2,p))%p
    return Z 

p=10**9+7
s=0
L=min(n,k+1)
Z1=combi(n,p)
Z2=combi(n-1,p)
for i in range(L):
  s=(s+(Z1[i]*Z2[i])%p)%p
print(s)  


Fixed submission:
x=input().split()
n=int(x[0])
k=int(x[1])
def fact_inverse(n,p):
    fact=[1]*(n+1)
    inv=[1]*(n+1)
    inv_fact=[1]*(n+1)
    inv[0]=0
    inv_fact[0]=0
    for i in range(2,n+1):
        fact[i]=(fact[i-1]*i)%p
        #compute the inverse of i mod p
        inv[i]=(-inv[p%i]*(p//i))%p
        inv_fact[i]=(inv_fact[i-1]*inv[i])%p
    return fact,inv_fact    
    

def combi2(n,p):
    f,inv=fact_inverse(n,p)
    combis=[1]*(n+1)
    for k in range(1,n+1):
        if k >=n//2+1:
            combis[k]=combis[n-k]
        else:
            combis[k]=(((f[n]*inv[n-k])%p)*inv[k])%p
    return combis    
      
    
p=10**9+7
combis1=combi2(n,p)
combis2=combi2(n-1,p)
s=0
L=min(n,k+1)
for i in range(L):
  s=(s+(combis1[i]*combis2[i])%p)%p
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
x=input().split()
n=int(x[0])
k=int(x[1])

def fast_expo(b,n,p):
    if n==0:
        return 1
    if n==1:
        return b%p
    if n%2==0:
        return fast_expo(((b%p)*(b%p))%p,n//2,p)
    else:
        return (b*fast_expo(((b%p)*(b%p))%p,n//2,p))%p
def combi(n,k,p):
    X=1
    Y=1
    for i in range(k):
        X=(X*(n-i))%p
        Y=(Y*(k-i))%p
    Z=fast_expo(Y,p-2,p)
    return (X*Z)%p

p=10**9+7
s=0
L=min(n,k+1)
for i in range(L):
  s=(s+(combi(n,i,p)*combi(n-1,i,p))%p)%p
print(s)  


Fixed submission:
x=input().split()
n=int(x[0])
k=int(x[1])
def fact_inverse(n,p):
    fact=[1]*(n+1)
    inv=[1]*(n+1)
    inv_fact=[1]*(n+1)
    inv[0]=0
    inv_fact[0]=0
    for i in range(2,n+1):
        fact[i]=(fact[i-1]*i)%p
        #compute the inverse of i mod p
        inv[i]=(-inv[p%i]*(p//i))%p
        inv_fact[i]=(inv_fact[i-1]*inv[i])%p
    return fact,inv_fact    
    

def combi2(n,p):
    f,inv=fact_inverse(n,p)
    combis=[1]*(n+1)
    for k in range(1,n+1):
        if k >=n//2+1:
            combis[k]=combis[n-k]
        else:
            combis[k]=(((f[n]*inv[n-k])%p)*inv[k])%p
    return combis    
      
    
p=10**9+7
combis1=combi2(n,p)
combis2=combi2(n-1,p)
s=0
L=min(n,k+1)
for i in range(L):
  s=(s+(combis1[i]*combis2[i])%p)%p
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
x=[]
y=[]
z=[]
for k in range(n):
  x.append(input())
  if x[-1] not in y:
    y.append(x[-1])
x.sort()
y.sort()
count=[1]*len(y)
head=0
for k in range(1,n):
  if x[k]!=x[k-1]:
    head+=1
  else:
    count[head]+=1
maxim=max(count)
for i in range(len(y)):
  if count[i]==maxim:
    print(y[i])

Fixed submission:
n=int(input())
x=[]
for k in range(n):
  x.append(input())
x.sort()
count=[1]
head=[0]
for k in range(1,n):
  if x[k]!=x[k-1]:
    head.append(k)
    count.append(1)
  else:
    count[-1]+=1
maxim=max(count)
for k in range(len(count)):
  if count[k]==maxim:
    print(x[head[k]])
Buggy python submission (verdict: Runtime Error):
x=input().split()
h=int(x[0])
n=int(x[1])
import numpy as np
a=np.full(n,0,int)
b=np.full(n,0,int)
for k in range(n):
  x=input().split()
  a[k]=int(x[0])
  b[k]=int(x[1])
m=max(a)  
inf=10**8
dp=np.full(h+m+1,inf,int)
dp[0]=0
for k in range(1,h+m):
  dp[k]=(dp[np.max(k-a,-1)]+b).min()
print(dp[h:h+m].min())

  

Fixed submission:
x=input().split()
H=int(x[0])
A=int(x[1])
if H%A==0:
  print(H//A)
else:
  print(H//A+1)

Buggy python submission (verdict: Runtime Error):
x=input().split()
h=int(x[0])
n=int(x[1])
a=[]
b=[]
for k in range(n):
  x=input().split()
  a.append(int(x[0]))
  b.append(int(x[1]))  
m=max(a)  
dp=[10**8]*(h+m)
dp[0]=0
for k in range(h+m):
  for i in range(n):
    if k-a[i]<0:
      continue
    new=dp[k-a[i]]+b[i]
    if new < dp[k]:
      dp[k]=new
print(min(dp[h:h+m]))
      
      

Fixed submission:
x=input().split()
H=int(x[0])
A=int(x[1])
if H%A==0:
  print(H//A)
else:
  print(H//A+1)

Buggy python submission (verdict: Runtime Error):
x=input().split()
h=int(x[0])
n=int(x[1])
a=[]
b=[]
for k in range(n):
  x=input().split()
  a.append(int(x[0]))
  b.append(int(x[1]))  
m=max(a)  
dp=[10**9]*(h+m)
dp[0]=0
for k in range(h+m):
  for i in range(n):
    if k-a[i]<0:
      continue
    new=dp[k-a[i]]+b[i]
    if new < dp[k]:
      dp[k]=new
print(min(dp[h:h+m]))
      
      

Fixed submission:
x=input().split()
H=int(x[0])
A=int(x[1])
if H%A==0:
  print(H//A)
else:
  print(H//A+1)

Buggy python submission (verdict: Runtime Error):
x=input().split()
h=int(x[0])
n=int(x[1])
a=[]
b=[]
c=[]
for k in range(n):
  x=input().split()
  a.append(int(x[0]))
  b.append(int(x[1]))
  c.append(int(x[0])/int(x[1]))
s=0  
while H>0:
  maxim=0
  for k in range(n):
    m=H//a[k]
    d=a[k]*(H//a[k]+1)
    if (d+1)*b[k]>maxim:
      maxim=(d+1)*b[k]
  s+=maxim
print(s)  

Fixed submission:
x=input().split()
H=int(x[0])
A=int(x[1])
if H%A==0:
  print(H//A)
else:
  print(H//A+1)
Buggy python submission (verdict: Runtime Error):
import math
def main():
    N, K = map(int, input().split())
    if K ==1:
        print(N+1)
    elif N % K == 0:
        print(math.ceil(math.log(N,K))+1)
    else:
        print(math.ceil(math.log(N,K)))


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    K, R = map(int, input().split())

    if K >=10:
        print(R)
    else:
        print(R + 100*(10-K))

if __name__ =='__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import math
def main():
    N, K = map(int, input().split())
    if N % K == 0:
        print(math.ceil(math.log(N,K))+1)
    else:
        print(math.ceil(math.log(N,K)))


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    K, R = map(int, input().split())

    if K >=10:
        print(R)
    else:
        print(R + 100*(10-K))

if __name__ =='__main__':
    main()

Buggy python submission (verdict: Runtime Error):
N = int(input())
x = list(map(int, input().split()))
 
n = len(x)
 
sum_a = 0
sum_b = 0
 
for xi in x:
  sum_a += xi * xi
  sum_b += xi
  
ans = sum_a - (sum_b*sum_b)/n
min_ans = 10**9
if ans < min_ans:
    ans = min_ans
 
print(int(ans+0.5))

Fixed submission:
N, R = map(int,input().split())

if N >= 10:
  print(R)
else:
  print( R+100*(10-N) )
Buggy python submission (verdict: Runtime Error):
N = int(input())
x = list(map(int, input().split()))
 
n = len(x)

sum_a = 0
sum_b = 0

for xi in x:
  sum_a += xi * xi
  sum_b += xi
  
ans = sum_a - (sum_b*sum_b)/n
min_ans = 10**9
if ans < min_ans
    ans = min_ans

print(int(ans+0.5))

Fixed submission:
N = int(input())
x = list(map(int, input().split()))
 
n = len(x)
 
sum_a = 0
sum_b = 0
 
for xi in x:
  sum_a += (xi*xi)
  sum_b += xi

p = int(sum_b/n+0.5)
ans = sum_a - 2*sum_b*p+n*p*p

min_ans = 10**9
if ans > min_ans:
    ans = min_ans
print(int(ans))

Buggy python submission (verdict: Runtime Error):
N = int(input())
X = list(map(int, input().split()))

n = len(X)

for xi in x:
  sum_a += xi * xi
  sum_b += xi
  
ans = sum_a - (sum_b*sum_b)/n
print(ans)

Fixed submission:
N = int(input())
x = list(map(int, input().split()))
 
n = len(x)
 
sum_a = 0
sum_b = 0
 
for xi in x:
  sum_a += (xi*xi)
  sum_b += xi

p = int(sum_b/n+0.5)
ans = sum_a - 2*sum_b*p+n*p*p

min_ans = 10**9
if ans > min_ans:
    ans = min_ans
print(int(ans))
Buggy python submission (verdict: Runtime Error):
,N = map(int,input().split())
Ai = map(int, input().split())
 
if sum(A) >= H:
  print('Yes')
else:
  print('No')

Fixed submission:
H,N = map(int,input().split())
A = map(int, input().split())

sum=0
for Ai in A:
  sum += Ai

if sum >= H:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import sys

def getMin(X, K):
    minVal = sys.maxsize
    if K == 1:
        return X[0]
    
    for l in range(0, len(X)-K):
        minVal = min(minVal, abs(X[l]) + abs(X[K + l - 1] - X[l]))
            
    return minVal

def solve(X, K):
    ans = min(getMin(X, K), getMin(X[::-1], K))
    return ans

if __name__ == "__main__":
    N, K = map(int, input().split())
    X = map(int, input().split())
    print(solve(X, K))



Fixed submission:
# coding: utf-8

def getMin(X, K):
    minVal = float('inf')
    for l in range(len(X)-K+1):        
        minVal = min(minVal, abs(X[l]) + abs(X[K + l - 1] - X[l]))
        minVal = min(minVal, abs(X[K + l - 1]) + abs(X[l] - X[K + l - 1]))
    return minVal

if __name__ == "__main__":
    N, K = map(int, input().split())
    X = list(map(int, input().split()))
    print(getMin(X, K))
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

def sIsland(slist):
    b1, b0 = slist[0][1], slist[0][1]-1
    slist = slist[1:]
    
    rest = []
    for i in range(len(slist)):
        if not(slist[i][0] <= b0 and b1 <= slist[i][1]):
            rest.append(slist[i])
    return rest

def solve(matrix):
    n_call = 1
    deleted = sIsland(sorted(matrix, key=lambda x:x[1]))
    while True:
        if len(deleted) == 0:
            return n_call
        deleted = sIsland(deleted)
        n_call += 1
    
if __name__ == "__main__":
    
    N, M = map(int, input().split())
    matrix = []
    for i in range(M):
        matrix.append([int(x) for x in  input().split(" ")])
    print(solve(matrix))


Fixed submission:
# coding: utf-8

def getG(N, M):
    G=[list() for i in range(N)]
    for i in range(M):
        a,b=map(int,input().split())
        a-=1
        b-=1
        G[a].append(b)
        G[b].append(a)

    return G

def solve(G, N):
    ans = 0
    index = -1

    for i in range(1, N):
        for p in G[i]:
            if index < p < i:
                ans += 1
                index = i - 1
    return ans

if __name__ == "__main__":
    N, M = map(int, input().split())
    G = getG(N, M)
    print(solve(G, N))
Buggy python submission (verdict: Time Limit Exceeded):
#coding: utf-8

def getInput():
    in_row = [ int(x) for x in input().split(" ") ]
    return in_row

def judgeTakahashi(in_row):
    A = in_row[0] # initial stock
    B = in_row[1] # initial Takahashi
    C = in_row[2]
    D = in_row[3]
    loop = []

    if A < B:
        return False

    # daytime - purchase
    while A not in loop:
        loop.append(A)
        A %= B

        # night - fill
        if A <= C:
            A += D

        if A < B:
            return False
    
    return True
    
    
if __name__ == "__main__":
    N = int(input())
    for i in range(N):
        in_row = getInput()
        result = "Yes" if judgeTakahashi(in_row) else "No"
        print(result)
    


Fixed submission:
#coding: utf-8

def getInput():
    in_row = [ int(x) for x in input().split(" ") ]
    return in_row

def gcd(n1, n2):
    while n1 % n2 != 0:
        if n1 < n2:
            n1, n2 = n2, n1
        n1 %= n2
    return n2
            
def judgeTakahashi(in_row):
    A = in_row[0]
    B = in_row[1]
    C = in_row[2]
    D = in_row[3]
    g = gcd(B, D)

    if B > A:
        return False
    if B > D:
        return False
    if C >= B:
        return True
    
    if B-g+(A%g) > C:
        return False
    else:
        return True

if __name__ == "__main__":
    N = int(input())
    assert gcd(1071, 1029) == 21, "error"
    assert not(judgeTakahashi([1, 10, 1, 1])), "error"
    for i in range(N):
        in_row = getInput()
        result = "Yes" if judgeTakahashi(in_row) else "No"
        print(result)