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:
"""
線形探索
O(n)かかる
"""
def LinearSerch(S, T):
    count = 0
    for i in T:
        for j in S:
            if i == j:
                count += 1
                break
            else:
                pass
    
    return count

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

print(LinearSerch(s, t))

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

q = int(input())

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

C = 0

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

Submission status: Accepted

Solution code:
# def linear_search(seq1, seq2):
#     count = 0
#     for i in seq1:
#         for j in seq2:
#             if i == j:
#                 count += 1
#     return count
from copy import deepcopy


def linear_search(seq, seq1_len, key):
    # 番兵
    seq[seq1_len] = key
    i = 0
    while seq[i] != key:
        i += 1
    return i != seq1_len


def main():
    # num_seq1 = int(input())
    seq1_len = int(input())
    seq1 = list(map(int, input().split(" "))) + [0]  # 番兵
    # num_seq2 = int(input())
    input()
    seq2 = list(map(int, input().split(" ")))
    count = 0
    for key in seq2:
        if linear_search(seq1, seq1_len, key):
            count += 1

    print(count)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
a = int(input())
alist = list(map(int,input().split()))
b = int(input())
blist = list(map(int,input().split()))
ans = 0
for num in blist:
    if num in alist:
        ans += 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()))
S.append("")

cnt = 0

def search(S,n, key):
    S[n] = key
    j = 0
    while( S[j] != key):
        j += 1


    return j != n

for i in T:
    if(search(S,n,i)): cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
def linear_search(number, list):
    i = 0
    n = len(list)
    list.append(number)
    while list[i] != number:
        i += 1
    if i == n:
        return 0
    return 1

n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = map(int, input().split())
cnt = 0
for i in T:
    cnt += linear_search(i, S)
print(cnt)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import copy

def linearSearch(S, length, key):
    numList = copy.copy(S)
    numList.append(key)
    j = 0
    while numList[j] != key:
        j += 1
    return j != length
    

sum = 0
lenS = int(input())
S = list(map(int, input().split())) 
lenT = int(input())
T = list(map(int, input().split())) 

for i in range(lenT):
    tmp = linearSearch(S, lenS, T[i])
    if tmp:
        sum += 1
print(sum)

Submission status: Accepted

Solution code:
n=int(input())
s=list(map(int,input().split()))
q=int(input())
cnt=0
t=list(map(int,input().split()))
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())
S = list(map(int, input().split()))
q = int(input())
T = map(int, input().split())
T = set(T)
ans = 0
for t in T:
    ans += S.count(t) != 0
print(ans)

Submission status: Accepted

Solution code:
def linear_search(num, numlist):
    numlist.append(num)
    index = 0
    while index < len(numlist) and numlist[index] != num:
        index += 1
    numlist.pop(-1)
    if index == len(numlist):
        return False
    else:
        return True

if __name__ == '__main__':
    n = input()
    numlist1 = [int(num) for num in input().split()]
    m = input()
    numlist2 = [int(num) for num in input().split()]

    tot = 0
    for num in numlist2:
        if linear_search(num, numlist1):
            tot += 1
    print(tot)

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 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 = set(input().split())
q = int(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()))

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

Submission status: Accepted

Solution code:
from collections import deque
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    input()
    s=list(map(int,input().split()))
    input()
    t=list(map(int,input().split()))
    s=set(s)
    t=set(t)
    print(len(s&t))

main()

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    n = input()
    A = set(map(int, input().split()))
    n = input()
    cnt = 0
    for b in map(int, input().split()):
        cnt += b in A
    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()]

anw = 0
for i in T:
    if i in S: anw += 1
print(anw)

Submission status: Accepted

Solution code:
#list L内にkey値が存在するか。nは番兵のindex
def linearSearch(L,n,key):
    i = 0
    L.append(key)#番兵としてkeyをLに追加
    while L[i] != key:
        i += 1
    L.pop(n)
    #i==n ならFalse(番兵まで探索した),i!=nなら番兵より手前でkeyと一致
    return i != n

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

ans = 0
for i in range(len(T)):
    if linearSearch(S,len(S),T[i]):
        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
lenS = len(S)
for i in T:
    S.append(i)
    idx = 0
    while True:
        if S[idx] == i:
            break
        else:
            idx += 1
    if idx < lenS:
        ans += 1
    S.pop()
print(ans)

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=int(input())
s=list(map(int,input().split()) )
q=int(input())
t=list(map(int,input().split()) )
print( sum( i in s for i in t) )

Submission status: Accepted

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

def linearsearch(n,S,t):
    for s in S:
        if s==t:
            return 1
    return 0

def main():
    n,S,q,T=inputting()
    count=0
    for t in T:
        flag=linearsearch(n,S,t)
        if flag==1:
            count+=1
    print(count)
    

if __name__=='__main__':
    main()

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

main()

Submission status: Accepted

Solution code:
def LinearSearch(intList,target):
    i=0
    intList.append(target)
    while intList[i] != target:
        i+=1
    intList.pop()
    if i == len(intList):
        return False
    return True

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

for i in range(len(T)):
    if LinearSearch(S, T[i]):
        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()))

def linearSearch(A: [int], key: int):
    i = 0
    A[len(A)-1] = key
    while A[i] != key:
        i += 1
    return i != n

c = 0
s.append(-1)
for i in range(len(t)):
    if linearSearch(s, t[i]):
        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()))

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 = list(map(int,input().split()))
Q = int(input())
T = list(map(int,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=list(map(int,input().split()))
q=int(input())
T=list(map(int,input().split()))
C=len([i for i in T if i in S])
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()))

count = 0
for elT in t:
    for elS in s:
        if elT == elS:
            count+=1
            break
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 Ti in T:
  for Si in S:
    if Si == Ti:
      ans += 1
      break

print(ans)

Submission status: Accepted

Solution code:
len_a = input()
a = set(map(int, input().split()))
len_b = input()
b = set(map(int, 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()))

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

Submission status: Accepted

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

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

counter = 0
for t in T:
    if search(S[:], t, n):
        counter += 1

print(counter)

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(A,key):
    i = 0
    A.append(key)
    n = len(A) - 1
    while A[i] != key:
        i += 1
    if i == n:
        return 0
    return 1

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

print(cnt)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Oct 24 00:11:24 2019

@author: iwao_yuuki
"""

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:
    flag = False
    for j in S:
        if i == j:
            cnt += 1
            flag = True
        if flag:
            break

print(cnt)

Submission status: Accepted

Solution code:

n=int(input())

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

q=int(input())

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

cou=0

for i in range(q):
    for k in range(n):
        if s[k]==t[i]:
            cou+=1
            break

print(cou)

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

Submission status: Accepted

Solution code:
S=[]
T=[]

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

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

Submission status: Accepted

Solution code:
n = int(input())
s = set([int(x) for x in input().split()])
q = int(input())
t = [int(x) for x in input().split()]
ans = 0
for i in t:
    if i in s:
        ans = ans + 1
print(ans)

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

c = 0

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

print(c)

Submission status: Accepted

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

cnt = 0
for i in range(len(l2)):
    for j in range(len(l1)):
        if(l1[j] == l2[i]):
            cnt = cnt + 1
            break
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()))
cnt=0

S.sort()
for i in range(n):
    for j in range(q):
        if S[i]==T[j]:
            if S[i-1]!=S[i]:
                cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n = int(input())
    arr_1 = set(map(int, input().split()))
    q = int(input())
    arr_2 = set(map(int, input().split()))
    arr = arr_1 & arr_2
    print(len(arr))

Submission status: Accepted

Solution code:
#17D8104026C 宮地拓海 Air_conditioner123 Python

n = int(input())
List = [int(i) for i in input().split()]
q = int(input())
List2 = [int(i) for i in input().split()]
count = 0
for i in range(q):
    count += list(set(List)).count(List2[i])
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()))
cnt = 0

S.sort()
for i in range(n):
    for j in range(q):
        if S[i] == T[j]:
            if S[i-1] != S[i]:
                cnt += 1
print(cnt)

Submission status: Accepted

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

r.sort()
l.sort()

c=0
for i in l:
    for j in r:
        if i==j:
            c=c+1
            break
print(c)

Submission status: Accepted

Solution code:
from collections import deque
n=int(input())
S=input().split()
q=int(input())
T=input().split()
cnt=0
F=deque()
for i in range(0,n-1):
    if S[i] in F:
        cnt+=0
    elif S[i] in T:
        cnt+=1
        F.append(S[i])
print(cnt)

Submission status: Accepted

Solution code:
n1=int(input())
a=list(map(int,input().split()))
n2=int(input())
b=list(map(int,input().split()))
cnt=0

for i in range(n2):
    for j in range(n1):
        if b[i]==a[j]:
            cnt+=1
            break


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

print(count)

Submission status: Accepted

Solution code:
n=int(input())
A=[]
A=input().split()
q=int(input())
B=[]
B=input().split()
count=0
for j in range(0,q):
    for i in range(0,n):
        if A[i]==B[j]:
            count=count+1
            break
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()))

cnt=0

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

count=0

for i in range(q):
    for j in range(n):
        #print(S[i],T[j])
        if S[j]==T[i]:
            #print("--")
            count+=1
            break
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()))
cnt=0
s.sort()
for i in range(n-1):
    if s[i]!=s[i+1]:
        for j in range(q):
            if s[i]==t[j]:
                cnt+=1
                break
if s[n-2]!=s[n-1]:
    for j in range(q):
        if s[n-1]==t[j]:
            cnt+=1
            break
print(cnt)

Submission status: Accepted

Solution code:
n=int(input())
s=input().split()
s.append(0)

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

cnt=0
for i in range(q):
    key=t[i]
    s[n]=key
    j=0
    while(s[j]!=key):
        j+=1

    if j==n:
        continue
    else:
        cnt+=1

print(cnt)

Submission status: Accepted

Solution code:
import math
def isPrime(s,t):
    cnt=0
    tmp=-1
    s.sort()
    t.sort()
    for i in s:
        if i!=tmp:
            for j in t:
                if i==j:
                    cnt=cnt+1
                    break;
        tmp=i
    return cnt
n=int(input())
s=list(map(int,input().split()))
q=int(input())
t=list(map(int,input().split()))
print(isPrime(s,t))

Submission status: Accepted

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

ans = 0
for ti in t:
    if ti in s:
        ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num1 = int(input())
arr1 = list(map(int,input().split()))

num2 = int(input())
arr2 = list(map(int,input().split()))

count = 0

for i in range(num2):
    try:
        a = arr1.index(arr2[i])
        count +=1
    except:
        pass

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

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:
def search_linear(target_list, target_length, key_value):
    i = 0
    target_list.append(key_value)
    while target_list[i] != key_value:
        i += 1
    target_list.pop()
    return i != target_length

target_length = int(input())
target_list = list(map(int,input().split()))
key_length = int(input())
key_list = list(map(int,input().split()))

exist_count = 0
for key_value in key_list:
    exist_count += 1 if search_linear(target_list, target_length, key_value) else 0
print(exist_count)

Submission status: Accepted

Solution code:
def func(n, t, q, s):
    matchN = 0
    t.append(0)
    for x in s:
        t[n] = x
        i = 0
        while t[i] != x:
            i += 1
        if i != n:
            matchN += 1
    return matchN

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

Submission status: Accepted

Solution code:
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/4/ALDS1_4_A
# やるだけ # 本では番兵を用いた実装だと定数倍早いとあるが、pythonではwhileが遅いのでおとなしくfor文を書く

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

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

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

print(cnt)

# list.index(hoge)とかlist.count(hoge)とかもよく使う。

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())
    ans = 0
    for t in T:
        if t in S:
            ans += 1
    print(ans)
    
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()))
C = 0
for i in T:
    if i in S:
        C += 1

print(C)

Submission status: Accepted

Solution code:
def linearSearch(A, n, key):
	i = 0
	A.append(key) # 番兵を置く
	while A[i] != key:
		i += 1
	A.pop(-1) # 番兵を取り出す
	return i != n # 見つかったらTrue, 見つからなかったらFalse


if __name__ == "__main__":
	n = int(input())
	S = list(map(int, input().split()))
	q = int(input())
	sum = 0
	for key in list(map(int, input().split())):
		if linearSearch(S, n, key):
			sum += 1
	print(sum)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

Submission status: Accepted

Solution code:
n = int(input())
NUM_LIST = list(map(int, input().split()))
k = int(input())
keys = list(map(int, input().split()))
cnt = 0
for key in keys:
    if key in NUM_LIST:
        cnt+= 1
print(cnt)

Submission status: Accepted

Solution code:
# 5
# 1 2 3 4 5
# 3
# 3 4 1

import copy

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

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

def liner_search(nums, n, v):
    S_copy = copy.deepcopy(nums)
    S_copy.append(v)
    i = 0
    while S_copy[i] != v:
        i += 1 
    
    return i != n


if __name__ == "__main__":
    count = 0 
    for t in T:
        if liner_search(S, Sn, t):
            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()))

cnt = 0
for i in t:
    if s.count(i) > 0:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
input()
S=list(map(int,input().split()))
input()
T=list(map(int,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 = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))

print(len(list(filter(lambda x: x in t, set(s)))))

Submission status: Accepted

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

print(len(s.intersection(t)))

Submission status: Accepted

Solution code:
n = int(input())
S = list(map(int,input().split()))
q = int(input())
T = list(map(int,input().split()))
S.append(0)
ans = 0
for i in T:
  S[n] = i
  j = 0
  while S[j] != i:
    j+=1
  if j!=n:
    ans+=1
print(ans)

Submission status: Accepted

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

for x in S:
    for y in T:
        if x==y:
            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()))

sort_S = list(sorted(S[:]))
sort_T = list(sorted(T[:]))
i, j = 0, 0
ans = 0
while i < n and j < q:
    if sort_S[i] == sort_T[j]: 
        ans += 1
        i += 1
        j += 1
    elif sort_S[i] > sort_T[j]:
        j += 1
    elif sort_S[i] < sort_T[j]:
        i += 1
print(ans)

Submission status: Accepted

Solution code:
# ALDS_1_4_A

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

print(count)

Submission status: Accepted

Solution code:
#番兵を使ったタイプの解き方
n=input()
s=list(map(int,input().split()))
q=input()
t=list(map(int,input().split()))
count=0
for i in t:
    j=0
    s.append(i)
    while s[j]!=i:j +=1
    s.pop()
    if j==int(n):continue
    else: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()))
ans=0
for i in T:
    if i in S:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
input()
a = list({int(i) for i in input().split()})
a.sort()
input()
print([int(i) in a for i in input().split()].count(True))

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:
import sys
s=int(input())
S=list(map(int,input().split()))
t=int(input())
T=list(map(int,input().split()))
S=list(set(S))
ans=0
for i in range(len(S)):
  for j in range(t):
    if S[i]==T[j]:
      ans+=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()))
ans=0
for a in t:
    if a in s:
        ans+=1

print(ans)

Submission status: Accepted

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


count = 0
for k in t:
    for l in s:
        if k == l:
            count += 1
            break

print(count)

Submission status: Accepted

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

cnt = 0
q = int(input())
t = list(map(int, input().split()))
for i in t:
    if i in s:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
import sys

def test():

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

	for i in range(len(T)):

		for j in range(len(S)):

			if T[i] == S[j]:
				S.pop(j)
				break
	print(f"{n-len(S)}")

if __name__ == "__main__":
	test()

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

print(cnt)

Submission status: Accepted

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

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

n_and_q = 0

for i in q:
    if i in n:
        n_and_q += 1
        
print(n_and_q)

Submission status: Accepted

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

C = 0
for t in T:
    if t in S:
        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()))
count=0
for i in t:
	for j in s:
		if i==j:
			count+=1
			break
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
s.sort()
for i in range(n):
    for j in range(q):
        if s[i]==s[i-1]:
            continue
        else:
            if s[i]==t[j]:
                ans+=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 i in range(q):
    t = T[i]
    for j in range(n):
        if S[j] == t:
            c += 1
            break
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(" ")]
searched = []

def linearSearch(target, t, q):
    res = 0
    t[q] = target
    j = 0
    while target!=t[j]:
        j += 1
    if j != q:
        res += 1
    return res    

cnt = 0
t.append("NIL")
for i in range(n):
    target = s[i]
    if target in searched:
        continue
    searched.append(target)
    
    cnt += linearSearch(target, t, q)
    
print(cnt)

Submission status: Accepted

Solution code:
n_num = int(input())
n_list = input().split()
q_num = int(input())
q_list = input().split()

cnt = 0
for q in q_list:
    if q in n_list:
       cnt += 1

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

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

ans = 0
s,t = 0,0
while s < len(S) and t < len(T):
    if S[s] == T[t]:
        ans += 1
        t += 1
    elif S[s] < T[t]:
        s += 1
    else:
        t += 1
print ans

Submission status: Accepted

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

def main():
    n = int(input())
    S = input().split(" ")
    _ = int(input())
    T = input().split(" ")

    sum = 0

    for s in T:
        if linearSearch(S, n, s):
            sum += 1
    
    print(sum)

if __name__ == '__main__':
    main()

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

def LinearSearch(S,T):
    count = 0
    for i in range(q): #T
        for j in range(n): #S
            if T[i] == S[j]:
                count += 1
                break
    return count

print(LinearSearch(S,T))

Submission status: Accepted

Solution code:
n = int(input())
S,T = set(),set()
a = [int(i) for i in input().split()]
for i in range(n):
    S.add(a[i])
n = int(input())
a = [int(i) for i in input().split()]
for i in range(n):
    T.add(a[i])
print(len(S&T))

"""
5
1 2 3 4 5
3
3 4 1
"""

Submission status: Accepted

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

def fun(S,T):
        c = 0
        for i in T:
                if i in S:
                        c+=1
        return c

print(fun(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()))

def search(lst, n, val):
    for i in range(n):
        if lst[i] == val:
            return True
    return False

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

Submission status: Accepted

Solution code:
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
 
N = int(input())
S = list(map(int,input().split()))
 
DICT = {}
 
for i in range(len(S)):
    DICT[S[i]] = True
 
Q = int(input())
T = list(map(int,input().split()))
 
ans = 0
 
for i in range(len(T)):
    if DICT.__contains__(T[i]):
        ans += 1
 
print("%d"%(ans))

Submission status: Accepted

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

for ti in t:
  if ti in s:
    result += 1

print(result)