Problem:


Search I

You are given a sequence of n integers S and a sequence of different q integers T. Write a program which outputs C, the number of integers in T which are also in the set S.

Input

In the first line n is given. In the second line, n integers are given. In the third line q is given. Then, in the fourth line, q integers are given.

Output

Print C in a line.

Constraints

n ≤ 10000

 q ≤ 500 

0 ≤ an element in S ≤ 109

0 ≤ an element in T ≤ 109

Sample Input 1

5
1 2 3 4 5
3
3 4 1

Sample Output 1

3

Sample Input 2

3
3 1 2
1
5

Sample Output 2

0

Sample Input 3

5
1 1 2 2 3
2
1 2

Sample Output 3

2

Notes

Template in C
-->



Sample input:
5
1 2 3 4 5
3
3 4 1


Sample output:
3

Submission status: Accepted

Solution code:
n = int(input())
[*A] = map(int, input().split(' '))
q = int(input())
[*Q] = map(int, input().split(' '))


def search(key):
    i = 0
    A[len(A) - 1] = key
    while A[i] != key:
        i += 1
    if i == len(A) - 1:
        return -1
    return i


A.append(0)
sum = 0
for i in range(q):
    A[len(A) - 1] = Q[i]
    if search(Q[i]) != -1:
        sum += 1
print(sum)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n = int(input())
    S = list(map(int, input().split()))
    q = int(input())
    T = list(map(int, input().split()))

    cnt = 0
    for i in T:
        for j in S:
            if i == j:
                cnt += 1
                break

    print(cnt)

Submission status: Accepted

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

def count(s, t):
    c = 0
    for x in t:
        for y in s:
            if x == y:
                c += 1
                break
    return c

n = int(input())
s = [int(x) for x in input().split()]

q = int(input())
t = [int(x) for x in input().split()]

print(count(s, t))

Submission status: Accepted

Solution code:
n=int(input())
s=[int(i) for i in input().split()]
q=int(input())
t=[int(i) for i in input().split()]

count=0

for i in t:
    if i in s:
        count+=1
        
print(count)

Submission status: Accepted

Solution code:
import sys

f = sys.stdin

n = f.readline().replace('\n','')
S = set(map(int, f.readline().replace('\n','').split()))
q = f.readline().replace('\n','')
T = set(map(int, f.readline().replace('\n','').split()))

print(len(S & T))

Submission status: Accepted

Solution code:
def liner_search(A, n, B, q):
    cnt = 0
    for i in range(q):
        for j in range(n):
            if B[i] == A[j]:
                cnt += 1
                break
    return cnt

n = int(input())
A = list(map(int,input().split()))
q = int(input())
B = list(map(int,input().split()))
print(liner_search(A, n, B, q))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

def search(S, key, n):
    i = 0
    S.append(key)
    while(S[i] != key):
        i += 1
    if(i == n):
        S.pop()
        return 0
    else:
        S.pop()
        return 1
        
        
count = 0
for key in T:
    count += search(S, key, n)
print(count)

Submission status: Accepted

Solution code:
input()
s=set(map(int,input().split(" ")))
input()
t=set(map(int,input().split(" ")))
print(len(s&t))

Submission status: Accepted

Solution code:
num = 0
line1=raw_input()
line2=raw_input()
line3=raw_input()
line4=raw_input()
num1 = 0
num2 = 0

A=line2.split(" ")
B=line4.split(" ")


for b in B:
    num1 = int(b)
    for a in A:
        num2 = int(a)
        if num1 == num2:
            num += 1 
            break
print(num)

Submission status: Accepted

Solution code:
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
# T < S

cnt = 0
for i in T:
    for j in S:
        if i == j:
            cnt += 1
            break

print(cnt)
# LinearSearch: 線形探索
# 線形探索は、配列の先頭から各要素が目的の値と等しいかどうかを順番に調べる。
# 等しいものが見つかった時点でその位置を返し探索を終了する。

Submission status: Accepted

Solution code:
n = int(input())
s = [int(i) for i in input().split()]
q = int(input())
t = [int(i) for i in input().split()]

count = 0
for i in t:
    if i in s:
        count += 1

print(count)

Submission status: Accepted

Solution code:
n=int(input())
s=[]
x=input().strip().split()
for i in range(n):
	s.append(int(x[i]))
q=int(input())
t=[]
y=input().strip().split()
for j in range(q):
	t.append(int(y[j]))
	
if n<q:
	tmp=s
	s=t
	t=tmp
	
count=0

for i in range(len(t)):
	for j in range(len(s)):
		if t[i]==s[j]:
			count+=1
			break

print(count)

Submission status: Accepted

Solution code:
n = int(input())
s = set(list(map(int, input().split())))
q = int(input())
t = set(list(map(int, input().split())))


print(len(t & s))

Submission status: Accepted

Solution code:
n = int(input())
A = [int(l) for l in input().split(' ')]
kn = int(input())
k_list = [int(l) for l in input().split(' ')]

def linear_search(k,A,n):
  i = 0
  while A[i] != k:
    i += 1
    if i == n:
      return False
  return True

sum = 0
for k in k_list:
   sum += 1 if linear_search(k,A,n) else 0
print(sum)

Submission status: Accepted

Solution code:
n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))
ans = 0
for ele in t:
  if ele in s:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
input()
a=set(map(int,input().split()))
input()
b=set(map(int,input().split()))
print(len(a)-len(a-b))

Submission status: Accepted

Solution code:
n = int(input())
S = [int(i) for i in input().split(' ')]
q = int(input())
T = [int(i) for i in input().split(' ')]
c = 0
for t in T:
	if t in S: c += 1
print(c)

Submission status: Runtime Error

Solution code:
N = int(input())
S = list(map(int, input()))
Q = int(input())
T = list(map(int, input()))

match_count = 0
for i in T:
    for j in S:
        if i == j:
            match_count += 1
            break

print(str(match_count))

Submission status: Runtime Error

Solution code:
n = int(input())
S = list(int, input().split())
q = int(input())
T = list(int, input().split())

cnt = 0
for t in T:
	if s in S:
		cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

cnt = 0
for t in T:
	if s in S:
		cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
n = int(raw_input())
S = map(int, raw_input().split(" "))
q = int(raw_input())
T = map(int, raw_input().split(" "))

count = 0
for n in S:
	for j in T:
		if n == j:
			count += 1

print count

Submission status: Runtime Error

Solution code:


n = int(raw_input())
S = map(int, raw_input().split(" ").strip(" "))
q = int(raw_input())
T = map(int, raw_input().split(" ").strip(" "))

count = 0
for n in S:
	for j in T:
		if n == j:
			count += 1

print count

Submission status: Runtime Error

Solution code:
class Sequence:
    def __init__(self,num, seq):
        self.n = num
        self.sequence = seq

def LinearSearch(A, n, key):
    i=0
    A[n] = key
    while A[i] != key:
        i += 1
    if i==n:
        return "NOT_FOUND"
    return i

if __name__ == "__main__":
    with open("LinearSearch.txt") as fp:
        data = fp.readlines()

    x = data[1].split()
    x.append(" ")
    A = Sequence(int(data[0]), x)
    x = data[3].split()
    x.append(" ")
    B = Sequence(int(data[2]), x)

    C = []

    for i in range(B.n):
        res = LinearSearch(A.sequence, A.n, B.sequence[i])
        if res != "NOT_FOUND":
            C.append(A.sequence[res])

    print(C)

Submission status: Runtime Error

Solution code:
n = int( raw_input( ) )
t = [ int( val ) for val in raw_input( ).split( " " ) ]
q = int( raw_input( ) )
s = [ int( val ) for val in raw_input( ).split( " " ) ]

cnt = 0
for si in s:
	for ti in t:
		if si == ti:
			cnt += 1
			break

print( cnt )

Submission status: Runtime Error

Solution code:
n = int( input( ) )
t = [ int( val ) for val in raw_input( ).split( " " ) ]
q = int( input( ) )
s = [ int( val ) for val in raw_input( ).split( " " ) ]

cnt = 0
for si in s:
	for ti in t:
		if si == ti:
			cnt += 1
			break

print( cnt )

Submission status: Runtime Error

Solution code:
n = int( input( ) )
t = [ int( val ) for val in input( ).split( " " ) ]
q = int( input( ) )
s = [ int( val ) for val in input( ).split( " " ) ]

cnt = 0
for si in s:
	for ti in t:
		if si == ti:
			cnt += 1
			break

print( cnt )

Submission status: Runtime Error

Solution code:
n = int(raw_input())
S = map(int, raw_input().split(' '))
q = int(raw_input())
T = map(int, raw_input().split(' '))

def search(S,k):
    for s in S:
        if s == k:
            return True
    return False

c = 0
for t in T:
    if search(S,t): c += 1

print c

Submission status: Runtime Error

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


def linerSearch(S, key):
    tmp = S[::1]
    i = 0
    tmp.append(key)
    while S[i] != key:
        i += 1
    if i == len(tmp)-1:
        return False
    return True

n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

count = 0

for i in range(q):
    if linerSearch(S, T[i]):
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
n = input()

S = map(int, raw_input().split())

q = input()

T = map(int, raw_input().split())

cnt = 0
for i in range(n):
    for j in range(q):
        if S[i] == T[j]:
            cnt = cnt + 1
            
print cnt   
~

Submission status: Runtime Error

Solution code:
n = input()

S = map(int, raw_input().split())

q = input()

T = map(int, raw_input().split())

cnt = 0
for i in range(n):
    for j in range(q):
        if S[i] == T[j]:
            cnt = cnt + 1
            break

print cnt

Submission status: Runtime Error

Solution code:
n = input()

S = map(int, raw_input().split())

q = input()

T = map(int, raw_input().split())

cnt = 0
for j in range(q):
    for i in range(n):
        if S[i] == T[j]:
            cnt = cnt + 1
            break

print cnt

Submission status: Runtime Error

Solution code:
n = input()

S = map(int, raw_input().split())

q = input()

T = map(int, raw_input().split())

S.append(0)
cnt = 0
for i in range(q):
    j = 0
    S[n] = T[j]
    while S[j] != S[n]:
        j = j + 1
    if j != n:
        cnt = cnt + 1


print cnt

Submission status: Runtime Error

Solution code:
n = input()

S = [int(x) for x in raw_input().split]

q = input()

T = [int(x) for x in raw_input().split]

C = 0

for i in S:
 for j in T:
  if i==j:
   C += 1

print C

Submission status: Runtime Error

Solution code:
n = input()

S = [int(x) for x in raw_input().split()]

q = input()

T = [int(x) for x in raw_input().split()]

C = 0

for i in S:
 for j in T:
  if i==j:
   C += 1
   break:

print C

Submission status: Runtime Error

Solution code:
n = input()
 
S = map(int, raw_input().split())
 
q = input()
 
T = map(int, raw_input().split())

C = 0

  for i in range(n):
    for j in range(q):
      if T[j] == S[i]:
        C++
print C

Submission status: Runtime Error

Solution code:
n = input()
 
S[ ] = map(int, raw_input().split())
 
q = input()
 
T[ ] = map(int, raw_input().split())

C = 0

for i in range(0,n):
  for j in range(0,q):
    if T[j] == S[i]:
      C++

print C

Submission status: Runtime Error

Solution code:
n = input()
 
S = map(int, raw_input().split())
 
q = input()
 
T = map(int, raw_input().split())

C = 0

for i in range(0,n):
  for j in range(0,q):
    if T[j] == S[i]:
      C++

print C

Submission status: Runtime Error

Solution code:
n = input()
 
S = map(int, raw_input().split())
 
q = input()
 
T = map(int, raw_input().split())

C = 0

for i in range(n-1):
  for j in range(q-1):
    if T[j] == S[i]:
      C++

print C

Submission status: Runtime Error

Solution code:
n = input()
S = map(int, raw_input().split())
q = input()
T = map(int, raw_input().split())

count = 0

for i in range(n):
    Search = T[i]
    for j in range(q):
        if S[j] == Search:
            count = count + 1
            break

print count

Submission status: Runtime Error

Solution code:
n = int(raw_input(''))
S = raw_input('').split(' ')
q = int(raw_input(''))
T = raw_input('').split(' ')
 
count = 0
for t in T:
    for s in S:
        if int(t)==int(s):
            count+=1
 
print count

Submission status: Runtime Error

Solution code:
#coding:UTF-8
def LS(n,S,q,T):
    count=0
    if n>q:
        for i in q:
            if T[i] in S:
                count+=1
    else:
        for i in n:
            if S[i] in T:
                count+=1
    print(count)
  
if __name__=="__main__":
    n=int(input())
    S=input().split(" ")
    q=int(input())
    T=input().split(" ")
    LS(n,S,q,T)

Submission status: Runtime Error

Solution code:
# encoding: utf-8


import sys


class Solution:
    def __init__(self):
        """
        init input array
        """
        self.__input = sys.stdin.readlines()

    @property
    def solution(self):
        length_1 = int(self.__input[0])
        array_1 = list(map(int, self.__input[1].split()))
        length_2 = int(self.__input[2])
        array_2 = list(map(int, self.__input[3].split()))

        assert length_1 == len(array_1) and length_2 == len(array_2)

        count = 0
        for each in array_2:
            if self.linear_search(key=each, array=array_1, array_length=length_1):
                count += 1

        return str(count)

    @staticmethod
    def linear_search(key, array, array_length):
        # print(len(set(array_1).intersection(set(array_2))))
        for i in array_length:
            if array[i] == key:
                return True
        return False


if __name__ == '__main__':
    case = Solution()
    print(case.solution)

Submission status: Runtime Error

Solution code:
input()
s = set(map(int,input().split()))
n = int(input())
t = set(map(int,input().split()))
c = 0
for i in range(n):
    if t[i] in s:
        c += 1
print(c)

Submission status: Runtime Error

Solution code:
def linearSearch(A, n, key):
    i = 0
    A.append(key)
    while A[i] != key:
        i += 1
    del A[n]
    return i != n


if __name__ == '__main__':
    n = int(input())
    S = list(map(int, input().split()))
    q = int(input())
    T = list(map(int, input().split()))
    cnt = 0

    for i in q:
        if linearSearch(S, n,T[i]):
            cnt += 1

    print(cnt)

Submission status: Runtime Error

Solution code:
# encording: utf-8

n = int(input())
ns = [int(input()) for _ in range(n)]
q = int(input())
qs = [int(input()) for _ in range(n)]


def main(ns, qs):
    total = 0
    for q in qs:
        if q in ns:
            total += 1
    return total


print(main(ns, qs))

Submission status: Runtime Error

Solution code:
n = input()
S = input().split()
q = input()
T = input().split()
cnt = 0

for i in range(T):
    if T[i] in S:
        cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
def main():
    n = input()
    D = []
    O = []
    for i in range(n):
        c, k = raw_input().split()
        if c == 'insert':
            D.append(k)
        else:
            O.append(search(D,k))

    for item in O:
        print item

    return 0


def search(D,k):
    Dc = D[:]
    o = 'no'
    while Dc != []:
        d = Dc.pop()
        if d == k:
            o = 'yes'
            break

    return o
            

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
n=input()
S=input().split()
q=input()
T=input().split()
c=0
for(t in T):
    if(t in S):c+=1
print(c)

Submission status: Runtime Error

Solution code:
n = int(input())
s = [int(x) for x in input().split()]
q = int(input())
t = [int(x) for x in input().split()]

s.sort()
t.sort()

i = 0
cnt = 0

for x in t:
	while s[i] <= x:
		if s[i] == x:
			cnt += 1
		i += 1

print(cnt)

Submission status: Runtime Error

Solution code:
n = int(input())
s = [int(x) for x in input().split()]
q = int(input())
t = [int(x) for x in input().split()]

s.sort()
t.sort()

i = 0
cnt = 0

for x in t:
	if i < n:
		while s[i] <= x:
			if s[i] == x:
				cnt += 1
			i += 1
	else:
		break

print(cnt)

Submission status: Runtime Error

Solution code:
import sys

n = int(sys.stdin.readline().strip())
S = map(int, sys.stdin.readline().strip().split(" "))

n = int(sys.stdin.readline().strip())
T = map(int, sys.stdin.readline().strip().split(" "))

res = []

for t in T:
    rse.append(S.count(t))
print sum(res)

Submission status: Runtime Error

Solution code:
n = int(raw_input())
S = map(int, raw_input(),split())

q = int(raw_input())
T = map(int, raw_input().split())

ans = 0

for i in T:
    if i in S:
        ans += 1

print ans

Submission status: Runtime Error

Solution code:
n = int(input())
S = map(int, input().split())
q = int(input())
T = map(int, input().split())
print(len(S & T)

Submission status: Runtime Error

Solution code:
n = int(input())
S = map(int, input().split())
q = int(input())
T = map(int, input().split())
print(len(S & T))

Submission status: Runtime Error

Solution code:
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
print(len(S & T))

Submission status: Runtime Error

Solution code:
n = int(input())
S = map(int, input(). split())
q = int(input())
T = map(int, input(). split())

print(len(S & T))

Submission status: Runtime Error

Solution code:
n = int(input())
S = list(map(int, input(). split()))
q = int(input())
T = list(map(int, input(). split()))

print(len(S & T))

Submission status: Runtime Error

Solution code:
import sys

ERROR_INPUT = 'input is invalid'
ERROR_INPUT_NOT_UNIQUE = 'input is not unique'


def main():
    S = get_input1()
    T = get_input2()

    count = 0
    for t in T:
        for s in S:
            if t == s:
                count += 1
                break

    print(count)


def get_input1():
    n = int(input())
    if n > 10000:
        print(ERROR_INPUT)
        sys.exit(1)

    li = []
    for x in input().split:
        if int(x) < 0 or int(x) > 10 ** 9:
            print(ERROR_INPUT)
            sys.exit(1)
        li.append(x)

    return li


def get_input2():
    n = int(input())
    if n > 500:
        print(ERROR_INPUT)
        sys.exit(1)

    li = []
    for x in input().split:
        if int(x) < 0 or int(x) > 10 ** 9:
            print(ERROR_INPUT)
            sys.exit(1)
        elif int(x) in li:
            print(ERROR_INPUT_NOT_UNIQUE)
            sys.exit(1)
        li.append(x)

    return li


main()

Submission status: Runtime Error

Solution code:
n=int(input())
s=input().split()
q=int(input())
t=input().split()
cnt=0

for i in range(q):
    for j in range(n):
        if s[i]==t[j]:
            cnt+=1
            break
            
print(cnt)

Submission status: Runtime Error

Solution code:
#coding: Shift_JIS
import numpy as np

def set_array(a,n):
	str=input()
	array=str.split()
	for i in range(n):
		a[i]=int(array[i])
	

n=int(input())
S=np.zeros(n)
set_array(S,n)
q=int(input())
T=np.zeros(q)
set_array(T,q)
C=0

def linear_search(S,x):
	np.append(S,x)
	len=np.size(S)
	i=0
	while(len>i):
		if S[i]==x: break;
		i=i+1
	
	np.delete(S,-1)
	if i!=len:
		return 1;
	else:
		return 0;

for v in T:
	C+=linear_search(S,v)

print(C)

Submission status: Runtime Error

Solution code:
n=int(input())
a=[]
b=[]
for i in range(1,n):
    a[i]=int(input())
    
x=int(input())
for i in range(1,x):
    b[i]=int(input())

Submission status: Runtime Error

Solution code:
#include<iostream>
#include<vector>
using namespace std;

int main(void){
	int n, q, num=0;
	long S[10001], T[501];
	
	std::cin >> n;
	for(int i=0; i<n; i++){
		std::cin >> S[i];
	}
	
	std::cin >> q;
	for(int i=0; i<q; i++){
		std::cin >> T[i];
	}
	
	for(int i=0; i<n; i++){
		for(int j=0; j<q; j++){
			if(S[i] == T[j]){
                            num+=1;
                        }
		}
	}
	
	cout(num);
	
	return 0;
}

Submission status: Runtime Error

Solution code:
c=0
n=int(input())
s=int(input().split())
nqint(input())
t=int(input().split())
for i in t:
	for j in s:
		if i==j:
			c +=1
print(c)

Submission status: Runtime Error

Solution code:
n = int(input())
s = list(map(int,input().split()))
q = int(input())
r = list(map(int,input().split()))
cou = 0

for i in range(q):
    for j in range(n):
        if(s[i] == r[j]):
            cou += 1
            break
print(cou)

Submission status: Runtime Error

Solution code:
#include<iostream>
#include<vector>
using namespace std;

int main(void){
	int n, q, num=0;
	long S[10001], T[501];
	
	std::cin >> n;
	for(int i=0; i<n; i++){
		std::cin >> S[i];
	}
	
	std::cin >> q;
	for(int i=0; i<q; i++){
		std::cin >> T[i];
	}
	
	for(int i=0; i<n; i++){
		for(int j=0; j<q; j++){
			if(S[i] == T[j]){
				num+=1;
			}
		}
	}
	
	cout << num << "\n";
	
	return 0;
}

Submission status: Runtime Error

Solution code:
S=[]
T=[]
n=int(input())
s=input().split()
for i in range(n):
	S.append(s[i])
q=int(input())
t=input().split()
for j in range(q):
	T.append(t[j])
cnt=0
for i in range(n):
	for j in range(q):
		if S[i]==T[j]:
			cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:

n=int(input())
lista=[0 for i in range(n)]
lista=input().split()
n2=int(input())
listb=[0 for i in range(n2)]
listb=input().split()
cnt=0
for i in range(n2):
    x=0
    
    for j in range(n):
        if listb[i]==lista[j] and if x==0:
            x=1
            cnt+=1

print(cnt)

Submission status: Runtime Error

Solution code:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#define MAX 10000

int linear_search(int a, int b);
void input(int a[]);

int main(void)
{
    int count=0;
    char null;
    int n,q;
    int S[MAX];
    int T[MAX];
    scanf("%d",&n);
    getchar();
    input(S);    
    scanf("%d",&q);
    input(T);
    getchar();
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<q;j++)
        {
            count+=linear_search(S[n],T[q]);
        }
    }
    printf("%d\n",count);


    return 0;
    
}

int linear_search(int a, int b)
{
    if(a == b){return 1;}
    else{return 0;}
}
void input(int a[])
{
    char str[MAX];
    int x;
    int j=0;
    fgets(str,MAX,stdin);
    int i=0;
    while(str[i]>=' ')
    {
        while(isspace(str[i])){i++;}
        if(isdigit(str[i]))
        {
            x=0;
            while(isdigit(str[i]))
            {
                x=10*x+(str[i]-'0');
                i++;
            }
            a[j]=x;
            j++;
        }
        else
        {
            i++;
        }
    }
}

Submission status: Runtime Error

Solution code:
def linearSearch(key, list):
    for e in list:
        if key == e:
            return 1
    return 0
    
    
N1 = int(input())
arr1 = [int(n) or n in input().split()]
N2 = int(input())
arr2 = [int(n) or n in input().split()]

print(sum([linearSearch(key, arr2) for key in arr])

Submission status: Runtime Error

Solution code:
def linearSearch(key, list, N):
    list[N] = key
    i = 0
    while l[i] != key:
        i += 1
    return int(i != N)


N1 = int(input())
arr1 = [int(n) for n in input().split() + [0]]
N2 = int(input())
arr2 = [int(n) for n in input().split()]

print(sum([linearSearch(key, arr1, N1) for key in arr2))

Submission status: Runtime Error

Solution code:
def linearSearch(key, list, N):
    list[N] = key
    i = 0
    while l[i] != key:
        i += 1
    return int(i != N)


N1 = int(input())
arr1 = [int(n) for n in input().split()] + [0]
N2 = int(input())
arr2 = [int(n) for n in input().split()]

print(sum([linearSearch(key, arr1, N1) for key in arr2))

Submission status: Runtime Error

Solution code:
def linearSearch(key, list, N):
    list[N] = key
    i = 0
    while l[i] != key:
        i += 1
    return int(i != N)


N1 = int(input())
arr1 = [int(n) for n in input().split()] + [0]
N2 = int(input())
arr2 = [int(n) for n in input().split()]

print(sum([linearSearch(key, arr1, N1) for key in arr2]))

Submission status: Runtime Error

Solution code:
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr = (input.trim()).split("\n");
var N1 = Number(Arr[0])
var arr1 = Arr[1].split(" ").map(Number);
var arr2 = Arr[3].split(" ").map(Number);

const linearSearch = (key, arr) => {
  let i = 0
  arr[N1] = key;
  while (true) {
      if (arr[i] === key) break;
      i++;
  }
  return i === N1 ? 1 : 0;
}
console.log(arr2.map(e => linearSearch(e, arr1)).reduce((a, b) => a + b, 0));