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())

dic = {}
for i in range(N):
    L = list(map(int, input().split()))
    L.pop(0)
    for i in L:
        if i in dic:
            dic[i] += 1
        else:
            dic[i] = 1

ans = 0
for i, j in dic.items():
    if j == N:
       ans += 1

print(ans)

Submission status: Accepted

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

for i in range(N):
    arr.append(list(map(int, input().split())))

for i in range(N):
    K = arr[i][0]
    for j in range(1,K+1):
        count_arr[arr[i][j]-1] += 1

count = 0
for i in count_arr:
    if i == N:
        count += 1

print(count)

Submission status: Accepted

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

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

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 range(1,a[0]+1):
        l[a[j]-1] += 1
print(l.count(n))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
x = [0 for _ in range(m)]
for _ in range(n):
  t = input().split()
  k = t[0]
  a = list(map(int,t[1:]))
  for aa in a:
    aa -= 1
    x[aa] += 1
x = list(filter(lambda s: 1 if s == n else 0, x))
print(len(x))

Submission status: Accepted

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

Submission status: Accepted

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

like = [ 0 for x in range(M+1)]
for ka in KA:
    a = ka[1:]
    for aa in a:
        like[aa] += 1

#print(like)
cnt = 0
for l in like:
    if l == N:
        cnt += 1
print(cnt)

Submission status: Accepted

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

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

ans=0

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

Submission status: Accepted

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


main()

Submission status: Accepted

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

alist = []
for i in range(n):
    a = list(map(int,input().split()))
    alist.append(a[1:])

for i in range(1,m+1):
    flag = True
    for a in alist:
        if i in a:
            continue
        else:
            flag = False
            break
    if flag:
        ans +=1
        
print(ans)

Submission status: Accepted

Solution code:

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

s=dict()
for i in range(N):
    a=list(map(int,input().split()))
    for i in range(1,len(a)):
        if(a[i] not in s):
            s.update({a[i]:1})
        else:
            s[a[i]]+=1
ans=0
for i in range(1,len(s)+1):
    try:
        if(s[i]==N):
            ans+=1
    except:
        pass
if(N==1):
    print(a[0])
else:
    print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    N, M = il()
    food = {i: 0 for i in range(1, M + 1)}
    for n in range(N):
        i = il()
        for x in i[1:]:
            food[x] += 1
    ans = 0
    for f in food:
        if food[f] == N:
            ans += 1
    return ans


if __name__ == "__main__":
    print(solve())

Submission status: Accepted

Solution code:
p = input().split()
n = int(p[0])
m = int(p[1])
k = []
for i in range(n):
    l = input().split()
    for j in range(int(l[0])):
        k.append(l[j+1])
c = 0
for i in range(m):
    s = 0
    for j in k:
        if (i+1) == int(j):
            s += 1
    if s == n:
        c += 1
print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M = map(int, input().split())
s = [0]*(M+1)
for _ in range(N):
    l = list(map(int, input().split()))
    for a in l[1:]:
        s[a] += 1

ans = 0
for i in s:
    if i == N:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
from functools import reduce
N, M = list(map(int, input().split()))
K = [set([int(a) for a in input().split()[1:]]) for _ in range(N)]
print(len(reduce(lambda x, y: x.intersection(y), K)))

Submission status: Accepted

Solution code:
N,M=[int(x) for x in input().split()]
result=list(range(1,M+1))
for i in range(N):
    I=input().split()
    K=int(I[0])
    As=[int(x) for x in I[1:]]
    result=list(set(As)&set(result))
print(len(result))

Submission status: Accepted

Solution code:
N,M = map(int,input().split(" "))
list = [0] * (M+1)
#print(list)

for i in range(N):
    A = input().split(" ")
    A = [int(i) for i in A]
    K = A[0]
    for j in range(K):
        list[A[j+1]] += 1
#print(list)
C = 0
for i in range(len(list)):
    if list[i] == N:
        C += 1
print(C)

Submission status: Accepted

Solution code:
#import collections
N,M=map(int,input().split())
lr=list(map(int,input().split()))[1:]
s = set(lr)

for i in range(N-1):
    l = list(map(int, input().split()))[1:]
    s = s&set(l)

print(len(s))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
[n,m] = [int(i) for i in input().split()]
ka = []
for i in range(n):
    ka.append([int(j) for j in input().split()])
dic = {}

for i in range(n):
    for j in range(1,len(ka[i])):
        if ka[i][j] not in dic.keys():
            dic[ka[i][j]] = 1
        else:
            dic[ka[i][j]] += 1
count = 0
for i in range(1,m+1):
    if i in dic.keys() and dic[i] == n:
        count += 1

print(count)

Submission status: Accepted

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

ans = set()
for i in range(n):
  c=list(map(int, input().split()))
  c.pop(0)
  if i ==0:
    ans = set(c)
  else:
    ans = ans & set(c)
print(len(ans))

Submission status: Accepted

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

a = [int(i) for i in input().split()][1:]
s = set(a)

for i in range(1, n):
  a = [int(i) for i in input().split()][1:]
  s = s & set(a)

print(len(s))

Submission status: Accepted

Solution code:
#coding:utf-8
N,M = map(int,(input().split()))
A = [list(map(int,input().split()[1:])) for i in range(N)]
numFav = [0]*M
for line in A:
    for a in line:
        numFav[a-1] = numFav[a-1] + 1
print(numFav.count(N))

Submission status: Accepted

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

for i in range(n):
    ka = list(map(int, input().split()))
    k = ka[0]
    aa = set(ka[1:])
    if temp is None:
        temp = aa
    else:
        temp.intersection_update(aa)

if temp is None:
    print(0)
else:
    print(len(temp))

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

for _ in range(N):
    K1, *A = [int(a) for a in input().split()]
    for i in range(M):
        if i+1 not in A:
            X[i] = 0
        
print(sum(X))

Submission status: Accepted

Solution code:
def solve(N, M, KAs):
    ans = 0
    for m in range(1, M+1):
        if all(m in KAs[n][1:] for n in range(N)):
            ans += 1
    return ans


if __name__ == "__main__":
    N, M = tuple(map(int, input().split(" ")))
    KAs = list(list(map(int, input().split(" "))) for _ in range(N))
    print(solve(N, M, KAs))

Submission status: Accepted

Solution code:
N, M = [int(v) for v in input().split()]
line = [int(v) for v in input().split()]
foods = set(line[1:])

for i in range(1, N):
    line = [int(v) for v in input().split()]
    foods = foods & set(line[1:])

print(len(foods))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

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

count = 0
for i in ans:
    if i == n:
        count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

    for j in range(inputs[0]):
        foods[inputs[j + 1] - 1] += 1

ans = 0
for food in foods:
    if food == N:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
def func():
    pass


def main():
    n, m = map(int, input().split())

    l = [0] * m
    for i in range(n):
        a = [int(i) for i in input().split()]
        for i, ai in enumerate(a):
            if i == 0:
                continue
            l[ai - 1] += 1

    print(l.count(n))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
c = [0 for i in range(b)]
cc = [0 for i in range(b)]
for i in range(a):
	l = list(map(int,input().split()))
	for j in range(l[0]):
		if cc[l[j+1]-1] == 0:
			c[l[j+1]-1] += 1
			cc[l[j+1]-1] += 1
	cc = [0 for i in range(b)]
co = 0
for i in range(b):
	if c[i] == a:
		co += 1

print(co)

Submission status: Accepted

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

I = [int(j) for j in input().split()]
k = I.pop(0)
ans = set(I)
for i in range(n-1):
    I = [int(j) for j in input().split()]
    k = I.pop(0)
    ans = ans & set(I)

print(len(ans))

Submission status: Accepted

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

ans = [a // N for a in ans]
print(sum(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(N):
  K = A[i][0]
  for j in range(1,K+1):
    A[i][j]
    if(A[i][j] in d):
      d[A[i][j]] += 1
    else:
      d[A[i][j]] = 1
cnt = 0
for k, v in d.items():
  if(v == N):
    cnt += 1
print(cnt)

Submission status: Accepted

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

for i in range(N):
	A = list(map(int,input().split()))
	for j in range(len(A)):
		if j == 0:
			continue
		else:
			cnt[A[j]] += 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())
res = [0]*31
for i in range(n):
    l = list(map(int,input().split()))
    for j in l[1:]:
        res[j] += 1
else:
    num = 0
    for k in res:
        if k==n:
            num += 1
    else:
        print(num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
K = []
food = set(range(1, M+1))
for _ in range(N):
    temp = list(map(int, input().split()))
    K.append(temp[0])
    food &= set(temp[1:])
print(len(food))

Submission status: Accepted

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

Submission status: Accepted

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

menu = [0] * m
for i in range(n):
    ka = list(map(int, input().split()))
    for a in ka[1:]:
        menu[a-1] += 1
res = 0
for i in menu:
    if i == n:
        res += 1
print(res)

Submission status: Accepted

Solution code:
from collections import Counter

n, m = map(int, input().split())
s = []
for i in range(n):
    a = list(map(int, input().split()))
    del a[0]
    for j in range(len(a)):
        s.append(a[j])
ans = 0
sS = Counter(s)
for i in sS.values():
    if i == n:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import numpy as np

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

current = set(A_list[0])
for foods in A_list:
    foods = set(foods)
    current = current & foods
print(len(list(current)))

Submission status: Accepted

Solution code:
import math
import copy
import bisect







def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:

            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input().split())
    return l

n=nCast(input().split())
m=nCast(inputArr1(n[0]))



def func():
    
    s=set(m[0][1:])
    for mm in m:
        tmp=set(mm[1:])
        s=s&tmp
    return len(s)
        


print(func())

Submission status: Accepted

Solution code:
N, M = map(int, input().split(' '))
dic = {i+1:0 for i in range(M)}
for i in range(N):
    lst = list(map(int, input().split(' ')))
    for a in lst[1:]:
        dic[a] += 1

cnt = 0
for v in dic.values():
    if v == N:
        cnt += 1
         
print(cnt)

Submission status: Accepted

Solution code:
N, M = map(int,input().split())
d = {}
for i in range(N):
    l = list(map(int, input().split()))
    for ak in l[1:]:
        if ak in d:
            d[ak] += 1
        else:
            d[ak] = 1

cnt = 0
for k in d.keys():
    if d[k] == N:
        cnt+=1

print(cnt)

Submission status: Accepted

Solution code:
a = list(map(int,input().split()))
cnt = [0,] *(a[1]+1)
for i in range(a[0]):
    suki = list(map(int,input().split()))
    for j in range(1, len(suki)):
        cnt[suki[j]]+=1
ans = 0
for i in range(1, a[1]+1):
    if cnt[i] == a[0]:
        ans+=1
print(str(ans))

Submission status: Accepted

Solution code:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor

import heapq
import itertools
import operator


def get_int():
    return int(input())


def get_str():
    return input().strip()


def get_int_list():
    return [int(i) for i in input().split()]


def get_char_list():
    return list(input().strip())


def main():
    n, m = get_int_list()
    kas = []
    for _ in range(n):
        kas.append(get_int_list())

    counter = Counter()
    for ka in kas:
        for x in ka[1:]:
            counter[x] += 1
    print(len(list(filter(lambda x: x == n, counter.values()))))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N,M = [int(_) for  _ in input().split()]
sA = set([int(_) for  _ in input().split()][1:])
for _ in range(N-1):
    sA &= set([int(_) for  _ in input().split()][1:])
print(len(sA))

Submission status: Accepted

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

Mlist = [0]*M
for x in range(N):
    cache = [int(x) for x in input().split()]
    for x in cache[1:]:
        Mlist[x-1] = Mlist[x-1]+1

count = 0
for x in Mlist:
    if x == N:
        count += 1

print(count)

Submission status: Accepted

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

k = [[int(i) for i in input().split()] for i in range(n)]
v = [0]*31
for i in range(n):
    for j in range(k[i][0]):
        v[k[i][j + 1]] += 1
count = 0
for i in range(len(v)):
    if v[i] == n:
        count += 1
print(count)

Submission status: Accepted

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    N, M = LI()
    KA = []
    [KA.append(LI()) for i in range(N)]

    result = 0
    for i in KA[0][1:]:
        if all([i in j[1:] for j in KA]):
            result += 1

    print(result)

main()

Submission status: Accepted

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

Submission status: Accepted

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

for x in range(0,N):
    A = list(map(int,input().split()))
    for y in A[1:]:
        likelist[y] += 1

answer = likelist.count(N)
print(answer)

Submission status: Accepted

Solution code:
from collections import Counter
n,m = map(int,input().split())
many  =[]
for i in range(n):
    a = list(map(int,input().split()))
    for j in range(1,a[0]+1):
        many.append(a[j])

ans = Counter(many).most_common()
count = 0
for i in range(len(ans)):
    if ans[i][1] == n:
        count += 1

print(count)

Submission status: Accepted

Solution code:
N, M = (int(x) for x in input().split())
lst = [0 for _ in range(M)]
for _ in range(N):
  A = tuple(int(x) for x in input().split())
  for a in A[1:]:
    lst[a-1] += 1
print(lst.count(N))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
from functools import reduce
N, M = map(int, input().split())
prod = set(range(1, M + 1))
for _ in range(N):
    prod &= set(list(map(int, input().split()))[1:])
ans = len(prod)
print(ans)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
B = [0 for _ in range(M+1)]
for _ in range(N):
    A = list(map(int, input().split()))
    A = A[1:]
    for a in A:
        B[a] += 1
cnt = 0
for b in B:
    if b == N:
        cnt += 1
print(cnt)

Submission status: Accepted

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

A = []
for i in range(a):
    X = list(map(int, input().split()))
    A.append(X[1:])

count = 0
sum= 0
for i in A[0]:
    for j in range(a):
        if(i in A[j]):
            count+=1
    if(count == a):
        sum+=1
    count= 0
print(sum)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
counter = [0] * m
for _ in range(n):
    suki = list(map(int, input().split()))
    for t in suki[1:]:
        counter[t-1] += 1
print(counter.count(n))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict
dic = defaultdict(int)
N,M = map(int, input().split())
for i in range(N):
    tmp = list(map(int,input().split()))
    for j in range(1,len(tmp)):
        dic[tmp[j]] += 1

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

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
K = []
A = []
for _ in range(N):
    row = list(map(int,input().split()))
    K.append(row[0])
    A.append(row[1:])

likedByAll = [True for _ in range(M)]
for i in range(N):
    for m in range(1,M+1):
        if m not in A[i]:
            likedByAll[m-1] = False
ans = 0
for liked in likedByAll:
    if liked:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from itertools import chain
from functools import reduce
from collections import OrderedDict, Counter, deque
import operator

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

t = [0] * (m+1)

for _ in range(n):
    ka = [int(x) for x in input().split()]
    for a in ka[1:]:
        t[a] += 1

print(sum(1 for x in t if x == n))

Submission status: Accepted

Solution code:
N,M=map(int,input().split(' '))
K = []
A = {i+1 for i in range(M)}


for i in [0]*N:
	t = list(map(int,input().split(' ')))
	t = set(t[1:])
	A &= t
print(len(A))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
like=[True]*M
for _ in range(N):
    A=list(map(int,input().split()))[1:]
    F=[False]*M
    for a in A:
        F[a-1]=True
    for i in range(M):
        like[i]=like[i]&F[i]
print(like.count(True))

Submission status: Accepted

Solution code:
import collections

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

a = []
for i in range(N):
    tmp = list(map(int, input().split()))
    a += tmp[1:]

c = collections.Counter(a)
ans = 0
for _ in c.values():
    if _ == N:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
index=0
listL=[]
while index < n:
    listA=list(map(int, input().split()))
    del listA[0]
    if index==0:
        listL=listA
    else:
        index2=0
        while index2 < len(listL):
            if listL[index2] in listA:
                pass
            else:
                del listL[index2]
                index2-=1
            index2+=1
        if len(listL)==0:
            print(0)
            break
    index+=1
if index==n:
    print(len(listL))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
food = [0 for _ in range(M + 1)]
for _ in range(N):
    lst = list(map(int, input().split()))
    for item in lst[1:]:
        food[item] += 1
ans = 0
for item in food:
    if item == N:
        ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#横にn個入力
n, m = map(int, input().split())
c = []
for i in range(n):#h:高さ
    c.append([int(m) for m in input().split()])

numset = set()
for i in range(1, 31):
    numset.add(i)

for i in range(n):
    numset= set(c[i][1:]) & numset
print(len(numset))

Submission status: Accepted

Solution code:
N,M = list(map(int, input().split()))
data = [0]*30
for i in range(N):
  ai = list(map(int, input().split()))
  ai.remove(ai[0])
  for item in ai:
    data[item-1] += 1

count = 0
for item in data:
  if item == N:
    count += 1

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

L=[0 for i in range(M+1)]

for i in range(N):
    s=list(map(int,input().split()))
    for j in range(1,len(s)):
        L[s[j]]+=1
        
ans=0
for i in range(len(L)):
    if L[i]==N:
        ans+=1
        
print(ans)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
B=[0 for i in range(31)]
for i in range(n):
  A=list(map(int,input().split()))
  k=A[0]
  for i in range(1,k+1):
    B[A[i]]+=1
print(B.count(n))

Submission status: Accepted

Solution code:
a,b=map(int, input().split(" "))
for i in range(a):
    if i ==0:
        arr=list(map(int, input().split(" ")))[1:]
    else:
        tmp=set(list(map(int, input().split(" ")))[1:])
        arr=(set(arr) & set(tmp))
#print(arr)
print(len(arr))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
foodlist = [0 for i in range(M)]
for i in range(N):
    food = list(map(int, input().split()))
    food.pop(0)
    for items in food:
        foodlist[items-1]+=1
cnt = 0
#print(foodlist)
for i in range(M):
    if(foodlist[i] == N): cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions

def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())


#n = ip()                              #入力整数1つ
a,b= (int(i) for i in input().split())      #入力整数横2つ
#n,x,y = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
c = []
for i in range(a):
    d = [int(i) for i in input().split()]
    d.pop(0)
    c.append(d)
s = set(c[0])
for i in range(1,a):
    s = s.intersection(set(c[i]))
print(len(s))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
KA = list(map(int,input().split()))
result = KA[1:]
for _ in range(N-1):
    KA = list(map(int, input().split()))
    A = KA[1:]
    new_result = []
    for i in result:
        if i in A:
            new_result.append(i)

    result = new_result

print(len(result))

Submission status: Accepted

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

N, M = map(int, input().split())

ans = {}

for _ in range(N):
    K, *A = list(map(int, input().split()))
    for a in A:
        if a in ans:
            ans[a] += 1
        else:
            ans[a] = 1

count = 0
for k, v in ans.items():
    if v == N:
        count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

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

ans = 0
for i in L:
    if i == n:
        ans += 1
print(ans)