Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03061 (python)

Fixed submission:
from fractions import gcd

NN = 202020
MOD = 10**9+7
INF = float("inf")

N = int(input())
A = list(map(int, input().split()))
left = [0]*N
right = [0]*N

left[0] = A[0]
for i in range(1, N-1):
    left[i] = gcd(left[i-1], A[i])

right[-1] = A[-1]
for i in range(N-2, 0, -1):
     right[i] = gcd(right[i+1], A[i])

# print(left, right)
max_val = max(left[-2], right[1])
for i in range(1, N-1):
    max_val = max(max_val, gcd(left[i-1], right[i+1]))

print(max_val)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
A = list(map(int, input().split()))
left = [0]*N
right = [0]*N

left_gcd = A[0]
left[0] = A[0]
for i in range(1, N-1):
    left[i] = math.gcd(left_gcd, A[i])

right_gcd = A[-1]
right[-1] = A[-1]
for i in range(N-2, 0, -1):
    right[i] = math.gcd(right_gcd, A[i])

# print(left, right)
max_val = max(left[-2], right[1])
for i in range(1, N-1):
    max_val = max(max_val, math.gcd(left[i-1], right[i+1]))

print(max_val)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
left = [0]*N
right = [0]*N

left_gcd = A[0]
left[0] = A[0]
for i in range(1, N-1):
    left[i] = math.gcd(left_gcd, A[i])

right_gcd = A[-1]
right[-1] = A[-1]
for i in range(N-2, 0, -1):
    right[i] = math.gcd(right_gcd, A[i])

# print(left, right)
max_val = max(left[-2], right[1])
for i in range(1, N-1):
    max_val = max(max_val, math.gcd(left[i-1], right[i+1]))

print(max_val)
Problem p03128 (python)

Fixed submission:
n, m = map(int, input().split())
A = list(map(int, input().split()))
digit = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}

dp = [(-1, -1)]*(n+1)
dp[0] = (0, -1)
for k in range(1, n+1):
    max_value = -1
    max_d = -1
    for num in A:
        if k >= digit[num]:
            suf, d = dp[k - digit[num]]
            if suf >= 0:
                value = num * (10 ** (d + 1)) + suf
                if value > max_value:
                    max_value = value
                    max_d = d + 1

    dp[k] = (max_value, max_d)
print(dp[n][0])

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
A = list(map(int, input().split()))
digit = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}


def dfs(k):
    if k == 0:
        return 0, -1
    if k in memo:
        return memo[k]

    max_value = -1
    max_d = -1
    for num in A:
        if k >= digit[num]:
            suf, d = dfs(k-digit[num])
            if suf >= 0:
                value = num*(10**(d+1))+suf
                if value > max_value:
                    max_value = value
                    max_d = d+1

    memo[k] = (max_value, max_d)
    return max_value, max_d


memo = dict()
print(dfs(n)[0])
Problem p03714 (python)

Fixed submission:
import heapq

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

pre = [0]*(n+1)
pre_list = [e for e in A[:n]]
heapq.heapify(pre_list)
pre_sum = sum(pre_list)
pre[0] = pre_sum
for i in range(n, 2*n):
    small = heapq.heappushpop(pre_list, A[i])
    pre_sum += A[i] - small
    pre[i-n+1] = pre_sum

suf = [0]*(n+1)
suf_list = [-e for e in A[2*n:]]
heapq.heapify(suf_list)
suf_sum = -sum(suf_list)
suf[-1] = suf_sum
for i in range(2*n-1, n-1, -1):
    large = -heapq.heappushpop(suf_list, -A[i])
    suf_sum += A[i] - large
    suf[i-n] = suf_sum

# print(pre)
# print(suf)

print(max([pre[i] - suf[i] for i in range(n+1)]))

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))

pre = [0]*(n+1)
pre_list = [e for e in A[:n]]
heapq.heapify(pre_list)
pre_sum = sum(pre_list)
pre[0] = pre_sum
for i in range(n, 2*n):
    small = heapq.heappushpop(pre_list, A[i])
    pre_sum += A[i] - small
    pre[i-n+1] = pre_sum

suf = [0]*(n+1)
suf_list = [-e for e in A[2*n:]]
heapq.heapify(suf_list)
suf_sum = -sum(suf_list)
suf[-1] = suf_sum
for i in range(2*n-1, n-1, -1):
    large = -heapq.heappushpop(suf_list, A[i])
    suf_sum += A[i] - large
    suf[i-n] = suf_sum

# print(pre)
# print(suf)

print(max([pre[i] - suf[i] for i in range(n+1)]))
Problem p02573 (python)

Fixed submission:
from sys import exit, stdin

input = stdin.readline
import copy
from collections import deque, Counter

# import numpy as np


class BIT:
    def __init__(self, a=0):
        self.n = a
        self.d = [0] * (a + 1)

    def add(self, i, x=1):
        i += 1
        while i <= self.n:
            self.d[i] += x
            i += i & (-i)

    def sum(self, *i):
        if len(i) == 1:
            x = 0
            i += 1
            while i:
                x += self.d[i]
                i -= i & (-i)
            return x
        else:
            return sum(self, i[1] - 1) - sum(self, i[0] - 1)


class UnionFind:
    def __init__(self, N):
        # N = data size
        self.n = N
        self.parents = [-1] * N

    def find(self, x):
        # find x's root
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        # unite x and y
        rx = self.find(x)
        ry = self.find(y)

        if rx == ry:
            return False
        if -(self.parents[rx]) < -(self.parents[ry]):
            rx, ry = ry, rx
        self.parents[rx] += self.parents[ry]
        self.parents[ry] = rx
        return True

    def size(self, x):
        # size of group of x's root
        return -(self.parents[self.find(x)])

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return "\n".join("{}: {}".format(r, self.members(r)) for r in self.roots())


N, M = list(map(int, input().split()))

if M == 0:
    print(1)
    exit()


D = UnionFind(N)

for i in range(M):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    D.union(a, b)

num = [D.size(r) for r in D.roots()]

print(max(num))

Buggy submission (verdict: Runtime Error):
from sys import exit, stdin

input = stdin.readline
import copy

from collections import deque, Counter

# import numpy as np


N, M = list(map(int, input().split()))

D = [-1] * N

tmp = 0
for i in range(M):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    if D[a] == -1 and D[b] == -1:
        D[a] = tmp
        D[b] = tmp
        tmp += 1
    elif D[a] == -1 and D[b] != -1:
        D[a] = D[b]
    elif D[a] != -1 and D[b] == -1:
        D[b] = D[a]
    elif D[a] != D[b]:
        for k in range(N):
            if D[k] == D[b]:
                D[k] = a


R = Counter(D)
ans = R.most_common(2)
if ans[0][0] == -1:
    print(ans[1][1])
else:
    print(ans[0][1])
Problem p02614 (python)

Fixed submission:
from sys import exit
import copy
import numpy as np
#from collections import deque


h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]
# print(c)


def count(arr):
    cnt = 0
    for l in arr:
        for i in l:
            if i == "#":
                cnt += 1

    return cnt


ans = 0
for i in range(2 ** w):
    tmp = copy.deepcopy(c)
    for j in range(w):
        if ((i >> j) & 1):
            for s in range(h):
                tmp[s][j] = '$'

    for t in range(2 ** h):
        tmp2 = copy.deepcopy(tmp)
        for j in range(h):
            if ((t >> j) & 1):
                for s in range(w):
                    tmp2[j][s] = '$'
        # for l in tmp2:
        #     print(l)
        if count(tmp2) == k:
            ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
from sys import exit
import copy
import numpy as np
#from collections import deque


h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]
# print(c)


def count(arr):
    cnt = 0
    for l in arr:
        for i in l:
            if i == "#":
                cnt += 1

    return cnt


ans = 0
for i in range(2 ** w):
    tmp = copy.deepcopy(c)
    for j in range(w):
        if ((i >> j) & 1):
            for s in range(h):
                tmp[s][j] = '$'

    for t in range(2 ** h):
        tmp2 = copy.deepcopy(tmp)
        for j in range(h):
            if ((t >> j) & 1):
                for s in range(w):
                    tmp2[j][s] = '$'
        # for l in tmp2:
        #     print(l)
        if count(tmp2) == k:
            ans += 1

print(ans)
Problem p02621 (python)

Fixed submission:
from sys import exit
#import copy
#import numpy as np
#from collections import deque


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

print(int(a+a**2+a**3))

Buggy submission (verdict: Runtime Error):
from sys import exit
import copy
# import numpy as np
from collections import deque

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

cnt = 0


a.insert(0, 0)
b.insert(0, 0)


for i in range(1, n+1):
    a_sum[i] += a_sum[i-1]

for i in range(1, m+1):
    b_sum[i] += b_sum[i-1]


for i in range(n+1):
    for j in range(m+1):
        if a_sum[i] + b_sum[j] <= k:
            pass
        else:
            if a_sum[i] + b_sum[j-1] <= k:
                cnt = max(cnt, i + j - 1)
            break
    else:
        if a_sum[i] + b_sum[j] <= k:
            cnt = max(cnt, i + j)
print(cnt)
Problem p02646 (python)

Fixed submission:
import numpy as np
import sys
# import copy


def xnxn(n=0, flag="v"):
    """
    args:
        int n: a number of lows to read
    example:
        input   1
        retrun  1

        input   1 2 3
        return  [1,2,3]
        input   1 2 3
                4
        return  [[1,2,3],
                [4]]
    """
    if n == 0:
        temp = list(map(int, input().split()))
        if len(temp) == 1:
            if flag == "l":
                return temp
            else:
                return temp[0]
        elif len(temp) > 1:
            return temp
    else:
        temp = [list(map(int, input().split())) for _ in range(n)]
        return temp


a, v = xnxn()
b, w = xnxn()
t = xnxn()


# for i in range(t):
#     if b - a > 0:
#         b = min(b + w, 10 ** 9)
#         a = min(a + v, 10 ** 9)
#         if b == a:
#             print("YES")
#             sys.exit()
#     elif b - a < 0:
#         b = max(b - w, 10 ** 9)
#         a = max(a - v, 10 ** 9)
#         if b == a:
#             print("YES")
#             sys.exit()

# print("NO")

if b - a > 0:
    # b_f = min(b+t*w, 10 ** 9)
    # a_f = min(a + t * v, 10 ** 9)
    b_f = b+t*w
    a_f = a+t*v
    if b_f > a_f:
        print("NO")
    else:
        print("YES")


else:
    # b_f = max(b-t*w, -10 ** 9)
    # a_f = max(a-t*v, -10 ** 9)
    b_f = b-t*w
    a_f = a-t*v

    if b_f < a_f:
        print("NO")
    else:
        print("YES")

Buggy submission (verdict: Runtime Error):
if b - a > 0:
    b_f = min(b+t*w, 10 ** 9)
    a_f = min(a+t*v, 10 ** 9)
    if b_f > a_f:
        print("NO")
    else:
        print("YES")


else:
    b_f = max(b-t*w, -10 ** 9)
    a_f = max(a-t*v, -10 ** 9)
    if b_f < a_f:
        print("NO")
    else:
        print("YES")
Problem p02641 (python)

Fixed submission:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
#from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#from scipy.sparse.csgraph import breadth_first_order, depth_first_order, shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
import sys

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

X, N = na()
p = na()
kouho = []
for i in range(-100, 200):
    if i in p:
        continue
    kouho.append((abs(X - i), i))
print(min(kouho)[1])

Buggy submission (verdict: Runtime Error):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
#from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#from scipy.sparse.csgraph import breadth_first_order, depth_first_order, shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
import sys

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

X, N = na()
p = na()
kouho = []
for i in range(1, 101):
    if i in p:
        continue
    kouho.append((abs(X - i), i))
print(min(kouho)[1])
Problem p02690 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10**7)

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

x = ni()
for a in range(-120, 120):
    for b in range(-120, 120):
        if a ** 5 - b ** 5 == x:
            print(a, b)
            exit(0)

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10**7)

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

x = ni()
for a in range(-250, 251):
    for b in range(-250, 251):
        if a ** 5 - b ** 5 == x:
            print(a, b)
            exit(1)
Problem p02720 (python)

Fixed submission:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

k = ni()
que = deque()
for i in range(1, 10):
    que.append(i)
ct = 0
for i in range(k):
    x = que.popleft()
    if x % 10 != 0:
        que.append(10*x+x%10-1)
    que.append(10*x+x%10)
    if x % 10 != 9:
        que.append(10*x+x%10+1)
print(x)

Buggy submission (verdict: Runtime Error):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

k = ni()
que = deque()
for i in range(1, 10):
    que.append(i)
ct = 0
while True:
    x = que.popleft()
    ct += 1
    if ct == k:
        print(x)
        exit(1)
    if x % 10 != 0:
        que.append(10*x+x%10-1)
    que.append(10*x+x%10)
    if x % 10 != 9:
        que.append(10*x+x%10+1)
Problem p02918 (python)

Fixed submission:
import copy
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()

n, k = na()
s = input()
ct = 0
for i in range(n-1):
    if s[i] == s[i+1]:
        ct += 1
print(min(ct + 2 * k, n - 1))

Buggy submission (verdict: Runtime Error):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()

n, k = na()
s = input()
ct = 0
lll = 1
li = []
for i in range(n-1):
    if s[i] == s[i+1]:
        ct += 1
        lll += 1
    else:
        li.append(lll)
        lll = 1
li.append(lll)
ans = []
"""
print(ct)
print(li[0::2])
print(li[1::2])
"""
for a, b in zip(li[0::2], li[1::2]):
    ans.append(a+b)
ans.sort()
if len(ans) == 1:
    print(ans[0] - 1)
else:
    for i in range(k):
        ct += (ans[-k] - 1)
    print(ct)
Problem p02953 (python)

Fixed submission:
import sys
from math import *
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
li = na()
mst = li[0]
flag = "Yes"
for i in range(n):
    if li[i] >= mst:
        mst = li[i]
    elif li[i] != mst - 1:
        flag = "No"
        break
print(flag)

Buggy submission (verdict: Runtime Error):
import sys
from math import *
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
li = na()
mst = li[0]
for i in range(n):
    if li[i] >= mst:
        mst = li[i]
    elif li[i] != mst - 1:
        print("No")
        exit(1)
print("Yes")

Buggy submission (verdict: Runtime Error):
import sys
from math import *
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
li = list(map(int,input().split()))
mst = li[0]
for i in range(1, n):
    if li[i] >= mst:
        mst = li[i]
    elif li[i] != mst - 1:
        print("No")
        exit(1)
print("Yes")

Buggy submission (verdict: Runtime Error):
import sys
from math import *
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
li = na()
mst = ni()
for i in range(1, n):
    num = ni()
    if num >= mst:
        mst = num
    elif num != mst - 1:
        print("No")
        exit(1)
print("Yes")

Buggy submission (verdict: Runtime Error):
import sys
from math import *
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
li = na()
mst = li[0]
for i in range(1, n):
    if li[i] >= mst:
        mst = li[i]
    elif li[i] != mst - 1:
        print("No")
        exit(1)
print("Yes")

Buggy submission (verdict: Runtime Error):
import sys
from math import *
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
li = na()
mst = li[0]
for i in range(1, n):
    if li[i] > mst:
        mst = li[i]
    elif li[i] != mst - 1:
        print("No")
        exit(1)
print("Yes")
Problem p02983 (python)

Fixed submission:
import sys
from math import *
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

num = 2019
l, r = na()
li = []
if r - l > 2019:
    print(0)
else:
    for i in range(l, r+1):
        li.append(i % num)
    li.sort()
    n = len(li)
    m = 1000000000
    for i in range(n):
        for j in range(i+1, n):
            kazu = (li[i] * li[j]) % num
            if m > kazu:
                m = kazu
    print(m)

Buggy submission (verdict: Runtime Error):
import sys
from math import *
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

num = 2019
l, r = na()
li = []
if r < num:
    print(l * r)
elif l <= num <= r:
    print(0)
elif l > num:
     if r - l >= num:
         print(0)
     else:
         for i in range(l, r+1):
             li.append(i%num)
     li.sort()
     print(li[0] * li[1])
Problem p03069 (python)

Fixed submission:
n = int(input())
s = input()
li = []
for i in range(n):
    if s[i] == "#":
        li.append(i)
li.append(len(s))
sum = 0
if len(li) == 1:
    print(0)
else:
    for i in range(len(li)-1):
        diff = li[i+1] - li[i] - 1
        if sum + diff >= i+1:
            sum = i+1
        else:
            sum += diff
    print(sum)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
li = []
for i in range(n):
    if s[i] == "#":
        li.append(i)
sum = 0
if len(li) == 0:
    print(0)
for i in range(len(li)-1):
    sum += li[i+1]-li[i]-1 
sum += len(s) - li[-1] - 1
print(sum)
Problem p03076 (python)

Fixed submission:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

res = 0
li = []
dic = {}
for i in range(5):
    li.append(int(input()))
for i in range(5):
    if li[i] % 10 != 0 and li[i] % 10 not in dic.values():
        dic[i] = li[i] % 10
if len(dic) == 0:
    res = sum(li)
else:
    m = min(dic.values())
    for j in range(5):
        if li[j] % 10 == 0:
            res += li[j]
        else:
            if li[j] % 10 == m and j in dic.keys():
                res += li[j]
            else:
                res += (li[j] // 10 + 1) * 10
print(res)

Buggy submission (verdict: Runtime Error):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

res = 0
li = []
dic = {}
for i in range(5):
    li.append(int(input()))
for i in range(5):
    if li[i] % 10 != 0 and li[i] % 10 not in dic.values():
        dic[i] = li[i] % 10
m = min(dic.values())
for j in range(5):
    if li[j] % 10 == 0:
        res += li[j]
    else:
        if li[j] % 10 == m and j in dic.keys():
            res += li[j]
        else:
            res += (li[j] // 10 + 1) * 10
print(res)

Buggy submission (verdict: Runtime Error):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

res = 0
li = []
dic = {}
for i in range(5):
    li.append(int(input()))
    if li[i] % 10 != 0 and li[i] % 10 not in dic.values():
        dic[i] = li[i] % 10
m = min(dic.values())
for j in range(5):
    if li[j] % 10 == 0:
        res += li[j]
    else:
        if li[j] % 10 == m and j in dic.keys():
            res += li[j]
        else:
            res += (li[j] // 10 + 1) * 10
print(res)
Problem p03078 (python)

Fixed submission:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

res = []
x, y, z, K = na()
a_li = na()
b_li = na()
c_li = na()
list.sort(a_li, reverse=True)
list.sort(b_li, reverse=True)
list.sort(c_li, reverse=True)
for i in range(x):
    for j in range(y):
        for k in range(z):
            if (i + 1) * (j + 1) * (k + 1) <= K:
                res.append(a_li[i] + b_li[j] + c_li[k])
            else:
                break
list.sort(res, reverse=True)
for i in range(K):
    print(res[i])

Buggy submission (verdict: Runtime Error):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

res = []
x, y, z, K = na()
a_li = na()
b_li = na()
c_li = na()
list.sort(a_li,reverse=True)
list.sort(b_li,reverse=True)
list.sort(c_li,reverse=True)
for i in range(x):
    for j in range(y):
        for k in range(z):
            if (i + 1) * (j + 1) * (k + 1) <= k:
                res.append(a_li[i] * b_li[j] + c_li[k])
            else:
                break

list.sort(res, reverse=True)
for i in range(K):
    print(res[i])