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):
from collections import Counter
N = int(input())
BlueCard = list(input() for _ in range(N))
M = int(input())
RedCard = list(input() for _ in range(M))
BlueCard_Counter = Counter(BlueCard)
RedCard_Counter = Counter(RedCard)
ans = 0
for key , blue_cnt in BlueCard_Counter.items():
    if key in RedCard:
        red_cnt = RedCard_Counter[key]
    else:
        red_cnt = 0
    now = blue_cnt - red_cnt
    if ans < now:
        ans = now
print(ans)

Solution (Python):
N=int(input())
S=[str(input()) for i in range(N)]
M=int(input())
T=[str(input()) for i in range(M)]
S.sort()
result=0

for i in range(N):
	if i<N-1 and S[i]!=S[i+1]:
		if S.count(S[i])-T.count(S[i])>result:
			result=S.count(S[i])-T.count(S[i])
	elif i==N-1 and S.count(S[i])-T.count(S[i])>result:
		result=S.count(S[i])-T.count(S[i])
print(result)

Solution (Python):
s=[input() for _ in range(int(input()))]
t=[input() for _ in range(int(input()))]
U=set(s)
ans=0
for u in U:
    ans=max(ans,s.count(u)-t.count(u))
print(ans)

Solution (Python):

import collections

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

blue_cards_counted = collections.Counter(blue_cards)
red_cards_counted = collections.Counter(red_cards)

for word in red_cards_counted:
    blue_cards_counted[word] -= red_cards_counted[word]       
    

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

Solution (Python):


import numpy as np

N=int(input())
S=np.full((N,),".",dtype=object)


for n in range(N):
    S[n]=input()

M=int(input())
T=np.full((M,),".",dtype=object)


for m in range(M):
    T[m]=input()

ust=np.unique(np.append(S,T)) 
maxy=0 


for u in ust:
    y=(len(np.where(S==u)[0])-len(np.where(T==u)[0]))
    maxy=max(maxy,y)

print(maxy)

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

a = Counter(s)
b = Counter(t)

a.subtract(b)
print (max(0,a.most_common(1)[0][1]))

Solution (Python):
n=int(input())
N=[input() for i in range(n)]
m=int(input())
M=[input() for i in range(m)]
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())
dic = {}
for i in range(N):
  s = input()
  if s not in dic:
    dic[s] = 1
  else:
    dic[s] += 1
M = int(input())
for i in range(M):
  s = input()
  if s not in dic:
    dic[s] = -1
  else:
    dic[s] -= 1
lst = list(dic.values())
lst.append(0)
print(max(lst))

Solution (Python):
from collections import Counter
n = int(input())
l = [input() for _ in range(n)]

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

c = Counter(l)
c2 = Counter(l2)


ans = [0]

for k,v in c.items():
    ans.append(v-c2[k])
    
print(max(ans))

Solution (Python):
d = {}
N = int(input())
for i in range(N):
  word = input()
  d[word] = d.get(word, 0) + 1
M = int(input())
for i in range(M):
  word = input()
  d[word] = d.get(word, 0) - 1
print(max(0, *d.values()))

Solution (Python):
n = int(input())
a = [input() for i in range(n)]
m = int(input())
b = [input() for i in range(m)]
min = 0
for i in range(n):
    max = a.count(a[i])-b.count(a[i])
    if max >= min:
        min = max
    else:
        pass
print(min)

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

card = {}
for i in range(N):
    tmp = input()
    if tmp in card:
        card[tmp] += 1
    else:
        card[tmp] = 1
        
M = int(input())
for i in range(M):
    tmp = input()
    if tmp in card:
        card[tmp] -= 1
 
print(max(0, max(card.values())))

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

ans = 0
s_set = set(s)

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

Solution (Python):

import sys
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')

n = int(input())
s = [list(map(str,input().split())) for i in range(n)]

m = int(input())
t = [list(map(str,input().split())) for i in range(m)]

ans = -1000

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

print( ans if ans >=0 else 0)

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

al = []
for _ in range(n):
    al.append(input())

m = int(input())
bl = []
for _ in range(m):
    bl.append(input())

ans = 0
for i in list(set(al)):
    tmp = al.count(i) - bl.count(i)
    ans = max(ans,tmp)

print(ans)

Solution (Python):
N = int(input())
cards = {}
for i in range(N):
  si = input()
  if si in cards:
    cards[si] += 1
  else:
    cards[si] = 1
M = int(input())
for i in range(M):
  ti = input()
  if ti in cards:
    cards[ti] -= 1
  else:
    cards[ti] = -1

answer = 0
for word in cards:
  if answer < cards[word]:
    answer = cards[word]

print(0 if answer < 0 else answer)

Solution (Python):
n = int(input())
s = sorted([input() for _ in range(n)])
m = int(input())
t = sorted([input() for _ in range(m)])
ans = -100
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
    ans = max(ans,cnt)
ans = max(ans,0)
print(ans)

Solution (Python):
from collections import defaultdict 

dic_b = defaultdict(int)
dic_r = defaultdict(int)

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

M = int(input())
for _ in range(M):
    dic_r[input()] +=1 


dif = []
for key in dic_b:
    dif.append(dic_b[key] - dic_r[key])


print( max(0, max(dif)) )

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


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

examB()

Solution (Python):
m = int(input())
blue = [input() for i in range(m)]
n = int(input())
red = [input() for j in range(n)]
l = list(set(blue))
anslist = []
for k in range(len(l)):
  anslist.append(max(0,blue.count(l[k]) - red.count(l[k])))
print(max(anslist))

Solution (Python):

N = int(input())
colors = {}
for _ in range(N):
    color = input()
    if colors.get(color):
        colors[color] += 1
    else:
        colors[color] = 1


M = int(input())
for _ in range(M):
    color = input()
    if colors.get(color):
        colors[color] -= 1
    else:
        colors[color] = -1

max_point = 0
for value in colors.values():
    if value > max_point:
        max_point = value
print(max_point)

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

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

d={}
for i in s:
  d[i]=d.get(i,0)+1
for i in t:
  d[i]=d.get(i,0)-1
ans=max(0,max(d.values()))
print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect_left
import heapq

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()))
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 s:
	ans = max(ans, dic_s[st]-dic_t[st])
print(ans)

Solution (Python):
from sys import stdin
import numpy as np
import math

n = int(stdin.readline().rstrip())
lin = [stdin.readline().rstrip() for _ in range(n)]
m = int(stdin.readline().rstrip())
lim = [stdin.readline().rstrip() for _ in range(m)]

lis = list(set(lin))
ma = 0
for i in lis:
    ma = max(lin.count(i)-lim.count(i),ma)

print(ma)

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

sCount = {}
for s in S:
    sCount[s] = S.count(s)

tCount = {}
for t in T:
    tCount[t] = T.count(t)

union = sCount.keys() & tCount.keys()
ans = sCount;
for i in union:
    ans[i] = sCount[i] - tCount[i]
    
if max(ans.values()) >= 0:
    print(max(ans.values()))
else:
    print(0)

Solution (Python):
N = int(input())
S = {}
for i in range(N):
    j = input()
    if((j in S) == False):
        S[j] = 1
    else:
        S[j] += 1
M = int(input())
T = {}
for i in range(M):
    j = input()
    if((j in T) == False):
        T[j] = 1
    else:
        T[j] += 1
ans = 0
for key,value in S.items():
    if(key in T):
        ans = max(ans,value - T[key])
    else:
        ans = max(ans,value)
print(ans)

Solution (Python):
import collections


def main():
    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)

    Mcnt = 0
    for s, ns in S.items():
        cnt = 0
        if s in list(T.elements()):
            if T[s] < ns:
                cnt = ns - T[s]
        else:
            cnt = ns

        if cnt > Mcnt:
            Mcnt = cnt

    print(Mcnt)


main()

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

s1=set(s)
t1=set(t)
ans=0
for i in s1:
    ans=max(ans,s.count(i)-t.count(i))
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 range(len(s)):
    point = 0
    kw = s[i]
    for j in range(len(s)):
        if s[j] == kw:
            point += 1
    for j in range(len(t)):
        if t[j] == kw:
            point -= 1
    ans = max(ans, point)
print(ans)

Solution (Python):

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

announced = set(s + t)
earned = 0

for word in announced:
    earned = max(earned, s.count(word) - t.count(word))

print(earned if earned > 0 else 0)

Solution (Python):
N = int(input())
p = {}

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

M = int(input())

for _ in range(M):
    s = input()
    p.setdefault(s, 0)
    p[s] -= 1

ans = max(p.values())

print(ans if ans >= 0 else 0)

Solution (Python):
from collections import defaultdict

d = defaultdict(int)
n = int(input())
for _ in range(n):
  key = input()
  d[key] += 1
m = int(input())
for _ in range(m):
  key = input()
  d[key] -= 1
print(max(max(d.values()), 0))

Solution (Python):
N = int(input())
blues = [input() for _ in range(N)]
M = int(input())
reds = [input() for _ in range(M)]
points = [blues.count(blue)-reds.count(blue) for blue in blues]
print(max(points) if max(points)>0 else 0)

Solution (Python):


n=int(input())
s=[]
ans=-10000
for i in range(n):
    s.append(input())
m=int(input())
t=[]
for j in range(m):
    t.append(input())
for k in range(n):
    if s.count(s[k])-t.count(s[k])>ans:
        ans=s.count(s[k])-t.count(s[k])
if ans>0:
    print(ans)
else:
    print(0)

Solution (Python):
n = int(input())
list_str = []
list_p = []
for _ in range(n):
  s = input()
  if s in list_str:
    list_p[list_str.index(s)] += 1
  else:
    list_str.append(s)
    list_p.append(1)
m = int(input())
for _ in range(m):
  t = input()
  if t in list_str:
    list_p[list_str.index(t)] -= 1
  else:
    list_str.append(s)
    list_p.append(-1)
if max(list_p) >= 0:
  print(max(list_p))
else:
  print(0)

Solution (Python):
from itertools import chain
import sys
def input(): return sys.stdin.readline().strip()

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

main()

Solution (Python):
b = [input() for i in range(int(input()))]
r = [input() for i in range(int(input()))]
k = 0
for w in list(set(b)):
  k = max(k, b.count(w) - r.count(w))
print(k)

Solution (Python):
b = [input() for i in range(int(input()))]
r = [input() for i in range(int(input()))]
o = 0
for w in list(set(b)):
  o = max(o, b.count(w) - r.count(w))
  
print(o)

Solution (Python):
import collections

def insert_card(card_number, card_list):
    i = 0
    while i < card_number:
        card_list.append(input())
        i += 1


blue_card_number = int(input())
blue_card_list = []
insert_card(blue_card_number, blue_card_list)

red_card_number = int(input())
red_card_list = []
insert_card(red_card_number, red_card_list)

blue_card_collection = collections.Counter(blue_card_list)
red_card_collection = collections.Counter(red_card_list)

result_card_collection = blue_card_collection - red_card_collection

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

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

Solution (Python):
n=int(input())
s=list(input() for i in range(n))
m=int(input())
t=list(input() for i in range(m))
result=0
for i in set(s):
    result=max(result,s.count(i)-t.count(i))
print(result)

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

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

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

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


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

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

for s in ss:
    ans = max(ans, (ss.count(s)-tt.count(s)))

print(ans)

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

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

s_set=set(s)
ans=0
for i in s:
    score = s.count(i)-t.count(i)
    if score>ans:
        ans=score
print(ans)

Solution (Python):
N = int(input())
l = {}
ans = 0
for _ in range(N):
  s = input()
  if s in l:
    l[s] = l[s] + 1
  else:
    l[s] = 1
M = int(input())
for _ in range(M):
  s = input()
  if s in l:
    l[s] = l[s] - 1
for v in l.values():
  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)]

Max = 0
for i in set(s):
    C = 0
    C = s.count(i) - t.count(i)
    if Max < C:
        Max = C
print(Max)

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

d = {}
for i in s:
    d[i] = d.get(i, 0)+1
for i in t:
    d[i] = d.get(i, 0)-1
ans = max(0, max(d.values()))
print(ans)

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
s = [input() for i in range(n)]
m = inp()
t = [input() for i in range(m)]
ds = defaultdict(int)
dt = defaultdict(int)
for i in s:
    ds[i] += 1
for i in t:
    dt[i] += 1
res = 0
for key in ds.keys():
    res = max(res, ds[key] - dt[key])
print(res)

Solution (Python):


import sys
import collections









def main():
    l = sys.stdin.read().split()
    n = int(l[0])
    m = int(l[n+1])
    a = collections.Counter(l[1:n+1])
    b = collections.Counter(l[n+2:n+m+2])
    for s, c in b.items():
        if s in a:
            a[s] -= c

    ma = max(max(a.values()), 0)
    print(ma)
        

if __name__ == "__main__":
    
    main()

Solution (Python):
from collections import Counter
N = int(input())
scounter = Counter([input() for _ in range(N)])
M = int(input())
tcounter = Counter([input() for _ in range(M)])

nums = []
for s in scounter.keys():
    nums.append(scounter[s] - tcounter[s])

max_num = max(nums)
print(max_num if max_num > 0 else 0)

Solution (Python):
from collections import Counter
N = int(input())
scounter = Counter([input() for _ in range(N)])
M = int(input())
tcounter = Counter([input() for _ in range(M)])

nums = []
for s in scounter.keys():
    nums.append(scounter[s] - tcounter[s])

max_num = max(nums)
print(max_num if max_num > 0 else 0)

Solution (Python):
from collections import Counter
N = int(input())
scounter = Counter([input() for _ in range(N)])
M = int(input())
tcounter = Counter([input() for _ in range(M)])

nums = []
for s in scounter.keys():
    nums.append(scounter[s] - tcounter[s])

max_num = max(nums)
print(max_num if max_num > 0 else 0)

Solution (Python):
n = int(input())
s = []
for i in range(n):
    j = input()
    s.append(j)
m = int(input())
t = []
for k in range(m):
    h = input()
    t.append(h)
couS=[]
for i in range(n):
    count=0
    count+=s.count(s[i])
    count-=t.count(s[i])
    couS.append(count)
    
if max(couS)<0:
    print(0)
else:
    print(max(couS))

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


def list_diff(list1, list2):
    result = list1.copy()
    for val in list2:
        if val in result:
            result.remove(val)
    return result


def count_max(diff_list):
    cnt_list = [diff_list.count(ele) for ele in set(diff_list)]
    if len(cnt_list) != 0:
        return max(cnt_list)
    else:
        return 0


lst = list_diff(s_list, t_list)
print(count_max(lst))

Solution (Python):
D = {}
N = int(input())
for _ in range(N):
    a = input()
    if a in D:
        D[a] += 1
    else:
        D[a] = 1
M = int(input())
for _ in range(M):
    a = input()
    if a in D:
        D[a] -= 1
    else:
        D[a] = -1
ma = 0
for a in D:
    ma = max(ma, D[a])
print(ma)

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

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):
import collections

N = int(input())
s_list = [input() for _ in range(N)]
M = int(input())
t_list = [input() for _ in range(M)]

s_copy = s_list[:]
t_copy = t_list[:]
for i, s in enumerate(s_list):
  if s in t_copy:
    t_copy.remove(s)
    s_copy.remove(s)

if s_copy:
  c = collections.Counter(s_copy)
  print(c.most_common(1)[0][1])
else:
  print(0)

Solution (Python):

si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

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

ST_map = set(S)|set(T)
b = 0
r = 0

ans = -1000
for st_m in ST_map:
    b = 0
    r = 0
    for s in S:
        if st_m == s:
            b+=1
    for t in T:
        if st_m == t:
            r+=1
    ans = max(ans,b-r)

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

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

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())
a = [input() for i in range(n)]
m = int(input())
b = [input() for i in range(m)]
ans = 0
for x in a:
    ans = max(ans,a.count(x)-b.count(x))
print(ans)

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 x in a:
  ans = max(ans,a.count(x)-b.count(x))
print(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())

max_money = 0

for word in set(s):
    money = s.count(word) - t.count(word)
    if money > max_money:
        max_money = money

print(max_money)

Solution (Python):
n=int(input())
a=[input() for _ in range(n)]
m=int(input())
b=[input() for _ in range(m)]
da={}
for word in a:
    da[word]=a.count(word)
for i in b:
    if i in da.keys():
        da[i]-=1
if max(da.values())>=0:
    print(max(da.values()))
else:
    print(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())

dic = {}
for item in s:
    if item not in dic.keys():
        dic[item] = 0
    dic[item] += 1

for item in t:
    if item not in dic.keys():
        dic[item] = 0
    dic[item] -= 1

ans = max(dic.values())

if ans < 0:
    print(0)
else:
    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)])

ans = 0
for key, num in S.items():
  if key in T: ans = max(num-T[key],ans)
  else: ans = max(ans, num)
print(ans)

Solution (Python):
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for j in range(M)]
x = list(set(s))
def counter(x,N,s,M,t):
    ans = [0]
    for i in range(len(x)):
        tmp = 0
        for j in range(N):
            if x[i] == s[j]:
                tmp += 1
        for k in range(M):
            if x[i] == t[k]:
                tmp += (-1)
        ans.append(tmp)
    return(ans)
print(max(counter(x,N,s,M,t)))

Solution (Python):
n = int(input())
s = []
t = []
for i in range(n):
    s.append(input())
for j in range(int(input())):
    t.append(input())
s_set = set(s)
ans = 0
for i in s_set:
    if ans <= s.count(i) - t.count(i):
        ans = s.count(i) - t.count(i)
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 set(s):
    point = s.count(i) - t.count(i)
    if ans < point:
        ans = point
print(ans)

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

red = Counter(s)
blue = Counter(t)

point = 0
for r in red:
  point = max(point, red[r] - blue[r])
  
if point<0:
  point=0

print(point)

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

M = int(input())
for m in range(M):
    s = input()
    if s in cards and cards[s] > 0:
        cards[s] -= 1
    else:
        cards[s] = 0

sorted_cards = list(reversed(sorted(cards.items(), key=lambda x:x[1])))
print(sorted_cards[0][1])

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

Solution (Python):
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
list = [s.count(i) - t.count(i) for i in set(s)]
print(max(0, *list))

Solution (Python):
from collections import Counter
N = int(input())
s_counter = Counter([input() for _ in range(N)])
M = int(input())
t_counter = Counter([input() for _ in range(M)])
d = {}
for key, value in s_counter.items():
  d[key] = [value]
for key, value in t_counter.items():
  if key not in d:
    d[key] = [-value]
  else:
    d[key].append(-value)
result = 0
for value in d.values():
  if sum(value) > result:
    result = sum(value)
print(result)

Solution (Python):
N=int(input())
d={}
ans=0
for n in range(N):
    S=input()
    if S in d:
        d[S]+=1
    else:
        d[S]=1
M=int(input())
for m in range(M):
    T=input()
    if T in d:
        d[T]-=1
    else:
        d[T]=1
for k in d:
    if d[k]>ans:
        ans=d[k]
print(ans)

Solution (Python):
def main():
    N = int(input())
    s = [input() for i in range(N)]
    M = int(input())
    t = [input() for i in range(M)]
    from collections import Counter
    s_counted = Counter(s)
    t_counted = Counter(t)
    ans = 0
    for key, val in s_counted.items():
        ans = max(ans, val - t_counted[key])
    print(ans)


if __name__ == '__main__':
    main()

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

max_money = 0
for word in set(S):
  money = 0
  for s in S:
    if word == s:
      money += 1
  for t in T:
    if word == t:
      money -= 1
  if money > max_money:
    max_money = money

print(max(max_money, 0))

Solution (Python):
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
dic = dict()
m = 0
for i in s:
    if i in dic:
        dic[i] = dic[i] + 1
    else:
        dic[i] = 1
for i in t:
    if i in dic:
        dic[i] = dic[i] - 1
    else:
        dic[i] = -1
for key in dic.keys():
    m = max(m,dic[key])
print(m)

Solution (Python):
N = int(input())
blues = {}
reds = {}
for i in range(N):
    s = input()
    if s in blues:
        blues[s] += 1
    else:
        blues[s] = 1
    reds[s] = 0
M = int(input())
for i in range(M):
    s = input()
    if s in reds:
        reds[s] += 1
    else:
        reds[s] = 1

res = 0
for s in blues:
    res = max(res, blues[s]-reds[s])

print(res)

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

print(ans)

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

Solution (Python):
import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 6)

def main():
    n = int(input())
    s = defaultdict(int)
    for _ in range(n):
        s[input()] += 1
    m = int(input())
    for _ in range(m):
        t = input()
        if t in s:
            s[t] -= 1
    print(max(max(s.values()), 0))

main()

Solution (Python):
from collections import Counter
N = int(input())
S = Counter()
for i in range(N):
  s_i = input()
  S[s_i] += 1

M = int(input())
T = Counter()
for i in range(M):
  t_i = input()
  T[t_i] += 1

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

Solution (Python):
a=int(input())
b=[input() for i in range(a)]
x=int(input())
y=[input() for i in range(x)]
list=[b.count(i) - y.count(i) for i in set(b)]
print(max(0,*list))

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

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())
s = []
for i in range(N):
    s.append(input())

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

import collections
v1 = collections.Counter(s)
v2 = collections.Counter(t)
c = 0
for s in v1.keys():
    _ = v1[s] - v2[s]
    if c < _:
        c = _
print(c)

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

Solution (Python):
s=[input() for _ in range(int(input()))]
t=[input() for _ in range(int(input()))]
cnt=[0]*(len(s)+1)
for i in range(len(s)):
    cnt[i]=s.count(s[i])-t.count(s[i])
print(max(cnt))

Solution (Python):
N = int(input())
n = [input() for _ in range(N)]

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

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