Problem:


Search I

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

Input

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

Output

Print C in a line.

Constraints

n ≤ 10000

 q ≤ 500 

0 ≤ an element in S ≤ 109

0 ≤ an element in T ≤ 109

Sample Input 1

5
1 2 3 4 5
3
3 4 1

Sample Output 1

3

Sample Input 2

3
3 1 2
1
5

Sample Output 2

0

Sample Input 3

5
1 1 2 2 3
2
1 2

Sample Output 3

2

Notes

Template in C
-->



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


Sample output:
3

Submission status: Accepted

Solution code:
N = int(input())
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:
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

n = I()
S = LI()
q = I()
T = LI()
ans = 0
for t in T:
    if t in S:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin

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

cnt = 0
for x in T:
    if x in S:
        cnt += 1

print(cnt)

Submission status: Accepted

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

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 linear_search(S, n, t):
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
def linerSearch(A, key):
    for i in A:
        if i == key:
            return 1
    return 0

n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
c=0
for j in T:
    if linerSearch(S, j) != 0:
        c += 1
print(c)

Submission status: Accepted

Solution code:
_, s, _, t = [[*map(int, o.split())] for o in open(0)]
print(sum(i in s for i in t))

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:
def main():
    m = int(input())
    a = set(map(int, input().split()))
    n = int(input())
    b = set(map(int, input().split()))
    print(len(a & b))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

    print(count)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

ans = 0


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

print(ans)

Submission status: Accepted

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

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

c = 0

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

print(c)

Submission status: Accepted

Solution code:
def main():
    import sys
    asa =  sys.stdin.readline
    n = int(input())
    s = list(map(int, asa().split()))
    q = int(input())
    t = list(map(int, asa().split()))
    
    c = 0
    s.append(0)
    
    for i in t: # tの中のiを探索
        j = 0
        s[n] = i
        while s[j] != i:
            j += 1
        if j < n:
            c += 1
            
    print(c)
        
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
_, S = input(), input().split()
_, T = input(), input().split()
print(sum(t in S for t in T))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
tmp=input()
a=input().split()
tmp=input()
b=input().split()
c=0
for i in b:
    if i in a:
        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:
#get input
n = input()
S = map(lambda x: int(x), input().split(' '))
q = input()
T = list(map(lambda x: int(x), input().split(' ')))

#create T set
T_set = set(T)

#iterate S and counting
count = 0
for i in S:
    if i in T_set:
        count += 1
        T_set.remove(i)

print(count)

Submission status: Accepted

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

N = int(input())
S = [int(x) for x in input().split(" ")]
S.append(None)


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

count = 0

for key in T:
    if LinearSearch(S,N,key):
        count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
nS = int(input())
S = list(map(int,input().split()))
nQ = int(input())
Q = list(map(int,input().split()))

cnt = 0

for i in range(nQ):
    copy_S = S.copy()
    copy_S.append(Q[i])

    j = 0
    while copy_S[j] != Q[i]:
        j += 1
    if j < len(copy_S)-1 : cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
input()
li1 = [int(x) for x in list(input().split())]
input()
li2 = [int(x) for x in list(input().split())]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def linear_search(s, n, key):
    for i in s:
        if i == key:
            return 1
    return 0

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 linear_search(s, n, i) != 0:
        ans += 1
print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque
import copy

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    S = il()
    Q = ii()
    T = il()

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


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

Submission status: Accepted

Solution code:
n1 = int(input())
nums1 = list(map(int, input().split()))
n2 = int(input())
nums2 = list(map(int, input().split()))

def linear_search(nums1, n1, key):
    nums1[n1] = key
    index = 0
    while nums1[index] != key:
        index += 1
    return index != n1

output = 0
nums1.append(None)
for key in nums2:
    if linear_search(nums1, n1, key):
        output += 1

print(output)

Submission status: Accepted

Solution code:
n = int(input())
str = input().split(" ")
S = [int(str[i]) for i in range(n)]
q = int(input())
str = input().split(" ")
T = [int(str[i]) for i in range(q)]

S_set = set(S)
S = list(S_set)
T.sort()

result = 0

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

print(result)

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(1 for i in t if i in s))

Submission status: Accepted

Solution code:
from collections import deque
import sys
input = sys.stdin.readline

_ = int(input())
S = [int(i) for i in input().strip().split()]
_ = int(input())
T = [int(i) for i in input().strip().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()))
cnt = 0
for i in range(q) :
    if T[i] in S :
        cnt += 1
print(cnt)

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S_len = int(input().rstrip())
S = input().rstrip().split(" ")
T_len = int(input().rstrip())
T = input().rstrip().split(" ")

cnt = 0
for t in T:
    cnt += t in S
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()))
ans = 0

for num in T:
    if num 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 = 0
for num in t:
    if num in s:
        c += 1

print(c)

Submission status: Accepted

Solution code:
n = int(input())
S = set(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:
def main():
    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):
        if i == 0:
            if S[i] in T:
                cnt += 1
                continue
        if (S[i] in T) and (S[i] != S[i-1]):
            cnt += 1

    return cnt

print(main())

Submission status: Accepted

Solution code:
N1=int(input())
array1=input().split()
N2=int(input())
array2=input().split()
c=0
for n2 in range(N2):
    if array2[n2] in array1:
        c+=1
print(c)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
  def linearSearch(t):
    S.append(t)
    #print(S)
    i=0
    while S[i]!=t:
      i+=1
    del S[n]
    return 1 if i!=n else 0

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

  ans=0
  for t in T:
    ans+=linearSearch(t)
    #print(t,ans)
  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 = list(set(S))

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

Submission status: Accepted

Solution code:
#coding:utf-8
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()))

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

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()))
    
    # 集合的なら
    # res = len(set(s) & set(p))
    # print(res)
    # 線形探索なら
    cnt = 0
    for i in t:
        if i in s:
            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()))
ans = 0
for i in T:
    if i in S:
        ans += 1
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()]
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:
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()]

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

C = 0

for i in S:
    if i in T:
        C += 1
        T.remove(i)
        
print(C)

Submission status: Accepted

Solution code:
_ = int(input())
S = list(map(int, input().split()))
_ = 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 resolve():
    N = int(input())
    S = [int(i) for i in input().split()]
    int(input())
    T = [int(i) for i in input().split()]

    ans = 0
    # S.append(-1)
    for t in T:
        for s in S:
            if s == t:
                ans += 1
                break
        # i = 0
        # S[N] = t
        # while S[i] != t:
        #     i += 1
        # if i != N:
        #     ans += 1
    print(ans)


resolve()

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

print(cnt)

Submission status: Accepted

Solution code:
from typing import Set, List


def linear_search_v1(S: List[int], key: int) -> int:
    for num in S:
        if num == key:
            return 1
    return 0


def linear_search_v2(S: List[int], key: int) -> int:
    i: int = 0
    S.append(key)

    while S[i] != key:
        i += 1

    if i != len(S) - 1:
        return 1
    else:
        return 0


def main_v1():
    _ = input()
    S: List[int] = list(map(int, input().split()))
    _ = input()
    T: List[int] = list(map(int, input().split()))
    count: int = 0

    for num in T:
        # count += linear_search_v1(S, num)
        count += linear_search_v2(S[:], num)

    print(count)


def main_v2():
    _ = input()
    S: Set[int] = set(map(int, input().split()))
    _ = input()
    T: List[int] = list(map(int, input().split()))
    count: int = 0

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

    print(count)


if __name__ == "__main__":
    main_v2()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ALDS1_4_A.py
_ = int(input())
S = list(map(int,input().split()))
_ = int(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()))

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

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

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

Submission status: Accepted

Solution code:
n = int(input())
S = list(map(int,input().split()))
p = 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()))
c = 0
for t in T:
    for s in S:
        if s == t:
            c += 1
            break
print(c)

Submission status: Accepted

Solution code:
from collections import deque

def linersearch(A,n,key):
    i = 0
    A.append(key)
    while A[i] != key:
        i += 1
    if i == n:
        A.pop()
        return False
    else:
        A.pop()
        return True

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

for q in T:
    if linersearch(S,n,q):
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
import sys, collections
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    n = I()
    S = LI()
    q = I()
    T = LI()

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

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
import collections

def main():
  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)


if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
#素直な実装
N = int(input())
num_list = list(map(int, input().split()))
q = int(input())
search_num = list(map(int,input().split()))
ans = 0
for i in search_num:
    if i in num_list:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

n = int(input())
a = list(map(int,input().split()))
t = int(input())
u = list(map(int,input().split()))
cnt = 0
for i in range(len(u)):
    for j in range(len(a)):
        if a[j] == u[i]:
            cnt += 1
            break
print(cnt)

Submission status: Accepted

Solution code:
from sys import stdin

n = input()
S = stdin.readline().split()
q = input()
T = stdin.readline().split()

count = 0
for a in T:
    for b in S:
        if b == a:
            count += 1
            break

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
slist = list(map(int, input().split()))
q = int(input())
tlist = list(map(int, input().split()))

cnt = 0
for t in tlist:
    for s in slist:
        if t == s:
            cnt += 1
            break

print(cnt)

Submission status: Accepted

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

count = 0

for i in t:
    if i in s:
        count += 1
    else:
        continue

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()))
answer=0

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

else:
    for i in range(n):
        if S[i] in T:
            answer+=1

print(answer)

Submission status: Accepted

Solution code:
from collections import deque
import sys


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

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

    print(count)

Submission status: Accepted

Solution code:
def binary_search(a,n,key):
  left = 0
  right = n
  while left < right:
    mid = (left + right) // 2
    if a[mid] == key:
      return 1
    elif key < a[mid]:
      right = mid
    else:
      left = mid + 1
  return 0

n1 = int(input())
s1 = list(map(int,input().split()))
s1.sort()
n2 = int(input())
s2 = list(map(int,input().split()))
i = 0
cnt = 0
while i < n2:
  cnt += binary_search(s1,n1,s2[i])
  i += 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()))
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()))

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

Submission status: Accepted

Solution code:
n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))
S = set()
S.update(s)
#print(S)
#print(t)
cnt = 0
for i in t:
	if s.count(i) !=0:
		cnt = cnt +1

print(cnt)

Submission status: Accepted

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

c = 0
for ti in t:
    if ti in s:
        c +=1

print(c)

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:
# coding: utf-8
# 線形探索


def linearSearch(target, data_list):
    for data in data_list:
        if target == data:
            return 1

    return 0


if __name__ == "__main__":
    n = int(input())
    S = [int(i) for i in input().split()]
    q = int(input())
    T = [int(j) for j in input().split()]

    total = 0

    for target in T:
        total += linearSearch(target, S)

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

ans = 0

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

print(ans)

Submission status: Accepted

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

def main(n,s,q,t):
    c = 0
    for j in t:
        for i in s:
            if(i == j):
                c += 1
                break

    return c

def main2(n,s,q,t):
    c=0
    for tj in t:
        s.append(tj)
        i=0
        while(s[i]!=tj):
            i+=1
        if(i<n):
            c+=1
        s.pop()
    return c

def main3(n,s,q,t):
    sets = set(s)
    sett = set(t)
    return (len((sets & sett)))

if __name__=='__main__':
    n,s,q,t = readinput()
    ans = main3(n,s,q,t)
    print(ans)

Submission status: Accepted

Solution code:
n = int(input())
S = input().split()
q = int(input())
T = input().split()
count = 0
for i in range(q):
    if T[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 s in S:
    for i in range(q):
        if s == T[i]:
            C += 1
            del T[i]
            q += -1
            break
print(C)

Submission status: Accepted

Solution code:
from typing import  Any, Sequence

def linerSearch(A: Sequence, K: int) -> int:
    global cnt
    N = len(S)
    for i in range(N):
        if A[i] == K:
            cnt += 1
    return  0



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

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

cnt = 0

for i in T:

    linerSearch(S, i)

print(cnt)

Submission status: Accepted

Solution code:
from sys import stdin

def linearSearch(target:list, value):
    target_copy = target.copy()
    target_copy.append(value)
    i = 0
    while target_copy[i] != value:
        i += 1
    if i == len(target_copy) - 1:
        return False
    return True

def main():
    n = stdin.readline()
    s = list(map(int, stdin.readline().split()))
    q = stdin.readline()
    t = list(map(int, stdin.readline().split()))
    print(sum([1 for v in t if linearSearch(s, v)]))
        
main()

Submission status: Accepted

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

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

print (i)

Submission status: Accepted

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

def Search(data, value):
    for i in range(len(data)):
           if data[i] == value:
               return i
    return -1
    
for j in range(q):
    if Search(S, T[j])  > -1:
        x.append(Search(S, T[j]))
print(len(x))

Submission status: Accepted

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

#%%
cnt = 0
for si in s:
    if si in t:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int,input().split()))
q = int(input())
l1 = list(map(int,input().split()))
s = 0
for i in l1:
  if i in l:
    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()))

def linearSearch(t):
  i = 0
  tmp = S + [t]
  while tmp[i] != t:
    i += 1
  if i == n:
    return "Not Found"
  return i

cnt = 0
for t in T:
  idx = linearSearch(t)
  if idx != 'Not Found':
    cnt += 1
    
print(cnt)

Submission status: Accepted

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

count = 0
for s in S:
    if s in T:
        count += 1
        T.remove(s)

print(count)

Submission status: Accepted

Solution code:
n = int(input())
s = [int(_) for _ in input().split()]
q = int(input())
t = [int(_) for _ 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:
# https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_4_A
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

C = 0
for t in T:
    for s in S:
        if s == t:
            C = 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(q):
    for j in range(n):
        if t[i] == s[j]:
            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()))

def sentinel_linear_search(lst, value):
    idx = 0
    while lst[idx] != value:
        idx += 1
        if idx == len(lst)-1:
            return 0
    return 1

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

ans = 0
for i in T:
    if i 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()))

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

print(str(cnt))

Submission status: Accepted

Solution code:
n = int(input())
S = set(list(map(int, input().split())))
q = int(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()))
S.append(0)
ans = 0
for i in range(q):
    j = 0
    key = (T[i])
    S[n] = key
    while S[j] != key:
        j += 1
    if j != n:
        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()))

counter=0
for i in range(q):
    #counter+=S.count(T[i])
    if T[i] in S:
        counter+=1
print(counter)