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

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))



cnt = 0
cnt1 = 0

for i in range(N):
    cnt = cnt + A[i]

for i in range(N):
    if A[i] / cnt >= 1 / 4 / M:
        cnt1 = cnt1 + 1



if cnt1 >= M:
    print('Yes')
else:
    print('No')

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

//print(A)

cnt = 0
cnt1 = 0

for i in range(N):
    cnt = cnt + A[i]

for i in range(N):
    if A[i] / cnt > 1 / 4 / M:
        cnt1 = cnt1 + 1

//print(cnt1)

if cnt1 > M:
    print('Yes')
else:
    print('No')

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

cnt = 0
cnt1 = 0

for i in range(N):
    cnt = cnt + A[i]

for i in range(N):
    if A[i] / cnt > 1 / 4 / M:
        cnt1 = cnt1 + 1

if cnt1 > M:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A[N]=map(int,input().split())

cnt = 0
cnt1 = 0

for i in range(N):
  	cnt = cnt + A[N]

for i in range(N):
  	if  A[i]/cnt > 1/4/M:
		cnt1 =cnt1 + 1
      
if cnt1 > M:
	print('Yes')
elif
	print('No')
Problem p02727 (python)

Fixed submission:
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
pi = 0
qi = 0
ri = 0
pl = len(p)
ql = len(q)
rl = len(r)
R = 1
scr = 0
for j in range(X+Y):
  mx = max(p[pi],q[qi],r[ri])
  scr += mx
  if mx == p[pi]:
    X -= 1
    if pi+1 >= pl or X <= 0:
      p.append(0)
      pi = -1
      X = 0
    else:
      pi += 1
  elif mx == q[qi]:
    Y -= 1
    if qi+1 >= ql or Y <= 0:
      q.append(0)
      qi = -1
      Y = 0
    else:
      qi += 1
  else:
    if ri+1 >= rl or R <= 0:
      r.append(0)
      ri = -1
      R = 0
    else:
      ri += 1
      
print(scr)

Buggy submission (verdict: Runtime Error):
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
pi = 0
qi = 0
ri = 0
pl = len(p)
ql = len(q)
rl = len(r)
scr = 0
for j in range(X+Y):
  mx = max(p[pi],q[qi],r[ri])
  scr += mx
  if mx == p[pi]:
    A -= 1
    if pi >= pl or A == 0:
      p.append(0)
      pi = -1
    else:
      pi += 1
  elif mx == q[qi]:
    B -= 1
    if qi >= ql or B == 0:
      q.append(0)
      qi = -1
    else:
      qi += 1
  else:
    if ri < rl:
      ri += 1
    else:
      r.append(0)
      ri = -1
      
print(scr)
Problem p02780 (python)

Fixed submission:
import numpy as np
N,K = map(int,input().split())
q = list(map(int,input().split()))
q = np.array(q)

p = (q + 1) /2
p = p.tolist()
a = sum(p[:K])
mx = a

for i in range(0,N-K):
    a = a - p[i] + p[i+K]
    if a > mx:
        mx = a

print(mx)

Buggy submission (verdict: Runtime Error):
import numpy as np
N,K = map(int,input().split())
q = list(map(int,input().split()))
q = np.array(q)

p = (q + 1) /2
p = p.tolist()
a = sum(p[:K])
mx = a

for i in range(0,N-K):
    a = a - p[i] + p[i+K]
    if a > mx:
        mx = a

print(float(mx))

Buggy submission (verdict: Runtime Error):
import numpy as np
N,K = map(int,input().split())
q = list(map(int,input().split()))
q = np.array(q)

p = (q + 1) /2
p = p.tolist()
a = sum(p[:K])
mx = a

for i in range(0,N-K):
    a = a - p[i] + p[i+K]
    if a > mx:
        mx = a

print(mx)

Buggy submission (verdict: Runtime Error):
import numpy as np
N,K = map(int,input().split())
q = list(map(int,input().split()))
q = np.array(q)

p = (q + 1) /2
p = p.tolist()

mx = sum(p[:K])
for i in range(0,N-K):
    a = mx - p[i] + p[i+K]
    if a > mx:
        mx = a

print(mx)
Problem p03005 (python)

Fixed submission:
N,K = map(int,input().split())
if K==1:
    print("0")
else:
    print(N-K)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
if K==1:
    ptint("0")
else:
    print(N-K)
Problem p02724 (python)

Fixed submission:
n = int(input())

print(int((n/500))*1000 + int((n%500)/5)*5)

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

print(int((n/500))*1000 + int((n%500)/5))*5
Problem p02705 (python)

Fixed submission:
r=int(input())
print(r*2*3.14)

Buggy submission (verdict: Runtime Error):
num = int(input())
a=[0*num for i in range(num)]
boss=input().split(" ")
for i in range(num-1):
  a[int(boss[i])-1]+=1
for i in range(num):
  print(a[i])
Problem p02787 (python)

Fixed submission:
h,n=map(int, input().split()) 
ab=[list(map(int, input().split())) for _ in range(n)] 

INF = 10**18
dp = [INF]*(h+1)
#dp[i]: hpがiの相手に消費する魔力の最小値
dp[0]=0

for i in range(h):#i:累積ダメージi
    for j in range(n):#
        if i+ab[j][0]<=h: #
            dp[i+ab[j][0]]=min(dp[i+ab[j][0]],dp[i]+ab[j][1])
        else:
            dp[-1]=min(dp[-1],dp[i]+ab[j][1])
print(dp[-1])

Buggy submission (verdict: Runtime Error):
h,n=map(int, input().split()) 
ab=[list(map(int, input().split())) for _ in range(n)] 

INF = 10**18
dp = [INF]*(h+1)
#dp[i]: hpがiの相手に消費する魔力の最小値
dp[0]=0

for i in range(h):#i:累積ダメージi
    for j in range(n):#
        if i+A[j]<=h: #
            dp[i+A[j]]=min(dp[i+A[j]],dp[i]+B[j])
        else:
            dp[-1]=min(dp[-1],dp[i]+B[j])
print(dp[-1])
Problem p02813 (python)

Fixed submission:
import itertools
n = int(input())
p = tuple(((map(int,input().split()))))
q = tuple(((map(int,input().split()))))

num = []
for i in range(1,n+1):
    num.append(i)
ans = []
for i in itertools.permutations(num,n):
    ans.append(i)

print(abs(ans.index(p)-ans.index(q)))

Buggy submission (verdict: Runtime Error):
import itertools 
n=int(input())
p=list(map(int, input().split()))
q=list(map(int, input().split()))

cnt=0
for v in itertools.permutations(range(1,n+1), n):
    cnt +=1
    if(p==v):
        a = cnt
    if(q==v):
        b = cnt

print(abs(a-b))

Buggy submission (verdict: Runtime Error):
import itertools 
n = int(input())
p = list(map(int,input().split()))
q= list(map(int,input().split()))

cnt=0
for v in itertools.permutations(range(1,n+1), n):
    cnt +=1
    if(p==v):
        a = cnt
    if(q==v):
        b = cnt

print(abs(a-b))

Buggy submission (verdict: Runtime Error):
import itertools 
n = int(input())
p = tuple(((map(int,input().split()))))
q = tuple(((map(int,input().split()))))

cnt=0
for v in itertools.permutations(range(1,N+1), N):
    cnt +=1
    if(p==v):
        a = cnt
    if(q==v):
        b = cnt

print(abs(a-b))

Buggy submission (verdict: Runtime Error):
from itertools 
n = int(input())
p = tuple(((map(int,input().split()))))
q = tuple(((map(int,input().split()))))

cnt=0
for v in itertools.permutations(range(1,N+1), N):
    cnt +=1
    if(p==v):
        a = cnt
    if(q==v):
        b = cnt

print(abs(a-b))

Buggy submission (verdict: Runtime Error):
from itertools import permutations

n = int(input())
p = tuple(((map(int,input().split()))))
q = tuple(((map(int,input().split()))))

cnt=0
for v in permutations(range(1,N+1), N):
    cnt +=1
    if(p==v):
        a = cnt
    if(q==v):
        b = cnt

print(abs(a-b))

Buggy submission (verdict: Runtime Error):
from itertools import permutations

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

cnt=0
for v in permutations(range(1,N+1), N):
    cnt +=1
    if(p==v):
        a = cnt
    if(q==v):
        b = cnt

print(abs(a-b))

Buggy submission (verdict: Runtime Error):
from itertools import permutations

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

cnt=0
for v in permutations(range(1,N+1), N):
    cnt +=1
    if(p==v):
        a = cnt
    if(q==v):
        b = cnt

print(abs(a-b))

Buggy submission (verdict: Runtime Error):
from itertools import permutations

n = int(input())
pq=[list(map(int,list(input()))) for i in range(h)] 

cnt=0
for v in permutations(range(1,N+1), N):
    cnt +=1
    if(pq[0]==v):
        a = cnt
    if(pq[1]==v):
        b = cnt

print(abs(a-b))

Buggy submission (verdict: Runtime Error):
from itertools import permutations

n = int(input())
p=list(map(int, input().split()))
q=list(map(int, input().split()))

cnt=0
for v in permutations(range(1,N+1), N):
    cnt +=1
    if(p==v):
        a = cnt
    if(q==v):
        b = cnt

print(abs(a-b))
Problem p03106 (python)

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

def cf(x1,x2):
    cf=[]
    for i in range(1,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

print(cf(a,b)[-k])

Buggy submission (verdict: Runtime Error):
a,b,k=map(int, input().split())

def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

print(cf(a,b)[-k])
Problem p03281 (python)

Fixed submission:
N = int(input())
cnt=0
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

for i in range(1,N+1,2):
    if(len(make_divisors(i))==8):
        cnt+=1
        
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


for i in range(1,N+1,2):
    if(len(make_divisors(i))==8):
        cnt+=1
        
print(cnt)
Problem p03371 (python)

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

ans = min(a*x+b*y, c*max(x,y)*2, c*x*2+max(0,(y-x)*b), c*y*2+max(0,(x-y)*a))

print(ans)

Buggy submission (verdict: Runtime Error):
a,b,c,x,y=map(int, input().split())

ans = min(a*x+b*y, c*max(x,y)*2, c*x*2+max(0,(y-x)*b), c*y*2+max((x-y)*a)*a)

print(ans)
Problem p02705 (python)

Fixed submission:
R = int(input())

result = 3.1415926535*2*R
print(result)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
for i in range(1,N+1):
    print(A.count(i))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
for i in range(1,N+1):
    print(A.count(i))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
for i in range(1,N+1):
    print(A.count(i))
Problem p02705 (python)

Fixed submission:
from sys import stdin
a = stdin.readline().rstrip()
#print(a.upper())    # 読み込んだ文字を大文字に変換
a = int(a)
pi = 3.14159265
r = 2*pi*a
print(r)

Buggy submission (verdict: Runtime Error):
from sys import stdin
a = stdin.readline().rstrip()
#print(a.upper())    # 読み込んだ文字を大文字に変換
pi = 3.14159265
r = 2*pi*a
print(r)
Problem p03105 (python)

Fixed submission:
in_str = input()
input_list = list(map(int,in_str.split()))
per = input_list[0]
money = input_list[1]
target = input_list[2]
time = int(money/per)
ans = 0
if(time>=target):
  ans = target
else:
  ans = time
print(ans)

Buggy submission (verdict: Runtime Error):
in_str = input()
input_list = map(int,in_str)
per = input_list[0]
money = input_list[1]
target = input_list[2]
time = int(money/par)
ans = 0
if(time>=target):
  ans = target
else:
  ans = time
print(ans)
Problem p03106 (python)

Fixed submission:
in_str = input()
input_list = list(map(int,in_str.split()))
A = input_list[0]
B = input_list[1]
K = input_list[2]
count = 0
ans = 0
max = 100
for i in range(max):
  div = max-i
  if(A%div==0 and B%div==0):
    ans = div
    count+=1
    if(count==K):
      break
print(ans)

Buggy submission (verdict: Runtime Error):
in_str = input()
input_list = list(map(int,in_str.split()))
A = input_list[0]
B = input_list[1]
K = input_list[2]
count = 0
ans = 0
for i in range(100):
  if(A/i==0 and B/i==0):
    ans = i
    count+=1
    if(count==K):
      break
print(ans)
Problem p03130 (python)

Fixed submission:
p_str = input().split()
p = [int(s) for s in p_str]
p_str = input().split()
p.extend([int(s) for s in p_str])
p_str = input().split()
p.extend([int(s) for s in p_str])
#print(p)
count_list = []
for i in range(4):
   count =  p.count(i+1)
   count_list.append(count)
#print(count_list)
if(count_list.count(1)==2 and count_list.count(2)==2):
   print("YES")
else:
   print("NO")

Buggy submission (verdict: Runtime Error):
p = int(input().split())
p.extend(int(input().split()))
p.extend(int(input().split()))
#print(p)
count_list = []
for i in range(4):
   count =  p.count(i+1)
   count_list.append(count)
#==
count_list2 = []
for j in range(2):
   count2 = count_list2.count(j+1)
   count2_list.append(count2)
#==
if(count2_list.count(1)==2 and count2_list.count(1)==2):
   print("YES")
else:
   print("NO")
Problem p02705 (python)

Fixed submission:
if __name__ == '__main__':
    N = int(input())
    import math
    print(2*N*(math.pi))

Buggy submission (verdict: Runtime Error):
import math

if __name__ == '__main__':
    N = int(input())
    print(N*N(math.pi)

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
    N = int(input())
    import math
    print(N*N(math.pi)

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
    N = int(input())
    import math
    print(N*N(math.pi)
Problem p02706 (python)

Fixed submission:
if __name__ == '__main__':
    N, M = [int(x) for x in input().split()]
    arr = [int(x) for x in input().split()]
    res = N - sum(arr)
    if res < 0:
        print(-1)
    else:
        print(res)

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
    N, M = [int(x) for x in input().split()]
    arr = [int(x) for x in input().split()]
    res = N - sum(arr)
    if res < 0:
        print(-1)
    else:
Problem p02713 (python)

Fixed submission:
import math
from functools import lru_cache

@lru_cache(maxsize=10**6)
def cached_gcd(i, j):
    return math.gcd(i, j)

if __name__ == '__main__':
    N = int(input())
    total = 0
    for i in range(1, N + 1):
        for j in range(1, N + 1):
            g = cached_gcd(j, i)
            for k in range(1, N + 1):
                total += cached_gcd(k, g)
    print(total)

Buggy submission (verdict: Runtime Error):
@lru_cache(maxsize=10**5)
def cached_gcd(i, j):
    return math.gcd(i, j)

if __name__ == '__main__':
    N = int(input())
    total = 0
    for i in range(1, N + 1):
        for j in range(1, N + 1):
            g = cached_gcd(j, i)
            for k in range(1, N + 1):
                total += cached_gcd(k, g)
    print(total)

Buggy submission (verdict: Runtime Error):
@lru_cache(maxsize=10**6)
def cached_gcd(i, j):
    return math.gcd(i, j)

if __name__ == '__main__':
    N = int(input())
    total = 0
    for i in range(1, N + 1):
        for j in range(1, N + 1):
            g = cached_gcd(j, i)
            for k in range(1, N + 1):
                total += cached_gcd(k, g)
    print(total)
Problem p03076 (python)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
s=a+b+c+d+e
li=[a,b,c,d,e]
for i in range(5) :
   li[i]=10-(li[i]%10)
while 10 in li :
   li.remove(max(li))
if len(li)>0 :
   li.remove(max(li))
print(s+sum(li))

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
s=a+b+c+d+e
li=[a,b,c,d,e]
for i in range(5) :
   li[i]=10-(li[i]%10)
while max(li)==10 :
   li.remove(max(li))
li.remove(max(li))
print(s+sum(li))

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
s=a+b+c+d+e
li=[a,b,c,d,e]
for i in range(5) :
   li[i]=10-(li[i]%10)
while max(li)==10 :
   li.remove(max(li))
li.remove(max(li))
s+=sum(li)
print(s)
Problem p03455 (python)

Fixed submission:
a,b = map(int,input().split())
if a<0 or b<0 :
    print("negative!")
elif a>10000 or b>10000 :
    print("too big!")
elif a*b%2==0 :
    print("Even")
else :
    print("Odd")

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
if a<0 or b<0 :
    print("negative!")
elif a>10000 or b>10000 :
    print("too big!")
elif a*b%2==0 :
    print("Even")
else :
    print("Odd")

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
if a<0 or b<0 :
    print("negative!")
elif a>10000 or b>10000 :
    print("too big!")
elif a*b%2==0 :
    print("even")
else :
    print("odd")

Buggy submission (verdict: Runtime Error):
if (int(input())*int(input()))%2==0 :
    print("even")
else :
    print("odd")
Problem p02885 (python)

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

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

Buggy submission (verdict: Runtime Error):
n = int(input())
ln = input().split()
s = 0

for i in range(n):
  for j in range(i + 1, n):
    s += int(ln[i]) * int(ln[j])
    
print(s)
Problem p03068 (python)

Fixed submission:
n = int(input())
str = input()
k = int(input())

c = str[k-1]
str2 = ""
for char in str:
  if char == c:
    str2 += c
  else:
    str2 += "*"
    
print(str2)

Buggy submission (verdict: Runtime Error):
n = int(input())
str = input()
k = int(input())

c = str[k-1]
str2 = ""
for char in str:
  if char == c:
    s += c
  else:
    s += *
    
print(s)
Problem p03760 (python)

Fixed submission:
O = input()
N = input()

pw = ""
if len(O) == len(N):
    for i in range(len(O)):
        pw += O[i] + N[i]
else:
    for i in range(len(O)-1):
        pw += O[i] + N[i]
    pw += O[-1]
   
print(pw)

Buggy submission (verdict: Runtime Error):
O = input()
N = input()

pw = ""
if len(O) == len(N):
    for i in range(len(O)):
        pw += O[i] + N[i]
else:
    for i in range(len(O)):
        pw += O[i] + N[i]
    pw += O[-1]
   
print(pw)

Buggy submission (verdict: Runtime Error):
O = input()
N = input()

pw = ""
if len(O) = len(N):
	for i in range(len(O)):
    	pw += O[i] + N[i]
else:
	for i in range(len(O)-1):
    	pw += O[i] + N[i]
    pw += O[-1]
   
print(pw)
Problem p03777 (python)

Fixed submission:
a, b = input().split()
print("H" if a == b else "D")

Buggy submission (verdict: Runtime Error):
a, b = input.split()
print("H" if a == b else D"")
Problem p03860 (python)

Fixed submission:
str = input()

print("A" + str[8] + "C")

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
c = input()

print("A" + b + "C")
Problem p04044 (python)

Fixed submission:
n, l = map(int, input().split(" "))
ln = []

for i in range(n):
  ln.append(input())
  
ln.sort()

s = ""
for word in ln:
  s += word
  
print(s)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = int(input())
ln = []

for i in range n:
  ln.append(input())
  
ln.sort()

s = ""

for word in ln:
  s += word
  
print(s)
Problem p02706 (python)

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

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = 0
for _ in range(m):
  a += int(input())
if a > n: print(-1)
else: print(n-a)
Problem p02730 (python)

Fixed submission:
def check(s: str):
    return s == s[::-1]


s = input()
n = len(s)
if check(s) and check(s[:(n-1)//2]):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
def check(s: str):
    return s == s[::-1]


s = input()
if check(s) and check(s[:(n-1)//2]):
    print("Yes")
else:
    print("No")
Problem p02732 (python)

Fixed submission:
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
all_comb = 0
for v in c.values():
    all_comb += v*(v-1)/2

for i in range(n):
    tmp = c[a[i]]
    print(int(all_comb-tmp+1))

Buggy submission (verdict: Runtime Error):
from collections import Counter
from copy import deepcopy

n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
for v in c.values():
    all_comb += v*(v-1)/2

for i in range(n):
    tmp = c[a[i]]
    print(all_comb - 2*(tmp-1))
Problem p02791 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 0
minimum = n

for i in range(n):
    if a[i] <= minimum:
        ans += 1
        minimum = a[i]

print(ans)

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

for i in range(n):
    if a[n] <= min(a[:n+1]):
        ans += 1

print(ans)

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

for i in range(n):
    if a[n] <= min(a[:n]):
        ans += 1

print(ans)
Problem p03031 (python)

Fixed submission:
n, m = map(int, input().split())
s = [list(map(int, input().split()))[1:] for _ in range(m)]
p = list(map(int, input().split()))
ans = 0

for i in range(1<<n):
    for j in range(m):
        cnt = 0
        for num in s[j]:  
            if i&(1<<(num-1)) != 0:
                cnt += 1
        if cnt%2 != p[j]: #j番目の電球でアウト
            break
    else: #すべての電球でパス
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict

n, m = map(int, input().split())
li_ord = [0 for _ in range(m)]
dic = defaultdict(list)

for i in range(m):
    s = list(map(int, input().split()))[1:]
    for j in s:
        dic[j].append(i)
p = list(map(int, input().split()))
dic = sorted(dict(dic).items())
ans = 0

if dic == []:
    if 1 in p:
        print(0)
    else:
        print(2**n)
    exit()

for i in range(2**n):
    tmp_num = bin(i)[2:].zfill(n)
    li = li_ord
    for j in range(n):
        digit = tmp_num[j]
        #print(digit, dic[j][1])
        if digit == '1':
            for k in dic[j][1]:
                #print(li[k], k)
                li[k] ^= 1
    #print(tmp_num, p, li)
    if p == li:
        ans += 1

print(ans)
Problem p03061 (python)

Fixed submission:
from functools import reduce
from fractions import gcd

n = int(input())
a = list(map(int, input().split()))
A = list(set(a))
ans = [reduce(gcd, A)]

if len(A) == 1:
    print(A[0])
    exit()
for i in A:
    b = sorted(A)
    b.remove(i)
    if a.count(i) == 1:
        ans.append(reduce(gcd, b))

print(max(ans))

Buggy submission (verdict: Runtime Error):
from functools import reduce
from fractions import gcd

n = int(input())
a = list(map(int, input().split()))
A = list(set(a))
ans = []

for i in a:
    b = sorted(A)
    b.remove(i)
    ans.append(reduce(gcd, b))

print(max(ans))
Problem p03076 (python)

Fixed submission:
ans = 0
a = []
for _ in range(5):
    x = int(input())
    if x%10 == 0:
        ans += x
    else:
        ans += (x//10)*10
        a.append(x%10)

ans += (len(a)-1)*10
if a != []:
    ans += min(a)
else:
    ans += 10

print(ans)

Buggy submission (verdict: Runtime Error):
ans = 0
a = []
for _ in range(5):
    x = int(input())
    if x%10 == 0:
        ans += x
    else:
        ans += (x//10)*10
        a.append(x%10)

ans += (len(a)-1)*10
ans += min(a)

print(ans)
Problem p03078 (python)

Fixed submission:
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ab, abc = [], []

for i in a:
    for j in b:
        ab.append(i+j)

ab.sort()
s = ab[x*y-k:]
for i in s:
    for j in c:
        abc.append(i+j)

abc.sort(reverse=True)
for i in range(k):
    print(abc[i])

Buggy submission (verdict: Runtime Error):
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split())))
ab, abc = [], []

for i in a:
    for j in b:
        ab.append(i+j)

ab.sort()
s = ab[x*y-k:]
for i in s:
    for j in c:
        abc.append(i+j)

abc.sort(reverse=True)
for i in range(k):
    print(abc[i])
Problem p03146 (python)

Fixed submission:
def collatz(a):
    if a%2 == 0:
        return int(a/2)
    else:
        return int(a*3+1)

x = []
n = int(input())
x.append(n)
test = n

for i in range(1, 1000001):
    a = collatz(test)
    if a in x:
        print(i+1)
        exit()
    else:
        x.append(a)
        test = a

Buggy submission (verdict: Runtime Error):
def collatz(a):
    if a%2 == 0:
        return int(a/2)
    else:
        return int(a*3+1)

x = [int(input())]

for i in range(1, 1000001):
    a = collatz(x[i-1])
    if a in x:
        print(i+1)
    else:
        x.append(a)