Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
arr = list(map(int,input().split()))

for i in range(m):
    arr[arr.index(max(arr))] //= 2
    
print(sum(arr))

Fixed submission:
n,m = map(int,input().split())
arr = list(map(int,input().split()))
l = len(arr)

while m != 0 :
    arr.sort(reverse=True)
    j = arr[0] // 2
    for i in range(l):
            if arr[i] > j:
                if m != 0:
                    m -= 1
                else:
                    break
                arr[i] //= 2
            else:
                break
    if arr[0] == 0:
        break
            

print(sum(arr))
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()

count = 0

for i in range(3);:
    if s[i] == t[i]:
        count += 1
        
print(count)

Fixed submission:
s = input()
t = input()

count = 0

for i in range(3):
    if s[i] == t[i]:
        count += 1
        
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

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

count = 0
mod = 10**9 + 7

for j in range(n):
    for i in range(1,n):
        head = arr[0]
        if head > arr[i]:
            if i+j < n: 
                count += (k*(k+1)//2) % mod
                count %= mod
            else:
                count += (k*(k-1)//2) % mod
                count %= mod
    arr = np.roll(arr, -1)
    
count %= mod
print(count)

Fixed submission:
n,k = map(int,input().split())
arr = list(map(int,input().split()))

leftCount = 0
rightCount = 0
mod = 10**9 + 7

for i in range(n):
    for j in range(n):
        if arr[i] > arr[j]:
            if i < j:
                rightCount +=1
            else:
                leftCount +=1
leftCount = leftCount*k*(k-1)//2
rightCount = rightCount*k*(k+1)//2
count = (leftCount % mod) + (rightCount % mod)
count %= mod
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

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

count = 0
mod = 10**9 + 7

for j in range(n):
    for i in range(1,n):
        head = arr[0]
        if head > arr[i]:
            if i+j < n: 
                count += (k*(k+1)//2) % mod
                count %= mod
            else:
                count += (k*(k-1)//2) % mod
                count %= mod
    arr = np.roll(arr, -1)
    
count %= mod
print(count)

Fixed submission:
n,k = map(int,input().split())
arr = list(map(int,input().split()))

leftCount = 0
rightCount = 0
mod = 10**9 + 7

for i in range(n):
    for j in range(n):
        if arr[i] > arr[j]:
            if i < j:
                rightCount +=1
            else:
                leftCount +=1
leftCount = leftCount*k*(k-1)//2
rightCount = rightCount*k*(k+1)//2
count = (leftCount % mod) + (rightCount % mod)
count %= mod
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int, input().split())
point_array = [list(map(int,input().split())) for i in range(n-1)]
point_array.sort()
action_array = [list(map(int,input().split())) for i in range(q)]
solution = [0]*n

for i in range(q):
    solution[action_array[i][0]-1] += action_array[i][1]

for i in range(n-1):
    solution[point_array[i][1]-1] += solution[point_array[i][0]-1]
    
print(*solution)

Fixed submission:
#これ計算量一次やけどACにならんかった

n,q = map(int, input().split())
point_array = [list(map(int,input().split())) for i in range(n-1)]
action_array = [list(map(int,input().split())) for i in range(q)]

point_array.sort()
solution = [0]*n

for i in range(q):
    solution[action_array[i][0]-1] += action_array[i][1]

for i in range(n-1):
    solution[point_array[i][1]-1] += solution[point_array[i][0]-1]
    
print(*solution)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()

arr = s[1:len(s)-1].split("LR")
arr = ["R"+i+"L" for i in arr]
solution_array = []

for i in arr:
    l = len(i)
    count = 1
    for j in range(l):
        if i[j] == "L":
            count = j
            break
    if count%2 != 0:        
        rcount = l - l//2
        lcount = l//2
    else:
        rcount = l//2
        lcount = l - l//2
    tmparray = [0]*l
    tmparray[count-1] = rcount
    tmparray[count] = lcount
    solution_array = solution_array + tmparray

print(" ".join(map(str, solution_array)))

Fixed submission:
s = input()
l = len(s)

arr = [1]*l

for i in range(l-2):
    if s[i] == "R":
        if s[i+1] == "R":
            arr[i+2] += arr[i]
            arr[i] = 0
        
for i in range(l-1,1,-1):
    if s[i] == "L":
        if s[i-1] == "L":
            arr[i-2] += arr[i]
            arr[i] = 0
        
print(*arr)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
s = s[1:len(s)-1]

arr = s.split("LR")
arr = ["R"+i+"L" for i in arr]
solution_array = []

for i in arr:
    l = len(i)
    count = 1
    for j in range(l):
        if i[j] == "L":
            count = j
            break
    if count%2 != 0:        
        rcount = l - l//2
        lcount = l//2
    else:
        rcount = l//2
        lcount = l - l//2
    tmparray = [0]*l
    tmparray[count-1] = rcount
    tmparray[count] = lcount
    solution_array = solution_array + tmparray
    
t = str(solution_array[0])
for i in range(len(s)+1):
    t = t +" " + str(solution_array[i+1])

print(t)

Fixed submission:
s = input()
l = len(s)

arr = [1]*l

for i in range(l-2):
    if s[i] == "R":
        if s[i+1] == "R":
            arr[i+2] += arr[i]
            arr[i] = 0
        
for i in range(l-1,1,-1):
    if s[i] == "L":
        if s[i-1] == "L":
            arr[i-2] += arr[i]
            arr[i] = 0
        
print(*arr)
Buggy python submission (verdict: Runtime Error):
import math

def combination(n,r):
    return int ( math.factorial(n) / math.factorial(n-r) / math.factorial(r) )
def permutation(n,r):
    return int( math.factorial(n) / math.factorial(n-r) )

N, K = tuple(map(int, input().split()))
mod = 10**9+7
for i in range(K):
    if i <= N-K:
        print( ( combination(K-1,i)*combination(N-K+1,i+1) ) % mod )
    else:
        print(0)

Fixed submission:
from operator import mul
from functools import reduce

def combination(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N, K = tuple(map(int, input().split()))
mod = 10**9+7
for i in range(K):
    if i <= N-K:
        print( ( combination(K-1,i)*combination(N-K+1,i+1) ) % mod )
    else:
        print(0)

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

def combination(n,r):
    return int ( math.factorial(n) / math.factorial(n-r) / math.factorial(r) )
def permutation(n,r):
    return int( math.factorial(n) / math.factorial(n-r) )

N, K = tuple(map(int, input().split()))
mod = 10**9+7
for i in range(K):
    if N >= 2*(i+1)-1:
        print( ( combination(K-1,i)*combination(N-K+1,i+1) ) % mod )
    else:
        print(0)

Fixed submission:
from operator import mul
from functools import reduce

def combination(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N, K = tuple(map(int, input().split()))
mod = 10**9+7
for i in range(K):
    if i <= N-K:
        print( ( combination(K-1,i)*combination(N-K+1,i+1) ) % mod )
    else:
        print(0)
Buggy python submission (verdict: Runtime Error):
N ,X = map(int, input().split())
difs = list(map(int, input().split()))
steps = [0]
for i in range(N):
    steps.append(steps[i] + difs[i])
for i in range(N+1):
    if steps[i] > X:
        print(i)
        break
    elif i == N:
        print(N+1)

Fixed submission:
X,A = map(int, input().split())
if X<A:
    print(0)
else:
    print(10)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=a

s=0
for i in range(n):
  if b[i]>a[i+1]:
    s+=(a[i]-a[i+1])
    b[i+1]=b[i]
print(s,a,b)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=a

s=0
for i in range(n-1):
  if b[i]>a[i+1]:
    s+=(a[i]-a[i+1])
    b[i+1]=b[i]
print(s)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split()
print(a*b)

Fixed submission:
a,b=map(int,input().split())
print(a*b)
Buggy python submission (verdict: Runtime Error):
a_s=a/1.08
a_t=(a+1)/1.08
b_s=b/1.1
b_t=(b+1)/1.1

a0=int(a_s)
a1=int(a_t)
b0=int(b_s)
b1=int(b_t)


if (a_s-a0)>0:
  a0+=1
if (a_t-a1)<=0:
  a1-=1
if (b_s-b0)>0:
  b0+=1
if (b_t-b1)<=0:
  b1-=1

lista=[i for i in range(a0,a1+1)]
listb=[i for i in range(b0,b1+1)]

ansl=[]
for j in range(len(lista)):
  if lista[j] in listb:
    ansl.append(lista[j])

if not ansl==[]:
  ans=ansl[0]
  print(ans)
else:
  print(-1)

Fixed submission:
a,b=map(int,input().split())
a_s=a/0.08
a_t=(a+1)/0.08
b_s=b/0.1
b_t=(b+1)/0.1

a0=int(a_s)
a1=int(a_t)
b0=int(b_s)
b1=int(b_t)


if (a_s-a0)>0:
  a0+=1
if (a_t-a1)<=0:
  a1-=1
if (b_s-b0)>0:
  b0+=1
if (b_t-b1)<=0:
  b1-=1

lista=[i for i in range(a0,a1+1)]
listb=[i for i in range(b0,b1+1)]

ansl=[]
for j in range(len(lista)):
  if lista[j] in listb:
    ansl.append(lista[j])

if not ansl==[]:
  ans=ansl[0]
  print(ans)
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
n,r=map(int,input())
if n<=10:
  print(r)
else:
  print(r-100*(10-n))
  

Fixed submission:
n,r=map(int,input().split())
if n>=10:
  print(r)
else:
  print(r+100*(10-n))
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b=map(int,input().split())
mod=10**9+7
def comb(n,k,mod):
  if k>n-k:
    k=n-k
  c=1
  for i in range(n-k+1,n+1):
    c*=i
    c%=mod
  d=1  
  for i in range(1,k+1):
    d*=i
    d%=mod
  return (c*pow(d,mod-2,mod))%mod

ans=(2**n-1)%mod-comb(n,a,mod)-comb(n,b,mod)
print(ans%mod)


Fixed submission:
n,a,b=map(int,input().split())
mod=10**9+7
def comb(n,k,mod):
  if k>n-k:
    k=n-k
  c=1
  for i in range(n-k+1,n+1):
    c*=i
    c%=mod
  d=1  
  for i in range(1,k+1):
    d*=i
    d%=mod
  return (c*pow(d,mod-2,mod))%mod

ans=pow(2,n,mod)-1-comb(n,a,mod)-comb(n,b,mod)
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
n,a,b=map(int,input().split())
mod=10**9+7
from scipy.special import comb
ans=(2**n-1)%mod-comb(n,a,exact=True)%mod-comb(n,b,exact=True)%mod
print(ans%mod)


Fixed submission:
n,a,b=map(int,input().split())
mod=10**9+7
def comb(n,k,mod):
  if k>n-k:
    k=n-k
  c=1
  for i in range(n-k+1,n+1):
    c*=i
    c%=mod
  d=1  
  for i in range(1,k+1):
    d*=i
    d%=mod
  return (c*pow(d,mod-2,mod))%mod

ans=pow(2,n,mod)-1-comb(n,a,mod)-comb(n,b,mod)
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
n,a,b=map(int,input().split())
mod=10**9+7
def comb(n,k,mod):
  if k>n-k:
    k=n-k
  c=1
  for i in range(n-k+1,n+1):
    c*=i
  d=1  
  for i in range(1,k+1):
    d*=i
  return (c*pow(d,mod-2,mod))%mod

ans=(2**n-1)%mod-comb(n,a,mod)-comb(n,b,mod)
print(ans%mod)


Fixed submission:
n,a,b=map(int,input().split())
mod=10**9+7
def comb(n,k,mod):
  if k>n-k:
    k=n-k
  c=1
  for i in range(n-k+1,n+1):
    c*=i
    c%=mod
  d=1  
  for i in range(1,k+1):
    d*=i
    d%=mod
  return (c*pow(d,mod-2,mod))%mod

ans=pow(2,n,mod)-1-comb(n,a,mod)-comb(n,b,mod)
print(ans%mod)

Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
mod=10**9+7
from math import pow
def comb(n,k,mod):
  if k>n-k:
    k=n-k
  c=1
  for i in range(n-k+1,n+1):
    c*=i
  d=1  
  for i in range(1,k+1):
    d*=i
return(c*pow(d,mod-2,mod)%mod)

ans=(2**n-1)-comb(n,a,mod)-comb(n,b,mod)
return (ans%mod)

Fixed submission:
n,a,b=map(int,input().split())
mod=10**9+7
def comb(n,k,mod):
  if k>n-k:
    k=n-k
  c=1
  for i in range(n-k+1,n+1):
    c*=i
    c%=mod
  d=1  
  for i in range(1,k+1):
    d*=i
    d%=mod
  return (c*pow(d,mod-2,mod))%mod

ans=pow(2,n,mod)-1-comb(n,a,mod)-comb(n,b,mod)
print(ans%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
b=[]
flag=True
for i in range(n):
  if a[i] in b:
    flag=False
    break
  else:
    b.append(a[i])
if flag:
  print("YES")
else:
  print("NO")

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a=set(a)
if len(set(a))==n:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
r1,c1,r2,c2=map(int,input().split())
mod=10**9+7
from scipy.special import comb
ans=0
for i in range(r1,r2+1):
  for j in range(c1,c2+1):
    ans+=comb(i+j,i,exact=True)%mod
print(ans%mod)


Fixed submission:
r1,c1,r2,c2=map(int,input().split())
mod=10**9+7
def comb(n,k,mod):
  if n<k:
    return 0
  if n-k<k:
    k=n-k
  c=1
  for x in range(n-k+1,n+1):
    c=(c*x)%mod
  d=1
  for x in range(1,k+1):
    d=(d*x)%mod
  c=c*pow(d,mod-2,mod)
  return c%mod
def f(i,j):
  return comb(i+j,i,mod)
ans=f(r2+1,c2+1)-f(r2+1,c1)-f(r1,c2+1)+f(r1,c1)
ans%=mod
print(ans)
Buggy python submission (verdict: Runtime Error):
h,n=map(int,input().split())
a=list(map(int,innput().split()))

if sum(a)>=h:
  print("Yes")
else:
  print("No")


Fixed submission:
h,n=map(int,input().split())
a=list(map(int,input().split()))

if sum(a)>=h:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
h=int(input())
a=list(map(int,innput().split()))

if sum(a)>=h:
  print("Yes")
else:
  print("No")

Fixed submission:
h,n=map(int,input().split())
a=list(map(int,input().split()))

if sum(a)>=h:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
import numpy as np
h,n=map(int,input().split)
p=[list(map(int,input().split())) for _ in range(n)]
m=max(p[:,0])
dp=[0]*(h+m+1)
for i in range(m+1,h+m+1):
  dp[i]=min(dp[i-a]+b for a,b in p)
print(dp[h+m])

Fixed submission:
import numpy as np
h,n=map(int,input().split())
p=[list(map(int,input().split())) for _ in range(n)]
m=10**4
dp=[0]*(h+m+1)
for i in range(m+1,h+m+1):
  dp[i]=min(dp[i-a]+b for a,b in p)
print(dp[h+m])
Buggy python submission (verdict: Runtime Error):
from collections import deque
n,d,a=map(int,input().split())
xh=[map(int,input().split()) for _ in range(n)]
xh.sort()
D=2*D
ans=0
total=0
q=deque()
for i in range(n):
  x,h=xh[i]
  while len(q)>=1 and x>q[0][0]:
    total-=q.popleft()[1]
  h-=total
  if h>0:
    num=(h-h%a)//a
    damage=a*nim
    ans+=num
    total+=damage
    q.append([x+D,damage])
print(ans)

Fixed submission:
from collections import deque
n,d,a=map(int,input().split())
xh=[list(map(int,input().split())) for _ in range(n)]
xh.sort()
d=2*d
ans=0
total=0
q=deque()
for i in range(n):
  x,h=xh[i]
  while len(q)>=1 and x>q[0][0]:
    total-=q.popleft()[1]
  h-=total
  if h>0:
    num=(h-1)//a+1
    damage=a*num
    ans+=num
    total+=damage
    q.append([x+d,damage])
print(ans)
Buggy python submission (verdict: Runtime Error):
N M =map(int,input().split())
if N==M:
  print("Yes")
else:
  print("No")

Fixed submission:
N,M=map(int,input().split())
if N==M:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
a,b=map(str,input().split())
if int(a)<=int(b):
  s=a
  for i in range(b-1):
    s+=a
  print (s)
else:
  s=b
  for j in range(a-1):
    s+=b
  print(s)
  


Fixed submission:
a,b=map(str,input().split())
if int(a)<=int(b):
  s=a
  for i in range(int(b)-1):
    s+=a
  print (s)
else:
  s=b
  for j in range(int(a)-1):
    s+=b
  print(s)

Buggy python submission (verdict: Runtime Error):
a,b=map(str,input().split())
if int(a)<=int(b):
  s=a
  for _ in range(b-1):
    s+=a
  print (s)
else:
  s=b
  for _ in range(a-1):
    s+=b
  print(s)
  


Fixed submission:
a,b=map(str,input().split())
if int(a)<=int(b):
  s=a
  for i in range(int(b)-1):
    s+=a
  print (s)
else:
  s=b
  for j in range(int(a)-1):
    s+=b
  print(s)

Buggy python submission (verdict: Runtime Error):
a,b=map(str,input().split())
if a<=b:
  s=a
  for _ in range(b-1):
    s+=a
  print (s)
else:
  s=b
  for _ in range(a-1):
    s+=b
  print(s)
  

Fixed submission:
a,b=map(str,input().split())
if int(a)<=int(b):
  s=a
  for i in range(int(b)-1):
    s+=a
  print (s)
else:
  s=b
  for j in range(int(a)-1):
    s+=b
  print(s)
Buggy python submission (verdict: Runtime Error):
n=int(input())
lst=list(map(int,input().split()))
premin=lst[0]
ans=0
for x in lst:
  if min_list>=x:
    ans+=1
    premin=x
print(ans)


Fixed submission:
n=int(input())
lst=list(map(int,input().split()))
premin=lst[0]
ans=0
for x in lst:
  if premin>=x:
    ans+=1
    premin=x
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
lst=list(map(int,input().split()))
premin=[lst[0]]
ans=0
for x in lst:
  if min_list>=x:
    ans+=1
    premin=x
print(ans)

Fixed submission:
n=int(input())
lst=list(map(int,input().split()))
premin=lst[0]
ans=0
for x in lst:
  if premin>=x:
    ans+=1
    premin=x
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
P=list(map(int,input().split()))
lst_con=[P[0]]
lst_num=[0]
s=0
for i in range(n):
  x=P[i]
  flag=True
  if x>lst_con[-1]:
    flag=False
  else:
    for j in range(lst_num[-1],i):
      if P[j]<x:
        flag=False
        break
  if flag:
    s+=1
print(s)


Fixed submission:
n=int(input())
lst=list(map(int,input().split()))
premin=lst[0]
ans=0
for x in lst:
  if premin>=x:
    ans+=1
    premin=x
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
P=list(map(int,input().split()))
s=0
for i in range(n):
  x=P[i]
  flag=True
  for j in range(i):
    if P[j]<x:
      flag=False
      break
  if flag:
    s+=1
print(s)


Fixed submission:
n=int(input())
lst=list(map(int,input().split()))
premin=lst[0]
ans=0
for x in lst:
  if premin>=x:
    ans+=1
    premin=x
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
from math import gcd
ans=a[0]
for i in range(1,n):
  ans=ans*a[i]//gcd(ans,a[i])
s=0
for j in range(n):
  s+=(ans//a[j])%mod
print(s%mod)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
from math import gcd
ans=a[0]
for i in range(1,n):
  ans=ans*a[i]//gcd(ans,a[i])
s=sum(pow(x,mod-2,mod) for x in a)
print(s*ans%mod)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
mod=10**9+7
a.sort()
def fact(n):
  if n==0:
    return 1
  else:
    s=1
    for i in range(1,n+1):
      s=s*i
    return s
def comb(n,k,mod):
  return (fact(n)//fact(k)//fact(n-k))%mod

if k>1:
  s=0
  for i in range(0,n-k):
    for j in range(i+k-1,n-1):
      s+=((a[j]-a[i])*comb(j-i-1,k-2,mod))%mod
  print(s%mod)
else:
  print(0)


Fixed submission:
C=str(input())
a=ord(C)
print(chr(a+1))
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
mod=10**9+7
fan=[1]*N+1
for i in range(2,N+1):
  fan[i]=fan[i-1]*(i)%mod
ans=0
def comb(a,b):
  return fan[a]*pow(fan[b],mod-2,mod)*pow(fan[a-b],mod-2,mod)%mod
for i in range(N-K+1):
  for j in range(0,i-K+1)
  ans+=comb(i-j-1,K-1)*(A[N-1-i]-A[j])
  ans%=mod
print(ans)

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
mod=10**9+7
fan=[1]*(N+1)
for i in range(2,N):
  fan[i]=fan[i-1]*(i)%mod
ans=0
def comb(a,b):
  return fan[a]*pow(fan[b],mod-2,mod)*pow(fan[a-b],mod-2,mod)
for i in range(N-K+1):
  ans+=comb(N-i-1,K-1)*(A[N-i-1]-A[i])
  ans%=mod
print(ans)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
mod=10**9+7
a.sort()
def fact(n):
  if n==0:
    return 1
  else:
    s=1
    for i in range(1,n+1):
      s=s*i
def comb(n,k,mod):
  return (fact(n)//fact(k)//fact(n-k))%mod

if k>1:
  s=0
  for i in range(0,n-k):
    for j in range(i+k-1,n-1):
      s+=((a[j]-a[i])*comb(j-i-1,k-2,mod))%mod
  print(s%mod)
else:
  print(0)


Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
mod=10**9+7
fan=[1]*(N+1)
for i in range(2,N):
  fan[i]=fan[i-1]*(i)%mod
ans=0
def comb(a,b):
  return fan[a]*pow(fan[b],mod-2,mod)*pow(fan[a-b],mod-2,mod)
for i in range(N-K+1):
  ans+=comb(N-i-1,K-1)*(A[N-i-1]-A[i])
  ans%=mod
print(ans)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
mod=10**9+7
a.sort()
def fact(n):
  if n==0:
    return 1
  else:
    s=1
    for i in range(1,n+1):
      s=s*i
def cmb(n,k,mod):
  return (fact(n)//fact(k)//fact(n-k))%mod

if k>1:
  s=0
  for i in range(0,n-k):
    for j in range(i+k-1,n-1):
      s+=((a[j]-a[i])*comb(j-i-1,k-2,mod))%mod
  print(s%mod)
else:
  print(0)


Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
mod=10**9+7
fan=[1]*(N+1)
for i in range(2,N):
  fan[i]=fan[i-1]*(i)%mod
ans=0
def comb(a,b):
  return fan[a]*pow(fan[b],mod-2,mod)*pow(fan[a-b],mod-2,mod)
for i in range(N-K+1):
  ans+=comb(N-i-1,K-1)*(A[N-i-1]-A[i])
  ans%=mod
print(ans)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
mod=10**9+7
a.sort()
def comb(n,k,mod):
  if (r<0 or r>n):
    return 0
  r=min(r,n-r)
  return fact[n]*factinv[r]*factinv[n-r]%mod

N=10**5
fact=[1,1]
factinv=[1,1]
inv=[0,1]

for i in range(2,N+1):
  fact.append((fact[-1]*i)%mod)
  inv.append((-inv[mod%i]*(mod//i))%mod)
  factinv.append((factinv[-1]*inv[-1])%mod)
  
if k>1:
  s=0
  for i in range(0,n-k):
    for j in range(i+k-1,n-1):
      s+=((a[j]-a[i])*comb(j-i-1,k-2,mod))%mod
  print(s%mod)
else:
  print(0)


Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
mod=10**9+7
fan=[1]*(N+1)
for i in range(2,N):
  fan[i]=fan[i-1]*(i)%mod
ans=0
def comb(a,b):
  return fan[a]*pow(fan[b],mod-2,mod)*pow(fan[a-b],mod-2,mod)
for i in range(N-K+1):
  ans+=comb(N-i-1,K-1)*(A[N-i-1]-A[i])
  ans%=mod
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import sqrt
N=int(input())
XY=[tuple(map(int,input().split() for _ in range(N)))]

def calc(r):
  lst=[]
  for i in range(N-1):
    x1=XY[i][0]
    y1=XY[i][1]
    for j in range(i+1,N):
      x2=XY[j][0]
      y2=XY[j][1]
      diff=sqrt((x1-x2)**2+(y1-y2)**2)
      if diff>2*r:
        return False
      
      h=sqrt(r**2-diff**2/4)
      if x1==x2:
        ny=(y1+y2)/2
        lst.append([x1-h,ny])
        lst.append([x1+h,ny])
      elif y1==y2:
        nx=(x1+x2)/2
        lst.append([nx,y1-h])
        lst.append([nx,y1+h])
      else:
        a=(y2-y1)/(x2-x1)
        b=-1/a
        size=sqrt(1+b**2)
        dx=h/size
        dy=dx*b
        nx=(x1+x2)/2
        ny=(y1+y2)/2
        lst.append([nx+dx,ny+dy])
        lst.append([nx-dx,ny-dy])
  for x,y in lst:
    flag=True
    for X,Y in XY:
      tmp=(x-X)**2+(y-Y)**2
      if tmp>r**2:
        flag=False
        break
    if flag:
      return True
  return False
l=0
r=1000
for i in range(100):
  mid=(i+r)/2
  if calc(mid):
    r=mid
  else:
    l=mid
print(r)
       
        

Fixed submission:
from math import sqrt
N=int(input())
XY=[tuple(map(int,input().split())) for _ in range(N)]

def calc(r):
  lst=[]
  for i in range(N-1):
    x1=XY[i][0]
    y1=XY[i][1]
    for j in range(i+1,N):
      x2=XY[j][0]
      y2=XY[j][1]
      diff=sqrt((x1-x2)**2+(y1-y2)**2)
      if diff>2*r:
        return False
      
      h=sqrt(r**2-diff**2/4)
      if x1==x2:
        ny=(y1+y2)/2
        lst.append([x1-h,ny])
        lst.append([x1+h,ny])
      elif y1==y2:
        nx=(x1+x2)/2
        lst.append([nx,y1-h])
        lst.append([nx,y1+h])
      else:
        a=(y2-y1)/(x2-x1)
        b=-1/a
        size=sqrt(1+b**2)
        dx=h/size
        dy=dx*b
        nx=(x1+x2)/2
        ny=(y1+y2)/2
        lst.append([nx+dx,ny+dy])
        lst.append([nx-dx,ny-dy])
  nr=r+10**(-9)
  for x,y in lst:
    flag=True
    for X,Y in XY:
      tmp=(x-X)**2+(y-Y)**2
      if tmp>nr**2:
        flag=False
        break
    if flag:
      return True
  return False
l=0
r=1000
for i in range(100):
  mid=(l+r)/2
  if calc(mid):
    r=mid
  else:
    l=mid
print(r)