Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[0]*N
shougen=[[] for i in range(0,N)]
for i in range(0,N):
    A[i]=int(input())
    for j in range(0,A[i]):
        a,b=map(int,input().split())
        shougen[i].append([a,b])
m=0
for i in range(0,2**N):
    flag=0
    check=[]
    for j in range(0,N):
        if i>>j & 1==1:
            check.extend(shougen[j])
    for j in range(0,N):
        if ([j+1,0] in check) or ([j+1,1] in check):
            if [j+1,0] in check:
                if j==0:
                    data=[0]
                else:
                    data.append(0)
            if [j+1,1] in check:
                if j==0:
                    data=[1]
                else:
                    data.append(1)

        else:
            if j==0:
                data=[2]
            else:
                data.append(2)
    for j in range(0,N):
        if data[j]!=2:
            if int(data[j])!=(i>>j)%2 :
                flag=1
    if len(data)!=N:
        flag=1
    if flag==0:
        test=sum(i>>j &1 for j in range(0,N))
        if test>m:
            m=test

print(m)


Fixed submission:
N=int(input())
shougen=[(0,0) for i in range(0,N)]
for i in range(0,N):
    A=int(input())
    honest=0
    unkind=0
    for j in range(0,A):
        x,y=map(int,input().split())
        if y==0:
            unkind+=2**(x-1)
        else:
            honest+=2**(x-1)
    shougen[i]=(honest,unkind)

ans=0
for i in range(0,2**N):
    honest=i
    unkind=2**N-1-i
    check=True
    test=0
    for j in range(0,N):
        if (i>>j)&1 ==1:
            test+=1
            x,y=shougen[j]
            if (honest-x)^x!=honest or (unkind-y)^y!=unkind:
                check=False
    if check:
        if test>ans:
            ans=test

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[0]*N
shougen=[[] for i in range(0,N)]
for i in range(0,N):
    A[i]=int(input())
    for j in range(0,A[i]):
        a,b=map(int,input().split())
        shougen[i].append([a,b])
m=0
for i in range(0,2**N):
    flag=0
    check=[]
    for j in range(0,N):
        if i>>j & 1==1:
            check.extend(shougen[j])
    for j in range(0,N):
        if ([j+1,0] in check) or ([j+1,1] in check):
            if [j+1,0] in check:
                if j==0:
                    data=[0]
                else:
                    data.append(0)
            if [j+1,1] in check:
                if j==0:
                    data=[1]
                else:
                    data.append(1)

        else:
            if j==0:
                data=[2]
            else:
                data.append(2)
    for j in range(0,N):
        if data[j]!=2:
            if int(data[j])!=(i>>j)%2 :
                flag=1
    if len(data)!=N:
        flag=1
    if flag==0:
        test=sum(i>>j &1 for j in range(0,N))
        if test>m:
            m=test

print(m)


Fixed submission:
N=int(input())
shougen=[(0,0) for i in range(0,N)]
for i in range(0,N):
    A=int(input())
    honest=0
    unkind=0
    for j in range(0,A):
        x,y=map(int,input().split())
        if y==0:
            unkind+=2**(x-1)
        else:
            honest+=2**(x-1)
    shougen[i]=(honest,unkind)

ans=0
for i in range(0,2**N):
    honest=i
    unkind=2**N-1-i
    check=True
    test=0
    for j in range(0,N):
        if (i>>j)&1 ==1:
            test+=1
            x,y=shougen[j]
            if (honest-x)^x!=honest or (unkind-y)^y!=unkind:
                check=False
    if check:
        if test>ans:
            ans=test

print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
    A=[0]*N
    shougen=[[] for i in range(0,N)]
    for i in range(0,N):
        A[i]=int(input())
        for j in range(0,A[i]):
            a,b=map(int,input().split())
            shougen[i].append([a,b])
    m=0
    for i in range(0,2**N):
        flag=0
        check=[]
        for j in range(0,N):
            if i>>j & 1==1:
                check.extend(shougen[j])
        for j in range(0,N):
            if ([j+1,0] in check) or ([j+1,1] in check):
                if [j+1,0] in check:
                    if j==0:
                        data=[0]
                    else:
                        data.append(0)
                if [j+1,1] in check:
                    if j==0:
                        data=[1]
                    else:
                        data.append(1)

            else:
                if j==0:
                    data=[2]
                else:
                    data.append(2)
        for j in range(0,N):
            if data[j]!=2:
                if int(data[j])!=(i>>j)%2 :
                    flag=1
        if len(data)!=N:
            flag=1
        if flag==0:
            test=sum(i>>j &1 for j in range(0,N))
            if test>m:
                m=test

    print(m)


Fixed submission:
N=int(input())
shougen=[(0,0) for i in range(0,N)]
for i in range(0,N):
    A=int(input())
    honest=0
    unkind=0
    for j in range(0,A):
        x,y=map(int,input().split())
        if y==0:
            unkind+=2**(x-1)
        else:
            honest+=2**(x-1)
    shougen[i]=(honest,unkind)

ans=0
for i in range(0,2**N):
    honest=i
    unkind=2**N-1-i
    check=True
    test=0
    for j in range(0,N):
        if (i>>j)&1 ==1:
            test+=1
            x,y=shougen[j]
            if (honest-x)^x!=honest or (unkind-y)^y!=unkind:
                check=False
    if check:
        if test>ans:
            ans=test

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N=int(input())
    A=[0]*N
    shougen=[[] for i in range(0,N)]
    for i in range(0,N):
        A[i]=int(input())
        for j in range(0,A[i]):
            a,b=map(int,input().split())
            shougen[i].append([a,b])
    m=0
    for i in range(0,2**N):
        flag=0
        check=[]
        for j in range(0,N):
            if i>>j & 1==1:
                check.extend(shougen[j])#証言の収集
        for j in range(0,N):
            if ([j+1,0] in check) or ([j+1,1] in check):
                if [j+1,0] in check:
                    if j==0:
                        data=[0]
                    else:
                        data.append(0)
                if [j+1,1] in check:
                    if j==0:
                        data=[1]
                    else:
                        data.append(1)

            else:
                if j==0:
                    data=[2]
                else:
                    data.append(2)#証言から得られる正直者リスト
        for j in range(0,N):
            if data[j]!=2:
                if int(data[j])!=(i>>j)%2 :
                    flag=1
        if len(data)!=N:
            flag=1
        if flag==0:
            test=sum(i>>j &1 for j in range(0,N))
            if test>m:
                m=test

    print(m)

if __name__ == '__main__':
    main()


Fixed submission:
N=int(input())
shougen=[(0,0) for i in range(0,N)]
for i in range(0,N):
    A=int(input())
    honest=0
    unkind=0
    for j in range(0,A):
        x,y=map(int,input().split())
        if y==0:
            unkind+=2**(x-1)
        else:
            honest+=2**(x-1)
    shougen[i]=(honest,unkind)

ans=0
for i in range(0,2**N):
    honest=i
    unkind=2**N-1-i
    check=True
    test=0
    for j in range(0,N):
        if (i>>j)&1 ==1:
            test+=1
            x,y=shougen[j]
            if (honest-x)^x!=honest or (unkind-y)^y!=unkind:
                check=False
    if check:
        if test>ans:
            ans=test

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def digit(N,n):#nは正の整数、N進法での桁数、許容は１０＾１０００
    if n<N:
        return 1
    else:
        return 1+digit(N,n//N)

def Nbasenumber(N,m):#N>1,mは正の整数、N進法表記、出力は数、許容はN＾１０００
    if  m<N:
        return m
    else:
        k=digit(N,m)#digitとの併用を忘れないこと
        i=m//(N**(k-1))
        return i*(10**(k-1))+Nbasenumber(N,m%(N**(k-1)))

def digitsum(n):#nは正の整数、各位の和、許容は１０＾１０００
    if n<10:
        return n
    else:
        m=n//10
        return n%10+digitsum(m)

def main():
    N=int(input())
    A=[0]*N
    shougen=[[] for i in range(0,N)]
    for i in range(0,N):
        A[i]=int(input())
        for j in range(0,A[i]):
            a,b=map(int,input().split())
            shougen[i].append([a,b])
    m=0
    for i in range(0,2**N):
        flag=0
        check=[]
        for j in range(0,N):
            if i>>j & 1==1:
                check.extend(shougen[j])#証言の収集
        for j in range(0,N):
            if ([j+1,0] in check) or ([j+1,1] in check):
                if [j+1,0] in check:
                    if j==0:
                        data=[0]
                    else:
                        data.append(0)
                if [j+1,1] in check:
                    if j==0:
                        data=[1]
                    else:
                        data.append(1)

            else:
                if j==0:
                    data=[2]
                else:
                    data.append(2)#証言から得られる正直者リスト
        for j in range(0,N):
            if data[j]!=2:
                if int(data[j])!=(i>>j)%2 :
                    flag=1
        if len(data)!=N:
            flag=1
        if flag==0:
            test=digitsum(Nbasenumber(2,i))
            if test>m:
                m=test

    print(m)

if __name__ == '__main__':
    main()


Fixed submission:
N=int(input())
shougen=[(0,0) for i in range(0,N)]
for i in range(0,N):
    A=int(input())
    honest=0
    unkind=0
    for j in range(0,A):
        x,y=map(int,input().split())
        if y==0:
            unkind+=2**(x-1)
        else:
            honest+=2**(x-1)
    shougen[i]=(honest,unkind)

ans=0
for i in range(0,2**N):
    honest=i
    unkind=2**N-1-i
    check=True
    test=0
    for j in range(0,N):
        if (i>>j)&1 ==1:
            test+=1
            x,y=shougen[j]
            if (honest-x)^x!=honest or (unkind-y)^y!=unkind:
                check=False
    if check:
        if test>ans:
            ans=test

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def digit(N,n):#nは正の整数、N進法での桁数、許容は１０＾１０００
    if n<N:
        return 1
    else:
        return 1+digit(N,n//N)

def Nbasenumber(N,m):#N>1,mは正の整数、N進法表記、出力は数、許容はN＾１０００
    if  m<N:
        return m
    else:
        k=digit(N,m)#digitとの併用を忘れないこと
        i=m//(N**(k-1))
        return i*(10**(k-1))+Nbasenumber(N,m%(N**(k-1)))

def digitsum(n):#nは正の整数、各位の和、許容は１０＾１０００
    if n<10:
        return n
    else:
        m=n//10
        return n%10+digitsum(m)

def main():
    N=int(input())
    A=[0]*N
    shougen=[[] for i in range(0,N)]
    for i in range(0,N):
        A[i]=int(input())
        for j in range(0,A[i]):
            a,b=map(int,input().split())
            shougen[i].append([a,b])
    m=0
    for i in range(0,2**N):
        flag=0
        check=[]
        for j in range(0,N):
            if i>>j & 1==1:
                check.extend(shougen[j])#証言の収集
        for j in range(0,N):
            if ([j+1,0] in check) or ([j+1,1] in check):
                if [j+1,0] in check:
                    if j==0:
                        data=['0']
                    else:
                        data.append('0')
                if [j+1,1] in check:
                    if j==0:
                        data=['1']
                    else:
                        data.append('1')

            else:
                if j==0:
                    data=['A']
                else:
                    data.append('A')#証言から得られる正直者リスト
        for j in range(0,N):
            if data[j]!='A':
                if int(data[j])!=(i>>j)%2 :
                    flag=1
        if len(data)!=N:
            flag=1
        if flag==0:
            test=digitsum(Nbasenumber(2,i))
            if test>m:
                m=test

    print(m)

if __name__ == '__main__':
    main()

Fixed submission:
N=int(input())
shougen=[(0,0) for i in range(0,N)]
for i in range(0,N):
    A=int(input())
    honest=0
    unkind=0
    for j in range(0,A):
        x,y=map(int,input().split())
        if y==0:
            unkind+=2**(x-1)
        else:
            honest+=2**(x-1)
    shougen[i]=(honest,unkind)

ans=0
for i in range(0,2**N):
    honest=i
    unkind=2**N-1-i
    check=True
    test=0
    for j in range(0,N):
        if (i>>j)&1 ==1:
            test+=1
            x,y=shougen[j]
            if (honest-x)^x!=honest or (unkind-y)^y!=unkind:
                check=False
    if check:
        if test>ans:
            ans=test

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def digit(N,n):#nは正の整数、N進法での桁数、許容は１０＾１０００
    if n<N:
        return 1
    else:
        return 1+digit(N,n//N)

def Nbasenumber(N,m):#N>1,mは正の整数、N進法表記、出力は数、許容はN＾１０００
    if  m<N:
        return m
    else:
        k=digit(N,m)#digitとの併用を忘れないこと
        i=m//(N**(k-1))
        return i*(10**(k-1))+Nbasenumber(N,m%(N**(k-1)))

def digitsum(n):#nは正の整数、各位の和、許容は１０＾１０００
    if n<10:
        return n
    else:
        m=n//10
        return n%10+digitsum(m)

def main():
    N=int(input())
    A=[0]*N
    shougen=[[] for i in range(0,N)]
    for i in range(0,N):
        A[i]=int(input())
        for j in range(0,A[i]):
            a,b=map(int,input().split())
            shougen[i].append([a,b])
    m=0
    for i in range(0,2**N):
        flag=0
        check=[]
        x=str(Nbasenumber(2,i))
        for j in range(0,N-len(x)):
            x='0'+x#正直者の仮定
        for j in range(0,N):
            if x[j]=='1':
                check.extend(shougen[j])#証言の収集
        for j in range(0,N):
            if ([j+1,0] in check) or ([j+1,1] in check):
                if [j+1,0] in check:
                    if j==0:
                        data='0'
                    else:
                        data=data+'0'
                if [j+1,1] in check:
                    if j==0:
                        data='1'
                    else:
                        data=data+'1'

            else:
                if j==0:
                    data='A'
                else:
                    data=data+'A'#証言から得られる正直者リスト
        for j in range(0,N):
            if data[j]!='A':
                if data[j]!=x[j]:
                    flag=1
        if len(data)!=N:
            flag=1
        if flag==0:
            test=digitsum(int(x))
            if test>m:
                m=test

    print(m)

if __name__ == '__main__':
    main()

Fixed submission:
N=int(input())
shougen=[(0,0) for i in range(0,N)]
for i in range(0,N):
    A=int(input())
    honest=0
    unkind=0
    for j in range(0,A):
        x,y=map(int,input().split())
        if y==0:
            unkind+=2**(x-1)
        else:
            honest+=2**(x-1)
    shougen[i]=(honest,unkind)

ans=0
for i in range(0,2**N):
    honest=i
    unkind=2**N-1-i
    check=True
    test=0
    for j in range(0,N):
        if (i>>j)&1 ==1:
            test+=1
            x,y=shougen[j]
            if (honest-x)^x!=honest or (unkind-y)^y!=unkind:
                check=False
    if check:
        if test>ans:
            ans=test

print(ans)