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:
if __name__ == '__main__':
    n = int(input())
    S = input().split()
    q = int(input())
    T = input().split()
    a = []
    count = 0
    for i in range(q):
        for j in range(n):
            if int(T[i]) == int(S[j]): 
                if T[i] in a: break
                else :
                    a.append(T[i])
                    count += 1
                    break
    print(str(count))

Submission status: Accepted

Solution code:
def main():
    _ = int(input())
    ns = list(map(int, input().split(' ')))
    _ = int(input())
    qs = list(map(int, input().split(' ')))
    count = 0
    for q in qs:
        for n in ns:
            if n == q:
                count += 1
                break
    print(count)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import collections


if __name__ == "__main__":
    S_num = int(input())
    S = collections.Counter(set(map(lambda x: int(x), input().split())))
    T_num = int(input())
    T = list(map(lambda x: int(x), input().split()))

    print(f"{sum(map(lambda x: S[x], 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 linearSearch(S, T):
    c = 0
    for i in range(len(T)):
        for j in range(len(S)):
            if S[j] == T[i]:
                c += 1
                break
    return c

r = linearSearch(S, T)
print(r)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

cnt = []
for i in s:
    if i in t:
        cnt.append(i)
print(len(set(cnt)))

Submission status: Accepted

Solution code:
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    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()))
    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()))

c=0

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

Submission status: Accepted

Solution code:
from collections import Counter
from sys import stdin
N = int(stdin.readline().rstrip())
S = Counter(int(_) for _ in stdin.readline().rstrip().split())
Q = int(stdin.readline().rstrip())
T = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 0
for i in T:
    if i in S:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n = int(raw_input())
    S = map(int, raw_input().split())
    S.append(0)
    q = int(raw_input())
    T = map(int, raw_input().split())
    cnt = 0
    for x in T:
        S[n] = x
        i = 0
        while S[i] != x:
            i += 1
        if i != n:
            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 i in t:
    if i in s:
        cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
v = list(map(int,input().split()))
q = int(input())
w = list(map(int,input().split()))
for i in v:
    for j in range(len(w)):
        if w[j]==i:
            del w[j]
            break
print(q-len(w))

Submission status: Accepted

Solution code:
from enum import Enum
from queue import Queue
import collections

import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

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

ans = 0
for key in T:
    if key in S:
        ans += 1
print("%d"%(ans))

Submission status: Accepted

Solution code:
class Search():
    def __init__(self,N,input_S):
        self.sum = 0
        self.N = N
        self.input_S = input_S
        input_S.append(0)
    def search(self,key):
        self.input_S[self.N] = key
        i = 0
        while(self.input_S[i]!=key):
            i += 1
        if i != self.N:
            self.sum += 1
def main():
    N = int(input())
    input_S = [int(i) for i in input().split()]
    M = int(input())
    input_T = [int(i) for i in input().split()]
    linear_search = Search(N,input_S)
    for i in range(len(input_T)):
        linear_search.search(input_T[i])
    print(linear_search.sum)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
As = list(map(int, input().split()))
q = int(input())
Ts = list(map(int, input().split()))

ans = 0
for T in Ts:
    for A in As:
        if T == A:
            ans += 1
            break
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 v in T:
    if v in S:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
s_list = list(map(int, input().split()))
q = int(input())
t_list = list(map(int, input().split()))

count = 0
for t in t_list:
    for s in s_list:
        if s == t:
            count = count + 1
            break

print(count)

Submission status: Accepted

Solution code:
def solve():
    n = int(input())
    S = [int(s) for s in input().split(' ') if s]
    q = int(input())
    T = [int(s) for s in input().split(' ') if s]
    ret = 0
    for t in T:
        if t in S:
            ret += 1

    print(ret)
    
solve()

Submission status: Accepted

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

print(sum(x in s for x in arr))

Submission status: Accepted

Solution code:
n = int(input())
numsA = list(map(int, input().split()))
q = int(input())
numsB = list(map(int, input().split()))
count = 0

# for i in range(n):
#     for j in range(q):
#         if numsB[j] == numsA[i]:
#             count += 1
#             break

for i in range(q):
    for j in range(n):
        if numsB[i] == numsA[j]:
            count += 1
            break

print(count)

Submission status: Accepted

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

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def linear_search_2(sequence, key):
    i = 0
    sequence_guard = sequence[:]
    sequence_guard.append(key)

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

    if i == len(sequence):
        return "NOT_FOUND"

    return i



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

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

cnt = 0

for t in T:
    
    result = linear_search_2(S, t)
    
    if result == "NOT_FOUND":
        continue
    
    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()))
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=input().split()
q=int(input())
t=input().split()
ans=0

for i in t:
    for j in s:
        if i==j:
            ans=ans+1
            break

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


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

print(c)

Submission status: Accepted

Solution code:
n=int(input())
N = list(map(int, input().split()))
q = int(input())
Q = list(map(int, input().split()))

ct = 0
for i in range (q):
  for j in range (n):
    if Q[i] == N[j]:
      ct += 1
      break
print(ct)

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
S.append(0)

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

for t in T:
  count += linearSearch(t)
print(count)

Submission status: Accepted

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

n2 = int(input())
b = list(map(int, input().split()))
b = set(b)

count = 0
for i in a:
    for j in b:
        if i == j:
            count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def _main():
  N = int(input())
  lst = list(map(int, input().split()))
  K = int(input())
  key_lst = list(map(int, input().split()))

  ans = 0
  for k in range(K):
    if search(lst, key_lst[k]): ans += 1

  print(ans)

def search(lst, key):
  lst.append(key)
  i = 0
  while lst[i] != key:
    i += 1
  lst.pop()
  return len(lst) != i

if __name__ == '__main__':
  _main()

Submission status: Accepted

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


def linearSearch(A, k):
    for a in A:
        if a == k:
            return True
    return False


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

Submission status: Accepted

Solution code:
count = 0
n1 = int(input())
s = list(map(int, input().split()))
n2 = int(input())
t = list(map(int, input().split()))
used = []
for tt in t:
  for ss in s:
    if tt == ss and tt not in used:
      used.append(tt)
      count += 1

print(count)

Submission status: Accepted

Solution code:
n = input()
list_S = input().split()

m = input()
list_T = input().split()

print(*[sum(1 for t in list_T if t in list_S)])

Submission status: Accepted

Solution code:
input()
s = [int(i) for i in input().split()]
input()
t = [int(i) for i in input().split()]
sd, td = {}, {}
for i in s:
    if i in sd:
        sd[i] += 1
    else:
        sd[i] =1
for i in t:
    if i in td:
        td[i] += 1
    else:
        td[i] =1
c = 0
for i in td.keys():
    if i in sd.keys():
        c += 1
print(c)

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

Solution code:

def linear_search(target, nums):
    for num in nums:
        if num == target:
            return True
    return False

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

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    N = int(input())
    S = list(map(int, input().split()))
    S.extend([-1, float('inf')])
    S.sort()
    # print(S)
    Q = int(input())
    T = list(map(int, input().split()))
    ans = 0
    for ti in T:
        for sj in S:
            if sj==ti:
                ans += 1
                break

    print(ans)

Submission status: Accepted

Solution code:
input()
a=list(map(int,input().split()))
n=int(input())
b=list(map(int,input().split()))
d={}


def s(bannpei):
    i=0
    c=b+[bannpei]
    while c[i]!=bannpei:
        i+=1
    if i==n:
        return False
    return True
for r in a:
    if s(r):
        d[r]=1
print(sum(d.values()))

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:
n=int(input())
list_n = list(map(int,input().split()))
q=int(input())
list_q=list(map(int,input().split()))
cnt=0
for i in list_q:
    if i in list_n:
        cnt +=1
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
q = int(input())
count = 0
b = [int(j) for j in input().split()]
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 = set(list(map(int, input().split())))
q = int(input())
T = set(list(map(int, input().split())))

print(len(S & T))

Submission status: Accepted

Solution code:
a1 = int(input())
a2 = list(map(int,input().split(" ")))
b1 = int(input())
b2 = list(map(int,input().split(" ")))

count = 0
for i in b2:
    a2.append(i)
    k = 0
    while True:
        if a2[k] == i:
            break
        k += 1
    if not k == len(a2)-1:
        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:
n = int(input())
SS = [int(i) for i in input().split()]
q = int(input())
TS = [int(i) for i in input().split()]


print(sum([1 for t in TS if t in SS]))

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

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


    n = int(input())
    a = input().split()
    a.append(None)
    q = int(input())
    t = input().split()

    sum_ = 0
    for key in t:
        if search(a, n, key):
            sum_ += 1
    print(sum_)

Submission status: Accepted

Solution code:
n1 = int(input())
nums1 = list(map(int, input().split(' ')))
n2 = int(input())
nums2 = list(map(int, input().split(' ')))
sum = 0
for i in range(n2):
    j = 0 
    nums1.append(nums2[i])
    while nums1[j] != nums2[i]:
        j += 1
    if j != n1:
        sum += 1
    nums1.pop()
print(sum)

Submission status: Accepted

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

n = int(input())
S = input().strip().split()

q = int(input())
T = input().strip().split()
count = 0
for i in range(len(T)):
    S.append(T[i])
    j = 0
    while S[j] != T[i]:
            j += 1
    if j != len(S[:-1]):
        count += 1
    S = S[:-1]
print(count)

Submission status: Accepted

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

ans = 0
for tt in t:
    for ss in s:
        if ss == tt:
            ans += 1
            break

print(ans)

Submission status: Accepted

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

print(len(s & t))

Submission status: Accepted

Solution code:
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:
#linear search
input()
S = set(input().split())
input()
s = set(input().split())
print(len(S & s))

Submission status: Accepted

Solution code:

def judge(array, key):
    if key in array:
        return True
    else :
        return False

s_length = int(input())
array_s = [int(i) for i in input().split()]
t_length = int(input())
array_t = [int(i) for i in input().split()]

cnt = 0
for i in range(t_length):
    key = array_t[i]
    if judge(array_s, key):
        cnt += 1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
n = int(input().rstrip())
S = list(map(int,input().rstrip().split()))
q = int(input().rstrip())
T = list(map(int,input().rstrip().split()))
count = 0
for i in range(q):
    if T[i] in S:
        count+=1

print(count)

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

Solution code:
num = int(input())
array = input().split()
 
num2 = int(input())
array2 = input().split()
 
count = 0
for i in range(num2):
        if array2[i] in array:
                count += 1
 
print(count)

Submission status: Accepted

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

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

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

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

print(cnt)

Submission status: Accepted

Solution code:
n=int(input())
A=list(map(int,input().split()))
m=int(input())
B=list(map(int,input().split()))
cnt=0
for i in B:
    for j in A:
        if i==j:
            cnt+=1
            break
            
print(cnt)

Submission status: Accepted

Solution code:
l=[]
for _ in range(4):l+=[set(input().split())]
print(len(l[1]&l[3]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin

stdin.readline().rstrip()
S = [int(x) for x in stdin.readline().rstrip().split()]
S.sort()
stdin.readline().rstrip()
T = [int(x) for x in stdin.readline().rstrip().split()]

C = 0
for ti in T:
    for si in S:
        if ti == si:
            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()]

count = 0
index = []
for i in range(n):
    for j in range(q):
        if s[i]==t[j]:
            for k in range(len(index)):
                if t[j]==index[k]:
                    break
            else:
                count += 1
                index.append(t[j])
            
print(count)

Submission status: Accepted

Solution code:
import sys

def InputData():

    data_len = int(input())
    # data = input().split()
    data = list(map(int, input().split()))

    searchdata_len = int(input())
    # searchdata = input().split()
    searchdata = list(map(int, input().split()))

    # data = int(data)
    # searchdata = int(searchdata)

    return data_len, data, searchdata_len, searchdata

def Liner_Search(data, key):

    contained_cnt = 0
    # for i in range(searchdata_len):
    for i in range(len(data)):
        if key == data[i]:
            return 1
    
    # return contained_cnt
    return "NOT_FOUND"

def PrintOut(contained_cnt):
    print(int(contained_cnt))

def main():
    [data_len, data, searchdata_len, searchdata] = InputData()
    count = 0
    for i in searchdata:
        if Liner_Search(data, i)  != "NOT_FOUND":
            count += 1
    
    PrintOut(count)

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()))
S = sorted(S)
T = sorted(T)
reg = 0
count = 0
for i in range(q):
    for j in range(reg, n):
        if T[i] > S[j]:
            reg = j
        elif T[i] == S[j]:
            reg = j
            count += 1
            break
        else:
            break
print(count)

Submission status: Accepted

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

"""
線形探索
"""

N = int(input())
sN = list(map(int, input().split()))
Q = int(input())
tQ = list(map(int, input().split()))

sN = list(set(sN))

cnt = 0
for i in range(Q):
    for j in range(len(sN)):
        if tQ[i] == sN[j]:
            cnt += 1
            # 見つかったらiQ[i]についてこれ以上調べることない
            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 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()))
#print(T)
cnt = 0
for x in T:
    for q in S:
        #print(str(x) + " " + str(q))
        if x==q:
            cnt += 1
            break
            
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:
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:
import sys

sys.stdin.readline()
s = set(map(int, sys.stdin.readline().split()))
sys.stdin.readline()

print(sum(
    t in s
    for t in map(int, sys.stdin.readline().split())
))

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:
def main():
    input()
    s = [int(i) for i in input().split()]
    input()
    t = [int(i) for i in input().split()]
    print(sum([i in s for i in t]))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_A&lang=jp
#  Linear Search : python3
#  2018.12.08 yonezawa


#from collections import deque
import sys
input = sys.stdin.readline
#import cProfile

def main():
    n1 = int(input())
    s1 = set(map(int,input().split()))
    n2 = int(input())
    s2 = set(map(int,input().split()))
    print (len(s1 & s2))

if __name__ == '__main__':
   main()
#    pr = cProfile.Profile()
#    pr.runcall(main)
#    pr.print_stats()

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

Submission status: Accepted

Solution code:
#-*- coding: utf-8 -*-
# O(log(n)) + O(n+q) = O(n)
def get_set3(S:list, T:list):
    D:dict = {}
    C = []
    for s in S:
        D[s] = 1
    for t in T:
        if t in D.keys() and D[t] == 1:
            D[t] = 2
            C.append(t)
    return C

def input_array():
    n = int(input())
    S = list(map(int, input().split()))
    return S


if __name__ == '__main__':
    S = input_array()
    T = input_array()
    ret = get_set3(S, T)
    print(len(set(ret)))

Submission status: Accepted

Solution code:
#NOT_FOUND = 0
import copy

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

if __name__ == '__main__':
    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):
        isExist = linearSearch(n, copy.deepcopy(S), T[i])
        if isExist :
            C = C + 1
    print(C)

Submission status: Accepted

Solution code:
# coding: utf-8

def linear_search(key, A):
    for i, v in enumerate(A):
        if v == key:
            # print(v, key)
            return i
    return 'Not Found'

def linear_search_sentinel(key, A):
    i = 0
    n = len(A)
    A.append(key)
    while A[i] != key:
        i += 1
    if i == n:
        return 'Not Found'
    return i


if __name__ == "__main__":
    # n = 10
    # S = list(map(int, '5 6 7 8 9 10 1 2 3 4'.split()))
    # q = 7
    # T = list(map(int, '100 11 5 6 1 12 33'.split()))
    n = int(input())
    S = list(map(int, input().strip().split()))
    q = int(input())
    T = list(map(int, input().strip().split()))


    c = 0
    for k in T:
        if linear_search(k, S) != 'Not Found':
            c += 1
    print(c)

Submission status: Accepted

Solution code:
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/4/ALDS1_4_A


def solve():
    _ = int(input())
    S = set(map(int, input().split()))
    _ = int(input())
    T = set(map(int, input().split()))

    print(len(S & T))


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

cnt = 0
al = []
for s in S:
    for t in T:
        if s == t:

            if t not in al: 

                cnt += 1
            
            al.append(t)
print(cnt)

Submission status: Accepted

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



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

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()))
c=[]

for i in a:
	for j in b:
		if i==j and i not in c:
			c.append(i)
			
print(len(c))

Submission status: Accepted

Solution code:
n = int(input())
*S, = set(input().split())
q = int(input())
*T, = set(input().split())
cnt = 0
for i in range(q):
    cnt += S.count(T[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()))
counter=0
for t in T:
    if t in S:
        counter+=1
print(counter)

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=input()
S=input().split()

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

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

Submission status: Accepted

Solution code:
s_num=int(input())
s_list=list(map(int,input().split()))
q_num=int(input())
q_list=list(map(int,input().split()))
count = 0
a_list = []
for q in q_list:
    for s in s_list:
        if s == q:
            count += 1
            break

            
print(count)

Submission status: Accepted

Solution code:
n = int(input())
list_s = list((map(int, input().split())))
q = int(input())
list_t = list((map(int, input().split())))
ans = 0
for numbert in list_t:
    for numbers in list_s:
        if numbers == numbert:
            ans += 1
            break
        else:
            pass
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.stdin.readline()
s = set(map(int,sys.stdin.readline().split()))
sys.stdin.readline()
t = set(map(int,sys.stdin.readline().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()))
count = 0
for i in T:
    if i in S:
        count += 1
print(count)

Submission status: Accepted

Solution code:
#119
#ALDS1_4_A
n = input()
s = set(input().split())
m = input()
t = set(input().split())
print(len(s&t))

Submission status: Accepted

Solution code:
import sys

# Set max recursion limit
sys.setrecursionlimit(1000000)


def li_input():
    return [int(_) for _ in input().split()]


def main():
    n = int(input())
    S = li_input()
    q = int(input())
    T = li_input()

    ans = 0

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

    print(ans)


main()

Submission status: Accepted

Solution code:
_ , A = input(), input().split()
_, E = input(), input().split()

result = []
for e in E:
    for a in A:
        if e == a and e not in result:
            result.append(a)

print(len(result))

Submission status: Accepted

Solution code:
def main():
    input()
    ss = input().split()
    input()
    ts = input().split()

    nums = {}

    for t in ts:
        nums[t] = False

    for s in ss:
        if s in nums:
            nums[s] = True

    cnt = 0
    for val in nums.values():
        if val:
            cnt += 1

    print(cnt)

if __name__ == '__main__':
    main()