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

Solution code:
############################
# 再帰的に呼出す関数
def half(a,b,low,high):

    if(low > high):
        return 0

    c = int((low+high)/2)

    if(a[c] == b):
        return 1
    elif(a[c] < b):
        return half(a,b,c+1,high)
    elif(a[c] > b):
        return half(a,b,low,c-1)
#############################


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

Submission status: Wrong Answer

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

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
    if x==0:
        for j in range(n):
            if listb[i]==lista[j]:
                x=1
                cnt+=1

print(cnt)

Submission status: Wrong Answer

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

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

print(cnt)

Submission status: Wrong Answer

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

def search_banpei(array, target, cnt):
    tmp = array[len(array)-1]
    array[len(array)-1] = target

    n = 0
    while array[n] != target:
        n += 1

    array[len(array)-1] = tmp
    if n < len(array) - 1 or target == tmp:
        cnt += 1
    return cnt        

def linear_search():  
    cnt = 0
    for t in T:
        for s in S:
            if t == s:
                cnt += 1
                break

def linear_banpei_search():
    cnt = 0
    for target in T:
        cnt = search_banpei(S, target, cnt)
    return cnt

cnt = linear_search()

print(cnt)

Submission status: Wrong Answer

Solution code:
def linearSearch(key, list):
    for e in list:
        if key == e:
            return 1
    return 0


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

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

Submission status: Wrong Answer

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


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

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

Submission status: Wrong Answer

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


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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
L = input().split()
n = int(input())
l = input().split()
count = 0
for i in range(N):
    for j in range(n):
        if L[i] == l[j]:
            count += 1
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
L = input().split()
n = int(input())
l = input().split()
count = 0
for i in range(N):
    for j in range(n):
        if L[i] == l[j]:
            count += 1
print(count)

Submission status: Accepted

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

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

print(str(match_count))

Submission status: Accepted

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

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

print(str(match_count))

Submission status: Accepted

Solution code:
#---------------for input--------------------
numberN=int(input())
arrayS=list(map(int,input().split()))

numberQ=int(input())
arrayT=list(map(int,input().split()))
#---------------for input----------------------

def linearSearch(arrayS,arrayT,numberQ):
    machedNumber=0
    index=0
    while index<numberQ:
        if arrayT[index] in arrayS:
            machedNumber+=1
        index+=1
    print(machedNumber) 

#----------------for main------------------------
linearSearch(arrayS,arrayT,numberQ)
#----------------for main------------------------

Submission status: Accepted

Solution code:
def linear_search(search_list, target):
    i = 0
    search_list.append(target)
    while search_list[i] != target:
        i += 1
    if i == len(search_list) - 1:
        return -1
    else:
        return i

if __name__ == '__main__':
    n = int(input())
    S = [int(x) for x in input().split()]
    q = int(input())
    T = [int(x) for x in input().split()]
    count = 0

    for x in T:
        if linear_search(S, x) > -1:
            count += 1
    print(count)

Submission status: Accepted

Solution code:
n1 = int(input())
a1 = [int(x) for x in input().split()]
n2 = int(input())
a2 = [int(x) for x in input().split()]

res = set()

cnt = 0

for i in range(n1) :
    for j in range(n2) :
        if a1[i] == a2[j] :
            res.add(a1[i])
            
print(len(res))

Submission status: Accepted

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


def linear_search(series, key):
    for x in series:
        if key == x:
            return 1
    return 0

cnt = 0
for t in T:
    cnt += linear_search(S, t)
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
def liner_search(S, key):
    for i in S:
        if i == key:
            return True
    return False
print(sum(liner_search(S, key) for key in T))

Submission status: Accepted

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

ans = s & t
print(len(ans))

Submission status: Accepted

Solution code:
def main():
    _ = input()
    array_A = input().split()
    _ = input()
    array_B = input().split()

    array_intersection = set(array_A) & set(array_B)

    print(len(array_intersection))

    return


main()

Submission status: Accepted

Solution code:
def linear_search(num_list,target):
    for num in num_list:
        if num == target:
            return 1
    return 0

n = input()
num_list = list(map(int,input().split()))
q = input()
target_list = list(map(int,input().split()))
ans = 0

for target in target_list:
    ans += linear_search(num_list,target)
print(ans)

Submission status: Accepted

Solution code:
def linear_search(arr, key):
	arr.append(key)
	i = 0 
	while arr[i] != key:
		i += 1
		if i == n:
			return -1 
	return i 

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 linear_search(S, T[i]) != -1:
		count += 1
print(str(count))

Submission status: Accepted

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())
	L = list(map(int, input().split()))

	q = int(input())
	Key = list(map(int, input().split()))

	cnt = 0
	for i in range(q):
		if (linearSearch(L, n, Key[i])):
			cnt += 1

	print(cnt)

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 t in T:
    for s in S:
        if t == s:
            count += 1
            break
print(count)

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 t in T:
    S.append(t)
    i = 0
    while t != S[i]:
        i += 1
    if i != (len(S) - 1):
        count += 1
    S.pop()
print(count)

Submission status: Accepted

Solution code:
input()
n1 = set(input().split())
input()
n2 = set(input().split())

print(len(n1&n2))

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

ans = 0
for si in set(s):
    if si in t:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
input()
S = set(input().split())
input()
print(len([s for s in input().split() if s in S]))

Submission status: Accepted

Solution code:
input()
S = input().split()
input()
print(len([s for s in input().split() if s in S]))

Submission status: Accepted

Solution code:
input()
S = set(input().split())
input()
T = set(input().split())
print(len(S & T))

Submission status: Accepted

Solution code:
n=int(input())
l1=list(map(int,input().split()))
m=int(input())
l2=list(map(int,input().split()))
c=0
for i in l2:
    if i in l1:
        c+=1
print(c)

Submission status: Accepted

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 t in S:
		cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
N = input()
S = set(map(int, input().split()))
Q = input()
T = set(map(int, input().split()))


intersection = S & T
print(len(intersection))

Submission status: Accepted

Solution code:
N = input()
S = set(map(int, input().split()))
Q = input()
T = set(map(int, input().split()))

ans = 0
for t in T:
  if t in S:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    S = [int(i) for i in input().split()]
    q = int(input())
    T = [int(i) for i in input().split()]
    print(len(set(S) & set(T)))

main()

Submission status: Accepted

Solution code:
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):
    for j in range(n):
        if T[i] == S[j]:
            count += 1
            break

print(count)

Submission status: Accepted

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

count = 0
for target in T:
  if target in S:
    count += 1

print(count)

Submission status: Accepted

Solution code:
input()
s=set(raw_input().split())
input()
t=set(raw_input().split())
print len(s&t)

Submission status: Accepted

Solution code:

n = int(raw_input())
S = []
S = map(int, raw_input().split())

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

count = 0

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

print count

Submission status: Accepted

Solution code:
n = input()
s = set(int(i) for i in input().split())
q = input()
t = set(int(i) for i in input().split())
print(len(t & s))

Submission status: Accepted

Solution code:
# import sys

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

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

print count

Submission status: Accepted

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

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

Submission status: Accepted

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__":

    n = int(raw_input())
    x =	map(int, raw_input().split())
    x.append(" ")
    A = Sequence(n, x)
    n =	int(raw_input())
    x =	map(int, raw_input().split())
    x.append(" ")
    B = Sequence(n, x)

    C_num = 0

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

    print(C_num)

Submission status: Accepted

Solution code:
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_A
# Linear Search
# Result:
import sys


### main
ary_s_len = int(sys.stdin.readline().rstrip())
ary_s = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]
ary_t_len = int(sys.stdin.readline().rstrip())
ary_t = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]
assert len(ary_s) == ary_s_len
assert len(ary_t) == ary_t_len

count = 0
for e in ary_t:
    for se in ary_s:
        if e == se:
            count += 1
            break

print count

Submission status: Accepted

Solution code:
n = int( raw_input( ) )
t = [ int( val ) for val in raw_input( ).rstrip( ).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: Accepted

Solution code:
n = int( input( ) )
t = [ int( val ) for val in input( ).rstrip( ).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: Accepted

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

c = 0
for t in T:
    for s in S:
        if(t == s):
            c+=1
            break
print c

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int( input( ) )
t = [ int( val ) for val in input( ).rstrip( ).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: Accepted

Solution code:
n = input()
s = set(input().split())
q = input()
t = set(input().split())

print(len(s & t))

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 j in t:
    s.append(j)
    i = 0
    while s[i] != j:
        i += 1
    if i >= n:
        pass
    else:
        ans += 1
print(ans)

Submission status: Accepted

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 x in T:
    if x in S:
        count += 1
print count

Submission status: Accepted

Solution code:
#coding:utf-8
#1_4_A
def isFound(array, x):
    """ linear search """
    array.append(x)
    i = 0
    while array[i] != x:
        i += 1
    if i == len(array)-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 isFound(S, T[i]):
        count += 1

print(count)

Submission status: Accepted

Solution code:
#coding:utf-8
#1_4_A
n = int(input())
S = set(map(int, input().split()))
q = int(input())
T = set(map(int, input().split()))

print(len(S & T))

Submission status: Accepted

Solution code:
n_1=input()
n_1_List=map(int,raw_input().split())
n_2=input()
n_2_List=map(int,raw_input().split())
n_1_List=set(n_1_List)
n_2_List=set(n_2_List)
print(len(n_1_List.intersection(n_2_List)))

Submission status: Accepted

Solution code:
# encoding: utf-8


def main():
    n = input()
    t = map(int, raw_input().split())
    q = input()
    s = map(int, raw_input().split())

    sum = 0
    for a in s:
        sum += 1 if a in t else 0

    print sum

main()

Submission status: Accepted

Solution code:
n = int(input())
S = input().split()

q = int(input())
T = input().split()

cnt = 0

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

print(cnt)

Submission status: Accepted

Solution code:
n = input()
S = set(input().split())
S.discard(' ')

q = input()
T = set(input().split())
T.discard(' ')


U = S.intersection(T)

print(len(U))

Submission status: Accepted

Solution code:
n = int(input())
S = input().split()
S.append(None)

q = int(input())
T = input().split()

cnt = 0

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(raw_input())
S = map(int, raw_input().strip().split(' '))
q = int(raw_input())
T = map(int, raw_input().strip().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: Accepted

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


def linerSearch(S, key):
    i = 0
    S.append(key)
    while S[i] != key:
        i += 1
    if i == len(S)-1:
        S.pop()
        return False
    S.pop()
    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: Accepted

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


def linearSearch(A, n, key):
    i = 0
    A.append(key) # ??????
    while A[i] != key:
        i += 1
    A.pop()
    return i != n

count = 0

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

print(count)

Submission status: Accepted

Solution code:
iterator = [["NS", "S"], ["NT", "T"]]
var = {}
for i, j in iterator:
    var[i] = int(input())
    var[j] = [int(k) for k in input().split()]
res = 0
for T in var["T"]:
    if T in var["S"]:
        res += 1
print(res)

Submission status: Accepted

Solution code:
def linear_search(li, value):
    for x in li:
        if x == value:
            return True
    return False

input() # n
S = [int(x) for x in input().split()] 
input() # q
T = [int(x) for x in input().split()]

ans = 0

for x in T:
    if linear_search(S, x):
        ans += 1

print(ans)

Submission status: Accepted

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

q = int(input())
a = input()
t=list(map(int,a.split()))

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

Submission status: Accepted

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[i]
    while S[j] != S[n]:
        j = j + 1
    if j != n:
        cnt = cnt + 1


print cnt

Submission status: Accepted

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 T:
 for j in S:
  if i==j:
   C += 1
   break

print C

Submission status: Accepted

Solution code:
n, s, q, t = input(), set(map(int, input().split())), input(), set(map(int, input().split()))
print(sum(i in s for i in t))

Submission status: Accepted

Solution code:
n = int(input())
S = [int(s) for s in str(input()).split()]
q = int(input())
T = [int(t) for t in str(input()).split()]
#print(n, S, q, T)

print(len([i for i in T if i in S]))

Submission status: Accepted

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

def main():
    n = int(raw_input())
    S = [int(_) for _ in raw_input().split()]
    q = int(raw_input())
    T = [int(_) for _ in raw_input().split()]
    Sum = 0
    for t in T:
        if linearSearch(S[:], t): Sum += 1
    print Sum
    return 0

main()

Submission status: Accepted

Solution code:
input()
s = set(n for n in input().split())
input()
t = set(n for n in input().split())
print(len(s & t))

Submission status: Accepted

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

count = 0

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

print count

Submission status: Accepted

Solution code:
def linearSearch(S, T):
    n = 0
    for t in T:
        for s in S:
            if s == t:
                n += 1
                break
    return n

if __name__ == "__main__":
    input()
    S = raw_input().split()
    input()
    T = raw_input().split()
    print linearSearch(S, T)

Submission status: Accepted

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

x = set(S) & set(T)
print len(x)

Submission status: Accepted

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

cnt = 0

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

print cnt

Submission status: Accepted

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())
	L = list(map(int, input().split()))

	q = int(input())
	Key = list(map(int, input().split()))

	cnt = 0
	for i in range(q):
		if (linearSearch(L, n, Key[i])):
			cnt += 1

	print(cnt)

Submission status: Accepted

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

n = int(raw_input())
S = map(int, raw_input().split())
q = int(raw_input())
T = map(int, raw_input().split())
count = 0
for i in range(q):
    for j in range(n):
        if T[i] == S[j]:
            count += 1
            break
print count

Submission status: Accepted

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

ans = 0
for c1 in t:
    for c2 in s:
        if c1 == c2:
            ans += 1
            break

print(ans)

Submission status: Accepted

Solution code:
def linear_search(l, key):
    _l = l + [key]

    i = 0
    while key != _l[i]:
        i += 1

    if i == len(_l) - 1:
        return -1

    return i


if __name__ == '__main__':
    n = input()
    s = input().split()
    q = input()
    t = input().split()

    ans = 0
    for c1 in t:
        if linear_search(s, c1) >= 0:
            ans += 1

    print(ans)

Submission status: Accepted

Solution code:
def linearSearch(S,t):
    L = S + [t]
    i = 0
    while L[i] != t: i += 1
    if i == len(L)-1: return 0
    else            : return 1

if __name__=='__main__':
    n=int(input()) 
    S=list(map(int,input().split()))
    q=int(input()) 
    T=list(map(int,input().split()))
    cnt = 0
    for t in T: cnt += linearSearch(S,t)
    print(cnt)

Submission status: Accepted

Solution code:
def linearSearch(S,t):
    L = S + [t]
    i = 0
    while L[i] != t: i += 1
    if i == len(L)-1: return 0
    else            : return 1

if __name__=='__main__':
    n=input() 
    S=input().split()
    q=input() 
    T=input().split()
    cnt = 0
    for t in T: cnt += linearSearch(S,t)
    print(cnt)

Submission status: Accepted

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

s = 0
for i in T:
    if i in S:
        s+=1
print s

Submission status: Accepted

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

q = int(input())
t = list(map(int, input().split()))

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

Submission status: Accepted

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


def linear_search(S, T):
    count = 0
    for i in xrange(len(T)):
        if T[i] in S:
            count += 1
    return count

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

    print linear_search(S, T)

Submission status: Accepted

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


def solve(s, t):
    cnt = 0
    for i in t:
        if i in s:
            cnt += 1
    return cnt


print(solve(S, T))

Submission status: Accepted

Solution code:
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_A&lang=jp
sample_input = list(range(3))
sample_input[0] = '''5
1 2 3 4 5
3
3 4 1'''
sample_input[1] = '''3
3 1 2
1
5'''
sample_input[2] = '''500
0 933 743 262 529 700 508 752 256 256 119 711 351 843 705 108 393 330 366 169 932 917 847 972 868 980 223 549 592 164 169 551 427 190 624 635 920 944 310 862 484 363 301 710 236 876 431 929 397 675 491 190 344 134 425 629 30 727 126 743 334 104 760 749 620 256 932 572 613 490 509 119 405 695 49 327 719 497 824 596 649 356 184 93 245 7 306 509 754 352 665 783 738 801 690 330 337 195 656 963 11 427 42 106 968 212 1 510 480 658 571 331 814 847 564 197 625 438 931 18 487 151 187 913 179 995 750 750 913 562 134 273 547 521 830 140 557 678 726 503 597 408 893 988 238 85 93 188 720 211 746 387 710 209 887 668 103 473 900 674 105 183 952 370 787 302 410 905 110 400 996 142 585 860 47 924 731 158 386 219 400 415 55 682 874 61 6 602 268 365 470 518 723 89 106 319 130 655 732 993 974 595 810 673 55 730 95 245 705 694 948 873 353 474 760 741 756 644 143 640 737 679 135 149 529 210 607 417 255 787 373 626 445 112 172 595 153 53 183 717 655 17 176 77 776 399 654 728 2 161 455 870 316 694 381 930 480 604 386 359 207 954 79 702 365 453 732 836 432 563 17 107 583 910 467 116 546 719 528 71 107 256 520 353 528 154 430 477 48 520 204 414 810 719 925 298 131 701 709 751 22 817 652 924 695 471 153 625 978 616 142 597 88 732 917 404 743 395 749 407 936 302 767 45 563 340 398 896 51 807 767 997 978 650 809 330 360 716 161 293 209 753 98 130 634 543 889 88 31 692 401 674 294 693 165 949 765 737 458 841 48 943 229 215 389 209 388 754 243 501 271 516 564 277 912 5 611 212 782 92 123 201 324 4 437 602 804 363 391 273 575 906 759 626 896 859 763 358 577 484 747 156 948 605 454 194 359 430 323 883 24 447 202 847 876 49 792 588 304 133 558 842 414 567 728 506 391 0 992 118 398 718 868 975 579 119 363 596 379 916 466 840 232 430 414 155 571 311 179 796 300 216 903 993 55 728 481 905 29 37 897 286 657 377 682 554 506 757 529 580 641 866 852 933 660 490 616 732 606 114 185 647 227 435 58 183 110 742 374 604 671 872 605 480 671 979 717 481 680 791
30
0 9 18 30 31 42 48 49 59 74 85 115 121 153 165 168 181 195 205 207 220 228 248 252 255 270 274 289 291 300'''
give_sample_input = None
if give_sample_input is not None:
    sample_input_list = sample_input[give_sample_input].split('\n')
    def input():
        return sample_input_list.pop(0)
        
# main
num_of_S = int(input())
S = list(map(int, input().split(' ')))
num_of_T = int(input())
T = list(map(int, input().split(' ')))

count = 0
for s in S:
    for i in range(len(T)):
        if s == T[i]:
            count += 1
            T[i] = -1
            break

print(count)

Submission status: Accepted

Solution code:
def search(S,t):
    for s in S:
        if t == s:
            return True
    return False

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


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

Submission status: Accepted

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

count = 0
for i in T:
    if i in S:
        count += 1

print(count)

Submission status: Accepted

Solution code:

def main():
    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 t in T:
        for s in S:
            if t == s:
                count += 1
                break

    print(count)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

n = int(sys.stdin.readline())
s = [int(x) for x in sys.stdin.readline().split()]
q = int(sys.stdin.readline())
t = [int(x) for x in sys.stdin.readline().split()]
cnt = 0

for i in t:
    if i in s:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
import sys

n = sys.stdin.readline()
s = sys.stdin.readline().split()
q = sys.stdin.readline()
t = sys.stdin.readline().split()
cnt = 0

for i in t:
    if i in s:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
input()
s = input().split()
input()
t = input().split()

cnt = 0

for t1 in t:
    for s1 in s:
        if t1 == s1:
            cnt += 1
            break

print(cnt)

Submission status: Accepted

Solution code:
def find(target, list):
  for i in xrange(len(list)):
    if target == list[i]:
      return 1
  return 0


n = int(raw_input())
S = raw_input().split()
q = int(raw_input())
T = raw_input().split()
count = 0
for i in xrange(q):
  count += find(T[i], S)
print count

Submission status: Accepted

Solution code:
import sys
n = int(sys.stdin.readline()[:-1])
S = sorted(list(map(int, (sys.stdin.readline()[:-1]).split())))
q = int(sys.stdin.readline()[:-1])
T = sorted(list(map(int, (sys.stdin.readline()[:-1]).split())))

count = 0
for i in T:
    x = 0
    while x < len(S):
        if i == S[x]:
            count += 1
            S = S[x:]
            break
        x += 1

print(count)

Submission status: Accepted

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

for i in li2:
	if i in li1:
		cnt +=1
print(cnt)

Submission status: Accepted

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

for x in t:
    c = s.count(x)
    if c != 0:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
# ALDS1 : Linear Search

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

print len(S & T)

Submission status: Accepted

Solution code:
n = input()
S = map(int,raw_input().split())
q = input()
T = map(int,raw_input().split())
ans = 0
for t in T:
    if t in S:
        ans+=1
print ans

Submission status: Accepted

Solution code:
n1 = int(raw_input())
nums1 = map(int, raw_input().split(" "))
n2 = int(raw_input())
nums2 = map(int, raw_input().split(" "))
nums1.append(-1)
count = 0

for key in nums2:
    nums1[len(nums1)-1] = key
    idx = 0

    while nums1[idx] != key:
        idx += 1

    if idx != len(nums1)-1:
        count += 1

print(count)