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):
import sys
import math
import itertools
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

n = I()
s = [S() for i in range(n)]
m = I()
t = [S() for i in range(m)]
ans,cnt = 0,0
for i in s:
    cnt = 0
    l = [k for k,x in enumerate(s) if x == i]
    cnt += len(l)
    l = [k for k,x in enumerate(t) if x == i]
    cnt -= len(l)
    ans = max(cnt,ans)
print(ans)

Solution (Python):
word=[]
blue=[]
red=[]
n=int(input())
for i in range(n):
  s=input()
  blue.append(s)
  if not s in word:
    word.append(s)
    
m=int(input())
for i in range(m):
  s=input()
  red.append(s)
  if not s in word:
    word.append(s)
ans=0
for wd in word:
  x=blue.count(wd)-red.count(wd)
  if ans<x:
    ans=x
print(ans)

Solution (Python):
def dic_inc(d,k,v):
    if k in d: d[k] += v
    else: d[k] = v

s = {}
n = int(input())
for _ in range(n): dic_inc(s, input(), 1)
m = int(input())
for _ in range(m): dic_inc(s, input(),-1)
print(max(0, max(s.values())))

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

s = {}
for _ in range(n):
    x = input()
    if x in s: s[x] += 1
    else: s[x] = 1

m = int(input())
t = {}
for _ in range(m):
    x = input()
    if x in t: t[x] += 1
    else: t[x] = 1

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

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





s = {}
for x in S:
    if x in s:
        s[x] += 1
    else:
        s[x] = 1

t = {}
for x in T:
    if x in t:
        t[x] += 1
    else:
        t[x] = 1


ans = 0
for k,v in s.items():
    
    c = v
    if k in t:
        c -= t[k]
    ans = max([ans,c])
print(ans)

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

Solution (Python):
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
SDic = Counter(S)

M = int(input())
T = [input() for _ in range(M)]
TDic = Counter(T)

DiffDic = SDic - TDic
if len(DiffDic)!=0:
    print(max(DiffDic.values()))
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)]

mx = 0
for ss in s:
	mx = max(s.count(ss) - t.count(ss),mx)

print(mx)

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

ctr_s = collections.Counter(s)
ctr_t = collections.Counter(t)
ans = 0
for k,v in ctr_s.items():
    if ctr_s[k]:
        ans = max(ans, v - ctr_t[k])
    else:
        ans = max(ans, v)
print(ans)

Solution (Python):
n = int(input())
S = []
T =[]

for _ in range(n):
    s = input()
    S.append(s)
    
m = int(input())
for _ in range(m):
    t = input()
    T.append(t)

from collections import Counter
cnt_s = Counter(S)
cnt_t = Counter(T)
ans = []
'''
for ks,vs in cnt_s.items():
    for kt,vt in cnt_t.items():
        if ks == kt:
            vs = vs - vt
'''

ans = cnt_s - cnt_t

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

Solution (Python):
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
result = {}
for i in s:
  if i not in result:
    result[i] = s.count(i) - t.count(i)
result = sorted(result.items(), key=lambda x:-x[1])
print(result[0][1] if result[0][1] > 0 else 0)

Solution (Python):
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
s_t_set = set(s + t)
ans = 0
for word in s_t_set:
    counter = 0
    counter += s.count(word)
    counter -= t.count(word)
    ans = max(ans, counter)
print(ans)

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())
val = [0]
for s in set(S):
    val.append(S.count(s) - T.count(s))
print(max(val))

Solution (Python):
n = int(input())
S = [input() for i in range(n)]
m = int(input())
T = [input() for j in range(m)]

ANS = []
for i in range(len(S)):
  p = 0
  q = 0
  for j in range(len(S)):
    if S[i]== S[j]:
      p += 1
  for k in range(len(T)):
    if S[i] == T[k]:
      q += -1
  ANS.append(p+q)

print(max(max(ANS),0))

Solution (Python):
N = int(input())
Count = {}
for _ in range(N):
    s = input()
    if s not in Count:
        Count[s] = [1, 0]
    else:
        Count[s][0] += 1
M = int(input())
for _ in range(M):
    s = input()
    if s not in Count:
        Count[s] = [0, 1]
    else:
        Count[s][1] += 1
ANS = []
for t in Count.values():
    ANS.append(t[0] - t[1])
print(max(0, max(ANS)))

Solution (Python):
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)
gain = 0
for text in s.keys():
  if text in t.keys():
    gain_0 = s[text]-t[text]
    if gain < gain_0:
      gain = gain_0
  else:
    gain_0 = s[text]
    if gain < gain_0:
      gain = gain_0
        
print(gain)

Solution (Python):
n = int(input())
words = dict()
for _ in range(n):
    s = input()
    words.setdefault(s, 0)
    words[s] += 1

m = int(input())
for _ in range(m):
    s = input()
    words.setdefault(s, 0)
    words[s] -= 1

mc = 0
for k, c in words.items():
    mc = max(mc, c)

if mc < 0:
    print(0)
else:
    print(mc)

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

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

Solution (Python):
def counting_sort(array_b, max_b, array_r, max_r):
    bucket = {}
    for i in array_b:
        if i in bucket:
            bucket[i] += 1
            continue
        bucket[i] = 1

    for j in array_r:
        if j in bucket:
            bucket[j] -= 1
            continue
        else:
            bucket[j] = -1

    return bucket


def main():
    N = int(input())
    blue_list = [input() for _ in range(N)]
    M = int(input())
    red_list = [input() for _ in range(M)]
    ans_bucket = counting_sort(blue_list, N, red_list, M)
    ans_list = []
    for k in blue_list:
        ans_list.append(ans_bucket[k])
    for h in red_list:
        ans_list.append(ans_bucket[h])
    ans_list.sort(reverse = True)
    if ans_list[0] < 0:
        print(0)
    else:
        print(ans_list[0])
    
    

main()

Solution (Python):
from collections import defaultdict
b = defaultdict(int)
r = defaultdict(int)
ans = defaultdict(int)

n = int(input())
for i in range(n):
  s = input()
  b[s] += 1

m = int(input())
for i in range(m):
  s = input()
  r[s] += 1

for e in b.keys(): 
  if e in r.keys():
    ans[e] = b[e] - r[e]
  else:
    ans[e] = b[e]

p = ans.values()
p = list(p)
p.append(0)
print(max(p))

Solution (Python):
words = {}
n = int(input())
for i in range(n):
    s = input()
    if not s in words:
        words[s] = 1
    else:
        words[s] += 1
m = int(input())
for i in range(m):
    s = input()
    if not s in words:
        words[s] = -1
    else:
        words[s] -= 1

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

Solution (Python):
from collections import defaultdict

n = int(input())
s_list = [input() for _ in range(n)]
m = int(input())
t_list = [input() for _ in range(m)]

def make_count_dict(target_list):
    count_dict = defaultdict(int)
    for key in target_list:
        count_dict[key] += 1
    return count_dict

s_dict = make_count_dict(s_list)
t_dict = make_count_dict(t_list)

ans = 0
for s in s_dict.keys():
    temp = s_dict[s] - t_dict[s]
    if temp > ans:
        ans = temp
print(ans)

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

counter = collections.Counter()

for i in s:
    counter[i] += 1

for j in t:
    counter[j] -= 1

ans = max(counter.values())

print(ans if ans >=0 else 0)

Solution (Python):
import collections
n = int(input())
fir = [str(input()) for _ in range(n)]
m = int(input())
sec = [str(input()) for _ in range(m)]
fc = []
sc = []
fn = []
sn = []
fir.sort()
sec.sort()
k = 1
for i in range(n-1):
    if fir[i] != fir[i+1]:
        fc.append(k)
        fn.append(fir[i])
        k = 1
    else:
        k += 1
fc.append(k)
fn.append(fir[-1])
l = 1
for j in range(m-1):
    if sec[j] != sec[j+1]:
        sc.append(l)
        sn.append(sec[j])
        l = 1
    else:
        l += 1
sc.append(l)
sn.append(sec[-1])
for p in sn:
    if p in fn:
        q = fn.index(p)
        fc[q] -= sc[sn.index(p)]
print(max(max(fc),0))

Solution (Python):
ans=0
n=int(input())
lst=[]
for i in range(n):
  lst.append(input())
m=int(input())
x=[]
for j in range(m):
  x.append(input())
for k in set(lst):
  c=lst.count(k)-x.count(k)
  ans=max(ans,c)
print(ans)

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
A = []
B = []
for s in S:
    if s not in A:
        B.append(S.count(s)-T.count(s))
        A.append(s)
ans = max(B)
if ans < 0:
  ans = 0
print(ans)

Solution (Python):
N = int(input())
nn = []
mm = []
ll = []
ans = 0
for i in range(N):
  k = input()
  nn.append(k)
  ll.append(k)
M = int(input())
l_s = set(ll)
for i in range(M):
  k = input()
  mm.append(k)
for i in l_s:
  count = 0
  for j in nn:
    if i == j:
      count += 1
  for j in mm:
    if i == j:
      count -= 1
  if count > ans:
    ans = count
print(ans)

Solution (Python):
n=int(input())
br=[]
for i in range(n):
  br.append(input())
m=int(input())
re=[]
for i in range(m):
  re.append(input())
point=[]
for i in br:
  bri=br.count(i)
  rei=re.count(i)
  point.append(bri-rei)
point.append(0)
print(max(point))

Solution (Python):
import bisect

def solve(n,m,s,t):
    res = 0
    for string in s:
        plus = bisect.bisect_right(s,string)
        plus -= bisect.bisect_left(s,string)
        minus = bisect.bisect_right(t,string)
        minus -= bisect.bisect_left(t,string)
        tmp = plus - minus
        res = max(res,tmp)
    return res

if __name__ == '__main__':
    n = int(input())
    s = []
    for i in range(n):
        si = input()
        bisect.insort_left(s,si)
    m = int(input())
    t = []
    for i in range(m):
        ti = input()
        bisect.insort_left(t,ti)
    print(solve(n,m,s,t))

Solution (Python):

n=[input() for _ in range(int(input()))]
m=[input() for _ 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))])))

Solution (Python):
n = int(input())
d = {}
for i in range(n):
    s = input()
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1
m = int(input())
for i in range(m):
    s = input()
    if s not in d:
        continue
    else:
        d[s] -= 1
print(max(max(d.values()),0))

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

ST = S + T
ST_set= set(ST)

list = []
for i in ST_set:
    list.append(S.count(i) - T.count(i))

if max(list) > 0:
    print(max(list))
else:
    print(0)

Solution (Python):
N=int(input())
from collections import defaultdict
d = defaultdict(int)
for i in range(N):
  s=input()
  d[s]+=1
M=int(input())
for i in range(M):
  s=input()
  d[s]-=1
a=sorted(list(d.values()))
print(max(a[-1],0))

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

for i in u:
    cnt = 0
    for j in s:
        if i == j:
            cnt += 1
    for k in t:
        if i == k:
            cnt -= 1
    l.append(cnt)
print(max(0, max(l)))

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

for i in u:
    cnt = 0
    for j in s:
        if i == j:
            cnt += 1
    for j in t:
        if i == j:
            cnt -= 1
    l.append(cnt)

print(max(0, max(l)))

Solution (Python):
import collections

N=int(input())
A=[]
for _ in range(N):
	A.append(input())
M=int(input())
B=[]
for _ in range(M):
	B.append(input())
A=sorted(A)
B=sorted(B)
ans=0
X=collections.Counter(A)
Y=collections.Counter(B)
for i,j in X.items():
	tmp=j
	for p,q in Y.items():
		if i==p:
			tmp=j-q
	ans=max(ans,tmp)
print(ans)

Solution (Python):

import math


def inp():
    return(int(input()))



def inlist():
    return(list(map(int, input().split())))



def instr():
    s = input()
    return(list(s[:len(s)]))



def invr():
    return(map(int, input().split()))


n = inp()
blue = []
red = []
for _ in range(n):
    blue.append(input())

m = inp()
for _ in range(m):
    red.append(input())
res = 0
for b in blue:
    res1 = blue.count(b)
    res2 = red.count(b)
    res = max(res, res1 - res2)
print(res)

Solution (Python):
from collections import Counter
N = int(input())
blue = Counter([input() for _ in range(N)])
M = int(input())
red = Counter([input() for _ in range(M)])
Max = 0
for key in blue:
    if key in red:
        point = blue[key] - red[key]
    else:
        point = blue[key]
    
    if point>Max:
        Max = point
print(Max)

Solution (Python):
import sys
from collections import Counter

input = sys.stdin.readline


def main():
    N = int(input())
    s = [""] * N
    for i in range(N):
        s[i] = input().rstrip()
    M = int(input())
    t = [""] * M
    for i in range(M):
        t[i] = input().rstrip()

    c_s = Counter(s)
    c_t = Counter(t)
    t_keys = c_t.keys()
    t_items = dict(c_t.items())
    ans = 0
    for k, v in c_s.items():
        money = v
        if k in t_keys:
            money -= t_items[k]
        if money > ans:
            ans = money

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
import math
import itertools
import collections
import heapq
import numpy as np

rl = sys.stdin.readline

n = int(rl())

blue = [rl() for _ in range(n)]

m = int(rl())
red = [rl() for _ in range(m)]

ans = 0
for i in list(set(blue)):
    b = blue.count(i) - red.count(i)
    if b > ans:
        ans = b
print(ans)

Solution (Python):
from collections import Counter

bag = Counter()

N  = int(input())

word_s = []
word_t = []

for i in range(N):
    bag[input()] += 1

M  = int(input())
for i in range(M):
    bag[input()] -= 1

max = sorted(bag.items(), key=lambda item: item[1], reverse=True)[0][1]

if max > 0:
    print(max)
else:
    print(0)

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

S = set(s)
ans = []
for i in S:
    cnt = 0
    for j in s:
        if i == j:
            cnt += 1
    for h in t:
        if i == h:
            cnt -= 1
    ans.append(cnt)

value = max(ans)

if value < 0:
    print(0)
else:
    print(value)

Solution (Python):
from collections import Counter

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

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

s_counter = Counter(S)
t_counter = Counter(T)

result = 0

for k, v in s_counter.items():
    result = max(result, v - (t_counter[k] if t_counter[k] else 0))

print(result if result > 0 else 0)

Solution (Python):
n=int(input())
s={}
for _ in range(n):
    i=input()
    if i in s:
        s[i]+=1
    else:
        s[i]=1
m=int(input())
for _ in range(m):
    j=input()
    if j in s:
        s[j]-=1
ans=max(s.values())
if ans<0:
    print(0)
else:
    print(ans)

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

for _ in range(m):
    t.append(input())
    
point=[None]*100

max_point=0

for i in range(len(s)):
    point_s=s.count(s[i])
    point_t=-1*t.count(s[i])
    point_sum=point_s+point_t
    max_point=max(max_point,point_sum)
    
print(max_point)

Solution (Python):
from collections import defaultdict


N = int(input())
blue_cards = defaultdict(int)
for _ in range(N):
    blue_cards[input()] += 1
M = int(input())
red_cards = defaultdict(int)
for _ in range(M):
    red_cards[input()] += 1
ans = 0
for string, score in blue_cards.items():
    ans = max(ans, score - red_cards.get(string, 0))
print(ans)

Solution (Python):
from collections import Counter
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
s = [readline().decode().rstrip() for _ in range(n)]
m = int(readline())
t = [readline().decode().rstrip() for _ in range(m)]

sc = Counter(s)
tc = Counter(t)
ans = 0
for k, v in sc.items():
    if k in tc.keys():
        ans = max(ans, v-tc[k])
    else:
        ans = max(ans, v)
print(ans)

Solution (Python):
n = int(input())
ds = {"hoge" : 0}
dt = {"hoge" : 0}
a = set()
for i in range(n):
    s = input()
    if s not in a:
        a.add(s)
        ds[s] =1
        dt[s] = 0
    else:
        ds[s] += 1
m = int(input())
for i in range(m):
    t = input()
    if t not in a:
        a.add(t)
        ds[t] = 0
        dt[t] = 1
    else:
        dt[t] += 1
b = 0
for i in a:
    c = ds[i] - dt[i]
    if b <= c:
        b = c
print(b)

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
set_s = list(set(s))
m = int(input())
t = [input() for _ in range(m)]
ans = [s.count(set_s[i]) - t.count(set_s[i]) for i in range(len(set_s))]
print(max(0, max(ans)))

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

from collections import Counter
CS = Counter(S)
CT = Counter(T)
maxv = 0
for k, v in CS.items():
	maxv = max(maxv, v - CT[k])
print(maxv)

Solution (Python):
n = int(input())
D = {}
for i in range(n):
	x = input()
	if x not in D:
		D[x] = 1
	else:
		D[x] += 1
m = int(input())
for i in range(m):
	x = input()
	if x in D:
		D[x] -= 1
print(max(0, max(D.values())))

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

reward = [0]
for st in s:
    r = s.count(st) - t.count(st)
    reward.append(r)
print(max(reward))

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
s = [input() for _ in range(N)]
M = INT()
t = [input() for _ in range(M)]
dic_s = defaultdict(int)
dic_t = defaultdict(int)
for st in s:
	dic_s[st] += 1
for st in t:
	dic_t[st] += 1

ans = 0
for st in dic_s:
	ans = max(ans, dic_s[st]-dic_t[st])
print(ans)

Solution (Python):
n=int(input())
slist=[]
sset=set()
for i in range(n):
    slist.append(input())
    sset.add(slist[i])
m=int(input())
ans=0
mlist=[]
for i in range(m):
    mlist.append(input())
for i in range(len(sset)):
    sstr=sset.pop()
    snum=slist.count(sstr)
    mnum=mlist.count(sstr)
    num=snum-mnum
    if num>ans:
        ans=num
print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
Plus = defaultdict(int)
for _ in range(N):
	s = input()
	Plus[s] += 1

M = INT()
Minus = defaultdict(int)
for _ in range(M):
	s = input()
	Minus[s] += 1

ans = 0
for x in Plus:
	ans = max(ans, Plus[x]-Minus[x])

print(ans)

Solution (Python):
import collections

n = int(input())
s = [input() for x in range(n)]
m = int(input())
t = [input() for y in range(m)]
ans = 0

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

for k, v in S.items():
    tmp = 0
    tmp = v
    if k in T:
        tmp -= T[k]
    ans = max(ans, tmp)

print(ans)

Solution (Python):
from collections import defaultdict

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

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

print(max(max(d.values()), 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 i in range(n):
    ans = max(ans, s.count(s[i])-t.count(s[i]))

print(ans)

Solution (Python):
from collections import Counter
n = int(input())
S = Counter([input() for i in range(n)])
m = int(input())
T = Counter([input() for i in range(m)])

ans = 0
for k, v in S.items():
    tmp = v
    if k in T:
        tmp -= T[k]
    ans = max(ans, tmp)
            
print(ans)

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 s:
    ans = max(ans, s.count(i) - t.count(i))

print(ans)

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

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

max_c = -float('inf')
for v in cards.values():
  max_c = max(max_c, v)
print(max(0, max_c))

Solution (Python):
a=[input() for _ in range(int(input()))]
for _ in range(int(input())):
    t=input()
    if t in a:
        a.remove(t)
d={}
for i in a:
  d[i]=d.get(i,0)+1
print(max(d.values()) if a else 0)

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

Solution (Python):



def main():
    Res = {}
    N = int(input())
    for i in range(N):
        x=input()
        if x in Res:
            Res[x]+=1
        else:
            Res[x]=1
    M = int(input())
    for i in range(M):
        x=input()
        if x in Res:
            Res[x]-=1
        else:
            Res[x]=-1
    dics = sorted(Res.items(), key=lambda x:x[1], reverse = True)[0]
    print(max(0,dics[1]))

if __name__ == '__main__':
    main()

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.append(s.count(i)-t.count(i))
print(max(ans))

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

m=int(input())
for i in range(m):
    r.append(input())

ans=0
for word in b:
    tmp=0
    for j in range(len(b)):
        if b[j]==word:
            tmp+=1
    for j in range(len(r)):
        if r[j]==word:
            tmp-=1
    if tmp>ans:
        ans=tmp
print(ans)

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
dict = {}
for ss in s :
    if ss in dict :
        dict[ss] += 1
    else :
        dict[ss] = 1
for tt in t:
    if tt in dict:
        dict[tt] -= 1
print(max(list(dict.values())+[0]))

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
sm = {}
for s in S:
    if s in sm:
        sm[s] += 1
    else:
        sm[s] = 1
for t in T:
    if t in sm:
        sm[t] -= 1
print(max(list(sm.values())+[0]))

Solution (Python):
n=int(input())
a=[]
b=[]
ans=0

for i in range(n):
    a.append(input())
m=int(input())
for i in range(m):
    b.append(input())
for i in a:
    if i not in b:
        ans=max(ans,a.count(i))
    else:
        ans=max(ans,a.count(i)-b.count(i))
print(ans)

Solution (Python):
N = int(input())
worddict = {}
for i in range(N):
  s = input()
  if s in worddict:
    worddict[s] += 1
  else:
    worddict[s] = 1
    
M = int(input())
for i in range(M):
  t = input()
  if t in worddict:
    worddict[t] -= 1
    
maxyen = 0
for i in worddict:
  maxyen = max(maxyen, worddict[i])
print(maxyen)

Solution (Python):


import sys









from collections import defaultdict          




















def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    d = defaultdict(int)
    n = ii()
    for _ in range(n):
        s = input()
        d[s] += 1
    m = ii()
    for _ in range(m):
        t = input()
        d[t] -= 1
    
    print(max(0, max(d.values())))


if __name__ == "__main__":
    main()

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

from collections import defaultdict
d=defaultdict(int)
for plus_word in s:
    d[plus_word]+=1
for minus_word in t:
    d[minus_word]-=1

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

Solution (Python):
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()
import collections
c = collections.Counter(s)
d = collections.Counter(t)

m = -101
for i in range(n):
    m = max(m,c[s[i]]-d[s[i]])
for i in range(n):
    m = max(m,c[s[i]]-d[s[i]])
print(max(m,0))

Solution (Python):
from collections import defaultdict

words = defaultdict(int)
for _ in range(int(input())):
    words[input()] += 1
for _ in range(int(input())):
    words[input()] -= 1
print(max([x for x in words.values()] + [0]))

Solution (Python):
from collections import defaultdict

words = set()
blue = defaultdict(int)
red = defaultdict(int)
for _ in range(int(input())):
    w = input()
    words.add(w)
    blue[w] += 1
for _ in range(int(input())):
    w = input()
    words.add(w)
    red[w] += 1
ans = 0
for w in words:
    ans = max(ans, blue[w] - red[w])
print(ans)

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

cards = {

}

for s in range(n):
    word = input()
    if word not in cards:
        cards[word] = 1
    else:
        cards[word] += 1

m = int(input())

for r in range(m):
    word = input()
    if word not in cards:
        cards[word] = -1
    else:
        cards[word] -= 1

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

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

Solution (Python):
import sys

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))

def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]

def to_bin(x: int) -> str: return format(x, 'b') 
def to_oct(x: int) -> str: return format(x, 'o') 
def to_hex(x: int) -> str: return format(x, 'x') 
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]

from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left


def main():
    n = II()
    ss = Counter([IS() for _ in range(n)])
    m = II()
    tt = Counter([IS() for _ in range(m)])
    tt_key = set(tt.keys())
    maxv = 0
    for s, c in ss.items():
        cnt = c
        if s in tt_key:
            cnt -= tt[s]
        maxv = max(maxv, cnt)
    print(maxv)


if __name__ == '__main__':
    main()

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

for i in ss:
    if i not in t:
        ans = max(ans, s.count(i))
    else:
        ans = max(ans, s.count(i)-t.count(i))
print(ans)