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

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n,k=n1()
H=n1()

dp=[float("inf")]*n
dp[0]=0
for i in range(0,n):
    for j in range(1,k+1):
        if i+j<n:
            dp[i+j]=min(dp[i+j],dp[i]+abs(H[i]-H[i+j]))

print(dp[n-1])

Fixed submission:

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n,k=n1()
H=n1()

dp=[float("inf")]*n
dp[0]=0
for i in range(0,n):
    for j in range(1,k+1):
        if i+j<n:
            dp[i+j]=min(dp[i+j],dp[i]+abs(H[i]-H[i+j]))

print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n,w=n1()
WV=n3(n)

W=[0]
W.extend([x[0] for x in WV])
V=[0]
V.extend([x[1] for x in WV])

dp=[[0]*(w+1) for _ in range(n+1)]
for i in range(1,n+1):
    for j in range(1,w+1):
        if j-W[i]>=0:
            dp[i][j]=max(dp[i-1][j-W[i]]+V[i],dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]
print(dp[-1][-1])

Fixed submission:

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n,w=n1()
WV=n3(n)

W=[0]
W.extend([x[0] for x in WV])
V=[0]
V.extend([x[1] for x in WV])

dp=[[0]*(w+1) for _ in range(n+1)]
for i in range(1,n+1):
    for j in range(1,w+1):
        if j-W[i]>=0:
            dp[i][j]=max(dp[i-1][j-W[i]]+V[i],dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]
print(dp[-1][-1])
Buggy python submission (verdict: Time Limit Exceeded):

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n,w=n1()
WV=n3(n)

W=[0]
W.extend([x[0] for x in WV])
V=[0]
V.extend([x[1] for x in WV])

max_v=sum(V)
dp=[[0]+[float("inf")]*(max_v) for _ in range(n+1)]

for i in range(1,n+1):
    for j in range(1,max_v+1):
        if j-V[i]>=0:
            dp[i][j]=min(dp[i-1][j-V[i]]+W[i],dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]
#     print(dp[i])

for i in range(max_v+1):
    if dp[n][i]<=w:
        ans=i
print(ans)

Fixed submission:

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n,w=n1()
WV=n3(n)

W=[0]
W.extend([x[0] for x in WV])
V=[0]
V.extend([x[1] for x in WV])

max_v=sum(V)
dp=[[0]+[float("inf")]*(max_v) for _ in range(n+1)]

for i in range(1,n+1):
    for j in range(1,max_v+1):
        if j-V[i]>=0:
            dp[i][j]=min(dp[i-1][j-V[i]]+W[i],dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]
#     print(dp[i])

for i in range(max_v+1):
    if dp[n][i]<=w:
        ans=i
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
s=s0()
t=s0()

len_s=len(s)
len_t=len(t)

dp=[[0]*(len_t+1) for _ in range(len_s+1)]
for i in range(len_s):
    for j in range(len_t):
        if s[i]==t[j]:
            dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1],dp[i][j]+1)
        else:
            dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1])

# print(dp)

#reverse
ans = ""
i = len_s
j = len_t
while (i>0  and j>0):
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans += s[i-1] 
        i -= 1
        j -= 1
print(ans[::-1])

Fixed submission:

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
s=s0()
t=s0()

len_s=len(s)
len_t=len(t)

dp=[[0]*(len_t+1) for _ in range(len_s+1)]
for i in range(len_s):
    for j in range(len_t):
        if s[i]==t[j]:
            dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1],dp[i][j]+1)
        else:
            dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1])

# print(dp)

#reverse
ans = ""
i = len_s
j = len_t
while (i>0  and j>0):
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans += s[i-1] 
        i -= 1
        j -= 1
print(ans[::-1])
Buggy python submission (verdict: Runtime Error):
N=int(input())
t=[[int(x) for x in input().split()] for i in range(0,N)]

def func(N,t):
    if (t[0][0]-(t[0][1]+t[0][2]))%2==1 or t[0][0]-(t[0][1]+t[0][2])<0 : return "No"
    
    for i in range(1,N):
        if ((t[i][0]-t[i-1][0])-(abs(t[i][1]-t[i-1][1])+abs(t[i][2]-t[i-1][2])))%2==1 and ((t[i][0]-t[i-1][0])-(abs(t[i][1]-t[i-1][1])+abs(t[i][2]-t[i-1][2])))<0 : return "No"
    
    return "Yes"
    
print(func(N,t))

Fixed submission:
a,b = [int(x) for x in input().split()]

if (a*b)%2==0:
    print("Even")
else:
    print("Odd")
Buggy python submission (verdict: Runtime Error):
N=int(input())
t=[[int(x) for x in input().split()] for i in range(0,N)]

def func(N,t):
    if (t[0][0]-(t[0][1]+t[0][2]))%2==1 or t[0][0]-(t[0][1]+t[0][2])<0 : return "No"
    
    for i in range(1,N+1):
        if ((t[i][0]-t[i-1][0])-(abs(t[i][1]-t[i-1][1])+abs(t[i][2]-t[i-1][2])))%2==1 or ((t[i][0]-t[i-1][0])-(abs(t[i][1]-t[i-1][1])+abs(t[i][2]-t[i-1][2])))<0 : return "No"
    
    return "Yes"
    
print(func(N,t))

Fixed submission:
N=int(input())
t=[[int(x) for x in input().split()] for i in range(0,N)]

def func(N,t):
    if (t[0][0]-(t[0][1]+t[0][2]))%2==1 or t[0][0]-(t[0][1]+t[0][2])<0 : return "No"
    
    for i in range(1,N):
        if ((t[i][0]-t[i-1][0])-(abs(t[i][1]-t[i-1][1])+abs(t[i][2]-t[i-1][2])))%2==1 or ((t[i][0]-t[i-1][0])-(abs(t[i][1]-t[i-1][1])+abs(t[i][2]-t[i-1][2])))<0 : return "No"
    
    return "Yes"
    
print(func(N,t))
Buggy python submission (verdict: Runtime Error):
S=input()

def func(S):
    if S[:7]=="dreamer":
        return min(func(S[5:]),func(S[7:]))
    elif S[:6]=="eraser":
        return min(func(S[5:]),func(S[6:]))
    elif S[:5]=="dream":
        return func(S[5:])
    elif S[:5]=="erase":
        return func(S[5:])
    
    return len(S) 
    

if func(S)==0:
    print("YES")
else:
    print("NO")

Fixed submission:
S=input()

l=len(S)

while True:
    if S[-7:]=="dreamer":
        S=S[:-7] 
    elif S[-6:]=="eraser":
        S=S[:-6]
    elif S[-5:]=="dream":
        S=S[:-5]
    elif S[-5:]=="erase":
        S=S[:-5]

    if l==len(S):
        break
    else:
        l=len(S)


if l==0:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
import math
n=int(input())
a=list(map(int,input().split(' ')))
l={}
m=0
for i in a:
  l[i]=l.get(i,0)+1
  if i > m:
    m = i
fl={}
for i in range(1, m+1):
  try:
    fl[i]=math.factorial(l[i])//(math.factorial(l[i]-2)*2)
  except:
    fl[i]=0
s=sum(fl.values())
for i in a:
  buf = fl[i]
  if l[i]>=3:
    c = math.factorial(l[i]-1)//(math.factorial(l[i]-3)*2)
  else:
    c = 0
  print(s-fl[i]+c)

Fixed submission:
import math
n=int(input())
a=list(map(int,input().split(' ')))
l={}
fl={}
for i in a:
  l[i]=l.get(i,0)+1
  fl[i]=(l.get(i,0)*(l.get(i,0)-1))//2
s=sum(fl.values())
for i in a:
  buf = (l[i]-1)*(l[i]-2)//2
  print(s-fl[i]+buf)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
d = deque()
d.extend(input())
q = int(input())
for i in range(q):
  qu = input().split()
  if qu[0] == "1":
    d.reverse()
  else:
    if qu[1] == "1":
      d.extendleft(qu[2])
    else:
      d.extend(qu[2])

print(''.join(list(d)))


Fixed submission:
from collections import deque
d = deque()
d.extend(input())
q = int(input())
r = False
for i in range(q):
  qu = input().split()
  if qu[0] == "1":
    r = not r
  else:
    if (qu[1] == "1" and not r) or (qu[1] == "2" and r):
      d.extendleft(qu[2])
    else:
      d.extend(qu[2])

if r:
  d.reverse()

print(''.join(list(d)))
Buggy python submission (verdict: Time Limit Exceeded):
input()
s = input()
i = s.find('ABC')
n = 0
while i != -1:
  i = s.find('ABC'[i+3:])
print(n)


Fixed submission:
input()
s = input()
n = 0
i = 0
while i != -1:
  i = s.find('ABC')
  s = s[i+3:]
  n += 1
print(n-1)
Buggy python submission (verdict: Runtime Error):
r =int(intput())
print(r**2)

Fixed submission:
r =int(input())
print(r**2)
Buggy python submission (verdict: Runtime Error):
n = int(input())
if(n%2==1):
  print("No")
else:
  s = input()
  a = s[:n/2]
  b = s[n/2:]
  if(a==b):
    print("Yes")
  else:
    print("No")

Fixed submission:
n = int(input())
s = input()
#print(n,s)
if(n%2==1):
  print("No")
else:
  a = s[:n//2]
  b = s[n//2:]
  if(a==b):
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
if a*b%2==0:
    print("Even")
else:
    print("Odd")

Fixed submission:
a, b = map(int, input().split())
if a*b%2==0:
    print("Even")
else:
    print("Odd")
Buggy python submission (verdict: Runtime Error):
if __name__ == "__main__":
    main()


def main():
    x = int(input())
    if x:
        print(0)
    else:
        print(1)


Fixed submission:
x = int(input())
if x:
    print(0)
else:
    print(1)

Buggy python submission (verdict: Runtime Error):
x = int(input())
if x:
  print(0)
 else:
  print(1)

Fixed submission:
x = int(input())
if x:
    print(0)
else:
    print(1)
Buggy python submission (verdict: Runtime Error):
s = input()
b = len(s)
c = 0
f = 0
while True:
    if f == b:
        break
    elif b - f <= 2:
        f = 0
        b -= 1
    else:
        if int(s[f:b]) % 2019 == 0:
            c += 1
            f += 1
        else:
            f += 1
print(c)


Fixed submission:
S, W = map(int, input().split())
if W >= S:
    print("unsafe")
else:
    print("safe")

Buggy python submission (verdict: Runtime Error):
S, W = map(int, input().split())
if W>=S:
  print("unsafe")
 else:
  print("safe")

Fixed submission:
S, W = map(int, input().split())
if W >= S:
    print("unsafe")
else:
    print("safe")
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = []
while True:
    Si = input()
    if Si:
        S.append(Si)
    else:
        break
g = S[: N]
print(g)


Fixed submission:
n = int(input())
s = set(input() for _ in range(n))
print(len(s))
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
from operator import mul

N,K,*A = map(int,open(0).read().split())
base = reduce(mul,A[:K])
for i in range(K,N):
    score = base // A[i-K] * A[i]
    print("Yes" if base < score else "No")
    base = score    
    

Fixed submission:
from functools import reduce
from operator import mul

N,K,*A = map(int,open(0).read().split())
base = sum(A[:K])
for i in range(K,N):
    score = base - A[i-K] + A[i]
    print("Yes" if base < score else "No")
    base = score
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N = int(input())
for n in range(1,N+1):
    if n<6: 
        print(0)
        continue
    cnt = 0
    for x,y in itertools.product(list(range(1,int(n**0.5))),repeat=2):
        zz = n - x*x - y*y
        if zz < 1: continue
        for z in range(1,int(zz**0.5)):
            if n == x*x + y*y +z*z + x*y + y*z + z*x:
                cnt += 1
    print(cnt)
    

Fixed submission:
import itertools

N = int(input())
lst = [0]*N
for x,y,z in itertools.product(list(range(1,int(N**0.5))),repeat=3):
    val = x*x + y*y + z*z + x*y + y*z + z*x
    if val <= N:
        lst[val-1] += 1
print(*lst,sep="\n")

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

N = int(input())
for n in range(1,N+1):
    if n<6: 
        print(0)
        continue
    cnt = 0
    for x,y,z in itertools.product(list(range(1,n)),repeat=3):
        if n == x*x + y*y +z*z + x*y + y*z + z*x:
            cnt += 1
    print(cnt)

Fixed submission:
import itertools

N = int(input())
lst = [0]*N
for x,y,z in itertools.product(list(range(1,int(N**0.5))),repeat=3):
    val = x*x + y*y + z*z + x*y + y*z + z*x
    if val <= N:
        lst[val-1] += 1
print(*lst,sep="\n")
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N,M,K = map(int,input().split())
A = np.array(input().split(),dtype=int)
B = np.array(input().split(),dtype=int)

AA = np.insert(A,0,0)
BB = np.insert(B,0,0)
AAA = np.cumsum(AA)
BBB = np.cumsum(BB)
max_mins = 0
max_books = 0
for a in enumerate(AAA):
    if a[1] > K:
        break
    for b in enumerate(BBB):
        if a[1] + b[1] > K:
            break
        if a[0] + b[0] > max_books:
            max_books = a[0] + b[0]
print(max_books)            


Fixed submission:
import numpy as np
from bisect import bisect

N,M,K = map(int,input().split())
A = np.array(input().split(),dtype=int)
B = np.array(input().split(),dtype=int)

AA = np.insert(A,0,0)
BB = np.insert(B,0,0)
AAA = np.cumsum(AA)
BBB = np.cumsum(BB)
max_books = 0
for a in enumerate(AAA):
    if a[1] > K:
        break
    books = a[0]
    ind = bisect(BBB,K - a[1])
    books += (ind-1)
    max_books = max(books,max_books)
print(max_books)

Buggy python submission (verdict: Runtime Error):
import numpy as np

N,M,K = map(int,input().split())
A = np.array(input().split(),dtype=int)
B = np.array(input().split(),dtype=int)

AA = np.insert(A,0,0)
BB = np.insert(B,0,0)
AAA = np.cumsum(AA)
BBB = np.cumsum(BB)
max_mins = 0
max_books = 0
for a in enumerate(AAA):
    if a[1] > K:
        break
    for b in enumerate(BBB):
        if a[2] + b[1] > K:
            break
        if a[0] + b[0] > max_books:
            max_books = a[0] + b[0]
print(max_books)            


Fixed submission:
import numpy as np
from bisect import bisect

N,M,K = map(int,input().split())
A = np.array(input().split(),dtype=int)
B = np.array(input().split(),dtype=int)

AA = np.insert(A,0,0)
BB = np.insert(B,0,0)
AAA = np.cumsum(AA)
BBB = np.cumsum(BB)
max_books = 0
for a in enumerate(AAA):
    if a[1] > K:
        break
    books = a[0]
    ind = bisect(BBB,K - a[1])
    books += (ind-1)
    max_books = max(books,max_books)
print(max_books)
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
def memoize(f):
    table = {}
    def func(*args):
        if not args in table:
            table[args] = f(*args)
        return table[args]
    return func
    
@memoize 
def soinsuu_bunkai(n):
    ret = {}
    p = 2
    while p * p <= n:
        while n % p == 0:
            ret[p]= ret[p]+1 if p in ret else 1
            n //= p
        p += 1
    if n != 1:
        ret[n] = 1
    return ret    

def yakusuu_no_kosuu(dic):
    return reduce(lambda x,y:x*y,map(lambda x:x+1,[v for (k,v) in dic.items()]))
    
ans = 0    
for i in range(2,int(input())+1):
    so = soinsuu_bunkai(i)
    if yakusuu_no_kosuu(so):
        ans += i * yakusuu_no_kosuu(so) 
    else:
        ans += 1
print(ans+1)    


Fixed submission:
def g(num):
    return (num*(num+1)) // 2

def f(num):
    return num * g(n//num)

n = int(input())
ans = 0
for i in range(1,n+1):
    ans += f(i)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
def soinsuu_bunkai(n):
    ret = {}
    p = 2
    while p * p <= n:
        while n % p == 0:
            ret[p]= ret[p]+1 if p in ret else 1
            n //= p
        p += 1
    if n != 1:
        ret[n] = 1
    return ret    

def yakusuu_no_kosuu(dic):
    return reduce(lambda x,y:x*y,map(lambda x:x+1,[v for (k,v) in dic.items()]))
    
ans = 0    
for i in range(2,int(input())+1):
    so = soinsuu_bunkai(i)
    if yakusuu_no_kosuu(so):
        ans += i * yakusuu_no_kosuu(so) 
    else:
        ans += 1
print(ans+1)    


Fixed submission:
def g(num):
    return (num*(num+1)) // 2

def f(num):
    return num * g(n//num)

n = int(input())
ans = 0
for i in range(1,n+1):
    ans += f(i)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N,K,*p = map(int,open(0).read().split())
print(min(map(lambda x: sum(x),itertools.combinations(p,K))))

Fixed submission:
N,K,*p = map(int,open(0).read().split())
p.sort()
print(sum(p[:K]))