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:
N, food = map(int, input().split())
S = set(range(1,food+1))
for i in range(N):
  k, *a = input().split()
  S &= set(a)
print(len(S))

Submission status: Wrong Answer

Solution code:
N, food = input().split()
like_food = [input().split()[1:] for s in range(int(N))]
like_food =sum(like_food, [])
set_food = set(like_food)
print(len(set_food))

Submission status: Wrong Answer

Solution code:
import sys
n, m = map(int, input().split())
likes = [list(map(int, input().split())) for _ in range(n)]
if n == 1:
    print(len(likes[0]) - 1)
    sys.exit(0)
common = set(likes[0][1:]) & set(likes[1][1:])
for i in range(2, len(likes)):
    common = common & set(likes[i][1:])
print(common)
print(len(common))

Submission status: Wrong Answer

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

def main():
    cnts = [0]*M
    ans = 0

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

    for cnt in cnts:
        if cnt == N:
            ans += 1
    return ans


if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

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

ans = []
for i in range(m):
    ans.append(i+1)

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

print(len(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
###B - Foods Loved by Everyone
N, M = map(int, input().split())
kaito = []
for i in range(N):
    kaito.append([int(i) for i in input().split()])

print(kaito)
cnt = 0
for i in range(1, M+1):
    jlist = []
    for j in range(N):
        print(i,j)
        if i in kaito[j][1:]:
            jlist.append(True)
        else:
            jlist.append(False)
    if all(jlist):
        cnt += 1
    print(jlist)
print(cnt)

Submission status: Wrong Answer

Solution code:
###B - Foods Loved by Everyone
N, M = map(int, input().split())
kaito = []
for i in range(N):
    kaito.append(list(map(int, input().split())))

cnt = 0
for i in range(1, M+1):
    jlist = []
    for j in range(N):
        if i in kaito[j]:
            jlist.append(True)
        else:
            jlist.append(False)
    if all(jlist):
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
a =[list(map(int, input().split())) for i in range(N)]
#print(a)
list_ = set([i for i in range(M)])

for j in range(N):
    list_ &= set(a[j][1:])
    #print(list_)

if len(list_) !=0:
    print(len(list_))
else:
    print(0)

Submission status: Wrong Answer

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

k = []
list = [0] * m
for i in range(n):
  line = [int(item) for item in input().split()]
  for item in range(m):
    if item in line[1:]:
      list[item] += 1

num = 0
for item in list:
  if item == n:
    num+=1

print(num)

Submission status: Wrong Answer

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

N, M = [int(x) for x in input().split()]
ls =[]
for _ in range(N):
    foodlist = [int(x) for x in input().split()]
    ls += foodlist

answer = 0
for M  in range(M):
    if ls[1:].count(M +1) == N:
        answer += 1

print (answer)

Submission status: Wrong Answer

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

N, M = [int(x) for x in input().split()]
ls =[]
for _ in range(N):
    foodlist = [int(x) for x in input().split()]
    ls += foodlist

answer = 0
for M  in range(M):
    ls[1:].count(M +1)
    if M +1 == N:
        answer += 1

print (answer)

Submission status: Wrong Answer

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

N, M = [int(x) for x in input().split()]
ls =[]
for _ in range(N):
    foodlist = [int(x) for x in input().split()]
    ls += foodlist

answer = 0
for M  in range(M):
    ls.count(M +1)
    if M +1 == N:
        answer += 1

print (answer)

Submission status: Wrong Answer

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

B=[0]*(M+1)

for i in range(0,N):
  A=list(map(int,input().split(" ")))
  #print(A)
  for j in range (0,A[0]):
    jj=A[j]
    B[jj]+=1
    
#print (B)
print (B.count(N))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M = list(map(int,"1 30".split()))

ref = [i+1 for i in range(M)]
LIKE = [i+1 for i in range(M)]

for i in range(N):
    myLIKE = list(map(int,"3 5 10 30".split()[1:]))
    for j in ref:
        if j not in myLIKE:
            LIKE.remove(j)
print(len(LIKE))

Submission status: Wrong Answer

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

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

for i in range(N):
    myLIKE = list(map(int,input().split()[1:]))
    for j in LIKE:
        if j not in myLIKE:
            LIKE.remove(j)
print(len(LIKE))

Submission status: Wrong Answer

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

# listのINNER JOINを繰り返して、最後にlistの要素数を返す
list_1st = input().split()[1:]
      

for i in range(N-1):
  list_tmp = input()[1:]
  # list_1st = list(set(list_1st) & set(list_tmp))
  list_1st = [x for x in list_1st if x in list_tmp]

if N == 1:
  print(len(list_1st))
else:
  l_output = [i for i in list_1st if i != ' ']
  print(len(l_output))

Submission status: Wrong Answer

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

result = [0]*M

for i in range(N):
  foods = map(int, raw_input().split())
  pers_count = foods.pop(0)
  
  for f in foods:
    result[f-1] += 1

res_count = 0
for r in result:
  if M == r:
    res_count += 1

print res_count

Submission status: Wrong Answer

Solution code:
import numpy as np

N, M = list(map(int, input().split(' ')))
mat = np.zeros((N, M))
for i in range(N):
  lines = list(map(int, input().split(' ')))
  for j in range(lines[0]):
    mat[i, lines[j] - 1] += 1

mat_common = np.min(mat, axis=0)
result = np.sum(mat_common)
print(int(result))

Submission status: Wrong Answer

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

count = 0
for i in range(1,M+1):
  for list in list_list:
    if i in list:
      continue
    else:
      break
  count += 1

  
print(count)

Submission status: Wrong Answer

Solution code:
l = [int(i) for i in input().split()]
apd = []
cmp = list(range(1, l[1]+1))
ans = []
for i in range(l[0]):
    m = [int(j) for j in input().split()]
    m.pop(0)
    apd = apd+m
apd = sorted(list(set(apd)))
for i in cmp:
    if (i not in apd)==True:
        ans.append(i)
print(len(ans))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
m = 0
for i in range(M):
    m += 2**i
for n in range(N):
    k = list(map(int, input().split()))
    k_n = k[0]
    _m = 0
    for i in range(k_n):
        _m ^= 2**(k[i+1]-1)
    m &= _m
    print(bin(m))
ret = bin(m).count("1")
print(ret)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
m = 0
for i in range(M):
    m += 2**i
for n in range(N):
    k = list(map(int, input().split()))
    k_n = k[0]
    _m = 0
    for i in range(k_n):
        _m ^= 2**k[i+1]
    m &= _m
ret = bin(m).count("1")
print(ret)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
m = 0
for i in range(M):
    m += 2**i
for n in range(N):
    k = list(map(int, input().split()))
    k_n = k[0]
    for i in range(k_n):
        m &= 2**k[i+1]
ret = bin(m).count("1")
print(ret)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
c=set(list(range(1,m+1)))#from 1 to m+1 set {}
#print(c)
for i in range(n):
    l=list(map(int,input().split()))
    a=l[1:]
    #l[0] no mean
    c=c & set(a) # and > & 
    print(c)
print(len(c))

Submission status: Wrong Answer

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

if not(n == 1):
    count = 0
    for i in range(1, m):
        check = True
        for j in range(n):
            if not (str(i) in favFood[j]):
                check = False
        if check:
            count += 1
    print(count)

else:
    print(len(favFood[0]))

Submission status: Wrong Answer

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

if not(n == 1):
    count = 0
    for i in range(1, m):
        check = True
        for j in range(n):
            if not (str(i) in favFood[j]):
                check = False
        if check:
            count += 1
    print(count)

else:
    print(len(favFood))

Submission status: Wrong Answer

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

if not(n == 0):
    count = 0
    for i in range(1, m):
        check = True
        for j in range(n):
            if not (str(i) in favFood[j]):
                check = False
        if check:
            count += 1
    print(count)
    
else:
    print(len(favFood))

Submission status: Wrong Answer

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

for i in range(1, m):
    check = True
    for j in range(n):
        if not (str(i) in favFood[j]):
            check = False
    if check:
        count += 1

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

from collections import defaultdict
fav = defaultdict(int)
for i in range(N):
    KA = list(map(int, input().split()))
    for i in range(1, KA[0]+1):
        fav[str(KA[i])] += 1

for i in sorted(fav.keys()):
    if fav[i] == N:
        print(i)

Submission status: Wrong Answer

Solution code:
import sys

(sn, sm) = sys.stdin.readline().split()
n = int(sn)
m = int(sm)

flg = [0 for j in range(m)]
for i in range(n):
  sa = sys.stdin.readline().split()
  for saj in sa:
    aj = int(saj)
    flg[aj - 1] += 1

suma = 0
for sumaj in flg:
  if sumaj == n:
    suma += 1
print(suma)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

L = defaultdict(int)
for i in range(N):
	KA = sorted(list(map(int, input().split())))
	for j in range(KA[0]):
		L[KA[1 + j]] += 1

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

print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N,M=map(int,input().split())
A=np.zeros((N+1,M+1))
A[0]=np.ones(M+1)
for i in range(1,N+1):
    B=list(map(int,input().split()))
    for m in range(1,B[0]+1):
        A[i][B[m]]=A[i-1][B[m]]
a=sum(A[N])
print(a)

Submission status: Wrong Answer

Solution code:
# ｎとｍの取得
data = input().split()
n = int(data[0]) #n == 人数
m = int(data[1]) #m == 数字の種類
ans = 0
#ｎ回データを取得してカウント

j = 1 #j == 好きな数字
i = 1 #i == 行数カウンタ
c = [0] * (m + 1)#c == ある数が含まれているかのカウンタ　0で初期化
    #データの取得

while i <= n:
    tmp = [int(s) for s in input().split()]
    td = tmp[1:] #td == 好きな番号
    tn = tmp[0]  #tn == 好きな番号の数
    print(td)
    # 数字が含まれているかの比較
    while j <= m: # jがすべての数字について実行
        
        if j in td: # jがｔｄに含まれるかの分岐
            j = int(j) #　ｊを数値に戻す
            print(j)
            c[j] += 1 # ｃのｊ番目の要素にカウント
        j = int(j) #if ではじかれたとき用にｊを数値に戻す
        j += 1# ｊをカウント
    j = 1    
    i += 1 # iをカウント

# 全てに含まれている数字の集計

for x in c:
    if x == n:
        ans += 1



print(ans)

Submission status: Wrong Answer

Solution code:
# ｎとｍの取得
data = input().split()
n = int(data[0]) #n == 人数
m = int(data[1]) #m == 数字の種類
ans = 0
#ｎ回データを取得してカウント

j = 1 #j == 好きな数字
i = 1 #i == 行数カウンタ
c = [0] * (m  *2)#c == ある数が含まれているかのカウンタ　0で初期化
    #データの取得

while i <= n:
    tmp = input()
    td = tmp[1:] #td == 好きな番号
    tn = tmp[0]  #tn == 好きな番号の数
    
    # 数字が含まれているかの比較
    while j <= m: # jがすべての数字について実行
        j = str(j)# jを文字列に変換
        if j in td: # jがｔｄに含まれるかの分岐
            j = int(j) #　ｊを数値に戻す
            c[j] += 1 # ｃのｊ番目の要素にカウント
        j = int(j) #if ではじかれたとき用にｊを数値に戻す
        j += 1# ｊをカウント
    j = 1    
    i += 1 # iをカウント

# 全てに含まれている数字の集計

for x in c:
    if x == n:
        ans += 1



print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    n, m = [int(x) for x in input().strip().split(' ')]
    hyp = set()
    for i in range(n):
        line = [int(x) for x in input().strip().split(' ')]
        k = line[0]
        hyp2 = set()
        for j in range(1, k):
            hyp2.add(line[j])
        if len(hyp) == 0:
            hyp = hyp2
        else:
            hyp.intersection(hyp2)
    print(len(hyp))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

tmp=[0]*(M+1)
for i in range(N):
	for j in range(1,KA[i][0]+1):
		tmp[KA[i][j]]+=1
print(tmp)
ans=0
for i in range(M+1):
	if tmp[i]==N:
		ans+=1
print(ans)

Submission status: Wrong Answer

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

tmp=[0]*(M+1)
for i in range(N):
	for j in range(1,KA[i][0]+1):
		tmp[KA[i][j]]+=1
# print(tmp)
ans=0
for i in range(M):
	if tmp[i]==N:
		ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
N, M = (int(i) for i in input().split())
hoge = {i + 1 for i  in range(M)}
print(hoge)
for i in range(N):
    likes = set()
    on = input().split()
    on.pop(0)
    likes = {int(j) for j in on}
    print(likes)
    hoge &= likes
    print("result")
    print(hoge)

c = len(hoge)

print(c)

Submission status: Wrong Answer

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

for i in range(n):
    popped_item1=listA[i].pop(0)
    
listB=[]
for i in listA:
    for j in i:
        listB.append(j)

cnt=0
for i in range(n+1):
    if listB.count(i)==n:
        cnt+=1
print(cnt)

Submission status: Wrong Answer

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

tmp=[0]*(M+1)
for i in range(N):
	for j in range(1,KA[i][0]+1):
		tmp[KA[i][j]]+=1
print(tmp)
ans=0
for i in range(M):
	if tmp[i]==N:
		ans+=1
print(ans)

Submission status: Wrong Answer

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

tmp=[0]*(M+1)
for i in range(N):
	for j in range(1,KA[i][0]):
		tmp[KA[i][j]]+=1
# print(tmp)
ans=0
for i in range(M):
	if tmp[i]==N:
		ans+=1
print(ans)

Submission status: Wrong Answer

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

tmp=[0]*(M+1)
for i in range(N):
	for j in range(KA[i][0]):
		tmp[KA[i][j]]+=1
# print(tmp)
ans=0
for i in range(M):
	if tmp[i]==N:
		ans+=1
print(ans)

Submission status: Wrong Answer

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

s=[]
for t in e:
  b_list=0
  for x in t[1:]:
    b_list = b_list | pow(2,x-1)
  s.append(b_list)
result=pow(2,30)-1
for i in s:
   result = result & i
cnt=0
for i in range(30):
  if result & pow(2,i):
    cnt+=1

Submission status: Wrong Answer

Solution code:
import sys
num = sys.stdin.readline().split()
d = {}
for line in sys.stdin.readlines():
  n = line.split()
  n.pop(0)
  for s in n:
    if s in d :
      d[s] = d[s]+1
    else :
      d[s] = 1
print d
keys = [k for k, v in d.items() if v == int(num[0])]
print(len(keys))

Submission status: Wrong Answer

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

for n in range(N):
    K_n_list = list(map(int, input().split()))
    del K_n_list[0]
    all_dish = [K_n_list_num for K_n_list_num in K_n_list]

#    for K_n_list_num in K_n_list:
#        all_dish.append(K_n_list_num)

prefer_dish = []
dish_kind = list(set(all_dish))
prefer_dish = [dish_kind_num for dish_kind_num in dish_kind if all_dish.count(dish_kind_num) == N]

print(len(prefer_dish))

Submission status: Wrong Answer

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

for n in range(N):
    K_n_list = list(map(int, input().split()))
    del K_n_list[0]
    all_dish = [K_n_list_num for K_n_list_num in K_n_list]

#   for K_n_list_num in K_n_list:
#       all_dish.append(K_n_list_num)

prefer_dish = []
dish_kind = list(set(all_dish))
#prefer_dish = [dish_kind_num for dish_kind_num in dish_kind if all_dish.count(dish_kind_num) == N]
for dish_kind_num in dish_kind:
    if all_dish.count(dish_kind_num) == N:
        prefer_dish.append(dish_kind_num)

print(len(prefer_dish))

Submission status: Wrong Answer

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

for n in range(N):
    K_n_list = list(map(int, input().split()))
    del K_n_list[0]
    all_dish = [K_n_list_num for K_n_list_num in K_n_list]

prefer_dish = []
dish_kind = list(set(all_dish))
prefer_dish = [dish_kind_num for dish_kind_num in dish_kind if all_dish.count(dish_kind_num) == N]

print(len(prefer_dish))

Submission status: Wrong Answer

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

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

for n in range(N):
    K_n_list = list(map(int, input().split()))
    del K_n_list[0]
    for dish_list_num in dish_list:
        if dish_list_num not in K_n_list:
            dish_list.remove(dish_list_num)

print(len(dish_list))

Submission status: Wrong Answer

Solution code:
x1 = input().split()
N = int(x1[0])
M = int(x1[1])
S = []
A = []
K = []
F = []
for i in range(M):
    S.append(0)
for i in range(N):
    K.append(0)
for i in range(N):
    A.append(input().split())
    K[i] = int(A[i][0])
    for j in range(K[i]):
        F.append(int(A[i][j]))
    for j in F:
        S[j-1] += 1
ans = 0
for i in range(M):
    if S[i] == N:
        ans += 1
print(ans)

Submission status: Wrong Answer

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

pre_res = [0 for i in range(m)]

for i in range(n):
    sel = [int(i)-1 for i in input().split(" ")][1:]
    for s in sel:
        pre_res[s] += 1

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

print(res)

Submission status: Wrong Answer

Solution code:
import numpy as np

i = [int(each) for each in input().split()]

n = i[0]
m = i[1]

l2 = np.zeros(m)

for i in range(n):
    for j, each in enumerate([int(each) - 1 for each in input().split()]):
        if j != 1:
            l2[each] += 1
    # print(l)

count = 0
for each in l2:
    if each == n:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import numpy as np

i = [int(each) for each in input().split()]

n = i[0]
m = i[1]

l = np.zeros(m)

for i in range(n):
    for i, each in enumerate([int(each) - 1 for each in input().split()]):
        if i != 1:
            l[each] += 1
    # print(l)

count = 0
for each in l:
    if each == n:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
# 2019/02/09
# AtCoder Beginner Contest 118 - B

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

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

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

# Output
print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
data = ""
for i in range(N):
    a = input()
    data += a[1:]
result = 0
for i in range(1, M+1):
    if data.count(str(i))==N:
        result += 1
print(result)

Submission status: Wrong Answer

Solution code:
#coding: utf-8

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

List = []
all_and = []
for i in range(N):
    l = list(map(int, input().split()))
    print(l)
    del l[0]
    print(l)
    List.append(l)
    print(List[i])
    print(List)

    if i ==0:
        all_and = List[0]
    else:
        all_and = set(all_and) & set(List[i])
        all_and = list(all_and)
    print(all_and)
    print()

#print(all_and)
print(len(all_and))

Submission status: Wrong Answer

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

if N == 1:
    print(len(A))
    quit()
else:
    res = list(set(A[0]) & set(A[1]))
    for a, v in enumerate(A):
        res = list(set(res) & set(v))
    print(len(res))

Submission status: Wrong Answer

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

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

c = 0
for i in range(1, m+1):
    g = True
    for j in range(n):
        if i in l[j][0:]:
            g = False
    if g:
        c = c + 1

print(c)

Submission status: Wrong Answer

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

for _ in range(N):
  hypo.append([int(s) for s in input().split(' ')])

like_counts = [0] * M
for h in hypo:
  h_ = list(set(h))
  for i in h_:
    like_counts[i - 1] += 1

counts = 0
for i in like_counts:
  if i == N:
    counts += 1
print(counts)

Submission status: Wrong Answer

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


seki = a[0]
for i in range(N-1):
    seki = seki & a[i+1]
    
print(len(seki))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
s = set(str(i) for i in range(m))
for _ in range(n):
  s = s & set(input().split())
print(len(s))

Submission status: Wrong Answer

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

c = []
d = []
for i in range(n):
    a = [int(x) for x in input().split(" ")]
    if i == 0:
        c = a[- a[0] + 1:]
    else:
        b = a[- a[0] + 1:]
        for ce in c:
            if ce in b:
                 d.append(ce)
        c = d
        d = []

print(len(c))

Submission status: Wrong Answer

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

c = []
d = []
for i in range(n):
    a = [int(x) for x in input().split(" ")]
    if i == 0:
        c = a[- a[0] + 1:]
    else:
        b = a[- a[0]:]
        for ce in c:
            if ce in b:
                 d.append(ce)
        c = d
        d = []

print(len(c))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
check = [1] * M
for i in range(N):
    a = [int(i) for i in input().split()]
    a = a[1:]
    for i in a:
        check[i-1] = 0

print(sum(check))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

listA = [list(map(int, input().split())) for j in range(n)]

ans = 0


for a in range(1, m):
    ok = True
    for i in range(n):
        if a not in listA[i][1:]:
            ok = False
    if ok:
        ans += 1



print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
k = 0
alist = []
while k < n :
  a = list(map(int,input().split()))
  alist.append(a)
  k += 1
#
for blist in alist :
  b = blist[0]
  blist.remove(b)
#
anslist = []
ans = 0
i_roop = len(alist[0])
while i_roop >= 0 :
  if i_roop == 0 :
    break
  else:
    c = min(alist[0])
    for j in range(1,n) :
      if c in alist[j] :
        anslist.append("OK")
        if j == n-1 :
          if len(anslist) == n-1 :
            ans += 1
      else:
        if j == n-1 :
          if len(anslist) == n-1 :
            ans += 1
        break
    alist[0].remove(c)
  anslist = []
  i_roop += -1

print(ans)

Submission status: Wrong Answer

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

like = []
cnt = 0

for i in range(N):
	like.append([int(x) for x in input().split()][1:])

for j in range(M):
	if all([j in x for x in like]):
		cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
N, M = map(int,input().split())
ans = list(range(M))
for j in range(N):
  k = list(map(int,input().split()))
  del k[0]
  ans += k
  ans_2 = [a for a in set(ans) if ans.count(a) > N]
if N == 1:
  print(len(k))
else:
  print(len(ans_2))

Submission status: Wrong Answer

Solution code:
N, M = map(int,input().split())
ans = list(range(M))
for j in range(N):
  k = list(map(int,input().split()))
  del k[0]
  print(k)
  ans += k
  ans_2 = [a for a in set(ans) if ans.count(a) > N]
if N == 1:
  print(len(k))
else:
  print(len(ans_2))

Submission status: Wrong Answer

Solution code:
#A
"""
a,b = map(int, input().split())
if b % a == 0:
    print(b + a)
else:
    print(b-a)
"""

#B

n, m = map(int, input().split())
ans = list(map(int, input().split()))
del ans[0]
for i in range(n-1):
    a = list(map(int, input().split()))
    del a[0]
    if len(a) != 0:
        for k in ans:
            if k in a:
                continue
            else:
                ans.remove(k)
        if len(ans) == 0:
            break
print(len(ans))


#C
"""
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

n = int(input())
a = list(map(int, input().split()))
print(gcd_list(a))
"""

Submission status: Wrong Answer

Solution code:
#A
"""
a,b = map(int, input().split())
if b % a == 0:
    print(b + a)
else:
    print(b-a)
"""

#B

n, m = map(int, input().split())
ans = list(map(int, input().split()))
del ans[0]
for i in range(n-1):
    a = list(map(int, input().split()))
    del a[0]
    for k in ans:
        if k in a:
            continue
        else:
            ans.remove(k)
    if len(ans) == 0:
        break
print(len(ans))


#C
"""
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

n = int(input())
a = list(map(int, input().split()))
print(gcd_list(a))
"""

Submission status: Wrong Answer

Solution code:
#A
"""
a,b = map(int, input().split())
if b % a == 0:
    print(b + a)
else:
    print(b-a)
"""

#B

n, m = map(int, input().split())
ans = input().split()
del ans[0]
for i in range(n-1):
    a = input().split()
    del a[0]
    for k in ans:
        if k in a:
            continue
        else:
            ans.remove(k)
    if len(ans) == 0:
        break
print(len(ans))

#C
"""
import math
n = int(input())
a = list(map(int, input().split()))
x = a[0]
for i in range(n):
    x = math.gcd(x, a[i])
print(x) 
"""

Submission status: Wrong Answer

Solution code:
#A
"""
a,b = map(int, input().split())
if b % a == 0:
    print(b + a)
else:
    print(b-a)
"""

#B
n, m = map(int, input().split())
ans = input().split()
del ans[0]
for i in range(n-1):
    a = input().split()
    del a[0]
    for k in ans:
        if k in a:
            continue
        else:
            ans.remove(k)
print(len(ans))

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    n, m = map(int, raw_input().split(" "))
    answers = []

    answer = set(raw_input().split(" ")[1:])
    for x in range(n-1):
        answer = answer.intersection(raw_input().split(" ")[1:])

    if answer:
        print(int(answer.pop()))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    n, m = map(int, raw_input().split(" "))
    answers = []

    answer = set(raw_input().split(" ")[1:])
    for x in range(n-1):
        answer.intersection(raw_input().split(" ")[1:])

    if answer:
        print(int(answer.pop()))
    else:
        print(0)

Submission status: Wrong Answer

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

A_list[0].pop(0)
a = A_list[0]
for i in range(1, N):
  A_list[i].pop(0)
  a = set(a) & set(A_list[i])

if len(a)==0:
  print(0)
else:
  print(a)

Submission status: Wrong Answer

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

a = A_list[0]
for i in range(1, N):
  a = set(a) & set(A_list[i])

if len(a)==0:
  print(0)
else:
  print(a)

Submission status: Wrong Answer

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