Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from sys import stdin
import numpy as np
from math import gcd


# noinspection PyShadowingBuiltinsInspection

def lcm(x, y):
    return (x * y) // gcd(x, y)

def main():
    N, M = [int(x) for x in input().split()]
    a = sorted(list({int(x) for x in input().split()}), reverse=True)
    x = a[0]
    p2 = 1
    while x % 2 == 0:
        p2 *= 2
        x //= 2
    flag = False
    y = 1 # a//2 の最小公倍数
    for i in range(len(a)):
        if a[i] % p2 != 0 or (a[i] // p2) % 2 == 0:
            flag = True
            break
        a[i] //= 2
        y = lcm(a[i], y)
    if flag:
        return 0
    z = M // y
    return z // 2 if z % 2 == 0 else z // 2 + 1
    # b = [a[0]]
    # for i in range(1, len(a)):
    #     flag = False
    #     for x in b:
    #         if x % a[i] == 0:
    #             flag = True
    #             break
    #     if not flag:
    #         b.append(a[i])
    # # print(b)
    # y = 1
    # for x in b:
    #     # print(b)
    #     y *= x
    # z = M // y
    # # print(y, z*y)
    # ret = z // 2 if z % 2 == 0 else z // 2 + 1
    # # print(ret)
    #
    # return ret


if __name__ == "__main__":
    print(main())

Fixed submission:
from sys import stdin
import numpy as np
from fractions import gcd


# noinspection PyShadowingBuiltinsInspection

def lcm(x, y):
    return (x * y) // gcd(x, y)

def main():
    N, M = [int(x) for x in input().split()]
    a = sorted(list({int(x) for x in input().split()}), reverse=True)
    x = a[0]
    p2 = 1
    while x % 2 == 0:
        p2 *= 2
        x //= 2
    flag = False
    y = 1 # a//2 の最小公倍数
    for i in range(len(a)):
        if a[i] % p2 != 0 or (a[i] // p2) % 2 == 0:
            flag = True
            break
        a[i] //= 2
        y = lcm(a[i], y)
    if flag:
        return 0
    z = M // y
    return z // 2 if z % 2 == 0 else z // 2 + 1
    # b = [a[0]]
    # for i in range(1, len(a)):
    #     flag = False
    #     for x in b:
    #         if x % a[i] == 0:
    #             flag = True
    #             break
    #     if not flag:
    #         b.append(a[i])
    # # print(b)
    # y = 1
    # for x in b:
    #     # print(b)
    #     y *= x
    # z = M // y
    # # print(y, z*y)
    # ret = z // 2 if z % 2 == 0 else z // 2 + 1
    # # print(ret)
    #
    # return ret


if __name__ == "__main__":
    print(main())
Buggy python submission (verdict: Runtime Error):
n = int(input())
ds = [int(x) for x in input().split()]
ds2 = [x*x for x in ds]
s = 0
s2 = 0
for i in range(n):
  s += ds[i]
  s2 += ds2[i]
ss = 0
for i in range(n):
  ss += ds[i] * s

print((ss - s2) / 2 )

Fixed submission:
a,b = [int(x) for x in input().split()]
c = a - 2*b
if c < 0:
  c = 0
print(c)

Buggy python submission (verdict: Runtime Error):
#import numpy as np
n = int(input())
#ds = np.array([int(x) for x in input().split()])
ds = [int(x) for x in input().split()]
ds2 = [x*x for x in ds]
s = sum(ds)
#print((sum(ds * sum(ds)) - sum(ds ** 2)) / 2 )
print(int((sum(ds * s) - sum(ds2)) / 2 ))

Fixed submission:
a,b = [int(x) for x in input().split()]
c = a - 2*b
if c < 0:
  c = 0
print(c)
Buggy python submission (verdict: Runtime Error):
n = int(input())
ds = map(int, input.split())
ret = 0
for i in range(n):
  for j in range(n-1):
    ret += ds[i] * ds[j + 1]
print(ret)

Fixed submission:
n = int(input())
ds = [int(x) for x in input().split()]
ret = 0
for i in range(n - 1):
  for j in range(i+1, n):
    ret += ds[i] * ds[j]
print(ret)
Buggy python submission (verdict: Runtime Error):
s = input()
i = 1
flag = True
c in s:
  if (i % 2 == 0 and c == "L") or (i % 2 == 1 and c == "R"):
    print("No")
    exit
print("Yes")


Fixed submission:
s = input()
i = 0
flag = True
for c in s:
  i += 1
  if (i % 2 == 0 and c == "R") or (i % 2 == 1 and c == "L"):
    print("No")
    exit(0)
print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    s = input()
    t = input()
    if not set(sorted(t)) <= set(sorted(s)):
        print(-1)
        return
    # print(set(sorted(t)) , set(sorted(s)))
    ret = 0
    ind = 0
    while not ind == len(t):
        if s[ret % len(s)] == t[ind]:
            ind += 1
        ret += 1
    print(ret)
    return


if __name__ == "__main__":
    main()

Fixed submission:
import copy


def main():
    s = input()
    ss = s + s
    t = input()
    if not set(sorted(t)) <= set(sorted(s)):
        print(-1)
        return
    cnt_s = {}
    cnt_t = {}
    pos = {}  # [({}) for x in range(len(s))]
    for i in range(len(ss)):
        c = ss[i]
        if c not in cnt_s:
            cnt_s[c] = 0
            pos[c] = []
        cnt_s[c] += 1
        pos[c].append(i)
    # for k in pos.keys():
    #     pos[k].reverse()
    # org_pos = copy.deepcopy(pos)
    ret = 0
    tmp = -1
    for i in range(len(t)):
        c = t[i]
        if pos[c][0] > tmp:
            tmp = pos[c][0]
            continue
        l = 1
        r = len(pos[c]) - 1
        while not l == r:
            p = (l + r) // 2
            if pos[c][p] > tmp:
                r = p
            if pos[c][p] <= tmp:
                l = p + 1
        tmp = pos[c][l]
        if tmp >= len(s):
            ret += len(s)
            tmp -= len(s)
    ret += tmp + 1
    print(ret)
    return


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
s = input()
  N = len(s)
  ans = 0

  tmp = ""
  i = 0
  while i < N:
if not tmp == s[i]:
tmp = s[i]
            ans += 1
  else:
tmp = ""
  i += 1
  if not i == N:
ans += 1
  i += 1
  # print(tmp, ans, i)

  print(ans)

Fixed submission:
def main():
    s = input()
    N = len(s)
    ans = 0

    tmp = ""
    i = 0
    while i < N:
        if not tmp == s[i]:
            tmp = s[i]
            ans += 1
        else:
            tmp = ""
            i += 1
            if not i == N:
                 ans += 1
        i += 1
        # print(tmp, ans, i)

    print(ans)
    return


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
n, x = input().split()
n = int(n)
x = int(x)
m = []
m_min = 1000
gokei = 0
for i in range(n):
  m.append(int(intput()))
  gokei += m[i]
  if m_min > m[i]:
    m_min = m[i]
x -= gokei
print((x//m_min) + n)

Fixed submission:
n, x = input().split()
n = int(n)
x = int(x)
m = []
m_min = 1000
gokei = 0
for i in range(n):
  m.append(int(input()))
  gokei += m[i]
  if m_min > m[i]:
    m_min = m[i]
x -= gokei
print((x//m_min) + n)
Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    max_a, max_b = 0, 0 # type:int
    for _ in range(n):
        a, b = input().split(' ')
        a = int(a)
        if max_a < a:
            max_a = a
            max_b = int(b)
    print(max_a + max_b)


if __name__ == "__main__":
    main()

Fixed submission:
def main():
    s = input()
    cnt = 0
    for c in s:
        if c == '1':
            cnt += 1
    print(cnt)
    return


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    ab:[[int]] = []
    for i in range(n):
        ab.append([int(x) for x in input().split()])
    a, b = max(ab, key=lambda x: x[0])
    print(a + b)


if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n = int(input())
    ab = [] # type:[[int]] 
    for i in range(n):
        ab.append([int(x) for x in input().split()])
    a, b = max(ab, key=lambda x: x[0])
    print(a + b)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
n, a, b = [int(i) for i in input().split()]
hs = [None]*n
kill_b = [None]*n
all_hp = 0
all_killb = 0
for i in range(n):
    hs[i] = int(input())
    # all_hp += hs[i]
    # kill_b[i] = hs[i] // b
    # if((hs[i] % b) != 0):
    #     kill_b[i] += 1
    # all_killb += kill_b[i]
# hs.sort()
max_hp = max(hs)
ret = 0
ab = a - b
right = max_hp // b
if((max_hp % b) != 0):
    right += 1
left = 1
while right != left:
    middle = (right + left) // 2
    # print([left, right, middle])
    all_a = 0
    for x in hs:
        nokori = x - (b * middle)
        if(nokori > 0):
            num_a = nokori // ab
            if(x > num_a * a + (middle - num_a) * b):
                num_a += 1
            all_a += num_a
    if(all_a <= middle):
        right = middle
    else:
        left = middle + 1
ret = right
    # for i in range(hs[-1] // b):
        # flag = False
        # for j in range(n):
        #     ret += 1
        #     base_height = (ret * b) + (i * (a-b))
        #     #print(base_height)
        #     if((j == n-1) or (hs[-(j+2)] <= (base_height))):
        #         break
        # max_height = (ret * b) + ((i + 1) * (a-b))
        # if(max_height >= hs[-1]):
        #     break
print(ret)


Fixed submission:
n = int(input())
s = []
all_ac = 0
for i in range(n):
    s.append(int(input()))
    all_ac += s[-1]
s.sort()
if((all_ac % 10) == 0):
    for x in s:
        if(x % 10 != 0):
            all_ac -= x
            break
if((all_ac % 10) == 0):
    print(0)
else:
    print(all_ac)
Buggy python submission (verdict: Runtime Error):
a,b,c = [int(i) for i in input().split()]
arr = set()
ret = "NO"
r = a%b
if r==0:
    if c==0:
        ret="YES"
    else:
        pass
elif r==1:
    ret = "YES"
else:
    rr = r
    while not(rr in arr):
#        print(arr,rr)
        if rr <= c and (c-rr)%r == 0:
            ret = "YES"
            break
        else:
            arr.add(rr)
            n = int(b-rr)/r
            n += 1 if (b-rr)%r != 0
            rr = (n*r + rr)%b
print(ret)



Fixed submission:
a,b,c = [int(i) for i in input().split()]
arr = set()
ret = "NO"
r = a%b
if r==0:
    if c==0:
        ret="YES"
    else:
        pass
elif r==1:
    ret = "YES"
else:
    rr = r
    while not(rr in arr):
        # print(arr,rr)
        if rr <= c and (c-rr)%r == 0:
            ret = "YES"
            break
        else:
            arr.add(rr)
            n = int((b-rr)/r)
            n += 1 if (b-rr)%r != 0 else 0
            rr = (n*r + rr)%b
            # print(n,rr)
print(ret)
Buggy python submission (verdict: Runtime Error):
o = input()
e = input()
ret = ""
for i in range(len(o) + len(e)):
    if i % 2 == 0:
        ret += o[i/2]
    else:
        ret += e[i/2]
print(ret)


Fixed submission:
o = input()
e = input()
ret = ""
for i in range(len(o) + len(e)):
    if i % 2 == 0:
        ret += o[i//2]
    else:
        ret += e[i//2]
print(ret)
Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split())
if a < 10 and b < 10:
  return a * b
else:
  return -1

Fixed submission:
a,b = map(int, input().split())
if a < 10 and b < 10:
  print(a * b)
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
S, T = input().split()

correct = 0
for i in range(0, 3):
    if S[i] == T[i]:
        correct += 1
        
print(correct)

Fixed submission:
# https://atcoder.jp/contests/abc139/tasks/abc139_a
S = input()
T = input()

correct = 0
for i in range(0, 3):
    if S[i] == T[i]:
        correct += 1
        
print(correct)
Buggy python submission (verdict: Runtime Error):
import numpy as np

i = list(map(int, input().split()))
N = i[0]
R = i[1]

if N>=10:
    print(R)
else:
    print(R-(100*(10-N))

Fixed submission:
import numpy as np

i = list(map(int, input().split()))
N = i[0]
R = i[1]

if N>=10:
    print(R)
else:
    print(R+(100*(10-N)))
Buggy python submission (verdict: Runtime Error):
line1 = list(raw_input())
line2 = list(raw_input())
overall = list1 + list2

gyaku = overall[::-1]

if overall == gyaku:
    print("YES")
else:
    print("NO")

Fixed submission:
line1 = list(input())
line2 = list(input())
overall = line1 + line2

gyaku = overall[::-1]

if overall == gyaku:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
N, K = input().split()
N = int(N)
K = int(K)
H = input()
H = [int(i) for i in H.split()]
H.sort(reverse = True)

while (K > 0):
  del H[0]
  K -=1
  if len(H) == 0:
    break

print(sum(H))

Fixed submission:
N, K = input().split()
N = int(N)
K = int(K)
H = input()
H = [int(i) for i in H.split()]
H.sort()
while (K > 0 and len(H) != 0):
  del H[-1]
  K -=1
print(sum(H))
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

N=int(input())
if N % 2 == 0:
    print(N//2)
else
    print(N//2 + 1)

Fixed submission:
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

N=int(input())
if N % 2 == 0:
    print(N//2)
else:
    print(N//2 + 1)
Buggy python submission (verdict: Time Limit Exceeded):

N, K=map(int, input().split())
Pn=list(map(int, input().split()))
V = [0] * N
ans = [0] * K
max_v = 0
for n in range(N):
    V[n] = (0.5*Pn[n]*(Pn[n]+1))/Pn[n]
    ans.pop(0)
    ans.append(V[n])
    max_v = max(max_v, sum(ans))
print(max_v)

Fixed submission:
N, K=map(int, input().split())
Pn=list(map(int, input().split()))
V = [0] * N
ans = [0] * K
max_v = 0
sum_v = 0
for n in range(N):
    V[n] = (0.5*Pn[n]*(Pn[n]+1))/Pn[n]
    if n < K:
        sum_v += V[n]
        max_v = sum_v
    else:
        sum_v = sum_v - V[n-K] + V[n]
        max_v = max(max_v, sum_v)
print(max_v)

Buggy python submission (verdict: Time Limit Exceeded):

N, K=map(int, input().split())
Pn=list(map(int, input().split()))
V = [0] * N
ans = [0] * K
max_v = 0
for n in range(N):
    V[n] = (0.5*Pn[n]*(Pn[n]+1))/Pn[n]
    ans.pop(0)
    ans.append(V[n])
    max_v = max(max_v, sum(ans))
print(max_v)

Fixed submission:
N, K=map(int, input().split())
Pn=list(map(int, input().split()))
V = [0] * N
ans = [0] * K
max_v = 0
sum_v = 0
for n in range(N):
    V[n] = (0.5*Pn[n]*(Pn[n]+1))/Pn[n]
    if n < K:
        sum_v += V[n]
        max_v = sum_v
    else:
        sum_v = sum_v - V[n-K] + V[n]
        max_v = max(max_v, sum_v)
print(max_v)

Buggy python submission (verdict: Time Limit Exceeded):
N, K=map(int, input().split())
Pn=list(map(int, input().split()))
V = [0] * N
ans = 0
for n in range(N-K+1):
    tmp = 0
    for i in range(K):
        V[n+i] = (0.5*Pn[n+i]*(Pn[n+i]+1))/Pn[n+i]
        tmp += V[n+i]
    ans = max(ans, tmp)

print(ans)

Fixed submission:
N, K=map(int, input().split())
Pn=list(map(int, input().split()))
V = [0] * N
ans = [0] * K
max_v = 0
sum_v = 0
for n in range(N):
    V[n] = (0.5*Pn[n]*(Pn[n]+1))/Pn[n]
    if n < K:
        sum_v += V[n]
        max_v = sum_v
    else:
        sum_v = sum_v - V[n-K] + V[n]
        max_v = max(max_v, sum_v)
print(max_v)

Buggy python submission (verdict: Time Limit Exceeded):
N, K=map(int, input().split())
Pn=list(map(int, input().split()))
V = [0] * N
for n in range(N):
    V[n] = (0.5*Pn[n]*(Pn[n]+1))/Pn[n]
ans = 0
for n in range(N):
    ans = max(ans, sum(V[n:n+K]))
print(ans)

Fixed submission:
N, K=map(int, input().split())
Pn=list(map(int, input().split()))
V = [0] * N
ans = [0] * K
max_v = 0
sum_v = 0
for n in range(N):
    V[n] = (0.5*Pn[n]*(Pn[n]+1))/Pn[n]
    if n < K:
        sum_v += V[n]
        max_v = sum_v
    else:
        sum_v = sum_v - V[n-K] + V[n]
        max_v = max(max_v, sum_v)
print(max_v)

Buggy python submission (verdict: Time Limit Exceeded):
N, K=map(int, input().split())
Pn=list(map(int, input().split()))
V = [0] * N
for n in range(N):
    for p in range(1, Pn[n]+1):
        V[n] += p/Pn[n]
ans = 0
for n in range(N):
    ans = max(ans, sum(V[n:n+K]))
print(ans)

Fixed submission:
N, K=map(int, input().split())
Pn=list(map(int, input().split()))
V = [0] * N
ans = [0] * K
max_v = 0
sum_v = 0
for n in range(N):
    V[n] = (0.5*Pn[n]*(Pn[n]+1))/Pn[n]
    if n < K:
        sum_v += V[n]
        max_v = sum_v
    else:
        sum_v = sum_v - V[n-K] + V[n]
        max_v = max(max_v, sum_v)
print(max_v)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

N, K=map(int, input().split())
HP=sorted(list(map(int, input().split())), reverse=True)

for i in range(K):
    if len(HP) > 0:
        HP.pop(0)

print(sum(HP))

Fixed submission:
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

N, K=map(int, input().split())
HP=sorted(list(map(int, input().split())), reverse=True)
cnt = 0
for i in range(N):
    if K > 0:
        K -= 1
        continue
    cnt += HP[i]

print(cnt)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

H, N=map(int, input().split())
dp = [0 for i in range(H + 1)]

hm = list(list(map(int, input().split())) for i in range(N))

for i in range(1, H+1):
    dp[i] = min(list(dp[i - h] + m for h, m in hm))
print(dp[H])

Fixed submission:
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

H, N=map(int, input().split())
dp = [0 for i in range(H + 10**4 + 1)]

hm = list(list(map(int, input().split())) for i in range(N))

for i in range(1, H+1):
    dp[i] = min(list(dp[i - h] + m for h, m in hm))
print(dp[H])

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

H, N=map(int, input().split())
dp = [0 for i in range(H + 10)]

hm = list(list(map(int, input().split())) for i in range(N))

for i in range(1, H+1):
    dp[i] = min(list(dp[i - h] + m for h, m in hm))
print(dp[H])

Fixed submission:
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

H, N=map(int, input().split())
dp = [0 for i in range(H + 10**4 + 1)]

hm = list(list(map(int, input().split())) for i in range(N))

for i in range(1, H+1):
    dp[i] = min(list(dp[i - h] + m for h, m in hm))
print(dp[H])
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left

N=int(input())
Pn=list(map(int, input().split()))
cnt = 0
for i in range(N):
    p_i = Pn[i]
    p_j = min(Pn[:i+1])
    if p_i <= p_j:
        cnt += 1
print(cnt)

Fixed submission:
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left

N=int(input())
Pn=list(map(int, input().split()))
p_min = [10**5 + 7 for i in range(N+1)]

cnt = 1
p_min[0] = Pn[0]
for i in range(1, N):
    p_i = Pn[i]
    p_j = min(p_i, p_min[i-1])
    p_min[i] = p_j
    if p_i <= p_j:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
S=input()

print(chr(ord(S)+1)

Fixed submission:
S=input()

print(chr(ord(S)+1))
Buggy python submission (verdict: Runtime Error):
S,T=map(int, input().split())
print(T+S)

Fixed submission:
S,T=map(str, input().split())
print(T+S)
Buggy python submission (verdict: Time Limit Exceeded):
A,B,K=map(int, input().split())

for i in range(K):
    if A > 0:
          A -= 1
    elif B > 0:
        B -= 1
    else:
        pass

print(str(A) + " " + str(B))

Fixed submission:
A,B,K=map(int, input().split())

if A - K >= 0:
    print(str(A-K) + " " + str(B))
else:
    if B-(K-A) < 0:
        B = 0
    else:
        B = B-(K-A)
    print("0 " + str(B))
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()

if n % 2 != 0:
  print('No')
else:
  m = n/2
  if s[:m-1] == s[m:]:
    print('Yes')

Fixed submission:
n=int(input())
s=input()

if n % 2 != 0:
  print('No')
else:
  m = int(n/2)
  if s[:m] == s[m:]:
    print('Yes')
  else:
    print('No')
Buggy python submission (verdict: Runtime Error):
a,b=map(int, input())
if (1 <= a and a <= 9) and (1<= b and b <= 9):
    print(a*b)
else:
    print(-1)


Fixed submission:
a,b=map(int, input().split())
if (1 <= a and a <= 9) and (1<= b and b <= 9):
    print(a*b)
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
a,b=map(int, input())
if 1 <= a <= 9 and 1<= b <= 9:
    print(a*b)
else:
    print(-1)


Fixed submission:
a,b=map(int, input().split())
if (1 <= a and a <= 9) and (1<= b and b <= 9):
    print(a*b)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input())

if (a/2 >= b):
    print(0)
else:
    print(2*(a/2 - b))


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

if (a/2 <= b):
    print(0)
else:
    print(int(2*(a/2 - b)))
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

N, M=map(int, input().split())
dp = [INF] * 2**N
dp[0] = 0
for i in range(M):
    A, B = map(int, input().split())
    C = sum([2**(int(i)-1) for i in input().split()])
    for s in range(2**N):
        t = s | C
        dp[t] = min(dp[t], dp[s] + A)
ans = dp[-1]
if ans == INF:
    ans = -1
print(ans)


Fixed submission:
#!/usr/bin/env python3
n, m = map(int, input().split())
dp = [float('inf')] * 2**n
dp[0] = 0
for _ in range(m):
    a, _ = map(int, input().split())
    c = sum([2**(int(i)-1) for i in input().split()])
    for s in range(2**n):
            t = s|c
            if dp[t] > dp[s] + a:
                dp[t] = dp[s] + a
ans = dp[-1]
if ans == float('inf'):
    ans = -1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

N, M=map(int, input().split())
dp = [INF] * 2**N
dp[0] = 0
for i in range(M):
    A, B = map(int, input().split())
    C = sum([2**(int(i)-1) for i in input().split()])
    for s in range(2**N):
        t = s | C
        dp[t] = min(dp[t], dp[s] + A)
ans = dp[-1]
if ans == INF:
    ans = -1
print(ans)


Fixed submission:
#!/usr/bin/env python3
n, m = map(int, input().split())
dp = [float('inf')] * 2**n
dp[0] = 0
for _ in range(m):
    a, _ = map(int, input().split())
    c = sum([2**(int(i)-1) for i in input().split()])
    for s in range(2**n):
            t = s|c
            if dp[t] > dp[s] + a:
                dp[t] = dp[s] + a
ans = dp[-1]
if ans == float('inf'):
    ans = -1
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b=int(input().split())
print(max([a+b,a-b,a*b]))

Fixed submission:
a,b=map(int,input().split())
print(max([a+b,a-b,a*b]))

Buggy python submission (verdict: Runtime Error):
a,b=int(input().split())
print(max[a+b,a-b,a*b])

Fixed submission:
a,b=map(int,input().split())
print(max([a+b,a-b,a*b]))