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 = {}
for _ in range(N):
    s = input()
    if s in S:
        S[s] += 1
    else:
        S[s] = 1

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

res = 0

for s in S:
    if s in T:
        if S[s] - T[s] > 0:
            res = max(res, S[s] - T[s])

    else:
        res = max(res, S[s])

print(res)

Solution (Python):
L=list()
R=list()
N=int(input())
for i in range(N):
  S=input()
  L.append(S)
M=int(input())
for i in range(M):
  S=input()
  R.append(S)
maxa=0
for i in range(N):
  s=L.count(L[i])-R.count(L[i])
  maxa=max(maxa,s)
print(maxa)

Solution (Python):
def resolve():
    N = int(input())
    S = []
    for _ in range(N):
        s = input()
        S.append(s)
    M = int(input())
    T = []
    for __ in range(M):
        t = input()
        T.append(t)
    SS = set(S)
    ans = []
    for i in SS:
        ans.append(S.count(i)-T.count(i))
    print(max(max(ans), 0))
resolve()

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

Solution (Python):
from collections import defaultdict


def main():

    blue = defaultdict(int)
    red = defaultdict(int)

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

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

    ans = 0

    for word, cnt in blue.items():
        if word in red.keys():
            ans = max(ans, cnt - red[word])
        else:
            ans = max(ans, cnt)
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
from collections import defaultdict
def main():
    d = defaultdict(int)
    n = int(input())
    for _ in range(n):
        d[input()] += 1
    n = int(input())
    for _ in range(n):
        d[input()] -= 1
    print(max(0, *d.values()))

if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter

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

c1 = Counter(s)
c2 = Counter(t)

MAX=0
for k1 in c1.keys():
  count = c1[k1]
  for k2 in c2.keys():
    if k1==k2:
      count -= c2[k2]
  MAX = max(MAX,count)

print(MAX)

Solution (Python):
N=int(input())
CARD={}
for i in range(N):
  s = str(input())
  if s not in CARD:
    CARD[s] = 1
  else:
    CARD[s]+=1
M=int(input())
for i in range(M):
  t = str(input())
  if t in CARD:
    CARD[t]-=1
print(max(max(CARD.values()),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 s:
    tmp = s.count(i) - t.count(i)
    ans = max(ans, tmp)
print(ans)

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

dd=ddf(lambda:0)
for e in s: dd[e]+=1
for e in t: dd[e]-=1
print(max(0,max(dd.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
for i in s:
    ans=max(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)]
money = []
for plus in collections.Counter(s).most_common():
    if plus[0] in t:
        money.append(plus[1] - collections.Counter(t).get(plus[0]))
    else:
        money.append(plus[1])
if max(money) < 0:
    print(0)
else:
    print(max(money))

Solution (Python):

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

d = {}
for st in s:
    if st not in d:
        d[st] = 0
    d[st] += 1
for st in t:
    if st not in d:
        d[st] = 0
    d[st] -= 1

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

Solution (Python):
n=int(input())
plus=[input() for _ in range(n)]
m=int(input())
minus=[input() for _ in range(m)]
res=[]
for i in plus:
    a=plus.count(i)
    b=minus.count(i)
    res+=[(a-b,i)]
res.sort(reverse=1)
print(max(0,res[0][0]))

Solution (Python):

import collections
n = int(raw_input())
cca = collections.Counter([raw_input() for _ in range(n)])
m = int(raw_input())
ccb = collections.Counter([raw_input() for _ in range(m)])

r = 0
for w in cca.keys() + ccb.keys():
	r = max(r,cca[w] - ccb[w])
print r

Solution (Python):
n=int(input())
blues=[]
for i in range(n):
    blues.append(input())
m=int(input())
reds=[]
for i in range(m):
    reds.append(input())
m=0
for blue in blues:
    x=blues.count(blue)-reds.count(blue)
    m=max(m,x)
print(m)

Solution (Python):
N=int(input())
s=[input() for i in range(N)]
M=int(input())
t=[input() for i in range(M)]
s2=list(set(s))
counter=0
for i in range(len(s2)):
    if s.count(s2[i])-t.count(s2[i])>counter:
        counter=s.count(s2[i])-t.count(s2[i])

print(counter)

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

ans = 0
for s in S:
    rwd = 0
    for i in range(n):
        if s == S[i]:
            rwd += 1
    for i in range(m):
        if s == T[i]:
            rwd -= 1
    ans = max(rwd, ans)
print(ans)

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



st_set = set(s_list + t_list)


ans = 0
for st in st_set:
    
    
    
    ans = max(ans, s_list.count(st) - t_list.count(st))

print(ans)

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

s.sort()
S = []
S.append(s[0])
for i in range(len(s)-1):
    if s[i] != s[i+1]:
        S.append(s[i+1])

MAX = 0
for i in S:
    d = s.count(i) - t.count(i)
    MAX = max(MAX, d)

print(MAX)

Solution (Python):
blue = [input() for _ in range(int(input()))]
red = [input() for _ in range(int(input()))]
ans = 0
for i in set(blue):
    c= blue.count(i) - red.count(i)
    ans = max(c, ans, 0)
print(ans)

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

cnt = 0

for s in set(S):
    score = S.count(s) - T.count(s)
    if score > cnt:
        cnt = score
        
print(cnt)

Solution (Python):



import collections

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

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

C_S=collections.Counter(S)
C_T=collections.Counter(T)

score=0

for word in C_S:
    temp_score=C_S[word] - C_T[word]
    if temp_score>score :
        score=temp_score
    else:
        pass

print(score)

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

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

answer = 0
for skey in sn.keys():
  if not skey in tn:
    check = sn[skey]
  else :
    check = sn[skey] - tn[skey]
  if answer < check:
    answer = check

print(answer)

Solution (Python):
n = int(input())
b = [input() for _ in range(n)]
m = int(input())
r = [input() for _ in range(m)]
c = list(set(b+r))
ans = 0
for i in range(len(c)):
  d = b.count(c[i])-r.count(c[i])
  ans = max(0, ans, d)
print(ans)

Solution (Python):
cards = {}

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

m = int(input())
for _ in range(m):
    t = input()
    cards[t] = cards.get(t,0)-1

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

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

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

maxi = 0
words = ""
for i in list(set(plus)):
  temp = plus.count(i) - minus.count(i)
  if maxi < temp:
    maxi = temp
    words = i
print(maxi)

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())
  
c = list(set(s))
ans = 0
for i in range(len(c)):
  ans = max([ans, s.count(c[i])-t.count(c[i])])
  
print(ans)

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

ans = 0

for i in card.values():
    if i > ans:
        ans = i

print(ans)

Solution (Python):
N=int(input())
s=[input() for i in range(N)]
M=int(input())
t=[input() for j in range(M)]
o=0
for k in s:
    ans=max(s.count(k)-t.count(k),o)
    o=ans

print(ans)

Solution (Python):
from collections import defaultdict

d = defaultdict(int)
N = int(input())
for _ in range(N):
    s = str(input())
    d[s] += 1
M = int(input())
for _ in range(M):
    t = str(input())
    d[t] -= 1

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

Solution (Python):
l={}
N=int(input())
for i in range(N):
    a=input()
    if a in l:
        l[a]+=1
    else:
        l[a]=1
M=int(input())
for j in range(M):
    b=input()
    if b in l:
        l[b]-=1

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

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

Solution (Python):
N = int(input())
ListP = []
for i in range (N):
  ListP.append(input())
M = int(input())
ListN = []
for i in range (M):
  ListN.append(input())
res = 0
mid = 0
for i in range(N):
  mid += ListP.count(ListP[i])
  mid += -ListN.count(ListP[i])
  res = max(res,mid)
  mid = 0
print(res)

Solution (Python):
d = {}

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

for i in range(int(input())):
    t = input()
    if t in d:
        d[t] -= 1

print(max(0, max(i for i in d.values())))

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

dic={}
for i in range(N):
    if s[i] in dic:
        dic[s[i]]+=1
    else:
        dic[s[i]]=1

for i in range(M):
    if t[i] in dic:
        dic[t[i]]-=1
    else:
        dic[t[i]]=-1

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

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

ans = 0
for w in set(blue_words):
  tmp = blue_words.count(w) - red_words.count(w)
  if tmp > ans:
    ans = tmp

print(ans)

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

for k, j in t.items():
    if k in s:
        s[k] -= j

values, counts = zip(*s.most_common())
print(max(0,counts[0]))

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

    ans = 0
    for s_i in s:
        tmp = 0
        tmp += s.count(s_i)
        tmp -= t.count(s_i)
        ans = max(ans, tmp)
    print(ans)


if __name__ == "__main__":
    solve()

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

keys = s.keys() & t.keys()
for key in keys:
    s[key] -= t[key]

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

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

ans = 0

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

Solution (Python):
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
ans = 0
ex_list = []
for i in range(N):
    if s[i] not in ex_list:
        if s.count(s[i]) > t.count(s[i]):
            ans = max(s.count(s[i])-t.count(s[i]),ans)
            ex_list.append(s[i])
print(ans)

Solution (Python):
n = int(input())
bluedict = {}
for i in range(n):
    word = input()
    if bluedict.get(word) == None:
        bluedict[word] = 1
    else:
        bluedict[word] += 1

m = int(input())
reddict = {}
for i in range(m):
    word = input()
    if reddict.get(word) == None:
        reddict[word] = 1
    else:
        reddict[word] += 1

m = 0
for blueword in bluedict.keys():
    c = 0
    c += bluedict[blueword]
    if reddict.get(blueword) != None:
        c -= reddict[blueword]
    m = max(m,c)

print(m)

Solution (Python):
N = int(input())
jisyo = {}
for i in range(N):
  a = input()
  if a not in jisyo:
    jisyo[a] = 1
  else:
    jisyo[a] +=1
M = int(input())
for i in range(M):
  b = input()
  if b not in jisyo:
    jisyo[b] = -1
  else:
    jisyo[b] -=1
maxi = 0
for i,k in jisyo.items():
  if maxi < k:
    maxi = k
print(maxi)

Solution (Python):
import sys
def I(): return int(sys.stdin.readline().rstrip())
def S(): return sys.stdin.readline().rstrip()

N = I()
s = [S() for i in range(N)]
M = I()
t = [S() for i in range(M)]

from collections import Counter

c1 = Counter(s)
c2 = Counter(t)
ans = 0
for a in c1.keys():
    ans = max(ans,c1[a]-c2[a])

print(ans)

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

l = list(set(s))


mx  = max(s.count(l[i])-t.count(l[i]) for i in range(len(l)))
print(max(0,mx))

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


cs = Counter(s)
ct = Counter(t)
for i in cs:
    
    for j in ct:
        
        if i == j:
            cs[i]=cs[i]-ct[j]
            

print(max(0,cs.most_common(1)[0][1]))

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

blues = []
reds = []

count = []
for i in range(n):
    count.append(0)
max_count = 0

for i in range(n):
    p = input()
    blues.append(p)

v = input()
m = int(v)

for i in range(m):
    q = input()
    reds.append(q)

for i in range(len(blues)):
    for j in range(len(blues)):
        if blues[i] == blues[j]:
            count[i] += 1

for i in range(len(blues)):
    for j in range(len(reds)):
        if blues[i] == reds[j]:
            count[i] -= 1

for i in range(len(count)):
    max_count = max(max_count, count[i])

print(max_count)

Solution (Python):
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
ans = 0
ex_list = []
for i in range(N):
    if s[i] not in ex_list:
        if s.count(s[i]) > t.count(s[i]):
            ans = max(s.count(s[i])-t.count(s[i]),ans)
            ex_list.append(s[i])
print(ans)

Solution (Python):
N_1 = int(input())
A = [str(input()) for i in range(N_1)]
N_2 = int(input())
B = [str(input()) for i in range(N_2)]

C = A+B
D = list(set(C))
E=[]
for i in range(len(D)):
    NN = A.count(D[i]) - B.count(D[i])
    E.append(NN)
if max(E)>=0:
    print(max(E))
else:
    print(0)

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
count = []
mx = 0
words_list = list(set(s+t))
for word in words_list :
    count.append([word, 0])
for word in words_list :
    idx = words_list.index(word)
    count[idx][1] += s.count(word)
    count[idx][1] -= t.count(word)
for i in range(len(words_list)) :
      mx = max(mx,count[i][1])
print(mx)

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

count = 0
for i in range(n):
  count = s.count(s[i]) - t.count(s[i]) if count < s.count(s[i]) - t.count(s[i]) else count
print(count)

Solution (Python):
s ={}
n = int(input())
for _ in range(n):
    word = input()
    s[word] = s.get(word, 0)+1
m = int(input())
for _ in range(m):
    word = input()
    s[word] = s.get(word, 0)-1

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

Solution (Python):
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n = I()
    s = [input() for _ in range(n)]
    m = I()
    t = [input() for _ in range(m)]
    word = set(s) | set(t)
    ans = 0
    for w in word:
        cnt = s.count(w)
        cnt -= t.count(w)
        ans = max(ans, cnt)
    print(ans)


if __name__ == '__main__':
    main()

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

for i in range(m):
    t = input()
    if t in count:
        count[t] -= 1
    else:
        count[t] = -1
max_v = max(count.values())
if max_v < 0:
    max_v = 0
print(max_v)

Solution (Python):
import collections

N = int(input())

a = []
b = []
for i in range(N):
    s = input()
    a.append(s)

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

a1 = collections.Counter(a)
a2 = a1.most_common()

ans = 0
for i in range(len(a1)):
    total = a2[i][1] - b.count(a2[i][0])
    if total > ans:
        ans = total
    else:
        continue
print(ans)

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

s1=set(s)
a=b=0
for ss in s1:
  a=s.count(ss)-t.count(ss)
  if a>b:
    b=a
print(b)

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]
S_set = set(S)
M = int(input())
T = [input() for _ in range(M)]
m = 0
for s in S_set:
  m = max(m, S.count(s)-T.count(s))
print(m)

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for j in range(m)]
S = list(set(s))
T = list(set(t))
b = []

for x in range(len(S)):
  a = s.count(S[x]) - t.count(S[x])
  b.append(a)
ans = max(0, max(b))
print(ans)

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

sd=C(s)
td=C(t)

max=0
for k in sd:
  if sd[k]-td[k]>max:
    max=sd[k]-td[k]
print(max)

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

max = 0
for c in S:
    money = S.count(c) - T.count(c)
    if money > max:
        max = money
print(max)

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


cntb = collections.Counter(lb)
cnta = collections.Counter(la)
t_max = 0
cntb.subtract(cnta)

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

Solution (Python):

N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
dic_s = {}
for i in set(s):
    dic_s[i] = s.count(i) 
dic_t = {}
for i in set(t):
    dic_t[i] = t.count(i)
ss=set(s)
ts=set(t)
if(ss & ts == set()):
    print(max(dic_s.values()))
else:
    dic_c = {}
    for i in ss&ts:
        dic_c[i] = dic_s[i] - dic_t[i]
    if(not (ss & (ss^ts) == set())):
        for i in ss & (ss^ts):
            dic_c[i] = dic_s[i]
    if(max(dic_c.values()) < 0):
        print(0)
    else:
        print(max(dic_c.values()))

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

reds = dict()
blues = dict()

n=ni()
for i in range(n):
  s = input()
  if s not in blues:
    blues[s] = 1
  else:
    blues[s]+=1

n = ni()
for i in range(n):
  s = input()
  if s not in reds:
    reds[s] = 1
  else:
    reds[s]+=1


ans=0
for k in blues.keys():
  if k in reds:
    num = blues[k]-reds[k]
    if num>0:
      ans = max(ans,num)
      continue
  else:
    ans = max(ans,blues[k])
  

print(ans)

Solution (Python):



N = int(input())
s = []

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

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

for j in range(M):
    t.append(str(input()))

set_s = set(s)
set_t = set(t)
ans = 0
tmp_ans = 0

for tmp_s in set_s:
    
    tmp_ans = s.count(tmp_s) - t.count(tmp_s)
    
    ans = max(ans, tmp_ans)

print(ans)

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







__giturl__ = "$URL$"


from collections import defaultdict
from sys import stdin
input = stdin.readline


def main():
  N = int(input())
  S = [input()[:-1] for _ in range(N)]

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

  smap = defaultdict(int)
  tmap = defaultdict(int)
  for i in range(N):
    smap[S[i]] += 1
  for i in range(M):
    tmap[T[i]] += 1

  max_ = 0
  for key in smap.keys():
    max_ = max(max_, smap[key]-tmap[key])

  print(max_)


if(__name__ == '__main__'):
  main()

Solution (Python):
N = int(input())
S = [input() for n in range(N)]
M = int(input())
T = [input() for m in range(M)]
ans = 0

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

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(*d.values(), 0))

Solution (Python):
import collections
i = int(input())
blue = [input() for b in range(i)]
l = int(input())
red = [input() for r in range(l)]
bluecount = collections.Counter(blue)
redcount = collections.Counter(red)

c = 0
for i, j in bluecount.items():
    c = max(j-redcount[i], c)
print(c)

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

lst = [0]*(N+1)

for i in range(N):
    ref = S[i]
    lst[i] = S.count(ref) - T.count(ref)

ans = max(lst)
print(ans)

Solution (Python):
import collections
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
S = collections.Counter(s)
T = collections.Counter(t)
c = 0
for i, j in S.items():
    c = max(j-T[i], c)
print(c)

Solution (Python):
s = []
t = []
ans = 0

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

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

for c in s:
    cnt = s.count(c) - t.count(c)
    ans = max(ans, cnt)

print(ans)

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

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


m = int(input())
r = [input() for i in range(m)]

from collections import Counter
bc = Counter(b)
rc = Counter(r)

bs = list(set(b))

res = 0
for i in bs:
    res = max(res,bc[i]-rc[i])
    
print(res)

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)

ans = 0

for i, j in cs.items():
    ans = max(j-ct[i], ans)

print(ans)

Solution (Python):
import sys
import collections

input = sys.stdin.readline

def main():
    ans = 0
    n = int(input())
    s = [input().rstrip('\n') for _ in range(n)]
    m = int(input())
    t = [input().rstrip('\n') for _ in range(m)]
    cs = collections.Counter(s)
    ct = collections.Counter(t)
    for k,v in cs.items():
        ans = max(v-ct[k], ans)
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
dic = {}
N = int(input())
for _ in range(N):
    s = input()
    dic.setdefault(s, 0)
    dic[s] += 1
M = int(input())
for _ in range(M):
    s = input()
    try:
        dic[s] -= 1
    except:
        continue
m = 0
for k in dic:
    m = max(m, dic[k])
print(m)

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

Solution (Python):
import sys
input = sys.stdin.readline
Pl = []
Mi = []

N = int(input())
for i in range(N):
    Pl.append(input().rstrip('\n'))
M = int(input())
for i in range(M):
    Mi.append(input().rstrip('\n'))

ans = 0
for s in Pl:
    ans = max(ans, Pl.count(s)-Mi.count(s))
print(ans)

Solution (Python):
N=int(input())
E={"*":0}
for _ in range(N):
    S=input()
    if S in E:
        E[S]+=1
    else:
        E[S]=1

M=int(input())
for _ in range(M):
    S=input()
    if S in E:
        E[S]-=1
    else:
        E[S]=-1

print(max(E.values()))

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


def main():
    N = int(input())
    dict = defaultdict(int)
    for _ in range(N):
        string = input()
        dict[string] += 1
    M = int(input())
    for _ in range(M):
        string = input()
        dict[string] -= 1

    ans = 0
    for key in dict: ans = max(ans, dict[key])
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):

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

ans = 0
for i in s:
    sc = s.count(i)
    tc = t.count(i)
    cnt = sc - tc
    if cnt > ans:
        ans = cnt

print(ans)

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

S = sorted(S)
T = sorted(T)
W = []
c = -1
num = []
for i in range(N):
    if not(S[i] in W):
        W.append(S[i])
        num.append(0)
        c += 1
        for j in range(i,N):
            if W[c] == S[j]:
                num[c] += 1
        for j in range(M):
            if W[c] == T[j]:
                num[c] -= 1
num.append(0)
print(max(num))

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

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

c = Counter(a)
max0 = 0
for i in c.most_common(): max0 = max(max0, i[1]-b.count(i[0]))
print(max0)

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

m = int(input())

for i in range(m):
  s = input()
  if s in n_s:
    n_s[s] -= 1
  else:
    n_s[s] = -1

if max(n_s.values()) < 0 :
  print(0)
else:
  print(max(n_s.values()))

Solution (Python):
n = int(input())
S = list(input() for _ in range(n))
m = int(input())
T = list(input() for _ in range(m))
ans = 0
for i in list(set(S)):
    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)]

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

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

Solution (Python):



import sys
from collections import defaultdict



def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(blue_count, blue_list, red_count, red_list):
    result = 0
    allDict = defaultdict(int)
    for j in range(0, blue_count, +1):
        allDict[blue_list[j]] += 1
    for j in range(0, red_count, +1):
        allDict[red_list[j]] -= 1
    
    
    dictList = list(allDict.values()) + [0]
    dictList.sort(reverse=True)
    
    result = dictList[0]
    return result


if __name__ == "__main__":
    N = II()
    si = []
    for _ in range(0, N, +1):
        si.append(input())
    M = II()
    ti = []
    for _ in range(0, M, 1):
        ti.append(input())
    print("{}".format(solver(N, si, M, ti)))

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

p_names = []
p_count = []
for n in range(N):
    p_count.append(0)

for n in range(N):
    tmp = input()
    if tmp in p_names:
        index = p_names.index(tmp)
        p_count[index] += 1
    else:
        p_names.append(tmp)
        index = p_names.index(tmp)
        p_count[index] += 1
        
M = int(input())
for m in range(M):
    tmp = input()
    if tmp in p_names:
        index = p_names.index(tmp)
        p_count[index] -= 1
    else:
        continue

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

Solution (Python):
import math
def main():
  n=int(input())
  s = [input() for i in range(n)]
  m=int(input())
  t = [input() for i in range(m)]
  ans=0
  while len(s)>0:
    num=s.count(s[0])-t.count(s[0])
    if ans<num:
      ans=num
    s=[x for x in s if x != s[0]]
  print(ans)
  
main()