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: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

N, K = (int(i) for i in input().split())
e = [[int(i) for i in input().split()] for i in range(N)]

if N == 1:
    print(e[0][0])
    exit()

set_list = []

for i in e:
    set_list.append(set(i[1:]))


ok= set()
for i in set_list:
    for i2 in set_list:
        if i == i2:
            continue
        if len(ok) >=1:
            ok = list(i2.intersection(ok))
        else:
            ok = list(i.intersection(i2))
    break

print(len(ok))

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = input().split()
hito = []
for i in range(int(N)):
    hito.append(input().split())

for i in range(int(N)):
    hito[i] = list(map(int, hito[i]))

hikaku = np.arange(1,int(M)+1)
for i in range(int(N)):
    hikaku = list(set(hikaku) & set(hito[i]))
    
print(len(hikaku))

Submission status: Wrong Answer

Solution code:
from sys import stdin


def count_samples_of_like_same_food(samples_and_like_foods):
    all_samples_count = len(samples_and_like_foods)
    like_foods_num_dict = {}
    for like_foods in samples_and_like_foods:
        for like_food in like_foods:
            if like_food not in like_foods_num_dict:
                like_foods_num_dict[like_food] = 0
            else:
                like_foods_num_dict[like_food] += 1
                continue

    same_like_food_samples_count = 0
    for key, value in like_foods_num_dict.items():
        if value == all_samples_count:
            same_like_food_samples_count += 1
    return same_like_food_samples_count


def main():
    input_line_list = stdin.readlines()
    samples_and_like_foods = [like_foods_string.split() for like_foods_string in input_line_list]
    #print(samples_and_like_foods)
    print(count_samples_of_like_same_food(samples_and_like_foods))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

#一列目削除
for i in range(0,N):
    list[i].pop(0)

stock = []

#解答が全リストにあるか探索
for i in range(0,N):
    cnt = 0
    for j in range(0,len(list[i])):
        if list[i][j] in list[i]:
            cnt += 1
    if cnt == N:
        stock.append(list[i][j])

if N == 1:
    stock = list[i]

print(len(stock))

Submission status: Wrong Answer

Solution code:
import numpy as np

N, M = map(int, input().split())
A = np.full((N, M), 0)
for i in range(N):
    Ka = list(map(int, input().split()))
    a = Ka[1:]
    for j in a:
        A[i, j-1] = 1
        
print(np.sum(np.prod(A, axis=0)))

Submission status: Wrong Answer

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

konomi = [[0 for j in range(M)] for i in range(N)]

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

kannryou = [1 for j in range(M)]

for i in range(N):
    for j in range(konomi[i][0]):
        kannryou[konomi[i][j+1]-1] = 0
    
ans = sum(kannryou)
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin


def count_samples_of_like_same_food(samples_and_like_foods):
    all_samples_count = len(samples_and_like_foods)
    like_foods_num_dict = {}
    for like_foods in samples_and_like_foods:
        for like_food in like_foods:
            if like_food not in like_foods_num_dict:
                like_foods_num_dict[like_food] = 0
            else:
                like_foods_num_dict[like_food] += 1

    same_like_food_samples_count = 0
    for key, value in like_foods_num_dict.items():
        if value == all_samples_count:
            same_like_food_samples_count += 1
    return same_like_food_samples_count


def main():
    input_line_list = stdin.readlines()
    samples_and_like_foods = [like_foods_string.split() for like_foods_string in input_line_list]
    #print(samples_and_like_foods)
    print(count_samples_of_like_same_food(samples_and_like_foods))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
answerers, num_foods = map(int, input().split(' '))
favorites = []

for i in range(answerers):
  current_ans = list(map(int, input().split(' ')))
  print(current_ans[1:])
  favorites.extend(current_ans[1:])

res = [ favorites.count(food) == answerers for food in list(set(favorites)) ]
print(res.count(True))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
x = 0
for j in range(1,listA[0][0]+1):
    for i in range(1,n):
        if listA[0][j] not in listA[i]:
            break
    else:
    	x += 1
print(x)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
like = list(map(int, input().split(" ")))
if N == 1:
    print(like[0])
else:
    for i in range(N-1):
        A2 = list(map(int, input().split(" ")))
        a1 = like[1:]
        a2 = A2[1:]
        like = set(a1) & set(a2)
        like = list(like)
    print(len(like))

Submission status: Wrong Answer

Solution code:
from sys import stdin


def count_samples_of_like_same_food(samples_and_like_foods):
    all_samples_count = len(samples_and_like_foods)
    like_foods_num_dict = {}
    for like_foods in samples_and_like_foods:
        for like_food in like_foods:
            if like_food not in like_foods_num_dict:
                like_foods_num_dict[like_food] = 0
            else:
                like_foods_num_dict[like_food] += 1

    same_like_food_samples_count = 0
    for key, value in like_foods_num_dict.items():
        if value == all_samples_count:
            same_like_food_samples_count += 1
    return same_like_food_samples_count


def main():
    input_line_list = stdin.readlines()
    samples_and_like_foods = [like_foods_string.split() for like_foods_string in input_line_list]
    print(samples_and_like_foods)
    print(count_samples_of_like_same_food(samples_and_like_foods))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
count = 0
list2 = [0] * m
for i in range(n):
  list = input().split()
 
  for j in range(len(list)-1):
    for k in range(m):
      if int(list[j+1]) == k:
        list2[k-1] += 1
        break;

for l in range(m):
  if list2[l] == n:
    count += 1
if n == 1:
  count = list[0]
print(count)

Submission status: Wrong Answer

Solution code:
N, M = list(map(int, input().split())) # 整数
answer=[]
a = []
food_list=[]
for i in range(N):
    answer=list(map(int, input().split()))
    if i==0:
        food_list=answer
    else:
        like_food=[]
        for food in answer[1:-1]:
            if (food in like_food)==False:
                if (food in food_list)==True:
                    like_food.append(food)
        food_list=like_food
print(len(food_list))

Submission status: Wrong Answer

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

ka=[]
for i in range(n):
    atmp=list(input().split())
    ka.append(atmp)


like=ka[0][1::]
ans=len(like)

if n>1:
    for i in range(1,n):
        liketmp=ka[i][1::]
        for j in range(0,len(liketmp)-1):
            if liketmp[j] not in like:
                ans-=1

print(ans)

Submission status: Wrong Answer

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

#一列目削除
for i in range(0,N):
    list[i].pop(0)

stock = []

#解答が全リストにあるか探索
for i in range(0,N):
    if N == 1:
        stock = list[i]
    else:
        cnt = 0
        for j in range(0,len(list[i])):
            if list[i][j] in list[i]:
                cnt += 1
        if cnt == N:
            stock.append(list[i][j])

print(len(stock))

Submission status: Wrong Answer

Solution code:
from collections import Counter

n,m = list(map(int, input().split()))
ls = []
for i in range(n):
  a = list(map(int, input().split()))
  del a[0]
  for j in range(len(a)):
    ls.append(a[j])
#print(ls)

c = Counter(ls)
b = [k[0] for k in c.items() if k[1] == 3]
#print(b)
print(len(b))

Submission status: Wrong Answer

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

for i in range(n):
    del P[i][0]
    
K = set(P[0])
L = {}
for i in range(1,n):
    L = set(P[i])
    K = K & L
M = list(K)
if len(M) == 0:
    print(0)
else:
    for i in range(len(M)):
        print(M[i])

Submission status: Wrong Answer

Solution code:
import numpy as np

N, M = map(int, input().split())
A = np.full((N, M), 0)
for i in range(N):
    K, *a = map(int, input().split())
    for j in a:
        A[i, j-1] = 1
        
print(np.sum(np.prod(A, axis=0)))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
x = 0
for j in range(1,listA[0][0]+1):
    for i in range(1,n):
        if listA[0][j] not in listA[i]:
            break
    x += 1
print(x)

Submission status: Wrong Answer

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

ka=[]
for i in range(n):
    atmp=list(input().split())
    ka.append(atmp)


like=ka[0][1::]
ans=len(like)

if n>1:
    for i in range(1,n):
        liketmp=ka[i][1::]
        print(liketmp)
        for j in range(0,len(liketmp)-1):
            if liketmp[j] not in like:
                ans-=1

print(ans)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
x = 0
for j in range(1,listA[0][0]+1):
    for i in range(1,n):
        if listA[0][j] not in listA[i]:
            break
        x += 1
print(x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
answerers, num_foods = map(int, input().split(' '))
favorites = []

for i in range(answerers):
  current_ans = list(map(int, input().split(' ')))
  favorites.extend(current_ans[1:])

res = [ favorites.count(num_food) == answerers for num_food in range(2, num_foods, 1)]
print(res.count(True))

Submission status: Wrong Answer

Solution code:
N, M = input().split(" ")
S = set(str(i) for i in range(1, int(M)+1))
print(S)

for _ in range(int(N)):
    S = S & set(input().split(" ")[1:])
print(len(S))

Submission status: Wrong Answer

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

a = list(s)
print(a[0] if a != [] else 0)

Submission status: Wrong Answer

Solution code:
s,m=map(int,input().split())
l=[]
for _ in range(s):
  n=[]
  n=list(map(int,input().split()))
  n.pop(0)
  l=l+n
m=dict()
for i in l:
  if i in m:
    m[i]+=1
  else:
    m[i]=1
  print(m)
cnt=0
for j in m:
  if m[j]==s:
    cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
foods = set(range(m))
for i in range(n):
  opinion = set(list(map(int, input().split()))[1:])
  match = foods & opinion
  if match:
    foods = match
  else:
    foods = set()
    break
print(len(foods))

Submission status: Wrong Answer

Solution code:


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

a = []
k = []
for _ in range(n):
    ka = [int(i) for i in input().split()]
    k.append(ka[0])
    a.append(ka[1:])


# print(n, m, k, a)
#%%
# n,m,k,a = 3, 4, [2, 3, 2], [[1, 3], [1, 2, 3], [3, 2]]

#%%
def main():
    
    food = a[k.index(max(k))]

    for i in range(len(a)):
        for f in food:
            if f in a[i]:
                continue
            else:
                food.remove(f)
        if len(food) == 0:
            return 0
    return len(food)

print(main())    
#%%
# k.index(max(k))


#%%

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
c = []
for i in range(a):
  *s, = map(int, input().split())
  c += s[1:]
count=[]
e = c[:]
d=list(set(c))
 
for i in d:
  if e.count(i) == a:
    count.append(i)

Submission status: Wrong Answer

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

food_list = []
for i in range(int(M)):
    food_list.append(str(i+1))

for i in range(int(N)):
    favorite_list = input().split()[1:]
    if len(food_list) == 0:
        break
    test_list = food_list
    for j in test_list:
        if not (j in favorite_list):
            food_list.remove(j)

print(len(food_list))

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
c = []
for i in range(a):
  *s, = map(int, input().split())
  c += s[1:]
count=[]
e = c[:]
d=list(set(c))

for i in d:
  if e.count(i) == a:
    count.append(i)
    
print(len(count))
print(e,d)

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split())
a = list(map(int, input().split()))
K_past = a[0]
A_past = a[1:]
  

for n in range(1,N):
  a = list(map(int, input().split()))
  K = a[0]
  A = a[1:]
  
  for i in range(K):
    l = []
    if A[i] in A_past:
      l.append(A[i])
    A_past = l

Submission status: Wrong Answer

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

if n != 1:
    for i in range(n):
        for j in range(1, len(notfav)):
            if not notfav[j] in favlist[i]:
                notfav[j] = 0
    print(m - len(notfav))
else:
    print(len(favlist[0]) - 1)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
c = []
for i in range(a):
  *s, = map(int, input().split())
  c += s[1:]
count=[]
e = c[:]
d=list(set(c))

for i in d:
  if c.count(i) == a:
    count.append(i)
  else:continue

Submission status: Wrong Answer

Solution code:
number=list(map(int,input().split()))
likes=[]
result=0
for i in range(number[0]):
    rawdata=list(map(int,input().split()))
    for k in range(rawdata[0]):
        likes.append(rawdata[k+1])
for i in range(number[1]):
    if likes.count(i+1):
        result+=1
print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
import sys
import random
from operator import itemgetter
input = sys.stdin.readline

# a = int(input().rstrip())
# a, b = map(int, input().rstrip().split())
# D = list(map(int, input().rstrip().split()))
# H = [int(input().rstrip()) for _ in range(L)]
# DD = [[0 for j in range(100)] for i in range(200)]
# dict = {} ## dictionary

# a = sorted(a, key=lambda x: x[1]))
# if __name__ == '__main__':


N, M = map(int, input().rstrip().split())
likeList = []
for i in range(N):
	l = (list(map(int, input().rstrip().split())))
	likeList.append(l[1::])

ans = likeList[0]
for i in range(1, len(likeList)):
	j = 0
	while j < len(ans):
		tmp = ans[j]
		if not tmp in likeList[i]:
			ans.remove(tmp)
		j += 1
		
print(len(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
K = [0]*N
A = [[0]*M for i in range(N)]
for i in range(N):
  x = list(map(int, input().split()))
  K[i] = x[0]
  A[i] = x[1:]
l = A[0]
for i in range(1, N):
  j = 0
  max_j = len(l)-1
  j = 0
  while(j != max_j+1):
    print(l, A[i])
    if l[j] not in A[i]:
      del l[j]
      max_j -= 1
      j -= 1
    j += 1
print(len(l))

Submission status: Wrong Answer

Solution code:
N, M = map(int,input().split())
S = {i+1 for i in range(M)}

for i in range(N):
    L = [int(j) for j in input().split()]
    K = set(L[1::])
    S = S & K
    print(S)
print(len(S))

Submission status: Wrong Answer

Solution code:
(n, m) = map(int, input().split())
l = [set(list(map(int, input().split()))[1:]) for _ in range(n)]
len(l[0].intersection(*l[1:]))

Submission status: Wrong Answer

Solution code:
s,m=map(int,input().split())
l=[]
for _ in range(s):
  n=[]
  n=list(map(int,input().split()))
  n.pop(0)
  l=l+n
m=dict()
for i in n:
  if i in m:
    m[i]+=1
  else:
    m[i]=1
cnt=0
for j in m:
  if m[j]==s:
    cnt+=1
print(cnt)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:


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

a = []
k = []
for _ in range(n):
    ka = [int(i) for i in input().split()]
    k.append(ka[0])
    a.append(ka[1:])



#%%
# n,m,a = 3, 4, [[1, 3], [1, 2, 3], [3, 2]]


#%%
def main():
    food = a[0]

    for i in range(1,len(a)):
        for f in food:
            if f in a[i]:
                continue
            else:
                food.remove(f)
        if len(food) == 0:
            return 0
    return len(food)

print(main())    
#%%

Submission status: Wrong Answer

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

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

print(a.count(n))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
food=[] #appendのために宣言が必要
for i in range(n):
    food.append(list(map(int,input().split())))

tmp = set(food[0][1:])
for i in range(1, n-1):
    tmp = tmp & set(food[i+1][1:])
print(len(tmp))

Submission status: Wrong Answer

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


j = 0
l = 0
for i in range(1,31):
    for n in lis:
        if i in n:
            j += 1
        if n == lis[-1]:
            if j==len(lis):
                l += 1
            j = 0
print(l)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Feb 16 20:59:16 2019

@author: doppe
"""

N, M = map(int, input().split())
likeList = []

for i in range(0, N):
    L = [int(i) for i in input().split()]
    likeListTmp = []
    if (i == 0):
        likeList = L
    else:
        for j in range(1, L[0] + 1):
            if (L[j] in likeList):
                likeListTmp.append(L[j])
        likeList = likeListTmp

print(len(likeList))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
K = [0]*N
A = [[0]*M for i in range(N)]
for i in range(N):
  x = list(map(int, input().split()))
  K[i] = x[0]
  A[i] = x[1:]
l = A[0]
for i in range(1, N):
  j = 0
  max_j = len(l)-1
  j = 0
  while(j != max_j):
    if l[j] not in A[i]:
      del l[j]
      max_j -= 1
      j -= 1
    j += 1
print(len(l))

Submission status: Wrong Answer

Solution code:
import numpy as np

N, M = map(int, input().split())
A = np.full((N, M), False)
for i in range(N):
    K, *a = map(int, input().split())
    for j in a:
        A[i, j-1] = True
print(np.sum(np.prod(A, axis=0)))

Submission status: Wrong Answer

Solution code:
N, M = map(int,input().split())
S = {i for i in range(M)}

for i in range(N):
    L = [int(j) for j in input().split()]
    K = set(L[1::])
    S = S & K

print(len(S))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Feb 16 20:59:16 2019

@author: doppe
"""

N, M = map(int, input().split())
likeList = []

for i in range(0, N):
    L = [int(i) for i in input().split()]
    likeListTmp = []
    if (i == 0):
        likeList = L
    else:
        for j in range(1, L[0] + 1):
            if (L[j] in likeList):
                likeListTmp.append(L[j])
        likeList = likeListTmp

print(likeList)

Submission status: Wrong Answer

Solution code:
n,m=map(int, input().split())  #複数数値入力
list1 = [0] * n

for i in range(n):
    list1[i]=list(map(int, input().split()))  #リスト入力（数値）
    list1[i].pop(0)

ans = 0
print(list1)

for i in range(m):
    check = 0
    for j in range(n):
        if not i+1 in list1[j]:
            check =1
            break
    
    if check == 0:
        ans += 1


print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, raw_input().split())
ma = []
num = 0
for i in range(n):
    x = []
    x = map(int, raw_input().split())
    ma.append(x[1:])
ma = sum(ma,[])
for mb in list(set(ma)):
    print ma.count(mb), mb
    if ma.count(mb) == n:
        num+=1
print(num)

Submission status: Wrong Answer

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

like = []
for i in range(m):
  like.append(0)

for i in range(n):
  for j in range(a[i][0]):
    like[a[i][j] - 1] += 1
    
for i in range(m):
  if like[i] == n:
    cnt += 1
    
print(cnt)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M =map(int,input().split())
search = np.zeros(M+1)
for i in range(N):
    K = list(map(int,input().split()))
    for j in range(1,K[0]+1):
        search[K[j]]+=1
place = np.where(search==N)
print(search)
print(place)
print(len(place[0]))

Submission status: Wrong Answer

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

for i in range(n-1):
  a=list(map(int,input().split()))
  a=a[1:]
  for x in res:
    if x not in a:
      res.remove(x)
print(len(res))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    N, M = map(int, input().split())
    all = list(map(int, input().split()))
    all.pop(0)
    tmp = []
    for _ in range(N - 1):
        tmp.clear()
        tmp = list(map(int, input().split()))
        tmp.pop(0)
        for i in all:
            if i not in tmp:
                all.remove(i)
    print(len(all))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
def li(): return map(int, stdin.readline().split())

N, M = tuple(li())
common = set(range(M))
for _ in range(N):
    answer = tuple(li())
    favs = set(answer[1:])
    common = common.intersection(favs)
print(len(common))

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

n, m = map(int, input().split())
X = []
A = []
inter = range(m)
for i in range(n):
    X = list(map(int, input().split()))
    A = X[1:]
    inter = list(set(inter) & set(A))

print(len(inter))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
K = []
A = []
for n in range(N):
    INPUT = list(map(int, input().split()))
    K.append(INPUT[0])
    A.append(INPUT[1:])
intersection=set(A[0])
print(A)
for a in A:
    intersection=intersection&set(a)
print(len(intersection))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans_list = list(map(int, input().split()))[1:]
for _ in range(1, n):
    a = list(map(int, input().split()))[1:]
    for ans in ans_list:
        if ans not in a:
            ans_list.remove(ans)

print(len(ans_list))

Submission status: Wrong Answer

Solution code:
def main():
    N, M = map(int, input().split())
    all = list(map(int, input().split()))
    all.pop(0)
    for _ in range(N - 1):
        tmp = list(map(int, input().split()))
        tmp.pop(0)
        for i in all:
            if i not in tmp:
                all.remove(i)
    print(len(all))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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

ans_list=[i for i in range(M)]

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

print(len(ans_list))

Submission status: Wrong Answer

Solution code:
n,m  = list(map(int, input().split()))
k = list(list(map(int, input().split())) for _ in range(n))
c = 0
f = 0
for i in range(m):
    for j in range(n):
        if not i in k[j][1:]:
            f == 1

    if f == 0:
        c += 1

print(c)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [int(input_raw[0]), int(input_raw[1])]
    dic = {}
    for m in range(1, M + 1):
        dic[m] = 0

    for i in range(N):
        input_raw = read_func().strip().split()
        K = int(input_raw[0])
        for j in range(K):
            dic[int(input_raw[j])] += 1

    count = 0
    for m in dic:
        if dic[m] == N:
            count += 1
    print count


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,m  = list(map(int, input().split()))
k = list(list(map(int, input().split())) for _ in range(n))
c = 0
f = 0
for i in range(m):
    for j in range(n):
        if not i in k[j]:
            f == 1

    if f == 0:
        c += 1

print(c)

Submission status: Wrong Answer

Solution code:
import sys

def main():
  input = sys.stdin.readline
  N, M = map(int, input().split())
  A = set(list(range(1, N+1)))
  for _ in range(N):
    B = set(list(map(int, input().split()))[1:])
    A = A & B
  print(len(A))


if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

for i in range(N):
    x = list(map(int, input().split()))
    for j in x[1:]:
        food[j-1] = False

print(food.count(True))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

allset = set()
for i in range(n):
    l_raw = input().split()
    l_new = l_raw[1:]
    if i != 0:
        allset = allset ^ set(l_new)
    else:
        allset = set(l_new)

print(len(allset))

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [int(input_raw[0]), int(input_raw[1])]
    dic = {}
    for m in range(1, M + 1):
        dic[m] = 0

    for i in range(N):
        input_raw = read_func().strip().split()
        K = int(input_raw[0])
        for i in range(K):
            dic[int(input_raw[i])] += 1

    count = 0
    for m in dic:
        if dic[m] == N:
            count += 1
    print count


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
n, m = list(map(int, input().split()))
se = set(range(1, m + 1))
for _ in range(n):
    x = set(map(int, input().split()))
    se -= x

print(len(se))

Submission status: Wrong Answer

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

allset = set()
for i in range(n):
    l_raw = input().split()
    l_new = l_raw[1:]
    allset = allset ^ set(l_new)

print(len(allset))