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

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

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

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




def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return float(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))


from collections import defaultdict

def main():
	s=defaultdict(int)
	n=II()
	for _ in range(n):
		s[RD()]+=1
	m=II()
	for _ in range(m):
		s[RD()]-=1

	ans=0
	for k,v in s.items():
		ans=max(ans,v)
	print(ans)





if __name__ == "__main__":
	main()

Solution (Python):
N = int(input())
Blue = [input() for _ in range(N)]
M = int(input())
Red = [input() for _ in range(M)]
Word = Blue + Red
Word = list(set(Word))
ans = 0
for i in range(len(Word)):
    cnt = 0
    cnt += Blue.count(Word[i])
    cnt -= Red.count(Word[i])
    ans = max(ans,cnt)
print(ans)

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

def ans091(N:int, s:list, M:int, t:list):
    test_count=0
    own=list(set(s))
    for i in range(len(own)):
        if test_count<=s.count(own[i])-t.count(own[i]):
            test_count=s.count(own[i])-t.count(own[i])
    if test_count>0:
        return test_count
    else:
        return 0
print(ans091(N,s,M,t))

Solution (Python):
N = int(input())
C = {}
for _ in range(N):
    a = input().strip()
    if a not in C:
        C[a] = 0
    C[a] += 1
M = int(input())
for _ in range(M):
    a = input().strip()
    if a not in C:
        C[a] = 0
    C[a] -= 1
cmax = -100
for a in C:
    cmax = max(cmax,C[a])
print(max(0,cmax))

Solution (Python):
from collections import defaultdict


cnt = defaultdict(int)
cnt[0] = 0
N = int(input())
for _ in range(N):
    cnt[input()] += 1
M = int(input())
for _ in range(M):
    cnt[input()] -= 1
print(max(v for v in cnt.values()))

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

sc = collections.Counter(s)
tc = collections.Counter(t)
ans = 0
for x in sc.keys():
  ans = max(ans,sc[x]-tc[x])
print(ans)

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

from collections import Counter
cs = Counter(S)
ct = Counter(T)

ans = -10**18
for k, v in cs.items():
    if k in ct:
        temp = v - ct[k]
    else:
        temp = v
    ans = max(ans, temp)
print(max(ans, 0))

Solution (Python):
n = int(input())
sl = list(input() for _ in range(n))
m = int(input())
tl = list(input() for _ in range(m))

cnt = 0
for s in sl:
    cnt = max(cnt, sl.count(s) - tl.count(s))

print(cnt)

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

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

Solution (Python):

import sys
input=sys.stdin.readline

def main():
    n = int(input())
    word_dict={}
    for i in range(n):
        s = input().rstrip()
        if s not in word_dict:
            word_dict[s]=1
        else:
            word_dict[s]+=1
    m = int(input())
    for j in range(m):
        t= input().rstrip()
        if t in word_dict:
            word_dict[t]-=1
        else:
            word_dict[t]=-1

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

if __name__=="__main__":
    main()

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

m = int(input())
t_l = [ str(input()) for _ in range(m)  ]
d = {}
for s in s_l:
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1
for t in t_l:
    if t not in d:
        d[t] = -1
    else:
        d[t] -= 1
ans = 0
for k, v in d.items():
    ans = max(v, ans)
print(ans)

Solution (Python):
n = int(input())
s=[]
for i in range(n):
    s.append(input())
from collections import Counter
cs = Counter(s)
m = int(input())
for i in range(m):
    t = input()
    if cs[t]:
        cs[t] -= 1
print(cs.most_common(1)[0][1], flush=True)

Solution (Python):
from typing import List


def answer(n: int, s: List[str], m: int, t: List[str]) -> int:
    result = 0
    for i in s:
        result = max(result, s.count(i) - t.count(i))

    return result


def main():
    n = int(input())
    s = [input() for _ in range(n)]
    m = int(input())
    t = [input() for _ in range(m)]
    print(answer(n, s, m, t))


if __name__ == '__main__':
    main()

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

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
ans = 0
sc = list(set(s.copy()))
from collections import Counter
sn = Counter(s)
tn = Counter(t)
for i in range(len(sc)):
  ans = max(sn[sc[i]]-tn[sc[i]],ans)
print(ans)

Solution (Python):
import sys, collections
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
n, = [int(num) for num in lines.pop(0).split(" ")]
blue_list = lines[:n]
lines = lines[n:]
m, = [int(num) for num in lines.pop(0).split(" ")]
red_list = lines
blue = collections.Counter(blue_list)
red = collections.Counter(red_list)
c = blue - red
lis = c.values()
if len(lis):
    ans = max(lis)
else:
    ans = 0
print(ans)

Solution (Python):
n = int(input())
a = []
for i in range(n):
  a.append([input(),0])
m = int(input())
b = []
for i in range(m):
  b.append([input(),0])

res = 0
for i in range(n):
  c = 0
  if a[i][1] == 0:
    a[i][1] = 1
    for j in range(i,n):
      if a[i][0] == a[j][0]:
        c += 1
        a[j][1] = 1
    for j in range(m):
      if a[i][0] == b[j][0]:
        c -= 1
  res = max(res,c)
print(res)

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

def point(x):
   result = 0
   result += s.count(x)
   result -= t.count(x)
   return result

ans = 0

for word in set(s):
   if ans < point(word):
      ans = point(word)

print(ans)

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

ans = 0
for i in range(n):
    tmp = blue.count(blue[i]) - red.count(blue[i])
    ans = max(ans, tmp)
print(ans)

Solution (Python):


def main():
    blue = [input() for i in range(int(input()))]
    red = [input() for i in range(int(input()))]
    l = list(set(blue))
    print(max(0, max(blue.count(l[i]) - red.count(l[i]) for i in range(len(l)))))


if __name__ == "__main__":
    main()

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

from collections import Counter
counter = Counter(S)
counter.subtract(T)
print(max(0, max(counter.values())))

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

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

score = sorted(memo.items(), key=lambda x:-x[1])
print(max(score[0][1],0))

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

Solution (Python):



from math import gcd
from itertools import combinations,permutations,accumulate, product 

from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq














import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7


INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
n = I()
s = Counter([input() for _ in range(n)])
m = I()
t = Counter([input() for _ in range(m)])
ans = 0
for k,v in s.items():
    ans = max(ans, max(0, v-t[k]))
print(ans)

Solution (Python):
from collections import defaultdict

cnt = defaultdict(int)
cnt["a" * 11] = 0
for _ in range(int(input())):
    cnt[input()] += 1
for _ in range(int(input())):
    cnt[input()] -= 1
ans = max(cnt.values())
print(ans)

Solution (Python):
from collections import defaultdict
d1 = defaultdict(int)
d2 = defaultdict(int)
n = int(input())
for i in range(n):
    d1[input()] += 1
m = int(input())
for i in range(m):
    d2[input()] += 1

ans = 0
for k, v in d1.items():
    ans = max(ans, v - d2[k])
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)])

for x,y in s.items():
    s[x] = s[x]-t[x]
print(max(max(list(s.values())), 0))

Solution (Python):
n = int(input())
sl = list(input() for _ in range(n))
m = int(input())
tl = list(input() for _ in range(m))

sl_s = list(set(sl))
tl_s = list(set(tl))

ans = 0
for s in sl_s:
    ans = max(ans, sl.count(s) - tl.count(s))

print(ans)

Solution (Python):
import collections
n = int(input())
b = [input() for _ in range(n)]
m = int(input())
r = [input() for _ in range(m)]
bc = collections.Counter(b)
rc = collections.Counter(r)
ans = 0
for x in bc.keys():
  ans = max(ans, bc[x]-rc[x])
print(ans)

Solution (Python):
from collections import Counter
N = int(input())
blue = [input() for _ in range(N)]
M = int(input())
red = [input() for _ in range(M)]
Cb = Counter(blue)
Cr = Counter(red)
ans = 0
for b in Cb.most_common():
    x = b[0]
    y = b[1]
    if Cr.get(x):
        ans = max(ans, y - Cr[x])
    else:
        ans = max(ans, y)
print(ans)

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

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

ans = 0
for k in CS.keys():
    if k not in CT:
        ans = max(CS[k], ans)
    else:
        ans = max(ans, max(0, CS[k]-CT[k]))
print(ans)

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

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

Solution (Python):
from collections import Counter
import math
import statistics
import itertools
a=int(input())






g = [input() for _ in range(a)]





b = int(input())
g2 = [input() for _ in range(b)]

g.sort()
g2.sort()

count=1
ans={}
ans2={}

for i in range(len(g)-1):
    if g[i+1]==g[i]:
        count+=1
    else:
        ans[g[i]]=count
        count=1

ans[g[-1]]=count
count=1
for i in range(len(g2)-1):
    if g2[i+1]==g2[i]:
        count+=1
    else:
        if g2[i] in ans.keys():
            ans[g2[i]]-=count
            count=1
        else:
            ans[g2[i]]=-count

if g2[-1] in ans.keys():
    ans[g2[-1]]-=count
    count=1
else:
    ans[g2[-1]]=-count

if max(ans.values())>0:
    print(max(ans.values()))
else:
    print(0)

Solution (Python):
n=int(input())
s=[]
t=[0]*101
for _ in range(n):
    si=input()
    if si not in s:s.append(si)
    t[s.index(si)]+=1
m=int(input())
for _ in range(m):
    si=input()
    if si in s:t[s.index(si)]-=1
print(max(0,max(t)))

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

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

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

Solution (Python):
n = int(input())
s = [""]*n
for i in range(n):
    s[i] = input()
import collections
s = collections.Counter(s)
m = int(input())
for j in range(m):
    t = input()
    if t in s:
        s[t] -= 1
print(max(0, s.most_common()[0][1]))

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

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

words = set(s)
ans = 0

for w in words:
    tmp = 0
    for si in s:
        if w == si:
            tmp += 1
    for ti in t:
        if w == ti:
            tmp -= 1
    ans = max(ans, tmp)
print(ans)

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

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

ans=[]
for i in s:
    cnt=0
    for j in range(n):
        if i==s[j]:
            cnt+=1
    for k in range(m):
        if i==t[k]:
            cnt-=1
    ans.append(cnt)

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

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

s = Counter(S)
t = Counter(T)

ans = 0
for k, v in s.items():
    tmp = v
    tmp -= t[k]
    ans = max(ans, tmp)
print(ans)

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

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

from collections import Counter

n = int(input())
s = [0] * n
for i in range(n):
    s[i] = input().strip()
s = Counter(s)
m = int(input())
t = [0] * m
for i in range(m):
    t[i] = input().strip()
t = Counter(t)

ans = 0
for k in s:
    tmp = s[k]
    if k in t:
        tmp -= t[k]
    ans = max(ans, tmp)
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 s in set(S):
  ans = max(ans,S.count(s)-T.count(s))
print(ans)

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

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

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

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

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

ans=max(dd.values())
if ans < 0:
  ans = 0
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())

words = set(s + t)
max_val = 0
for word in words:
    ans = s.count(word)
    ans -= t.count(word)
    if ans > max_val:
        max_val = ans
print(max_val)

Solution (Python):
from collections import Counter

def solve():
    N = int(input())
    S = [input() for _ in range(N)]
    M = int(input())
    T = [input() for _ in range(M)]
    SC = Counter(S)
    TC = Counter(T)
    ans = 0
    for k, v in SC.items():
        ans = max(ans, v - TC.get(k, 0))
    print(ans)

if __name__ == "__main__":
    solve()

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

Solution (Python):
N=int(input())
s=dict()
for _ in range(N):
    S=input()
    if S not in s:
        s[S]=0
    s[S]+=1
M=int(input())
for _ in range(M):
    t=input()
    if t in s:
        s[t]-=1
print(max(max(0,x) for x in s.values()))

Solution (Python):





def resolve():
    import sys
    input = sys.stdin.readline

    word_dict = {}
    n = int(input().rstrip())
    for i in range(n):
        s = input().rstrip()
        if s not in word_dict:
            word_dict[s] = 0
        word_dict[s] += 1

    m = int(input().rstrip())
    for i in range(m):
        s = input().rstrip()
        if s not in word_dict:
            word_dict[s] = 0
        word_dict[s] -= 1

    ans = max(word_dict.values())
    print(ans if ans > 0 else 0)

if __name__ == "__main__":
    resolve()

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

st_dict = {}

for i in range(N):
    if s[i] not in st_dict.keys():
        st_dict[s[i]] = 1
    else:
        st_dict[s[i]] += 1
for i in range(M):
    if t[i] not in st_dict.keys():
        st_dict[t[i]] = -1
    else:
        st_dict[t[i]] -= 1

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

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 = 0
for word, cnt in Blue.items():
  temp = cnt - Red[word]
  ans = max(ans, temp)

print(ans)

Solution (Python):
import collections

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

maxi = 0

for i in range(len(S)):
    if S.count(S[i]) - T.count(S[i]) > maxi:
        maxi = S.count(S[i]) - T.count(S[i])

print(maxi)

Solution (Python):
N = int(input())
dic = {}
for i in range(N):
  a = input()
  dic[a] = dic.get(a, 0) + 1
M = int(input())
for i in range(M):
  b = input()
  dic[b] = dic.get(b, 0) - 1
d = sorted(dic.values(), reverse = True)
print(max(0, d[0]))

Solution (Python):
N = int(input())
blue = {}
for _ in range(N):
  s = input()
  if s in blue.keys():
    blue[s] += 1
  else:
    blue[s] = 1

M = int(input())
red = {}
for _ in range(M):
  t = input()
  if t in red.keys():
    red[t] += 1
  else:
    red[t] = 1
    
cnt = 0
for i in blue.keys():
  if i in red.keys():
    cnt = max(cnt, blue[i] - red[i])
  else:
    cnt = max(cnt, blue[i])
    
print(cnt)

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

b = list(s.keys())
r = list(t.keys())
subs = []

for i in range(len(b)):
    if b[i] in r:
        subs.append(s[b[i]]-t[b[i]])
    else:
        subs.append(s[b[i]])
print(max(0,max(subs)))

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

Solution (Python):


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


all_words = set(blue_cards + red_cards)

ans = 0
for i,w in enumerate(all_words):
    cnt_b = cnt_r = 0
    for b in blue_cards:
        if b == w:
            cnt_b += 1
    for r in red_cards:
        if r == w:
            cnt_r+= 1

    diff = cnt_b - cnt_r
    if diff > ans:
        ans = diff

print(ans)

Solution (Python):
n = int(input())
blue = list()
for i in range(n):
    blue.append(input())
m = int(input())
red = list()
for j in range(m):
    red.append(input())
ans = 0
for p in range(n):
    cnt = 0
    for q in range(n):
        if blue[p] == blue[q]:
            cnt += 1
    for r in range(m):
        if blue[p] == red[r]:
            cnt -= 1
    ans = max(ans, cnt)
print(ans)

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

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

Solution (Python):
import sys
import itertools

import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


N = int(input())
A = [input() for _ in range(N)]
M = int(input())
B = [input() for _ in range(M)]

cnt_a = Counter(A)
cnt_b = Counter(B)

ans = 0
for k, v in cnt_a.items():
    val = v - cnt_b[k]
    ans = max(ans, val)
print(ans)

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

s_dic = {}
t_dic = {}

for i in s:
  if i in s_dic.keys():
    s_dic[i] += 1
  else:
    s_dic[i] = 1
    
for i in t:
  if i in t_dic.keys():
    t_dic[i] += 1
  else:
    t_dic[i] = 1
    
all_list = []

for i in s_dic.keys():
  if i in t_dic.keys():
    all_list.append(s_dic[i] - t_dic[i])
  else:
    all_list.append(s_dic[i])
    
for i in t_dic.keys():
  if i in s_dic.keys():
    all_list.append(s_dic[i] - t_dic[i])
  else:
    all_list.append(-t_dic[i])
    
print(max(max(all_list), 0))

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

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

print(m)

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

ssset = set(ss)
cnt = 0
for x in ssset:
	cnt = max(cnt, ss.count(x) - ts.count(x))
print(cnt)

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 word, count in S.items():
    temp = count - T[word]
    ans = max(ans, temp)
print(ans)

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

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

s = Counter(s)
t = Counter(t)

ans = 0
for key, num in s.items():
    if key in t:
        if ans < num - t[key]:
            ans = num - t[key]
    else:
        if ans < num:
            ans = num

print(ans)

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

profit = 0
for i in s:
	temp = s.count(i) - t.count(i)
	if profit < temp:
		profit = temp

print(profit)

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import Counter
    N = int(readline())
    blue = Counter()
    red = Counter()

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

    M = int(readline())

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

    ans = 0

    for key in blue.keys():
        score = blue[key] - red[key]
        ans = max(ans, score)

    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):
import collections

N = int(input())
S = [input() for i in range(N)]
cS = collections.Counter(S)
lS = list(cS.items())
M = int(input())
T = [input() for i in range(M)]
cT = collections.Counter(T)
list1 = []
ans = 0

for i in range(len(lS)):
    
    if lS[i][0] in cT:
        x = lS[i][1] - cT[lS[i][0]]
        
    else:
        x = lS[i][1]
        
    if x > 0:
        list1.append(x)
    
if list1 == []:
  print(0)
else:
  print(max(list1))

Solution (Python):

from collections import Counter

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

s = Counter(s)

t = Counter(t)

ans = 0
for i in s.keys():
    if i in t:
        ans_tmp = s[i] - t[i]
    else:
        ans_tmp = s[i]
    ans = max(ans, ans_tmp)
print(ans)

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

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

for i in set(s):
    plus.append(s.count(i))
    minus.append(t.count(i))

for j in range(len(plus)):
    total.append(plus[j]-minus[j])
    
print(max(0,max(total)))

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
Get = {}
for s in S:
    if s in Get:
        Get[s] += 1
    else:
        Get[s] = 1
for t in T:
    if t in Get:
        Get[t] += -1
    else:
        Get[t] = -1
ans = max(Get.values())
print(ans if ans > 0 else 0)

Solution (Python):



def main():
    d = {}
    n = int(input())
    for i in range(n):
        s = input()
        v = d.get(s, 0)
        d[s] = v + 1

    m = int(input())
    for i in range(m):
        s = input()
        v = d.get(s, 0)
        d[s] = v - 1
    ans = 0
    for i in d.values():
        if i > ans:
            ans = i
    print(ans)


if __name__ == "__main__":
    main()

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

s_set = list(set(s))
t_set = list(set(t))

ans = ""
INF = -float("inf")

for i in s_set:
    score = s.count(i) - t.count(i)
    if INF < score:
        INF = score
        ans = i
for i in t_set:
    score = s.count(i) - t.count(i)
    if INF < score:
        INF = score
        ans = i

if INF < 0:
    print(0)
else:
    print(INF)

Solution (Python):
from collections import defaultdict
n = int(input())
s = defaultdict(int)
t = defaultdict(int)

for i in range(n):
    x = input()
    s[x] += 1

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

ans = 0
for x, v in s.items():
    now = v - t[x]
    ans = max(ans, now)

print(ans)

Solution (Python):
n=int(input())
ans=0
count=0
s={}
t={}
for i in range(n):
  a=input()
  if a not in s:
    s[a]=1
  else:
    s[a]+=1
m=int(input())
for i in range(m):
  a=input()
  if a not in t:
    t[a]=1
  else:
    t[a]+=1
    
S=list(s.keys())
T=list(t.keys())
for i in range(len(S)):
  if S[i] in T:
    count=s[S[i]]-t[S[i]]
  else: count=s[S[i]]
  ans=max(ans,count)
  
print(ans)

Solution (Python):
from collections import Counter

n = int(input())
s = [None] * n
for i in range(n):
    s[i] = input().rstrip()

m = int(input())
t = [None] * m
for i in range(m):
    t[i] = input().rstrip()

ctr = Counter(s) - Counter(t)
if ctr:
    print(ctr.most_common(1)[0][1])
else:
    print(0)

Solution (Python):
N = int(input())
n_list = []
for i in range(N):
  n_list.append(input())
M = int(input())
m_list = []
for i in range(M):
  m_list.append(input())
add_dic = {}
for n in n_list:
  add = add_dic.get(n, 0)
  add_dic[n] = add + 1
diff_dic = {}
for m in m_list:
  diff = diff_dic.get(m, 0)
  diff_dic[m] = diff + 1

max_ = 0
for key, add in add_dic.items():
  total = add - diff_dic.get(key, 0)
  if total > max_:
    max_ = total

print(max_)

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

Solution (Python):
n = int(input())
str_dict = dict()
for i in range(n):
    s = input()
    if s not in str_dict:
        str_dict[s] = 1
    else:
        str_dict[s] += 1

m = int(input())
for i in range(m):
    t = input()
    if t not in str_dict:
        str_dict[t] = -1
    else:
        str_dict[t] -= 1

res = max(0, sorted(list(str_dict.values()))[-1])
print(res)

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

Solution (Python):
import collections

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

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

for i in mlist:
    if i in nlist:
        nlist.remove(i)

nlist = collections.Counter(nlist).most_common()

if nlist==[]:
    print(0)
    exit()

print(nlist[0][1])