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: Runtime Error

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

like = [0]*m
for i in range(n):
    for j in range(1,ka[i][0]+1):
        like[ka[i][j]] += 1

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

print(answer)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,M = list(map(int,input().split()))
lst = list(map(int,input().split()))
for i in range(N-1):
    k = list(map(int,input().split()))
    for j in k[1:]:
        if j in lst:
            continue
        else:
            lst.remove(j)
print(len(lst))

Submission status: Runtime Error

Solution code:
Tmp = []
Tmp = input().rstrip().split(' ')

nN = int(Tmp[0])
nM = int(Tmp[1])

nF = [ 0 for i in range(nM)]

for i in range(nN):
  Tmp = input().rstrip().split(' ')
  nTmpN = int(Tmp[0])
  for j in range(nTmpN):
    nCnt = int(Tmp[j+1])
    nF[nCnt] += 1

nAns = 0
for i in range(nM):
  nTmpN = nF[i]
  if nTmpN == nN:
    nAns += 1

print(nAns)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

all_like=0
for _ in cnt:
    if _ == n:
        all_like += 1

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
erase = {}
for i in range(N):
    a = list(map(int, input().split()))
    
    if i == 0:
        food = a[1:]
    else:
        for j in range(len(food)): 
            if food[j] not in a[1:]:
                erase.add(food[j])
print(len(food)-len(erase))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
erase = {}
for i in range(N):
    a = list(map(int, input().split())) #a = [2,1,3] -> a = [3,1,2,3]
    
    if i == 0:
        food = a[1:] #food = [1] -> food = [1,3]
    else:
        for j in range(len(food)): 
            if food[j] not in a[1:]:
                erase.add(food[j])
print(len(food)-len(erase))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
erase = {}
for i in range(N):
    a = list(map(int, input().split())) #a = [2,1,3] -> a = [3,1,2,3]
    
    if i == 0:
        food = a[1:] #food = [1] -> food = [1,3]
    else:
        for j in range(len(food)): 
            if food[j] not in a[1:]:
                erase.add(j)
print(len(food)-len(erase))

Submission status: Runtime Error

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

a_non = []
for i in range(1, len(a_k)):
    if len(a_k[0]) <= 1:
        break

    for j in range(1, len(a_k[0])):
        if a_k[0][j] not in a_k[i][1:]:
            a_non.append(j)

for j in range(len(a_non)):
    a_k[0].pop(a_non[j])


print(len(a_k[0]) - 1)

Submission status: Runtime Error

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

for i in range(1, len(a_k)):
    a_non = []
    if len(a_k[0]) <= 1:
        break

    for j in range(1, len(a_k[0])):
        if a_k[0][j] not in a_k[i][1:]:
            a_non.append(j)

    for j in range(len(a_non)):
        a_k[0].pop(a_non[j])


print(len(a_k[0]) - 1)

Submission status: Runtime Error

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

for i in range(1, len(a_k)):
    a_non = []

    for j in range(1, len(a_k[0])):
        if a_k[0][j] not in a_k[i][1:]:
            a_non.append(j)

    for j in range(len(a_non)):
        a_k[0].pop(a_non[j])
    if len(a_k[0]) <= 1:
        break


print(len(a_k[0]) - 1)

Submission status: Runtime Error

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

for i in range(1, len(a_k)):
    a_non = []

    for j in range(1, len(a_k[0])):
        if a_k[0][j] not in a_k[i][1:]:
            a_non.append(j)

    for j in range(len(a_non)):
        a_k[0].pop(a_non[j])
        if len(a_k[0]) <= 1:
            break


print(len(a_k[0]) - 1)

Submission status: Runtime Error

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

for i in range(1, len(a_k)):
    a_non = []

    for j in range(1, len(a_k[0])):
        if a_k[0][j] not in a_k[i][1:]:
            a_non.append(j)

    for j in range(len(a_non)):
        a_k[0].pop(a_non[j])


print(len(a_k[0]) - 1)

Submission status: Runtime Error

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

na3 = []

for i4 in range(n1):
    na3.append([int(j) for j in input().split()])

na5 = [0] * n2

for i6 in range(n1):
    for i7 in range(na3[i6][0] + 1):
        if i7 != 0:
            na5[na3[i6][i7 - 1]] += 1
            
r8 = 0
for i9 in range(n2):
    if na5[i9] == n1:
        r8 += 1

print(r8)

Submission status: Runtime Error

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

Submission status: Runtime Error

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


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

print(len(intersect_set(hyou)))

Submission status: Runtime Error

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

C = [0]*M

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

print(C.count(N))

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// #define int long long

typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

signed main() {
    int N, M;
    cin >> N >> M;

    vi cnt(M, 0);
    REP(i, N) {
        int K; cin >> K;
        REP(j, K) {
            int A; cin >> A; --A;
            cnt[A]++;
        }
    }

    int ans = 0;
    REP(i, M) if (cnt[i] == N) ans++;
    cout << ans << endl;
    return 0;
}

Submission status: Runtime Error

Solution code:
n=int(input())
s=[int(input()) for i in range(n)]
 
print(sum(s)-max(s)//2)

Submission status: Runtime Error

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

print(cnt.count(N))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
fav = [0]*M
for n in range(N):
    KA = list(map(int, input().split()))
    for i in range(len(KA)-1):
        fav[KA[i+1]] += 1

counter = 0
for f in fav:
    if f == N:
        counter += 1
    
print(counter)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

print(ans.count(n))

Submission status: Runtime Error

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

for i in range(n):
	k,*p = map(int, open(0).read().split())
	for j in range(k):
		l[p[j]-1] += 1
ans = 0
for i in range(m):
	if l[i] == n:
		ans += 1
print(ans)

Submission status: Runtime Error

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

for i in range(n):
	k,*p = map(int, open(0).read().split())
	for j in range(k):
		l[p[j]-1] += 1
ans = 0
for i in range(m):
	if l[i] == n:
		ans += 1
print ans

Submission status: Runtime Error

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

for i in range(n):
	k,*p = map(int, open(0).read().split())
	for j in range(k):
		l[p[j]-1] += 1
ans = 0
for i in range(m):
	if l[i] == 0:
		ans += 1
print ans

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
like_set = {}
for i in range(1, M+1):
    like_set.add(i)
for i in range(N):
    like = input().split()
    like = set(like[1:])
    like_set = like_set & like
print(len(like_set))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
like_set = {}
for i in range(1,M+1):
    like_set = like_set | {i}
for i in range(N):
    k_a = input().split()
    a = k_a[1:]
    like_set = set(a) & like_set
print(len(like_set))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

like = [0] * M

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

print(cnt)

Submission status: Runtime Error

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

items = set(KA[1:])


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

ans = len(items)
print(ans)

Submission status: Runtime Error

Solution code:
data = []
for i in range(N):
    data.append(list(map(int, input().split())))
#print(data)
counter1 = 0
counter2 = 0
for i in range(1, M + 1):
    for ans in data:
        num = ans[0]
        #print(ans[1 : num + 1])
        if i in ans[1 : num + 1]:
            counter1 += 1
        else:
            counter1 = 0
            break
    if counter1 == N:
        print(i)
        counter2 += 1
print(counter2)

Submission status: Runtime Error

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

print(ans)

Submission status: Runtime Error

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

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
l = [int(i) for i in input().split()]
if 2 * max(l) - sum(l) < 0:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
n = int(input())
l = [int(i) for i in input().split()]
if 2 * l[n-1] - sum(l) <= 0:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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

like = list(map(int, input().split()))
all_like = set()
for l in like:
	all_like.add(l)
    
for i in range(N-1):
  like = list(map(int, input().split()))
  for l in like:
    if l not in all_like:
      all_like.remove(l);
print(len(all_like))

Submission status: Runtime Error

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

like = list(map(int, input().split()))
all_like = set()
for l in like:
	all_like.add(l)
for i in range(N):
  like = list(map(int, input().split()))
  for l in like:
    if l not in all_like:
      all_like.remove(l);
print(len(all_like))

Submission status: Runtime Error

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

ansLst = ['0'] * M
for i in range(1, len(kLst[0])):
    ansLst[i] = kLst[0][i]
for i in range(N):
    del kLst[i][0]
ansLst = list(set(ansLst))
ansLst.remove('0')

for i in range(1, N):
    for j in ansLst:
        if kLst[i].count(j) == 0:
            ansLst.remove(j)
print(len(ansLst))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for i in range(n):
  f.append(list(map(int, input().split())))

num = [0 for i in range(m+1)]
  
for i in range(n):
  for j in range(1, len(f[i])):
    num[f[i][j]] += 1
    
    
cnt = 0
for i in num:
  if i = n:
    cnt += 1
    
    
print(cnt)

Submission status: Runtime Error

Solution code:
n,m = map(int,input())
sum = {}
ans = 0

for i in range(n):
  k = list(map(int,input().split()))
  for j in range(1,k[0] + 1):
    if k[j] not in sum:
      sum[k[j]] = 1
    else:
      sum[k[j]] += 1
for l in sum:
  if sum[l] == n:
    ans += 1
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split());a=[0]*m
for _ in a:
  _,*o=map(int,input().split())
  for x in o:res[x-1]+=1
print(a.count(n))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

like_count = [0 for _ in range(m+1)]

for _ in range(N):
    tmp = list(map(int,input().split()))
    like_list = tmp[1:]
    for like in like_list:
        like_count[like] += 1

count = 0
for value in like_count:
    if value == N:
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
N, M = map(int, raw_input().split())
menu = []
for i in range(0, M):
	menu.append(0)
for i in range(0, N):
	answer = map(int, raw_input().split())
	for j in range(1, answer[0]+1):
		menu[answer[i]-1] += 1
cnt = 0
for i in range(0, M):
	if menu[i] == N: cnt += 1

print cnt

Submission status: Runtime Error

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

Submission status: Runtime Error

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

ans = input().split()

for i in range(N):
  b = input().split()
  c = set(ans) & set(b)
  ans = list(c)
  
print(len(ans))

Submission status: Runtime Error

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

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

x = [True] * m

for i in a:
    y = i[0]
    xx = [False] * m
    for j in range(y):
        xx[i[j + 1]] = True
    for j in range(m):
        if xx[j] == False:
            x[j] = False

print(sum(x))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

x = [True] * m

for i in a:
    y = i[0]
    xx = [False] * m
    for j in range(y):
        x[i[j + 1]] = True
    for j in range(m):
        if xx[j] == False:
            x[j] = False

print(sum(x))

Submission status: Runtime Error

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

x = [True] * m

for i in a:
    y = i[0]
    xx = [False] * m
    for j in range(y):
        x[i[j + 1]] = True
    for j in range(m):
        if xx[j] == False:
            x[j] = False

print(sum(x))

Submission status: Runtime Error

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

S = set(range(1, m+1))

for i in range(n):
  K, *a = map(int, input().split())
  S = S & set(A)

print(len(S))

Submission status: Runtime Error

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

x = [True] * m

for i in a:
  y = i[0]
  xx = [False] * m
  for j in range(y):
    x[i[j+1]] = True
  for j in range(m):
    if xx[j] = False:
      x[j] = False

print(sum(x))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
L = list()
ans = list()
for i in range(N):
  l = [int(_) for _ in input().split()]
  for j in range(len(l[0])):
    ans.append(l[j+1])
  l = L.copy()
cnt = 0
num = 0
s = -1
ans.sort()
for k in ans:
  if s == k:
    cnt += 1
    if cnt == N:
      num += 1
      cnt = 0
  else:
    cnt = 1
    s = k
print(num)

Submission status: Runtime Error

Solution code:
K = [None]*30
A = [None]*30
Ms = [0]*30
def main():
    N, M = map(int, input().split())
    for i in range(N):
        K[i], *A[i], = map(int, input().split())
    for i in A:
        if i == None:
            break
        for j in i:
            Ms[j] += 1
    print(Ms.count(N))

main()

Submission status: Runtime Error

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

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

print(result.count(N))

Submission status: Runtime Error

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

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

print(result.count(N))

Submission status: Runtime Error

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

for i in range(N):
  K=input().split()
  for k in range(K):
    List[int(k[K])-1]+=1
    
print(List.count(N))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

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

print(count)

Submission status: Runtime Error

Solution code:
N, food = map(int, input().split())
S = set(range(1,food+1))
for i in range(N):
  k, *a = ma(int,input().split())
  S &= set(a)
print(len(S))

Submission status: Runtime Error

Solution code:
N, food = 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: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
ls=set(list(map(int,input().split()))[1:])
unique=ls.copy()
for i in range(n-1):
  A=list(map(int,input().split()))
  for j in ls:
    if j not in A[1:]:
      unique.remove(j)
print(len(unique))

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
a,c=[],[]
for i in range(m):
  c.append(i+1)
i=0
while i<n:
  k,a=input().split()
  for j in range(len(c)):
    if c[j] not in a:#なかったら
      c.remove(c[j])
      j-=1
    j +=1
  a=[]
print(len(c))

Submission status: Runtime Error

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

for i in range(n):
  k,*b = input().split()
  b = [int(j) for j in b]
  for l in b:
    counter[l] +=1
    
print(counter.count(n))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
loved_by_everyone = [0] * M
for _ in range(N):
    like_list = list(map(int, input().split()))
    for like in like_list[1:]:
        loved_by_everyone[like] += 1

kinds = 0
for food in loved_by_everyone:
    kinds += 1 if food == N else 0
print(kinds)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
a=[]
for i in range(N):
  x = input().split()
  z = x[1:]
  a += list(map(int,z))
cnt=0
for k in range(1:M+1):
  n = a.count(k)
  if n==N:
    cnt +=1
  else:
    cnt = cnt
print(cnt)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
a=[]
for i in range(N):
  x = input().split()
  z = x[1:]
  w = list(map(int,z))
  a.append(w)
b = []
for l in range(1:M+1):
  for j in range(N-1):
    if ((l in a[j]) and (l in a[j+1])):
      b.append(l)
cnt=0
for k in range(1:M+1):
  n = b.count(k)
  if n==N-1:
    cnt +=1
print(cnt)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
a=[]
for i in range(N):
  x = input().split()
  y = int(x[0])
  z = x[1:y+1]
  w = list(map(int,z))
  a.append(w)
  
b = []
for l in range(1:M+1):
  for j in range(N-1):
    if ((l in a[j]) and (l in a[j+1])):
      b.append(l)
    else:
      b = b

cnt=0
for k in range(1:M+1):
  n = b.count(k)
  if n==N-1:
    cnt +=1
  else:
    cnt = cnt
print(cnt)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
a=[]
for i in range(N):
  x = input().split()
  y = int(x[0])
  z = x[1:y+1]
  w = list(map(int,z))
  a.append(w)
b = []
for l in range(1:M+1):
  for j in range(N-1):
    if ((l in a[j]) and (l in a[j+1])):
      b.append(l)
    else:
      b = b
cnt=0
for k in range(1:M+1):
  n = b.count(k)
  if n==N-1:
    cnt +=1
  else:
    cnt = cnt
print(cnt)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
a=[]
for i in range(N):
  x = input().split()
  y = int(x[0])
  z = x[1:y+1]
  w = list(map(int,z))
  a.append(w)
b = []
for l in range(1:M+1):
  for j in range(N-1):
    if l in a[j] and l in a[j+1]:
      b.append(l)
    else:
      b = b
cnt=0
for k in range(1:M+1):
  n = b.count(k)
  if n==N-1:
    cnt +=1
  else:
    cnt = cnt
print(cnt)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
a=[]
for i in range(N):
  x = input().split()
  y = int(x[0])
  z = x[1:y+1]
  w = list(map(int,z))
  a.append(w)
b = []
for l in range(1:M+1):
  for j in range(N-1):
    if l in a[j] and l in a[j+1]:
      b.append(l)
    else:
      b = b
cnt=0
for k in range(1:M+1):
  n = b.count(k)
  if n==N-1:
    cnt +=1
print(cnt)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
a=[]
for i in range(N):
  x = input().split()
  y = int(x[0])
  z = x[1:y+1]
  w = list(map(int,z))
  w.append(a)
b = []
for l in range(1:M+1):
  for j in range(N-1):
    if l in a[j] and l in a[j+1]:
      l.append(b)
    else:
      b = b
cnt=0
for k in range(1:M+1):
  n = b.count(k)
  if n==N-1:
    cnt +=1
print(cnt)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
a=[]
for i in range(N):
  x = input().split()
  y = int(x[0])
  z = x[1:y+1]
  w = list(map(int(z)))
  w.append(a)
b = []
for l in range(1:M+1):
  for j in range(N-1):
    if l in a[j] and l in a[j+1]:
      l.append(b)
    else:
      b = b
cnt=0
for k in range(1:M+1):
  n = b.count(k)
  if n==N-1:
    cnt +=1
print(cnt)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
a=[]
for i in range(N):
  x = input().split()
  y = int(x[0])
  z = x[1:y]
  w = list(map(int(z)))
  w.append(a)
b = []
for l in range(1:M+1):
  for j in range(N-1):
    if l in a[j] and l in a[j+1]:
      l.append(b)
    else:
      b = b
cnt=0
k=1
for k in range(M+1):
  n = b.count(k)
  if n==M:
    cnt +=1
print(cnt)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
ans = [0 for i in range(M)]
for i in range(N):
  tmp = list(map(int, input().split()))
  #print(tmp)
  for j in range(tmp[0]): #K
    ans[tmp[j]] += 1

count = 0
for k in ans:
  if k == N:
    count += 1
print(count)

Submission status: Runtime Error

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
print(foodlike.count(n))

Submission status: Runtime Error

Solution code:
N,M = list(map(int,input().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,input().split()[1:]))
    for j in ref:
        if j not in myLIKE:
            LIKE.remove(j)
print(len(LIKE))

Submission status: Runtime Error

Solution code:
tmp = [int(i) for i in raw_input().split()]
list2 = [0]*tmp[1]
list = []
if tmp[0] != 1:
    for i in range(tmp[0]):
        tmp2 = [int(i) for i in raw_input().split()]
        list.append(tmp2)
    
    for i in range(tmp[1]-1):

        for s in range(list[i][0]):
            list2[list[i][s+1]-1] += 1


    tmp3 = 0
    for i in range(tmp[0]):
        if list2[i] == tmp[0]:
            tmp3 += 1

    print(tmp3)
else:
    tmp2 = [int(i) for i in raw_input().split()]
    print(tmp2[0])

Submission status: Runtime Error

Solution code:
tmp = [int(i) for i in raw_input().split()]
list2 = [0]*tmp[1]
list = []
if tmp[0] != 1:
    for i in range(tmp[0]):
        tmp2 = [int(i) for i in raw_input().split()]
        list.append(tmp2)
    print(list)
    for i in range(tmp[1]-1):
        print(i)
        for s in range(list[i][0]):
            list2[list[i][s+1]-1] += 1
        print(i)

    tmp3 = 0
    print(list2)
    print(tmp[0])
    for i in range(tmp[0]):
        if list2[i] == tmp[0]:
            tmp3 += 1

    print(tmp3)
else:
    tmp2 = [int(i) for i in raw_input().split()]
    print(tmp2[0])

Submission status: Runtime Error

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

value = 0
converter = {
    'JPY' : 1,
    'BTC' : 380000
}
for v in vectors:
    x, u = v
    value += float(x) * converter.get(u)

print(value)

Submission status: Runtime Error

Solution code:
from sys import stdin
N, M = [int(x) for x in stdin.readline().rstrip().split()]
l = []
for i in range(N):
    l.append(stdin.readline().rstrip().split())
k = l[0]
for i in range(N):
    k = k&l[i]
print(len(k))

Submission status: Runtime Error

Solution code:
import sys

N,M = map(int,input().split())
member = dict()
for i in range(1,N+1,1):
    ilist = list(map(int,input().split()))
    ilist.pop(0)
    member[i]=set(ilist)

if(N==1):
    print(member(1))
    sys.exit(0)

match_set=member[1]
for i in range(2,N+1,1):#memberに対し、1人ずつ検査していく
    match_set = match_set & member[i]

print(len(match_set))