qyliang/CodeNanoFix huggingface dataset:
Buggy code:
def examB():
    N = I(); s = [S() for _ in range(N)]
    M = I(); t = [S() for _ in range(M)]
    d = defaultdict(int)
    for l in s:
        d[l] +=1
    for l in t:
        d[l] -=1
    ans = max(d.values())
    print(ans)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Fixed code:
def examB():
    N = I(); s = [S() for _ in range(N)]
    M = I(); t = [S() for _ in range(M)]
    d = defaultdict(int)
    for l in s:
        d[l] +=1
    for l in t:
        d[l] -=1
    ans = max(0,max(d.values()))
    print(ans)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()
Buggy code:
N=int(input())
Blue=[]
for I in range(N):
	Blue.append(input())
M=int(input())
Red=[]
for J in range(M):
	Red.append(input())
W=[]
Max=-101
for K in Blue:
	if K not in W:
		W.append(K)
		R=Blue.count(K)-Red.count(K)
		if R>Max:
			Max=R
print(Max)

Fixed code:
N=int(input())
Blue=[]
for I in range(N):
	Blue.append(input())
M=int(input())
Red=[]
for J in range(M):
	Red.append(input())
W=[]
Max=-101
for K in Blue:
	if K not in W:
		W.append(K)
		R=Blue.count(K)-Red.count(K)
		if R>Max:
			Max=R
if Max<=0:
	print(0)
else:
	print(Max)
Buggy code:
nm = int(input())
n = [input() for _ in range(nm)]
mm = int(input())
m = [input() for _ in range(mm)]
s = list(set(n))

print(max(0,max(n.count(s[i])-m.count(s[i]) for i in range(len(s))))

Fixed code:
nm = int(input())
n = [input() for _ in range(nm)]
mm = int(input())
m = [input() for _ in range(mm)]
s = list(set(n))

print(max(0,max(n.count(s[i])-m.count(s[i]) for i in range(len(s)))))
Buggy code:
h={};
for i in[1,-1]:
    for _ in range(int(input())):
        s=input()
        if s in h:h[s]+=i
        else:h[s]=i
print(max(h.values()))

Fixed code:
h={"":0};
for i in[1,-1]:
    for _ in range(int(input())):
        s=input()
        if s in h:h[s]+=i
        else:h[s]=i
print(max(h.values()))
Buggy code:
blue = [input() for i in range(int(input()))]
red = [input() for i in range(int(input()))]
print(max(0, [blue.count(i) - red.count(i) for i in set(blue + red)]))

Fixed code:
blue = [input() for i in range(int(input()))]
red = [input() for i in range(int(input()))]
print(max(0, max([blue.count(i) - red.count(i) for i in set(blue + red)])))
Buggy code:
a = [input() for _ in range(int(input()))]
b = [input() for _ in range(int(input()))]

l = list(set(a))


a = max(0, [a.count(l[i]) - b.count(l[i]) for i in range(len(l))])
print(a)



Fixed code:
a = [input() for _ in range(int(input()))]
b = [input() for _ in range(int(input()))]
l = list(set(a))
c = max(0, max([a.count(i) - b.count(i) for i in l]))
print(c)
Buggy code:
from collections import Counter

arr_b = []
N = int(input())
for i in range(N):
    arr_b.append(str(input()))
arr_r = []
N = int(input())
for i in range(N):
    arr_r.append(str(input()))

c_b = Counter(arr_b)
c_r = Counter(arr_r)

res = 0
for k_b in c_b.keys():
    if k_b in c_r:
        if res < c_b[k_b] - c_r[k_r]:
            res = c_b[k_b] - c_r[k_r]

print(res)

Fixed code:
from collections import Counter

arr_b = []
N = int(input())
for i in range(N):
    arr_b.append(str(input()))
arr_r = []
N = int(input())
for i in range(N):
    arr_r.append(str(input()))

c_b = Counter(arr_b)
c_r = Counter(arr_r)

res = 0
for k_b in c_b.keys():
    if k_b in c_r :
        if res < c_b[k_b] - c_r[k_b]:
            res = c_b[k_b] - c_r[k_b]
    else:
        if res < c_b[k_b]:
            res = c_b[k_b]

print(res)
Buggy code:
n = int(input())
s = list()

for a in range(n):
    s.append(input())

t = list()
m = int(input())

for a in range(m):
    t.append(input())

kind = list(set(s))
kind_length = len(kind)

counter = dict()
for a in range(kind_length):
    counter[kind[a]] = 0

for a in range(n):
    counter[s[a]] += 1

for a in range(m):
    if t[a] not in counter:
        continue
    counter[t[a]] -= 1

print(max(counter.values()))


Fixed code:
n = int(input())
s = list()

for a in range(n):
    s.append(input())

t = list()
m = int(input())

for a in range(m):
    t.append(input())

kind = list(set(s))
kind_length = len(kind)

counter = dict()
for a in range(kind_length):
    counter[kind[a]] = 0

for a in range(n):
    counter[s[a]] += 1

for a in range(m):
    if t[a] not in counter:
        continue
    counter[t[a]] -= 1

print(max(max(counter.values()), 0))
Buggy code:
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t=[input() for _ in range(m)]
for i in range(n):
    result=s.count(s[i])-t.count(s[i])
print(max(o,result))


Fixed code:
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t=[input() for _ in range(m)]
result=0
for i in range(n):
    result=max(result,s.count(s[i])-t.count(s[i]))
print(result)
Buggy code:
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t=[input() for _ in range(m)]
for i in set(s):
    result=s.count(i)-t.count(i)
print(max(o,result))


Fixed code:
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t=[input() for _ in range(m)]
result=0
for i in set(s):
    result=max(result,s.count(i)-t.count(i))
print(result)
Buggy code:
BlueN = int(input())
BlueList = []
for i in range(1,BlueN):
  BlueList.append(input())

RedN = int(input())
RedList = []
for i in range(1,RedN):
  RedList.append(input())

stocker = 0

for i in set(BlueList):
  if BlueList.count(i) * 1 + RedList.count(i) * -1 >= stocker:
    stocker = BlueList.count(i)

print(stocker)

Fixed code:
BlueN = int(input())
BlueList = []
for i in range(0,BlueN):
  BlueList.append(input())

RedN = int(input())
RedList = []
for i in range(0,RedN):
  RedList.append(input())

stocker = 0

for i in set(BlueList):
  if BlueList.count(i) * 1 + RedList.count(i) * -1 >= stocker:
    stocker = BlueList.count(i) * 1 + RedList.count(i) * -1

print(stocker)
Buggy code:
n = int(input()
s ={}
for i in range(n):
    string = input()
    s[string] = s[string] + 1 if string in s else 1 
m = int(input()
for i in range(m):
    string = input()
    s[string] = s[string] - 1 if string in s else -1
print(max(0,max(s.values())))

Fixed code:
n = int(input())
s ={}
for i in range(n):
    string = input()
    s[string] = s[string] + 1 if string in s else 1 
m = int(input())
for i in range(m):
    string = input()
    s[string] = s[string] - 1 if string in s else -1
print(max(0,max(s.values())))
Buggy code:
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
a = list(set(s+t))
ans = {}
for i in a:
    ans[i] = 0
for i in s:
    ans[i] += 1
for i in t:
    ans[i] -= 1

print(max(ans.values()))

Fixed code:
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
a = list(set(s+t))
ans = {'min': 0}
for i in a:
    ans[i] = 0
for i in s:
    ans[i] += 1
for i in t:
    ans[i] -= 1

print(max(ans.values()))
Buggy code:
N = int(input())
s = [input() for _ in range(N)]

M = int(input())
t = [input() for _ in range(M)]

ans = [s.count(si) - t.count(si) for si in set(s)]

print(max(ans))


Fixed code:
N = int(input())
s = [input() for _ in range(N)]

M = int(input())
t = [input() for _ in range(M)]

ans = [s.count(si) - t.count(si) for si in set(s)]

print(max(0, max(ans)))
Buggy code:
n = int(input())
s = []
for i in range(n):
    a = input()
    s.append(a)
m = int(input())
t = []
for i in range(m):
    a = input()
    t.append(a)
c = [0]*n
k = 0
for i in s:
    for j in s:
        if i == j:
            c[k] += 1
    for j in t:
        if i == j:
            c[k] -= 1
    k += 1
print(max(c))


Fixed code:
n = int(input())
s = []
for i in range(n):
    a = input()
    s.append(a)
m = int(input())
t = []
for i in range(m):
    a = input()
    t.append(a)
c = []
k = 0
for i in s:
    for j in s:
        if i == j:
            k += 1
    for j in t:
        if i == j:
            k -= 1
    c.append(k)
    k = 0
if max(c) < 0:
    print(0)
else:
    print(max(c))
Buggy code:
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for j in range(M)]
x = list(set(s))
def counter(x,N,s,M,t):
    ans = []
    for i in range(len(x)):
        tmp = 0
        for j in range(N):
            if x[i] == s[j]:
                tmp += 1
        for k in range(M):
            if x[i] == t[k]:
                tmp += (-1)
        ans.append(tmp)
    return(ans)
print(max(counter(x,N,s,M,t)))

Fixed code:
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for j in range(M)]
x = list(set(s))
def counter(x,N,s,M,t):
    ans = [0]
    for i in range(len(x)):
        tmp = 0
        for j in range(N):
            if x[i] == s[j]:
                tmp += 1
        for k in range(M):
            if x[i] == t[k]:
                tmp += (-1)
        ans.append(tmp)
    return(ans)
print(max(counter(x,N,s,M,t)))
Buggy code:
N = int(input())
s = [''] * N
for i in range(N):
  s[i] = input()
M = int(input())
t = [''] * M
for i in range(M):
  t[i] = input()
  
p = {si: s.count(si) for si in set(s)}
for ti in t:
  if ti in p:
    p[ti] -= 1
print(max(p.values()))


Fixed code:
N = int(input())
s = [''] * N
for i in range(N):
  s[i] = input()
M = int(input())
t = [''] * M
for i in range(M):
  t[i] = input()
  
p = {si: s.count(si) for si in set(s)}
for ti in t:
  if ti in p:
    p[ti] -= 1
print(max(max(p.values()), 0))
Buggy code:
n = int(input())
lsn = [input() for _ in range(n)]
m = int(input())
lsm = [input() for _ in range(m)]
 
from collections import defaultdict
 
d = defaultdict(int)
 
for i in lsn:
    d[i] += 1
for j in lsm:
    d[j] -= 1
 
print(max(d.values()))

Fixed code:
n = int(input())
lsn = [input() for _ in range(n)]
m = int(input())
lsm = [input() for _ in range(m)]
 
from collections import defaultdict
 
d = defaultdict(int)
 
for i in lsn:
    d[i] += 1
for j in lsm:
    d[j] -= 1
 
print(max(max(d.values()),0))
Buggy code:

N=int(input())
L=[input() for i in range(N)]
M=int(input())
S=[input() for i in range(M)]
A=[0]
for i in range(N):
  A.append(L.count(L[i])-S.count(S[i]))

print(max(A))

Fixed code:
N=int(input())
L=[input() for i in range(N)]
M=int(input())
S=[input() for i in range(M)]
A=[0]
for i in range(N):
  A.append(L.count(L[i])-S.count(L[i]))
 
print(max(A))
Buggy code:
n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for j in range(m)]
l=list(set(s))
print(l)
print(max(0,max(s.count(l[i])-t.count(l[i]) for i in range(len(l)))))

Fixed code:
n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for j in range(m)]
l=list(set(s))
print(max(0,max(s.count(l[i])-t.count(l[i]) for i in range(len(l)))))
Buggy code:
import collections
n = int(input())
Lista = [str(input()) for i in range(n)]
m = int(input())
Listb = [str(input()) for j in range(m)]
lst = []
for k in range(m):
  if Listb[k] in Lista:
    Lista.remove(Listb[k])
lst = collections.Counter(Lista)
print(lst.most_common()[0][1])



Fixed code:
import collections
n = int(input())
Lista = [str(input()) for i in range(n)]
m = int(input())
Listb = [str(input()) for j in range(m)]
lst = []
for k in range(m):
  if Listb[k] in Lista:
    Lista.remove(Listb[k])
if len(Lista) > 0:
  lst = collections.Counter(Lista)
  print(lst.most_common()[0][1])
elif len(Lista) == 0:
  print(0)
Buggy code:
s = [input() for _ in range(int(input()))]
t = [input() for _ in range(int(input()))]
yMax = 0
c = count

for i in s:
    cnt = s.c(i) - t.c(i)
    if yMax < cnt:
        yMax = cnt
print(yMax)


Fixed code:
s = [input() for _ in range(int(input()))]
t = [input() for _ in range(int(input()))]
yMax = 0

for i in s:
    cnt = s.count(i) - t.count(i)
    if yMax < cnt:
        yMax = cnt
print(yMax)
Buggy code:
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]

dicts = {}
small = 0
for i in s:
    if i not in dicts.values():
        dicts[i] = 1
    else:
        dicts[i] += 1
    
for i in t:
    if i not in dicts.values():
        dicts[i] = -1
    else:
        dicts[i] -= 1

tmp = max(dicts.values())
print(max(tmp, small))


Fixed code:
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]

dicts = {}
small = 0
for i in s:
    if i not in dicts.keys():
        dicts[i] = 1
    else:
        dicts[i] += 1
    
for i in t:
    if i not in dicts.keys():
        dicts[i] = -1
    else:
        dicts[i] -= 1

tmp = max(dicts.values())
print(max(tmp, small))
Buggy code:
s = [input() for _ in range(int(input))]
t = [input() for _ in range(int(input))]

l = list(set(s))

print(max(0, max(s.count(l[i]) - t.count(l[i]) for i in range(len(l)))))

Fixed code:
s = [input() for _ in range(int(input()))]
t = [input() for _ in range(int(input()))]

l = list(set(s))

print(max(0, max(s.count(l[i]) - t.count(l[i]) for i in range(len(l)))))
Buggy code:
from collections import Counter
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t =[input() for _ in range(m)]
sc=Counter(s)
tc=Counter(t)
u=list(set(s)&set(t))
ans=n
for i in u:
    ans-=sc[i]
    ans+=max(0,sc[i]-st[i])
print(ans)

Fixed code:
from collections import Counter
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t =[input() for _ in range(m)]
sc=Counter(s)
tc=Counter(t)
u=list(set(s)&set(t))
ans=0
for i in u:
    ans=max(ans,max(0,sc[i]-tc[i]))
v=list(set(s)-set(u))
for i in v:
    ans=max(ans,sc[i])
print(ans)
Buggy code:
l=[input() for _ in range(int(input()))]
m=[input() for _ in range(int(input()))]
n=set(l)
h=max([l.count(i)-m.count(i) for i in n])
print(h)

Fixed code:
l=[input() for _ in range(int(input()))]
m=[input() for _ in range(int(input()))]
n=set(l)
h=max([l.count(i)-m.count(i) for i in n])
print(max(0,h))
Buggy code:
a = int(input())
blue = []
count = []
for i in range(a):
    x = input()
    if x in blue:
        count[blue.index(x)] += 1
    else:
        blue.append(x)
        count.append(1)
b = int(input())
for i in range(b):
    x = input()
    if x in blue:
        count[blue.index(x)] -= 1
    else:
        blue.append(x)
        count.append(-1)

count.sort()
count.reverse()
print (count[0])

Fixed code:
a = int(input())
blue = []
count = []
for i in range(a):
    x = input()
    if x in blue:
        count[blue.index(x)] += 1
    else:
        blue.append(x)
        count.append(1)
b = int(input())
for i in range(b):
    x = input()
    if x in blue:
        count[blue.index(x)] -= 1
    else:
        blue.append(x)
        count.append(-1)

count.sort()
count.reverse()
if count[0] < 0:
    print("0")
else:
    print (count[0])
Buggy code:
GI = lambda: int(input()); GIS = lambda: map(int, input().split()); LGIS = lambda: list(GIS())

from collections import Counter
def main():
  ss = Counter(input() for _ in range(GI()))
  ts = Counter(input() for _ in range(GI()))

  for k in ss:
    if k in ts:
      ss[k] -= ts[k]

  print(max(ss.values()))

main()


Fixed code:
GI = lambda: int(input()); GIS = lambda: map(int, input().split()); LGIS = lambda: list(GIS())

from collections import Counter
def main():
  ss = Counter(input() for _ in range(GI()))
  ts = Counter(input() for _ in range(GI()))

  for k in ss:
    if k in ts:
      ss[k] -= ts[k]

  print(max(max(ss.values()), 0))

main()
Buggy code:
n = int(input())
nlst = [input() for _ in range(n)]
m = int(input())
mlst = [input() for _ in range(m)]

lst = []
lst.extend(nlst)
lst.extend(mlst)

lst = set(lst)

c = [nlst.count(i) - mlst.count(i) for i in lst]
print(max(c))

Fixed code:
n = int(input())
nlst = [input() for _ in range(n)]
m = int(input())
mlst = [input() for _ in range(m)]

lst = []
lst.extend(nlst)
lst.extend(mlst)
lst = set(lst)

c = [nlst.count(i) - mlst.count(i) for i in lst]
c.append(0)
print(max(c))
Buggy code:
n = int(input())
s = [1]
for _ in range(n) :
    s += [input()]
m = int(input())
t = []
for _ in range(m) :
    t += [input()]
wordlist = list(set(s))
s_countdict = {word : s.count(word) for word in wordlist}
t_countdict = {word : t.count(word) for word in wordlist}
pointlist = [s_countdict[word] - t_countdict[word] for word in wordlist]
print(max(pointlist))

Fixed code:
n = int(input())
s = []
for _ in range(n) :
    s += [input()]
m = int(input())
t = []
for _ in range(m) :
    t += [input()]
wordlist = list(set(s))
s_countdict = {word : s.count(word) for word in wordlist}
t_countdict = {word : t.count(word) for word in wordlist}
pointlist = [s_countdict[word] - t_countdict[word] for word in wordlist]
print(max(max(pointlist), 0))
Buggy code:
N = int(input())
s = []
for i in range(N):
    s.append(input()

M = int(input())
t = []
for i in range(N):
    t.append(input())

sum = 0
for i in range(N):
    temp = 0
    sample = s[i]
    for j in range(N):
        if sample == s[j]:
            temp += 1
    for k in range(M):
        if sample == t[k]:
            temp -= 1
    if temp > sum:
        sum = temp
print(sum)

Fixed code:
N = int(input())
s = []
for i in range(N):
    s.append(input())

M = int(input())
t = []
for i in range(M):
    t.append(input())

sum = 0
for i in range(N):
    temp = 0
    sample = s[i]
    for j in range(N):
        if sample == s[j]:
            temp += 1
    for k in range(M):
        if sample == t[k]:
            temp -= 1
    if temp > sum:
        sum = temp
print(sum)
Buggy code:
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
ss=set(s)
ans = [1]
for i in ss:
  ans.append(s.count(i)-t.count(i))
print(max(ans))

Fixed code:
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
ss=set(s)
ans = [0]
for i in ss:
  ans.append(s.count(i)-t.count(i))
print(max(ans))
Buggy code:
dict = {}

n = int(input())

for i in range(n):
	s = input()
	try:
		dict[s] += 1
	except:
		dict[s] = 1

m = int(input())

for i in range(m):
	s = input()
	try:
		dict[s] -= 1
	except:
		dict[s] = -1

ans = sorted(dict.items(), key=lambda x: -x[1])

print(ans[0][1])

Fixed code:
dict = {}

n = int(input())

for i in range(n):
	s = input()
	try:
		dict[s] += 1
	except:
		dict[s] = 1

m = int(input())

for i in range(m):
	s = input()
	try:
		dict[s] -= 1
	except:
		dict[s] = -1

ans = sorted(dict.items(), key=lambda x: -x[1])

if ans[0][1] < 0:
	print(0)
else:
	print(ans[0][1])
Buggy code:
from collections import Counter

N = int(input())
plus = Counter([input() for _ in range(N)])
M = int(input())
minus = Counter([input() for _ in range(M)])

ans = 1
for k, v in dict(plus).items():
    if minus[k]:
        ans = max(ans, v - minus[k])
    else:
        ans = max(ans, v)

print(ans)


Fixed code:
from collections import Counter

N = int(input())
plus = Counter([input() for _ in range(N)])
M = int(input())
minus = Counter([input() for _ in range(M)])

ans = 0
for k, v in dict(plus).items():
    if minus[k]:
        ans = max(ans, v - minus[k])
    else:
        ans = max(ans, v)

print(ans)
Buggy code:
lst_blue = []
lst_red = []

N = int(input())
for i in range(0,N):
  lst_blue.append(input())
M = int(input())
for i in range(0,M):
  lst_red.append(input())

for i in list(set(lst_blue)):
  dic = {lst_bule[i]:int(lst_blue.count(i))}
for i in list(set(lst_red)):
  if i in dic:
    dic[i] -= 1

print(max(dic.values()))


Fixed code:
lst_blue = []
lst_red = []
dic = {}

N = int(input())
for i in range(0,N):
  lst_blue.append(input())
M = int(input())
for i in range(0,M):
  lst_red.append(input())

for i in list(set(lst_blue)):
  dic[i] = int(lst_blue.count(i))

for i in lst_red:
  if i in dic:
    dic[i] -= 1
    
print(max(0,max(dic.values())))
Buggy code:
import collections
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

S = collections.Counter(s)
T = collections.Counter(t)


ans = [0]
for key, cont in S.most_common():
  if cont > T[key]:
    ans.append(cont)
print(max(ans))
 

Fixed code:
import collections
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

S = collections.Counter(s)
T = collections.Counter(t)


ans = [0]
for key, cont in S.most_common():
  if cont > T[key]:
    ans.append(cont-T[key])
print(max(ans))
Buggy code:
n=(input() for i in range(int(input())))
m=(input() for i in range(int(input())))

l=list(set(n))

print(max(0,max(n.count(l[i])-m.count(l[i]) for i in range(len(l)))))

Fixed code:
n=[input() for i in range(int(input()))]
m=[input() for i in range(int(input()))]

l=list(set(n))

print(max(0,max(n.count(l[i])-m.count(l[i]) for i in range(len(l)))))
Buggy code:
m = {}

n = int(input())
for i in range(n):
    s = input().strip()
    if s not in m:
        m[s] = 1
    else:
        m[s] += 1

m = int(input())
for i in range(m):
    t = input().strip()
    if t not in m:
        m[t] = -1
    else:
        m[t] -= 1

res = max(m.values())
if res<0:
    res = 0

print(res)

Fixed code:
memo = {}

n = int(input())
for i in range(n):
    s = input().strip()
    if s not in memo:
        memo[s] = 1
    else:
        memo[s] += 1

n = int(input())
for i in range(n):
    s = input().strip()
    if s not in memo:
        memo[s] = -1
    else:
        memo[s] -= 1

res =  max(memo.values())
if res<0:
    res = 0

print(res)
Buggy code:
# coding: utf-8
# Your code here!

def countDic(str_list):
    ret = {}
    for s in str_list:
        if s in ret.keys():
            ret[s] += 1
        else:
            ret[s] = 1
    return ret

N = int(input())
s = [''] * N
for i in range(N):
    s[i] = input()
M = int(input())
t = [''] * M
for i in range(M):
    t[i] = input()

s_c = countDic(s)
t_c = countDic(t)
a = []
for k in s_c.keys():
    if k in t_c.keys():
        a.append(s_c[k] - t_c[k])
    else:
        a.append(s_c[k])
print(max(a))


Fixed code:
# coding: utf-8
# Your code here!

def countDic(str_list):
    ret = {}
    for s in str_list:
        if s in ret.keys():
            ret[s] += 1
        else:
            ret[s] = 1
    return ret

N = int(input())
s = [''] * N
for i in range(N):
    s[i] = input()
M = int(input())
t = [''] * M
for i in range(M):
    t[i] = input()

s_c = countDic(s)
t_c = countDic(t)
a = []
for k in s_c.keys():
    if k in t_c.keys():
        a.append(s_c[k] - t_c[k])
    else:
        a.append(s_c[k])
if max(a) > 0:
    print(max(a))
else:
    print(0)
Buggy code:
# ABC091B

n = int(input)
s = [0] * n
for i in range(n):
    s[i] = input()
m = int(input)
t = [0] * m
for i in range(m):
    t[i] = input()

blue = {}
for c in s:
    if c in blue.keys():
        blue[c] += 1
    else:
        blue.setdefault(c, 1)
red = {}
for c in t:
    if c in red.keys():
        red[c] += 1
    else:
        red.setdefault(c, 1)

Max = 0
for blue_key, blue_value in blue.items():
    get = blue_value
    if blue_key in red.keys():
        for red_key, red_value in red.items():
            if blue_key == red_key:
                get -= red_value
                break
    Max = max(Max, get)
print(Max)


Fixed code:
# ABC091B

n = int(input())
s = [0] * n
for i in range(n):
    s[i] = input()
m = int(input())
t = [0] * m
for i in range(m):
    t[i] = input()

blue = {}
for c in s:
    if c in blue.keys():
        blue[c] += 1
    else:
        blue.setdefault(c, 1)
red = {}
for c in t:
    if c in red.keys():
        red[c] += 1
    else:
        red.setdefault(c, 1)

Max = 0
for blue_key, blue_value in blue.items():
    get = blue_value
    if blue_key in red.keys():
        for red_key, red_value in red.items():
            if blue_key == red_key:
                get -= red_value
                break
    Max = max(Max, get)
print(Max)