Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
class Node():
    def __init__(self, data):
        # string
        self.data = data
        self.children = dict()
        
class Tries():
    def __init__(self):
        self.head = Node("*")

    def add(self, string):
        nodelist = [Node(char) for char in string]
        cur_node = self.head
        for node in nodelist:
            char = node.data
            if char not in cur_node.children:
                cur_node.children[char] = node
                cur_node = cur_node.children[char]
            else:
                cur_node = cur_node.children[char]
        cur_node.children["*"] = 0

    def _add(self, string):
        '''
        deprecated
        '''
        
        nodelist = [Node(char) for char in string]
        cur_node = self.head
        i = 0
        
        while(i < len(nodelist)):
            node = nodelist[i]
            char = node.data
            
            if char not in cur_node.children:
                cur_node.children[char] = nodelist[i]
                cur_node = cur_node.children[char]

            else:
                # cur_node.children[char]
                cur_node = cur_node.children[char]

            i += 1
            
    def find(self, string):
        i = 0
        cur_node = self.head
        while(i <= len(string)-1):
            
            char = string[i]
            if char in cur_node.children:
                cur_node = cur_node.children[char]
                i += 1
            else:
                return False
        if cur_node.children.get("*") == None:
            return False
        return True
                
if __name__ == "__main__":
    
    n = int(input())
    ops = []
    words = []
    for _ in range(n):
        op, word = input().split()
        ops.append(op)
        words.append(word)
    
    tries = Tries()
    for op, word in zip(ops, words):
        if op=='insert':
            tries.add(word)
        else:
            if tries.find(word)==True:
                print("yes")
            else:
                print("no")



Fixed submission:
if __name__ == "__main__":
    
    n = int(input())
    ops = []
    words = []
    for _ in range(n):
        op, word = input().split()
        ops.append(op)
        words.append(word)
    
    db = set()
    for op, word in zip(ops, words):
        if op=='insert':
            db.add(word)
        else:
            if word in db:
                print("yes")
            else:
                print("no")
Buggy python submission (verdict: Runtime Error):
nums = input().split()

if nums[0] =< nums[1] and nums[1] =< nums[2]:
    print("Yes")
else:
    print("No")

Fixed submission:
nums = input().split()

if int(nums[0]) < int(nums[1]) and int(nums[1]) < int(nums[2]):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
nums = input().split()

if int(nums[0]) < int(nums[1]) and int(num[1]) < int(nums[2]):
    print("Yes")
else:
    print("No")

Fixed submission:
nums = input().split()

if int(nums[0]) < int(nums[1]) and int(nums[1]) < int(nums[2]):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
nums = input().split()

if int(nums[0]) < int(nums[1]) and int(numS[1]) < int(nums[2]):
    print("Yes")
else:
    print("No")

Fixed submission:
nums = input().split()

if int(nums[0]) < int(nums[1]) and int(nums[1]) < int(nums[2]):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
str_list = []

for _ in range(n):
    cmd,input_str = input().split()
    if   cmd == 'insert':
        str_list.append(input_str)
    elif cmd == 'find':
        if input_str in str_list:
            print('yes')
        else:
            print('no')
    


Fixed submission:
n = int(input())
dic = {}
ans_list = []

for i in range(n):
    cmd,num = input().split()
    if   cmd == 'insert':
        dic[num] = i
    elif cmd == 'find':
        if dic.__contains__(num):
            ans_list.append('yes')
        else:
            ans_list.append('no')

for ans in ans_list:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def solve(i,m):
    if m == 0:
        return True
    if i == n:
        return False
    else:
        return solve(i+1,m) | solve(i+1,m-n_list[i])


n = int(input())
n_list = list(map(int,input().split()))
q = int(input())
q_list = list(map(int,input().split()))

for num in q_list:
    print('yes') if solve(0,num) else print('no')


Fixed submission:
n = int(input())
a_list = list(map(int,input().split()))
q = int(input())
q_list = list(map(int,input().split()))
bits = 1

for a in a_list:
    bits |= bits << a

for q in q_list:
    if (bits>>q)&1:
        print('yes')
    else:
        print('no')

Buggy python submission (verdict: Time Limit Exceeded):
def solve(i,m):
    if m == 0:
        return True
    if i == n:
        return False
    else:
        return solve(i+1,m) | solve(i+1,m-n_list[i])


n = int(input())
n_list = list(map(int,input().split()))
q = int(input())
q_list = list(map(int,input().split()))

for num in q_list:
    print('yes') if solve(0,num) else print('no')


Fixed submission:
n = int(input())
a_list = list(map(int,input().split()))
q = int(input())
q_list = list(map(int,input().split()))
bits = 1

for a in a_list:
    bits |= bits << a

for q in q_list:
    if (bits>>q)&1:
        print('yes')
    else:
        print('no')

Buggy python submission (verdict: Time Limit Exceeded):
def brute(i,m):
    if m == 0:
        return True
    elif i >= n or m < 0:
        return False
    return brute(i+1,m) | brute(i+1,m-n_list[i])

n = int(input())
n_list = list(map(int,input().split()))
q = int(input())
q_list = list(map(int,input().split()))

for num in q_list:
    print('yes') if brute(0,num) else print('no')



Fixed submission:
n = int(input())
a_list = list(map(int,input().split()))
q = int(input())
q_list = list(map(int,input().split()))
bits = 1

for a in a_list:
    bits |= bits << a

for q in q_list:
    if (bits>>q)&1:
        print('yes')
    else:
        print('no')
Buggy python submission (verdict: Runtime Error):
memo = {}

def fib_memo(n):
  if n <= 1:
    return n
  if n in memo: # 動的計画法とも
    return memo[n]
  memo[n] = fib_memo(n - 1) + fib_memo(n - 2)
  return memo[n]

n = int(raw_input())

print fib_memo(n)

Fixed submission:
memo = {}

def fib_memo(n):
  if n <= 1:
    return 1
  if n in memo:
    return memo[n]
  memo[n] = fib_memo(n - 1) + fib_memo(n - 2)
  return memo[n]

x = int(raw_input())

print fib_memo(x)

Buggy python submission (verdict: Runtime Error):
memo = {}

def fib_memo(n):
  if n <= 1:
    return 1
  if n in memo: # 動的計画法とも
    return memo[n]
  memo[n] = fib_memo(n - 1) + fib_memo(n - 2)
  return memo[n]

x = int(raw_input())

print fib_memo(x)

Fixed submission:
memo = {}

def fib_memo(n):
  if n <= 1:
    return 1
  if n in memo:
    return memo[n]
  memo[n] = fib_memo(n - 1) + fib_memo(n - 2)
  return memo[n]

x = int(raw_input())

print fib_memo(x)
Buggy python submission (verdict: Runtime Error):
N = int(raw_input())
A = [0] * N
for i in range(N):
  A[i] = [0] * N

for line in sys.stdin:
  values = line.split()
  u = int(values[0]) - 1
  k = int(values[1])
  nodes = values[2:]
  for i in range(int(k)):
    v = int(nodes[i]) - 1
    A[u][v] = 1

for i in range(N):
  print " ".join([str(x) for x in A[i]])

Fixed submission:
import sys

N = int(raw_input())
A = [0] * N
for i in range(N):
  A[i] = [0] * N

for line in sys.stdin:
  values = line.split()
  u = int(values[0]) - 1
  k = int(values[1])
  nodes = values[2:]
  for i in range(int(k)):
    v = int(nodes[i]) - 1
    A[u][v] = 1

for i in range(N):
  print " ".join([str(x) for x in A[i]])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(raw_input())
F = [0] * (n+1)

def makeFibonacci(n):
    global F
    F[0] = 1
    F[1] = 1
    for i in xrange(2,n+1):
        F[i] = makeFibonacci(i-2) + makeFibonacci(i-1)
    return F[n]

def main():
    ans = makeFibonacci(n)
    print ans
    return 0

main()

Fixed submission:
n = int(raw_input())
F = [0] * (n+1)



def fibonacci(n):
    global F
    if n == 0 or n == 1:
        F[n] = 1
        return F[n]
    if F[n] != 0:
        return F[n]
    F[n] = fibonacci(n-2) + fibonacci(n-1)
    return F[n]

def makeFibonacci(n):
    global F
    F[0] = 1
    F[1] = 1
    for i in xrange(2,n+1):
        F[i] = makeFibonacci(i-2) + makeFibonacci(i-1)
    return F[n]

def main():
    ans = fibonacci(n)
    print ans
    return 0

main()
Buggy python submission (verdict: Time Limit Exceeded):
def lcs(X, Y):
    m = len(X) + 1
    n = len(Y) + 1
    c = [[0] * n for _ in xrange(m)]
    X = ' ' + X
    Y = ' ' + Y
    for i in xrange(1,m):
        for j in xrange(1,n):
            if X[i] == Y[j]:
                c[i][j] = c[i-1][j-1] + 1
            elif c[i-1][j] >= c[i][j-1]:
                c[i][j] = c[i-1][j]
            else:
                c[i][j] = c[i][j-1]
    print c[m-1][n-1]
    return 0

def main():
    q = int(raw_input())
    for i in xrange(q):
        X = raw_input()
        Y = raw_input()
        lcs(X,Y)
    return 0

main()

Fixed submission:
def lcs(x,y):
    a, b = len(x), len(y)
    x1 = [0 for k in range(b+1)]
    for i in xrange(a):
        e = x[i]
        x2 = x1+[]
        for j in xrange(b):
            if e == y[j]:
                x1[j+1] = x2[j] + 1
            elif x1[j+1] < x1[j]:
                x1[j+1] = x1[j]
    print max(x1)
    return 0

def main():
    q = int(raw_input())
    for i in xrange(q):
        X = raw_input()
        Y = raw_input()
        lcs(X,Y)
    return 0

main()

Buggy python submission (verdict: Time Limit Exceeded):
def lcs(X, Y):
    m = len(X) + 1
    n = len(Y) + 1
    c = [[0] * n for _ in xrange(m)]
    X = ' ' + X
    Y = ' ' + Y
    maxl = 0
    for i in xrange(1,m):
        for j in xrange(1,n):
            if X[i] == Y[j]:
                c[i][j] = c[i-1][j-1] + 1
            #elif c[i-1][j] >= c[i][j-1]:
            #    c[i][j] = c[i-1][j]
            else:
                c[i][j] = max(c[i][j-1],c[i-1][j])
        maxl = max(maxl, c[i][j])
    print maxl
    return 0

def main():
    q = int(raw_input())
    for i in xrange(q):
        X = raw_input()
        Y = raw_input()
        lcs(X,Y)
    return 0

main()

Fixed submission:
def lcs(x,y):
    a, b = len(x), len(y)
    x1 = [0 for k in range(b+1)]
    for i in xrange(a):
        e = x[i]
        x2 = x1+[]
        for j in xrange(b):
            if e == y[j]:
                x1[j+1] = x2[j] + 1
            elif x1[j+1] < x1[j]:
                x1[j+1] = x1[j]
    print max(x1)
    return 0

def main():
    q = int(raw_input())
    for i in xrange(q):
        X = raw_input()
        Y = raw_input()
        lcs(X,Y)
    return 0

main()
Buggy python submission (verdict: Runtime Error):
def main():
    N = input()
    a = map(int, raw_input().split())
    print ' '.join(map(str,a))
    for i in xrange(1,len(a)-1):
        v = a[i]
        j = i - 1
        while j >= 0 && a[j] > v:
            a[j+1] = a[j]
            j -= 1
        a[j+1] = v
        print ' '.join(map(str,a))
    return 0

main()

Fixed submission:
def main():
    N = input()
    a = map(int, raw_input().split())
    print ' '.join(map(str,a))
    for i in xrange(1,len(a)):
        v = a[i]
        j = i - 1
        while (j >= 0) & (a[j] > v):
            a[j+1] = a[j]
            j -= 1
        a[j+1] = v
        print ' '.join(map(str,a))
    return 0

main()
Buggy python submission (verdict: Runtime Error):
def main():
    
    N = input()
    a = [input() for y in range(N)]
    a_max = -10**9
    for i in xrange(1,len(a)):
        if (max(a[(i+1):]) - a[i]) >= a_max:
            a_max = max(a[(i+1):]) - a[i]
    return a_max

main()

Fixed submission:
def main():
    N = input() 
    a = [input() for y in range(N)] 
    a_max = -10**9
    a_min = a[0]
    for j in xrange(1,len(a)):
        if a[j] - a_min > a_max:
            a_max = a[j] - a_min
        if a[j] < a_min:
            a_min = a[j]
    print a_max
main()

Buggy python submission (verdict: Runtime Error):
    N = input()
    a = [input() for y in range(N)]
    a_max = -10**9
    for i in xrange(1,len(a)-1):
        if (max(a[(i+1):]) - a[i]) >= a_max:
            a_max = max(a[(i+1):]) - a[i]
    print a_max

Fixed submission:
def main():
    N = input() 
    a = [input() for y in range(N)] 
    a_max = -10**9
    a_min = a[0]
    for j in xrange(1,len(a)):
        if a[j] - a_min > a_max:
            a_max = a[j] - a_min
        if a[j] < a_min:
            a_min = a[j]
    print a_max
main()
Buggy python submission (verdict: Runtime Error):
def insertionSort(A, n, g, cnt):
    for i in xrange(1,n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return A, cnt

def shellSort(A, n):
    cnt = 0
    G = [1]
    for i in range(1,len(A)):
        if 3*G[i-1]+1 < len(A):
            G.append(3*G[i-1]+1)
    G = list(reversed(G[:]))
    #print G
    m = len(G)
    print m
    print ' '.join(map(str,G))
    newA = A[:]
    for i in range(0,m):
        newA, cnt = insertionSort(newA[:],len(A),G[i],cnt)
    return newA, cnt

def main():
    n = int(input())
    A = [int(input()) for i in xrange(n)]
    newA, cnt = shellSort(A, n)
    print cnt
    for i in range(len(newA)):
        print newA[i]
    return 0

if __name__ == '__main__':
    main()

Fixed submission:
def insertionSort(A, n, g, cnt):
    for i in xrange(1,n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return A, cnt

def shellSort(A, n):
    cnt = 0
    G = [1]
    idx = 0
    for i in range(1,len(A)):
        if 3*G[idx]+1 < len(A):
            G.append(3*G[idx]+1)
            idx += 1
    G = list(reversed(G[:]))
    #print G
    m = len(G)
    print m
    print ' '.join(map(str,G))
    newA = A[:]
    for i in range(0,m):
        newA, cnt = insertionSort(newA[:],len(A),G[i],cnt)
    return newA, cnt

def main():
    n = int(input())
    A = [int(input()) for i in xrange(n)]
    newA, cnt = shellSort(A, n)
    print cnt
    for i in range(len(newA)):
        print newA[i]
    return 0

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
from collections import deque

def main():
    S = input().split()
    D = deque([])
    for s in S:
        if s == '+':
            b = D.pop()
            a = D.pop()
            D.append(a+b)   
        elif s == '-':
            b = D.pop()
            a = D.pop()
            D.append(a-b)
        elif s == '*':
            b = D.pop()
            a = D.pop()
            D.append(a*b)
        else:
            D.append(int(s))
        print D
    print D.pop()
    return 0

main()

Fixed submission:
from collections import deque

def main():
    S = raw_input().split()
    D = deque([])
    for s in S:
        if s == '+':
            b = D.pop()
            a = D.pop()
            D.append(a+b)   
        elif s == '-':
            b = D.pop()
            a = D.pop()
            D.append(a-b)
        elif s == '*':
            b = D.pop()
            a = D.pop()
            D.append(a*b)
        else:
            D.append(int(s))
    print D.pop()
    return 0

main()
Buggy python submission (verdict: Time Limit Exceeded):
def binarySearch(A, key):
    left = 0
    right = len(A)
    while left < right:
        mid = int((left + right) / 2)
        if A[mid] == key:
            return True
        elif key < A[mid]:
            right = mid
        else:
            left = mid+1
    return False

def main():
    n = int(raw_input())
    S = [int(_) for _ in raw_input().split()]
    q = int(raw_input())
    T = [int(_) for _ in raw_input().split()]
    Sum = 0
    for t in T:
        if binarySearch(S[:], t): Sum += 1
    print Sum
    return 0

main()

Fixed submission:
n = int(raw_input())
S = map(int,raw_input().split())
q = int(raw_input())
T = map(int,raw_input().split())
 
c = 0
for t in T:
    left = 0
    right = n
    while left < right:
        mid = int((left + right)/2)
        if(S[mid] == t):
            c+=1
            break
        elif(t<S[mid]):
            right = mid
        else:
            left = mid+1
 
print c

Buggy python submission (verdict: Time Limit Exceeded):
def binarySearch(A, key):
    left = 0
    right = len(A)
    while left < right:
        mid = (left + right) / 2
        if A[mid] == key:
            return True
        elif key < A[mid]:
            right = mid
        else:
            left = mid+1
    return False

def main():
    n = int(raw_input())
    S = [int(_) for _ in raw_input().split()]
    q = int(raw_input())
    T = [int(_) for _ in raw_input().split()]
    Sum = 0
    for t in T:
        if binarySearch(S[:], t): Sum += 1
    print Sum
    return 0

main()

Fixed submission:
n = int(raw_input())
S = map(int,raw_input().split())
q = int(raw_input())
T = map(int,raw_input().split())
 
c = 0
for t in T:
    left = 0
    right = n
    while left < right:
        mid = int((left + right)/2)
        if(S[mid] == t):
            c+=1
            break
        elif(t<S[mid]):
            right = mid
        else:
            left = mid+1
 
print c
Buggy python submission (verdict: Time Limit Exceeded):
n = int(raw_input())
A = map(int, raw_input().split())
q = int(raw_input())
M = map(int, raw_input().split())

def solve(i,m):
    if m == 0:
        return True
    if i >= n:
        return False
    res = solve(i+1, m) or solve(i+1, m-A[i])
    return res

def main():
    for m in M:
        res = solve(0,m)
        if res:
            print 'yes'
        else:
            print 'no'

main()
    

Fixed submission:
def solve(i, m):
  if dp[i][m] != -1:
    return dp[i][m]
 
  if m == 0:
    dp[i][m] = 1
  elif i >= n:
    dp[i][m] = 0
  elif solve(i+1, m):
    dp[i][m] = 1
  elif solve(i+1, m-A[i]):
    dp[i][m] = 1
  else:
    dp[i][m] = 0
 
  return dp[i][m]
 
 
 
n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())
 
dp = [[-1 for col in range(2000)] for row in range(n+1)]
 
for i in range(p):
  if solve(0, m[i]):
    print 'yes'
  else:
    print 'no'

Buggy python submission (verdict: Time Limit Exceeded):
n = int(raw_input())
A = map(int, raw_input().split())
q = int(raw_input())
M = map(int, raw_input().split())

def solve(i,m):
    if m == 0:
        return 1
    if i >= n:
        return 0
    res = solve(i+1, m) or solve(i+1, m-A[i])
    return res

def main():
    for m in M:
        res = solve(0,m)
        if res:
            print 'yes'
        else:
            print 'no'

main()
    

Fixed submission:
def solve(i, m):
  if dp[i][m] != -1:
    return dp[i][m]
 
  if m == 0:
    dp[i][m] = 1
  elif i >= n:
    dp[i][m] = 0
  elif solve(i+1, m):
    dp[i][m] = 1
  elif solve(i+1, m-A[i]):
    dp[i][m] = 1
  else:
    dp[i][m] = 0
 
  return dp[i][m]
 
 
 
n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())
 
dp = [[-1 for col in range(2000)] for row in range(n+1)]
 
for i in range(p):
  if solve(0, m[i]):
    print 'yes'
  else:
    print 'no'
Buggy python submission (verdict: Runtime Error):
import sys

n = int(raw_input())


#class of node
class Node:
    def __init__(self):
        self.p = -1
        self.l = -1
        self.r = -1

T = [ Node() for _ in xrange(n)] #info of u
D = [0] * n #depth of u

def printInfo(u):
    #print 'node', u, ':',
    #print 'parent = ', T[u].p, ',',
    #print 'depth = ', D[u], ',',
    print "node {}: parent = {}, depth = {},".format(u, T[u].p, D[u]) ,
    if T[u].p == -1: 
        print 'root, ',
    elif T[u].l == -1:
        print 'leaf, ',
    else:
        print 'internal node, ',

    #print '[',
    sys.stdout.write("[")

    c = T[u].l
    i = 0
    while c != -1:
        if i > 0:
            print ', ',
        sys.stdout.write(str(c))
        #print "{}".format(c),
        c = T[c].r
        i += 1
    #print ']'
    sys.stdout.write("]\n")

    return 0

def rec(u, p):
    D[u] = p
    if T[u].r != -1:
        rec(T[u].r, p)
    if T[u].l != -1:
        rec(T[u].l, p+1)
    return

def main():
    for i in xrange(n):
        a = map(int, raw_input().split())
        v = a[0]
        d = a[1]
        for j in xrange(d):
            if j == 0:
                T[v].l = a[j+2]
            else:
                T[l].r = a[j+2]
            l = a[j+2]
            T[a[j+2]].p = v
    for i in xrange(n):
        if T[i].p == -1:
            r = i

    rec(r, 0)

    for i in xrange(n):
        printInfo(i)

    return 0

main()

Fixed submission:
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
 
FORMAT = ('node {0.id}: parent = {0.parent}, depth = {0.depth},'
          ' {0.kind}, {0.childs}').format
 
 
class Node(object):
    def __init__(self, node):
        self.depth = 0
        self.parent = -1
        self.id = node[0]
        self.degree = node[1]
        self.kind = 'internal node' if node[1] else 'leaf'
        self.childs = node[2:]
 
    def __str__(self):
        return FORMAT(self)
 
 
def calc_depth(tree, i):
    for j in tree[i].childs:
        tree[j].depth += 1
        calc_depth(tree, j)
 
 
n = int(stdin.readline())
tree = [-1] * n
#assert 1 <= n <= 100000
for _ in xrange(n):
    node = Node([int(s) for s in stdin.readline().split()])
    i = node.id
    node.parent = tree[i]
    for j in node.childs:
        if isinstance(tree[j], int):
            tree[j] = i
        else:
            tree[j].parent = i
    tree[i] = node
 
for i in xrange(n):
    calc_depth(tree, i)
 
for i, node in enumerate(tree):
    if node.parent == -1:
        node.kind = 'root'
    print(node)
Buggy python submission (verdict: Runtime Error):

a = [int(s) for s in raw_input().split()]
if a > b > c:
  print "Yes"
else 
  print "No"

Fixed submission:

a = [int(s) for s in raw_input().split()]
if a[0] <  a[1] < a[2]:
  print "Yes"
else:
  print "No"

Buggy python submission (verdict: Runtime Error):

a = [int(s) for s in raw_input().split()]
if a[0] <  a[1] < a[2]:
  print "Yes"
else 
  print "No"

Fixed submission:

a = [int(s) for s in raw_input().split()]
if a[0] <  a[1] < a[2]:
  print "Yes"
else:
  print "No"
Buggy python submission (verdict: Time Limit Exceeded):
def fibonacci(n):
    if n==0:
        return 1
    elif n==1:
        return 1
    else:
        return fibonacci(n-1) + fibonacci(n-2)

n = int(input())
print(fibonacci(n))

Fixed submission:
def fibonacci(n, memo=None):
    if memo==None:
        memo = [None]*n
    if n<=1:
        return 1 
    else:
        if memo[n-2]==None:
            memo[n-2] = fibonacci(n-2, memo)
        if memo[n-1]==None:
            memo[n-1] = fibonacci(n-1, memo)
    return memo[n-1] + memo[n-2]

n = int(input())
print(fibonacci(n))
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()))

ans = sum([1 for tmp_t in T if tmp_t in S])

print(ans)

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

ans = 0
for tmp_t in T:
    left = 0
    right = n
    while(left<right):
        mid = (left + right)//2
        if S[mid]==tmp_t:
            ans += 1
            break
        elif S[mid]>tmp_t:
            right = mid
        else:
            left = mid+1

print(ans)