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

Fixed submission:
N = int(input())
str = input()
new_str = ''
 
for x in str:
  temp = ord(x)+N
  if temp>90:
    new_str += chr(temp - 26)
  else:
    new_str += chr(temp)
 
print(new_str)

Buggy submission (verdict: Runtime Error):
N = input()
str = input()
new_str = ""

for x in str:
  temp = ord(x)+N
  if temp>90:
    str += chr((ord(x)+N) - 26)
  else:
    str += chr(ord(x)+N)

print(new_str)
Problem p02898 (python)

Fixed submission:
N, K = map(int, input().split())
h = list(map(int, input().split()))
count=0
 
for i in range(N):
  if h[i] >= K:
    count+=1
 
print(count)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
h = list(map(int, input().split()))
count=0
 
while i in range(N):
  if h[i] >= K:
    count+=1
 
print(count)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
h = list(map(int, input().split()))
count=0

while i in range(N):
  if(h[i] >= K):
    count+=1

print(count)
Problem p03030 (python)

Fixed submission:
from operator import itemgetter
n = int(input())
arr_ = [[str(i) for i in input().split()] for _ in range(n)]
for i in range(n):
    arr_[i].append(i+1)
    arr_[i][1] = int(arr_[i][1])

arr_.sort(key=itemgetter(1), reverse=True)
arr_.sort(key=itemgetter(0))
for i in range(n):
    print(arr_[i][2])

Buggy submission (verdict: Runtime Error):
import pandas as pd
n = int(input())
arr_ = [[str(i) for i in input().split()] for _ in range(n)]
arr = pd.DataFrame(arr_)
arr[2] = [i for i in range(n)]
num = arr.sort_values(by=1,ascending=False)
name = num.sort_values(by=0,ascending=True)
name.index = [i for i in range(n)]
for i in range(n):
    print(name[2][i]+1)
Problem p03047 (python)

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

ans = n - k +1
print(ans)

Buggy submission (verdict: Runtime Error):
r, g, b, n = map(int, input().split())

ans = 0

for x in range(n+1):
    for y in range(n+1):
        if r*x + g*y >n:
            break
        for z in range(n+1):
            w = r*x + g*y + b*z
            if w>n:
                break
            if w == n:
                ans+=1
print(ans)
Problem p03076 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

g = []
g.append(a)
g.append(b)
g.append(c)
g.append(d)
g.append(e)

G = []

A=a%10
B=b%10
C=c%10
D=d%10
E=e%10

G.append(A)
G.append(B)
G.append(C)
G.append(D)
G.append(E)

min_except0 = G[:]

for i in range(4):
    try:
        min_except0.remove(0)
    except:
        pass
x = G.index(min(min_except0))

loop = [0,1,2,3,4]
loop.remove(x)

answer = 0
for i in loop:
  answer += g[i]
  answer += 10-G[i]
answer += g[x]

minas = 10*(5 - len(min_except0))

answer -= minas

print(answer)

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

g = []
g.append(a)
g.append(b)
g.append(c)
g.append(d)
g.append(e)

G = []

A=a%10
B=b%10
C=c%10
D=d%10
E=e%10

G.append(A)
G.append(B)
G.append(C)
G.append(D)
G.append(E)

min_except0 = G

for i in range(4):
  min_except0.remove(0)

x = G.index(min(min_except0))

loop = [0,1,2,3,4]
loop.remove(x)

answer = 0
for i in loop:
  answer += g[i]
  answer += 10-G[i]
answer += g[x]

print(answer)
Problem p03240 (python)

Fixed submission:
def check():
    for k in range(0,n):
        if h[k]!=0:
            break
    for i in range(0,101):
        for j in range(0,101):
            flag=True
            h1=abs(i-x[k])+abs(j-y[k])+h[k]
            for l in range(0,n):
                if h[l]!=max(h1-abs(i-x[l])-abs(j-y[l]),0):
                    flag=False
                    break
            if flag==True:
                print(i,j,h1)
                return
            
n=int(input())
x=[0 for i in range(0,n)]
y=[0 for i in range(0,n)]
h=[0 for i in range(0,n)]
for i in range(0,n):
    x[i],y[i],h[i]=map(int,input().split())
check()

Buggy submission (verdict: Runtime Error):
def check():
    for k in range(0,n):
        if h[k]!=0:
            break
    for i in range(0,101):
        for j in range(0,101):
            flag=True
            h1=abs(i-x[k])+abs(j-y[k])+h[k]
            for l in range(k+1,n):
                if h[l]!=max(h1-abs(i-x[l])-abs(j-y[l]),0)
                    flag=False
                    break
            if flag==True:
                print(i,j,h1)
                return
            
n=int(input())
x=[0 for i in range(0,n)]
y=[0 for i in range(0,n)]
h=[0 for i in range(0,n)]
for i in range(0,n):
    x[i],y[i],h[i]=map(int,input().split())
check()
Problem p03274 (python)

Fixed submission:
n,k=list(map(int, input().split()))
x=list(map(int, input().split()))
t=0
tmin=2*(x[n-1]-x[0])
for i in range (0,n-k+1):
    if x[i]>=0:
        t=x[i+k-1]
    else:
        if x[i+k-1]<=0:
            t=abs(x[i])
        else:
            if -1*x[i]<x[i+k-1]:
                t=-2*x[i]+x[i+k-1]
            else:
                t=-1*x[i]+2*x[i+k-1]
    if t<tmin:
        tmin=t
print(tmin)

Buggy submission (verdict: Runtime Error):
a,b=input().split("\n")
n,k=a.split(" ")
x=b.split(" ")
t=0
tmin=2*(x[n-1]-x[0])
for i in range (0,n-k+1):
    if x[i]>=0:
        t=x[i+k-1]
    else:
        if x[i+k-1]<=0:
            t=abs(x[i])
        else:
            if -1*x[i]<x[i+k-1]:
                t=-2*x[i]+x[i+k-1]
            else:
                t=-1*x[i]+2*x[i+k-1]
    if t<tmin:
        tmin=t
print(tmin)
Problem p03854 (python)

Fixed submission:
a=list(input())
n=0
while n<len(a):
    oldn=n
    if a[n] == "e":
        if n+4<len(a) and a[n+1]=="r" and a[n+2]=="a" and a[n+3]=="s" and a[n+4]=="e":
            if n+5<len(a) and a[n+5]=="r":
                n=n+6
            else:
                n=n+5
    else:
        if a[n] == "d":
            if n+4<len(a) and a[n+1]=="r" and a[n+2]=="e" and a[n+3]=="a" and a[n+4]=="m":
                if n+6<len(a) and a[n+5]=="e" and a[n+6] == "r":
                    if n+7<len(a) and a[n+7]=="a":
                        n=n+5
                    else:
                        n=n+7
                else:
                    n=n+5
    if oldn == n:
        print("NO")
        break
else:
    print("YES")

Buggy submission (verdict: Runtime Error):
a=list(S)
n=0
while n<len(a):
    oldn=n
    if a[n] == "e":
        if n+4<len(a) and a[n+1]=="r" and a[n+2]=="a" and a[n+3]=="s" and a[n+4]=="e":
            if n+5<len(a) and a[n+5]=="r":
                n=n+6
            else:
                n=n+5
    else:
        if a[n] == "d":
            if n+4<len(a) and a[n+1]=="r" and a[n+2]=="e" and a[n+3]=="a" and a[n+4]=="m":
                if n+6<len(a) and a[n+5]=="e" and a[n+6] == "r":
                    if n+7<len(a) and a[n+7]=="a":
                        n=n+5
                    else:
                        n=n+7
                else:
                    n=n+5
    if oldn == n:
        print("NO")
        break
else:
    print("OK")

Buggy submission (verdict: Runtime Error):
a=list(S)
n=0
while n<len(a):
    oldn=n
    if a[n] == "e":
        if n+4<len(a) and a[n+1]=="r" and a[n+2]=="a" and a[n+3]=="s" and a[n+4]=="e":
            if n+5<len(a) and a[n+5]=="r":
                n=n+6
            else:
                n=n+5
    else:
        if a[n] == "d":
            if n+4<len(a) and a[n+1]=="r" and a[n+2]=="e" and a[n+3]=="a" and a[n+4]=="m":
                if n+6<len(a) and a[n+5]=="e" and a[n+6] == "r":
                    if n+7<len(a) and a[n+7]=="a":
                        n=n+5
                    else:
                        n=n+7
                else:
                    n=n+5
    if oldn == n:
        print("NO")
        break
else:
    print("OK")
Problem p03067 (python)

Fixed submission:
inputs = list(map(int,input().split()))
if inputs[0] < inputs[2] < inputs[1] or inputs[0] > inputs[2] > inputs[1]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
if inputs[0] <= inputs[2] and inputs[2] <= inputs[1]:
    print("Yes")
elif inputs[0] >= inputs[2] and inputs[2] >= inputs[1]:
    print("Yes")
else:
    print("No")
Problem p03067 (python)

Fixed submission:
A, B, C = map(int, input().split())
if A < C < B:
    print('Yes')
elif B < C < A:
    print('Yes')
else:
   print('No')

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())

A, B, C = map(int, input().split())
if A < C < B:
    print('Yes')
else:
   print('No')

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
if A > C:
    print('No')
elif:
   B < C:
    print('No')
else:
   print('Yes')
Problem p03085 (python)

Fixed submission:
b = input()

if b=='A':
    print('T')
elif b=='G':
    print('C')
elif b=='T':
    print('A')
else:
    print('G')

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

if b==A:
    print('T')
elif b==G:
    print('C')
elif b==T:
    print('A')
else:
    print('G')
Problem p03206 (python)

Fixed submission:
D = int(input())

if D==25:
    print('Christmas')
elif D==24:
    print('Christmas Eve')
elif D==23:
    print('Christmas Eve Eve')
elif D==22:
    print('Christmas Eve Eve Eve')

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

if D==25:
    print('Christmas')
elif D==24:
    print('Christmas Eve')
elif D==23:
    print('Christmas Eve Eve')
ellif D==22:
    print('Christmas Eve Eve Eve')

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

if D==25:
    print('Christmas')
elif D==24:
    print('Christmas Eve')
elif D==23:
    print('Christmas Eve Eve')
ellif D==22:
    print('Christmas Eve Eve Eve')

Buggy submission (verdict: Runtime Error):
if D==25:
    print('Christmas')
elif D==24:
    print('Christmas Eve')
elif D==23:
    print('Christmas Eve Eve')
else:
    print('Christmas Eve Eve Eve')
Problem p02760 (python)

Fixed submission:
A = [0]*3
for i in range(0, 3):
    A[i] = list(map(int, input().split()))
N = int(input())
b = [0]*N
for i in range(0, N):
    b[i] = int(input())
for i in range(0, 3):
    for j in range(0, 3):
        for k in range(0, N):
            if A[i][j] == b[k]:
                A[i][j] = 0
if A[0] == [0, 0, 0] or A[1] == [0, 0, 0] or A[2] == [0, 0, 0]:
    print ("Yes")
elif A[0][0] == A[1][0] == A[2][0] == 0:
    print ("Yes")
elif A[0][1] == A[1][1] == A[2][1] == 0:
    print ("Yes")
elif A[0][2] == A[1][2] == A[2][2] == 0:
    print ("Yes")
elif A[0][0] == A[1][1] == A[2][2] == 0:
    print ("Yes")
elif A[0][2] == A[1][1] == A[2][0] == 0:
    print ("Yes")
else:
    print ("No")

Buggy submission (verdict: Runtime Error):
A = [0]*3
b = [0]*N
for i in range(0, 3):
    A[i] = list(map(int, input().split()))
N = int(input())
for i in range(0, N):
    b[i] = int(input())
for i in range(0, 3):
    for j in range(0, 3):
        for k in range(0, N):
            if A[i][j] == b[k]:
                A[i][j] = 0
if A[0] == [0, 0, 0] or A[1] == [0, 0, 0] or A[2] == [0, 0, 0]:
    print ("Yes")
elif A[0][0] == A[1][0] == A[2][0] == 0:
    print ("Yes")
elif A[0][1] == A[1][1] == A[2][1] == 0:
    print ("Yes")
elif A[0][2] == A[1][2] == A[2][2] == 0:
    print ("Yes")
elif A[0][0] == A[1][1] == A[2][2] == 0:
    print ("Yes")
elif A[0][2] == A[1][1] == A[2][0] == 0:
    print ("Yes")
else:
    print ("No")

Buggy submission (verdict: Runtime Error):
A = [0]*3
b = [0]*N
for i in range(0, 3):
    A[i] = list(map(int, input().split()))
N = int(input())
for i in range(0, N):
    b[i] = int(input())
for i in range(0, 3):
    for j in range(0, 3):
        for k in range(0, N):
            if A[i][j] == b[k]:
                A[i][j] = 0
if A[0] == [0, 0, 0] or A[1] == [0, 0, 0] or A[2] == [0, 0, 0]:
    print ("Yes")
elif A[0][0] == A[1][0] == A[2][0] == 0:
    print ("Yes")
elif A[0][1] == A[1][1] == A[2][1] == 0:
    print ("Yes")
elif A[0][2] == A[1][2] == A[2][2] == 0 :
    print ("Yes")
elif A[0][0] == A[1][1] == A[2][2] == 0:
    print ("Yes")
elif A[0][2] == A[1][1] == A[2][0] == 0:
    print ("Yes")
else:
    print ("No")
Problem p02802 (python)

Fixed submission:
N, M = map(int, input().split())
p, S = [0]*M, [0]*M
for i in range(0,M):
    p[i], S[i] = input().split()
    p[i] = int(p[i])
s, t = 0, 0
res = []
for i in range(0,N):
    res.append([i,0])
for i in range(0,M):
    if S[i] == "WA":
        res[p[i]-1][1] = res[p[i]-1][1]+1
    elif res[p[i]-1][0] != -1:
        s, t = s+1, t+res[p[i]-1][1]
        res[p[i]-1][0] = -1
print(s, t)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
p_S = []
for i in range(0,M):
    a, b = input().split()
    a = int(a)
    p_S.append([a,b])
s, t = 0, 0
res = []
for i in range(0,N):
    res.append([i,0])
for i in range(0,M):
    if p_S[i][1] == "WA":
        res[p_S[i][0]][1] = res[p_S[i][0]][1]+1
    elif res[p_S[i][0]][1] >= 0:
        s, t = s+1, t+res[p_S[i][0]][1]
        res[p_S[i][0]][1] = -1
print(s, t)
Problem p02803 (python)

Fixed submission:
H, W = map(int, input().split())
S = [input() for _ in range(H)]

from collections import deque

def bfs(sy, sx):
    q = deque([[sy, sx]])
    visited = [[-1]*W for _ in range(H)]
    visited[sy][sx] = 0
    while q:
        y, x = q.popleft()
        for i, j in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y+i, x+j
            if not 0 <= new_y < H or not 0 <= new_x < W:
                continue
            if S[new_y][new_x] ==  "." and visited[new_y][new_x] == -1:
                visited[new_y][new_x] = visited[y][x]+1
                q.append([new_y, new_x])
    return max(max(l) for l in visited)

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            ans = max(ans, bfs(i, j))
print (ans)

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
S = [input().split() for _ in range(H)]

from collections import deque

def bfs(sy, sx):
    q = deque([[sy, sx]])
    visited = [[-1]*W for _ in range(H)]
    visited[sy][sx] = 0
    while q:
        y, x = q.popleft()
        for i, j in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y+i, x+j
            if not 0 <= new_y < H or not 0 <= new_x < W:
                continue
            if S[new_y][new_x] ==  "." and visited[new_y][new_x] == -1:
                visited[new_y][new_x] = visited[y][x]+1
                q.append([new_y, new_x])
    return max(max(l) for l in visited)

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            ans = max(ans, bfs(i, j))
print (ans)
Problem p02936 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N, Q = map(int, input().split())
lines = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    lines[a-1].append(b-1)
    lines[b-1].append(a-1)
ans = [0]*N
for _ in range(Q):
    p, x = map(int, input().split())
    ans[p-1] += x

def dfs(v, parent):
    for u in lines[v]:
        if u != parent:
            ans[u] += ans[v]
            dfs(u, v)

dfs(0, -1)
print (*ans)

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
lines = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    lines[a-1].append(b-1)
    lines[b-1].append(a-1)
ans = [0]*N
for _ in range(Q):
    p, x = map(int, input().split())
    ans[p-1] += x

def dfs(v, parent):
    for u in lines[v]:
        if u != parent:
            ans[u] += ans[v]
            dfs(u, v)

dfs(0, -1)
print (*ans)
Problem p03000 (python)

Fixed submission:
N, X = map(int, input().split())
L = list(map(int, input().split()))
pos, ans = 0, 1
for i in range(N):
    pos += L[i]
    if pos <= X:
        ans += 1
    else:
        break
print (ans)

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
L = list(map(int, input().split()))
pos = 0
for i in range(N+1):
    if pos <= X:
        pos += L[i]
    else:
        print (i)
        break
else:
    print (N+1)
Problem p02732 (python)

Fixed submission:
import collections

N = int(input())
A = [int(i) for i in input().split()]

u = collections.Counter(A)
sum = 0
for j, c in u.items():
    sum += int(c * (c - 1) / 2)

s = ""
for k in A:
    s += str(sum - u[k] + 1) + "\n"
print(s)

Buggy submission (verdict: Runtime Error):
import numpy as np

N = int(input())
A = [int(i) for i in input().split()]


def solve(a):
    ar = np.array(a)
    u, counts = np.unique(ar, return_counts=True)
    c = 0
    for v in counts:
        c += int(v*(v-1)/2)
    print(c)

for k in range(N):
    p_A = A[:k] + A[k+1:]
    solve(p_A)
Problem p02755 (python)

Fixed submission:
import math

A, B = [int(i) for i in input().split()]

ans = []

true_A_max = A + 0.999
true_B_max = B + 0.999

X_A = math.floor(A / 0.08)
X_max_A = math.ceil(true_A_max /0.08)
X_B = math.floor(B / 0.1)
X_max_B = math.ceil(true_B_max /0.08)

if X_max_A - X_A >= X_max_B - X_B:
    X_min = X_B
    X_max = X_max_B

else:
    X_min = X_A
    X_max = X_max_A

for X in range(X_min, X_max):
    cal_A = math.floor(X * 0.08)
    cal_B = math.floor(X * 0.1)
    
    if cal_A == A and cal_B == B:
        ans.append(X)
            
if len(ans) > 0:
    print(min(ans))
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
A, B = [int(i) for i in input().split()]

ans = []

true_A_max = A + 0.999
true_B_max = B + 0.999

X_A = math.floor(A / 0.08)
X_max_A = math.ceil(true_A_max /0.08)
X_B = math.floor(B / 0.1)
X_max_B = math.ceil(true_B_max /0.08)

if X_max_A - X_A >= X_max_B - X_B:
    X_min = X_B
    X_max = X_max_B

else:
    X_min = X_A
    X_max = X_max_A

for X in range(X_min, X_max):
    cal_A = math.floor(X * 0.08)
    cal_B = math.floor(X * 0.1)
    
    if cal_A == A and cal_B == B:
        ans.append(X)
            
if len(ans) > 0:
    print(min(ans))
else:
    print(-1)
Problem p03227 (python)

Fixed submission:
S = input()

if len(S) == 2:
    print(S)
elif len(S) == 3:
    #str_list = list(reversed(S))
    new_str = ''.join(list(reversed(S)))
    print(new_str)

Buggy submission (verdict: Runtime Error):
S = input()

if len(S) == 2:
    print(S)
elif len(S) == 3:
    str_list = list(reversed(S))
    new_str = ''.join(list(reversed(org_str)))
    print(new_str)
Problem p02760 (python)

Fixed submission:
import numpy as np

a_list = list(map(int, input().split()))
a_list_2 = list(map(int, input().split()))
a_list_3 = list(map(int, input().split()))

a_total_list = np.array([a_list, a_list_2, a_list_3])
bingo_array = np.zeros((3, 3))

N = int(input())

b_list = []

for i in range(N):
    b = int(input())
    if b in a_total_list:
        bingo_array[np.where(a_total_list == b)[0][0]][np.where(a_total_list == b)[1][0]] = 1

bingo_x_y = 0
break_flag = False
for i in range(3):
    if break_flag is True:
        break
    else:
        bingo_x = 0
        bingo_y = 0
    for j in range(3):
        if bingo_array[i][j] == 1:
            bingo_x += 1
            if bingo_x == 3:
                break_flag = True
                break
        if bingo_array[j][i] == 1:
            bingo_y += 1
            if bingo_y == 3:
                break_flag = True
                break
        if i == j:
            if bingo_array[i][j] == 1:
                bingo_x_y += 1
                if bingo_x_y == 3:
                    break_flag = True
                    break

if bingo_x >= 3:
    print("Yes")
    exit()
elif bingo_y >= 3:
    print("Yes")
    exit()
elif bingo_x_y >= 3:
    print("Yes")
    exit()
elif bingo_array[0][2] == 1 and bingo_array[1][1] == 1 and bingo_array[2][0] == 1:
    print("Yes")
    exit()
else:
    print("No")
    exit()

Buggy submission (verdict: Runtime Error):
import numpy as np

a_list = list(map(int, input().split()))
a_list_2 = list(map(int, input().split()))
a_list_3 = list(map(int, input().split()))

a_total_list = np.array([a_list, a_list_2, a_list_3])
bingo_array = np.zeros((3, 3))

N = int(input())

b_list = []

for i in range(N):
    b = int(input())
    if b in a_total_list:
        bingo_array[np.where(a_total_list == b)[0][0]][np.where(a_total_list == b)[1][0]] = 1

bingo_x_y = 0
break_flag = False
for i in range(3):
    bingo_x = 0
    bingo_y = 0
    if break_flag is True:
        break
    for j in range(3):
        if bingo_array[i][j] == 1:
            bingo_x += 1
        if bingo_x == 3:
            break_flag = True
            break
        if i == 0:
            if bingo_array[j][i] == 1:
                bingo_y += 1
            if bingo_y == 3:
                break_flag = True
                break
        if i == j:
            if bingo_array[i][j] == 1:
                bingo_x_y += 1
            if bingo_x_y == 3:
                break_flag = True
                break

if bingo_x == 3:
    print("Yes")
elif bingo_y == 3:
    print("Yes")
elif bingo_x_y == 3:
    print("Yes")
elif bingo_array[0][2] == 1 and bingo_array[1][1] == 1 and bingo_array[2][0] == 1:
    print("Yes")
else:
    print("No")
Problem p02837 (python)

Fixed submission:
N = int(input())

g_list = [[-1 for i in range(N)] for j in range(N)]

for i in range(N):
    m = int(input())
    for j in range(m):
        a_x = list(map(int, input().split()))
        a = a_x[0]
        a -= 1
        x = a_x[1]
        g_list[i][a] = x

ans = 0

for i in range(1 << N):
    d = [0 for l in range(N)]
    for j in range(N):
        if i >> j & 1:
            d[j] = 1
    ok = True
    for j in range(N):
        if d[j]:
            for k in range(N):
                if g_list[j][k] == -1:
                    continue
                if g_list[j][k] != d[k]:
                    ok = False
    if ok:
        total = list(bin(i)[2:].rjust(N, '0'))
        count = 0
        for t in total:
            if t == '1':
                count += 1
        ans = max(ans, count)

print(ans)

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

g_list = [[]]
for i in range(N):
    for j in range(N):
        g_list[i][j] = -1

for i in range(N):
    m = int(input())
    for j in range(m):
        a_x = list(map(int, input().split()))
        a = a_x[0]
        a -= 1
        x = a_x[1]
        g_list[i][a] = x

ans = 0

for i in range(1<<N):
    d = [0 for l in range(N)]
    for j in range(N):
        if i >> j & 1:
            d[j] = 1
    ok = True
    for j in range(N):
        if d[j]:
            for k in range(N):
                if g_list[j][k] == -1:
                    continue
                if g_list[j][k] != d[k]:
                    ok = False
    if ok:
        total = sum(bin(i)[2:])
        ans = max(ans, total)

print(ans)