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:
n,m = map(int, input().split())
d = {i+1:0 for i in range(m)}
a = [list(map(int, input().split()))[1:] for _ in range(n)]
for i in a:
  for j in i:
    d[j] += 1

print(sum([i==n for i in d.values()]))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
answer = set([])
for i in range(N):
  K_A = [int(x) for x in input().split()]
  K = K_A[0]
  A = K_A[1:]
  if i==0:
    answer = answer.union(set(A))
  else:
    answer = answer.intersection(set(A))
 
print(len(answer))

Submission status: Accepted

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

Submission status: Accepted

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

se = set(range(M+1))
for _ in range(N):
  enquete = [int(x) for x in input().split()]
  se &= set(enquete[1:])

answer = len(se)
print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, raw_input().split())
A = [0 for i in range(N)]
for i in range(N):
    A[i] = [int(tmp) for tmp in raw_input().split()[1:]]

count = 0
for i in range(1, M + 1):
    flag = True
    for j in range(N):
        if i not in A[j]:
            flag = False
    if flag:
        count += 1
print str(count)

Submission status: Accepted

Solution code:
N, M = (int(i) for i in input().split())
K = []
A = []
like_dict = {}
for i in range(N):
  KA = [int(j) for j in input().split()]
  K.append(KA[0])
  A.append(KA[1:])
for i in range(M):
  like_dict[i+1] = 0

for i in range(N):
  for j in range(K[i]):
    like_dict[A[i][j]] += 1

ans = 0

for i in range(1,M+1):
  if like_dict[i] == N:
    ans +=1

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
n, m = map(int, input().split())
ll = [0] * m
for i in range(n):
    l = list(map(int, input().split()))
    for j in range(l[0]):
        ll[l[j+1] - 1] += 1
print(ll.count(max(ll)) if max(ll)==n else 0)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
food = {}
for i in range(n):
    a = input().split()[1:]
    food = set(food)&set(a)
    if i == 0:
        food = a

print(len(food))

Submission status: Accepted

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

sum = 0
for i in range(1,m+1):
    if food[i] == n:
        sum += 1

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

like = list(map(int, input().split()))[1:]
for _ in range(n - 1):
    l = list(map(int, input().split()))[1:]
    like = set(l) & set(like)

print(len(like))

Submission status: Accepted

Solution code:
inp = input().split()
n = int(inp[0])
m = int(inp[1])
favorite = [] #　i番目の人が好きなものの集合のリスト
for i in range(n):
    tmp = []
    tmp_inp = input().split()
    k = int(tmp_inp[0])
    for i in range(k):
        tmp.append(int(tmp_inp[i+1]))
    favorite.append(set(tmp))


def intersect_set(list):  # 集合のリストを受け取って、それらの積集合を返す
    result = list[0]
    for i in range(len(list)-1):
        result = result.intersection(list[i+1])
    return result

print(len(intersect_set(favorite)))

Submission status: Accepted

Solution code:
inp = input().split()
n = int(inp[0])
m = int(inp[1])
hyou = []
for i in range(n):
    tmp = []
    tmp_inp = input().split()
    k = int(tmp_inp[0])
    for i in range(k):
        tmp.append(int(tmp_inp[i+1]))
    hyou.append(set(tmp))


def intersect_set(list):
    result = list[0]
    for i in range(len(list)-1):
        result = result.intersection(list[i+1])
    return result

print(len(intersect_set(hyou)))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ka = []
for i in range(n):
    ka.append(list(map(int, input().split())))
ok = 0
flag = False
for j in range(1, 31):
    for i in range(n):
        row = ka[i][1:]
        flag = (j in row)
        if not flag:
            break
    if flag:
        ok += 1
        flag = False
print(ok)

Submission status: Accepted

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

C = [0]*(M+1)

for _ in range(N):
    li = list(map(int, input().split()))
    K = li[0]
    for i in range(K):
        C[li[i+1]] += 1
        # print(C)

print(C.count(N))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

N,M = list(map(int,input().split(" ")))
a = [list(map(int,input().split(" "))) for i in range(N)]
tmp = []
for i in range(N):
    del a[i][0]
    tmp+=a[i]
c=0
for _ in list(set(tmp)):
    if tmp.count(_)==N:
        c+=1
print(c)

Submission status: Accepted

Solution code:
import numpy as np

NM = list(map(int, input().split()))

count_num = np.zeros((NM[1], 1))

for i in range(NM[0]):
    num = list(map(int, input().split()))
    del num[0]
    for j in num:
        count_num[j-1] += 1

print(np.sum(count_num == NM[0]))

Submission status: Accepted

Solution code:
import collections

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

lst2 = list()
for i in range(0, len(lst)):
    for j in range(1, len(lst[i])):
        lst2.append(lst[i][j])

c = collections.Counter(lst2)

ans_cnt = 0
for moji, cnt in c.items():
    if cnt == n:
        ans_cnt+=1

print(ans_cnt)

Submission status: Accepted

Solution code:
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N, M = list(map(int, sys.stdin.readline().split()))
ans =set( list(range(M+1)))
for i in range(N):
    _, *A = list(map(int, sys.stdin.readline().split()))
    ans &= set(A)
print(len(ans))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ans = set()
for i in range(n):
    fi = set([x for x in map(int, input().split())][1:])
    if i == 0:
        ans = ans | fi
    else:
        ans = ans & fi
print(len(ans))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
candidate = list(range(1, M+1))
for i in range(N):
    items = list(map(int, input().split()))
    items = items[1:]
    candidate = [cand for cand in candidate if cand in items]
    
print(len(candidate))

Submission status: Accepted

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

ans_list = []
for i in range(N):
    k, *A = map(int, input().split())
    for a in A:
        ans_list.append(a)
        
ans = 0
for i in range(1, M+1):
    if ans_list.count(i) == N:
        ans += 1
        
print(ans)

Submission status: Accepted

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

for i in range(1,M+1):
    for j in range (N):
        for k in range(1,K[j][0]+1):
            if K[j][k]  == i:
                yobi += 1
        
    if yobi == N:
        ans += 1
        yobi = 0
    
    else:
        yobi = 0

print(ans)

Submission status: Accepted

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

for _ in range(N):
    KA=list(map(int,input().split()))
    for i in KA[1:]:
        L[i-1]+=1

print(L.count(N))

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
L=[]
for s in range(a):
  x=input().split()[1:]
  L=list(set(L)&set(x))
  if s==0:
    L=x
print(len(L))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

A_li = [0]*M

for i in range(N):
    A = list(map(int,input().split()))  
    K = A.pop(0)
    for j in range(K):
        A_li[A[j]-1] += 1


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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
k=[input().split() for i in range(n)]
ans=0
for i in range(1,m+1):
 kari=0
 for s in range(n):
  if str(i) in k[s][1:]:
   kari+=1 
 if kari==n:
  ans+=1
print(ans)

Submission status: Accepted

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

food = [0] * M

for i in range(N) :
    A = list(map(int,input().split()))
    for index in A[1:] :
        food[index-1] += 1

ans = 0
for count in food :
    if count >= N :
        ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

hoge = set(list(range(1, M+1)))
for i in range(N):
    A = list(map(int, input().split()))[1:]
    A_set = set(A)
    hoge &= A_set

print(len(hoge))

Submission status: Accepted

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

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:
# PROXY

import collections
N, M = map(int, input().split())
co = collections.Counter()
for i in range(N):
  k, *a = map(int, input().split())
  co.update(a)
print(sum(1 for k, v in co.items() if v == N))

Submission status: Accepted

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

import collections
counter = collections.Counter()
for i in range(N):
  k, *a = map(int, input().split())
  counter.update(a)

print(sum(1 for k, v in counter.items() if v == N))

Submission status: Accepted

Solution code:
from collections import defaultdict

n,m = map(int,input().split())
k = [0]*n
a = [0]*n

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


d = defaultdict(int)

for j in a:
    for k in j:
        d[k] += 1

flg = 0
for k in d.values():
    if k == n:
        flg +=1

print(flg)

Submission status: Accepted

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

x = [int(x) for x in input().split()][1:]
final = set(x)

for i in range(1, n):
    x = [int(x) for x in input().split()][1:]
    final = final.intersection(x)

print(len(final))

Submission status: Accepted

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

m = [0] * (M+1)

for ka in KA:
    for i, s in enumerate(ka):
        if i != 0:
            m[int(s)] += 1

ans = 0
for s in m:
    if s == N:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
import collections

N,M = map(int,input().split())
A = [list(map(int,input().split())) for i in range(N)]
favorite = []
count = 0

for i in range(1,A[0][0]+1):
    favorite.append(A[0][i])
for j in range(1,N):
    for k in range(1, A[j][0]+1):
        if A[j][k] in favorite:
            favorite.append(A[j][k])

a = collections.Counter(favorite)
for key,value in a.items():
    if value == N:
        count += 1
print(count)

Submission status: Accepted

Solution code:
n, m= map(int, input().split())
ka = [input() for i in range(n)]
common = {i for i in range(1,m+1)}
for k in ka:
    tmp = {int(i) for i in k.split()[1:]}
    common = common.intersection(tmp)

print(len(common))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b = map(int, input().split())

allitem = []
for i in range(b):
    allitem.append(i+1)

for i in range(a):
    item = []
    ans = [int(iz) for iz in input().split()]
    for j in range(ans[0]):
        item.append(ans[j+1])

    allitem = list(set(allitem) & set(item))

    
print(len(allitem))

Submission status: Accepted

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

U = [[0]*M for i in range(N)]

for i in range(N):
    A = list(map(int, input().split()))
    K = A[0]
    A = A[1:]
    for j in range(K):
        t = A[j] - 1
        U[i][t] = 1

cnt = 0
for i in range(M):
    cnt2 = 0
    for j in range(N):
       cnt2 += U[j][i]
       if cnt2 == N:
           cnt +=1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
L=[]
for i in range(N):
  a=list(map(int,input().split()))
  for b in a[1:]:
    L.append(b)
ans=0
for i in range(31):
  if L.count(i)==N:
    ans=ans+1
print(ans)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
li = [0]*n
for i in range(n):
  li[i] = list(map(int,input().split()))
  li[i] = li[i][1:]

ans = 0
for i in range(1,m+1):
  for j in range(n):
    if i in li[j]:
      continue
    else:
      break
  else:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/python
# coding: UTF-8
n,m = map(int,input().split())

res = [0 for _ in range(m)]

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

print(sum([res[i]==n for i in range(m)]))

Submission status: Accepted

Solution code:
#!/usr/bin/python
# coding: UTF-8
n,m = map(int,input().split())

res = [0 for _ in range(m)]

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

print(res.count(n))

Submission status: Accepted

Solution code:
#!/usr/bin/python
# coding: UTF-8
n,m = map(int,input().split())

res = [0 for _ in range(m)]

for i in range(n):
  res_tmp = [0 for _ in range(m)]
  for j in list(map(int,input().split()))[1:]:
    res[j-1] += 1

print(sum([res[i]==n for i in range(m)]))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
S0 = list(input().split())
S = S0[1:]

for _ in range(N - 1):
	S0 = list(input().split())
	S = set(S) & set(S0[1:])

print(len(S))

Submission status: Accepted

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

x=0
for i in range(1,m+1):
    for j in range(n):
        v.append(a[j].count(i))

for i in range(0,m*n,n):
  
    if v[i:i+n].count(1)==n:
        x+=1

  
print(x)

Submission status: Accepted

Solution code:
n,m = [ int(v) for v in input().split() ]

food_list = [ 0 for i in range(m) ]
for i in range(n):
	food = [ int(v) for v in input().split() ]
	for j in range(food[0]):
		food_list[food[j+1]-1] += 1

print(food_list.count(n))

Submission status: Accepted

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

dic = [True for _ in range(M)]

for i in range(N):
    K, *A = list(map(int,input().split()))
    for j in range(M):
        if j+1 in A:
            continue
        else:
            dic[j] = False

print(dic.count(True))

Submission status: Accepted

Solution code:
import sys
from collections import deque
input = sys.stdin.readline

N, M = map(int, input().split())
A = deque()
ans = [[0]*M for i in range(N)]
counter = [0 for i in range(M)]
counter2 = 0
for _ in range(N):
    A.append(list(map(int, input().split())))

for i in range(N):
    for j in range(1, len(A[i])):
        counter[A[i][j]-1] += 1

for i in range(len(counter)):
    if counter[i] == N:
        counter2 += 1
print(counter2)

Submission status: Accepted

Solution code:
#118
import collections
N, M = map(int, input().split())
A = [[] for _ in range(N)]
for i in range(N):
    A[i] = list(map(int, input().split()))
All = []
count = 0
for v in A:
    v.pop(0)
    
for v in A:
    for _v in v:
        All.append(_v)
_All= collections.Counter(All)
#All = set(All)
for v in _All:
    if _All[v] == N:
        count += 1
print(count)

Submission status: Accepted

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

all_ka = []
for ka in KA:
    all_ka.extend(ka)
all_ka = collections.Counter(all_ka)
count = 0
for one in all_ka:
    if all_ka[one] == len(KA):
        count += 1
print(count)

Submission status: Accepted

Solution code:
n,m = (int(x) for x in input().split())
k = [0]*n
a = []
for i in range(n):
    tmp =  input().split()
    k[i] = int(tmp.pop(0))
    a.append(tmp)
# ここまで入力

# 以下　何人が各種類を好物としているのか配列に入れてカウント
species = [0]*m
for i in range(n):
    for j in range(k[i]):
        species[int(a[i][j])-1] += 1

ans = 0
# 好みとした人がn人ならば答えのカウントを増やす
for i in species:
    if i == n:
        ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
a = [input().split() for i in range(N)]
for b in a:
    del b[0]
x = set(a[0])

for b in a:
    x = x & set(b)
print(len(x))

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()))
  a=a[1:]
  for j in range(len(a)):
    cnt[a[j]-1] +=1

print(cnt.count(n))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
a = [input().split() for i in range(N)]
for b in a:
    del b[0]
x = set(a[0])

for b in a:
    x = x & set(b)
print(len(x))

Submission status: Accepted

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

lst = [0 for i in range(M+1)]
for i in range(N):
    for j in list(map(int, input().split()))[1:]:
        lst[j] += 1

cnt = 0
for i in range(1, M+1):
    if lst[i] == N:
        cnt += 1

print(cnt)

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()))
    A = A[1:]
    for j in range(len(A)):
        cnt[A[j]-1] += 1

print(cnt.count(N))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
A=[]
for i in range(N):
    B=list(input().split())
    for j in range(1,int(B[0])+1):
        A.append(B[j])
count=0
for k in range(M+1):
    if A.count(str(k))==N:
        count+=1
print(count)

Submission status: Accepted

Solution code:

lst_1 = input().split()
N = int(lst_1[0])
M = int(lst_1[1])

lst_A = []

ans = 0

for i in range(N):
    lst_A.append(input().split())

for food_num in range(1, M+1):

    count = 0

    for i in range(0, N):

        list_range = int(lst_A[i][0])

        for j in range(1, list_range + 1):

            if food_num == int(lst_A[i][j]):
                count += 1

    if count == N:
        ans += 1

print(ans)

Submission status: Accepted

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

for _ in range(N):
  l.append(list(map(int, input().split()))[1:])
  
for i in range(M):
  if all(i+1 in l0 for l0 in l):
    cnt += 1

print(cnt)

Submission status: Accepted

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

l = []
for i in range(N):
  K, *A = map(int, input().split())
  for k in range(K):
    l.append(A[k])

cnt = 0
for i in list(set(l)):
  if l.count(i) == N:
    cnt = cnt + 1

print(cnt)

Submission status: Accepted

Solution code:
def sub():
    N, M = [int(e) for e in input().split()]
    memo = [0 for _ in range(M)]
    for i in range(N):
        lines = [int(e) for e in input().split()]
        K = lines[0]
        As = lines[1:]
        for a in As:
            memo[a-1] = memo[a-1] + 1
    count = 0
    for m in memo:
        if m == N:
            count += 1
    print(count)

sub()

Submission status: Accepted

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

C = [0] * M
for _ in range(N):
    A = list(map(int, input().split()))
    del(A[0])
    
    for a in A:
        C[a-1] += 1
       
print(C.count(N))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# スペース区切りの整数の入力
N,M = map(int, input().split())
A_list=[]
food_list=[]

for i in range(N):
  A_list.append([int(e) for e in input().split()])

for i in range(M):
  food_list.append(0)
  
for i in range(N):
  K=A_list[i][0]
  for j in range(1,K+1):
    #print(A_list[i][j],end="")
    food_list[A_list[i][j]-1]+=1

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

Submission status: Accepted

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

for _ in range(n):
    k, *a = map(int, input().split())
    s = s.intersection(set(a))

print(len(s))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = [int(nm) for nm in input().split()]
L = []
for n in range(N):
  KA = [int(ka) for ka in input().split()]
  for ka in range(len(KA)-1):
    L.append(KA[ka+1])
like = 0
for m in range(M):
  if L.count(m+1) == N:
    like += 1
print(like)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans.count(n))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3



# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N, M = map(int,input().split())
    K = []
    A = []
    for n in range(N):
        d = list(map(int,input().split()))
        K.append(d[0])
        A.append(set(d[1:]))

    res = A[0]
    for a in A:
        res = res & a

    print(len(res))





if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N, M = map(int, input().split())

    ans = set()
    for i in range(N):
        A = set(list(map(int, input().split()))[1:])
        if i == 0:
            ans = A
        else:
            ans.intersection_update(A)
    print(len(ans))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

for i in range(1,M+1):
    count = 0
    for f_food in list_a:
        f_food[0] = -1
        if(i in f_food):
            count += 1
    if(count == len(list_a)):
            ans += 1
print(ans)

Submission status: Accepted

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

for i in range(n):
    for j in ka[i][1:]:
        ans[j-1] += 1

print(ans.count(n))

Submission status: Accepted

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

for i in range(n):
    for j in ka[i][1:]:
        ans[j-1] += 1
print(ans.count(n))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ka = [list(map(int, input().split())) for i in range(n)]
ans = [0] * m

for i in range(n):
    for j in ka[i][1:]:
        ans[j-1] += 1

print(ans.count(n))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ka = [list(map(int, input().split())) for i in range(n)]
ans = [0] * m

for i in range(n):
    for j in range(1, len(ka[i])):
        for k in range(1, m+1):
            if ka[i][j] == k:
                ans[k-1] += 1
                break

print(ans.count(n))

Submission status: Accepted

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

Submission status: Accepted

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

List = [list(map(int, input().split())) for i in range(n)]
sum = 0

for i in range(1,m+1):
    cnt = 0
    for j in range(n):
        if i in List[j][1:]:
            cnt += 1
            if cnt == n:
                sum += 1

print(sum)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
val = []
for i in range(n):
    val.append([i for i in map(int,input().split())])
    del(val[i][0])


ans = [[] for i in range(n+1)]

ans[0] = [i+1 for i in range(m)]
for i in range(n):
    for j in val[i]:
        if j in ans[i] :
            ans[i+1].append(j)
        else: pass
print(len(ans[n]))

Submission status: Accepted

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

# 各Kについて積集合をとる
ans = set([int(i) for i in range(1, M+1)])

for n in range(N):
    ans = ans & set(KA[n][1:])

print(len(ans))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
member = [list(map(int, input().split())) for i in range(N)]  # 複数行の数値の入力

allcnt = 0
cnt = 0
exist = False
for i in range(1, M + 1):
    cnt = 0
    for j in range(0, N):
        for k in range(1, member[j][0] + 1):
            if member[j][k] == i:
                exist = True
        if exist == True:
            cnt += 1
            exist = False
    if cnt == N:
        allcnt += 1

print(allcnt)

Submission status: Accepted

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

def main():
    ans = set()
    [ans.add(int(s)) for s in range(1, M + 1)]
    for _ in range(N):
        _, *a = [int(s) for s in input().split()]
        ans = ans & set(a)
    print(len(ans))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
master = [True] * m
for i in range(n):
    d = map(int, input().split())
    d = list(d)
    num = int(d[0])
    d = d[1:]
    table = [False] * (m + 1)
    for j in range(num):
        table[ d[j] - 1 ] = True
    for j in range(m):
        master[j] = master[j] and table[j]

count = 0
for j in range(m):
    if master[j]:
        count += 1
print(count)

Submission status: Accepted

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

Ans =[0]*M
for i in K:
  for itr , j in enumerate(i):
    if itr != 0:
      Ans[j-1] += 1

print(Ans.count(N))