Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def prim(cost):
    sumcost = 0
    V = len(cost)
    mincost = [float('inf')] * V
    used = [False] * V
    mincost[0] = 0
    while True:
        v = -1
        for u in range(V):
            if not used[u] and (v == -1 or mincost[u] < mincost[ju):
                v = u
        if v == -1: break
        used[v] = True
        sumcost = sumcost + mincost[v]
        for u in range(V):
            if cost[u][v] == -1:
                continue
            mincost[u] = min(mincost[u], cost[v][u])
    return sumcost

Fixed submission:
def prim(cost):
    sumcost = 0
    V = len(cost)
    mincost = [float('inf')] * V
    used = [False] * V
    mincost[0] = 0
    while True:
        j = -1
        for i in range(V):
            if not used[i] and (j == -1 or mincost[i] < mincost[j]):
                j = i
        if j == -1:
            break
        used[j] = True
        sumcost = sumcost + mincost[j]
        for i in range(V):
            if cost[i][j] == -1:
                continue
            mincost[i] = min(mincost[i], cost[j][i])
    return sumcost
 
n = int(raw_input())
A = [0] * n
for i in range(n):
    A[i] = map(int, raw_input().split())
 
result = prim(A)
print(result)
Buggy python submission (verdict: Runtime Error):
 n=input()
for i in range(n):
    if i==0:
        num_1=input()
    elif i==1:
        num_2=input()
        maxv=num_2 - num_1
        MIN=min(num_1,num_2)
    else:
        num_3=input()
        if (num_3-MIN)>maxv:
            maxv=num_3-MIN
        if (num_3)<MIN:
            MIN=num_3
print(maxv)
 

Fixed submission:
n=input()
for i in range(n):
    if i==0:
        num_1=input()
    elif i==1:
        num_2=input()
        maxv=num_2 - num_1
        MIN=min(num_1,num_2)
    else:
        num_3=input()
        if (num_3-MIN)>maxv:
            maxv=num_3-MIN
        if (num_3)<MIN:
            MIN=num_3
print(maxv)
Buggy python submission (verdict: Runtime Error):
n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())
    
def solve(i, m):
  if m=0:
    return True
  if i>=n or m>sum(A):
    return False
  res=solve(i+1,m) or solve(i+1,m-A[i])
  return res
    
    
for m in M:
  if solve(0,m):
    print"yes"
  else:
    print"no"

Fixed submission:
n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())
    
def solve(i, m):
  if m==0:
    return True
  if i>=n or m>sum(A):
    return False
  res=solve(i+1,m) or solve(i+1,m-A[i])
  return res
    
    
for m in M:
  if solve(0,m):
    print"yes"
  else:
    print"no"

Buggy python submission (verdict: Runtime Error):
n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())
    
def solve(i, m):
  if m=0:
    return True
  if i>=n or m>sum(A):
    return False
  res=solve(i+1,m) or solve(i+1,m-A[i])
  return res
    
    
for m in M:
  if solve(0,m):
    print"yes"
  else:
    print"no"

Fixed submission:
n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())
    
def solve(i, m):
  if m==0:
    return True
  if i>=n or m>sum(A):
    return False
  res=solve(i+1,m) or solve(i+1,m-A[i])
  return res
    
    
for m in M:
  if solve(0,m):
    print"yes"
  else:
    print"no"

Buggy python submission (verdict: Runtime Error):
def solve(i, j):
    if i = 0:
        return True
    if j < n and A[0] <= i <= sum(A[j:]):
        x = solve(i-A[j], j+1)
        if x:
            return x
        y = solve(i, j+1)
        if y:
            return y
 
n = input()
A = sorted(map(int, raw_input().split()))
p = input()
m = map(int, raw_input().split())
 
for k in m:
    if solve(k, 0):
        print "yes"
    else:
        print "no"

Fixed submission:
n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())
    
def solve(i, m):
  if m==0:
    return True
  if i>=n or m>sum(A):
    return False
  res=solve(i+1,m) or solve(i+1,m-A[i])
  return res
    
    
for m in M:
  if solve(0,m):
    print"yes"
  else:
    print"no"
Buggy python submission (verdict: Runtime Error):
w,h,x,y,r = map(int,raw_input().split())
 
if x<r:
 print 'No'
elif y<r:
 print'No'
elif w-x<r:
 print 'No'
elif h-y<r:
 print 'No'
else :
print 'Yes'

Fixed submission:
W, H, x, y, r = map(int, raw_input().split())
 
if x < r or x + r > W or y < r or y + r >H:
  print "No"
else:
 print "Yes"
Buggy python submission (verdict: Runtime Error):
a=1
while 1:
    x=int(raw_input())
    if x==0:
        break
    print "Case %d: %d" % (a,x)
    cnt+=1;

Fixed submission:
a=1
while 1:
    x=int(raw_input())
    if x==0:
        break
    print "Case %d: %d" % (a,x)
    a+=1;
Buggy python submission (verdict: Runtime Error):
a,b = map(double, raw_input().split())
int x,y
double z
x=a/b
y=a%b
z=a/b
print x y z

Fixed submission:
a,b=map(int,raw_input().split())
print ('%d %d %f' % (a/b,a%b,float(a)/b))
Buggy python submission (verdict: Runtime Error):
r=map(int,raw_input().split())
print ('%f %f' % (float2*??*r,floatr*r*??)

Fixed submission:
import math
r = float(raw_input())
print "%f %f" % (math.pi* r*r, math.pi*r*2)

Buggy python submission (verdict: Runtime Error):
r=map(int,raw_input().split())
print ('%f %f' (float2*M_PI*r,floatr*r*M_PI)

Fixed submission:
import math
r = float(raw_input())
print "%f %f" % (math.pi* r*r, math.pi*r*2)

Buggy python submission (verdict: Runtime Error):
r=map(int,raw_input().split())
print ('%f %f' (float(2*M_PI*r),float(r*r*M_PI))

Fixed submission:
import math
r = float(raw_input())
print "%f %f" % (math.pi* r*r, math.pi*r*2)
Buggy python submission (verdict: Runtime Error):


while True:
    Input = raw_input().split()
 
    a  = int(Input[0])
    op = Input[1]
    b  = int(Input[2])
 
    if   op == "+":
        ans = a + b
        print ans
    elif op == "-":
        ans = a - b
        print ans
    elif op == "/":
        ans = a / b
        print ans
    elif op == "*":
        ans = a * b
        print ans
    elif op == "?":
        break
 

 
Compile Error Logs: 

You are not authorized to see the message. 
 
 
Status 
Judge: 5/5  Python  CPU: 00.01 sec  Memory: 6436 KB  Length: 376 B  2016-01-27 11:43  2016-01-27 11:43  
Results for testcases 
Case # Verdict CPU Time Memory In Out Case Name 
 Case #1: : Accepted  00.01 sec 6344 KB 12 B 2 B test_case_1 
 Case #2: : Accepted  00.01 sec 6384 KB 30 B 9 B test_case_2 
 Case #3: : Accepted  00.00 sec 6240 KB 178 B 69 B test_case_3 
  

Fixed submission:
while True:
    a, op, b = raw_input().split()
    if op == "?":
        break
    else:
        if op == '+':
            print int(a) + int(b)
        elif op == '-':
            print int(a) - int(b)
        elif op == '*':
            print int(a) * int(b)
        elif op == '/':
            print int(a) / int(b)
        else:
            print "error"

Buggy python submission (verdict: Runtime Error):
while True:
    Input = raw_input().split()
 
    a  = int(Input[0])
    op = Input[1]
    b  = int(Input[2])
 
    if   op == "+":
        ans = a + b
        print ans
    elif op == "-":
        ans = a - b
        print ans
    elif op == "/":
        ans = a / b
        print ans
    elif op == "*":
        ans = a * b
        print ans
    elif op == "?":
        break
 

 
Compile Error Logs: 

You are not authorized to see the message. 
 
 
Status 
Judge: 5/5  Python  CPU: 00.01 sec  Memory: 6436 KB  Length: 376 B  2016-01-27 11:43  2016-01-27 11:43  
Results for testcases 
Case # Verdict CPU Time Memory In Out Case Name 
 Case #1: : Accepted  00.01 sec 6344 KB 12 B 2 B test_case_1 
 Case #2: : Accepted  00.01 sec 6384 KB 30 B 9 B test_case_2 
 Case #3: : Accepted  00.00 sec 6240 KB 178 B 69 B test_case_3 
  

Fixed submission:
while True:
    a, op, b = raw_input().split()
    if op == "?":
        break
    else:
        if op == '+':
            print int(a) + int(b)
        elif op == '-':
            print int(a) - int(b)
        elif op == '*':
            print int(a) * int(b)
        elif op == '/':
            print int(a) / int(b)
        else:
            print "error"
Buggy python submission (verdict: Runtime Error):
n = input()
m = map(int,raw_input().split())
a = 0
for i in xrange(n):
    a += m[i]
 
print min(m),max(m),a
 

 
Compile Error Logs: 

You are not authorized to see the message. 
 
 
Status 
 

Fixed submission:
n = int(raw_input())
a = map(int, raw_input().split())
 
print min(a), max(a), sum(a)
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
 
print '',
for i in xrange(1, n+1):
    x = i
    if x % 3 == 0:
        print i,
    else:
        while x:
            if x % 10 == 3:
                print i,
                break

Fixed submission:
n = input()
 
print '',
for i in xrange(1, n+1):
    x = i
    if x % 3 == 0:
        print i,
    else:
        while x:
            if x % 10 == 3:
                print i,
                break
            x /= 10
Buggy python submission (verdict: Runtime Error):
n,m = map(int,raw_input().split())
a = []
b = []
 
for i in range(n):
    a.append(map(int, raw_input().split()))
for i in range(m):
    b.append(input())
for i in range(n):
    ans = 0
for j in range(m):
    ans += a[i][j]*b[j]
print ans:

Fixed submission:
n,m = map(int,raw_input().split())
a = []
b = []
 
for i in range(n):
  a.append(map(int, raw_input().split()))
for i in range(m):
  b.append(input())
for i in range(n):
  ans = 0
  for j in range(m):
    ans += a[i][j]*b[j]
  print ans
Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
matrix = []
for i in range(n):
    line = raw_input()
    splited = line.split(" ")
    splited = map(lambda x: int(x), splited)
    matrix.append(splited)

result = 0
candidate = 0
selected = [0]
for i in range(n):
    weight = 2001
    for item in selected:
        for j in range(n):
            if matrix[j][item] != -1 and matrix[j][item] < weight and j not in selected:
                candidate = j
                weight = matrix[j][item]
    selected.append(candidate)
    if(len(selected) == n + 1):
        break
    result += weight
print result

Fixed submission:
n = int(raw_input())
matrix = []
for i in range(n):
    line = raw_input()
    splited = line.split()
    splited = map(lambda x: int(x), splited)
    matrix.append(splited)

result = 0
candidate = 0
selected = [0]
for i in range(n):
    weight = 2001
    for item in selected:
        for j in range(n):
            if matrix[j][item] != -1 and matrix[j][item] < weight and j not in selected:
                candidate = j
                weight = matrix[j][item]
    selected.append(candidate)
    if(len(selected) == n + 1):
        break
    result += weight
print result
Buggy python submission (verdict: Runtime Error):
def bubbleSort(A, N):
    flag = 1
    count = 0
    while flag == 1:
        flag = 0
        for i in range(1, N)[::-1]:
            if A[j] < A[j - 1]:
                tmp = A[j]
                A[j] = A[j - 1]
                A[j - 1] = tmp
                flag = 1
                count += 1

    print(" ".join(map(str, A)))
    print(count)

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

bubbleSort(A, n)

Fixed submission:
def bubbleSort(A, N):
    flag = 1
    count = 0
    while flag == 1:
        flag = 0
        for i in range(1, N)[::-1]:
            if A[i] < A[i - 1]:
                tmp = A[i]
                A[i] = A[i - 1]
                A[i - 1] = tmp
                flag = 1
                count += 1

    print(" ".join(map(str, A)))
    print(count)

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

bubbleSort(A, n)
Buggy python submission (verdict: Runtime Error):
def SelectionSort(A):
    for i in range(len(A)):
        minj = i
        for j in range(i, range(A)):
            if A[j] < A[minj]:
                minj = j
        A[i], A[minj] = A[minj], A[i]


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

SelectionSort(A)

Fixed submission:
def SelectionSort(A):
    count = 0
    for i in range(len(A)):
        minj = i
        for j in range(i, len(A)):
            if A[j] < A[minj]:
                minj = j
        if i != minj:
            A[i], A[minj] = A[minj], A[i]
            count += 1
    print(" ".join(map(str, A)))
    print(count)


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

SelectionSort(A)

Buggy python submission (verdict: Runtime Error):
def SelectionSort(A):
    count = 0
    for i in range(len(A)):
        minj = i
        for j in range(i, range(A)):
            if A[j] < A[minj]:
                minj = j
        A[i], A[minj] = A[minj], A[i]
        count += 1
    print(" ".join(map(str, A)))
    print(count)


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

SelectionSort(A)

Fixed submission:
def SelectionSort(A):
    count = 0
    for i in range(len(A)):
        minj = i
        for j in range(i, len(A)):
            if A[j] < A[minj]:
                minj = j
        if i != minj:
            A[i], A[minj] = A[minj], A[i]
            count += 1
    print(" ".join(map(str, A)))
    print(count)


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

SelectionSort(A)
Buggy python submission (verdict: Runtime Error):
n = int(input())
list = []
for _ in range(n):
    command = input().split()
    if command[0] == 'insert':
        num = int(command[1])
        list.insert(0, num)
    elif command[0] == 'delete':
        num = int(command[1])
        list.remove(num)
    elif command[0] == 'deleteFirst':
        list.pop(0)
    elif command[0] == 'deleteLast':
        list.pop()

print(" ".join(map(str, list)))

Fixed submission:
from collections import deque
import sys

dq = deque()
num = int(sys.stdin.readline())
line = sys.stdin.readlines()

for i in range(num):

    order = line[i].split()

    if order[0] == 'insert':
        dq.appendleft(order[1])
    elif order[0] == 'deleteFirst':
        dq.popleft()
    elif order[0] == 'deleteLast':
        dq.pop()
    else:
        if order[1] in dq:
            dq.remove(order[1])

print(' '.join(dq))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list = []
for _ in range(n):
    command = input().split()
    if command[0] == 'insert':
        num = int(command[1])
        list.insert(0, num)
    elif command[0] == 'delete':
        num = int(command[1])
        try:
            list.remove(num)
        except:
            pass
    elif command[0] == 'deleteFirst':
        list.pop(0)
    elif command[0] == 'deleteLast':
        list.pop()

print(" ".join(map(str, list)))

Fixed submission:
from collections import deque
import sys

dq = deque()
num = int(sys.stdin.readline())
line = sys.stdin.readlines()

for i in range(num):

    order = line[i].split()

    if order[0] == 'insert':
        dq.appendleft(order[1])
    elif order[0] == 'deleteFirst':
        dq.popleft()
    elif order[0] == 'deleteLast':
        dq.pop()
    else:
        if order[1] in dq:
            dq.remove(order[1])

print(' '.join(dq))

Buggy python submission (verdict: Runtime Error):
dq = deque()
num = int(sys.stdin.readline())
line = sys.stdin.readlines()

for i in range(num):

    order = line[i].split()

    if order[0] == 'insert':
        dq.appendleft(order[1])
    elif order[0] == 'deleteFirst':
        dq.popleft()
    elif order[0] == 'deleteLast':
        dq.pop()
    else:
        if order[1] in dq:
            dq.remove(order[1])

print(' '.join(dq))

Fixed submission:
from collections import deque
import sys

dq = deque()
num = int(sys.stdin.readline())
line = sys.stdin.readlines()

for i in range(num):

    order = line[i].split()

    if order[0] == 'insert':
        dq.appendleft(order[1])
    elif order[0] == 'deleteFirst':
        dq.popleft()
    elif order[0] == 'deleteLast':
        dq.pop()
    else:
        if order[1] in dq:
            dq.remove(order[1])

print(' '.join(dq))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))

count = 0
for item in t:
    middle = int((n - 1) / 2)
    upper = n - 1
    lower = 0
    while(True):
        if s[middle] == item:
            count += 1
            break
        elif upper == lower:
            break
        elif s[middle] > item:
            upper = middle
            middle = int((lower + middle) / 2)
        elif s[middle] < item:
            lower = middle
            middle = int((upper + middle) / 2)

print(count)

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

count = 0
for item in t:
    middle = int((n - 1) / 2)
    upper = n - 1
    lower = 0
    while(True):
        if s[middle] == item:
            count += 1
            break
        elif lower >= upper:
            break
        elif s[middle] > item:
            upper = middle
            middle = int((lower + lower) / 2)
        elif s[middle] < item:
            lower = middle + 1
            middle = int((upper + lower) / 2)

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))

count = 0
for item in t:
    middle = int((n - 1) / 2)
    upper = n - 1
    lower = 0
    while(True):
        if s[middle] == item:
            count += 1
            break
        elif upper == lower:
            break
        elif s[middle] > item:
            upper = middle
            middle = int((lower + middle) / 2)
        elif s[middle] < item:
            lower = middle
            middle = int((upper + middle) / 2)

print(count)

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

count = 0
for item in t:
    middle = int((n - 1) / 2)
    upper = n - 1
    lower = 0
    while(True):
        if s[middle] == item:
            count += 1
            break
        elif lower >= upper:
            break
        elif s[middle] > item:
            upper = middle
            middle = int((lower + lower) / 2)
        elif s[middle] < item:
            lower = middle + 1
            middle = int((upper + lower) / 2)

print(count)
Buggy python submission (verdict: Runtime Error):
def gcd_loop(a,b):
    if a < 0: a = -a
    if b < 0: b = -b
    if b < a: b, a = a, b
    if a == 0:
        return b
    while True:
        if b%a == 0:
            return a
        a, b = b%a, a


x, y = map(int, input().split())
print(gcd(x, y))



Fixed submission:
def gcd_loop(a,b):
    if a < 0: a = -a
    if b < 0: b = -b
    if b < a: b, a = a, b
    if a == 0:
        return b
    while True:
        if b%a == 0:
            return a
        a, b = b%a, a


x, y = map(int, input().split())
print(gcd_loop(x, y))
Buggy python submission (verdict: Runtime Error):
import math

maxv = -inf
minv = inf

n = int(input())

for i in range(n):
    tmp = int(input())
    
    maxv = max(maxv, tmp - minv)
    minv = min(tmp, minv)

print(maxv)

Fixed submission:
maxv = -1 * (10 ** 10) - 1
minv = 10 ** 10 + 1

n = int(input())

for i in range(n):
    tmp = int(input())
    
    maxv = max(maxv, tmp - minv)
    minv = min(tmp, minv)

print(maxv)

Buggy python submission (verdict: Runtime Error):
maxv = -inf
minv = inf

n = int(input())

for i in range(n):
    tmp = int(input())
    
    maxv = max(maxv, tmp - minv)
    minv = min(tmp, minv)

print(maxv)

Fixed submission:
maxv = -1 * (10 ** 10) - 1
minv = 10 ** 10 + 1

n = int(input())

for i in range(n):
    tmp = int(input())
    
    maxv = max(maxv, tmp - minv)
    minv = min(tmp, minv)

print(maxv)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(x) for x in input().split()]

c = 0

for i in range(n):
    for j in range(i + 1, n):
        if a[j - 1] > a[j]:
            tmp = a[j - 1]
            a[j - 1] = a[j]
            a[j] = tmp
            c += 1

print(" ".join([str(x) for x in a])
print(c)

Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]

c = 0

for i in range(n):
    for j in range(1, n):
        if a[j - 1] > a[j]:
            tmp = a[j - 1]
            a[j - 1] = a[j]
            a[j] = tmp
            c += 1

print(" ".join([str(x) for x in a]))
print(c)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(x) for x in input().split()]

c = 0

for i in range(n - 1):
    minj = i
    for j in (i + 1, n):
        if a[j] < a[minj]:
            minj = j
    if minj != i:
        tmp = a[i]
        a[i] = a[minj]
        a[minj] = tmp
        c += 1

print(" ".join([str(x) for x in a]))
print(c)

Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]

c = 0

for i in range(n - 1):
    minj = i
    for j in range(i + 1, n):
        if a[j] < a[minj]:
            minj = j
    if minj != i:
        tmp = a[i]
        a[i] = a[minj]
        a[minj] = tmp
        c += 1

print(" ".join([str(x) for x in a]))
print(c)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = input().split()
b = a

for i in range(n):
    for j in range(i + 1, n):
        if int(a[j - 1][1]) > int(a[j][1]):
            tmp = a[j - 1]
            a[j - 1] = a[j]
            a[j] = tmp

ra = " ".join(a)

print(ra)
print("Stable")

for i in range(n - 1):
    minj = i
    for j in (i + 1, n):
        if int(b[j][1]) < int(b[minj][1]):
            minj = j
    if minj != i:
        tmp = b[i]
        b[i] = b[minj]
        b[minj] = tmp

rb = " ".join(b)
print(rb)

if ra == rb:
    print("Stable")
else:
    print("Not Stable")

Fixed submission:
import copy

n = int(input())
a = input().split()
b = copy.deepcopy(a)

for i in range(n):
    for j in range(n - 1 - i):
        if int(a[j][1]) > int(a[j + 1][1]):
            tmp = a[j]
            a[j] = a[j + 1]
            a[j + 1] = tmp

ra = " ".join(a)

print(ra)
print("Stable")

for i in range(n - 1):
    minj = i
    for j in range(i + 1, n):
        if int(b[j][1]) < int(b[minj][1]):
            minj = j
    if minj != i:
        tmp = b[i]
        b[i] = b[minj]
        b[minj] = tmp

rb = " ".join(b)
print(rb)

if ra == rb:
    print("Stable")
else:
    print("Not stable")
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = [int(x) for x in input().split()]
q = int(input())
t = [int(x) for x in input().split()]

s.sort()
t.sort()

i = 0
cnt = 0

for x in t:
	while s[i] <= x:
		if s[i] == x:
			cnt += 1
		i += 1

print(cnt)

Fixed submission:
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 x in t:
	if x in s:
		cnt += 1

print(cnt)

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = [int(x) for x in input().split()]
q = int(input())
t = [int(x) for x in input().split()]

s.sort()
t.sort()

i = 0
cnt = 0

for x in t:
	if i < n:
		while s[i] <= x:
			if s[i] == x:
				cnt += 1
			i += 1
	else:
		break

print(cnt)

Fixed submission:
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 x in t:
	if x in s:
		cnt += 1

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [int(x) for x in input().split()]
q = int(input())
t = [int(x) for x in input().split()]

cnt = 0

def binarysearch(x, l):
	mi = 0
	ma = len(l) - 1
	
	while mi != ma:
		tmp = (mi + ma) // 2
		
		if l[tmp] == x:
			return tmp
		elif l[tmp] < x:
			mi = tmp + 1
		else:
			ma = tmp - 1
	else:
		if x == l[mi]:
			return mi
		else:
			return -1
	
	

for x in t:
	if binarysearch(x, s) != -1:
		cnt += 1

print(cnt)

Fixed submission:
n = int(input())
s = [int(x) for x in input().split()]
q = int(input())
t = [int(x) for x in input().split()]

cnt = 0

def binarysearch(x, l):
	mi = 0
	ma = len(l) - 1
	
	while mi < ma:
		tmp = (mi + ma) // 2
		
		if l[tmp] == x:
			return tmp
		elif l[tmp] < x:
			mi = tmp + 1
		else:
			ma = tmp - 1
	
	else:
		if mi == ma:
			if x == l[mi]:
				return mi
			else:
				return -1
		else:
			if x == l[mi]:
				return mi
			elif x == l[ma]:
				return ma
			else:
				return -1
	
	

for x in t:
	if binarysearch(x, s) != -1:
		cnt += 1

print(cnt)