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())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]

R = {}
for i in s:
  if i in R:
    R[i] += 1
  else:
    R[i] = 1

for i in t:
  if i in R:
    R[i] -= 1

ans = max(R.values())
print(max(0, 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 s:
    cnt = s.count(i) - t.count(i)
    ans = max(cnt, 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)]
a=[0]
for i in set(s):
    a.append((s.count(i)-t.count(i)))
print(max(a))

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

set_s = set(s) 

max_result = 0
for elem in set_s:
    r = s.count(elem) - t.count(elem)
    max_result = max(r, max_result)

print(max_result)

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

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

ans = 0
for i in set(ls):
    sum = ls.count(i) - lt.count(i)
    if sum > ans:
        ans = sum
print(ans)

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

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

ans = max(max((S.count(x) - T.count(x) for x in set(S))), 0)

print(ans)

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):
    i = input()
    if i in S:
        S[i] -= 1

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

print(ans)

Solution (Python):
n=int(input())
A=[]
for i in range(n):
  a=input()
  A.append(a)
m=int(input())
B=[]
for i in range(m):
  b=input()
  B.append(b)
count=[]
for i in range(len(set(A))):
  count.append(A.count(list(set(A))[i])-B.count(list(set(A))[i]))
print(max(count) if max(count)>0 else '0')

Solution (Python):
maxi = 0

n_blue = int(input())
blue_str = [input() for _ in range(n_blue)]
n_red = int(input())
red_str = [input() for _ in range(n_red)]

kind = list(set(blue_str))

blue_count= [blue_str.count(i) for i in kind]
red_count= [red_str.count(i) for i in kind]

profit = [blue_count[i] - red_count[i] for i in range(len(blue_count))]

print(max(0, max(profit)))

Solution (Python):
n_blue = int(input())
blue_str = []
red_str = []
blue_count = []
red_count = []
maxi = 0
for _ in range(n_blue):
    blue_str.append(input())
n_red = int(input())
for _ in range(n_red):
    red_str.append(input())
kind = list(set(blue_str))
for i in kind:
    blue_count.append(blue_str.count(i))
    red_count.append(red_str.count(i))
for i in range(len(blue_count)):
    tmp = blue_count[i] - red_count[i]
    maxi = max(maxi, tmp)
print(max(0, maxi))

Solution (Python):
N=int(input())
A=[input() for _ in range(N)]
M=int(input())
b=list(set(A))
z=0
k=0
B=[input() for _ in range(M)]
c=list(set(B))
for j in range(len(b)):
    k=A.count(b[j])-B.count(b[j])
    z=max(0,z,k)
print(z)

Solution (Python):
N=int(input())
A=[input() for _ in range(N)]
M=int(input())
b=list(set(A))
z=0
k=0
B=[input() for _ in range(M)]
c=list(set(B))
for j in range(len(b)):
    k=A.count(b[j])-B.count(b[j])
    z=max(0,z,k)
print(z)

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

words = {'na': 0}  

for i in range(N):

    s = input()

    if s in words:
        words[s] += 1
    else:
        words[s] = 1

M = int(input())

for i in range(M):

    t = input()

    if t in words:
        words[t] -= 1

print(max(words.values()))

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())
ans = 0
for i in range(n):
    ans = max(ans,blue.count(blue[i])-red.count(blue[i]))
print(ans)

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

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

tmpList = []
getMoneyList = [0]
for i in range(n):
  if s[i] in tmpList:
    continue
  si = s[i]
  tmpList.append(si)
  cnts = s.count(si)
  cntt = t.count(si)
  if cnts - cntt > 0:
    getMoneyList.append(cnts - cntt)

print(max(getMoneyList))

Solution (Python):
d = dict()

def getv(a):
  M = int(input())
  for x in range(M):
    n = input()
    if d.get(n) is None:
      d[n] = 0
    d[n] += a

getv(1)
getv(-1)

print(max(0,d[sorted(d, key=lambda x:d[x], reverse=True)[0]]))

Solution (Python):
from collections import Counter  

blue = []
red = []
N = int(input())
for i in range(N):
    blue.append(input())
M = int(input())
for j in range(M):
    red.append(input())
b = Counter(blue)
r = Counter(red)
print(max([0] + [b[x] - r[x] for x in b]))

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
sc = Counter(s)
tc = Counter(t)
expected_gain = []
for key in sc.keys():
    if key in t:
        expected_gain.append(sc[key] - tc[key])
    else:
        expected_gain.append(sc[key])

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

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)]
cs = Counter(s)
ct = Counter(t)
print(max([0]+[cs[k]-ct[k] for k in cs]))

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 S:
    count = S.count(s)-T.count(s)
    if ans<count:
        ans=count
    
print(ans)

Solution (Python):
d = {}
n = int(input())
for i in range(n):
    s = input()
    c = d.get(s, 0)
    d[s] = c + 1
m = int(input())
for i in range(m):
    s = input()
    c = d.get(s, 0)
    d[s] = c - 1
co = 0
wo = ""
for k in d:
    if d[k] > co:
        co = d[k]
        wo = k
print(co if co > 0 else "0")

Solution (Python):
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
from collections import Counter
s = Counter(s)
t = Counter(t)
ans = 0
for k, v in s.items():
    if k in t:
        ans = max(ans, max(v - t[k], 0))
    else:
        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)]

s.sort()
t.sort()

ans = 0
sset = set(s)

for si in sset:
    ans = max(ans, s.count(si)-t.count(si))
print(ans)

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

c = {"":0}
for s in S:
    c[s] = c.get(s, 0) + 1
for t in T:
    c[t] = c.get(t, 0) - 1

print(max(c.values()))

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

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

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

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

Solution (Python):
n=int(input())
plus=[]
for i in range(n):
    plus.append(input())
m=int(input())
minus=[]
for j in range(m):
    minus.append(input())

score=[]
for i in range(n):
    score.append(plus.count(plus[i])-minus.count(plus[i]))
    
print(max(score) if max(score)>0 else 0)

Solution (Python):

import sys
import collections


def solve(N: int, s: "List[str]", M: int, t: "List[str]"):
    cs = collections.Counter(s)
    ts = collections.Counter(t)

    res = 0
    for k,v in cs.items():
        t = v - ts[k]
        res = max(res,t)

    print(res)

    
             




def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    s = [ next(tokens) for _ in range(N) ]  
    M = int(next(tokens))  
    t = [ next(tokens) for _ in range(M) ]  
    solve(N, s, M, t)

if __name__ == '__main__':
    main()

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

card_list = list(set(blue_list+red_list))

point = 0

for i in card_list:
	point = max(point,blue_list.count(i)-red_list.count(i))

print(point)

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

money = -1

for i in s:
    cnt = s.count(i) - t.count(i)
    if money < cnt:
        money = cnt

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

Solution (Python):
ans = 0
n = int(input())
blue = [input() for i in range(n)]
m = int(input())
red = [input() for i in range(m)]
for i in range(m):
    if red[i] in blue:
        blue.remove(red[i])
for j in list(set(blue)):
    if blue.count(j) > ans:
        ans = blue.count(j)
print(ans)

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
count = {'':0}
for i in s:
  count.setdefault(i, 0)
  count[i] += 1
for i in t:
  count.setdefault(i, 0)
  count[i] -= 1
print(max(count.values()))

Solution (Python):
N = int(raw_input())
blue = []
for i in range(0, N):
	blue.append(raw_input())
wordlist = []
for i in range(0, N):
	if blue[i] not in wordlist: wordlist.append(blue[i])
M = int(raw_input())
red = []
for i in range(0, M):
	red.append(raw_input())

max = 0
for i in range(0, len(wordlist)):
	sum = 0
	for j in range(0, N):
		if wordlist[i] == blue[j]: sum += 1
	for j in range(0, M):
		if wordlist[i] == red[j]: sum -= 1
	if max < sum: max = sum
print max

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())
cmax=0
for i in range(n):
    cnt=0
    for j in range(n):
        if s[i]==s[j]:
            cnt+=1
    for j in range(m):
        if s[i]==t[j]:
            cnt-=1
    cmax = max(cnt,cmax)
print(cmax)

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

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

print(max(max(s.count(x)-t.count(x) for x in s),0))

Solution (Python):

import sys


def solve(N: int, s: "List[str]", M: int, t: "List[str]"):
    dic = {}
    for a in s:
        if a in dic:
            dic[a] += 1
        else:
            dic[a] = 1
    for a in t:
        if a in dic:
            dic[a] -= 1
        else:
            dic[a] = -1
    ret = 0
    for val in dic.values():
        ret = max(ret, val)
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    s = [ next(tokens) for _ in range(N) ]  
    M = int(next(tokens))  
    t = [ next(tokens) for _ in range(M) ]  
    solve(N, s, M, t)

if __name__ == '__main__':
    main()

Solution (Python):
ad = {}
mi = {}

n = int(input())
for i in range(n):
    s = input()
    n = ad.get(s, 0)
    n += 1
    ad[s] = n

n = int(input())
for i in range(n):
    s = input()
    n = mi.get(s, 0)
    n += 1
    mi[s] = n

res = 0
for k in ad.keys():
    val = ad[k]
    val -= mi.get(k, 0)
    res = max(res, val)

print(res)

Solution (Python):
N = int(input())
s = []
for _ in range(N):
    s.append(input())
M = int(input())
t = []
for _ in range(M):
    t.append(input())
ans = []
for ss in set(s):
    ans.append(s.count(ss) - t.count(ss))
p = max(ans) if max(ans) > 0 else 0
print(p)

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:
  cnt1 = S.count(i)
  cnt2 = T.count(i)
  ans = max(cnt1-cnt2,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

for a in S:
    p = S.count(a)
    q = T.count(a)
    ans = max(ans, p - q)
print(ans)

Solution (Python):
n = int(input())
aoaka = set()
s = []
t = []
for i in range(n):
    new = input()
    s.append(new)
    aoaka.add(new)
m = int(input())
for i in range(m):
    new = input()
    t.append(new)
    aoaka.add(new)
saidai = 0
for i in aoaka:
    cnt = 0
    cnt = cnt + s.count(i) - t.count(i)
    saidai = max(saidai,cnt)
print(saidai)

Solution (Python):
import collections

blue = int(input())
blue_string = [input() for i in range(blue)]
blue_type = set(blue_string)
red = int(input())
red_string = [input() for i in range(red)]
red_type = set(red_string)
result = [0]

for i in blue_type:
    bulue_sort_count = blue_string.count(i)
    red_sort_count = red_string.count(i)
    result.append(bulue_sort_count - red_sort_count )
print(max(result))

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

s_col = collections.Counter(s)
t_col = collections.Counter(t)

s_com = s_col.most_common()
t_com = t_col.most_common()

ans = []

for item in s:
    try:
        ans.append(s_col[item] - t_col[item])
    except:
        ans.append(s_col[item])

print(max(max(ans), 0))

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

Solution (Python):
s_dic = {}
for _ in range(int(input())):
    s = input()
    if not s in s_dic.keys():s_dic[s] = 1
    else:s_dic[s] += 1
for _ in range(int(input())):
    t = input()
    if t in s_dic.keys():s_dic[t] -= 1
print(max(0,max(s_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)]
c = collections.Counter(s)
d = collections.Counter(t)
counter = c -d
try:
        print(counter.most_common(1)[0][1])
except IndexError:
        print("0")

Solution (Python):

N=int(input())

l1=[]
for i in range(N):
  l1.append(input())

M=int(input())

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


mx=-len(l2)

for x in l1:
  
  a=l1.count(x)

  
  b=l2.count(x)

  mx=max(mx,a-b)


print(max(mx,0))

Solution (Python):
N = int(input())
s = {}
for _ in range(N):
    a = input()
    if a in s.keys():
        s[a] += 1
    else:
        s[a] = 1 
M = int(input())
t = {}
for _ in range(M):
    a = input()
    if a in t.keys():
        t[a] += 1
    else:
        t[a] = 1 
ret = 0
for i in s.keys():
    tmp = s[i]
    if i in t.keys():
        tmp -= t[i]
    ret = max(ret, tmp)
print(ret)

Solution (Python):


from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


class UnionFind:

    def __init__(self, n):
        self.parent = [i for i in range(n)]

    def root(self, i):
        if self.parent[i] == i:
            return i
        self.parent[i] = self.root(self.parent[i])
        return self.parent[i]

    def unite(self, i, j):
        rooti = self.root(i)
        rootj = self.root(j)
        if rooti == rootj:
            return
        if rooti < rootj:
            self.parent[rootj] = rooti
        else:
            self.parent[rooti] = rootj

    def same(self, i, j):
        return self.root(i) == self.root(j)





def main():
    n = intin()
    slist = [input() for _ in range(n)]
    m = intin()
    tlist = [input() for _ in range(m)]

    counts = defaultdict(int)
    for s in slist:
        counts[s] += 1

    for t in tlist:
        counts[t] -= 1

    ans = 0
    for s, count in counts.items():
        ans = max(ans, count)

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
from sys import stdin
N=int(stdin.readline().rstrip())

blue=[]
for i in range(N):
    blue.append((input()))

M=int(stdin.readline().rstrip())

red=[]
for j in range(M):
    red.append((input()))

ans = len(set(blue)) * [0]
for ind,k in enumerate(set(blue)):
    ans[ind] = blue.count(k) - red.count(k)

print(max(max(ans),0))

Solution (Python):


n = int(input())
w = []
sn = []
tn = []
for _ in range(n):
    s = input()
    f = True
    for i in range(len(w)):
        if w[i] == s:
            sn[i] += 1
            f = False
            break
    if f:
        w.append(s)
        sn.append(1)
        tn.append(0)
        
m = int(input())
for _ in range(m):
    t = input()
    f = True
    for i in range(len(w)):
        if w[i] == t:
            tn[i] += 1
            f = False
            break
    if f:
        w.append(t)
        tn.append(1)
        sn.append(0)
        

        
print(max([sn[i]-tn[i] for i in range(len(w))]+[0]))

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

for i in range(n):
    a.append(str(input()))
m=int(input())
for s in range(m):
    b.append(str(input()))
for k in range(n):
    c.append(a.count(a[k])-b.count(a[k]))
for l in range(m):
    c.append(a.count(b[l]) - b.count(b[l]))
c.append(0)
print(max(c))

Solution (Python):
ifhesay={}
def say(word,add):
	if word in ifhesay:
		ifhesay[word]+=add
	else:
		ifhesay[word]=add

n=int(input())

for i in range(n):
	say(input(),1)

m=int(input())

for i in range(m):
	say(input(),-1)

max=0

for k in ifhesay:
	v=ifhesay[k]
	if v>max:
		max=v
print(max)

Solution (Python):
import collections

N = int(input())
S = [input() for s in range(N)]
M = int(input())
T = [input() for t in range(M)]
S_counter = collections.Counter(S)
T_counter = collections.Counter(T)

for k, v in S_counter.items():
    if k in T_counter:
        S_counter[k] = S_counter[k] - T_counter[k] if (S_counter[k] - T_counter[k]) > 0 else 0

print(max(S_counter.values()))

Solution (Python):
import collections
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
cs = collections.Counter(s)
ct = collections.Counter(t)
points = 0
for key in cs.keys():
    points = max(points, cs[key] - ct[key])
print(points)

Solution (Python):
from collections import Counter as cnt

N = int(input())
counter = {}
for i in range(N):
  s = input()
  if s not in counter:
    counter[s] = [1,0]
  else:
    counter[s][0] += 1
N = int(input())
for i in range(N):
  s = input()
  if s not in counter:
    counter[s] = [0,1]
  else:
    counter[s][1] += 1
counter[0] = [0,0]

print(max([b-r for b,r in counter.values()]))

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 i in range(n):
    tmp = s[i]
    cnt = 0
    for j in range(n):
        if tmp == s[j]:
            cnt += 1
    for k in range(m):
        if tmp == t[k]:
            cnt -= 1
    ans = max(ans,cnt)
print(ans)

Solution (Python):
n = int(input())
a = [input() for _ in range(n)]
m = int(input())
b = [input() for _ in range(m)]
words = list(set(a) or set(b))
ans = 0

for word in words:
    ans = max(ans, a.count(word) - b.count(word))
print(ans)

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


mine = 0
    
flags = [1] * N

for i in range(N):
    plus = 1
    minus = 0
    
    if flags[i] == 0:
        continue
        
    if flags[i] == 1:
        flags[i] = 0
    
    for j in range(i+1, N):
        if s[i] == s[j]:
            plus += 1
            flags[j] = 0
            
    for k in range(M):
        if s[i] == t[k]:
            minus += 1
            
    mine = max([mine, plus - minus]) 

    
print(mine)

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

maxlist=[0]
for i in range(n):
    mx=0
    for j in range(n):
        if a[i]==a[j]:
            mx+=1
    for k in range(m):
        if a[i]==t[k]:
            mx-=1
    maxlist.append(mx)

print(max(maxlist))

Solution (Python):
n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for i in range(m)]
kari=[0]
for i in range(n):
 cnt=s.count(s[i])
 cnt-=t.count(s[i])
 kari.append(cnt)
 cnt=0

print(max(kari))

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):
    tmp = s[i]
    cnt = 0
    for i in range(N):
        if tmp == s[i]:
            cnt += 1
    for j in range(M):
        if tmp == t[j]:
            cnt -= 1
    ans = max(ans,cnt)
      
print(ans)

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

res={}

for i in s:
    res[i] = res.get(i, 0) + 1

for i in t:
    res[i] = res.get(i, 0) - 1

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

Solution (Python):
import collections

blue = [input() for i in range(int(input()))]
red = [input() for i in range(int(input()))]

blue_c = collections.Counter(blue)
red_c = collections.Counter(red)

ans = 0

blue_s = set(blue)

for i in blue_s:
    if blue_c[i] - red_c[i] > ans:
        ans = blue_c[i] - red_c[i]
        
print(ans)

Solution (Python):
from collections import defaultdict

def main():
    data = defaultdict(int)

    num = int(input())
    for i in range(num):
        aaa = input()
        data[aaa] += 1

    num = int(input())
    for i in range(num):
        aaa = input()
        data[aaa] -= 1

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




if __name__ == '__main__':
    main()

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)])
print(max((S - T).values()) if len(S - T) > 0 else 0)

Solution (Python):




n = int(input())
bc = list()
for i in range(n):
    bc.append(input())

m = int(input())
rc = list()
for j in range(m):
    rc.append(input())

bc.sort()
rc.sort()


strdict = dict()
wk_str = bc[0]
wk_cnt = 1
for i in range(1, n):
    if wk_str != bc[i]:
        strdict[wk_str] = wk_cnt
        wk_cnt = 1
        wk_str = bc[i]
    else:
        wk_cnt += 1

strdict[wk_str] = wk_cnt

wk_str = rc[0]
wk_cnt = 1

for j in range(1, m):
    if wk_str != rc[j]:
        if strdict.get(wk_str) == None:
            strdict[wk_str] = wk_cnt * -1
        else:
            strdict[wk_str] += wk_cnt * -1
        wk_cnt = 1
        wk_str = rc[j]
    else:
        wk_cnt += 1

if strdict.get(wk_str) == None:
    strdict[wk_str] = wk_cnt * -1
else:
    strdict[wk_str] += wk_cnt * -1


maxval = -101
for k in strdict.keys():
    if maxval < strdict[k]:
        maxval = strdict[k]

ans = max(maxval, 0)

print(ans)

Solution (Python):
n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for j in range(m)]
ans=0
for i in range(n):
  count=0
  for ii in range(n):
    if s[i]==s[ii]:
      count+=1
  for jj in range(m):
    if s[i]==t[jj]:
      count-=1
  ans=max(count,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
for i in s:
  if ans < s.count(i) - t.count(i):
    ans = s.count(i) - t.count(i)
print(ans)

Solution (Python):
N = int(input())
b = []
r = []
all_l = []
for i in range(N):
  tmp = input()
  b.append(tmp)
  all_l.append(tmp)
N = int(input())
for i in range(N):
  tmp = input()
  r.append(tmp)
  all_l.append(tmp)
all_l = list(set(all_l))
ans = 0
for i in all_l:
  ans = max(ans, b.count(i)-r.count(i))
print(ans)

Solution (Python):
n0 = int(input()) 
t0 = [input() for i in range(n0)] 
n1 = int(input()) 
t1 = [input() for i in range(n1)] 
s = set(t0) | set(t1)
l = max([sum([1 for x0 in t0 if x0 == i]) - sum([1 for x1 in t1 if x1 == i]) for i in s])
print(max(l,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())
K=[0]
for i in S:
    K.append(S.count(i)-T.count(i))

    
print(max(K))

Solution (Python):
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t=[input() for _ in range(m)]
d={a:0 for a in s+t}
for a in s:
    d[a] += 1
for a in t:
    d[a] -= 1
print(max(max(d.values()),0))

Solution (Python):
n = int(input())
b = [input() for i in range(n)]
m = int(input())
r = [input() for j in range(m)]
ans = 0
for i in b:
    if b.count(i)-r.count(i) > ans:
        ans = b.count(i)-r.count(i)            
print(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()

S = {s: S.count(s) for s in S}
T = {t: T.count(t) for t in T}

ans = 0
for s in S:
    adv = S[s] - T.get(s, 0)
    ans = max(ans, adv)
print(ans)

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

print(max([s.count(S) - t.count(S) for S in s]+[0]))

Solution (Python):
N = int(input())
S = {'__min__': 0}
for _ in range(N):
    s = input()
    if S.get(s) == None:
        S[s] = 1
    else:
        S[s] += 1

M = int(input())
for _ in range(M):
    t = input()
    if S.get(t) == None:
        continue
    elif S[t] <= 1:
        S.pop(t)
    else:
        S[t] -= 1

print(max(S.values()))

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

cnt = 0

for i in s:
    x = s.count(i) - t.count(i)
    cnt = max(cnt,x)

print(cnt)

Solution (Python):
from collections import defaultdict


s_box = defaultdict(int)
t_box = defaultdict(int)

N = int(input())
s = [str(input()) for i in range(N)]
M = int(input())
t = [str(input()) for j in range(M)]

for key in s:
    s_box[key] += 1
for key in t:
    t_box[key] += 1

ans = []

for k, v in t_box.items():
    s_box[k] -= v

for v in s_box.values():
    ans.append(v)

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

Solution (Python):
n=int(input())
ans={}
for i in range(n):
    s=input()
    ans[s]=ans.get(s,0)+1
m=int(input())
for i in range(m):
    t=input()
    ans[t]=ans.get(t,0)-1
print(max(ans.values()) if max(ans.values())>0 else 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())
ans = 0
for key in s:
  if s.count(key)-t.count(key) > ans:
    ans = s.count(key)-t.count(key)
print(ans)

Solution (Python):
n=int(input())
ns=[input() for _ in range(n)]
m=int(input())
ms=[input() for _ in range(m)]
l = list(set(ns))
print(max(0, max(ns.count(l[i])-ms.count(l[i]) for i in range(len(l)))))

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

sset = list(set(s))
imax = 0
for i in range(len(sset)):
    if imax < s.count(sset[i]) - t.count(sset[i]):
        imax = s.count(sset[i]) - t.count(sset[i])
print(imax)