Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

list = [1,2,3,4,5,6,7,8,9]

for i in range(n):
  x = list[0]
  mod_x = x%10
 # print(i,"番目　",x)
  list.pop(0)
  if mod_x != 0: list.append(10*x + (x%10) -1)
  list.append(10*x + (x%10))
  if mod_x != 9: list.append(10*x + (x%10) + 1)
print(x)


Fixed submission:
import queue
n = int(input())
q = queue.Queue()
for i in range(9):
    q.put(i+1)
for i in range(n):
  x = q.get()
  mod_x, mul_x = x%10, 10*x
  if mod_x != 0: q.put(mul_x+mod_x-1)
  q.put(mul_x+mod_x)
  if mod_x != 9: q.put(mul_x+mod_x+1)
print(x)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

list = [1,2,3,4,5,6,7,8,9]

for i in range(n):
  x = list[0]
  mod_x = x%10
 # print(i,"番目　",x)
  list.pop(0)
  if mod_x != 0:
    list.append(10*x + (x%10) -1)
    
  list.append(10*x + (x%10))
  
  if mod_x != 9:
    list.append(10*x + (x%10) + 1)

print(x)


Fixed submission:
import queue
n = int(input())
q = queue.Queue()
for i in range(9):
    q.put(i+1)
for i in range(n):
  x = q.get()
  mod_x, mul_x = x%10, 10*x
  if mod_x != 0: q.put(mul_x+mod_x-1)
  q.put(mul_x+mod_x)
  if mod_x != 9: q.put(mul_x+mod_x+1)
print(x)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

list = [1,2,3,4,5,6,7,8,9]

for i in range(n):
  x = list[0]
  mod_x = x%10
 # print(i,"番目　",x)
  list.pop(0)
  if mod_x != 0:
    list.append(10*x + (x%10) -1)
  list.append(10*x + (x%10))
  if mod_x != 9:
    list.append(10*x + (x%10) + 1)
print(x)


Fixed submission:
import queue
n = int(input())
q = queue.Queue()
for i in range(9):
    q.put(i+1)
for i in range(n):
  x = q.get()
  mod_x, mul_x = x%10, 10*x
  if mod_x != 0: q.put(mul_x+mod_x-1)
  q.put(mul_x+mod_x)
  if mod_x != 9: q.put(mul_x+mod_x+1)
print(x)
Buggy python submission (verdict: Runtime Error):
def can_reach_the_goal(u, x):
    return min(u) >= x

n, m, x = map(int, input().split())

c = []
a = []
for i in range(n):
    ca = [int(row) for row in input().split()]
    c.append(ca[0])
    a.append(ca[1:])

INF = 10**7
min_cost = INF
for k in range(2**n):
    purchase = [True if c == '1' else False for c in list(format(k, '0{}b'.format(n)))]
    cost = 0
    u = [0]*m
    for i in range(n):
        cost += c[i] if purchase[i] else 0
        for j in range(m):
            u[j] += a[i][j] if purchase[i] else 0

    if can_reach_the_goal(u, x) and cost < min_cost:
        min_cost = cost

if min_cost == INF:
    print(-1)
else:
    print(min_cost)

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

if (s == t[0:len(t)-1]):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
s = input()
if s == 'ABC':
	print('ARC)
else:
	print('ARC')


Fixed submission:
s = input()
if s == 'ABC':
	print('ARC')
else:
	print('ABC')

Buggy python submission (verdict: Runtime Error):
s = input()
if s = 'ABC':
	print('ARC)
else:
	print('ARC')

Fixed submission:
s = input()
if s == 'ABC':
	print('ARC')
else:
	print('ABC')
Buggy python submission (verdict: Runtime Error):
def combination(n, k):
	return fact(n) / ( fact(n-k) * fact(k) )

def fact(n):
	if n < 0:
		return 0
	if n == 0:
		return 1
	if n == 1:
		return 1
	return fact(n-1)

n, m = [int(x) for x in input().split()]
answer = combination(n, 2) + combination(m, 2)
print(answer)

Fixed submission:
def fact(n):
    if n < 0:
        return 0
    if n == 0:
        return 1
    if n == 1:
        return 1
    return n * fact(n-1)

def combination(n, k):
    if n < k:
        return 0
    return fact(n) / ( fact(n-k) * fact(k))

n, m = [int(x) for x in input().split()]
answer = int(combination(n, 2) + combination(m, 2))
print(answer)
Buggy python submission (verdict: Runtime Error):
x, a = map(int, input())
print(10 if x - a >= 0 else 0)

Fixed submission:
x, a = map(int, input().split())
print(10 if x - a >= 0 else 0)
Buggy python submission (verdict: Runtime Error):
import numpy as np
import pandas as pd
n = int(input())

df = pd.DataFrame([], columns=['num','city','score'],index=range(n))
for i in range(n):
    s, p = input().split()
    df.iloc[i,:] = np.array([i + 1, s, int(p)])

for i in df.sort_values(['city','score'], ascending=[True,False])['num']:
    print(i)

Fixed submission:
from operator import itemgetter

n = int(input())
 
data = []
for i in range(n):
    city, point = input().split()
    data.append([city, int(point), i+1])

data = sorted(data, key=itemgetter(1), reverse=True)
data = sorted(data, key=itemgetter(0), reverse=False)

for i in range(n):
    print(data[i][2])
Buggy python submission (verdict: Runtime Error):
A,B,C,K=map(int,input().split())
if (A>=K):
	print(K)
else:
	K = K-A
	if (B>=K):
		print(A)
	else:
		K = K-B
		print(A-K)

Fixed submission:
S=input()
T=input()
if (S==T[:len(T)-1]):
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
A,B,C,K=map(int,input().split())
if (A>=K):
  print(K)
else:
  K = K-A
  if (B>=D):
    print(A)
  else:
    K = K-B
    print(A-K)

Fixed submission:
S=input()
T=input()
if (S==T[:len(T)-1]):
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
A,B,C,K=map(int,input().split())
if (A>=K):
  print(K)
else:
  D = K-A
  if (B>=D):
    print(A)
  else:
    D = D-B
    print(A-D)

Fixed submission:
S=input()
T=input()
if (S==T[:len(T)-1]):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
A,B,C,K=map(int,input().split())
if (A>=K):
	print(K)
else:
	K = K-A
	if (B>=D):
		print(A)
	else:
		K = K-B
		print(A-K)

Fixed submission:
A,B,C,K=map(int,input().split())
if (A>=K):
	print(K)
else:
	K = K-A
	if (B>=K):
		print(A)
	else:
		K = K-B
		print(A-K)

Buggy python submission (verdict: Runtime Error):
A,B,C,K=map(int,input().split())
if (A>=K):
  print(K)
else:
  K = K-A
  if (B>=D):
    print(A)
  else:
    K = K-B
    print(A-K)

Fixed submission:
A,B,C,K=map(int,input().split())
if (A>=K):
	print(K)
else:
	K = K-A
	if (B>=K):
		print(A)
	else:
		K = K-B
		print(A-K)
Buggy python submission (verdict: Runtime Error):
A,P=map(int(input().split()))
print(((A*3)+P)//2)

Fixed submission:
A,P=map(int,input().split())
print(((A*3)+P)//2)
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
A=[]
for I in range(M):
	x,y=map(int,input().split())
	A.append(list(range(x,y+1)))
F=set(A[0]).intersection(*A[1:])
print(len(F))

Fixed submission:
N,M=map(int,input().split())
L=[]
R=[]
for I in range(M):
	x,y=map(int,input().split())
	L.append(x)
	R.append(y+1)
F=list(range(max(L),min(R)))
print(len(F))
Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
	if a==0:
		return b
	return gcd(b%a,a)

def find_lcm(num1, num2):
    if(num1>num2):
        b = num1
        a = num2
    else:
        b = num2
        a = num1
    G = gcd(a,b)
    lcm = int(int(num1 * num2)/int(G))
    return lcm
     
N=int(input())
A=list(map(int,input().split()))
lcm = find_lcm(A[0],A[1])
for I in range(2, N):
    lcm = find_lcm(lcm, A[I])
Ans=0
lcm-=1
for I in range(N):
	Ans+=(lcm%A[I])
print(Ans)

Fixed submission:
def gcd(a,b):
	if a==0:
		return b
	return gcd(b%a,a)

def find_lcm(num1, num2):
    if(num1>num2):
        b = num1
        a = num2
    else:
        b = num2
        a = num1
    G = gcd(a,b)
    lcm = (num1*num2)//G
    return lcm
     
N=int(input())
A=list(map(int,input().split()))
lcm = find_lcm(A[0],A[1])
for I in range(2, N):
    lcm = find_lcm(lcm, A[I])
Ans=0
lcm-=1
for I in range(N):
	Ans+=(lcm%A[I])
print(Ans)

Buggy python submission (verdict: Runtime Error):
def find_lcm(num1, num2):
    if(num1>num2):
        num = num1
        den = num2
    else:
        num = num2
        den = num1
    rem = num % den
    while(rem != 0):
        num = den
        den = rem
        rem = num % den
    gcd = den
    lcm = int(int(num1 * num2)/int(gcd))
    return lcm
     
N=int(input())
A=list(map(int,input().split()))
N1 = A[0]
N2 = A[1]
lcm = find_lcm(N1,N2)
for i in range(2, N):
    lcm = find_lcm(lcm, A[i])
Ans=0
lcm-=1
for I in range(N):
	Ans+=(lcm%A[I])
print(Ans)

Fixed submission:
def gcd(a,b):
	if a==0:
		return b
	return gcd(b%a,a)

def find_lcm(num1, num2):
    if(num1>num2):
        b = num1
        a = num2
    else:
        b = num2
        a = num1
    G = gcd(a,b)
    lcm = (num1*num2)//G
    return lcm
     
N=int(input())
A=list(map(int,input().split()))
lcm = find_lcm(A[0],A[1])
for I in range(2, N):
    lcm = find_lcm(lcm, A[I])
Ans=0
lcm-=1
for I in range(N):
	Ans+=(lcm%A[I])
print(Ans)
Buggy python submission (verdict: Runtime Error):
X=int(input())
C=1
if (X==1):
	print(1)
else:
	for J in range(2,100):
		for I in range(2,X+1):
			if pow(I,J)<=X:
				if pow(I,J)>C:
					C=pow(I,J)
			else:
				break
print(C)

Fixed submission:
A,B,C,D=map(int,input().split())
E=abs(A-B)
F=abs(A-C)
G=abs(B-C)
if F<=D or (E<=D and G<=D):
	print("Yes")
else:
	print("No")
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a>=b:
	print(b)
else
	print(a)

Fixed submission:
a,b=map(int,input().split())
if a==b:
	print(b)
elif b<a:
	print(a-1)
else:
	print(a)
Buggy python submission (verdict: Runtime Error):
def countSol(coeff, start, end, rhs, a):
	if (rhs == 0):
		return 1
	result = 0
	for I in range(start,end+1):
		if (coeff[I]<=rhs and a[I]>=0):
			a[I]-=1
			result+=countSol(coeff, I, end, rhs - coeff[I],a)
	return result 
A=int(input())
B=int(input())
C=int(input())
X=int(input())
D=[A,B,C]
print(countSol([500,100,50],0,2,X,D))

Fixed submission:
X=int(input())
A=int(input())
B=int(input())
print((X-A)%B)
Buggy python submission (verdict: Runtime Error):
a, b, c, k = map(int, input().split())
maxi=2*A-K+B
print(maxi)

Fixed submission:
S=input()
T=input()
if 1<=len(S)<=10 and (S.islower() and S.islower()) and S==T[:-1]:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=int(input())
K=int(input())
maxi=2*A-K+B
print(maxi)

Fixed submission:
S=input()
T=input()
if 1<=len(S)<=10 and (S.islower() and S.islower()) and S==T[:-1]:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=int(input())
K=int(input())
maxi=2*A-K+B
print(maxi)

Fixed submission:
S=input()
T=input()
if 1<=len(S)<=10 and (S.islower() and S.islower()) and S==T[:-1]:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
list = list(map(int,input().split()))
a = 1
list2=[]
begin = 0
time = 0
flag=False
while flag==False:
    a = list[a-1]
    for i,x in enumerate(list2):
        if x == a:
            begin=i
            time = len(list2)-begin
            flag=True
    list2.append(a)
if K<=begin:
    print(list2[K-1])
else:
    print(list2[begin:begin+time][(K-begin)%time-1])

Fixed submission:
S=input()
T=input()
if S==T[:-1]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import math
k = int(input())
ans = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        for l in range(1, k + 1):
            ans += math.gcd(math.gcd(i, j), l)
print(ans)

Fixed submission:
import math
k = int(input())
ans = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        for l in range(1, k + 1):
            ans += math.gcd(math.gcd(i, j), l)
print(ans)
Buggy python submission (verdict: Runtime Error):
l = [int(input()) for _ in range(5)]
ans = 0
m = []
for i in range(5):
    if l[i] % 10 != 0:
        m.append(l[i] % 10)
m.sort()
for i in l:
    if i % 10 != 0:
        ans += ((i // 10) + 1) * 10
    else:
        ans += i
print(ans - 10 + m[0])

Fixed submission:
l = [int(input()) for _ in range(5)]
ans = 0
m = []
for i in range(5):
    if l[i] % 10 != 0:
        m.append(l[i] % 10)
m.sort()
for i in l:
    if i % 10 != 0:
        ans += ((i // 10) + 1) * 10
    else:
        ans += i
if m != []:
    print(ans - 10 + m[0])
else:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())
for i in range(a, b + 1):
    if i <= a + k - 1 or b - k + 1 <= i:
        print(i)

Fixed submission:
a, b, k = map(int, input().split())
l = list()
for i in range(a, a + k):
    if i <= b:
        l.append(i)
for i in range(b - k + 1, b + 1):
    if i >= a:
        l.append(i)
l = sorted(list(set(l)))
for i in range(len(l)):
    print(l[i])

Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())
for i in range(a, b + 1):
    if i <= a + k - 1 or b - k + 1 <= i:
        print(i)

Fixed submission:
a, b, k = map(int, input().split())
l = list()
for i in range(a, a + k):
    if i <= b:
        l.append(i)
for i in range(b - k + 1, b + 1):
    if i >= a:
        l.append(i)
l = sorted(list(set(l)))
for i in range(len(l)):
    print(l[i])
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
v = (a + b) // 2
if abs(a - v) == abs(b - v)
    print(v)
else:
    print('IMPOSSIBLE')


Fixed submission:
a, b = map(int, input().split())
v = (a + b) // 2
if abs(a - v) == abs(b - v):
    print(v)
else:
    print('IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = input()
c = s[k]
s = s[:k] + chr(ord(c) - ord('A') + ord('a')) + s[k + 1:]
print(s)

Fixed submission:
n, k = map(int, input().split())
k -= 1
s = input()
c = s[k]
s = s[:k] + chr(ord(c) - ord('A') + ord('a')) + s[k + 1:]
print(s)
Buggy python submission (verdict: Runtime Error):
from math import gcd

n = int(input())
a = list(map(int, input().split()))
p = list(a)
s = list(a)
for i in range(1, n):
    p[i] = gcd(p[i - 1], p[i])
for i in range(n - 2, -1, -1):
    s[i] = gcd(s[i], s[i + 1])

ans = max(p[-2], s[1])
if n > 2:
    ans = max(ans, max(gcd(p[i - 1], s[i + 1]) for i in range(1, n - 1)))

print(ans)


Fixed submission:
from fractions import gcd

n = int(raw_input())
a = list(map(int, raw_input().split()))
p = list(a)
s = list(a)
for i in range(1, n):
    p[i] = gcd(p[i - 1], p[i])
for i in range(n - 2, -1, -1):
    s[i] = gcd(s[i], s[i + 1])

ans = max(p[-2], s[1])
if n > 2:
    ans = max(ans, max(gcd(p[i - 1], s[i + 1]) for i in range(1, n - 1)))

print(ans)

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

n = int(input())
a = list(map(int, input().split()))
p = list(a)
s = list(a)
for i in range(1, n):
    p[i] = gcd(p[i - 1], p[i])
for i in range(n - 2, -1, -1):
    s[i] = gcd(s[i], s[i + 1])

ans = max(p[-2], s[1])
ans = max(ans, max(gcd(p[i - 1], s[i + 1]) for i in range(1, n - 1)))
print(ans)


Fixed submission:
from fractions import gcd

n = int(raw_input())
a = list(map(int, raw_input().split()))
p = list(a)
s = list(a)
for i in range(1, n):
    p[i] = gcd(p[i - 1], p[i])
for i in range(n - 2, -1, -1):
    s[i] = gcd(s[i], s[i + 1])

ans = max(p[-2], s[1])
if n > 2:
    ans = max(ans, max(gcd(p[i - 1], s[i + 1]) for i in range(1, n - 1)))

print(ans)

Buggy python submission (verdict: Runtime Error):
from math import gcd

n = int(input())
a = list(map(int, input().split()))
p = list(a)
s = list(a)
for i in range(1, n):
    p[i] = gcd(p[i - 1], p[i])
for i in range(n - 2, -1, -1):
    s[i] = gcd(s[i], s[i + 1])

ans = max(p[-2], s[1])
ans = max(ans, max(gcd(p[i - 1], s[i + 1]) for i in range(1, n - 1)))
print(ans)


Fixed submission:
from fractions import gcd

n = int(raw_input())
a = list(map(int, raw_input().split()))
p = list(a)
s = list(a)
for i in range(1, n):
    p[i] = gcd(p[i - 1], p[i])
for i in range(n - 2, -1, -1):
    s[i] = gcd(s[i], s[i + 1])

ans = max(p[-2], s[1])
if n > 2:
    ans = max(ans, max(gcd(p[i - 1], s[i + 1]) for i in range(1, n - 1)))

print(ans)
Buggy python submission (verdict: Runtime Error):
from functools import reduce
from math import gcd
n, x = map(int, input().split())
y = [int(v) - x for v in input().split()]
y.append(0)
g = reduce(gcd, y)
print(g)


Fixed submission:
from functools import reduce
from fractions import gcd
n, x = map(int, input().split())
y = [abs(int(v) - x) for v in input().split()]
g = y[0] if len(y) == 1 else reduce(gcd, y)
print(g)
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = 0
for _ in range(n):
  l, r = map(int, input().split())
  ans += r - l + 1
  
print(ans)

Fixed submission:
s = input()
if '9' in s:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
s = set()
n = int(input())
for _ in range(n):
  x = int(input())
  if x in s:
    s.remove(x)
  else:
    s.add(x)
    
print(len(x))

Fixed submission:
s = set()
n = int(input())
for _ in range(n):
    x = int(input())
    if x in s:
        s.remove(x)
    else:
        s.add(x)

print(len(s))
Buggy python submission (verdict: Runtime Error):
#D
n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
nxt = 1
loop = []
tset = set()
final = -1
while 1:
    loop.append(nxt)
    tset.add(nxt)
    nxt = a[nxt-1]
    if nxt in tset:
        final = nxt #重複した町
        break
m = -1
for i in range(len(loop)):
    if loop[i]==final:
        m = i
        break
l = len(a)
if k < m:
    print(loop[k])
else:
    print(loop[(k+1-m)%(l-m)])
# print(loop[(k+1)%l])

Fixed submission:
#D
n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
nxt = 1
loop = []
tset = set()
final = -1
while 1:
    loop.append(nxt)
    tset.add(nxt)
    nxt = a[nxt-1]
    if nxt in tset:
        final = nxt #重複した町
        break
m = -1
for i in range(len(loop)):
    if loop[i]==final:
        m = i
        break
l = len(loop)
if k < m:
    print(loop[k])
else:
    print(loop[(k-m)%(l-m)+m])
# print(loop[(k+1)%l])

Buggy python submission (verdict: Runtime Error):
#D
n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
nxt = 1
loop = []
tset = set()
final = -1
while 1:
    loop.append(nxt)
    tset.add(nxt)
    nxt = a[nxt-1]
    if nxt in tset:
        final = nxt #重複した町
        break
m = -1
for i in range(n):
    if loop[i]==final:
        m = i
        break
l = len(a)
if k < m:
    print(loop[m])
else:
    print(loop[(k+1-m)%(l-m)])
# print(loop[(k+1)%l])

Fixed submission:
#D
n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
nxt = 1
loop = []
tset = set()
final = -1
while 1:
    loop.append(nxt)
    tset.add(nxt)
    nxt = a[nxt-1]
    if nxt in tset:
        final = nxt #重複した町
        break
m = -1
for i in range(len(loop)):
    if loop[i]==final:
        m = i
        break
l = len(loop)
if k < m:
    print(loop[k])
else:
    print(loop[(k-m)%(l-m)+m])
# print(loop[(k+1)%l])
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [0]*n
x = [[] for i in range(n)]
y = [[] for i in range(n)]
for i in range(n):
    a[i] = int(input())
    for j in range(a[i]):
        tmp1,tmp2 = list(map(int,input().split()))
        x[i].append(tmp1-1)
        y[i].append(tmp2)

ans = 0
honest = [0]*n
cnt=0
for i in range(2**n): #bit全探索
    for j in range(n):
        if((i>>j)&1):
            honest[j] = 1
            cnt+=1
        else:
            honest[j] = 0
            
        f = True
        for k in range(n):
          	if honest[k]!=1:
                f = False
                break
            for l in range(a[k]):
                if( and y[k][l]!=honest[x[k][l]]):
                    f = False
                    break
        	if f:
            	ans = max(ans,cnt)
        cnt=0

print(ans)

Fixed submission:
n = int(input())
a = [0]*n
x = [[] for i in range(n)]
y = [[] for i in range(n)]
for i in range(n):
    a[i] = int(input())
    for j in range(a[i]):
        tmp1,tmp2 = list(map(int,input().split()))
        x[i].append(tmp1-1)
        y[i].append(tmp2)

ans = 0
honest = [0]*n
for i in range(2**n): #bit全探索
    for j in range(n):
        if((i>>j)&1):
            honest[j] = 1
        else:
            honest[j] = 0
            
        f = True
        for k in range(n):
            for l in range(a[k]):
                if(honest[k]==1 and y[k][l]!=honest[x[k][l]]):
                    f = False
                    break
        if f:
            ans = max(ans,honest.count(1))

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [0]*n
x = [[] for i in range(n)]
y = [[] for i in range(n)]
for i in range(n):
    a[i] = int(input())
    for j in range(a[i]):
        tmp1,tmp2 = list(map(int,input().split()))
        x[i].append(tmp1-1)
        y[i].append(tmp2)

ans = 0
honest = [0]*n
for i in range(2**n): #bit全探索
    for j in range(n):
        if((i>>j)&1):
            honest[j] = 1
        else:
            honest[j] = 0
            
        f = True
        for k in range(n):
            for l in range(a[k]):
                if(honest[k]==1 and y[k][l]!=honest[x[k][l]]):
                    f = False
                    break
        if f:
            ans = max(ans,honest.count(1))

print(ans)

Fixed submission:
n = int(input())
a = [0]*n
x = [[] for i in range(n)]
y = [[] for i in range(n)]
for i in range(n):
    a[i] = int(input())
    for j in range(a[i]):
        tmp1,tmp2 = list(map(int,input().split()))
        x[i].append(tmp1-1)
        y[i].append(tmp2)

ans = 0
honest = [0]*n
for i in range(2**n): #bit全探索
    for j in range(n):
        if((i>>j)&1):
            honest[j] = 1
        else:
            honest[j] = 0
            
        f = True
        for k in range(n):
            for l in range(a[k]):
                if(honest[k]==1 and y[k][l]!=honest[x[k][l]]):
                    f = False
                    break
        if f:
            ans = max(ans,honest.count(1))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# n+2m=i
# 2n+m=j
# (4n+2m=2j)
# n=(2j-i)/3
# m=(2i-j)/3
# n+m C n (n+m)!/n!/m!

MOD = 10**9+7
MAX = (10**6)*2+5
fac = [0]*MAX
inv = [0]*MAX
finv = [0]*MAX
def COMinit():
    fac[0]=1
    fac[1]=1
    finv[0]=1
    finv[1]=1
    inv[1]=1
    for i in range(2,MAX):
        fac[i] = fac[i-1]*i%MOD
        inv[i] = MOD - inv[MOD%i]*(MOD//i)%MOD
        finv[i] = finv[i-1]*inv[i]%MOD
def COM(n,k):
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD

x,y=list(map(int,input().split()))
if (2*y-x)%3!=0 or (2*x-y)%3!=0:
    print(0)
else:
    n=(2*y-x)//3
    m=(2*x-y)//3
    if n<0 or m<0:
        print(0)
    else:
        COMinit()
        print(COM(n+m,n))

Fixed submission:
# n+2m=i
# 2n+m=j
# (4n+2m=2j)
# n=(2j-i)/3
# m=(2i-j)/3
# n+m C n (n+m)!/n!/m!

MOD = 10**9+7
MAX = (10**6)*2+5
fac = [0]*MAX
inv = [0]*MAX
finv = [0]*MAX
def COMinit():
    fac[0]=1
    fac[1]=1
    finv[0]=1
    finv[1]=1
    inv[1]=1
    for i in range(2,MAX):
        fac[i] = fac[i-1]*i%MOD
        inv[i] = MOD - inv[MOD%i]*(MOD//i)%MOD
        finv[i] = finv[i-1]*inv[i]%MOD
def COM(n,k):
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD

x,y=list(map(int,input().split()))
if (2*y-x)%3!=0 or (2*x-y)%3!=0:
    print(0)
else:
    n=(2*y-x)//3
    m=(2*x-y)//3
    if n<0 or m<0:
        print(0)
    else:
        COMinit()
        print(COM(n+m,n))

Buggy python submission (verdict: Runtime Error):
MOD = 10**9+7
fac = [0]*MOD
inv = [0]*MOD
finv = [0]*MOD
def COMinit():
    fac[0]=1
    fac[1]=1
    finv[0]=1
    finv[1]=1
    inv[1]=1
    for i in range(2,MOD):
        fac[i] = fac[i-1]*i%MOD
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
        finv[i] = finv[i-1]*inv[i]%MOD
def COM(n,k):
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD

x,y=list(map(int,input().split()))
if (2*y-x)%3!=0 or (2*x-y)%3!=0:
    print(0,'NO')
else:
    n=(2*y-x)//3
    m=(2*x-y)//3
    COMinit()
    print(COM(n+m,n))

Fixed submission:
# n+2m=i
# 2n+m=j
# (4n+2m=2j)
# n=(2j-i)/3
# m=(2i-j)/3
# n+m C n (n+m)!/n!/m!

MOD = 10**9+7
MAX = (10**6)*2+5
fac = [0]*MAX
inv = [0]*MAX
finv = [0]*MAX
def COMinit():
    fac[0]=1
    fac[1]=1
    finv[0]=1
    finv[1]=1
    inv[1]=1
    for i in range(2,MAX):
        fac[i] = fac[i-1]*i%MOD
        inv[i] = MOD - inv[MOD%i]*(MOD//i)%MOD
        finv[i] = finv[i-1]*inv[i]%MOD
def COM(n,k):
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD

x,y=list(map(int,input().split()))
if (2*y-x)%3!=0 or (2*x-y)%3!=0:
    print(0)
else:
    n=(2*y-x)//3
    m=(2*x-y)//3
    if n<0 or m<0:
        print(0)
    else:
        COMinit()
        print(COM(n+m,n))