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:
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: Accepted

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

    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: Accepted

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:
        if linner_search(S, t):
            count += 1

    print(count)


def linner_search(li, key):
    li.append(key)
    i = 0
    while li[i] != key:
        i += 1

    return i != len(li) - 1


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: Accepted

Solution code:
def search(S, n, t):
    i=0
    S[n]=t
    while (S[i] != t):
        i+=1
    return i!=n

sum=0

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

S.append([0]*10000)

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

for i in range(0,q):
    if search(S,n,T[i]):
        sum+=1

print(sum)

Submission status: Accepted

Solution code:
input()
l = [int(i) for i in input().split()]
input()
c = 0
for i in input().split():
    for j in l:
        if int(i) == j:
            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:
# -*- coding: utf-8 -*-


def linearSearch(l, key):
    m = len(l)
    l.append(key)
    i = 0
    while l[i] != key:
        i += 1
    l.pop()
    if i == m:
        return "NOT_FOUND"
    return i


if __name__ == '__main__':

    n = int(input())
    S = [int(s) for s in input().split(" ")]
    q = int(input())
    T = [int(t) for t in input().split(" ")]

    count = 0
    for t in T:
        if linearSearch(S, t) != "NOT_FOUND":
            count += 1

    print(count)

Submission status: Accepted

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

def equal_element(S,T):
	m=0
	for i in range(len(T)):
		for j in range(len(S)):
			if S[j]==T[i]:
				m+=1
				break
	return(m)
	
print(equal_element(S,T))

Submission status: Accepted

Solution code:
first_set_count = int(input());
first_set = [int(n) for n in input().split()];
second_set_count = int(input());
second_set = [int(n) for n in input().split()];

def linear_search(first_set, second_set):
    count = 0;
    for n in second_set:
        for m in first_set:
            if n == m:
                count += 1;
                break;
    print(count);

linear_search(first_set, second_set);

Submission status: Accepted

Solution code:
def linearSearch(S, N, key):
    i = 0
    S[N] = key
    while S[i] != key:
        i += 1
    if i != N:
        return True
    
N = int(input())
S = list(map(int,input().split()))
q = int(input())
T = list(map(int,input().split()))  

S.append(0)

sum = 0 

for j in range(q):
    if linearSearch(S,N,T[j]) == True:
        sum += 1
    
print(sum)

Submission status: Accepted

Solution code:
def linearSearch(A, key):
    i = 0
    A.append(key)
    while A[i] != key:
        i += 1
    if i == len(A)-1:
        A.pop()
        return 'Not_found'
    A.pop()
    return i

if __name__ == '__main__':
    c = 0
    n = int(input())
    hoge1 = [int(x) for x in input().split()]
    q = int(input())
    for key in (int(x) for x in input().split()):
        if linearSearch(hoge1, key) == 'Not_found':
            continue
        else:
            c += 1
    print (c)

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()]
cnt = 0
for i in t:
    if i in s:
        cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
input()
s=set(input().split())
print(int(input())-len(set(input().split())-s))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
s=sys.stdin.readlines()
print(len(set(s[1].split())&set(s[3].split())))

Submission status: Accepted

Solution code:
#coding: UTF-8
n = int(input())
S = list(map(int,input().split()))
q = int(input())
T = list(map(int,input().split()))
ans = 0
for v in T:
  if v in S:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
#coding: UTF-8
n = int(input())
S = list(map(int,input().split()))
q = int(input())
T = list(map(int,input().split()))
ans = 0
def linsearch(v,S):
  for w in S:
    if v == w:
      return True
  return False
  
for v in T:
  if linsearch(v,S):
    ans += 1
  
print(ans)

Submission status: Accepted

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

import sys

n = int(sys.stdin.readline())
s = list(map(int, sys.stdin.readline().split()))
q = int(sys.stdin.readline())
t = list(map(int, sys.stdin.readline().split()))

s_set = set(s)
total = 0

for x in t:
    if x in s_set:
        total += 1

print(total)

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):
    s.append(t[i])
    j = 0
    while t[i] != s[j]:
        j += 1
    if j != n:
        count += 1
    del s[n]
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(' ')))

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

Submission status: Accepted

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

cnt = 0
for i in t:
    if i in s:
        cnt += 1
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()))

Sset = set(S)
Tset = set(T)

print(len(Sset & Tset))

Submission status: Accepted

Solution code:
import sys

def linierSearch(x,data):
    for i in range(0,len(data)):
        if data[i] == x:
            return 1
    return 0

l = []
for i in sys.stdin:
    l.append(i)

l[1] = l[1].split()
l[3] = l[3].split()

count = 0
for i in range(0,len(l[3])):
    count += linierSearch(l[3][i],l[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()))
ans = 0
for i in T:
    if i in S:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
def count(xs, ys):
    """Returns a count of elements in xs which is also in ys.

    >>> count([1, 2, 3], [1, 3])
    2
    >>> count([1, 2, 3, 4, 5], [3, 4, 1])
    3
    """
    xset = set(xs)
    yset = set(ys)
    return len(xset & yset)


def run():
    _ = input()  # flake8: noqa
    s = [int(i) for i in input().split()]
    _ = input()  # flake8: noqa
    t = [int(j) for j in input().split()]

    print(count(s, t))


if __name__ == '__main__':
    run()

Submission status: Accepted

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

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

count = 0

for i in t:
    # 配列に番兵を追加
    s += [i]
    j = 0
    while s[j] != i:
        j += 1
    s.pop()
    if j == ns:
        continue
    count += 1

print(count)

Submission status: Accepted

Solution code:
input()
a = set(map(int, input().split()))
input()
b = set(map(int, input().split()))
print(len(a & b))

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()]
cnt = 0
for i in t:
    if i in s:
        cnt += 1
print(cnt)

Submission status: Accepted

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

res = 0
for t in T:
    if t in S:
        res += 1

print(res)

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 i in range(q):
    if T[i] in S:
        ans += 1
print(ans)

Submission status: Accepted

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

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

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

print(result)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 30 11:23:30 2018
ALDS1-4a most simple implementation using the features of the python
@author: maezawa
"""

n = int(input())
s = map(int, input().split())
q = int(input())
t = map(int, input().split())

s_set = set(s)
t_set = set(t)
sandt = s_set & t_set
print(len(sandt))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 30 11:33:59 2018
ALDS1-4a_r  simple implementation without sets
@author: maezawa
"""

n = int(input())
s = list(map(int, input().split())) # in演算子を使うためにはsはlistである必要がある。
q = int(input())
t = map(int, input().split())

cnt = 0

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

print(cnt)

Submission status: Accepted

Solution code:
#! python3
# linear_search.py

n = int(input())
S = [int(x) for x in input().split(' ')]
q = int(input())
T = [int(x) for x in 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())
a = set(input().split())
m = int(input())
b = set(input().split())
print(len(a&b))

Submission status: Accepted

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

S_s =set(S)
T_s =set(T)
C = S_s & T_s
print(len(C))

Submission status: Accepted

Solution code:
S=[]
T=[]

S_num=int(input())
S=input().split()

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

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = input().split()
q = int(input())
t = 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:
n1=int(input())
l1=list(input().split())

n2=int(input())
l2=list(input().split())


cnt=0
for x in l2:
    if x in l1:
        cnt=cnt+1


print(cnt)

Submission status: Accepted

Solution code:

S=int(input())
A=list(input().split())

T=int(input())
B=list(input().split())

n=0

for i in B:
    if i in A:
        n=n+1

print(n)

Submission status: Accepted

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[j]==t[i]:
            cnt+=1
            break
            
print(cnt)

Submission status: Accepted

Solution code:
sn = int(input())

S=[0 for i in range(sn)]

S=input().split()

tn = int(input())

T=[0 for i in range(tn)]

T=input().split()

cnt=0

A=[]

for i in range(len(T)):
	for j in range(len(S)):
		if T[i]==S[j]:
			if T[i] not in A:
				cnt+=1
			A.append(T[i])

print(cnt)

Submission status: Accepted

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

n = int(input())
T = list(map(int, input().split()))
cnt = 0

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

print(cnt)

Submission status: Accepted

Solution code:
#coding: Shift_JIS

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

n=int(input())
S=[]
set_array(S,n)
q=int(input())
T=[]
set_array(T,q)
C=0

def linear_search(S,x):
	S.append(x)
	l=len(S)
	i=0
	while(l>i):
		if S[i]==x:
			break
		i=i+1
	S.pop(-1)
	if i!=l-1:
		return 1;
	else:
		return 0;
for v in T:
	C+=linear_search(S,v)

print(C)

Submission status: Accepted

Solution code:
def linearSearch(A,key):
    for i in range(len(A)):
        if A[i]==key:
            return i
        else: pass
    return -1


n=int(input())
s=list(input().split())
q=int(input())
t=input().split()

cnt=0
for i in range(q):
    x=linearSearch(s,t[i])
    if x!=(-1):
        cnt+=1
        
print(cnt)

Submission status: Accepted

Solution code:
def linear_search(arr, key):
    idx = 0
    while arr[idx] != key:
        idx += 1

    if idx == len(arr) - 1:
        return False

    return True


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

s.append(None)
cnt = 0
for i in range(q):
    s[n] = t[i]
    if linear_search(s, t[i]):
        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(input())
a=input().split()

m=int(input())
b=input().split()

a=[int(i) for i in a]
b=[int(i) for i in b]

a.sort()
b.sort()
cnt=0

for j in range(m):
  if b[j] in a:
    cnt+=1
print(cnt)

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#16D8102008K 4-B Yagyu Hauzki

n=int(input())
s=set(map(int,input().split()))
q=int(input())
t=set(map(int,input().split()))
print(len(t&s))

Submission status: Accepted

Solution code:
n1=input()
X=set(input().split())
n2=input()
Y=set(input().split())
print(len(X&Y))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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[j] == r[i]):
            cou += 1
            break
print(cou)

Submission status: Accepted

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

Submission status: Accepted

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 x==0:
            x=1
            cnt+=1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

    cnt = 0
    for et in t:
        sc = s.copy()
        sc.append(et)
        i = 0

        while sc[i] != et:
            i += 1

        if i < n:
            cnt += 1

    print(cnt)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
S = list(map(int, input().split(' ')))
q = int(input())
T = list(map(int, input().split(' ')))
counter = 0
for t in  T:
    for s in S:
        if(s == t):
            counter += 1
            break

print(counter)

Submission status: Accepted

Solution code:
n = int(input())
S = [int(n) for n in input().split()]
q = int(input())
T = [int(n) for n in input().split()]
cnt = 0
for n in T:
    if n in S:
        cnt += 1

print(cnt)

Submission status: Accepted

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

cnt = 0

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

print(cnt)

Submission status: Accepted

Solution code:
# ALDS1_4_A.
# リニアサーチ。

def intinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    n = int(input())
    S = intinput()
    q = int(input())
    T = intinput()
    count = 0
    for k in T:
        if k in S: count += 1
    print(count)

    
if __name__ == "__main__":
    main()

Submission status: Accepted

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
            break

print(cnt)

Submission status: Accepted

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

print(cnt)

Submission status: Accepted

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
    return cnt

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: 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 t in T:
    if t in S:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
n = int(input()); s = input().split()
q = int(input()); t = input().split()
cnt = 0
for i in t:
    if i in s:
        cnt += 1
print(cnt)

Submission status: Accepted

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

c = 0
for x_t in t:
    for x_s in s:
        if x_t == x_s:
            c += 1
            break

print(c)

Submission status: Accepted

Solution code:
def main():
    n = int(stdinput())
    S = [*map(int, stdinput().split())]
    q = int(stdinput())
    T = [*map(int, stdinput().split())]

    S = sorted(S)
    T = sorted(T)

    i = j = c = 0

    while i < n and j < q:
        if S[i] == T[j]:
            c += 1
            i += 1
            j += 1
        elif S[i] > T[j]:
            j += 1
        else:
            i += 1
    
    print(c)

def stdinput():
    from sys import stdin
    return stdin.readline().strip()

if __name__ == '__main__':
    main()
    # import cProfile
    # cProfile.run('main()')

Submission status: Accepted

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

c = set()

for s in S:
    for q in Q:
        if s == q:
            c.add(s)

print(len(c))

Submission status: Accepted

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

c = 0

def seach(A, n, key):
    i = 0
    A = A + [key]
    while A[i] != key:
        i += 1
    return i != n

for q in Q:
    if seach(S, N, q):
        c += 1
        
print(c)

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 i in range(q):
    for j in range(n):
        if t[i] == s[j]:
            ans += 1
            break
print(ans)

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()]
s=0
for i in range(q):
    if T[i] in S:
        s+=1
print(s)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    S = [int(_) for _ in input().split()]
    Q = int(input())
    T = [int(_) for _ in input().split()]

    ans = 0

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

    print(ans)

main()

Submission status: Accepted

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


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

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

Submission status: Accepted

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, arr1) for key in arr2]))

Submission status: Accepted

Solution code:
def linearSearch(key, list, N):
    l = list + [key]
    i = 0
    while l[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: Accepted

Solution code:
n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))
count = 0
for a in t:
    for b in s:
        if a == b:
            count += 1
            break

print(count)

Submission status: Accepted

Solution code:
def linearSearch(key, list, N):
    list[N] = key
    i = 0
    while list[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: Accepted

Solution code:
def linear_search(s,t):
    count = 0
    check_list = []
    for i in s:
        for j in t:
            if i == j and (j in check_list) == False:
                count = count + 1
                check_list.append(j)
    return count

sline = []
tline = []

n = int(input())

sline = list(map(int,input().split()))
if len(sline) != n:
    print("Error")
    exit()

q = int(input())

tline = list(map(int,input().split()))
if len(tline) != q:
    print("Error")
    print(len(tline),q)
    exit()

count = linear_search(sline,tline)

print(count)

Submission status: Accepted

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: Accepted

Solution code:
N = int(input())
L = input().split()
n = int(input())
l = input().split()
dup = []
count = 0
for i in range(N):
    for j in range(n):
        if L[i] == l[j]:
            dup.append(L[i])
            break
dup = list(set(dup))
print(len(dup))

Submission status: Accepted

Solution code:
# input the number for array of a[]
n = int(input())
a = list(map(int, input().split()))

# input the number for array of b[]
m = int(input())
b = list(map(int, input().split()))

# do the linear search
count = 0
for i in range(m):
    for j in range(n):
        if(b[i] == a[j]):
            count += 1
            break

print(count)

Submission status: Accepted

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


q=int(input())
T=list(map(int,input().split()))
count=0

for j in range(q):
    if T[j] in S1:
        count+=1
    
        
print(count)

Submission status: Accepted

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

n = int(input())
s = list(input().split())
n = int(input())
t = list(input().split())
cnt = 0
for i in range(n):
    if t[i] in s:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
S = [int(t) for t in input().split()]
q = int(input())
T = [int(t) for t in input().split()]
assert n == len(S) and q == len(T)

print(sum(1 for t in T if t in S))

Submission status: Accepted

Solution code:
# AOJ ALDS1_4_A Linear Search
# Python3 2018.7.3 bal4u

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 =input().split(" ")
l =int(input())
T = input().split(" ")
ans =0
for t in T:
    S.append(t)
    j =0
    while S[j] !=t:
        j+=1
    if j !=n:
        ans +=1
    S=S[:-1]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def run():
    s_n = int(input())
    S = set(map(int, input().split()))
    t_n = int(input())
    T = set(map(int, input().split()))

    print(len(S&T))

if __name__ == '__main__':
    run()

Submission status: Accepted

Solution code:
n = input()
S = set([int(s) for s in raw_input().split()])
m = input()
T = set([int(s) for s in raw_input().split()])
print len(T & S)

Submission status: Accepted

Solution code:
n = raw_input()
S = set(raw_input().split())

q = raw_input()
T = set(raw_input().split())

print len(S & T)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
stdin.readline()
s = {int(s) for s in stdin.readline().split()}
stdin.readline()
s.intersection_update((int(s) for s in stdin.readline().split()))
print(len(s))

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding:utf-8 -*-
#from __future__ import print_function
import time
import sys
import io
import re
import math
start = time.clock()
i = 0
m=int(raw_input())
n=map(int, raw_input().split())
o=int(raw_input())
p=map(int, raw_input().split())
for j in xrange(o):
    if int(p[j]) in n: i+=1
print i

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n1 = int(input())
s1 = set(map(int, input().strip().split()))
n2 = int(input())
s2 = set(map(int, input().strip().split()))
print(len(s1 & s2))

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:
a_N = int(input())
a_list = list(map(int, input().split()))
b_N = int(input())
b_list = list(map(int, input().split()))

answer = 0
for i in b_list:
  if i in a_list:
    answer += 1

print(answer)

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 i in range(q):
  for j in range(n):
    if s[j]==t[i]:
      ans+=1
      break
print(ans)