Harryxun/stf_run huggingface dataset:
A = int(input())
N = list(map(int,input().split(" ")))
def bubble(A, N):
    count = 0
    flag = True
    while flag == True:
        for j in range(N-1, 0, -1):
            flag = False
            if A[j] < A[j - 1]:
                A[j -1],A[j] = A[j], A[j - 1]
                count += 1
                flag = True
        print(" ".join(map(str, A)))
        print(count)

bubble(A, N)
    

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))


def bubble_sort(A, N):
    cnt = 0
    flag = True
    while(flag):
        flag = False
        for i in range(N-1, 0, -1):
            if(A[i-1] > A[i]):
                A[i-1], A[i] = A[i], A[i-1]
                cnt += 1
                flag = True

    print(" ".join(list(map(str, A))))
    print(cnt)

bubble_sort(A, N)
[a_index, a_v] = map(int, input().split())
[b_index, b_v] = map(int, input().split())
t = input()

d = abs(b_index - a_index)
d_v = abs(w - v)
t_at = d / a_v

if (t_at < t) :
  print("YES")
else :
  print("NO")


### FIXED CODE ###

a_index, a_v = map(int, input().split())
b_index, b_v = map(int, input().split())
t = int(input())
 
d = abs(b_index - a_index)
d_v = a_v - b_v
 
if d == 0 :
  print("YES")
elif d_v > 0 and d / d_v <= t :
  print("YES")
else :
  print("NO")
n = int(input())

if n[0] != 9 and n[1] != 9:
    print('No')
else:
    print('Yes')

### FIXED CODE ###

n = input()

if n[0] != '9' and n[1] != '9':
    print('No')
else:
    print('Yes')
import sys
c=[[int(i) for i in l.stlip()] for l in sys.stdin]
for i in range(2):
  stack=c[i][0]-c[i+1][0]
  for j in range(3):
    if stack!=c[i][j]-c[i+1][j]:
      print('No')
      exit()
for i in range(2):
  stack=c[0][i]-c[0][i+1]
  for j in range(3):
    if stack!=c[j][i]-c[j][i+1]:
      print('No')
      exit()
print('Yes')

### FIXED CODE ###

import sys
c=[[int(i) for i in l.split()] for l in sys.stdin]
for i in range(2):
  stack=c[i][0]-c[i+1][0]
  for j in range(3):
    if stack!=c[i][j]-c[i+1][j]:
      print('No')
      exit()
for i in range(2):
  stack=c[0][i]-c[0][i+1]
  for j in range(3):
    if stack!=c[j][i]-c[j][i+1]:
      print('No')
      exit()
print('Yes')
from collections import deque

S = input()
Q = int(input())
Query = [input().split() for _ in range(Q)]

S = deque(S)
S1 = deque('')
S2 = deque('')
rev = False

for TFC in Query:
    if TFC[0] == '1':
        rev = not rev
    else:
        if TFC[1] == '1':
            if rev:
                S2.append(TFC[2])
            else:
                S1.appendleft(TFC[2])
        else:
            if rev:
                S1.appendleft(TFC[2])
            else:
                S2.append(TFC[2])
if rev:
    S2.reverse()
    S.reverse()
    S1.reverse()
    print(''.join(S2 + S + S1))
else:
    print(''.join(S1 + S + S2))

### FIXED CODE ###

S = input()
Q = int(input())
Query = [input().split() for _ in range(Q)]

rev = False
S1 = ''
S2 = ''

for TFC in Query:
    if TFC[0] == '1':
        rev = not rev
    else:
        if TFC[1] == '1':
            if rev:
                S2 += TFC[2]
            else:
                S1 = TFC[2] + S1
        else:
            if rev:
                S1 = TFC[2] + S1
            else:
                S2 += TFC[2]

if rev:
    print(S2[::-1] + S[::-1] + S1[::-1])
else:
    print(S1 + S + S2)
result=[]
for i in range(1,n+1):
    if i %3==0:
        result.append(i)
    else:
        k=i
        for j in range(1,5):
            if k%(10**j)==3:
                result.append(i)
                break
            else:
                k=k//10**j
        else:
            continue

print(" ",*result)

### FIXED CODE ###

n=int(input())
 
result=[]
for i in range(1,n+1):
    if i %3==0:
        result.append(i)
    else:
        k=i
        for j in range(1,5):
            if k%10==3:
                result.append(i)
                break
            else:
                k=k//10
        else:
            continue
 
print("",*result)
import math

r = floatinput())

print(f' {math.pi * r ** 2}　{math.pi * r * 2}')



### FIXED CODE ###

import math

r = float(input())

print(f' {math.pi * r ** 2} {math.pi * r * 2}')
n, a, b = map(int, input().split())

import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

MDO = 10 ** 9 + 7

total = 2 ** n - 1
ans = total - combinations_count(n, a) - combinations_count(n, b)
print(ans % MOD)



### FIXED CODE ###

from functools import reduce

N, A, B = map(int, input().split())

MOD = 10 ** 9 + 7

def f(A):
    num = reduce(lambda x, y: x * y % MOD, range(N, N - A, -1))
    den = reduce(lambda x, y: x * y % MOD, range(1, A + 1))
    return num * pow(den, MOD - 2, MOD) % MOD

answer = pow(2, N, MOD) - 1 - f(A) - f(B)
answer %= MOD
print(answer)
X,N = map(int, input().split())
P = list(map(int, input().split()))
sortP = sorted(P)
if N==0:
    print(X)
elif sortP[0]>X:
    print(sortP[0]-1)
elif sortP[N-1]<X:
    print(sortP[N-1]+1)
else:
    for n in range(sortP[0],sortP[N-1]+2):
        if n in sortP:
            continue
        if n ==X:
            print(X)
        elif n>X:
            if X-a<=n-X:
                print(a)
                break
            else:
                print(n)
                break
        a = n

### FIXED CODE ###

X,N = map(int, input().split())
P = list(map(int, input().split()))
sortP = sorted(P)
if N==0:
    print(X)
elif sortP[0]>X:
    print(X)
elif sortP[N-1]<X:
    print(X)
else:
    for n in range(sortP[0]-2,sortP[N-1]+2):
        if n in sortP:
            continue
        if n ==X:
            print(X)
            break
        elif n>X:
            if X-a<=n-X:
                print(a)
                break
            else:
                print(n)
                break
        a = n
a, b = [int(i) for i in input().split()]
if b == 1:
    print(0)
    return
n = (b-2) / (a-1)
print(n+1)

### FIXED CODE ###

a, b = [int(i) for i in input().split()]
if b == 1:
    print(0)
    exit()
n = int((b-2) / (a-1))
print(n+1)
import sys
n = int(input())
mem = [None]*(n+1)
def DFS(k, d):
    if k<0 or d>5000:
        return 10**9
    if k==0:
        return 0
    if k<6:
        return k
    if mem[k] is not None:
        return mem[k]
    tmp = 10**5
    for i in range(1, 7):
        tmp = min(tmp, DFS(k-6**i, d+1)+1)
    for i in range(1, 6):
        tmp = min(tmp, DFS(k-9**i, d+1)+1)
    mem[k] = tmp
    return tmp
if n<6:
    print(n)
else:
    print(DFS(n, 0))

### FIXED CODE ###

import sys
n = int(input())
INF = 10*n
dp = [INF]*(n+1)
dp[0] = 0
for i in range(1, n+1):
    tmp = dp[i-1] + 1
    for j in range(10):
        if i-6**j<0:
            break
        tmp = min(tmp, dp[i-6**j] + 1)
    for j in range(10):
        if i-9**j<0:
            break
        tmp = min(tmp, dp[i-9**j] + 1)
    dp[i] = tmp
print(dp[n])
day = input()
count = day.count("R")
if count == 2:
    if count1 = day.count("RR"):
	    print(2)
	else:
    	print(1)
if count == 1:
    print(1)
if count == 0:
    print(0)

### FIXED CODE ###

s = input()

if "RRR" in s:
    print("3")
elif "RR" in s:
    print("2")
elif "R" in s:
    print("1")
else:
    print("0")
import numpy as np

N = int(input())
A = [int(i) for i in input().split()]
a = np.array(A)
sum = np.prod(a)

if  sum > 10 ** 18:
    print(-1)
else:
    print(sum)


### FIXED CODE ###

A, B =map(int, input().split())
print(A*B)
import math
N,A,B = map(int,input().split())
# ans = 0
#N = list(str(N))
#N_len = len(N)
ans = 0
for i in range(1,int(N)+1):
    if (i < 10) and  (A <= i  and i<=B):
        ans += i
    elif 10<=i and i <100:
        list_i = list(str(i))
        if (A <= int(list_i[0])+int(list_i[1])  and int(list_i[0])+int(list_i[1])<=B):
            ans +=i
    elif 100<= i and i <1000:
        list_i = list(str(i))
        if (A <= int(list_i[0])+int(list_i[1])+int(list_i[2])  and int(list_i[0])+int(list_i[1])+int(list_i[2])<=B):
            ans +=i
    elif 1000 <=i:
        list_i = list(str(i))
        if (A <= int(list_i[0])+int(list_i[1])+int(list_i[2])+int(list_i[3])  and int(list_i[0])+int(list_i[1])+int(list_i[2])+list_i[3]<=B):
            ans +=i

print(ans)

### FIXED CODE ###

import math
N,A,B = map(int,input().split())
ans = 0
for i in range(1,N+1):
    sum_temp = sum(map(int,list(str(i))))
    if A<=sum_temp<=B:
        ans +=i
print(ans)
# 092

# 1.値を正しく取得
a, b, c, d = (int(x) for x in input().split())

# 2.正しく処理
gokei1 = a + b
gokei2 = a + c
gokei3 = a + d
gokei4 = b + c
gokei5 = b + d
gokei6 = c + d

resalt = [gokei1,gokei2,gokei3,gokei4,gokei5,gokei6]
print(min(resalt))

### FIXED CODE ###

# 092

# 1.値を正しく取得
a =int(input())
b =int(input())
c =int(input())
d =int(input())

# 2.正しく処理
if a > b :
    resalt1=int(b)
else :
    resalt1=int(a)

if c > d :
    resalt2=int(d)
else :
    resalt2=int(c)

print(resalt1 + resalt2)
def aFrog(N,h):
    dp = [0 for i in range(10)]
    dp[0] = 0
    dp[1] = abs(h[1]-h[0])
    print(dp)
    for i in range(2,N):
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
    return dp[N-1]

N = int(input())
h = list(map(int, input().split()))
print(aFrog(N,h))

### FIXED CODE ###

N = int(input())
h = list(map(int, input().split()))
    
inf = 10**9
dp = [0] + [inf]*N
    
for i in range(1,N):
    if i == 1:
        dp[1] = abs(h[1]-h[0])
    else:
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
    
print(dp[N-1])
import random
input()
print(random.random(0,3))


### FIXED CODE ###

a = input()
print(a.count("1"))
N = int(input())
A = list(map(int, input().split())

#print(N)
#print(A)

syozi = 1000
kabu = 0

for i in range(N-1):
#  print(str(i)+': '+ str(A[i]) + ', ' + str(kabu) + ', ' + str(syozi) )
  if A[i] < A[i+1]:
    kabu = syozi // A[i] 
    syozi = int( syozi % A[i] )
  elif A[i] > A[i+1]:
    syozi += A[i] * kabu
    kabu = 0
  else:
    pass
#  print( str(i)+': '+str(A[i]) + ', ' + str(kabu) + ', ' + str(syozi) )

if A[N-2] < A[N-1]:
  syozi += A[N-1] * kabu
  kabu = 0

print(syozi)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))

money = 1000
ticket = 0
for i in range(N - 1):
    # buy
    if A[i] < A[i + 1]:
        ticket += money // A[i]
        money -= (money // A[i]) * A[i]
    elif A[i] == A[i + 1]:
        pass
    # sell
    else:
        money += A[i] * ticket
        ticket = 0

money += A[-1] * ticket

print(money)
string = input()
a, b = input().split(' ')
if (a > b):
    print('a > b')
elif (a < b):
    print('a < b')
else (a == b):
    print('a == b')


### FIXED CODE ###

string = input()
a, b = map(int, (string.split(' ')))
if a > b:
    print('a > b')
elif a < b:
    print('a < b')
else:
    print('a == b')
def main():

m, n = tuple(map(int, input().split()))
a = [[0 for j in range(n)] for i in range(m)]
b = [0 for j in range(n)]
c = [0 for i in range(m)]

for i in range(m):
    tmplst = list(map(int, input().split()))
    for j in range(n):
        a[i][j] = tmplst[j]

for j in range(n):
    b[j] = int(input())

for i in range(m):
    for j in range(n):
        c[i] += a[i][j] * b[j]
        print(c[i])



if __name__ == '__main__':
    main()


### FIXED CODE ###

n, m = map(int, input().split())
A = [[0 for _ in range(m)] for _ in range(n)]
b = [0 for _ in range(m)]
Ab = [0 for _ in range(n)]

for i in range(n):
    x = list(map(int, input().split()))
    for j in range(m):
        A[i][j] = x[j]

for j in range(m):
    b[j] = int(input())

for i in range(n):
    for j in range(m):
        Ab[i] += A[i][j] * b[j]

for i in range(n):
    print(Ab[i])
import copy
import sys
sys.setrecursionlimit(10**7)

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

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

def main():
    n, m = map(int, input().split())
    # これだと72がREになる
    A = [int(x) for x in input().split()]
    # A_s = set(A)
    # A_ = copy.deepcopy(A)
    # a_lcm = A.pop()
    a_lcm = 1
    # Aの要素が複数ならlcmを計算する
    #if len(A) >= 1:
    for a in A:
        a_lcm = lcm(a_lcm, a)
    #else:
    #    a_lcm = a_lcm
    # 元のAの値とlcmの半分の値を割り切れるものがあったら0
    #for i in A_:
    for a in A:
        #if a_lcm // 2 % a == 0:
        if (a_lcm // a) % 2 == 0: 
            print(0)
            exit()
        # else:
        #     continue
    # mがlcmの半分よりも小さかったら0
    if (a_lcm / 2) > m:
    # if a_lcm > m * 2:
        print(0)
        exit()
    else:
        # # あとは定数倍の数調べて終わり
        ans = int((m - (a_lcm / 2)) // a_lcm) + 1
        print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import copy
# from math import gcd


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

def lcm(a, b):
    return (a // gcd(a, b)) * b
def main():
    n, m = map(int, input().split())
    A = set([int(x) for x in input().split()])
    a_lcm = 1
    for a in A:
        a_lcm = lcm(a_lcm, a)
        # mがlcmの半分よりも小さかったら0
        if (a_lcm / 2) > m:
            print(0)
            exit()
    for a in A:
        if (a_lcm / 2) % a == 0:
            print(0)
            exit()
    # # あとは定数倍の数調べて終わり
    ans = int((m - (a_lcm / 2)) // a_lcm) + 1
    print(ans)

if __name__ == '__main__':
    main()
import numpy as np
A,B=map(int,input().split())
s=[]
for i in range(A,B+1):
    s.append(format(i,'b'))
for i in range(len(s)):
    if len(s[i])<len(s[-1]):
        s[i]='0'+s[i]
a=np.array(s)
b=[list(map(int,a[i])) for i in range(len(a))]
b=np.array(b)
x=[0]*len(s[-1])#x[0]~s[len(s[-1])-1]
ans=''
for i in range(len(s[-1])):
    if np.sum(b[:,i])%2==0:
        x[len(s[-1])-1-i]='0'
    else:
         x[len(s[-1])-1-i]='1'
for i in range(len(s[-1])):
    ans+=x[i]
print(ans)
print(int(ans,2))

### FIXED CODE ###

A,B=map(int,input().split())
def f(n):
    if n%4==0:
        return n
    elif n%4==1:
        return 1
    elif n%4==2:
        return n^1
    else:
        return 0
print(f(A-1)^f(B))
W,H,x,y,r =map(int, input().split())

if r =< x and x =< (W-r):
    if r =< y and y =< (H-r):
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

### FIXED CODE ###

W, H, x, y, r = input().split()

if int(r) <= int(x) and int(x) <= int(W) - int(r):
    if int(r) <= int(y) and int(y) <= int(H) - int(r):
        print("Yes")
    else:
        print("No")

else:
    print("No")
H, N = map(int, input().split())
lis = list(input().split())
if sum(lis) >= H:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

H, N = map(int, input().split())
lis = list(map(int, input().split()))
if sum(lis) >= H:
  print("Yes")
else:
  print("No")
x=int(input())
y=int(input())
if x%y != 0:
    print(x)
else:
    print(-1)

### FIXED CODE ###

import math
import sys

x,y = map(int, input().split())
if x%y != 0:
    print(x)
else:
    print(-1)
n, q = map(int, input().split(" "))
items = [i for i in range(n)]
parent = [i for i in range(n)]

def root(s):
    if parent[s] == s:
        return s
    else:
        parent[s] = root(parent[s])
        return parent[s]

def same(s1, s2):
    if parent[s1] == parent[s2]:
        print("1")
    else:
        print("0")

def unite(s1, s2):
    s1 = root(s1)
    s2 = root(s2)

    if s1 == s2:
        return

    parent[s1] = s2


for i in range(q):
    query, item1, item2 = input().split(" ")
    item1, item2 = int(item1), int(item2)

    if query == "0":
        unite(item1, item2)
    else:
        same(item1, item2)

### FIXED CODE ###

n, q = map(int, input().split(" "))
parent = [i for i in range(n)]
rank = [0] * len(parent)

def root(s):
    if parent[s] == s:
        return s
    else:
        parent[s] = root(parent[s])
        return parent[s]

def same(s1, s2):
    if root(s1) == root(s2):
        print("1")
    else:
        print("0")

def unite(s1, s2):
    s1 = root(s1)
    s2 = root(s2)

    if s1 == s2:
        return

    if rank[s1] < rank[s2]:
        parent[s1] = s2
    else:
        parent[s2] = s1
        if rank[s1] == rank[s2]:
            rank[s1] += 1

for i in range(q):
    query, item1, item2 = input().split(" ")
    item1, item2 = int(item1), int(item2)

    if query == "0":
        unite(item1, item2)
    else:
        same(item1, item2)
a,b,c,x,y=readInts()
for i in range(max(x,y)*2+1,2):
	ans=min(ans,max(x-i//2,0)*a+max(y-i//2,0)*b+i*c)
print(ans)



### FIXED CODE ###

import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1

a,b,c,x,y = readInts()

ans = 1000000000000000000
for i in range(0,x+1):
	B = max(y-(x-i),0)
	AB = max(2*(x-i),0)
	money = i*a+B*b+AB*c
	ans = min(ans,money)

for i in range(0,y+1):
	A = max(x-(y-i),0)
	AB = max(2*(y-i),0)
	money = A*a+b*i+AB*c
	ans = min(ans,money)

for i in range(0,max(x,y)*2+1,2):
	A = max(x - i//2,0)
	B = max(y - i//2,0)
	money = A*a+B*b+i*c
	ans = min(ans,money)

print(ans)
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    if p[i] == i+1:
        print(p)
        p[i], p[i+1] = p[i+1], p[i]
        ans += 1
if p[-1] == n:
    ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    if p[i] == i+1:
        p[i], p[i+1] = p[i+1], p[i]
        ans += 1
if p[n-1] == n:
    ans += 1
print(ans)
n = int(input())
s = list(ranege(n))
for i in range(n):
  s[i] = list(str(input()))
  s[i].sort()

ans = 0
for i in range(n-1):
  for j in range(i+1, n):
    if s[i] == s[j]:
      ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
s = []
cnt = {}
ans = 0
for i in range(n):
  s_ = list(str(input()))
  s_.sort()
  s_ = "".join(s_)
  if s_ in cnt:
    ans += cnt[s_]
    cnt[s_] += 1
  else:
    cnt[s_] = 1

print(ans)
a , b = map(int(),input().split())
 
X = 0
Y = 0
 
if a < b:
	for i in b:
		X = 'X' + 'a'
    print(X)
 
else:
	for v in a:
		Y = 'Y' + 'b'
	print(Y)

### FIXED CODE ###

a , b =input().split()
 
if a <= b:
    print(a*int(b))
else:
	print(b*int(a))
import sys
dishes = [int(input()) for _ in range(5)]
min_ = min([(d%10,d) for d in dishes if d%10>0])

ans = min_[1]
dishes.remove(min_[1])
for d in dishes:
    if d%10==0:
        ans += d
    else:
        ans += (d//10+1)*10
print(ans)


### FIXED CODE ###

import sys
dishes = [int(input()) for _ in range(5)]
a = [(d%10,d) for d in dishes if d%10>0]
if a==[]:
    print(sum(dishes))
    sys.exit()
min_ = min(a)

ans = min_[1]
dishes.remove(min_[1])
for d in dishes:
    if d%10==0:
        ans += d
    else:
        ans += (d//10+1)*10
print(ans)
N, X = map(int, input().split())
b = 0
if X == 1:
  print(0)
else:
  while b <= N: 
    N = abs(N - X)
    b = abs(N - X)
  print(N)

### FIXED CODE ###

X, Y, Z = input().split()
print(Z, X, Y)
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)

### FIXED CODE ###

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)
import numpy as np

n,m=map(int,input().split())
road=[list(map(int,input().split())) for i in range(m)]

ans=np.unique(road,return_counts=True)
for i in range(n):
    print(ans[1][i])

### FIXED CODE ###

n,m=map(int,input().split())
road=[list(map(int,input().split())) for i in range(m)]
 
ans={}
for i in range(m):
  sta,gol = road[i][0],road[i][1]
  if sta not in ans:
    ans[sta] = []
  ans[sta].append(gol)
  
  if gol not in ans:
    ans[gol] = []
  ans[gol].append(sta)
  
for i in range(1,n+1):
  if i in ans:
  	print(len(ans[i]))
  else:
    print(0)
r=int(input())
g=int(input())
b=int(input())
a=100*r+10*g+b

if a%4 ==0:
    print("YES")
else:
    primt("NO")

### FIXED CODE ###

r,g,b=(int(x) for x in input().split())

num=100*r+10*g+b
if num%4==0:
    print("YES")
else:
    print("NO")
n=input()
if n='Sunny':
  print('Cloudy')
elif n='Cloudy':
  print('Rainy'):
else:
  print('Sunny')

### FIXED CODE ###

n=input()
if n=='Sunny':
  print('Cloudy')
elif n=='Cloudy':
  print('Rainy')
else:
  print('Sunny')
S = input()

a = S[0]
b = S[1]
c = S[2]
d = S[3]

i = 0

if a == b:
  i += 1
if a == c:
  i += 1
if a == d:
  i += 1
  
if b == c:
  i += 1
if b == d:
  i += 1
if c == d:
  i += 1

if i == 2:
  print(YES)
else:
  print(NO)

### FIXED CODE ###

S = input()

a = S[0]
b = S[1]
c = S[2]
d = S[3]

i = 0

if a == b:
  i += 1
if a == c:
  i += 1
if a == d:
  i += 1
  
if b == c:
  i += 1
if b == d:
  i += 1
if c == d:
  i += 1

if i == 2:
  print('Yes')
else:
  print('No')