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

Fixed submission:
from fractions import gcd
MOD = 10**9 + 7
H, W, T = map(int, input().split())
ga, gb = gcd(H, T), gcd(W, T)
H //= ga
W //= gb
ans = (pow(2, H, MOD) + pow(2, W, MOD) - 1 + pow(2, gcd(H, W)) - 2) % MOD
print(pow(ans, ga*gb, MOD))

Buggy submission (verdict: Runtime Error):
from math import gcd
MOD = 10**9 + 7
H, W, T = map(int, input().split())
ga, gb = gcd(H, T), gcd(W, T)
H //= ga
W //= gb
ans = (pow(2, H, MOD) + pow(2, W, MOD) - 1 + pow(2, gcd(H, W)) - 2) % MOD
print(pow(ans, ga*gb, MOD))

Buggy submission (verdict: Runtime Error):
from math import gcd
MOD = 10**9 + 7
H, W, T = map(int, input().split())
ga, gb = gcd(H, T), gcd(W, T)
H //= ga
W //= gb
ans = pow(2, H, MOD) + pow(2, W, MOD) - 1 + pow(2, gcd(H, W)) - 2
print(pow(ans, ga*gb, MOD))
Problem p03394 (python)

Fixed submission:
def f(x):
    return x%2==0 or x%3==0 or x%5==0

prd = list(filter(lambda x: f(x[0]) and f(x[1]), [(i, 30 - i) for i in range(1, 14)]))

pairs = []
for i in range(1, 1000):
    for j in prd:
        pairs += [i * 30 + j[0], i * 30 + j[1]]
for i in range(0, 500):
    pairs += [i * 30 + 15, (999 - i) * 30 + 15]
pairs += [4, 26, 6, 24, 8, 22, 9, 21, 10, 20, 12, 18, 14, 16]
N = int(input())
if N == 4:
    print(2, 3, 25, 30)
    exit(0)

a = [2, 3, 25]
aiv = [28, 27, 5]
if (N - len(a)) % 2 == 1: a += aiv

a += pairs
for i in range(1, 1001): a.append(i * 30)
print(" ".join(map(str, a[:N])))

Buggy submission (verdict: Runtime Error):
from math import gcd
def f(x):
    return x%2==0 or x%3==0 or x%5==0

prd = list(filter(lambda x: f(x[0]) and f(x[1]), [(i, 30 - i) for i in range(1, 14)]))

pairs = []
for i in range(1, 1000):
    for j in prd:
        pairs += [i * 30 + j[0], i * 30 + j[1]]
for i in range(0, 500):
    pairs += [i * 30 + 15, (999 - i) * 30 + 15]
pairs += [4, 26, 6, 24, 8, 22, 9, 21, 10, 20, 12, 18, 14, 16]
N = int(input())
if N == 4:
    print(2, 3, 25, 30)
    exit(0)

a = [2, 3, 25]
aiv = [28, 27, 5]
if (N - len(a)) % 2 == 1: a += aiv

a += pairs
for i in range(1, 1001): a.append(i * 30)
print(" ".join(map(str, a[:N])))
Problem p02780 (python)

Fixed submission:
n, k = map(int, input().split())
Ps = list(map(int, input().split()))

import numpy as np

Ps = np.array(Ps)

Exp_each_p = (Ps + 1) /2

sum_Exp = [sum(Exp_each_p[0:k])]
if n == 1:
    print(sum_Exp[0])
else:    
    for id in range(1, n - k + 1):
        sum_Exp.append(sum_Exp[id - 1] - Exp_each_p[id - 1] + Exp_each_p[id + k - 1])

    print(max(sum_Exp))

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

import numpy as np

Ps = np.array(Ps)

Exp_each_p = (Ps + 1) /2

sum_Exp = []
for id in range(n - k - 1):
    sum_Exp.append(sum(Exp_each_p[id:(id + k)]))

print(max(sum_Exp))
Problem p03693 (python)

Fixed submission:
# !/usr/bin python3
# -*- coding: utf-8 -*-

rgb = int(input().replace(" ", ""))

if rgb % 4 == 0:
    print('YES')

else:
    print('NO')

Buggy submission (verdict: Runtime Error):
# !/usr/bin python3
# -*- coding: utf-8 -*-

rgb = int(input().strip(' '))

if rgb % 4 == 0:
    print('YES')

else:
    print('NO')

Buggy submission (verdict: Runtime Error):
# !/usr/bin python3
# -*- coding: utf-8 -*-

rgb = int(input().join())

if rgb % 4 == 0:
    print('YES')

else:
    print('NO')

Buggy submission (verdict: Runtime Error):
# !/usr/bin python3
# -*- coding: utf-8 -*-

rgb = int(input().join())

if rgb % 4:
    print('YES')

else:
    print('NO')
Problem p02952 (python)

Fixed submission:
print(len([1 for i in range(1,int(input())+1) if len(str(i))%2 == 1]))

Buggy submission (verdict: Runtime Error):
print(len([1 for i in range(1,int(input())+1) if str(i)%2 == 1]))
Problem p03006 (python)

Fixed submission:
import collections
n = int(input())
xy =[]
for i in range(n):
    x,y = map(int,input().split())
    xy.append((x,y))
xy2 = xy[:]
c = collections.Counter()
for x,y in xy:
    for w,z in xy2:
        c[(x-w,y-z)] +=1
if n==1:
    print(1)            
else:    
    print(n-c.most_common(2)[1][1])

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
xy =[]
for i in range(n):
    x,y = map(int,input().split())
    xy.append((x,y))
xy2 = xy[:]
c = collections.Counter()
for x,y in xy:
    for w,z in xy2:
        c[(x-w,y-z)] +=1
print(n-c.most_common(2)[1][1])
Problem p03436 (python)

Fixed submission:
import collections
h,w = map(int,input().split())
s=[list(input()) for _ in range(h)]
deq = collections.deque([[0,0,0]])

while deq:
    i,j,k = deq.popleft()
    if not((i in range(h)) and (j in range(w))):
        continue
    if s[i][j] != '.':
        continue
    s[i][j]=k
    if i==h-1 and j == w-1:
        break
    deq.append([i + 1, j, k + 1])
    deq.append([i - 1, j, k + 1])
    deq.append([i, j + 1, k + 1])
    deq.append([i, j - 1, k + 1])
if s[h-1][w-1] == '#'or s[h-1][w-1] =='.':
    print(-1)
else:
    black = sum([y.count('#') for y in s])
    print(h*w-black-s[h-1][w-1]-1)

Buggy submission (verdict: Runtime Error):
import collections
h,w = map(int,input().split())
s=[list(input()) for _ in range(h)]
deq = collections.deque([[0,0,0]])

while deq:
    i,j,k = deq.popleft()
    if not((i in range(h)) and (j in range(w))):
        continue
    if s[i][j] != '.':
        continue
    s[i][j]=k
    if i==h-1 and j == w-1:
        break
    deq.append([i + 1, j, k + 1])
    deq.append([i - 1, j, k + 1])
    deq.append([i, j + 1, k + 1])
    deq.append([i, j - 1, k + 1])
if s[i][j] in '.#':
    print(-1)
else:
    black = sum([y.count('#') for y in s])
    print(h*w-black-s[h-1][w-1]-1)

Buggy submission (verdict: Runtime Error):
import collections
h,w = map(int,input().split())
s=[list(input()) for _ in range(h)]
deq = collections.deque([[0,0,0]])

while deq:
    i,j,k = deq.popleft()
    if not((i in range(h)) and (j in range(w))):
        continue
    if s[i][j] != '.':
        continue
    s[i][j]=k
    if i==h-1 and j == w-1:
        break
    deq.append([i + 1, j, k + 1])
    deq.append([i - 1, j, k + 1])
    deq.append([i, j + 1, k + 1])
    deq.append([i, j - 1, k + 1])
if s[i][j] =='.':
    print(-1)
else:
    black = sum([y.count('#') for y in s])
    print(h*w-black-s[h-1][w-1]-1)
Problem p03485 (python)

Fixed submission:
print((sum([int(i) for i in input().split()])+1)//2)

Buggy submission (verdict: Runtime Error):
s = sorted(input())
t = sorted(input())
t.reverse()
if s<t:
	print("Yes")
else:
	print("No")
Problem p03549 (python)

Fixed submission:
n,m=map(int,input().split())
print(2**m*(18*m+n)*100)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
print(2**m*(18m+n)*100)
Problem p03558 (python)

Fixed submission:
import collections
k=int(input())
lst = [k+1]*k
q = collections.deque([1])
lst[1] = 1
while q:
    a = q.pop()
    if lst[a*10%k] > lst[a]:
        lst[a*10%k] = lst[a]
        q.append(a*10%k)
    if lst[(a+1)%k]>= lst[a]+1:
        lst[(a+1)%k] = lst[a]+1
        q.appendleft((a+1)%k)
print(lst[0])

Buggy submission (verdict: Runtime Error):
k=int(input())
while k%2 == 0:
    k //=2
while k%5 == 0:
    k //=5

lst = [k+1]*k
queue = [1]
lst[1] = 1
while queue:
    a = queue.pop(0)
    if lst[a*10%k] > lst[a]:
        lst[a*10%k] = lst[a]
        queue.insert(0,a*10%k)
    if lst[(a+1)%k]>= lst[a]+1:
        lst[(a+1)%k] = lst[a]+1
        queue.append((a+1)%k)
print(lst[0])
Problem p03853 (python)

Fixed submission:
h=int(input().split()[0])
c=[input() for _ in [0]*h]
for _c in c:
    print(_c)
    print(_c)

Buggy submission (verdict: Runtime Error):
w=int(input().split()[1])
c=[input() for _ in [0]*w]
for _c in c:
    print(_c)
    print(_c)
Problem p02755 (python)

Fixed submission:
a = list(map(int,input().split()))
A = a[0]
B = a[1]
c = True
for x in range(10001):
    a = x * 0.08
    b = x * 0.1
    if A == int(a) and B == int(b):
        print(x)
        c = False
        break
if c:
    print(-1)

Buggy submission (verdict: Runtime Error):
a = list(map(int,input().split()))
x = [a[0]]
y = [a[1]]
a = []
b = []
c = 0
d = 0
while x[len(x)-1] < x[0] + 1:
    x.append(round(x[d] + 0.01,2))
    y.append(round(y[d] + 0.01,2))
    d += 1
for i in x:
    a.append(i/0.08)
for i in y:
    b.append(i/0.1)
a.extend(b)
c = round(min([z for z in set(a) if a.count(z) > 1]))
if c > 0:
    print(c)
else:
    print(-1)
Problem p02681 (python)

Fixed submission:
s = input()
t = input()

if (s + t[-1]) == t :
    print("Yes")

else :
    print("No")

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

if (a + b[-1]) == b :

   print("Yes")

else:
   print("No")

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

if (a + b[-1]) == b :

   print("Yes")

else:
   print("No")

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

if (a + b[-1]) == b :

   print("Yes")

else:
   print("No")

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

if (a + b[-1]) == b :

   print("Yes")

else:
   print("No")

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

if a + b[-1] == b :

   print("Yes")

else:
   print("No")

Buggy submission (verdict: Runtime Error):
a,b map(input().spilit())

if a + b[-1] == b :

   print("Yes")

else:
   print("No")

Buggy submission (verdict: Runtime Error):
a,b map(input().spilit().)

if a + b[-1] == b :

   print("Yes")

else:
   print("No")
Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
ans = [0 for _ in range(N)]
if N == 1:
	ans[0] = 0
else:
	ans[0] = 1
f = 1
flg = [-1 for _ in range(M + 1000)]

for _ in range(M):
	s, c = map(int, input().split())
	if s == 1 and c == 0 and N != 1: 
		f = 0
	if flg[s] != -1 and flg[s] != c:
		f = 0
	else:
		flg[s] = c
		ans[s - 1] = c

if f:
	for a in ans:
		print(a, end = "")
else:
	print(-1)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ans = [0 for _ in range(N)]
if N == 1:
	ans[0] = 0
else:
	ans[0] = 1
f = 1
flg = [-1 for _ in range(M + 1)]

for _ in range(M):
	s, c = map(int, input().split())
	if s == 1 and c == 0 and N != 1: 
		f = 0
	if flg[s] != -1 and flg[s] != c:
		f = 0
	else:
		flg[s] = c
		ans[s - 1] = c

if f:
	for a in ans:
		print(a, end = "")
else:
	print(-1)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ans = [0 for _ in range(N)]
ans[0] = 1
f = 1
flg = [-1 for _ in range(M + 1)]

for _ in range(M):
	s, c = map(int, input().split())
	if s == 1 and c == 0: 
		f = 0
	if flg[s] != -1 and flg[s] != c:
		f = 0
	else:
		flg[s] = c
		ans[s - 1] = c

if f:
	for a in ans:
		print(a, end = "")
else:
	print(-1)
Problem p02802 (python)

Fixed submission:
N, M = map(int, input().split())
seitou = [0 for _ in range(N)]
penalty = [0 for _ in range(N)]

for i in range(M):
	S = list(input().split())
	# print(S)
	num = int(S[0])
	res = S[1]
	if res == "AC":
		seitou[num - 1] = 1
	else:
		if seitou[num - 1] == 0:
			penalty[num - 1] += 1
			
# print(*seitou)
# print(*penalty)
print(sum(seitou), end=" ")

ans = 0

for i in range(N):
	if seitou[i] == 1:
		ans += penalty[i]
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
seitou = [0 for _ in range(N)]
penalty = [0 for _ in range(M)]

for i in range(M):
	S = list(input().split())
	# print(S)
	num = int(S[0])
	res = S[1]
	if res == "AC":
		seitou[num - 1] = 1
	else:
		if seitou[num - 1] == 0:
			penalty[num - 1] += 1
			
# print(*seitou)
# print(*penalty)
print(sum(seitou), end=" ")
print(sum(penalty))
Problem p02830 (python)

Fixed submission:
N = int(input())
s, t = map(str, input().split())
S = list(map(str, s))
T = list(map(str, t))

for i in range(N):
	print(S[i], end = "")
	print(T[i], end = "")

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(map(str, input()))
T = list(map(str, input()))

for i in range(N):
  print(S[i], end = "")
  print(T[i], end = "")
Problem p02900 (python)

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

def gcd(a, b):
	if b == 0: return(a)
	else : return gcd(b, a % b)
		
G = gcd(A, B)
ctr = 1
for i in range(2, int(math.sqrt(G)) + 1):
    if G == 1: 
        break
    if G % i == 0: 
        ctr += 1
    while G % i == 0:
        G /= i
        
if G == 1:        
    print(ctr)
else:
    print(ctr + 1)

Buggy submission (verdict: Runtime Error):
# 所持している鍵の集合をbitで表現する
#　鍵の集合を表す2進数が少なくなる方向に遷移することはないから，for文for文でかける

N, M = map(int, input().split())
status_money = [float('inf')] * (1 << N)
key_money = []

# 初期状態からの遷移を記録
for _ in range(M) :
    a, b = map(int, input().split())
    key_money.append(a)
    C = 0
    for c in input().split() :
        C |= (1 << int(c) - 1)
    status_money[C] = min(status_money[C], a)
    
# ある状態とある状態の組合せを全部取る
for c in range(1 << N):
    # どんな鍵の組合せでも到達できない宝箱の組合せがあるかもしれない
    if status_money[c] == float('inf'):
        continue
    for d in range(1 << N):
        # c と d の論理和をとって新しく生成される状態 e を考える
        e = c | d
        # eにあらかじめ格納されている最小コストと，今生成したコストとのminをとる
        status_money[e] = min(status_money[c] + status_money[d], status_money[e])

# そもそも到達できない場合の処理を記述       
if status_money[-1] == float('inf'):
    print(-1)
else:
    print(status_money[-1])
Problem p02913 (python)

Fixed submission:
N = int(input())
S = list(map(str, input()))

dp = [[0 for _ in range(N)] for _ in range(N)]
edge_r = N - 1
edge_d = N - 1
for i in reversed(range(N)):
	for j in reversed(range(N)):
		if i == edge_d or j == edge_r:
			if S[i] == S[j]:
				dp[i][j] = 1
			else:
				dp[i][j] = 0
		else:
			if S[i] == S[j]:
				dp[i][j] = dp[i + 1][j + 1] + 1
ans = 0
for i in range(N):
	for j in range(N):
		if i >= j:
			continue
		# ij間の距離よりもdp[i][j]が大きいならば、それはかぶってる
		tmp = min(dp[i][j], j - i)
		ans = max(tmp, ans)
		
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(map(str, input()))

def next_char(candidate, cor_char_index, ctr):
	# print("next_char")
	# print(candidate, cor_char_index, ctr)
	char = S[cor_char_index]
	satisfy = []
	for i in candidate:
		if cor_char_index < i - ctr + 1 and i + 1 < N and S[i + 1] == char:
			satisfy.append(i + 1)
	if len(satisfy) >= 1 and cor_char_index + 1 < N:
		return next_char(satisfy, cor_char_index + 1, ctr + 1)
	else:
		return ctr
	
ret = 0
for i in range(N):
	if ret > N - i:
		break
	else:
		tmp = (next_char([j for j in range(i, N)], i, 0))
		ret = max(ret, tmp)
		
print(ret)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(map(str, input()))

def next_char(candidate, cor_char_index, ctr):
	# print("next_char")
	# print(candidate, cor_char_index, ctr)
	char = S[cor_char_index]
	satisfy = []
	for i in candidate:
		if cor_char_index < i - ctr + 1 and i + 1 < N and S[i + 1] == char:
			satisfy.append(i + 1)
	if len(satisfy) >= 1:
		return next_char(satisfy, cor_char_index + 1, ctr + 1)
	else:
		return ctr
	
ret = 0
for i in range(N):
	if ret > N - i:
		break
	else:
		tmp = (next_char([j for j in range(i, N)], i, 0))
		ret = max(ret, tmp)
		
print(ret)
Problem p02918 (python)

Fixed submission:
N, K = map(int, input().split())
S = list(map(str, input()))
score = 0
for i in range(N - 1):
	if S[i] == S[i + 1]:
		score += 1
print(min(score + 2 * K, N - 1))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = list(map(str, input()))
score = 0
for i in range(1, N):
	if S[i] == S[i + 1]:
		score += 1
print(min(score + 2 * K, N - 1))
Problem p02947 (python)

Fixed submission:
N = int(input())
S = []

dic = dict()

for _ in range(N):
	s = ''.join(sorted(input()))
	
	if not s in dic:
		dic[s] = 1
	else:
		dic[s] += 1
	
ans = 0

for key, val in dic.items():
	if val > 1:
		ans += (val * (val - 1)) / 2
		
print(int(ans))

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

dic = dict()

for _ in range(N):
	s = ''.join(sorted(input()))
	
	if not s in dic:
		dic[s] = 0
	else:
		dic[s] += 1
	
ans = 0

for val in dic.values():
	if val > 1:
		ret += (val * (val - 1)) / 2
		
print(int(ans))
Problem p02995 (python)

Fixed submission:
from fractions import gcd
A, B, C, D = (map(int, input().split()))


s = int(C * D // gcd(C, D))

p  = B - A + 1 - int((B // C - (A - 1) // C) + (B // D - (A - 1) // D) - (B // s - (A - 1) // s))
print(p)

Buggy submission (verdict: Runtime Error):
import math
A, B, C, D = (map(int, input().split()))


s = C * D / math.gcd(C, D)

p  = B - A + 1 - int((B // C - (A - 1) // C) + (B // D - (A - 1) // D) - (B // s - (A - 1) // s))
print(p)

Buggy submission (verdict: Runtime Error):
import math
A, B, C, D = (map(int, input().split()))

def lcm(a, b):
	return a * b / math.gcd(a, b)

s = lcm(C, D)	

p  = B - A + 1 - int((B // C - (A - 1) // C) + (B // D - (A - 1) // D) - (B // s - (A - 1) // s))
print(p)

Buggy submission (verdict: Runtime Error):
import math
A, B, C, D = (map(int, input().split()))

def lcm(a, b):
	return a * b / math.gcd(a, b)

s = lcm(C, D)	
print(B - A + 1 - int((B // C - (A - 1) // C) + (B // D - (A - 1) // D) - (B // s - (A - 1) // s)))

Buggy submission (verdict: Runtime Error):
import math
A, B, C, D = (map(int, input().split()))

def lcm(a, b):
	return a * b / math.gcd(a, b)

s = lcm(C, D)	
print(B - A + 1 - int((B // C - (A - 1) // C) + (B // D - (A - 1) // D) - (B // s - (A - 1) // s)))
Problem p03014 (python)

Fixed submission:
H, W = map(int, input().split())

# 上下左右に余分に1マスとっとく
square = [[0 for _ in range(W)] for _ in range(H)]

for row in range(H):
	S = list(map(str, input()))
	for column in range(W):
		if S[column] == "#":
			# 下駄をはかせるの忘れない
			square[row][column] = -1
			
for row in range(H):
	done = [False for _ in range(W)]
	for column in range(W):
		if square[row][column] == -1: continue
		if done[column]: continue
		l = 1
		while column + l <= W - 1:
			if square[row][column + l] == -1: break
			l += 1
		for i in range(column, column + l):
			square[row][i] += l
			done[i] = True
			
for column in range(W):
	done = [False for _ in range(H)]
	for row in range(H):
		if square[row][column] == -1: continue
		if done[row]: continue
		l = 1
		while row + l <= H - 1:
			if square[row + l][column] == -1: break
			l += 1
		for i in range(row, row + l):
			square[i][column] += l
			done[i] = True

ret = 0			
for row in range(H):
	for column in range(W):
		ret = max(ret, square[row][column] - 1)
		
		
print(ret)

Buggy submission (verdict: Runtime Error):
import math
 
H, W = list(map(int, input().split()))

# H, W = 4, 6
board = []
L = [[0 for i in range(W)] for i in range(H)]
R = [[0 for i in range(W)] for i in range(H)]
U = [[0 for i in range(W)] for i in range(H)]
D = [[0 for i in range(W)] for i in range(H)]

# board = [['#', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '#'], ['.', '.', '.', '.', '#', '.'], ['#', '.', '#', '.', '.', '.']]

# insert elements to the board
for i in range(H):
	a = list(input())
	board.append(a)


# high_score is output values
high_score = 0
	
# round robin
for h in range(H):
	for w in range(W):
		# print(h, w)
		# board put light is envolved
		score = 1
		# if not obstacle in board[h][w]
		if board[h][w] != "#":
			# DOWN
			for i in range(1, H):
				if h + i == W:
					break
				elif board[h + i][w] == "#":
					break
			score += i - 1
			D[h][w] = i - 1
			# print(D[h][w])
			
			# UP
			if h == 0 or board[h - 1][w] == "#":
				U[h][w] = 0
			else:
				U[h][w] = U[h - 1][w] + 1
			score += U[h][w]
			# print(U[h][w])
			
			# RIGHT
			for i in range(1, W):
				if w + i == W:
					break
				elif board[h][w + i] == "#":
					break
			score += i - 1
			R[h][w] = i - 1
			# print(R[h][w])
			
			# LEFT
			if w == 0 or board[h][w - 1] == "#":
				L[h][w] = 0
			else:
				L[h][w] = L[h][w - 1] + 1
			score += L[h][w]
			# print(L[h][w])
			
			# print(score)
			if score > high_score:
				high_score = score
				
print(high_score)
Problem p03029 (python)

Fixed submission:
A, P = list(map(int, input().split()))
print((3 * A + P) // 2)

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

# kの値は特に必要ないので最初から取得しない
# S = [[1, 2], [2]]
# p = [0, 1]
S = [list(map(int,input().split()))[1:] for i in range(M)]
p = list(map(int, input().split()))

ans = 0

for i in range(1<<N): #スイッチのオンオフ状態(0, 1, 2, 3)
    count_2 = -1
    bit = list(str(bin(i))) # 0b0, 0b1, 0b10...
    fail = 0
    
    # 桁埋め処理
    ketaume = (1<<N) // 2 + 2 - len(bit) 
    if ketaume > 0:
        for i in range(ketaume):
            bit.insert(2, "0")
    # print("search target={}".format(bit))
    for s in S: #[1, 2], [2]の階層
        count_2 += 1 # 何番目のSかを数えたい
        count = 0
        for t in s: # 1, 2の階層
            # print("bit = {}".format(bit[-t]))
            if int(bit[-t]) == 1:
                count += 1 # ついているスイッチの数を数える
                
        # print("{}-> number of switch is {}".format(s, count))
                
        # ついているスイッチが偶数か奇数かを判定
        # print("if mod is {}, OK".format(p[count_2]))
        # print("")
        if not count % 2 == p[count_2]:
            fail = 1 # 望ましくなければ，失敗フラグを立ててブレイク
            break
    if fail == 0:
        # print("ans += 1")
        ans += 1
        
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
lst = []
for i in range(N):
  s, p = input().split()
  lst.append([s, p, i])
  lst_2 = sorted(lst, key = lambda x : (x[0], -1 * int(x[1])))
  
for i in lst_2:
  print(i[2] + 1)

Buggy submission (verdict: Runtime Error):
A, P = list(map(int, input()))
print((3 * A + P) // 2)
Problem p03030 (python)

Fixed submission:
N = int(input())
lst = []
for i in range(N):
  s, p = input().split()
  lst.append([s, p, i])
  lst_2 = sorted(lst, key = lambda x : (x[0], -1 * int(x[1])))
  
for i in lst_2:
  print(i[2] + 1)

Buggy submission (verdict: Runtime Error):
N = input()
lst = []
for i in range(N):
  s, p = map(int, input().split())
  lst.append([s, p, i])
  lst_2 = sort(key = lambda x : (x[0], -1 * int(x[1])))
  
for i in lst_2:
  print(i[2] + 1)

Buggy submission (verdict: Runtime Error):
N = input()
lst = []
for i in range(N):
  s, p = map(int, input().split())
  lst.append([s, p])
  lst_2 = sort(key = lambda x : (x[0], -1 * int(x[1])))
  
for i in lst_2:
  print(i[2] + 1)
Problem p03059 (python)

Fixed submission:
A, B, T = map(int, input().split())
a = T // A
total = 0

for i in range(a):
  total += B
  
print(total)

Buggy submission (verdict: Runtime Error):
A, B, T = map(int, input().split())
a = T // A
total = 0

if i in range(a):
  total += B
  
print(total)
Problem p03060 (python)

Fixed submission:
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
lst = []

for i in range(N):
	if V[i] > C[i]:
		lst.append(V[i] - C[i])

print(sum(lst))

Buggy submission (verdict: Runtime Error):
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
lst = []

for i in range(len(N)):
  lst.append(V[i] - C[i])
  
high_score = 0
  
for i in range(2 ** len(N)):
  a = str(bin(i)).split[2 :]
  b = map(int, a)
  score = 0
  for j in range(len(b)):
    score += lst[i] * b[j]
  if high_score < score:
    high_score = score
    
print(high_score)
Problem p03062 (python)

Fixed submission:
N = int(input())
A = map(int, input().split())
minus_count = 0
total = 0
minimum = 999999999999999999

for a in A:
	total += abs(a)
	if abs(a) < minimum:
		minimum = abs(a)
	if a < 0:
		minus_count += 1
			
if minus_count % 2 == 0:
	print(total)
else:
	print(total - 2 * minimum)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = map(int, input().split())
plus_count = 0
total = 0
minimum = 999999999999999999

for a in A:
	total += abs(a)
	if abs(a) < minimum:
		minimum = abs(a)
	if a >= 0:
		plus_count += 1
			
if plus_count % 2 == 0 or plus_count == N:
	print(total)
else:
	print(total + 2 * mininum)