Problem:


Score : 200 points

Problem Statement

Katsusando loves omelette rice.

Besides, he loves crème brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.

To prove that hypothesis, he conducted a survey on M kinds of foods and asked N people whether they like these foods or not.

The i-th person answered that he/she only likes the A_{i1}-th, A_{i2}-th, ..., A_{iK_i}-th food.

Find the number of the foods liked by all the N people.

Constraints

All values in input are integers.

1 \leq N, M \leq 30

1 \leq K_i \leq M

1 \leq A_{ij} \leq M

For each i (1 \leq i \leq N), A_{i1}, A_{i2}, ..., A_{iK_i} are distinct.

Constraints

Input is given from Standard Input in the following format:

N M
K_1 A_{11} A_{12} ... A_{1K_1}
K_2 A_{21} A_{22} ... A_{2K_2}
:
K_N A_{N1} A_{N2} ... A_{NK_N}

Output

Print the number of the foods liked by all the N people.

Sample Input 1

3 4
2 1 3
3 1 2 3
2 3 2

Sample Output 1

1

As only the third food is liked by all the three people, 1 should be printed.

Sample Input 2

5 5
4 2 3 4 5
4 1 3 4 5
4 1 2 4 5
4 1 2 3 5
4 1 2 3 4

Sample Output 2

0

Katsusando's hypothesis turned out to be wrong.

Sample Input 3

1 30
3 5 10 30

Sample Output 3

3



Sample input:
3 4
2 1 3
3 1 2 3
2 3 2


Sample output:
1

Submission status: Accepted

Solution code:
# B - Foods Loved by Everyone
from collections import deque
N,M = map(int,input().split())
K = []
A = []
for o in range(N):
    KA = deque(list(map(int,input().split())))
    Ki = KA.popleft()
    K.append(Ki)
    A.append(list(KA))

common = [0]*(M+1)
for i in A:
    for j in i:
        common[j] += 1
count = 0
for k in common:
    if k == N:
        count += 1
print(count)

Submission status: Accepted

Solution code:
N, M = map(int,input().split())
like = [0 for i in range(M+1)]

for i in range(N):
    KA = list(map(int,input().split()))

    for k in range(1,KA[0]+1):
        like[KA[k]] += 1
        
ans = 0
for i in range(M+1):
    if like[i] == N:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
a=[0]*m
for i in range(n):
    for j in range(l[i][0]):
        a[l[i][j+1]-1]+=1
ans=0
for i in range(m):
    if a[i]==n:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

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

ans = [0]*m

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

#print(ans)
print(ans.count(n))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ans = [0]*M

for _ in range(N):
  K, *A = map(int, input().split())
  for x in A:
    ans[x-1] += 1

print(sum([1 for i in ans if i == N]))

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
target = list()
for i in range(N):
	target_list = list(map(int,input().split()))
	target_list.pop(0)
	target.append(target_list)

# print(target)

ans = dict()
for i in range(0,len(target)):
	for j in range(len(target[i])):
		if i == 0:
			ans[target[i][j]] = 1
		else:
			if target[i][j] in ans:
				ans[target[i][j]] += 1

ans_num = 0
for k in ans.keys():
	if ans[k] == N:
		ans_num += 1
print(ans_num)

Submission status: Accepted

Solution code:
N,M = map(int, input().split())

ans = set(range(1, M+1))

for _ in range(N):
    L = list(map(int, input().split()))
    ans &= set(L[1:])

print(len(ans))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
L = [0] * M
for i in range(N):
    for j in range(1, A[i][0] + 1):
        L[ A[i][j] -1 ] += 1
print(L.count(N))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A = set(list(map(int, input().split()))[1:])
for i in range(1, N):
    A = A & set(list(map(int, input().split()))[1:])
print(len(A))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())

X = {i for i in range(1, m+1)}
for i in range(n):
    k, *A = map(int, input().split())
    X = X & set(A)
print(len(X))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())

k_lst = []
a_lst = []
for _ in range(n):
    lst = list(map(int,input().split()))
    k_lst.append(lst[0])
    a_lst.append(lst[1:])

temp = a_lst[0]

for i in range(1,n):
    lstwa = temp + a_lst[i]
    tyofuku = [x for x in set(lstwa) if lstwa.count(x) > 1]
    temp = tyofuku

print(len(temp))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ka = [list(map(int, input().split())) for i in range(N)]

l = []
for i in range(N):
    for j in ka[i][1:]:
        l.append(j)

ans = 0
for i in range(M):
    if l.count(i+1) == N:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())

A = [list(map(int, input().split()))[1:] for _ in range(N)]

ans = 0

for i in range(1, M + 1):
    for K in A:
        if K.count(i) == 0:
            break
    else:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ans = set(range(1, M+1))
for i in range(N):
  K, *A = map(int, input().split())
  ans = ans & set(A)
print(len(ans))

Submission status: Accepted

Solution code:
from collections import Counter
N, M = map(int, input().split())
c = Counter()
for i in range(N):
    K, *A = list(map(int, input().split()))
    c.update(A)
r = 0
for k, v in c.items():
    if v == N:
        r += 1
print(r)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = [0]*m
for _ in range(n):
    k = list(map(int, input().split()))
    for i in range(m):
        if i+1 in k[1:]:
            a[i] += 1
ans = 0
for i in range(m):
    if a[i] == n:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())


menu =[0]*m 
for i in range(n):
    k,*a = map(int,input().split())
    for j in range(k):
        menu[a[j]-1] += 1

print(menu.count(n))

Submission status: Accepted

Solution code:
import numpy as np
N, M = map(int, input().split())
ans = np.zeros(M)
for i in range(N):
  KA = list(map(int, input().split()))
  for j in range(KA[0]):
    idx = KA[j+1]-1
    ans[idx] += 1

count = 0
for i in range(M):
  if ans[i] == N:
    count += 1
print(count)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
flg=[1]*m
for i in range(n):
  a=list(map(int,input().split()))[1:]
  for j in range(m):
    if j+1 not in a:
      flg[j]=0
print(sum(flg))

Submission status: Accepted

Solution code:
N, M = list(map(lambda a: int(a), input().split(" ")))
P = [(i + 1) for i in range(M)]
s = []
for j in range(N):
  A = list(map(lambda x: int(x), input().split(" ")))
  s.append(A[1:])
  
for k in range(len(s)):
  P = list(set(P) & set(s[k]))


print(len(P))

Submission status: Accepted

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, m = inintm()

kyoutu = []

for i in range(1,31):
    kyoutu.append(i)

for _ in range(n):
    A = inintl()
    t = A[1:]
    kyoutu = set(kyoutu) & set(t)

print(len(kyoutu))

Submission status: Accepted

Solution code:
N,M = map(int, input().split())
an_li = list(map(int, input().split()))
an_li.remove(an_li[0])
for i in range(N-1):
    flag = False
    r = []
    li = list(map(int, input().split()))
    li.remove(li[0])
    for t in an_li:
        if t in li:
            a = 1
        else:
            r.append(t)
            flag = True
    if flag:
        for w in r:
            an_li.remove(w)
print(len(an_li))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
s = set()
for i in range(N):
    K, *A = map(int, input().split())
    if i == 0:
        s = set(A)
    else:
        t = set(A)
        s = s.intersection(t)
print(len(s))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
s=set(range(m+1))
for i in range(n):s=s&set(list(map(int,input().split()))[1:])
print(len(s))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
KA=[0]*N
count=[0]*(M+1)
for i in range(N):
  KA[i]=list(map(int,input().split()))
for i in range(N):
  for j in range(1,len(KA[i])):
    count[KA[i][j]]+=1
ans=0
for i in range(1,M+1):
  if count[i]==N :
    ans+=1
print(ans)

Submission status: Accepted

Solution code:
N,M = [int(i) for i in input().split()]

ans = [0]*M
for i in range(N):
    K,*A = [int(j) for j in input().split()]
    for k in range(K):
        ans[A[k]-1] += 1

print(ans.count(N))

Submission status: Accepted

Solution code:
n, m = [int(x) for x in input().split()]
a = {i : 0 for i in range(1, m+1)}

for _ in range(n):
  k, *likes = [int(x) for x in input().split()]
  for l in likes:
    a[l] += 1

result = len(list(filter(lambda x : x == n, a.values())))
print(result)

Submission status: Accepted

Solution code:
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n, m = nm()
    cnt = [0] * m
    for i in range(n):
        k, *A = nm()
        for a in A:
            cnt[a - 1] += 1
    print(cnt.count(n))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N,M=mi()

    X = [0]*(M+1)
    for i in range(N):
        Y = list(mi())
        for a in Y[1:]:
            X[a] += 1
    
    ans = 0
    for x in X:
        if x == N:
            ans += 1
    
    print(ans)
            
        



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
z = [0]*(m+1)

for i in range(n):
    l= list(map(int, input().split()))
    for j in range(1, l[0]+1):
        z[l[j]] +=1

cnt = 0

for i in z:
    if i == n:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
S=set(range(1,m+1))
for i in range(n):
    K,*A=map(int,input().split())
    S&=set(A)
print(len(S))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
counter_map = [0] * (m + 1)

for i in range(n):
    k, *a = map(int, input().split())
    for j in a:
        counter_map[j] += 1

res = 0
for i in range(m + 1):
    if counter_map[i] == n:
        res += 1

print(res)

Submission status: Accepted

Solution code:
import collections

N, M = map(int, input().split())
koubutu = []
for _ in range(N):
    ka = list(map(int, input().split()))
    koubutu.extend(ka[1:])
print(list(collections.Counter(koubutu).values()).count(N))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
res=[0 for i in range(m+1)]
for i in range(n):
    ka=list(map(int,input().split()))
    for j in range(ka[0]):
        res[ka[j+1]]+=1
ans=0
for i in range(m):
    if res[i+1]==n:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
like = [0] * m
for i in range(n):
    ka = list(map(int, input().split()))
    k = ka[0]
    a = ka[1:]
    for j in a:
        like[j-1]+=1

print(like.count(n))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())

res = [0] * (M + 1)

for _ in range(N):
    A = list(map(int, input().split()))
    K = A.pop(0)
    for a in A:
        res[a] += 1

ans = 0

for r in res:
    if r == N:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
n,m=map(int, input().split())
l=range(1,m+1)
for i in range(n):
  b=list(map(int, input().split()))
  b.pop(0)
  l=set(l)&set(b)

print(len(l))

Submission status: Accepted

Solution code:
N,M = list(map(int,input().split()))
KA = []
for i in range(N):
    KA.append(list(map(int,input().split())))

food = [0 for i in range(M)]

for i in range(N):
    x = KA[i][1:]
    for j in x:
        food[j - 1] += 1

print(food.count(N))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
kl,al = [],[]
for _ in range(n):
	k,*a = list(map(int,input().split()))
	kl.append(k)
	al.append(a)
ans = [0]*(m+1)
cnt = 0
for i in range(n):
	for j in range(kl[i]):
		inx = al[i][j]
		ans[inx] += 1
for t in range(m+1):
	if ans[t] == n:
		cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N, M = map(int, input().split())
suki = [0] * M
for _ in range(N):
    K, *A = map(int, input().split())
    for a in A:
        suki[a-1] += 1

ans = len(list(filter(lambda x: x == N, suki)))
print(ans)

Submission status: Accepted

Solution code:
n, m = map(int,input().split())
lst = []
for _ in range(n):
    l = list(map(int, input().split()))
    lst.append(l[1:])

ansset = set(lst[0])
for i in range(1,n):
    ansset = ansset & set(lst[i])

print(len(ansset))

Submission status: Accepted

Solution code:
num,food_num = map(int,input().split())

food_dict = {}

for i in range(num):
    l = list(map(int,input().split()))
    for j in range(1,l[0]+1):
            food_dict.setdefault(l[j],0)
            food_dict[l[j]] += 1

ans = 0

for name, likes in food_dict.items():
    if likes == num:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
num,food_num = map(int,input().split())

food_dict = {}

for i in range(num):
    l = list(map(int,input().split()))
    for j in range(1,l[0]+1):
            food_dict.setdefault(l[j],0)
            food_dict[l[j]] += 1

ans = 0

for name, likes in food_dict.items():
    if likes == num:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
ans=[0]*M
a=0
for i in range(N):
  A=list(map(int,input().split()))
  for j in range(1,A[0]+1):
    ans[A[j]-1]+=1
for x in range(M):
  if ans[x]==N:
    a+=1
print(a)

Submission status: Accepted

Solution code:
MM = input().split()
N =int(MM[0])
M =int(MM[1])
list1 = [i for i in range(M+1)]
for i in range(N):
  MM = input().split()
  list2 = [int(MM[j]) for j in range(1,int(MM[0])+1)]
  list1 = set(list1)&set(list2)
print(len(list1))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
cnt = [0] * (m + 1)

for i in range(n):
    a = list(map(int, input().split()))
    for j in range(a[0]):
        cnt[a[j+1]] += 1

ans = 0
for i in range(m+1):
    if cnt[i] == n:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
C = [0] * (M+1)
for i in range(N):
    K = list(map(int, input().split()))
    for k in range(len(K)):
        if k != 0:
            C[K[k]] += 1
count = 0

for c in C:
    if c == N:
        count += 1

print(count)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
a=[]
for _ in range(n):
  a.append(list(map(int,input().split())))

x = [0]*m

for i in range(n):
  for k in range(1,a[i][0]+1):
    x[a[i][k]-1] += 1
count = 0
for i in range(m):
  if x[i] == n:
    count += 1
print(count)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
n = [0]*(M+1)
for i in range(N):
  K,*A=map(int,input().split())
  for j in range(K):
    n[A[j]] += 1

count = 0
for i in range(len(n)):
  if n[i]==N:count += 1

print(count)

Submission status: Accepted

Solution code:
def main():
    N, M = map(int, input().split())
    K = []
    for i in range(N):
        K.append(list(map(int, input().split())))
    l = []
    ans = 0
    for i in range(M+1):
        l.append(0)
    for i in range(N):
        for j in range(K[i][0]):
            l[K[i][j+1]] += 1
    for i in range(len(l)):
        if l[i] == N:
            ans += 1
    print(ans)
main()

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
li=[list(map(int, input().split()))[1:] for _ in range(n)]
res=[0]*m
for i in range(n):
    for j in range(len(li[i])):
        res[li[i][j]-1]+=1
print(res.count(n))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
mist=[0 for i in range(m)]
for j in range(n):
    temp=list(map(int,input().split()))
    for s in range(1,len(temp)):
        mist[temp[s]-1]+=1

ans=sum(1 for x in mist if x==n)

print(ans)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ans = set(range(1,M+1))
for i in range(N):
    A = set(map(int, input().split()[1:]))
    ans = ans&A
#    print(ans)
#    print(i)
print(len(ans))

Submission status: Accepted

Solution code:
from collections import Counter
n, m = map(int, input().split())
ka = [list(map(int, input().split())) for _ in range(n)]

foods = [0]*m
for i in ka:
    for j in i[1:]:
        foods[j-1] += 1

foods = Counter(foods)
print(foods[n])

Submission status: Accepted

Solution code:
N, M = map(int,input().split())
a = []
ans = range(1,M + 1)
ans = list(ans)
for i in range(N):
    A = list(map(int,input().split()))
    K = A[0]
    A.remove(A[0])
    for j in range(1,M + 1):
        if j not in A:
            a.append(j)
for i in a:
    if i in ans:
        ans.remove(i)
print(len(ans))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
l=[0]*M
for i in range(N):
    a=list(map(int,input().split()))
    for j in a[1:]:
        l[j-1]+=1
cnt=0
for k in l:
    if k==N:
        cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
# abc118_b.py
# https://atcoder.jp/contests/abc118/tasks/abc118_b

# B - Foods Loved by Everyone /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# カツサンドくんはオムライスが好きです。
# 他にも明太子や寿司、クリームブリュレやテンダーロインステーキなどが好きで、これらの食べ物は全て、誰もが好きだと信じています。
# その仮説を証明するために、N人の人に M種類の食べ物について好きか嫌いかの調査を行いました。
# 調査の結果、i番目の人は Ai1 番目, Ai2 番目, ..., AiKi番目の食べ物だけ好きだと答えました。
# N人全ての人が好きだと答えた食べ物の種類数を求めてください。

# 制約
#     入力は全て整数である。
#     1≤N,M≤30
#     1≤Ki≤M
#     1≤Aij≤M
#     各 i(1≤i≤N) について Ai1,Ai2,...,AiKiは全て異なる。

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N M
# K1 A11 A12 ... A1K1
# K2 A21 A22 ... A2K2
# :
# KN AN1 AN2 ... ANKN

# 出力
# N人全ての人が好きだと答えた食べ物の種類数を出力せよ。

# 入力例 1
# 3 4
# 2 1 3
# 3 1 2 3
# 2 3 2

# 出力例 1
# 1

# 3人全員が好きだと答えた食べ物は 3 番目の食べ物だけなので 1を出力します。

# 入力例 2
# 5 5
# 4 2 3 4 5
# 4 1 3 4 5
# 4 1 2 4 5
# 4 1 2 3 5
# 4 1 2 3 4

# 出力例 2
# 0

# カツサンドくんの仮説は全く正しくありませんでした。

# 入力例 3
# 1 30
# 3 5 10 30

# 出力例 3
# 3


def calculation(lines):
    # line = lines[0]
    # N = int(lines[0])
    N, M = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i+1]))
    valueses = list()
    for i in range(N):
        valueses.append(list(map(int, lines[i+1].split())))

    dic = dict()
    for values in valueses:
        for i in range(1, len(values)):
            value = values[i]
            if value not in dic.keys():
                dic[value] = 1
            else:
                dic[value] += 1

    result = 0
    for key in dic:
        if dic[key] == N:
            result += 1

    return [result]


# 引数を取得
def get_input_lines():
    line = input()
    N, M = list(map(int, line.split()))
    lines = list()
    lines.append(line)
    for _ in range(N):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['3 4', '2 1 3', '3 1 2 3', '2 3 2']
        lines_export = [1]
    if pattern == 2:
        lines_input = ['5 5', '4 2 3 4 5', '4 1 3 4 5', '4 1 2 4 5', '4 1 2 3 5', '4 1 2 3 4']
        lines_export = [0]
    if pattern == 3:
        lines_input = ['1 30', '3 5 10 30']
        lines_export = [3]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines()
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
ListMaster=[]
for i in range(M):
  ListMaster.append(i+1)
s =set(ListMaster)
mid = set()
List = []
for i in range(N):
  List.append(list(map(int, input().split())))
for i in range(N):
  List[i].pop(0)
for i in range(N):
  mid = set(List[i])
  s = s&mid
print(len(s))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())

l = []

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

    for j in range(1, A[0] + 1):
        l.append(A[j])

ans = 0

for i in range(M + 1):
    if l.count(i) == N:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = set(range(1, m + 1))
for _ in range(n):
    a &= set(list(map(int, input().split()))[1:])
print(len(a))

Submission status: Accepted

Solution code:
N, M = map(int,input().split())
dish = [0 for i in range(M)]
for i in range(N):
  like = list(map(int,input().split()))
  for i in like[1:]:
    dish[i-1]+=1
ans = dish.count(N)
print(ans)

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
l = dict()
for i in range(1,m+1):
  l[i] = 0

for i in range(n):
  x = list(map(int, input().split()))
  k = x[0]
  for j in x[1:]:
    l[j] += 1

cnt = 0
for k,v in l.items():
  if v==n:
    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
KA = [list(map(int,input().split())) for _ in range(N)]

lst = [0]*M

for i in range(N):
    for j in range(KA[i][0]):
        lst[KA[i][j+1]-1] += 1

ans = lst.count(N)
print(ans)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ka = [list(map(int, input().split())) for i in range(n)]
l = [True] * m
for i in ka:
  K = i[0]
  for j in range(m):
    if j+1 not in i[1:]:
      l[j] = False
print(l.count(True))

Submission status: Accepted

Solution code:
import numpy as np
n,m = map(int, input().split())
arr = np.zeros(m)
for i in range(n):
    ka = np.array([int(i) for i in input().split()])
    for j in range(ka[0]):
        arr[ka[j+1]-1] += 1
ans = (arr == n).sum()
print(ans)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
an = []

for i in range(n):
  l = [int(num) for num in input().split()]
  an.append(l[1:])

check = {}
for i in an:
  for j in i:
    if j not in check:
      check[j] = 1
    else :
      check[j] += 1

answer = 0
for v in check.values() :
  if v == n:
    answer +=1
      
print(answer)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())


#print(A)
def comp(lst1,lst2):
    ret = []
    for i in lst1:
        if i in lst2:
            ret.append(i)
    return ret
ret = list(map(int,input().split()))
ret = ret[1:]
#print(ret)
for i in range(1,N):
    lst = list(map(int,input().split()))
    ret = comp(ret,lst[1:])
    #print(ret)
print(len(ret))

Submission status: Accepted

Solution code:
N,M = map(int, input().split())

A=[]
for i in range(N):
  x = [int(i) for i in input().split()]
  A = A + x[1:]

ans = 0
from collections import Counter
for k,v in Counter(A).items():
  # print(k,v)
  if v==N: ans += 1

print(ans)

Submission status: Accepted

Solution code:
# その23
# ABC118 B - Foods Loved by Everyone

n,m = map(int,input().split())
K_2=[]
t = 0
for i in range(n):
    A, *K =list(map(int,input().split()))
    K_2 +=K
K_3 = list(set(K_2))
for j in range(len(K_3)):
    K_4 = K_2.count(K_3[j])
    if K_4 == n:
        t +=1
print(t)

Submission status: Accepted

Solution code:
N,M = [int(i) for i in input().split()]
s = [0]*M
for _ in range(N):
    K,*A = [int(i) for i in input().split()]
    for i in A:
        s[i-1] += 1
print(s.count(N))

Submission status: Accepted

Solution code:
N, M = input().split(' ')
N = int(N)
M = int(M)
K1 = input().split(' ')
Like = [int(K1[i]) for i in range(1, len(K1))]
Like = set(Like)
for i in range(N-1):
  K = input().split(' ')
  K = [int(K[i]) for i in range(1, int(K[0])+1)]
  K = set(K)
  Like &= K
print(len(Like))

Submission status: Accepted

Solution code:
x = list(map(int, input().split()))
k = [list(map(int, input().split())) for i in range(x[0])]
f = 0
for i in k:
  i.pop(0)
  if f == 0:
    tmp = i
    f = 1
    s = i
  else:
    s = set(tmp) & set(i)
    tmp = s
print(len(s))

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, m = map(int, input().split())
    foods = [0] * m
    ans = 0
    for _ in range(n):
        k = list(map(int, input().split()))
        for i in range(1, k[0]+1):
            foods[k[i]-1] += 1
    for i in range(m):
        if foods[i] == n:
            ans += 1
    print(ans)
        
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
L = [0]*31

for n in range(N):
  K,*A = map(int,input().split())
  for a in A:
    L[a]+=1
    
print(L.count(N))

Submission status: Accepted

Solution code:
import math
def main():
  n,m = list(map(int,input().split()))
  alist=[[]]
  for i in range(0,n):
    alist.append(list(map(int,input().split())))
  ans=set(alist[1][1:])
  for i in range(2,n+1):
    ans=ans & set(alist[i][1:])
  print(len(ans))
main()

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
LIKE = [True] * M

for i in range(N):
  KA = list(map(int,input().split()))
  A = KA[1:]
  
  for i in range(M):
    if not (i+1) in A:
      LIKE[i] = False
      
print(LIKE.count(True))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())

l = [0] * (m+1)
for i in range(n):
  inp = list(map(int, input().split()))
  for j in range(1, inp[0]+1):
    l[inp[j]] += 1
ans = 0
#print(l, n)
for i in range(1, m+1):
  if l[i] == n:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N, M = mi()

d = defaultdict(int)

for _ in range(N):
    A = li()
    for i in range(1, len(A)):
        d[A[i]] += 1

ans = 0

for key, value in d.items():
    if value == N:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]

d = {}
for i in range(m):
    d[i+1] = 0

for i in a:
    for j in i[1:]:
        d[j] += 1
ans = 0
for i in d.values():
    if i == n:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
l = [0] * m
for i in range(n):
    a = list(map(int,input().split()))
    for j in a[1:]:
        l[j-1] += 1
ans = 0
for i in l:
    if i == n:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
T = set([*range(1, M+1)])
for _ in range(N):
  K, *A = map(int, input().split())
  T = T&set(A)
print(len(T))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
cnt = [0 for i in range(m)]
for i in range(n):
    a = list(map(int, input().split()))[1:]
    for j in a:
        cnt[j - 1] += 1
ans = cnt.count(n)
print(ans)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
like = [1]
for i in range(2,M+1):
  like.append(i)
for j in range(N):
  A = list(map(int,input().split()[1:]))
  for l in range(M):
    if l+1 in A:
      continue
    else:
      if l+1 in like:
        like.remove(l+1)
print(len(like))

Submission status: Accepted

Solution code:
# 42
N,M = map(int,input().split())
a = [0 for i in range(31)]
for i in range(N):
    l = list(map(int,input().split()))
    for i in range(1,31):
        for j in l[1:]:
            if i == j:
                a[i] +=1


cou = 0
for i in a:
    if i == N:
        cou+=1
    
print(cou)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n,m = map(int, input().split())
cnt = [0] * m
for _ in range(n):
    a = list(map(int, input().split()))
    for i in range(1, len(a)):
        a[i] -= 1
        cnt[a[i]] += 1

ans = 0
for c in cnt:
    if c == n:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
c = set(range(1, m+1))
for i in range(n):
  k, *a = map(int, input().split())
  c &= set(a)
print(len(c))

Submission status: Accepted

Solution code:
# coding: utf-8

# https://atcoder.jp/contests/abc118


def main():
    N, M = map(int, input().split())
    k_a = [None] * N
    for i in range(N):
        k_a[i] = list(map(int, input().split()))
    
    food = [0] * (M+1)
    for i in range(N):
        for j in range(1, k_a[i][0]+1):
            food[k_a[i][j]] += 1
    
    ans = 0
    for m in range(1, M+1):
        if food[m] == N:
            ans += 1
    
    return ans


print(main())

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
point = [0] * m
ans = 0
for i in range(n) :
    data = list(map(int, input().split()))
    for j in range(1,data[0]+1) :
        point[data[j]-1] += 1
for k in range(m) :
    if point[k] == n :
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
k = []
a = []
for _ in range(n):
    words = input().split()
    k.append(int(words[0]))
    a.append(list(map(int, words[1:])))

like_cnt = {i: 0 for i in range(1, m + 1)}
for ai in a:
    for aij in ai:
        like_cnt[aij] += 1
print(list(like_cnt.values()).count(n))

Submission status: Accepted

Solution code:
def main():
    n,m = map(int,input().split())
    a = []
    for i in range(n):
        tmp = [int(i) for i in input().split()]
        a.append(tmp)
    l = [0 for i in range(m)]
    for i in range(n):
        k = a[i][0]
        for j in range(1,k+1):
            l[a[i][j]-1] +=1
    ans = 0
    for i in range(m):
        if l[i] == n:
            ans += 1
    print(ans)

main()

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
l=list()
for i in range(N):
    A=list(map(int,input().split()))
    del A[0]
    l+=A
result=0
for i in range(M):
    if l.count(i+1)==N:
        result+=1
print(result)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
food=set(range(1,M+1))
for i in range(N):
    A=map(int,input().split()[1:])
    food&=set(A)
print(len(food))