Problem:
 Score : 200 points    Problem Statement Takahashi has N blue cards and M red cards.
A string is written on each card. The string written on the i -th blue card is s_i , and the string written on the i -th red card is t_i .  Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen.  Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces atcoder , he will not earn money even if there are blue cards with atcoderr , atcode , btcoder , and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.)  At most how much can he earn on balance?  Note that the same string may be written on multiple cards.      Constraints  N and M are integers.  1 \leq N, M \leq 100  s_1, s_2, ..., s_N, t_1, t_2, ..., t_M are all strings of lengths between 1 and 10 (inclusive) consisting of lowercase English letters.         Input Input is given from Standard Input in the following format:  N  s_1  s_2  :  s_N  M  t_1  t_2  :  t_M       Output If Takahashi can earn at most X yen on balance, print X .        Sample Input 1 3
apple
orange
apple
1
grape      Sample Output 1 2  He can earn 2 yen by announcing apple .       Sample Input 2 3
apple
orange
apple
5
apple
apple
apple
apple
apple      Sample Output 2 1  If he announces apple , he will lose 3 yen. If he announces orange , he can earn 1 yen.       Sample Input 3 1
voldemort
10
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort      Sample Output 3 0  If he announces voldemort , he will lose 9 yen. If he announces orange , for example, he can avoid losing a yen.       Sample Input 4 6
red
red
blue
yellow
yellow
red
5
red
red
yellow
green
blue      Sample Output 4 1

Solution (Python):
N = int(input())
words = []
for _ in range(N):
  words.append(('plus', input()))
M = int(input())
for _ in range(M):
  words.append(('minus', input()))
ans = 0
for i in range(N):
  point = 1
  for j in range(N+M):
    if words[i][1] == words[j][1] and i != j:
      if words[j][0] == 'plus':
        point += 1
      else:
        point -= 1
  ans = max(ans, point)
print(ans)

Solution (Python):
n = int(input())
d= {}
for _ in range(n):
    i = input()
    if i in d:
        d[i] += 1
    else: d[i] = 1

for _ in range(int(input())):
    i = input()
    if i in d:
        d[i] -= 1

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

Solution (Python):
n = int(input())
st = {}
for i in range(0,n):
    si = input()
    if si in st:
        st[si] += 1
    else:
        st[si] = 1
m = int(input())
for i in range(0,m):
    ti = input()
    if ti in st:
        st[ti] -= 1
    else:
        st[ti] = -1
stlist = list(st.items())
stlist.sort(key=lambda x:x[1])
stlist.reverse()
print(max(stlist[0][1],0))

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
ans = 0
dic = {'0':0}
us = list(set(s))
for i in us:
    tmp = s.count(i) - t.count(i)
    dic['{}'.format(i)] = tmp
print(max(dic.values()))

Solution (Python):
import collections

N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
cs = collections.Counter(s)
ct = collections.Counter(t)
ans = 0
for k in cs.keys():

  c = cs[k] - ct[k]
  if c > ans:
    ans = c
print(max(ans, 0))

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007


def A():
    a, b, c = LI()
    if a + b >= c:
        print("Yes")
    else:
        print("No")
    return


def B():
    n = II()
    s = SR(n)
    m = II()
    t = SR(m)
    ans = 0
    for si in s:
        ans = max(ans, s.count(si) - t.count(si))
    print(ans)
    return


def C():
    n = II()
    ab = LIR(n)
    cd = LIR(n)
    ab.sort()
    cd.sort()
    check = [0 for i in range(n)]
    ans = 0
    for _, c in enumerate(cd):
        d = c[1]
        c = c[0]
        maxy = -1
        x = -1
        for k, a in enumerate(ab):
            b = a[1]
            a = a[0]
            if maxy < b and c > a and check[k] == 0 and d > b:
                maxy = b
                x = k
        if x != -1:
            ans += 1
            check[x] += 1
    print(ans)


    return


def D():
    N = II()
    a = LI()
    b = LI()
    ans = 0
    for i in range(29):
        t = 2 ** i
        a2 = [A % (2 * t) for A in a]
        b2 = [B % (2 * t) for B in b]
        a2.sort()
        b2.sort()
        ansb = 0
        r1 = r2 = r3 = 0
        for A in reversed(a2):
            while r1 < N and A + b2[r1] < t:
                r1 += 1
            while r2 < N and A + b2[r2] < 2*t:
                r2 += 1
            while r3 < N and A + b2[r3] < 3*t:
                r3 += 1
            ansb += (r2 - r1) + (N - r3)
        ans += ((ansb %2 ) << i)
    print(ans)
    return


if __name__ == '__main__':
    B()

Solution (Python):
n=int(input())
l1=[input() for i in range(n)]
m=int(input())
l2=[input() for i in range(m)]
d={}
for w in l1:
    if w in list(d.keys()):
        d[w]+=1
    else:
        d[w]=1
for w in l2:
    if w in list(d.keys()):
        d[w]-=1
print(max(0,max(list(d.values()))))

Solution (Python):
a = int(input())
b = {}
for i in range(a):
    c = input()
    if c in b:
        b[c] += 1
    else:
        b.setdefault(c, 1)
a = int(input())
for i in range(a):
    c = input()
    if c in b:
        b[c] -= 1
    else:
        b.setdefault(c, 1)
b = sorted(b.values(), reverse=True)
print(max(b[0], 0))

Solution (Python):
from collections import defaultdict
n = int(input())
ds = defaultdict(int)
for i in range(n):
    s = input()
    ds[s] += 1


m = int(input())
for i in range(m):
    t = input()
    ds[t] -= 1

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

Solution (Python):
n=int(input())
s=[input() for _ in [0]*n]
m=int(input())
t=[input() for _ in [0]*m]
print(max([s.count(x)-t.count(x) for x in s]+[0]))

Solution (Python):

import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math





 
def main():
    N = int(input())
    S = {}
    
    for i in range(N):
        tmp = input()
        if tmp in S:
            S[tmp] += 1
        else:
            S[tmp] = 1
            
    M = int(input())
    for i in range(M):
        tmp = input()
        if tmp in S:
            S[tmp] -= 1
        else:
            S[tmp] = -1
            
    ans = 0
    for v in S.values():
        if ans < v:
            ans = v
    
    print(ans)
    
	
if __name__ == "__main__":
	main()

Solution (Python):
from collections import defaultdict
dic = defaultdict(int)
n = int(input())

for i in range(n):
    tmp = input()
    dic[tmp] += 1

m = int(input())
ans = 0
for i in range(m):
    tmp = input()
    dic[tmp] -= 1
print(max(max(dic.values()),0))

Solution (Python):
from collections import defaultdict
d = defaultdict(lambda : 0)
for i in range(int(input())): d[input()]+=1
for j in range(int(input())): d[input()]-=1
ans = max(d.values())
print(ans if ans>0 else 0)

Solution (Python):
n=int(input())
S=[input() for _ in range(n)]
m=int(input())
T=[input() for _ in range(m)]
li=[]
for word in S:
  s=S.count(word)
  t=T.count(word)
  li.append(s-t)
if max(li) < 0:print(0)
else:print(max(li))

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
ans = 0
for i in set(s):
  tmp = s.count(i)-t.count(i)
  if ans < tmp:
    ans = tmp 
print(ans)

Solution (Python):
from collections import Counter
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
ss = set(s)
sl = Counter(s)
tl = Counter(t)
goukei=[]
for i in ss:
  goukei.append(sl[i]-tl[i])
  
if max(goukei) > 0:
  print(max(goukei))
else:
  print(0)

Solution (Python):
a=int(input())
b=[str(input()) for i in range(a)]
c=int(input())
d=[str(input()) for i in range(c)]

bset=list(set(b))
e=[]
for i in bset:
  e.append(b.count(i)-d.count(i))

f=max(e)
print(max(0,f))

Solution (Python):


import sys

def input():
    return sys.stdin.readline().strip()

N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
a = set(s)
s_num = 0
t_num = 0
max_num = 0

for i in a:
    s_num = s.count(i)
    t_num = t.count(i)
    if max_num < s_num - t_num:
        max_num = s_num - t_num
print(max_num)

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

ans = 0

for i in set(s):
    ans = max(ans , s.count(i) - t.count(i))
print(ans)

Solution (Python):



from collections import defaultdict

n = int(input())
x = [str(input()) for _ in range(n)]
m = int(input())
y = [str(input()) for _ in range(m)]

dx = defaultdict(int)
dy = defaultdict(int)

for temp_x in x:
    dx[temp_x] += 1
for temp_y in y:
    dy[temp_y] += 1
    
max_count = 0
for k in dx.keys():
    max_count = max(max_count, dx[k] - dy[k])
    
print(max_count)

Solution (Python):
a = int(input())
b = {}
for i in range(a):
    c = input()
    if c not in b:
        b.setdefault(c, 1)
    else:
        b[c] = b.get(c) + 1
d = int(input())
for i in range(d):
    c = input()
    if c not in b:
        b.setdefault(c, 1)
    else:
        b[c] = b.get(c) - 1
b = sorted(b.values(), reverse=True)
print(max(b[0], 0))

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

ans = 0

for w in s:
    ans = max(ans, s.count(w) -  t.count(w))

print(ans)

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
ans = 0
s1 = list(set(s))
for i in s1:
    x = s.count(i) - t.count(i)
    if ans < x:
        ans = x
print(ans)

Solution (Python):
n = int(input())
s_list = [input() for i in range(n)]
m = int(input())
t_list = [input() for i in range(m)]

count_max = 0
for s in set(s_list):
    count = s_list.count(s) - t_list.count(s)
    if count > count_max:
        count_max = count
for t in set(t_list):
    count = s_list.count(t) - t_list.count(t)
    if count > count_max:
        count_max = count

print(count_max)

Solution (Python):
from collections import Counter
n = int(input())
ns = [input() for i in range(n)]
m = int(input())
ms = [input() for i in range(m)]
cn = dict(Counter(ns).most_common())
cm = dict(Counter(ms).most_common())
for i in cn.keys():
    cn[i] -= cm[i] if i in cm else 0
print(max(sorted(cn.values(), reverse=True)[0], 0))

Solution (Python):
n=int(input())
s=[str(input()) for i in range(n)]
m=int(input())
t=[str(input()) for i in range(m)]

mny_l=[]

for i in range(n):
    mny=0
    for j in range(n):
        if s[i]==s[j]:
            mny+=1
    for j in range(m):
        if s[i]==t[j]:
            mny-=1
    mny_l.append(mny)
ans=max(0,max(mny_l))
print(ans)

Solution (Python):
N = int(input())

dic = {}

for _ in range(N):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1

M = int(input())


for _ in range(M):
    s = input()
    if s in dic:
        dic[s] -= 1
    else:
        dic[s] = -1

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

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
count = 0
for s in S:
    count = max(count, S.count(s) - T.count(s))
print(count)

Solution (Python):
cardcost = {}
N = int(input())
for i in range(N):
    s = input()
    scost = cardcost.get(s, 0)
    cardcost[s] = scost+1

M = int(input())
for i in range(M):
    t = input()
    tcost = cardcost.get(t, 0)
    cardcost[t] = tcost-1


ans = max(cardcost.values())
if(ans > 0):
    print(ans)
else:
    print(0)

Solution (Python):



n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

ans = 0
for i in range(n):
    ans = max(ans,s.count(s[i])-t.count(s[i]))
print(ans)

Solution (Python):



def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [tuple(map(typ, input().split())) if m > 1 else typ(input()) for _ in range(n)]


def main():
    N, = read_h()
    s = read_v(N, typ=str)
    M, = read_h()
    t = read_v(M, typ=str)

    cnt = {}
    for si in s:
        cnt[si] = cnt.get(si, 0) + 1
    for ti in t:
        cnt[ti] = cnt.get(ti, 0) - 1

    ans = max(0, *cnt.values())
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
dict = {'A':0}
for i in range(n):
    str = input()
    dict[str] = dict.get(str,0) + 1
m = int(input())
for i in range(m):
    str = input()
    dict[str] = dict.get(str,0) - 1
print(max(dict.values()))

Solution (Python):
n = int(input())
dict = {'a':0}
for i in range(n):
    str = input()
    dict[str] = dict.get(str,0) + 1
m = int(input())
for i in range(m):
    str = input()
    dict[str] = dict.get(str,0) - 1
print(max(dict.values()))

Solution (Python):
a = int(input())
b = list(input() for i in range(a))
c = int(input())
d = list(input() for i in range(c))
e = [0]

for s in b:
  e.append(b.count(s)-d.count(s))
else:
  print(max(e))

Solution (Python):
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(blues, reds):
    blue_counts = {}
    red_counts = {}

    for b in blues:
        if b not in blue_counts:
            blue_counts[b] = 1
        else:
            blue_counts[b] += 1

    for r in reds:
        if r not in red_counts:
            red_counts[r] = 1
        else:
            red_counts[r] += 1

    max_count = 0
    for name, c in blue_counts.items():
        if name in red_counts:
            max_count = max(max_count, c - red_counts[name])
        else:
            max_count = max(max_count, c)
    return max_count


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    [N] = string_to_int(input())
    blues = inputs(N)
    [M] = string_to_int(input())
    reds = inputs(M)
    ret = solve(blues, reds)
    print(ret)

Solution (Python):
n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for i in range(m)]
x=[]
s.sort()
t.sort()

for i in range(n):
    x.append(s.count(s[i])-t.count(s[i]))

print(max(max(x),0))

Solution (Python):
n=int(input())
l_s=[str(input()) for _ in range(n)]
m=int(input())
l_t=[str(input()) for _ in range(m)]
s=set(l_s)
ans=0
for i in s:
    ans=max(ans,l_s.count(i)-l_t.count(i))
print(ans)

Solution (Python):
N = int(input())
d = {}
for _ in range(N):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

M = int(input())
for _ in range(M):
    s = input()
    if s in d:
        d[s] -= 1
    else:
        d[s] = -1

ans = 0
for v in d.values():
    ans = max(ans, v)

print(ans)

Solution (Python):
N = int(input())
s = [input().split() for i in range(N)]
M = int(input())
t = [input().split() for i in range(M)]
s.sort()
t.sort()
count = 0
s_sub = []
j = 0
for i in range(M):
    for j in range(N):
        if t[i] == s[j]:
            s[j] = ["0"]
            break
for i in range(N):
    if s[i][0] != "0":
        s_sub.append(s[i][0])
ans = 0
for i in range(len(s_sub)):
    count = 0
    for j in range(len(s_sub)):
        if s_sub[i] == s_sub[j]:
            count += 1
    if ans < count:
        ans = count
print(ans)

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]

dic = {}
for s in S:
    if s in dic.keys():
        dic[s] += 1
    else:
        dic[s] = 1
for t in T:
    if t in dic.keys():
        dic[t] -= 1
    else:
        dic[t] = -1

possible = dic.values()
print(max(possible) if max(possible) > 0 else 0)

Solution (Python):
N = int(input())
list_s = [input() for j in range(N)]
M = int(input())
list_t = [input() for i in range(M)]





list = []

for s in list_s:
    list.append(list_s.count(s) - list_t.count(s))
if max(list)>=0:
    print(max(list))
else:
    print(0)

Solution (Python):
N = int(input())
S = [input() for i in range(N)]
M = int(input())
T = [input() for i in range(M)]
 
Scores = []
for s in S:
  score = len([s2 for s2 in S if s == s2])
  score -= len([s2 for s2 in T if s == s2])
  Scores.append(score)
print(max(Scores) if max(Scores)>0 else 0)

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

ans = 0
for i in set(s + t):
    ans = max(s.count(i) - t.count(i), ans)
print(ans)

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

ans = 0
l = list(set(s))
for i in range(len(l)):
    ans = max(ans,  max(0, s.count(l[i]) - t.count(l[i])))
print(ans)

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
words = set(s+t)
ans = 0
for word in words:
    ansi = 0
    ansi += s.count(word)
    ansi -= t.count(word)
    ans = max(ans, ansi)
print(ans)

Solution (Python):
n = int(input())
lst_blue = [input() for i in range(n)]

m = int(input())
lst_red = [input() for i in range(m)]

ans = 0

for w in lst_blue:
    x = lst_blue.count(w)
    y = lst_red.count(w)
    num = x-y
    if num > ans:
        ans = num
print(ans)

Solution (Python):
n = int(input())
ao = [input() for _ in range(n)]
m = int(input())
aka = [input() for _ in range(m)]
str = set(ao + aka)
ans = 0
for i in str:
    temp = ao.count(i) - aka.count(i)
    ans = max(temp, ans, 0)
print(ans)

Solution (Python):
N=int(input())
result={}
s=[]
t=[]
for i in range(N):
  s.append(input())
  if s[i] in result.keys():
    result[s[i]]+=1
  else:
    result[s[i]]=1
M=int(input())
for j in range(M):
  t.append(input())
  if t[j] in result.keys():
    result[t[j]]-=1
if max(result.values()) > 0:
  print(max(result.values()))
else:
  print(0)

Solution (Python):
from collections import defaultdict
N = int(input())
counters = defaultdict(int)
conutert = defaultdict(int)
for i in range(N):
    s = input()
    counters[s] += 1
M = int(input())
for i in range(M):
    t = input()
    conutert[t] += 1

ans = 0
for k, v in counters.items():
    if conutert.get(k):
        ans = max(v-conutert[k], ans)
    else:
        ans = max(v, ans)
print(ans)

Solution (Python):
from collections import Counter

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

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

c1 = Counter(s)
c2 = Counter(t)
ans = max(v - c2[i] for i, v in c1.most_common())
print(max(0, ans))

Solution (Python):
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))

Solution (Python):
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))

Solution (Python):
n=int(input())
blue=[]
red=[]

for i in range(n):
    blue.append(input())

m=int(input())

for j in range(m):
    red.append(input())

ans=[]

for b in blue:
    if blue.count(b)<=red.count(b):
        ans.append(0)

    else:
        ans.append((blue.count(b)-red.count(b)))
print(max(ans))

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



s_set = list(set(s))
t_set = list(set(t))



deff_max = 0
for i in s_set:
    s_cnt = s.count(i)
    t_cnt = t.count(i)
    
    deff = s_cnt - t_cnt
    
    if deff_max < deff:
        deff_max = deff

print(deff_max)

Solution (Python):
if __name__ == '__main__':
    N = int(input())
    s_list = [str(input()) for i in range(N)]
    M = int(input())
    t_list = [str(input()) for i in range(M)]

    D = {}

    for s in s_list:
        if s in D.keys():
            D[s] = D[s] + 1
        else:
            D[s] = 1

    for t in t_list:
        if t in D.keys():
            D[t] = D[t] - 1
        else:
            D[t] = -1

    answer = max(0, max(D.values()))
    print(answer)

Solution (Python):
n = int(input())
s = sorted([input() for i in range(n)])

m = int(input())
t = sorted([input() for j in range(m)])

ans = 0

for i in range(n):
    name = s[i]
    count = s.count(name) - t.count(name)
    if count > ans:
        ans = count

print(ans)

Solution (Python):
n=int(input())
d=dict()
for i in range(n):
  a=input()
  if a not in d:
    d[a]=1
  else:
    d[a]+=1
m=int(input())
for i in range(m):
  a=input()
  if a not in d:
    d[a]=-1
  else:
    d[a]-=1
dl=sorted(d.items(),key=lambda x:x[1],reverse=True)
print(max(dl[0][1],0))

Solution (Python):
import sys

def input():
    return sys.stdin.readline().rstrip()

if __name__ == "__main__":
    n = int(input())
    sl = [input() for i in range(n)]

    m = int(input())
    tl = [input() for i in range(m)]

    maxcount = 0
    for s in set(sl):
        count = sl.count(s) - tl.count(s)
        if count > maxcount:
            maxcount = count

    print(maxcount)

Solution (Python):
import sys

def input():
    return sys.stdin.readline().rstrip()

if __name__ == "__main__":
    n = int(input())
    sl = [input() for i in range(n)]

    m = int(input())
    tl = [input() for i in range(m)]

    maxcount = 0
    for s in set(sl+tl):
        count = sl.count(s) - tl.count(s)
        if count > maxcount:
            maxcount = count

    print(maxcount)

Solution (Python):
import collections

n = int(input())
blue = [input() for _ in range(n)]
m = int(input())
red = [input() for _ in range(m)]

blue_cnter = collections.Counter(blue)
red_cnter = collections.Counter(red)

maxget = 0
for key, count in blue_cnter.items():
    
    bluecount = count
    redcount = red_cnter.get(key, 0)
    maxget = max(maxget, bluecount-redcount)
print(maxget)

Solution (Python):
N = int(input())
S = []
for n in range(N):
  S.append(input())
M = int(input())
T = []
for m in range(M):
  T.append(input())

ST_set = list(set(S + T))
ans = 0
for i in ST_set:
  money = S.count(i) - T.count(i)
  if ans < money:
    ans = money
print(ans)

Solution (Python):
from collections import defaultdict
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
S = defaultdict(int)
for i in range(N):
    S[s()] += 1

M = n()
T = defaultdict(int)
for i in range(M):
    T[s()] += 1

max_coin = 0

for k, v in S.items():
    coin = v - T[k]
    if coin > max_coin:
        max_coin = coin
for k, v in T.items():
    coin = S[k] - v
    if coin > max_coin:
        max_coin = coin

print(max_coin)

Solution (Python):
N = int(input())
A = []
ans = -100000000

for i in range(N):
    A.append(input())

M = int(input())
B = []

for i in range(M):
    B.append(input())

for c in A:
    X = A.count(c) - B.count(c)
    ans = max(ans, X)

if ans <= 0:
    print(0)
else:
    print(ans)

Solution (Python):
def abc():
    n = int(input())
    blue = {}
    for i in range(n):
        s = input().rstrip()
        blue[s] = blue.get(s, 0) + 1

    m = int(input())
    red = {}
    for i in range(m):
        s = input().rstrip()
        red[s] = red.get(s, 0) + 1

    ans = 0
    for k in blue.keys():
       ans = max(ans, blue.get(k) - red.get(k, 0))
    print(ans)


abc()

Solution (Python):
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]

s2 = set(s)

ans = 0

for i in s2:
    ans = max(s.count(i) - t.count(i), ans)

print(max(ans, 0))

Solution (Python):
N=int(input())
Blue=[ input() for i in range(N)]
M=int(input())
Red=[ input() for i in range(M)]
L=[0]
for b in set(Blue):
  L.append(Blue.count(b)-Red.count(b))
print(max(L))

Solution (Python):
n=int(input())
a=[]
for i in range(n):
  a.append(input())
m=int(input())
b=[]
for i in range(m):
  b.append(input())


ans=[]
for i in range(len(a)):
  z=a.count(a[i])
  ans.append(z-b.count(a[i]))


ans=max(ans)  
if ans<=0:
  print(0)
else:
  print(ans)

Solution (Python):
dic = {}

N = int(input())
for i in range(N):
  s = input()
  if s in dic:
    dic[s] += 1
  else:
    dic[s] = 1
M = int(input())
for i in range(M):
  t = input()
  if t in dic:
    dic[t] -= 1
  else:
    dic[t] = -1

sort_dic = sorted(dic.items(), key = lambda x:x[1], reverse = True)
print(sort_dic[0][1] if sort_dic[0][1] > 0 else 0)

Solution (Python):
from collections  import defaultdict
d = defaultdict(lambda :0)
N = int(input())
blues =[(input()) for _ in range(N)]

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

for blue in blues:
    d[blue] += 1
for red in reds:
    d[red] -= 1

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

Solution (Python):
N = int(input())
slist = []
for _ in range(N):
    slist.append(input())

M = int(input())
tlist = []
for _ in range(M):
    tlist.append(input())

slist_set = set(slist)
tlist_set = set(tlist)
all_set = list(slist_set | tlist_set)

anslist = []
for i in range(len(all_set)):
    ans = 0
    for j in range(N):
        if all_set[i] == slist[j]:
            ans += 1
    
    for j in range(M):
        if all_set[i] == tlist[j]:
            ans -= 1
    anslist.append(ans)
    
if max(anslist) < 0:
    print(0)
else:
    print(max(anslist))

Solution (Python):
from functools import reduce
import math
import collections
def main():
    
    
    
    

    
    
    
    
    
    

    
    

    
    
    
    
    
    
    
    
    
    INF = float("inf")

    
    MOD = 10**9+7
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    N = int(input())
    s = collections.defaultdict(int)
    for i in range(N):
        s[input()] += 1
    M = int(input())
    for i in range(M):
        s[input()] -= 1
    print(max(max(s.values()),0))
    
if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
dic = {}
for _ in range(n):
  s = input()
  if s in dic:
    dic[s] += 1
  else:
    dic[s] = 1
  
m = int(input())
for _ in range(m):
  t = input()
  if t in dic:
    dic[t] -= 1
  else:
    dic[t] = -1

ans = 0
for k, v in dic.items():
  ans = max(ans, v)
print(ans)

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
word = set(S + T)
ans = 0

for w in word:
    amount = S.count(w) - T.count(w)
    ans = max(ans, amount)

print(ans)

Solution (Python):
n=int(input())
s=[0]*n
for _ in range(n):
  s[_]=input()
sd={}
for _ in s:
  sd[_]=s.count(_)
m=int(input())
t=[0]*m
for _ in range(m):
  t[_]=input()
l=sd.keys()
for _ in t:
  if _ in l:
    sd[_]-=1
if max(sd.values())<0:
  print(0)
else:
  print(max(sd.values()))

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
scores = []
sCards = list(set(s))
for c in sCards:
    scores.append(s.count(c) - t.count(c))
if max(scores) < 0:
    print(0)
else:
    print(max(scores))

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

name_union = set(s) | set(t)
money = {}
for i, n in enumerate(name_union):
  money.setdefault(n, s.count(n) - t.count(n))

print(0 if max(money.values()) < 0 else max(money.values()))

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

name_union = set(s) | set(t)
money = {}
for i, n in enumerate(name_union):
  money.setdefault(n, 0)
  money[n] += sum(map(lambda x: 1 if x == n else 0, s))
  money[n] -= sum(map(lambda x: 1 if x == n else 0, t))


print(0 if max(money.values()) < 0 else max(money.values()))

Solution (Python):
N = int(input())
s, t = [], []
for n in range(N):
  s.append(input())

M = int(input())
for m in range(M):
  t.append(input())

name_union = set(s) | set(t)
money = {}
for i, n in enumerate(name_union):
  money.setdefault(n, 0)
  money[n] += sum(map(lambda x: 1 if x == n else 0, s))
  money[n] -= sum(map(lambda x: 1 if x == n else 0, t))


print(0 if max(money.values()) < 0 else max(money.values()))

Solution (Python):
from collections import Counter
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
ans = 0
sd = {k:v for k,v in Counter(s).items()}
td = {k:v for k,v in Counter(t).items()}
for key in sd.keys():
    try:
        ans = max(ans,sd[key]-td[key])
    except:
        ans = max(ans,sd[key])
print(ans)

Solution (Python):
from collections import defaultdict
d = defaultdict(int)

N = int(input())
for _ in range(N):
  d[input()] += 1

M = int(input())
for _ in range(M):
  d[input()] -= 1

answer = max(d.values())
if answer < 0:
  answer = 0
print(answer)

Solution (Python):
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
S = [sys.stdin.readline().rstrip() for _ in range(N)]
M = int(sys.stdin.readline())
T = [sys.stdin.readline().rstrip() for _ in range(M)]

ans = 0
for s in set(S):
    a = S.count(s)
    b = T.count(s)
    ans = max(ans, a - b, 0)

print(ans)

Solution (Python):
n = int(input())
lin = [input() for i in range(n)]
m = int(input())
lim = [input() for i in range(m)]

cnt = 0
for s in set(lin):
  tmp = lin.count(s) - lim.count(s)
  cnt = max(cnt,tmp)
print(cnt)

Solution (Python):
n=int(input())
sl=[input() for _ in range(n)]
m=int(input())
tl=[input() for _ in range(m)]
ans=0
for s in sl:
    ans=max(ans,sl.count(s)-tl.count(s))
print(ans)

Solution (Python):
n=int(input())
sl=[input() for _ in range(n)]
m=int(input())
tl=[input() for _ in range(m)]
ans=0
for s in sl:
    ans=max(ans,sl.count(s)-tl.count(s))
print(ans)

Solution (Python):
N = int(input())
s = {}
t = {}
for i in range(N):
    k = input()
    if k not in s.keys():
        s[k] = 0
        t[k] = 0
    s[k] += 1

M = int(input())

for i in range(M):
    k = input()
    if k not in t.keys():
        t[k] = 0
    t[k] += 1

ans = 0
for k in s.keys():
    ans = max(ans , s[k] - t[k])
print(ans)

Solution (Python):
n = int(input())
s = []
for i in range(n):
    si = input()
    s.append(si)
m = int(input())
t = []
for i in range(m):
    ti = input()
    t.append(ti)
ans = 0
for i in s:
    ans = max(ans,s.count(i)-t.count(i))
print(ans)

Solution (Python):


n = int(input())
s = [input() for i in range(n)]

m = int(input())
t = [input() for i in range(m)]

sset = list(set(s))

ans = 0
for i in range(len(sset)):
    a = sset[i]
    ans = max(ans, s.count(a) - t.count(a))

print(ans)