Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
a = []
for i in range(N):
    array = list(map(int,input().split()))
    a.append(array)
a.sort()
ans = 0
bought = 0
while bought!=M:
    b=a.pop(0)
    if bought+b[1]>M:
        ans+= b[0]*(M-bought)
        bought=M
        print(ans)
        exit()
    ans += b[0]*b[1]
    bought += b[1]
print(ans)

Fixed submission:
N,M = map(int,input().split())
a = []
for i in range(N):
    array = list(map(int,input().split()))
    a.append(array)
a.sort()
ans = 0
bought = 0
for i in range(N):
    if bought+a[i][1]>M:
        ans+= a[i][0]*(M-bought)
        bought=M
        print(ans)
        exit()
    ans += a[i][0]*a[i][1]
    bought += a[i][1]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def nearestdis(x,y):
    lst_new = [abs(j-x) for j in y]
    return(min(lst_new))
    
a,b,q = map(int,input().split())
lst_s = [int(input()) for i in range(a)]
lst_t = [int(input()) for i in range(b)]
lst_x = [int(input()) for i in range(q)]


for i in lst_x:
    lst_ans = []
    lst_s_x = [abs(j-i) for j in lst_s]
    lst_t_x = [abs(j-i) for j in lst_t]
    min_s = min(lst_s_x)
    min_t = min(lst_t_x)
    if i-min_s in lst_s:
        lst_ans.append(min_s+nearestdis(i-min_s,lst_t))
    if i+min_s in lst_s:
        lst_ans.append(min_s+nearestdis(i+min_s,lst_t))
    if i-min_t in lst_t:
        lst_ans.append(min_t+nearestdis(i-min_t,lst_s))
    if i+min_t in lst_t:
        lst_ans.append(min_t+nearestdis(i+min_t,lst_s))
    print(min(lst_ans))

Fixed submission:
from bisect import bisect
a,b,q=map(int,input().split())
INF=10**11+7
ls=[-INF]+[int(input()) for _ in range(a)]+[INF]
lt=[-INF]+[int(input()) for _ in range(b)]+[INF]
lq=[int(input()) for _ in range(q)]
for i in lq:
    inds=bisect(ls,i)
    indt=bisect(lt,i)
    s1,s2=i-ls[inds-1],ls[inds]-i
    t1,t2=i-lt[indt-1],lt[indt]-i
    print(min(max(s1,t1),max(s2,t2),min(2*s1+t2,s1+2*t2),min(2*t1+s2,t1+2*s2)))
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
l = list(map(int,input().split()))
l_ans = [0,abs(l[1]-l[0])]+[0]*(n-2)
for i in range(2,n):
    tmp1=float("inf")
    for j in range(1,min(i+1,k+1)):
        tmp2=l_ans[i-j]+abs(l[i]-l[i-j])
        if tmp1>tmp2:tmp1=tmp2
    l_ans[i]=tmp1
print(l_ans[::-1][0])

Fixed submission:
n,k = map(int,input().split())
l = list(map(int,input().split()))
l_ans = [0,abs(l[1]-l[0])]+[0]*(n-2)
for i in range(2,n):
    tmp1=float("inf")
    for j in range(1,min(i+1,k+1)):
        tmp2=l_ans[i-j]+abs(l[i]-l[i-j])
        if tmp1>tmp2:tmp1=tmp2
    l_ans[i]=tmp1
print(l_ans[::-1][0])

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
l = list(map(int,input().split()))
l_ans = [0,abs(l[1]-l[0])]
for i in range(2,n):
    tmp1=float("inf")
    for j in range(1,min(i+1,k+1)):
        tmp2=l_ans[i-j]+abs(l[i]-l[i-j])
        if tmp1>tmp2:tmp1=tmp2
    l_ans.append(tmp1)
print(l_ans[::-1][0])

Fixed submission:
n,k = map(int,input().split())
l = list(map(int,input().split()))
l_ans = [0,abs(l[1]-l[0])]+[0]*(n-2)
for i in range(2,n):
    tmp1=float("inf")
    for j in range(1,min(i+1,k+1)):
        tmp2=l_ans[i-j]+abs(l[i]-l[i-j])
        if tmp1>tmp2:tmp1=tmp2
    l_ans[i]=tmp1
print(l_ans[::-1][0])

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
l = list(map(int,input().split()))
l_ans = [0,abs(l[1]-l[0])]
for i in range(2,n):
    l_tmp=[]
    for j in range(1,min(i+1,k+1)):l_tmp.append(l_ans[i-j]+abs(l[i]-l[i-j]))
    l_ans.append(min(l_tmp))
print(l_ans[::-1][0])

Fixed submission:
n,k = map(int,input().split())
l = list(map(int,input().split()))
l_ans = [0,abs(l[1]-l[0])]+[0]*(n-2)
for i in range(2,n):
    tmp1=float("inf")
    for j in range(1,min(i+1,k+1)):
        tmp2=l_ans[i-j]+abs(l[i]-l[i-j])
        if tmp1>tmp2:tmp1=tmp2
    l_ans[i]=tmp1
print(l_ans[::-1][0])
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input.split());print(a+b/2)

Fixed submission:
a,b=map(int,input().split());print(int(a+b/2))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
h = []
for i in range(n):
    arr= list(map(int,input().split()))
    h.append(arr[2])
    a.append(arr)


for i in range(101):
    for j in range(101):
        for k in range(min(h),min(h)+201):
            if all(max(k-abs(l[0]-i)-abs(l[1]-j),0) == l[2] for l in a):
                print(i,j,k)
                exit()

Fixed submission:
n = int(input())
a = []
h = []
for i in range(n):
    arr= list(map(int,input().split()))
    h.append(arr[2])
    a.append(arr)
l = [i for i in a if i[2]>0]
xt = l[0][0]
yt = l[0][1]
ht = l[0][2] 
for i in range(101):
    for j in range(101):
        h_ans = ht+abs(xt-i)+abs(yt-j)    
        if all(max(h_ans-abs(l[0]-i)-abs(l[1]-j),0) == l[2] for l in a):
            print(i,j,h_ans)
            exit()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input())
lst_ans=[]
lst_e = []
lst_w = []
for i in range(n):
    lst_e.append(s[:i+1].count("E"))
    lst_w.append(s[:i+1].count("W"))
for i in range(n):
    if i == 0:ans = lst_e[n-1]
    else:ans = (lst_w[i-1]+lst_e[n-1]-lst_e[i])
    lst_ans.append(ans)
print(min(lst_ans))

Fixed submission:
n=int(input())
s=list(input())
n_W,n_E=0,0
l_W,l_E=[0],[0]
for i in s:
    if i=="W":n_W+=1
    else:n_E+=1
    l_W.append(n_W)
    l_E.append(n_E)
ans=10**9+7
for i in range(n):
    tmp=l_W[i]+l_E[-1]-l_E[i+1]
    if tmp<ans:ans=tmp
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input())
lst_ans=[]
for i in range(n):
    lst_w = s[:i]
    lst_e = s[i+1:]
    lst_ans.append(lst_w.count("W")+lst_e.count("E"))
print(min(lst_ans))

Fixed submission:
n=int(input())
s=list(input())
n_W,n_E=0,0
l_W,l_E=[0],[0]
for i in s:
    if i=="W":n_W+=1
    else:n_E+=1
    l_W.append(n_W)
    l_E.append(n_E)
ans=10**9+7
for i in range(n):
    tmp=l_W[i]+l_E[-1]-l_E[i+1]
    if tmp<ans:ans=tmp
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,k=map(int,input().split())
n1=1
n2=0
if a==b:print(0);exit()
for i in range(k):
    n1,n2=n2*2,n1+n2
    if abs((n1-n2)*(a-b))>10**18:print("Unfair");exit()
print((n1-n2)*(a-b))

Fixed submission:
a,b,c,k=map(int,input().split())
t=-1
if k%2==0:t=1
print(t*(a-b))

Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,k=map(int,input().split())
n1=1
n2=0
if a==b:print(0);exit()
for i in range(k):
    n1,n2=n2*2,n1+n2
    if (n1-n2)*(a-b)>10**18:print("Unfair");exit()
print((n1-n2)*(a-b))

Fixed submission:
a,b,c,k=map(int,input().split())
t=-1
if k%2==0:t=1
print(t*(a-b))
Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())
k = int(input())
set_a = set()
for i in range(len(s)+1):
    for j in range(i+1,len(s)+1):
        set_a.add(s[i:j])
print(sorted(set_a)[k-1])

Fixed submission:
s = input()
k = int(input())
set_a = set()
for i in range(len(s)+1):
    for j in range(i+1,min(len(s)+1,i+k+1)):
        set_a.add(s[i:j])
print(sorted(set_a)[k-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())
k = int(input())
set_a = set()
for i in range(len(s)+1):
    for j in range(i+1,len(s)+1):
        set_a.add(s[i:j])
print(sorted(set_a)[k-1])

Fixed submission:
s = input()
k = int(input())
set_a = set()
for i in range(len(s)+1):
    for j in range(i+1,min(len(s)+1,i+k+1)):
        set_a.add(s[i:j])
print(sorted(set_a)[k-1])
Buggy python submission (verdict: Runtime Error):
    a,b=map(int,input().split())
    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):
n,k=map(int,input().split())
if n*K%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):
n,k = map(int,input().split())
lst = list(map(int,input().split()))
lst_com = collections.Counter(lst).most_common()
if len(lst_com)<=k:
    print(0)
    exit()
ans=n
for i in range(k):
    ans -= lst_com[i][1]
print(ans)

Fixed submission:
import collections

n,k = map(int,input().split())
lst = list(map(int,input().split()))
lst_com = collections.Counter(lst).most_common()
if len(lst_com)<=k:
    print(0)
    exit()
ans=n
for i in range(k):
    ans -= lst_com[i][1]
print(ans)
Buggy python submission (verdict: Runtime Error):
n,c=map(int,input().split())
l=[0]*10**5
for i in range(n):
    s,t,c=map(int,input().split())
    l[s-1]+=1
    l[t]-=1
for i in range(10**5-1):
    l[i+1]+=l[i]
print(max(l))

Fixed submission:
n,c=map(int,input().split())
ls=[[set(),set()] for i in range(30)]
l=[0]*(10**5+1)
for i in range(n):
    s,t,c=map(int,input().split())
    if s in ls[c-1][1]:ls[c-1][1].remove(s)
    else:ls[c-1][0].add(s-1)
    if t-1 in ls[c-1][0]:ls[c-1][0].remove(t-1)
    else:ls[c-1][1].add(t)
for i in ls:
    for j in i[0]:
        l[j]+=1
    for j in i[1]:
        l[j]-=1
for i in range(10**5):
    l[i+1]+=l[i]
print(max(l))
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
n4=sum([i%4==0 for i in l])
n2=sum([i%2==0 for i in l])-n4
if n4>=max(n//2,1):
    print("Yes")
else:
    if (n//2)*2-n4*2<=n2:
        print("Yes"):
    else:print("No")

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
n4=sum([i%4==0 for i in l])
n2=sum([i%2==0 for i in l])-n4
if n4>=max(n//2,1):
    print("Yes")
else:
    if (n//2)*2-n4*2<=n2:
        print("Yes")
    else:print("No")
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
n=int(input())
l=list(map(int,input().split()))
l1=[]
l2=[]
ans=[[0]*w for _ in range(h)]
for i in range(n):
    for j in range(i+1):
        l1.append(i+1)
flag=1
for i in range(h):
    for j in range(w):
        if flag==1:
            l2.append([i,j])
        else:
            l2.append([i,w-j-1])
    flag*=(-1)

for i in range(h*w):
        ans[l2[i][0]][l2[i][1]]=l1[i]
for i in ans:
    print(*i)


Fixed submission:
h,w=map(int,input().split())
n=int(input())
l=list(map(int,input().split()))
l1=[]
l2=[]
ans=[[0]*w for _ in range(h)]
for i in range(n):
    for j in range(l[i]):
        l1.append(i+1)

flag=1
for i in range(h):
    for j in range(w):
        if flag==1:
            l2.append([i,j])
        else:
            l2.append([i,w-j-1])
    flag*=(-1)
for i in range(h*w):
        ans[l2[i][0]][l2[i][1]]=l1[i]
for i in ans:
    print(*i)

Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
n=int(input())
l=list(map(int,input().split()))
l1=[]
l2=[]
ans=[[0]*w for _ in range(h)]
for i in range(n):
    for j in range(i+1):
        l1.append(l[i])
flag=1
for i in range(h):
    for j in range(w):
        if flag==1:
            l2.append([i,j])
        else:
            l2.append([i,w-j-1])
    flag*=(-1)

for i in range(h*w):
        ans[l2[i][0]][l2[i][1]]=l1[i]
for i in ans:
    print(*i)

Fixed submission:
h,w=map(int,input().split())
n=int(input())
l=list(map(int,input().split()))
l1=[]
l2=[]
ans=[[0]*w for _ in range(h)]
for i in range(n):
    for j in range(l[i]):
        l1.append(i+1)

flag=1
for i in range(h):
    for j in range(w):
        if flag==1:
            l2.append([i,j])
        else:
            l2.append([i,w-j-1])
    flag*=(-1)
for i in range(h*w):
        ans[l2[i][0]][l2[i][1]]=l1[i]
for i in ans:
    print(*i)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
if m == 1:
    print("IMPOSSIBLE")
    exit()
a = []
for i in range(m):
    arr = list(map(int,input().split()))
    if 1 in arr or n in arr:
        a.append(arr)
l = [i[0] for i in a if i[1]==n]
if len(l)==0:
    print("IMPOSSIBLE")
    exit()
for i in l:
    if [1,i] in a:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Fixed submission:
n,m = map(int,input().split())
if m == 1:
    print("IMPOSSIBLE")
    exit()
a = set()
b = set()
for i in range(m):
    arr = list(map(int,input().split()))
    if 1 in arr:a.add(arr[1])
    if n in arr:b.add(arr[0])
if len(a&b)==0:print("IMPOSSIBLE")
else:print("POSSIBLE")

Buggy python submission (verdict: Runtime Error):
if m == 1:
    print("IMPOSSIBLE")
    exit()
a = []
for i in range(m):
    arr = list(map(int,input().split()))
    if 1 in arr or n in arr:
        a.append(arr)
l = [i[0] for i in a if i[1]==n]
if len(l)==0:
    print("IMPOSSIBLE")
    exit()
for i in l:
    if [1,i] in a:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Fixed submission:
n,m = map(int,input().split())
if m == 1:
    print("IMPOSSIBLE")
    exit()
a = set()
b = set()
for i in range(m):
    arr = list(map(int,input().split()))
    if 1 in arr:a.add(arr[1])
    if n in arr:b.add(arr[0])
if len(a&b)==0:print("IMPOSSIBLE")
else:print("POSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
if m == 1:
    print("IMPOSSIBLE")
    exit()
a = []
for i in range(m):
    arr = list(map(int,input().split()))
    a.append(arr)
l = [i[0] for i in a if i[1]==n]
if len(l)==0:
    print("IMPOSSIBLE")
    exit()
for i in l:
    if [1,i] in a:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Fixed submission:
n,m = map(int,input().split())
if m == 1:
    print("IMPOSSIBLE")
    exit()
a = set()
b = set()
for i in range(m):
    arr = list(map(int,input().split()))
    if 1 in arr:a.add(arr[1])
    if n in arr:b.add(arr[0])
if len(a&b)==0:print("IMPOSSIBLE")
else:print("POSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
if m == 1:
    print("IMPOSSIBLE")
    exit()
a = []
for i in range(m):
    arr = list(map(int,input().split()))
    a.append(arr)
l = [i[1] for i in a if i[0]==1]
for i in l:
    l_2 = [j[1] for j in a if j[0]==i]
    if n in l_2:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Fixed submission:
n,m = map(int,input().split())
if m == 1:
    print("IMPOSSIBLE")
    exit()
a = set()
b = set()
for i in range(m):
    arr = list(map(int,input().split()))
    if 1 in arr:a.add(arr[1])
    if n in arr:b.add(arr[0])
if len(a&b)==0:print("IMPOSSIBLE")
else:print("POSSIBLE")
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a>b:print("GREATER")
elif a<b:print("LESS")
else:print("EQUAL")

Fixed submission:
a=int(input())
b=int(input())
if a>b:print("GREATER")
elif a<b:print("LESS")
else:print("EQUAL")
Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())
s = int(math.sqrt(n))

for i in range(s,n+1):
    if n%i == 0:
        print(max(len(str(i)),len(str(n//i))))
        exit()

Fixed submission:
import math
n = int(input())
s = int(math.sqrt(n))

for i in range(s,0,-1):
    if n%i == 0:
        print(max(len(str(i)),len(str(n//i))))
        exit()
Buggy python submission (verdict: Runtime Error):
from collections import deque
n,c,k=map(int,input().split())
l=sorted([int(input()) for _ in range(n)],reverse=True)
ans=0
d=deque(l)
while len(d)!=0:
    ans+=1
    t=d.popleft()
    cnt=1
    while d[0]>=t-k and cnt<c:
        d.popleft()
        cnt+=1
print(ans)

Fixed submission:
from collections import deque
n,c,k=map(int,input().split())
l=sorted([int(input()) for _ in range(n)],reverse=True)
ans=0
d=deque(l)
while len(d)!=0:
    ans+=1
    t=d.popleft()
    cnt=1
    while len(d)!=0 and d[0]>=t-k and cnt<c:
        d.popleft()
        cnt+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n,c,k=map(int,input().split())
l=sorted([int(input()) for _ in range(n)],reverse=True)
ans=0
d=deque(l)
while len(d)!=0:
    ans+=1
    t=d.popleft()
    for i in range(c-1):
        if len(d)!=0 and d[0]>=t-k:
            d.popleft()
print(ans)

Fixed submission:
from collections import deque
n,c,k=map(int,input().split())
l=sorted([int(input()) for _ in range(n)],reverse=True)
ans=0
d=deque(l)
while len(d)!=0:
    ans+=1
    t=d.popleft()
    cnt=1
    while len(d)!=0 and d[0]>=t-k and cnt<c:
        d.popleft()
        cnt+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n,c,k=map(int,input().split())
l=sorted([int(input()) for _ in range(n)],reverse=True)
ans=0
d=deque(l)
while len(d)!=0:
    ans+=1
    t=d.popleft()
    for i in range(c-1):
        if len(d)!=0 and d[0]>=t-k:
            d.popleft()
print(ans)

Fixed submission:
from collections import deque
n,c,k=map(int,input().split())
l=sorted([int(input()) for _ in range(n)],reverse=True)
ans=0
d=deque(l)
while len(d)!=0:
    ans+=1
    t=d.popleft()
    cnt=1
    while len(d)!=0 and d[0]>=t-k and cnt<c:
        d.popleft()
        cnt+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
if n==1:print(1);exit()
l=[i for i in range(1,n+1) if isPrime(i)==True]
ans=1
INF=10**9+7
for i in l:
    tmp=0
    tmpi=i
    while n//i>0:
        tmp+=n//i
        i*=tmpi
    ans=(ans*(tmp+1))%INF
print(ans)

Fixed submission:
import math
def isPrime(num):
    if num < 2: return False
    elif num == 2: return True
    for i in range(2,math.floor(math.sqrt(num))+1):
        if num % i == 0:
            return False
    return True

n=int(input())
if n==1:print(1);exit()
l=[i for i in range(1,n+1) if isPrime(i)==True]
ans=1
INF=10**9+7
for i in l:
    tmp=0
    tmpi=i
    while n//i>0:
        tmp+=n//i
        i*=tmpi
    ans=(ans*(tmp+1))%INF
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
x,y=map(int,input().split())
ans=0
for i in range(x+1):
    for j in range(x+1):
        for k in range(x+1):
            if i+j+k==y:ans+=1
print(ans)

Fixed submission:
x,y=map(int,input().split())
ans=0
for i in range(x+1):
    for j in range(x+1):
        if 0<=y-(i+j)<=x:ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
s = str(input())[::-1]
while True:
    if s[:5]=="maerd" or s[:5]=="esare":
        s=s[5:]
        if len(s)==0:
            print("YES")
            exit()
    elif s[:6]=="resare"
        s=s[6:]
        if len(s)==0:
            print("YES")
            exit()
    elif s[:7]=="remaerd":
        s=s[7:]
        if len(s)==0:
            print("YES")
            exit()
    else:
        print("NO")
        exit()

Fixed submission:
s = str(input())[::-1]
while True:
    if s[:5]=="maerd" or s[:5]=="esare":
        s=s[5:]
        if len(s)==0:
            print("YES")
            exit()
    elif s[:6]=="resare":
        s=s[6:]
        if len(s)==0:
            print("YES")
            exit()
    elif s[:7]=="remaerd":
        s=s[7:]
        if len(s)==0:
            print("YES")
            exit()
    else:
        print("NO")
        exit()
Buggy python submission (verdict: Runtime Error):
x = l_a.pop(0)
ans=0
while ans==0:
    if x == "a":
        if len(l_a) != 0: x = l_a.pop(0)
        else:ans = "A"
    if x == "b":
        if len(l_b) != 0: x = l_b.pop(0)
        else:ans = "B"
    if x == "c":
        if len(l_c) != 0: x = l_c.pop(0)
        else:ans = "C"
print(ans)

Fixed submission:
l_a = list(str(input()))
l_b = list(str(input()))
l_c = list(str(input()))

x = l_a.pop(0)
ans=0
while ans==0:
    if x == "a":
        if len(l_a) != 0: x = l_a.pop(0)
        else:ans = "A"
    if x == "b":
        if len(l_b) != 0: x = l_b.pop(0)
        else:ans = "B"
    if x == "c":
        if len(l_c) != 0: x = l_c.pop(0)
        else:ans = "C"
print(ans)
Buggy python submission (verdict: Runtime Error):
n = str(input())
a = ["","+"]
l = list(itertools.product(a,repeat=len(n)-1))
l_n = list(n)
ans=0
for i in l:
    l_a = [None]*(len(n)*2-1)
    l_a[::2] = l_n
    l_a[1::2] = i
    ans+=eval("".join(l_a))
print(ans)

Fixed submission:
import itertools
n = str(input())
a = ["","+"]
l = list(itertools.product(a,repeat=len(n)-1))
l_n = list(n)
ans=0
for i in l:
    l_a = [None]*(len(n)*2-1)
    l_a[::2] = l_n
    l_a[1::2] = i
    ans+=eval("".join(l_a))
print(ans)
Buggy python submission (verdict: Runtime Error):
n, m, x = [*map(int, input().split())]
k = []
ans = 10 ** 6
for i in range(n):
    c, *a = [*map(int, input().split())]
    s += c
    k.append([c, *a])

for i in range(2 ** n):
    cost = 0
    skills = [0] * m
    for j in range(n):
        if ((i >> j) & 1):
            cost += k[j][0]
            for s, t in enumerate(k[j][1:]):
                skills[s] += t
            if all(map(lambda skill: skill >= x, skills)):
                ans = min(ans, cost)
print(-1 if ans == 10 ** 6 else ans)

Fixed submission:
n, m, x = [*map(int, input().split())]
k = [[*map(int, input().split())] for _ in range(n)]
ans = 10 ** 9

for i in range(2 ** n):
    cost = 0
    skills = [0] * m
    for j in range(n):
        if ((i >> j) & 1):
            cost += k[j][0]
            for s, t in enumerate(k[j][1:]):
                skills[s] += t
            if all(map(lambda skill: skill >= x, skills)):
                ans = min(ans, cost)
print(-1 if ans == 10 ** 9 else ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]

idx = -1
m = 0
for i in range(n-k+1):
    s = sum(p[i:i+k])
    if m < s:
        m = s
        idx = i

ans = 0
for i in p[idx:idx+k]:
    ans += (i - 1) * 0.5 + 1
print('{:.12f}'.format(float(ans)))


Fixed submission:
n, k = [int(i) for i in input().split()]
p = [(int(i) + 1) * 0.5 for i in input().split()]
m = sum(p[:k])
s = m
for i in range(k, n):
    s = s + p[i] - p[i-k]
    m = max(m, s)
print('{:.7f}'.format(m))
Buggy python submission (verdict: Runtime Error):
n = int(input())
c = 0

def count(i):
    h = str(i)
    s = lambda j, k, l: int('{}{}{}'.format(j, k, j))
    if len(set(h)) == 1:
        h = h[0]
        c = 1
        s = h * 1
        while int(s) <= n:
            c += 1
            s = h * c
        return c - 1
    if h[-1] == '0' or s(h[-1], '', h[0]) > n:
        return 0
    d = 1
    while s(h[-1], '0' * d, h[0]) <= n:
        d += 1
    for i in range(10):
        if s(h[-1], i, h[0]) > n:
            break
    return 11 * (d - 1) + 1

s = 0
for i in range(1, n+1):
    c = count(i)
    print(f'{i} = {c}')
    s += c
print(s)


Fixed submission:
n = int(input())
d = {}

for a in range(1, n+1):
    a = str(a)
    f, l = a[0], a[-1]
    if '0' in [f, l]:
        continue
    if (f, l) in d:
        d[(f, l)] += 1
    else:
        d[(f, l)] = 1

ans = 0
for b in range(1, n+1):
    b = str(b)
    f, l = b[-1], b[0]
    if (f, l) in d:
        ans += d[(f, l)]
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
c = 0

def count(i):
    h = str(i)
    s = lambda j, k, l: int(f'{j}{k}{l}')
    if len(set(h)) == 1:
        h = h[0]
        c = 1
        s = h * 1
        while int(s) <= n:
            c += 1
            s = h * c
        return c - 1
    if h[-1] == '0' or s(h[-1], '', h[0]) > n:
        return 0
    # d = 1
    # while s(h[-1], '0' * d, h[0]) <= n:
    #     d += 1
    # i = 0
    # while
    i = 0
    while s(h[-1], i, h[0]) <= n:
        i += 1
    return i + 1

s = 0
for i in range(1, n+1):
    c = count(i)
    # print(f'{i} = {c}')
    s += c
print(s)


Fixed submission:
n = int(input())
d = {}

for a in range(1, n+1):
    a = str(a)
    f, l = a[0], a[-1]
    if '0' in [f, l]:
        continue
    if (f, l) in d:
        d[(f, l)] += 1
    else:
        d[(f, l)] = 1

ans = 0
for b in range(1, n+1):
    b = str(b)
    f, l = b[-1], b[0]
    if (f, l) in d:
        ans += d[(f, l)]
print(ans)