Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input().split()
q=int(input())
t=input().split()
cnt=0

left=0
right=n
for i in range(t):
    while left<right:
        mid=(left+right)/2
        if s[mid]==t[i]:
            return cnt+=1
        elif s[mid]>t[i]:
            right=mid
        else:
            left=mid+1
            
            
print(cnt)



Fixed submission:
n=int(input())
S=input().split()
q=int(input())
T=input().split()

S=list(map(int,S))
T=list(map(int,T))

cnt=0

for i in range(q):
	left=0
	right=n-1
	while left<=right:
		mid=int((left+right)/2)
		if S[left]>T[i] and S[right]<T[i]:
			break
		if S[mid]==T[i]:
			cnt+=1
			break
		elif S[mid]>T[i]:
			right=mid-1
		elif S[mid]<T[i]:
			left=mid+1

print(cnt)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input().split()
q=int(input())
t=input().split()
cnt=0

left=0
right=n
for i in range(t):
    while left<right:
        mid=(left+right)/2
        if s[mid]==t[i]:
            cnt+=1
        elif s[mid]>t[i]:
            right=mid
        else:
            left=mid+1
            
            
print(cnt)


Fixed submission:
n=int(input())
S=input().split()
q=int(input())
T=input().split()

S=list(map(int,S))
T=list(map(int,T))

cnt=0

for i in range(q):
	left=0
	right=n-1
	while left<=right:
		mid=int((left+right)/2)
		if S[left]>T[i] and S[right]<T[i]:
			break
		if S[mid]==T[i]:
			cnt+=1
			break
		elif S[mid]>T[i]:
			right=mid-1
		elif S[mid]<T[i]:
			left=mid+1

print(cnt)

Buggy python submission (verdict: Runtime Error):
#16D8103010K Ko Okasaki
#ALDS4_B

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

Q=list(map(int,Q))
S=list(map(int,S))

cnt=1

for i in range(q):
	left=0
	right=n-1
	while left<=right:
		mid=int((n-1)/2)
		if S[mid]==Q[i]:
			cnt+=1
			break
		elif S[mid]>Q[i]:
			right=mid
		elif S[mid]<Q[i]:
			left=mid

print(cnt)



Fixed submission:
n=int(input())
S=input().split()
q=int(input())
T=input().split()

S=list(map(int,S))
T=list(map(int,T))

cnt=0

for i in range(q):
	left=0
	right=n-1
	while left<=right:
		mid=int((left+right)/2)
		if S[left]>T[i] and S[right]<T[i]:
			break
		if S[mid]==T[i]:
			cnt+=1
			break
		elif S[mid]>T[i]:
			right=mid-1
		elif S[mid]<T[i]:
			left=mid+1

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
Q=input().split()
q=int(input())
S=input().split()

Q=list(map(int,Q))
S=list(map(int,S))

cnt=0

for i in range(q):
	left=0
	right=n-1
	while left<=right:
		mid=int((n-1)/2)
		if S[mid]==Q[i]:
			cnt+=1
			break
		elif S[mid]>Q[i]:
			right=mid
		elif S[mid]<Q[i]:
			left=mid

print(cnt)


Fixed submission:
n=int(input())
S=input().split()
q=int(input())
T=input().split()

S=list(map(int,S))
T=list(map(int,T))

cnt=0

for i in range(q):
	left=0
	right=n-1
	while left<=right:
		mid=int((left+right)/2)
		if S[left]>T[i] and S[right]<T[i]:
			break
		if S[mid]==T[i]:
			cnt+=1
			break
		elif S[mid]>T[i]:
			right=mid-1
		elif S[mid]<T[i]:
			left=mid+1

print(cnt)

Buggy python submission (verdict: Runtime Error):
n=int(input())
S=input().split()
q=int(input())
T=input().split()

S=list(map(int,S))
T=list(map(int,T))

cnt=0

for i in range(q):
	left=0
	right=n-1
	while left<right:
		mid=int((left+right)/2)
		if S[mid]==T[i]:
			cnt+=1
			break
		elif S[mid]>T[i]:
			right=mid
		else:
			left=mid

print(cnt


Fixed submission:
n=int(input())
S=input().split()
q=int(input())
T=input().split()

S=list(map(int,S))
T=list(map(int,T))

cnt=0

for i in range(q):
	left=0
	right=n-1
	while left<=right:
		mid=int((left+right)/2)
		if S[left]>T[i] and S[right]<T[i]:
			break
		if S[mid]==T[i]:
			cnt+=1
			break
		elif S[mid]>T[i]:
			right=mid-1
		elif S[mid]<T[i]:
			left=mid+1

print(cnt)