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):
s = []
t = []

N = int(input())
for i in range(N):
    s.append(input())

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

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

print(count)

Solution (Python):


import itertools
import collections
import bisect

def main():
    N = int(input())
    S = [input() for _ in range(N)]
    sc = collections.Counter(S)
    M = int(input())
    T = [input() for _ in range(M)]
    tc = collections.Counter(T)

    ans = 0
    for item in sc.items():
        ans = max(ans, item[1] - tc[item[0]])
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict


def main():
    N = int(input())
    d = defaultdict(lambda: 0)
    for _ in range(N):
        s = input()
        d[s] += 1
    M = int(input())
    for _ in range(M):
        s = input()
        d[s] -= 1
    print(max(list(d.values()) + [0]))


if __name__ == "__main__":
    main()

Solution (Python):

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

Solution (Python):
import collections
n = int(input())
s = []
for i in range(n):
	s.append(input())
m = int(input())
t = []
for i in range(m):
	t.append(input())
cs = collections.Counter(s)
ct = collections.Counter(t)
ans = []
for i in range(len(cs)):
	for j in range(len(ct)):
		if cs.most_common()[i][0] == ct.most_common()[j][0]:
			ans.append([cs.most_common()[i][1] - ct.most_common()[j][1], cs.most_common()[i][0]])
			break
	if cs.most_common()[i][0] not in ct.keys():
		ans.append([cs.most_common()[i][1], cs.most_common()[i][0]])
ans.sort(reverse=True)
if ans[0][0] <= 0:
	print(0)
else:
	print(ans[0][0])

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:
    Dic[s] = Dic.get(s,0) + 1
for t in T:
    Dic[t] = Dic.get(t,0) - 1
             
print(max(max(Dic.values()),0))

Solution (Python):
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    S = [str(input().strip()) for _ in range(N)]
    M = int(input())
    T = [str(input().strip()) for _ in range(M)]

    ans = 0
    for s in S:
        cur = sum([s == a for a in S]) - sum([s == b for b in T])
        ans = max(ans, cur)
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
blue=[]
for i in range(n):
    blue.append(input())
m=int(input())
red=[]
for i in range(m):
    red.append(input())
maximam=0
for i in blue:
    b=blue.count(i)
    r=red.count(i)
    maximam=max(maximam,b-r)
print(maximam)

Solution (Python):
n=int(input())
blue=[]
for i in range(n):
    blue.append(input())
m=int(input())
red=[]
for i in range(m):
    red.append(input())
max=0
for i in blue:
    b=blue.count(i)
    r=red.count(i)
    if b-r>max:max=b-r
print(max)

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

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

cnt = [0]
for i in range(len(s)):
    cnt.append(s.count(s[i]))
print(max(cnt))

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

red = {}
for i in T:
    if i not in red:
        red[i] = 1
    else:
        red[i] += 1

blue = {}
for i in S:
    if i not in blue:
        blue[i] = 1
    else:
        blue[i] += 1

res = 0
for i in set(S):
    if i not in red:
        tmp = blue[i]
    else:
        tmp = blue[i] - red[i]

    if res < tmp:
        res = tmp

print(res)

Solution (Python):

import collections
b = []
n = int(input())
for _ in range(n):
    b.append(input())
bc = collections.Counter(b)
r = []
n = int(input())
for _ in range(n):
    r.append(input())
rc = collections.Counter(r)
c = [0]
for bv in bc.keys():
    c.append(bc[bv] - rc[bv])
print(max(c))

Solution (Python):

"""
Created on Sat Mar  2 22:51:25 2019

@author: yuta
"""
from collections import Counter

N = int(input())
S = [input() for i in range(N)]
M = int(input())
T = [input() for j in range(M)]

def main(s,t):
    count_blue = Counter(s)
    count_red = Counter(t)
    all_str = list(set(s+t))
    count_max = 0
    for i in all_str:
        count_i = count_blue[i] - count_red[i]
        if count_i >= count_max:
            count_max = count_i
    print(count_max)

main(S,T)

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

res = 0
for si in set(s):
    res = max(res, s.count(si) - t.count(si))
print(res)

Solution (Python):
n=int(input())
a=[input() for i in range(n)]
m=int(input())
b=[input() for i in range(m)]
ans=0
for ai in set(a):
  n=a.count(ai)-b.count(ai)
  if n>ans:
    ans=n
print(ans)

Solution (Python):
from collections import Counter
N = int(input())
S = Counter([input() for _ in range(N)])
M = int(input())
T = Counter([input() for _ in range(M)])
n = 0
for s, s_c in S.items():
    t_c = 0 if s not in T else T[s]
    n = max(n, s_c - t_c)
print(n)

Solution (Python):


import collections

N = int(input())

blue_card = []
red_card = []
ans = 0
for i in range(N):
    blue_card.append(input())

M = int(input())

for i in range(M):
    red_card.append(input())
    
blue = collections.Counter(blue_card)
red = collections.Counter(red_card)

for i in blue.items():
    k,v = i[0],i[1]
    ans = max(ans,v-red.get(k,0))
        
print(ans)

Solution (Python):
def main():
	n = int(input())
	lst = {}
	for _ in range(n):
		temp = input()
		if temp in lst:
			lst[temp] = lst[temp]+1
		else:
			lst[temp] = 1
	m = int(input())
	for _ in range(m):
		temp = input()
		if temp in lst:
			lst[temp] = lst[temp] - 1
	ans = 0
	for i in lst:
		ans = max(lst[i], ans)
	print(ans)

main()

Solution (Python):
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
u = set(s)
count = []
cnt = 0
for i in u:
    count.append(s.count(i))
    count[cnt] -= t.count(i)
    cnt += 1
res = max(count)
if res <= 0:
    print(0)
else:
    print(res)

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
ds = {}
dt = {}
for word in s:
    if word not in ds:
        ds[word] = 1
    else:
        ds[word] += 1
for word in t:
    if word not in dt:
        dt[word] = 1
    else:
        dt[word] += 1
ret = 0
for word, count in ds.items():
    if word not in dt:
        tcount = 0
    else:
        tcount = dt[word]
    ret = max(ret, count - tcount)
print(ret)

Solution (Python):
def main():
    N = int(input())
    s = [input() for _ in range(N)]
    M = int(input())
    t = [input() for _ in range(M)]
    ans = 0
    for ss in s:
        ans = max(ans, s.count(ss) - t.count(ss))
    print(ans)


main()

Solution (Python):
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
d1, d2 = {}, {}
for i in s:
    d1.setdefault(i, 0)
    if i in d1:
        d1[i] += 1
for i in t:
    d2.setdefault(i, 0)
    if i in d2:
        d2[i] += 1
bucket = [d1[i]-d2[i] if i in d2 else d1[i] for i in d1]
ans = max(bucket)
if ans > 0:
    print(ans)
else:
    print(0)

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

s_c=collections.Counter(s)
t_c=collections.Counter(t)
a_l=[]
for i in s_c.keys():
    a_l.append(s_c[i]-t_c[i])
if max(a_l)>0:
    ans=max(a_l)
else:
    ans=0
print(ans)

Solution (Python):
n = int(input())
dic = {}
key = ''
for i in range(n):
  key = input()
  if (key in dic.keys())==True:
    dic[key] += 1
  else:
    dic[key] = 1
m = int(input())
for i in range(m):
  key = input()
  if (key in dic.keys())==True:
    dic[key] -= 1
  else:
    dic[key] = -1
print(max(max(dic.values()),0))

Solution (Python):
def main():
    N = int(input())
    s_dict = {}
    for i in range(N):
        inp = input()
        if inp not in s_dict.keys():
            s_dict[inp] = 1
        else:
            s_dict[inp] += 1
    M = int(input())
    t_dict = {}
    for i in range(M):
        inp = input()
        if inp not in t_dict.keys():
            t_dict[inp] = 1
        else:
            t_dict[inp] += 1
    ans = 0
    for word in s_dict.keys():
        blue = s_dict[word]
        red = t_dict[word] if word in t_dict.keys() else 0
        get = blue - red
        if get > ans:
            ans = get
    print(ans)


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 range(n) :
    ans = max(ans, S.count(S[i]) - T.count(S[i]))

print(ans)

Solution (Python):
A = {}

N = input()
for i in range(N):
  s = raw_input()
  if s not in A:
    A[s] = 0
  A[s] += 1
M = input()
for i in range(M):
  t = raw_input()
  if t not in A:
    A[t] = 0
  else:
    A[t] -= 1
print max(A.values()+[0])

Solution (Python):
n=int(input())
s=[]
for x in range(n):
    s.append(input())
m=int(input())
t=[]
for y in range(m):
    t.append(input())
q=0
for i in range(n):
    v=s[i]
    c=0
    for k in range(i,n):
        if v==s[k]:
            c+=1
    for j in range(m):
        if v==t[j]:
            c-=1
    if c>q:
        q=c
print(q)

Solution (Python):


n=int(input())
a={}
for i in range(0,n):
  s=input()
  if s in a.keys():
    a[s]=a[s]+1
  else:
    a[s]=1
m=int(input())
for i in range(0,m):
  t=input()
  if t in a.keys():
    a[t]=a[t]-1
r=0
for k in a.keys():
  r=max(r,a[k])
print(r)

Solution (Python):

n = int(input()) 
s = [str(input()) for i in range(n)] 
m = int(input()) 
t = [str(input()) for i in range(m)]
ans = []
for string in list(set(s)):
    ans.append(s.count(string) - t.count(string))
if max(ans) < 0:
    print(0)
else:
    print(max(ans))

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

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

ans = 0
for s in S:
  score = 0
  for s2 in S:
    if s == s2:
      score += 1
  for t in T:
    if s == t:
      score -= 1
  ans = max(ans, score)

print(ans)

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
money = s.count(s[0]) - t.count(s[0])
for i in set(s):
    if money < s.count(i) - t.count(i):
        money = s.count(i) - t.count(i)
print(money) if money >= 1 else print(0)

Solution (Python):
from collections import Counter
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
c = Counter()
for i in s:
    c[i] += 1
for j in t:
    c[j] -= 1
maxc = 0
for i in c:
    if c[i] > maxc:
        maxc = c[i]
        
print(maxc)

Solution (Python):
n,*s=open(0).readlines();print(max(0,*[s.count(i)-s[int(n):].count(i)*2for i in s]))

Solution (Python):
n,*s=open(0).readlines();n=int(n);print(max(0,*[s.count(i)-s[n:].count(i)*2for i in s]))

Solution (Python):
n,*s=open(0).readlines();n=int(n);print(max(0,*[s[:n].count(i)-s[n:].count(i)for i in s]))

Solution (Python):
n,*s=open(0).readlines();n=int(n);print(max(0,*[s[:n].count(i)-s[n:].count(i)for i in s[:n]]))

Solution (Python):
n,*s=open(0).read().split();n=int(n);print(max(0,*[s[:n].count(i)-s[n:].count(i)for i in s[:n]]))

Solution (Python):
I=lambda:[input()for _ in[0]*int(input())];s=I();t=I();print(max(0,*[s.count(i)-t.count(i)for i in s]))

Solution (Python):
I=lambda:[input()for _ in[0]*int(input())];s=I();t=I();print(max(0,*[s.count(i)-t.count(i)for i in s]))

Solution (Python):
I=lambda:[input()for _ in[0]*int(input())];s=I();t=I();print(max(0,*[s.count(i)-t.count(i)for i in set(s)]))

Solution (Python):
I=lambda:[input()for _ in[0]*int(input())];s=I();t=I();print(max([0]+[s.count(i)-t.count(i)for i in set(s)]))

Solution (Python):
from collections import*;n,*a=open(0).read().split()
print(max(0,max(v-Counter(a[int(n)+1:])[k] for k,v in Counter(a[0:int(n)]).items())))

Solution (Python):
from collections import*
n,*a=open(0).read().split()
blue=a[0:int(n)]
red=a[int(n)+1:]
print(max(0,max(v-Counter(red)[k] for k,v in Counter(blue).items())))

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

m=int(input())
T=[]
for j in range(m):
    T.append(input())

res=0
for i in range(n):
    x=S.count(S[i])
    y=T.count(S[i])
    if x-y>res:
        res=x-y
for j in range(m):
    x=S.count(T[j])
    y=T.count(T[j])
    if x-y>res:
        res=x-y

print(res)

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
m =  int(input())
t = [input() for i in range(m)]
cnt = {}
for word in s:
    if word in cnt: cnt[word] += 1
    else:cnt[word] = 1
for word2 in t:
    if word2 in cnt:cnt[word2] -= 1
    else : cnt[word2]= -1
ls = [v for k,v in cnt.items()]
if max(ls) <0 :print(0)
else:print(max(ls))

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

cnt = 0
for v in a.values():
    if v < 0:
        cnt += 1
        
if len(a) == cnt:
    print(0)
else:
    print(max(list(a.values())))

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

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
l = set(s+t)
d = [s.count(i) - t.count(i) for i in l] + [0]
print(max(d))

Solution (Python):
from collections import Counter

n = int(input())
blue_cards = [input() for i in range(n)]
m = int(input())
red_cards = [input() for i in range(m)]

blue_c = Counter(blue_cards)
red_c = Counter(red_cards)

score = 0
for k,v in blue_c.most_common():
    score = max(score, v - red_c[k])

print(score)

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

max_score = 0
for term in blue_cards:
    score = 0
    for card in blue_cards:
        if term == card:
            score +=1
    for card in red_cards:
        if term == card:
            score -=1
    if(max_score < score):
        max_score = score
if max_score < 0:
    max_score = 0

print(max_score)

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

dic = {}

for l in L:
    if l in dic:
        dic[l] += 1
    else:
        dic[l] = 1
        
for k in K:
    if k in dic:
        dic[k] -= 1
    else:
        dic[k] = -1

res = 0
for i in dic:
    res = max(res, dic[i])
    
print(res)

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

sss=list(set(ss))
nums = [0] * (len(sss)+1)
for i,s in enumerate(sss):
    nums[i]=ss.count(s) - tt.count(s)
print(max(nums))

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

tmp_S = {}
for s in S:
  if(s in tmp_S):
    tmp_S[s] += 1
  else:
    tmp_S[s] = 1
for t in T:
  if(t in tmp_S):
    tmp_S[t] -= 1
print(max(0, max(tmp_S.values())))

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())

ans=0
for i in range(n):
    strtmp=s[i]
    anstmp=s.count(strtmp)-t.count(strtmp)
    if ans<anstmp:
        ans=anstmp

print(ans)

Solution (Python):
int_n = int(input())
blue_card_ar = [input() for i in range(int_n)]

int_m = int(input())
red_card_ar = [input() for i in range(int_m)]

result_ar = []
for x in blue_card_ar:
    result_ar.append(blue_card_ar.count(x) - red_card_ar.count(x))

print(max(result_ar) if max(result_ar) > 0 else 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 s_ in set(s):
    ans = max(ans,s.count(s_)-t.count(s_))
print(ans)

Solution (Python):
N = int(input())
st = set()
s = []

for i in range(N):
    tmp = input()
    st.add(tmp)
    s.append(tmp)

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

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

ans = -100
tmp = 0

for x in st:
    tmp = s.count(x)
    tmp -= t.count(x)
    ans = max(ans, tmp)

print(ans if 0 <= ans else 0)

Solution (Python):
N=int(input())
s=[]
for i in range(N):
    s.append(input())
M=int(input())
t=[]
for i in range(M):
    t.append(input())
result=0
for i in range(N):
    if s[i] in t:
        ans=s.count(s[i])-t.count(s[i])
    else:
        ans=s.count(s[i])
    if ans>result:
        result=ans
print(result)

Solution (Python):
n = int(input())
blue = [input() for x in range(n)]
m = int(input())
red = [input() for x in range(m)]

points = []
for i in range(n):
    point = 0
    point += blue.count(blue[i])
    point -= red.count(blue[i])
    points.append(point)
print(max( max(points), 0))

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

Solution (Python):
N = int(input())
S = []
number = []
for i in range(N):
    s = input()
    if s in S:
       number[S.index(s)] += 1
    else:
        number.append(1)
        S.append(s)
M = int(input())
for i in range(M):
    s = input()
    if s in S:
        number[S.index(s)] -= 1

print(max(max(number),0))

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

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

Solution (Python):
N = int(input())
s = []
for _ in [0]*N:
    s.append(input().rstrip())
M = int(input())
t = []
for _ in [0]*M:
    t.append(input().rstrip())

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

print(ans)

Solution (Python):
n = int(input())
dc = {}
for i in range(n):
  s = input()
  if s in dc:
    dc[s] += 1
  else :
    dc[s] = 1
m = int(input())
for i in range(m):
  t = input()
  if t in dc:
    dc[t] -= 1
  else :
    dc[t] = -1
ans = 0
for i in dc:
  ans = max(ans, dc[i])
print(ans)

Solution (Python):
from statistics import mean, median,variance,stdev
import sys
import math
import fractions

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())











x =ip()
a = []
for i in range(x):
    a.append(input())
y = ip()
b = []
for i in range(y):
    b.append(input())

c = list(set(a))
d = list(set(b))
m = [0]
for i in range(len(c)):
    m.append(a.count(c[i])-b.count(c[i]))
print(max(m))

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

counter = dict()
for i in s:
  counter[i] = counter.get(i, 0) + 1
for i in t:
  counter[i] = counter.get(i, 0) - 1

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

Solution (Python):
""" AtCoder """

import collections

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

ss = collections.Counter(s)
tt = collections.Counter(t)

ans = 0

for i in range(len(ss)):
    ans = max(ss.most_common()[i][1] - tt[ss.most_common()[i][0]], ans)

print(ans)

Solution (Python):
card = {}

N = int(input())

for i in range(N):
    s = input()
    card.setdefault(s, 0)
    card[s] += 1

M = int(input())

for i in range(M):
    t = input()
    card.setdefault(t, 0)
    card[t] -= 1

print(max(0, max(x for x in card.values())))

Solution (Python):
n = int(input())
s = [str(input()) for i in range(n)]
m = int(input())
t = [str(input()) for i in range(m)]
a = [0]
for i in range(n):
    p = s.count(s[i])
    m = t.count(s[i])
    a.append(p-m)
print(max(a))

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
scorelists = []
for key in S:
    score = 0
    for tmp in S:
        if key == tmp:
            score += 1
    for tmp in T:
        if key == tmp:
            score -= 1
    scorelists.append(score)

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

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

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

money = 0
money_list = []
word_list = list(set(s+t))
for i in range(len(word_list)):
    sum = s.count(word_list[i])
    sum -= t.count(word_list[i])
    if sum < 0:
        sum = 0
    money_list.append(sum)

money_list.sort(reverse = True)
print(money_list[0])

Solution (Python):
n=int(input())
S=list(map(str,[input() for i in range(n)]))
m=int(input())
T=list(map(str,[input() for i in range(m)]))
A=[]
for i in range(n):
    score=S.count(S[i])-T.count(S[i])
    A.append(score)
ans=max(0,max(A))
print(ans)

Solution (Python):
def getNum(li, st):
    cnt = 0
    for l in li:
        if l == st:
            cnt += 1
    return cnt


n = int(input())
bc = []
for x in range(n):
    bc.append(input())

m = int(input())
rc = []
for x in range(m):
    rc.append(input())

bcu = list(set(bc))
rcu = list(set(rc))

brcu = list(set(bcu + rcu))

blist = {}
rlist = {}

for sentence in brcu:
    blist[sentence] = 0
    rlist[sentence] = 0

for srt in bcu:
    blist[srt] = getNum(bc, srt)

for srt in rcu:
    rlist[srt] = getNum(rc, srt)





result = []

for sentence in brcu:
    result.append(blist[sentence] - rlist[sentence])


if max(result) < 0:
    print(0)
else:
    print(max(result))

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

d = {}
for s in S:
  if(s not in d):
    d[s] = 1
  else:
    d[s] += 1
for t in T:
  if(t in d):
    d[t] -= 1
print(max(max(d.values()), 0))

Solution (Python):
N=int(input())
s=[input() for i in range(N)]
M=int(input())
l=[input() for i in range(M)]
list_str=list(dict.fromkeys(s+l))
s_l=[]
for i in range(len(list_str)):
  s_l.append(s.count(list_str[i])-l.count(list_str[i]))

if(all([i < 0 for i in s_l])):
  print(0)
else:print(max(s_l))

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

Solution (Python):
N=int(input())
s = [input() for i in range(N)]
M=int(input())
t = [input() for i in range(M)]
tmp=[0]
for i in range(N):
    point=0
    point+=s.count(s[i])
    point-=t.count(s[i])
    tmp.append(point)
print(max(tmp))

Solution (Python):
N=int(input())
s = [input() for i in range(N)]
M=int(input())
t = [input() for i in range(M)]
tmp=[0]
point=0
for i in range(N):
    point+=s.count(s[i])
    if s[i] in t:
        point-=t.count(s[i])
    tmp.append(int(point))
    point=0 
print(max(tmp))

Solution (Python):
from collections import Counter

n = int(input())
c = Counter([input() for _ in range(n)])
m = int(input())
d = Counter([input() for _ in range(m)])

ans = 0
for k in c.keys():
    ans = max(ans, c[k]-d.setdefault(k, 0))
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
for i in range(n):
  ans=max(ans,s.count(s[i])-t.count(s[i]))
print(ans)

Solution (Python):
N = input()

S = [raw_input() for i in range(N)]

M = input()

T = [raw_input() for i in range(M)]

maximam = 0

for i in S:
    maximam = max(S.count(i)-T.count(i),maximam)

print maximam

Solution (Python):
N = input()

S = []
for i in range(N):
    S.append(raw_input())

M = input()

T = []
for i in range(M):
    T.append(raw_input())

maximam = 0

for i in S:
    maximam = max(S.count(i)-T.count(i),maximam)

print maximam

Solution (Python):

def getInt(): return int(input())
def db(x): 
    global debug
    if debug: print(x)
debug = False
N = getInt()
S = []
for i in range(N): S.append(input())
M = getInt()
T = []
for i in range(M): T.append(input())
db((N,M))
db((S,T))
dic = {}
for w in S: 
    if w in dic: dic[w] += 1
    else: dic[w] = 1
for w in T: 
    if w in dic: dic[w] -= 1
    else: dic[w] = -1
db(dic)
db(dic.values())
db(list(dic.values()))

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

Solution (Python):
def count(counted, cards, is_blue):
    for word in cards:
        if not word in counted:
            counted[word] = 1 if is_blue else -1
        else:
            counted[word] += 1 * (1 if is_blue else -1)
    return counted


counted = {}
n = int(input())
counted = count(counted, [input() for _ in range(n)], True)
m = int(input())
counted = count(counted, [input() for _ in range(m)], False)
high_score = max(sorted(counted.items(), key=lambda x: x[1], reverse=True)[0][1], 0)
print(high_score)

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

m = int(input())
for word in [input() for _ in range(m)]:
    if not word in count:
        count[word] = -1
    else:
        count[word] -= 1

high_score = max(sorted(count.items(), key=lambda x: x[1], reverse=True)[0][1], 0)
print(high_score)

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

count = {}
for word in s:
    if not word in count:
        count[word] = 1
    else:
        count[word] += 1
for word in t:
    if not word in count:
        count[word] = -1
    else:
        count[word] -= 1

high_score = max(sorted(count.items(), key=lambda x: x[1], reverse=True)[0][1], 0)
print(high_score)

Solution (Python):

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


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

best = -200

for w in set(s + t):
    r = sum([1 for _ in s if _ == w]) - sum([1 for _ in t if _ == w])
    if r > best:
        best = r

if best < 0:
    best = 0
    
print(best)

Solution (Python):
a=int(input())
A=[]
for i in range(a):
  A.append(input())
m=int(input())
B=[]
for j in range(m):
  B.append(input())
ans=[]
for i in A:
  ans.append(A.count(i)-B.count(i))
print(max(0,max(ans)))

Solution (Python):


import numpy as np
import random

n = int(input())
s = []
t = []
for i in range(n):
    s_tem = str(input())
    s.append(s_tem)

m = int(input())
for i in range(m):
    t_tem = str(input())
    t.append(t_tem)

count_dic = {}

for name in s:
    if name in count_dic.keys():
        count_dic[name] += 1
    else:
        count_dic[name] = 1
for name in t:
    if name in count_dic.keys():
        count_dic[name] -= 1
    else:
        count_dic[name] = -1

sorted_count_dic = sorted(count_dic.items(),key=lambda x:x[1],reverse = True)
answer = max(sorted_count_dic[0][1], 0)
print(answer)

Solution (Python):
point = {}
for i in range(int(input())):
    name = input()
    if (name in point.keys()) == True:
        point[name] += 1
    else:
        point[name] = 1
for i in range(int(input())):
    name = input()
    if (name in point.keys()) == True:
        point[name] -= 1
    else:
        point[name] = -1
result = max(list(point.values()))
if result > 0:
    print(result)
else:
    print(0)

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

v = 0
ss = set(s)
for x in ss:
    tmp = s.count(x) - t.count(x)
    if tmp > v:
        v = tmp

print(v)

Solution (Python):
import sys
sys.setrecursionlimit(100000)
dic={}
for i in range(int(input())):
    s=input()
    try:
        dic[s]+=1
    except:
        dic[s]=1
for i in range(int(input())):
    s=input()
    try:
        dic[s]-=1
    except:
        dic[s]=-1

print(max(list(dic.values())+[0]))

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

memo = {}
for i in range(n):
  if s[i] not in memo:
    memo[s[i]] = 1
  else:
    memo[s[i]] +=1

for i in range(m):
  if t[i] in memo:
    memo[t[i]] -=1

ans=0
for i in memo:
  ans = max(memo[i],ans)
print(ans)

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

from collections import Counter
CS = Counter(S).most_common()
CT = Counter(T)

ans = 0
for cs in CS:
    k,v = cs
    ans = max(ans, v-CT[k])

print(ans)

Solution (Python):
from collections import Counter

N = int(input())
sss = [input() for _ in range(N)]
M = int(input())
tss = [input() for _ in range(M)]

cntS = Counter(sss)
cntT = Counter(tss)

ans = 0
for key in cntS.keys() | cntT.keys():
    num = 0
    if key in cntS:
        num += cntS[key]
    if key in cntT:
        num -= cntT[key]
    ans = max(ans, num)
print(ans)