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

Solution (Python):

import collections

def uzai():
            n = int(input())
            s = []
            for i in range(n):
                        s_i = input()
                        s.append(s_i)
            count_dict_s = collections.Counter(s)
            return n, s, count_dict_s

n,s,count_dict_s = uzai()
m,t,count_dict_t = uzai()




s_count_l=[]
for s_name, s_count in count_dict_s.items():
            for t_name, t_count in count_dict_t.items():
                    if s_name==t_name:
                                 s_count_l.append(s_count-t_count)
                    elif s_name not in count_dict_t:
                                 s_count_l.append(s_count)
                                
if max(s_count_l)<=0:
            print('0')
else:
             print(max(s_count_l))

Solution (Python):

import collections

def uzai():
            n = int(input())
            s = []
            for i in range(n):
                        s_i = input()
                        s.append(s_i)
            count_dict_s = collections.Counter(s)
            return n, s, count_dict_s

n,s,count_dict_s = uzai()
m,t,count_dict_t = uzai()




s_count_l=[]
for s_name, s_count in count_dict_s.items():
            for t_name, t_count in count_dict_t.items():
                    if s_name==t_name:
                                 s_count_l.append(s_count-t_count)
                    elif s_name not in count_dict_t:
                                 s_count_l.append(s_count)
                                
if max(s_count_l)<=0:
            print('0')
else:
             print(max(s_count_l))

Solution (Python):
n=int(input())
b=[input() for _ in range(n)]
m=int(input())
r=[input() for _ in range(m)]
l=list(set(b))
a=[]
for s in l:
    a.append(b.count(s) - r.count(s))

print(max(max(a),0))

Solution (Python):
N = int(input())
dic = {}
for i in range(N):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
M = int(input())
dic2 = {}
for i in range(M):
    s = input()
    if s in dic2:
        dic2[s] += 1
    else:
        dic2[s] = 1
ans = 0
for k,v in dic.items():
    tmp = v
    for k2,v2 in dic2.items():
        if k == k2:
            tmp -= v2
    ans = max(tmp,ans)
print(ans)

Solution (Python):
n = int(input())
lsn=[(input()) for i in range(n)]
m = int(input())
lsm=[(input()) for i in range(m)]
ls = []
for i in range(n):
  ls.append(lsn.count(lsn[i])-lsm.count(lsn[i]))
if max(ls) <= 0:
  print(0)
else:
  print(max(ls))

Solution (Python):
from collections import Counter

n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
ans, sav = 0, 0
smc = Counter(s).most_common()
for v, i in smc:
    if v in t:
        sav = i - t.count(v)
    else:
        sav = i

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

Solution (Python):
import collections
d = collections.defaultdict(int)
N = int(input())
for _ in range(N):
  s = input()
  d[s] += 1
M = int(input())
for _ in range(M):
  s = input()
  d[s] -= 1
ret = 0
for k,v in d.items():
  ret = max(ret,v)
print(ret)

Solution (Python):
n=int(input())
a=[] ; b=[]
for _ in range(n):
    a.append(input())
m=int(input())
for _ in range(m):
    b.append(input())
from collections import Counter
a=Counter(a)
b=Counter(b)
for i in b:
    if i in a:
        a[i]=max(0,a[i]-b[i])
print(max(a.values()))

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()
n=int(input())
a=[] ; b=[]
for _ in range(n):
    a.append(input())
m=int(input())
for _ in range(m):
    b.append(input())
from collections import Counter
a=Counter(a)
b=Counter(b)
for i in b:
    if i in a:
        a[i]=max(0,a[i]-b[i])
print(max(a.values()))

Solution (Python):
import collections
s = [input() for i in range(int(input()))]
t = [input() for i in range(int(input()))]
s = list(collections.Counter(s).items())
ans = [0]
for i in range(len(s)):
  ans.append(s[i][1]-t.count(s[i][0]))
ans.sort(reverse = True)
print(ans[0])

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
count = [0] * n
for i in range(n):   
    count[i] = s.count(s[i])
    for j in range(m):
        if s[i] == t[j]:
            count[i] -= 1
if all(i < 0 for i in count):
    print(0)
else:
    print(max(count))

Solution (Python):


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

for i in set(s):
    l.append([s.count(i)-t.count(i),i])
l = sorted(l,reverse=True)


print(max(l[0][0],0))

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


S_set = set(S)


max_cnt = -100
for checker in S_set:
  cnt = 0
  for s in S:
    if s == checker:
      cnt += 1
  for t in T:
    if t == checker:
      cnt -= 1
  if cnt > max_cnt:
    max_cnt = cnt
if max_cnt < 0:
  print(0)
else:
  print(max_cnt)

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)]
s_cnt = Counter(s)
t_cnt = Counter(t)
ans = []

for i in s_cnt:
    if i in t_cnt:
        cal = s_cnt[i] - t_cnt[i]
        if cal <= 0:
            cal = 0
        ans.append(cal)
    else:
        ans.append(s_cnt[i])
print(max(ans))

Solution (Python):
import sys
input = sys.stdin.readline

s_map = {}
N = int(input())
for _ in range(N):
    s = input().rstrip('\r\n')
    num = s_map.get(s)
    if num == None:
        num = 1
    else:
        num += 1
    s_map[s] = num
M = int(input())
for _ in range(M):
    s = input().rstrip('\r\n')
    num = s_map.get(s)
    if num == None:
        num = -1
    else:
        num -= 1
    s_map[s] = num
s_map_sorted = sorted(s_map.items(), key=lambda x:x[1], reverse=True)
ans = max(0, s_map_sorted[0][1])
print(ans)

Solution (Python):
N = int(input())
S = []
L = []
for i in range(N):
  s = str(input())
  S.append(s)
M = int(input())
for i in range(M):
  l = str(input())
  L.append(l)
Ans = 0
for i in range(N):
  a = S[i]
  A = S.count(a)-L.count(a)  
  if A > Ans:
    Ans = A
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)]

ctr = Counter(s)

for val in t:
    if not val in ctr:
        continue
    ctr[val] -= 1

ans = ctr.most_common()[0][1]
if ans >= 0:
    print(ans)
else:
    ans = 0
    print(ans)

Solution (Python):
n = int(input())
blu_list = [str(input()) for _ in range(n)]
m = int(input())
red_list = [str(input()) for _ in range(m)]

blu_set_list = list(set(blu_list))
red_set_list = list(set(red_list))
set_list = blu_set_list + red_set_list

blu_cnt = []
red_cnt = []
ans = []

for i in set_list:
    blu_cnt.append(blu_list.count(i))
    red_cnt.append(red_list.count(i))

for i in range(len(set_list)):
    ans.append(blu_cnt[i] - red_cnt[i])

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

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

sc=Counter(s).most_common()
li=[]
for k,j in sc:
    cnt=0
    for x in range(len(t)):
        if(k==t[x]):
            cnt+=1
    li.append(j-cnt)
if(len(li)!=0):
    print(max(0,max(li)))

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

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

import collections

posi = collections.Counter(s_L)

ans = {}
for k,v in posi.items():
    for t in t_L:
        if t == k:
            v -= 1
    ans[k] = v


ans = sorted(ans.items(),key=lambda x:x[1],reverse=True)

if ans[0][1] < 0:
    print(0)
else:
    print(ans[0][1])

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

counts = {}

for r in RED:
    counts[r] = (counts.get(r) or 0) + 1
    
for b in BLUE:
    counts[b] = (counts.get(b) or 0) - 1
    
print(max(max(counts.values()),0))

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

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

for _ in range(M):
    try:
        S.remove(input())
    except:
        pass

if S==[]:
    print(0)
else:
    S_=Counter(S)
    print(S_.most_common()[0][1])

Solution (Python):
from collections import defaultdict

cards = defaultdict(int)

N = int(input())

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

for _ in range(M):
  cards[input()] -= 1
  
print(max(
  max(cards.values()),
  0
))

Solution (Python):

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

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

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

m = int(input())
red_card = {}
for _ in range(m):
    s = input()
    if s not in red_card:
        red_card[s] = 1
    else:
        red_card[s] += 1
max_diff = 0
for s in blue_card:
    if s not in red_card:
        red_card[s] = 0
    diff = blue_card[s] - red_card[s]
    max_diff = max(max_diff, diff)
print(max_diff)

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

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

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

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

result = 0
for i in range(len(s)):
    result = max(s[i][1]-t[s[i][0]], result)
print(result)

Solution (Python):
import collections
n = int(input())
s = list()
for i in range(n):
    s.append(input())
m = int(input())
t = list()
for i in range(m):
    t.append(input())
st = set(s)
tt = set(t)
sc = collections.Counter(s)
tc = collections.Counter(t)
highest = -float("inf")
for i in st:
    x = sc[i] - tc[i]
    if x > highest:
        highest = x
if highest < 0:
    print(0)
else:

    print(highest)

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
ans = 0
temp = set(S)
for i in temp:
    if S.count(i) - T.count(i) > ans:
        ans = S.count(i) - T.count(i)
print(ans)

Solution (Python):
import collections

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

set_S=set(S)
dict_S=collections.Counter(S)
set_T=set(T)
dict_T=collections.Counter(T)

for i in set_S:
    if i in set_T:
        dict_S[i]-=dict_T[i]
print(max(max(dict_S.values()),0))

Solution (Python):
n = int(input())
S = [input() for _ in range(n)]
D = {}
for s in S:
    if s in D:
        D[s] += 1
    else:
        D[s] = 1
m = int(input())
T = [input() for _ in range(m)]
for t in T:
    if t in D:
        D[t] -= 1
D_sorted = sorted(D.items(), key=lambda x: x[1], reverse=True)
for k, v in D_sorted:
    print(max(0, v))
    exit()

Solution (Python):
ls_blue = [input() for _ in range(int(input()))]
ls_red = [input() for _ in range(int(input()))]
set_all = set(ls_blue + ls_red)
dic_point = {}
for word in set_all:
    dic_point[word] = ls_blue.count(word) - ls_red.count(word)

max_point = max(dic_point.values())
if max_point < 0:
    print(0)
else:
    print(max_point)

Solution (Python):
def main(n, s: list, m, t: list):
    choices = set(s + t)

    ans = [0]

    for choice in choices:
        ans_t = 0
        for _s in s:
            if choice == _s:
                ans_t += 1
        for _t in t:
            if choice == _t:
                ans_t -= 1

        ans.append(ans_t)

    print(max(ans))


if __name__ == "__main__":
    n = int(input())
    s = [input() for _ in range(n)]
    m = int(input())
    t = [input() for _ in range(m)]

    main(n, s, m, t)

Solution (Python):
from itertools import groupby

def solve():
    N = int(input())
    a = [input() for _ in range(N)]
    a.sort()
    M = int(input())
    b = [input() for _ in range(M)]
    b.sort()
    
    d = {}
    gr = groupby(a)
    for key, group in gr:
        d.setdefault(key, []).append(len(list(group)))
    
    gr = groupby(b)
    for key, group in gr:
        d.setdefault(key, []).append(-len(list(group)))
    
    m = 0
    for k, v in d.items():
        su = sum(v)
        if su > m:
            m = su
    return m

print(solve())

Solution (Python):
import sys
from collections import defaultdict
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    cards = defaultdict(int)
    for _ in range(N):
        cards[input()] += 1

    M = int(input())
    for _ in range(M):
        cards[input()] -= 1
    print(max(max(cards.values()),0))

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
s_li = [input() for i in range(N)]
M = int(input())
t_li = [input() for i in range(M)]
cost_dic = {}
for i in range(N) :
    cost_dic[s_li[i]] = s_li.count(s_li[i]) - t_li.count(s_li[i])
cost_sorted = sorted(cost_dic.items(), key=lambda x:x[1],reverse=True)
print(max(0, cost_sorted[0][1]))

Solution (Python):
import collections

n = int(input())
blue = [0] * n
for i in range(n):
    blue[i] = input()
m = int(input())
red = [0] * m
for i in range(m):
    red[i] = input()

ans = 0
word = []
wordCnt = []

for i in range(n):
    if not blue[i] in word:
        word.append(blue[i])
        wordCnt.append(1)
    else:
        for j in enumerate(word):
            if blue[i] == j[1]:
                wordCnt[j[0]] += 1

for i in range(m):
    if not red[i] in word:
        word.append(red[i])
        wordCnt.append(-1)
    else:
        for j in enumerate(word):
            if red[i] == j[1]:
                wordCnt[j[0]] -= 1

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

Solution (Python):
N = int(input())
s = []
t = []
ans = 0
for i in range(N):
    S = input()
    s.append(S)
M = int(input())
for i in range(M):
    T = input()
    t.append(T)    
for k in range(N):
    cnt = s.count(s[k])-t.count(s[k])
    ans = max(ans,cnt)
print(ans)

Solution (Python):
from collections import defaultdict
blue = defaultdict(int)
red = defaultdict(int)

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

m = int(input())
for _ in range(m):
    s = input()
    red[s] += 1

ans = 0
for k, v in blue.items():
    w = v - red[k]

    ans = max(w, ans)
print(ans)

Solution (Python):
from operator import itemgetter
n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for i in range(m)]
d=dict()
for i in range(n):
  if s[i] not in d:
    d[s[i]]=1
  else:
    d[s[i]]+=1
for i in range(m):
  if t[i] in d:
    d[t[i]]-=1
d=sorted(list(d.items()),reverse=True,key=itemgetter(1))
if d[0][1]>0:
  print(d[0][1])
else:
  print(0)

Solution (Python):

n=int(input())
blue=[input() for _ in range(n)]
bset = set(blue)

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

print(max([max(0, blue.count(b) - red.count(b)) for b in bset]))

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

m = int(input())
ts = []
for i in range(m):
    ts.append(input())

counter = dict()

for s in ss:
    counter.setdefault(s, 0)
    c = counter.get(s)
    counter[s] = c + 1
    
for t in ts:
    counter.setdefault(t, 0)
    c = counter.get(t)
    counter[t] =  c - 1
    
ans = max(counter.values())
if ans < 0:
    ans = 0
print(ans)

Solution (Python):
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

from collections import defaultdict

N = ni()
s = nsn(N)
M = ni()
t = nsn(M)

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

for i in range(M):
    b[t[i]] += 1

ans = -inf
for k, v in d.items():
    ans = max(ans, v - b[k])

if ans < 0:
    print(0)
else:
    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 set(s):
  num = s.count(i) - t.count(i)
  if num > ans :
    ans = num
    
    
print(ans)

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

M=int(input())
for i in range(M):
    score[input()]-=1
    
print(max(0,max(score.values())))

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

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

K=int(input())
for i in range(K):
  s=input()
  if (str(s) in A)==1:
    A.remove(s)
B=set(A)
ans=0
for i in B:
  if A.count(i)>ans:
    ans=A.count(i)
print(ans)

Solution (Python):
def BlueCardsCnt(cards, n):
    for i in range(n):
        s = input()
        cards.setdefault(s, 0)
        cards[s] += 1
    return cards

def RedCardsCnt(cards, m):
    for i in range(m):
        s = input()
        cards.setdefault(s, 0)
        cards[s] -= 1
    return cards

N = int(input())
cards = {}
cards = BlueCardsCnt(cards, N)
M = int(input())
cards = RedCardsCnt(cards, M)

max_v = max(cards.values())

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

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

list_all = list( set(blue) | set(red) )
dict_all = dict.fromkeys(list_all, 0)

for i in range(len(blue)) :
    dict_all[blue[i]] += 1

for i in range(len(red)) :
    dict_all[red[i]] -= 1

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

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

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

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())
nl = [input() for _ in [0]*n]
m = int(input())
ml = [input() for _ in [0]*m]
xl = list(set(nl + ml))
x,y,z = 0,0,0
for i in range(len(xl)):
    x = nl.count(xl[i])
    y = ml.count(xl[i])
    z = max(z, (x-y))
print(z)

Solution (Python):




N = int(input().strip())
S_list = [input().strip() for _ in range(N)]

M = int(input().strip())
T_list = [input().strip() for _ in range(M)]

text_dic = {}

for word in S_list:
    if word not in text_dic:
        text_dic[word] = 1
    else:
        text_dic[word] += 1

for word in T_list:
    if word not in text_dic:
        text_dic[word] = -1
    else:
        text_dic[word] -= 1

result = max(text_dic.values())
if result < 0:
    result = 0

print(result)

Solution (Python):
import collections

n = int(input())
s = list(input() for i in range(n))
m = int(input())
t = list(input() for j in range(m))

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

s -= t
s = dict(s)

print(max(s.values()) if len(s) != 0 else 0)

Solution (Python):
from collections import defaultdict
blue, red = defaultdict(int), defaultdict(int)
n = int(input())
for _ in range(n):
    blue[input()] += 1
m = int(input())
for _ in range(m):
    red[input()] += 1
    
ans = []
for k in blue.keys():
    ans.append(max(0, blue[k]-red[k]))
print(max(ans))

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

Solution (Python):
from collections import defaultdict

def main():
    N = int(input())
    blue_str_freq = defaultdict(int)
    for blue_str in [input() for _ in range(N)]:
        blue_str_freq[blue_str] += 1

    M = int(input())
    red_str_freq = defaultdict(int)
    for red_str in [input() for _ in range(M)]:
        red_str_freq[red_str] += 1

    max_val = 0
    for blue_str, blue_freq in blue_str_freq.items():
        if blue_freq - red_str_freq[blue_str] > max_val:
            max_val = blue_freq - red_str_freq[blue_str]
    print(max_val)

if __name__ == '__main__':
    main()

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

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

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

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

print(answer)

Solution (Python):
n = int(input())
d = {}
for _ in range(n):
    s = input()
    if s not in d.keys():
        d[s] = 0
    d[s] += 1
m = int(input())
for _ in range(m):
    s = input()
    if s in d.keys():
        d[s] -= 1
d = sorted(d.items(), key=lambda x:x[1])
if d[-1][1] == - (m - 1) or (d[-1][1] < 0): print(0)
else: print(d[-1][1])

Solution (Python):
lst_blue = []
lst_red = []
dic = {}

N = int(input())
for i in range(0,N):
  lst_blue.append(input())
M = int(input())
for i in range(0,M):
  lst_red.append(input())

for i in list(set(lst_blue)):
  dic[i] = int(lst_blue.count(i))

for i in lst_red:
  if i in dic:
    dic[i] -= 1
    
print(max(0,max(dic.values())))

Solution (Python):
from collections import defaultdict

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

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

ans = 0

for key in S:
  if key in T:
    _ = S[key] - T[key]
  else:
    _ = S[key]
  
  ans = max(ans,_)

print(ans)

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

lis = set(s)
ans = 0

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

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

N=int(input())
for i in range(N):
    s=input()
    dd[s]+=1
    
M=int(input())
for _ in range(M):
    t=input()
    dd[t]-=1
    
ans=0
for k,v in dd.items():
    ans=max(ans,v)
    
print(ans)

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

l=[]
for i in p:
  l.append(p.count(i)-m.count(i))
print(max(0,max(l)))

Solution (Python):
from collections import defaultdict
d = defaultdict(int)
for _ in range(int(input())):
    d[input()] += 1
for _ in range(int(input())):
    d[input()] -= 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=0
buf=0
s.sort()
t.sort()
for i in range(n):
    buf=0
    for j in range(i,n):
        if s[i]==s[j]:
            buf+=1
        elif s[i]<s[j]:
            break
    for j in range(m):
        if s[i]==t[j]:
            buf-=1
        elif s[i]<t[j]:
            break
    if buf>ans:
        ans=buf
print(ans)

Solution (Python):
S=[input() for _ in range(int(input()))]
T=[input() for _ in range(int(input()))]
ans=0
for i in S:
    tmp=S.count(i)-T.count(i)
    if tmp>ans:
        ans=tmp
print(ans)

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

for j in range(m):
  s = input()
  if s not in d2:
    d2[s] = 1
  else:
    d2[s] += 1
k1 = d1.keys()
k2 = d2.keys()
a = 0
temp = 0
for x in k1:
  if x not in k2:
    if a < d1[x]:
      a = d1[x]
  else:
    temp = d1[x] - d2[x]
    if a < temp:
      a = temp
print(a)

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

C = []

for i in list(set(A)):
    C.append(A.count(i) - B.count(i))
print(max(max(C), 0))

Solution (Python):
N = int(input())
A = []
for i in range(N):
    A.append(input())
M = int(input())
B = []
for j in range(M):
    B.append(input())

count = 0
ans = 0

for k in set(A):
    count = A.count(k)-B.count(k)
    if count >= 0 and ans <= count:
        ans = count

print(ans)

Solution (Python):
N = int(input())
blue = [input() for i in range(N)]
M = int(input())
red = [input() for i in range(M)]
blue_only = []

max_get = 0
for i in range(N):
    if blue[i] in red:
        get = blue.count(blue[i]) - red.count(blue[i])
    else:
        get = blue.count(blue[i])
    if get > max_get:
        max_get = get

print(max_get)

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

Solution (Python):
from collections import Counter

N = int(input())
s_count = Counter([input() for _ in range(N)])
M = int(input())
t_count = Counter([input() for _ in range(M)])

s_count.subtract(t_count)
print(max(0,s_count.most_common(1)[0][1]))

Solution (Python):
Blue = []
Red = []
N = int(input())
for _ in range(N):
    Blue.append(input())
M = int(input())
for _ in range(M):
    Red.append(input())
    
Red.sort()
Blue.sort()

P = []
n = 1
for i in range(N):
    if i != N-1:
        if Blue[i] == Blue[i+1]:
            n += 1
        else:
            for j in range(M):
                if Blue[i] == Red[j]:
                    n -= 1
            P.append(n)
            n = 1
    else:
        for j in range(M):
            if Blue[i] == Red[j]:
                n -= 1
        P.append(n)
        n = 1

maxi = max(P)
if maxi < 0:
    print(0)
else:
    print(maxi)

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

    cnt = 0
for s in set(S):
    cnt = max(cnt, S.count(s)-T.count(s))
print(cnt)

Solution (Python):
def get_info(diff):
    length = int(input())
    strings = {}
    for _ in range(length):
        tmp = input()
        if tmp in strings:
            strings[tmp] += diff
        else:
            strings[tmp] = diff
    return length, strings


def main():
    blue_card, blue_card_str = get_info(1)
    red_card, red_card_str = get_info(-1)
    answer = 0
    available_keys = (blue_card_str.keys() & red_card_str.keys()) | blue_card_str.keys()
    for key in available_keys:
        if key in red_card_str:
            diff = blue_card_str[key] + red_card_str[key]
        else:
            diff = blue_card_str[key]
        answer = max(answer, diff)
    print(answer)


if __name__ == '__main__':
    main()

Solution (Python):

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

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

"""
ans = s[0]
for h in range(n):
    tmp = s[h]
    money = 0
    money_max = 0
    for i in range(n):
        if s[i] == tmp:
            money += 1
    for j in range(m):
        if t[j] == tmp:
            money -= 1
    if money > money_max:
        money_max = money
        ans = tmp
print(money_max, ans)
"""

Solution (Python):
N = int(input())
s = {}
for i in range(N):
  a = input()
  if a in s:
    s[a] += 1
  else:
    s[a] = 1
M = int(input())
t = {}
for i in range(M):
  b = input()
  if b in t:
    t[b] += 1
  else:
    t[b] = 1
ans = 0
for p in s:
  if p in t:
    m = s[p] - t[p]
  else:
    m = s[p]
  if m > ans:
    ans = m
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())


from collections import Counter
c1 = Counter()
c2 = Counter()

for si in S:
    c1[si] += 1

for ti in T:
    c2[ti] += 1




ans = 0
for si in c1.keys():
    ans = max(ans, c1[si] - c2[si])

print(ans)

Solution (Python):
n = int(input())
blueList = [input() for _ in range(n)]
m = int(input())
redList = [input() for _ in range(m)]
max_score = 0
for i in blueList:
    score = blueList.count(i) - redList.count(i)
    if max_score < score:
        max_score = score
print(max_score)

Solution (Python):
n=int(input())
a=[input() for i in range(n)]
m=int(input())
b=[input() for i in range(m)]
l=set(a+b)
m=0
for x in l:
    c=0
    for y in a:
        if x==y:c+=1
    for z in b:
        if x == z:c-=1
    m=max(m,c)
print(max(m,0))

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

s_counter = collections.Counter(s)
t_counter = collections.Counter(t)

ans = 0
for i in s_counter:
    ans = max(ans, s_counter[i] - t_counter[i])
print(ans)