Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
from functools import reduce
n=int(input())
a=list(map(int,input().split()))
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
k=0
m=lcm_list(a)-1
for i in range(n):
    k+=m%a[i]
print(k)

Fixed submission:
from fractions import gcd
from functools import reduce
n=int(input())
a=list(map(int,input().split()))
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
k=0
m=lcm_list(a)-1
for i in range(n):
    k+=m%a[i]
print(k)

Buggy python submission (verdict: Runtime Error):
from fractions import gcd
from functools import reduce
n=int(input())
a=list(map(int,input().split()))
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
k=0
m=lcm_list(l)-1
for i in range(n):
    k+=m%l[i]
print(k)

Fixed submission:
from fractions import gcd
from functools import reduce
n=int(input())
a=list(map(int,input().split()))
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
k=0
m=lcm_list(a)-1
for i in range(n):
    k+=m%a[i]
print(k)

Buggy python submission (verdict: Runtime Error):
from fractions import gcd
from functools import reduce
n=int(input())
a=list(map(int,input().split()))
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
k=0
m=lcm_list(l)-1
for i in range(n):
    k+=m%l[i]
print(k)

Fixed submission:
from fractions import gcd
from functools import reduce
n=int(input())
a=list(map(int,input().split()))
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
k=0
m=lcm_list(a)-1
for i in range(n):
    k+=m%a[i]
print(k)

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
n=int(input())
a=list(map(int,input().split()))
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
k=0
m=lcm_list(l)-1
for i in range(n):
    k+=m%l[i]
print(k)

Fixed submission:
from fractions import gcd
from functools import reduce
n=int(input())
a=list(map(int,input().split()))
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
k=0
m=lcm_list(a)-1
for i in range(n):
    k+=m%a[i]
print(k)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(m)]
l.sort(key=lambda x:x[1])
lb=0
ans=0
for a,b in l:
    if a>=lb:
        lb=b
        ans+=1
print(ans)

Fixed submission:
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
l.sort(key=lambda x:x[1])
lb=0
c=0
for a,b in l:
    if a>=lb:
        lb=b
        c+=1
print(c)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=map(int,input().split())
print(max(a)-min(a))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
print(max(a)-min(a))

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[map(int,input().split())]
print(max(a)-min(a))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
print(max(a)-min(a))

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for _ in range(n)]
print(max(a)-min(a))


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
print(max(a)-min(a))
Buggy python submission (verdict: Runtime Error):
n=input()
n1=int(n)
n=list(n)
k=0
for i in range(len(n)):
    k+=int(a[i])
if n1%k==0:print('Yes')
else:print('No')


Fixed submission:
n=input()
n1=int(n)
n=list(n)
k=0
for i in range(len(n)):
    k+=int(n[i])
if n1%k==0:print('Yes')
else:print('No')
Buggy python submission (verdict: Runtime Error):
import numpy as np
n=int(input())
a=list(map(int,input().split()))
a1=[i for i in a if i % 2 == 0]
a1=np.array(a1)
p=np.prod(a1, axis = 0)
k=0
while True:
    if p%2==0:k+=1
    else:break
print(k)

Fixed submission:
#import sys
#input()=sys.stdin.readline()
n=int(input())
a=list(map(int,input().split()))
k=0
for i in range(len(a)):
    while True:
        if a[i]%2==0:
            a[i]/=2
            k+=1
        else:break
print(k)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a1=[i for i in a if i % 2 == 0]
a1=np.array(a1)
p=np.prod(a1, axis = 0)
k=0
while True:
    if p%2==0:k+=1
    else:break
print(k)

Fixed submission:
#import sys
#input()=sys.stdin.readline()
n=int(input())
a=list(map(int,input().split()))
k=0
for i in range(len(a)):
    while True:
        if a[i]%2==0:
            a[i]/=2
            k+=1
        else:break
print(k)
Buggy python submission (verdict: Runtime Error):
n=int(input())
k=n-999
if n<=999:print('ABC'+str(n).fill(3))
else:print('ABD'+ str(k).zfill(3))

Fixed submission:
n=int(input())
if n<=999:print('ABC')
else:print('ABD')

Buggy python submission (verdict: Runtime Error):
n=int(input())
k=n-999
if n<=999:print('ABC'+str(n.fill(3)))
else:print('ABD'+ str(k.zfill(3)))


Fixed submission:
n=int(input())
if n<=999:print('ABC')
else:print('ABD')
Buggy python submission (verdict: Runtime Error):
n,x=map(int,input().split())
m=[int(input()) for _ in range(n)]
s=x-sum(m)
print(m+s//min(m))

Fixed submission:
n,x=map(int,input().split())
m=[int(input()) for _ in range(n)]
s=x-sum(m)
print(s//min(m) + len(m))
Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
l=list(range(a,b+1))
l1=[]
for i in range(k):
    print(l[i])
    l1.append(l[i])
for j in range(b-k+1,b+1):
    if l[j] not in l1:print(l[j])
    else:pass

Fixed submission:
a,b,k=map(int,input().split())
if k <= (b-a+1)//2:
  for i in range(a, a+k):
    print(i)
  for i in range(b-k+1,b+1):
    print(i)
else:
  for i in range(a,b+1):
    print(i)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
s = list(input() for _ in range(n))
m=int(input())
t = list(input() for _ in range(m))

def list_difference(s,t):
    l = s.copy()
    for value in t:
        if value in l:
            l.remove(value)

    return l
l=list_difference(s,t)
l1=Counter(l)
print(l1.most_common()[0][1])

Fixed submission:
from collections import Counter
n=int(input())
s = [input() for _ in range(n)]
m=int(input())
t = [input() for _ in range(m)]

def list_difference(s,t):
    l = s.copy()
    for value in t:
        if value in l:
            l.remove(value)
    return l
l=list_difference(s,t)
l1=Counter(l)
if len(l)>0:print(l1.most_common()[0][1])
else:print(0)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s = list(input() for _ in range(n))
m=int(input())
t = list(input() for _ in range(m))

def list_difference(s,t):
    l = s.copy()
    for value in t:
        if value in l:
            l.remove(value)

    return l
l=list_difference(s,t)
l1=Counter(l)
print(l1.most_common()[0][1])

Fixed submission:
from collections import Counter
n=int(input())
s = [input() for _ in range(n)]
m=int(input())
t = [input() for _ in range(m)]

def list_difference(s,t):
    l = s.copy()
    for value in t:
        if value in l:
            l.remove(value)
    return l
l=list_difference(s,t)
l1=Counter(l)
if len(l)>0:print(l1.most_common()[0][1])
else:print(0)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s = list(input() for _ in range(n))
m=int(input())
t = list(input() for _ in range(m))

def list_difference(s,t):
    l = s.copy()
    for value in t:
        if value in l:
            l.remove(value)

    return l
l=list_difference(s,t)
print(l.most_common()[0][1])

Fixed submission:
from collections import Counter
n=int(input())
s = [input() for _ in range(n)]
m=int(input())
t = [input() for _ in range(m)]

def list_difference(s,t):
    l = s.copy()
    for value in t:
        if value in l:
            l.remove(value)
    return l
l=list_difference(s,t)
l1=Counter(l)
if len(l)>0:print(l1.most_common()[0][1])
else:print(0)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s = list(input() for _ in range(n))
m=int(input())
t = list(input() for _ in range(m))

def list_difference(s,t):
    l = s.copy()
    for value in t:
        if value in l:
            l.remove(value)

    return l
print(l.most_common()[0][1])

Fixed submission:
from collections import Counter
n=int(input())
s = [input() for _ in range(n)]
m=int(input())
t = [input() for _ in range(m)]

def list_difference(s,t):
    l = s.copy()
    for value in t:
        if value in l:
            l.remove(value)
    return l
l=list_difference(s,t)
l1=Counter(l)
if len(l)>0:print(l1.most_common()[0][1])
else:print(0)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input())
l=list(range(a,b+1))
s=[]
for i in range(len(l)):
    if str(l[i])[0]==str(l[i])[4] and str(l[i])[1]==str(l[i])[3]:s.append(l[i])
print(len(s))

Fixed submission:
a,b=map(int,input().split())
l=list(range(a,b+1))
s=[]
for i in range(len(l)):
    if str(l[i])[0]==str(l[i])[4] and str(l[i])[1]==str(l[i])[3]:s.append(l[i])
print(len(s))
Buggy python submission (verdict: Runtime Error):
from itertools import combinations as c
n=int(input())
s=[input() for _ in range(n)]
m=[m1 for m1 in s if s.startswith('M')]
a=[a1 for a1 in s if s.startswith('A')]
r=[r1 for r1 in s if s.startswith('R')]
c=[c1 for c1 in s if s.startswith('C')]
h=[h1 for h1 in s if s.startswith('H')]
march=[len(m),len(a),len(r),len(c),len(h)]
print(sum(i*j*k for i, j, k in c(march, 3)))

Fixed submission:
from itertools import combinations as c
n=int(input())
s=[input() for _ in range(n)]
march=[0]*5
for i in range(n):
    if s[i][0]=='M':march[0]+=1
    elif s[i][0]=='A':march[1]+=1
    elif s[i][0]=='R':march[2]+=1
    elif s[i][0]=='C':march[3]+=1
    elif s[i][0]=='H':march[4]+=1
print(sum(i*j*k for i, j, k in c(march, 3)))
Buggy python submission (verdict: Runtime Error):
n-int(input())
a=int(input())
k = n%500
if k<=a:print('Yes')
else:print('No')

Fixed submission:
n=int(input())
a=int(input())
k = n%500
if k<=a:print('Yes')
else:print('No')
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=[list(map(int,input().split()))]
l1=[0]*n
for i in range(n-1):
    l1[i]+=l[i][0]+l[i][1]
    for j in range(1,n-i-1):
        if l1[i]<l[i+j][1]:
            l1[i]-=l1[i]
            l1[i]+=l[i+j][1]
            
        if l1[i]>=l[i+j][1] and (l1[i]-l[i+j][1])%l[i+j][2]!=0:
            l1[i]+=((l[i+j][1]%l[i+j][2])+(l[i+j][2]*l1[i]))%l1[i]
            
        if l1[i]>=l[i+j][1] and (l1[i]-l[i+j][1])%l[i+j][2]==0:
            l1[i]+=l[i+j][0]
    print(l1[i])
print(0)

Fixed submission:
import math

n = int(input())
csf = [list(map(int, input().split())) for i in range(n-1)]
ANS = []
for i in range(n):
  ans = 0
  for c,s,f in csf[i:]:
    if ans <= s:
      ans = s + c
    else:
      ans = s + math.ceil((ans-s)/f) * f + c
  ANS.append(ans)
for i in ANS:
  print(i)
Buggy python submission (verdict: Runtime Error):
q=int(input())
pn=[2]
qn=[0]*10**5+1
c=0
for i in range(1, 10**5+1,2):
    for i2 in pn:
        if i % i2 == 0:
            break
        else:
            pn.append(i)
for i in range(10**5+1):
    if (pn[i]+1)/2 in pn:
        c+=1
    qn[i]=c
for _ in range(q):
    l,r = map(int, input().split())
    print(qn[r]-qn[l-1])

Fixed submission:
q = int(input())
k = 10**5+1
x = [0]*k
def sieve(n):
    prime = [True] * (n+1)
    prime[0] = prime[1] = False
    for i in range(2, n+1):
        if prime[i]:
            for j in range(i*2, n+1, i):
                prime[j] = False
    return prime

p = sieve(k+1)
c = 0
for i in range(3, k):
    if p[i] and p[(i+1)//2]:
        c += 1
    x[i] = c

for _ in range(q):
    l, r = map(int, input().split())
    print(x[r] - x[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
q=int(input())
pn=[2]
qn=[0]*10**5
c=0
for i in range(1, 10**5+1):
    for i2 in pn:
        if i % i2 == 0:
            qn[i]=c
            break
        else:
            pn.append(i)
            qn[i]=c        
            if (i+1)/2 in pn:
                c+=1
                qn[i]=c

for _ in range(q):
    l,r = map(int, input().split())
    print(qn[r]-qn[l-1])

Fixed submission:
q = int(input())
k = 10**5+1
x = [0]*k
def sieve(n):
    prime = [True] * (n+1)
    prime[0] = prime[1] = False
    for i in range(2, n+1):
        if prime[i]:
            for j in range(i*2, n+1, i):
                prime[j] = False
    return prime

p = sieve(k+1)
c = 0
for i in range(3, k):
    if p[i] and p[(i+1)//2]:
        c += 1
    x[i] = c

for _ in range(q):
    l, r = map(int, input().split())
    print(x[r] - x[l-1])

Buggy python submission (verdict: Runtime Error):
q=int(input())
lr=[list(map(int,input().split())) for _ in range(q)]
pn=[2]
for L in range(3, 10**5, 2):
    for L2 in pn:
        if L % L2 == 0:
            break
    else:
        if (L+1)/2 in pn:
            pn.append(L)
pn.pop(0)
for i in range(q):
    print(len([i for i in pn if lr[i][0]<=i<=lr[i][1]]))

Fixed submission:
q = int(input())
k = 10**5+1
x = [0]*k
def sieve(n):
    prime = [True] * (n+1)
    prime[0] = prime[1] = False
    for i in range(2, n+1):
        if prime[i]:
            for j in range(i*2, n+1, i):
                prime[j] = False
    return prime

p = sieve(k+1)
c = 0
for i in range(3, k):
    if p[i] and p[(i+1)//2]:
        c += 1
    x[i] = c

for _ in range(q):
    l, r = map(int, input().split())
    print(x[r] - x[l-1])
Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
n1=list(range(1,n+1))
k=[]
for j in range(n):
    n2=sum(int(i) for i in n1[j])
    if a<=n2<=b:k.append(n1[j])
    else:pass
print(sum(int(l) for l in k))


Fixed submission:
n,a,b=map(int,input().split())
k=0
for i in range(n+1):
    n1=list(str(i))
    n2=sum(int(j) for j in n1)
    if a<=n2<=b:k+=i
    else:pass
print(k)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
print(math.ceil((a+b)//2))

Fixed submission:
import math
a,b = map(int,input().split())
print(math.ceil((a+b)/2))

Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
print(math.floor((a+b)/2))

Fixed submission:
import math
a,b = map(int,input().split())
print(math.ceil((a+b)/2))
Buggy python submission (verdict: Runtime Error):
a=int(k[0])
b=int(k[1])
c=int(k[2])
d=int(k[3])
if (a+b+c+d)==7:print(k[0]+'+'+k[1]+'+'+k[2]+'+'+k[3]+'='+'7')
elif (a-b+c+d)==7:print(k[0]+'-'+k[1]+'+'+k[2]+'+'+k[3]+'='+'7')
elif (a+b-c+d)==7:print(k[0]+'+'+k[1]+'-'+k[2]+'+'+k[3]+'='+'7')
elif (a+b+c-d)==7:print(k[0]+'+'+k[1]+'+'+k[2]+'-'+k[3]+'='+'7')
elif (a-b-c+d)==7:print(k[0]+'-'+k[1]+'-'+k[2]+'+'+k[3]+'='+'7')
elif (a+b-c-d)==7:print(k[0]+'+'+k[1]+'-'+k[2]+'-'+k[3]+'='+'7')
elif (a-b+c-d)==7:print(k[0]+'-'+k[1]+'+'+k[2]+'-'+k[3]+'='+'7')
elif (a-b-c-d)==7:print(k[0]+'-'+k[1]+'-'+k[2]+'-'+k[3]+'='+'7')

Fixed submission:
k=input()
a=int(k[0])
b=int(k[1])
c=int(k[2])
d=int(k[3])
if (a+b+c+d)==7:print(k[0]+'+'+k[1]+'+'+k[2]+'+'+k[3]+'='+'7')
elif (a-b+c+d)==7:print(k[0]+'-'+k[1]+'+'+k[2]+'+'+k[3]+'='+'7')
elif (a+b-c+d)==7:print(k[0]+'+'+k[1]+'-'+k[2]+'+'+k[3]+'='+'7')
elif (a+b+c-d)==7:print(k[0]+'+'+k[1]+'+'+k[2]+'-'+k[3]+'='+'7')
elif (a-b-c+d)==7:print(k[0]+'-'+k[1]+'-'+k[2]+'+'+k[3]+'='+'7')
elif (a+b-c-d)==7:print(k[0]+'+'+k[1]+'-'+k[2]+'-'+k[3]+'='+'7')
elif (a-b+c-d)==7:print(k[0]+'-'+k[1]+'+'+k[2]+'-'+k[3]+'='+'7')
elif (a-b-c-d)==7:print(k[0]+'-'+k[1]+'-'+k[2]+'-'+k[3]+'='+'7')
Buggy python submission (verdict: Runtime Error):
n,a=map(int,input().split('/n'))
print((n**2) -a )

Fixed submission:
N = int(input())
A = int(input())
print(N**2-A)

Buggy python submission (verdict: Runtime Error):
n,a=map(int,input().splitlines())
print((n**2) -a )

Fixed submission:
N = int(input())
A = int(input())
print(N**2-A)

Buggy python submission (verdict: Runtime Error):
n,a=map(int,input().split())
print((n**2) -a )

Fixed submission:
N = int(input())
A = int(input())
print(N**2-A)
Buggy python submission (verdict: Runtime Error):
n=int(input())
k=int(input())
x=map(int,input().split())
l=[]
for i in range(n):
    p=2*min(x[i],k-x[i])
    l.append(p)
print(sum(l))

Fixed submission:
n=int(input())
k=int(input())
x=list(map(int,input().split()))
l=[]
for i in range(n):
    p=2*min(x[i],k-x[i])
    l.append(p)
print(sum(l))
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
input = sys.stdin.readline
n=int(input())
l=[0]*10**5
for i in range(n):
    a=int(input())
    l[a-1]+=1
l1=np.array(l)
print(np.count_nonzero(l1%2==1))

Fixed submission:
import sys
P=set()
N=int(input())
for s in sys.stdin.readlines():
    n = int(s)
    if n in P:
        P.remove(n)
    else:
        P.add(n)
print(len(P))

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
input = sys.stdin.readline
n=int(input())
l=[0]*10**5
for i in range(n):
    a=int(input())
    l[a-1]+=1
l1=np.array(l)
l2=l%2
l2.count('1')

Fixed submission:
import sys
P=set()
N=int(input())
for s in sys.stdin.readlines():
    n = int(s)
    if n in P:
        P.remove(n)
    else:
        P.add(n)
print(len(P))
Buggy python submission (verdict: Runtime Error):
s=input()
k=[]
if len(s)%2==0:
   for i in range(len(s)/2):
       k.append(s[2*i])
else:
    for i in range((len(s)//2)+1):
        k.append(s[2*i])
print("".join(k))

Fixed submission:
s = list(input())
k = s[::2]
print("".join(k))

Buggy python submission (verdict: Runtime Error):
s=list(map(input()))
k=[]
if len(s)%2==0:
   for i in range(len(s)/2):
       k.append(s[2*i])
else:
    for i in range((len(s)//2)+1):
        k.append(s[2*i])
print("".join(k))

Fixed submission:
s = list(input())
k = s[::2]
print("".join(k))

Buggy python submission (verdict: Runtime Error):
s=list(input())
k=[]
if len(s)%2==0:
   for i in range(len(s)/2):
       k.append(s[2*i])
else:
    for i in range((len(s)//2)+1):
        k.append(s[2*i])
print("".join(k))

Fixed submission:
s = list(input())
k = s[::2]
print("".join(k))
Buggy python submission (verdict: Runtime Error):
x,a,b=map(int,input().split())
if |a-x|<|b-x|:print('A')
else:print('B')

Fixed submission:
x,a,b=map(int,input().split())
if abs(a-x)<abs(b-x):print('A')
else:print('B')
Buggy python submission (verdict: Runtime Error):
n,k=map(int(input().split()))
l=list(map(int,input().split()))
l1 = sorted(l, reverse=True)
s=0
for i in range(k):
    s+=l1[i]
print(s)

Fixed submission:
n,k=map(int,input().split())
l=list(map(int,input().split()))
l1 = sorted(l, reverse=True)
s=0
for i in range(k):
    s+=l1[i]
print(s)

Buggy python submission (verdict: Runtime Error):
n,k=int(input().split())
l=list(map(int,input().split()))
l1 = sorted(l, reverse=True)
s=0
for i in range(k):
    s+=l1[i]
print(s)

Fixed submission:
n,k=map(int,input().split())
l=list(map(int,input().split()))
l1 = sorted(l, reverse=True)
s=0
for i in range(k):
    s+=l1[i]
print(s)

Buggy python submission (verdict: Runtime Error):
n,k=int(input().split())
l=list(map(int,input()))
l1 = sorted(l, reverse=True)
s=0
for i in range(k):
    s+=l1[i]
print(s)

Fixed submission:
n,k=map(int,input().split())
l=list(map(int,input().split()))
l1 = sorted(l, reverse=True)
s=0
for i in range(k):
    s+=l1[i]
print(s)

Buggy python submission (verdict: Runtime Error):
n,k=int(input())
l=list(map(int,input()))
l.sort()
s=0
for i in range(k):
    s+=l[i]
print(s)

Fixed submission:
n,k=map(int,input().split())
l=list(map(int,input().split()))
l1 = sorted(l, reverse=True)
s=0
for i in range(k):
    s+=l1[i]
print(s)

Buggy python submission (verdict: Runtime Error):
n,k=int(input())
l=list(map(int,input().split()))
l.sort()
s=0
for i in range(k):
    s+=l[i]
print(s)
    

Fixed submission:
n,k=map(int,input().split())
l=list(map(int,input().split()))
l1 = sorted(l, reverse=True)
s=0
for i in range(k):
    s+=l1[i]
print(s)
Buggy python submission (verdict: Runtime Error):
x,a,b=int(input().split())
if a-b>=0:print('delicious')
elif a-b < 0 and a+x>=b:print('safe')
else:print('dangerous')

Fixed submission:
x,a,b=map(int,input().split())
if a-b>=0:print('delicious')
elif a-b < 0 and a+x>=b:print('safe')
else:print('dangerous')
Buggy python submission (verdict: Runtime Error):
n=int(input())
a = [map(int,input() for _ in range(n))]
nex=[]
k=1
for i in range(len(a)):
    nex.append(a[k-1])
    k=nex[-1]
    if nex[-1]==2:
        print(len(nex))
        break
    elif len(nex)>=n:print(-1)
    else:pass

Fixed submission:
n=int(input())
a = [int(input()) for _ in range(n)]
nex=[]
k=1
for i in range(len(a)):
    nex.append(a[k-1])
    k=nex[-1]
    if nex[-1]==2:
        print(len(nex))
        break
    elif len(nex)>=n:print(-1)
    else:pass

Buggy python submission (verdict: Runtime Error):
n=int(input())
a = [map(int,input()) for _ in range(n)]
nex=[]
k=1
for i in range(len(a)):
    nex.append(a[k-1])
    k=nex[-1]
    if nex[-1]==2:
        print(len(nex))
        break
    elif len(nex)>=n:print(-1)
    else:pass

Fixed submission:
n=int(input())
a = [int(input()) for _ in range(n)]
nex=[]
k=1
for i in range(len(a)):
    nex.append(a[k-1])
    k=nex[-1]
    if nex[-1]==2:
        print(len(nex))
        break
    elif len(nex)>=n:print(-1)
    else:pass

Buggy python submission (verdict: Runtime Error):
n=int(input())
a = [input() for _ in range(n)]
nex=[]
k=1
for i in range(len(a)):
    nex.append(a[k-1])
    k=nex[-1]
    if nex[-1]==2:
        print(len(nex))
        break
    elif len(nex)>=n:print(-1)
    else:pass

Fixed submission:
n=int(input())
a = [int(input()) for _ in range(n)]
nex=[]
k=1
for i in range(len(a)):
    nex.append(a[k-1])
    k=nex[-1]
    if nex[-1]==2:
        print(len(nex))
        break
    elif len(nex)>=n:print(-1)
    else:pass

Buggy python submission (verdict: Runtime Error):
from itertools import chain
n=int(input())
an= [list(input()) for _ in range(n)]
a=list(chain.from_iterable(an))
nex=[]
k=1
for i in range(len(a)):
    #if k-1==-1:k-1=0
    nex.append(a[k-1])
    k=nex[-1]
    if nex[-1]==2:
        print(len(nex))
        break
    elif len(nex)>=n:print(-1)
    else:pass

Fixed submission:
n=int(input())
a = [int(input()) for _ in range(n)]
nex=[]
k=1
for i in range(len(a)):
    nex.append(a[k-1])
    k=nex[-1]
    if nex[-1]==2:
        print(len(nex))
        break
    elif len(nex)>=n:print(-1)
    else:pass

Buggy python submission (verdict: Runtime Error):
n=int(input())
a= [list(input()) for _ in range(n)]
nex=[]
k=1
for i in range(len(a)):
    #if k-1==-1:k-1=0
    nex.append(a[k-1])
    k=nex[-1]
    if nex[-1]==2:
        print(len(nex))
        break
    elif len(nex)>=n:print(-1)
    else:pass

Fixed submission:
n=int(input())
a = [int(input()) for _ in range(n)]
nex=[]
k=1
for i in range(len(a)):
    nex.append(a[k-1])
    k=nex[-1]
    if nex[-1]==2:
        print(len(nex))
        break
    elif len(nex)>=n:print(-1)
    else:pass