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 sys

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))

def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]

def to_bin(x: int) -> str: return format(x, 'b') 
def to_oct(x: int) -> str: return format(x, 'o') 
def to_hex(x: int) -> str: return format(x, 'x') 
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]

from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left


def main():
    n = II()
    ss = Counter([IS() for _ in range(n)])
    m = II()
    tt = Counter([IS() for _ in range(m)])
    tt_key = set(tt.keys())
    maxv = 0
    for s, c in ss.items():
        cnt = c
        if s in tt_key:
            cnt -= tt[s]
        maxv = max(maxv, cnt)
    print(maxv)


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)]
max = 0
for ss in s:
  if s.count(ss) -t.count(ss) > max:
    max = s.count(ss) - t.count(ss)
print(max)

Solution (Python):
from collections import Counter

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


sc = Counter(s)
tc = Counter(t)
u = list(set(s + t))
maxcnt = 0
for i in range(len(u)):
	cnt = 0
	cnt += sc[u[i]]
	cnt -= tc[u[i]]
	if cnt >= maxcnt:
		maxcnt = cnt
print(maxcnt)

Solution (Python):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop

import collections

n = int(input())
S = []
U = []
for i in range(n):
    s = input()
    S.append(s)
    U.append(s)
m = int(input())
T = []
for i in range(m):
    t = input()
    T.append(t)
    U.append(t)
U = list(set(U))
cnt = [0] *len(U)
for i in range(n):
    for j in range(len(U)):
        if S[i] == U[j]:
            cnt[j] += 1
for i in range(m):
    for j in range(len(U)):
        if T[i] == U[j]:
            cnt[j]-=1
a = max(cnt)
print(max(a,0))

Solution (Python):
from collections import Counter
N = int(input())
s_counter = Counter()
for _ in range(N):
    s = input()
    s_counter[s] += 1
M = int(input())
t_counter = Counter()
for _ in range(M):
    t = input()
    t_counter[t] += 1
max_profit = 0
for key in s_counter.keys():
    max_profit = max([max_profit, s_counter[key] - t_counter[key]])
print(max_profit)

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

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

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 = 0

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

print(ans)

Solution (Python):
N=int(input())
s = []
for i in range(N):
    s.append(input())
M=int(input())
t=[]
for k in range(M):
    t.append(input())
count=0
for r in s:
    scount=s.count(r)
    tcount=t.count(r)
    ans=scount-tcount
    if ans>=count:
        count=ans
print(count)

Solution (Python):
n = int(input())
B = [input() for _ in range(n)]
m = int(input())
R = [input() for _ in range(m)]
L = list(set(B) | set(R))
dict = {key:0 for key in L}
for b in B:
    dict[b] += 1
for r in R:
    dict[r] -=1
dict.update({"AAA":0})
print(max(dict.values()))

Solution (Python):
N = int(input())
Blue = [str(input()) for i in range(N)]
M = int(input())
Red = [str(input()) for i in range(M)]
Blue_Set = list(set(Blue))
X = 0
for i in range(len(Blue_Set)):
  if (Blue.count(Blue_Set[i]) - Red.count(Blue_Set[i])) > X:
    X = Blue.count(Blue_Set[i])-Red.count(Blue_Set[i])
print(X)

Solution (Python):


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

blue = {}
for c in s:
    if c in blue.keys():
        blue[c] += 1
    else:
        blue.setdefault(c, 1)
red = {}
for c in t:
    if c in red.keys():
        red[c] += 1
    else:
        red.setdefault(c, 1)

Max = 0
for blue_key, blue_value in blue.items():
    get = blue_value
    if blue_key in red.keys():
        for red_key, red_value in red.items():
            if blue_key == red_key:
                get -= red_value
                break
    Max = max(Max, get)
print(Max)

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

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

Solution (Python):
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range (M)]
sc = []
sl = []
tc = []
tl = []
anslist = []
i = 0 
j = 0
k = 0
l = 0

s.sort()
t.sort()


while i < N:
  sc.append(s.count(s[i]))
  sl.append(s[i])
  i += s.count(s[i])
  
while j < M:
  tc.append(t.count(t[j]))
  tl.append(t[j])
  j += t.count(t[j])

for k in range(len(sl)):
  for l in range(len(tl)):
    if tl[l] == sl[k]:
      sc[k] -= tc[l]
  
print(max(max(sc), 0))

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

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

d = {}
for val,cnt in Counter(s).items():
    d[val] = cnt

for val,cnt in Counter(t).items():
    if val in d:
        d[val] -= cnt
print(max(max(d.values()),0))

Solution (Python):
from collections import defaultdict

N = int(input())
dic = defaultdict(int)
for i in range(N):
  temp = str(input())
  dic[temp] += 1

M = int(input())
for i in range(M):
  temp = str(input())
  dic[temp] -= 1

ans = max(dic.values())
if ans < 0:
  print("0")
else:
  print(ans)

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

b = []
m = int(input())
for j in range(m):
    b += [input()]

ans = 0
for k in set(a):
    if k in b:
        ans = max(ans, a.count(k) - b.count(k))
    else:
        ans = max(ans, a.count(k))
print(ans)

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

Solution (Python):
import sys
from collections import defaultdict
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(input())
    d = defaultdict(int)
    for _ in range(N):
        d[input()] += 1
    M = int(input())
    for _ in range(M):
        d[input()] -= 1
    print(max(0,max(d.values())))
if __name__ == '__main__':
    main()

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

ss = set(s)
mx = 0
for ssi in ss:
    mx = max(mx, s.count(ssi) - t.count(ssi))
print(mx)

Solution (Python):
import collections

n= int(input())
A =[input() for _ in range(n)]
Ac = collections.Counter(A)
m= int(input())
B =[input() for _ in range(m)]
Bc = collections.Counter(B)
ans =[]
for i in Ac.keys():
    ans.append(Ac[i]-Bc[i])
print(max(max(ans),0))

Solution (Python):
import collections

n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
d = collections.Counter(s)

for k in t:
    if k in d:
        d[k]-=1
print(d.most_common()[0][1] if d.most_common()[0][1]>=0 else 0)

Solution (Python):
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
M = int(input())
T = [input() for i in range(M)]
d = Counter(S)
for t in T:
    if t in d:
        d[t]+=-1
    else:
        d[t]=-1
print(d.most_common()[0][1] if d.most_common()[0][1]>0 else 0)

Solution (Python):


n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
word = list(set(s))
ans = 0

for w in word:
    ans = max(ans, s.count(w) - t.count(w))

print(max(0, ans))

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
ans = [0]*n
for i in range(n):
    for j in range(n):
        if s[i] == s[j]:
            ans[i] += 1
    for j in range(m):
        if s[i] == t[j]:
            ans[i] -= 1
print(max(0, max(ans)))

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

li = []
nums = []
for s in S:
    if s not in li:
        li.append(s)
        nums.append(1)
    else:
        nums[li.index(s)] += 1
for t in T:
    if t in li:
        nums[li.index(t)] -= 1
mx = max(nums)
ans = max(0, mx)
print(ans)

Solution (Python):
d={'':0}
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(d.values()))

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

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

Solution (Python):
import collections as ct
n = int(input())
s_c = ct.Counter([input() for i in range(n)])
m = int(input())
t_c = ct.defaultdict(int, ct.Counter([input() for i in range(m)]))
ans = max([s_c[k] - t_c[k] for k in s_c])
print(max(ans, 0))

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

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

X_list = []
for str in s_list:
    x = s_list.count(str) - t_list.count(str)
    X_list.append(x)

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

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

c = collections.Counter(s).most_common()
C = []
for i in range(len(c)):
    C.append([c[i][0], c[i][1]])

ans = []
for j in range(len(C)):
    if C[j][0] in t:
        C[j][1] -= t.count(C[j][0])
    ans.append(C[j][1])

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

Solution (Python):
result = 0
blue_num = int(input())
blue_list = []

for i in range(blue_num):
  blue_list.append(input())
  
red_num = int(input())
red_list = []

for i in range(red_num):
  red_list.append(input())
  
for key in set(blue_list + red_list):
  point = blue_list.count(key) - red_list.count(key)
  if result < point:
    result = point

print(result)

Solution (Python):
from collections import Counter

s=Counter(input() for i in range(int(input())))
t=Counter(input() for i in range(int(input())))
print(max([0]+[s[i]-t[i] for i in s.keys()]))

Solution (Python):
import collections

N=int(input())
s=collections.Counter([input() for i in range(N)])
M=int(input())
t=collections.Counter([input() for i in range(M)])

print(max([0]+[s[i]-t[i] for i in s.keys()]))

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

max_point = 0
for i in range(N):
  point = len([1 for s in S if s==S[i]]) - len([1 for t in T if t==S[i]])
  max_point = max([max_point,point])
  
print(max_point)

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

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

max=0

for i in range(s_num):
    if max < int(s.count(s[i]) - t.count(s[i])):
        max = int(s.count(s[i]) - t.count(s[i]))
        
print(max)

Solution (Python):
n = int(input())
b = []
b_i = [0 for i in range(110)]
for i in range(n):
    s = input()
    if not s in b:
        b.append(s)
        b_i[b.index(s)] += 1
    else:
        b_i[b.index(s)] += 1 
m = int(input())
for i in range(m):
    t = input()
    if not t in b:
        b.append(t)
        b_i[b.index(t)] += 1
    else:
        b_i[b.index(t)] -= 1 
print(max(b_i))

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

for i in range(N):
    s[i]=input()

M=input()
M=int(M)
t = [0 for i in range(M)]

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


ans=0
for i in range(N):
    count=0
    
    target=s[i]
    
    
    for j in range(N):
        if target==s[j]:
            count+=1
    
    for j in range(M):
        if target==t[j]:
            count-=1
    
    if ans<count:
        ans=count

print(ans)

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

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

sset=list(set(s))
tset=list(set(t))

Nset=len(sset)
ans=0
for i in range(Nset):
  if s.count(sset[i])-t.count(sset[i])>ans:
    ans=s.count(sset[i])-t.count(sset[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(t) - m.count(t) for t in l)))

Solution (Python):
import sys
N = int(sys.stdin.readline())
s = [sys.stdin.readline().rstrip() for i in range(N)]
M = int(sys.stdin.readline())
t = [sys.stdin.readline().rstrip() for i in range(M)]
ans = 0
p = 0
m = 0
for i in s:
    p = s.count(i)
    m = t.count(i)
    ans = max(ans, p - m)
print(ans)

Solution (Python):
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    n = ni()
    s = [ns() for _ in range(n)]
    m = ni()
    t = [ns() for _ in range(m)]

    c1 = Counter(s)
    c2 = Counter(t)
    ans = []
    for key1, value1 in c1.items():
        if key1 in c2.keys():
            ans.append(value1 - c2[key1])
        else:
            ans.append(value1)

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

if __name__ == '__main__':
    main()

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

for a in S1:
    if a not in T:
        result.append(S.count(a))
    else:
        if S.count(a) >= T.count(a):
            result.append(S.count(a) - T.count(a))

if not result:
    print(0)
else:
    print(max(result))

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

Solution (Python):
import collections
N=int(input())
s=[input() for _ in range(N)]
M=int(input())
t=[input() for _ in range(M)]
s_set=collections.Counter(s)
t_set=collections.Counter(t)
score=[]
for w in s_set:
    score+=[s_set[w]-t_set[w]]
print(max(score) if max(score)>0 else 0)

Solution (Python):
n=int(input())
s={}
for _ in range(n):
  si=input()
  if si in s:
    s[si]+=1
  else:
    s[si]=1
m=int(input())
t={}
for _ in range(m):
  ti=input()
  if ti in t:
    t[ti]+=1
  else:
    t[ti]=1

ans=0
for i in s:
  p=s[i]-t.get(i, 0)
  if p>ans:
    ans=p
print(ans)

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

Solution (Python):
from collections import defaultdict
dic = defaultdict(int)
n = int(input())
for i in range(n):
    dic[input()] += 1
n = int(input())
for i in range(n):
    dic[input()] -= 1
m = sorted([i for i in dic.values()])[-1]
if m >= 0:
    print(m)
else:
    print(0)

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

s = [0] * N

for i in range(N):
    s[i] = input()

M = int(input()) 

t = [0] * M

for i in range(M):
    t[i] = input()
    
p = "" 
counter = 0
ans = 0

for i in range(N):
    p = s[i]
    for ii in range(N):
        if p == s[ii]:
            counter += 1
    for iii in range(M):
        if p == t[iii]:
            counter -= 1
    if ans < counter:
        ans = counter
    counter = 0    

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)]
count_red = Counter(s)
count_blue = Counter(t)
ans = [0]
for i in count_red:
    a = count_red[i]
    if i in count_blue:
        a -= count_blue[i]
    ans.append(a)
print(max(ans))

Solution (Python):
from sys import stdin
import sys

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

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

words_count = {}
for i in range(N):
    words_count[S[i]] = words_count.get(S[i], 0) + 1

for i in range(M):
    words_count[T[i]] = words_count.get(T[i], 0) - 1

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

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

print(max([s.count(S) - t.count(S) for S in s] + [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())
max = 0
for a in s:
  cnt = s.count(a) - t.count(a)
  if cnt > max:
    max = cnt
print(max * (max > 0))

Solution (Python):
B = [input() for i in range(int(input()))]
R = [input() for i in range(int(input()))]
B_dict = {}

for i in B:
    if i in B_dict:
        B_dict[i] += 1
    else:
        B_dict[i] = 1

max = 0
for item in B_dict:
    b_value = B_dict[item]
    r_value = R.count(item)
    if b_value - r_value > max:
        max = b_value - r_value

print(max)

Solution (Python):
import collections

def main():
    S = []
    T = []
    n = int(input())
    for _ in range(n):
        S.append(input())
    m = int(input())
    for _ in range(m):
        T.append(input())

    cs = collections.Counter(S)
    ct = collections.Counter(T)
    ans = 0
    for s in cs:
        ans = max(ans,cs[s]-ct[s])
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
a = list(set(s+t))
ans = {'min': 0}
for i in a:
    ans[i] = 0
for i in s:
    ans[i] += 1
for i in t:
    ans[i] -= 1

print(max(ans.values()))

Solution (Python):
from collections import defaultdict

dic = defaultdict(int)

N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
for i in s:
    dic[i] += 1

for i in t:
    dic[i] -= 1

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

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

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

print(ans)

Solution (Python):
red_str_list=[]
blue_str_list=[]

blue_cnt=int(input())

for _  in range(blue_cnt):
  red_str_list.append(input())
  
red_cnt=int(input())
for _  in range(red_cnt):
  blue_str_list.append(input())
  
ans=0
dic = dict()

for i in red_str_list:
  if (i in dic.keys()):
    dic[i]+=1
  else:
    dic[i]=1
    
for i in blue_str_list:
  if (i in dic.keys()):
    if dic[i]>0:
      dic[i]-=1

print(max(dic.values()))

Solution (Python):
from collections import Counter

n = int(input())
a = [input() for i in range(n)]
m = int(input())
b = [input() for i in range(m)]

a_cnt = Counter(a)
b_cnt = Counter(b)

maxs = 0
for k, v in a_cnt.items():
    maxs = max(maxs, v - b_cnt[k])
print(maxs)

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

Solution (Python):



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


d = {}
for i in s:
    if i in d.keys():
        d[i] += 1
    else:
        d[i] = 1 

for i in t:
    if i in d.keys():
        d[i] -= 1
    else:
        d[i] = -1

a = list(d.values())
a.append(0)
print(max(a))

Solution (Python):
def myAnswer(N:int,s:list,M:int,t:list) -> int:
   dic = dict()
   for blueCard in s:
      if(blueCard in dic.keys()):
         dic[blueCard]+=1
      else:
         dic[blueCard]=1
   for redCard in t:
      if(redCard in dic.keys()):
         if(dic[redCard] > 0):
            dic[redCard] -= 1
   return max(dic.values())


def modelAnswer():
   tmp=1
def main():
   N = int(input())
   s = [input() for _ in range(N)]
   M = int(input())
   t = [input() for _ in range(M)]
   print(myAnswer(N,s[:],M,t[:]))
if __name__ == '__main__':
   main()

Solution (Python):
a=int(input())
b,d,e=[],[],[0]
for i in range(a):
    b.append(str(input()))
c=int(input())
up,down=0,0
for j in range(c):
    d.append(str(input()))
for k in set(b):
    up+=b.count(k)
    down+=d.count(k)
    e.append(up-down)
    up,down=0,0
print(max(e))

Solution (Python):
b_list = [input() for i in range(int(input()))]
r_list = [input() for i in range(int(input()))]

ans = 0 
for i in list(set(b_list)):
  if ans <= b_list.count(i) - r_list.count(i):
    ans = b_list.count(i) - r_list.count(i)
    
print(int(ans))

Solution (Python):
import collections
n = int(input())
Lista = [str(input()) for i in range(n)]
m = int(input())
Listb = [str(input()) for j in range(m)]
lst = []
for k in range(m):
  if Listb[k] in Lista:
    Lista.remove(Listb[k])
if len(Lista) > 0:
  lst = collections.Counter(Lista)
  print(lst.most_common()[0][1])
elif len(Lista) == 0:
  print(0)

Solution (Python):
N = int(input())
li1 = [input() for _ in range(N)]
M = int(input())
li2 = [input() for _ in range(M)]
ans = 0
for i in set(li1):
    tmp = li1.count(i) - li2.count(i)
    ans = max(ans, tmp)
print(ans)

Solution (Python):
dic = dict()
for a in range(int(input())):
    i = input()
    if not i in dic:
        dic[i] = 1
    else:
        dic[i] = dic[i]+1
for b in range(int(input())):
    i = input()
    if not i in dic:
        dic[i] = -1
    else:
        dic[i] = dic[i]-1
print(max(max([a for a in dic.values()]), 0))

Solution (Python):
n = int(input())
S = []
T = []

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

m = int(input())

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

ans = 0

for tango in set(S):
    tmp = S.count(tango) - T.count(tango)
    ans = max(ans, tmp)
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 word in set(s):
    if word not in t:
        ans = max(ans, s.count(word))
    else:
        ans = max(ans, s.count(word) - t.count(word))
print(ans)

Solution (Python):
from collections import Counter
N = int(input())
s = []
for _ in range(N):
    s.append(input())
M = int(input())
t = []
for _ in range(M):
    t.append(input())
count1 = Counter(s)
count2 = Counter(t)
ans = -1 * M
for key in count1.keys():
    ans = max(ans, count1[key] - count2[key])
ans = max(ans, 0)
print(ans)

Solution (Python):
from collections import defaultdict
cards = defaultdict(int)
n = int(input())
for _ in range(n):
    s = input()
    cards[s] += 1
m = int(input())
for _ in range(m):
    t = input()
    cards[t] -= 1
ans = 0
for k, v in cards.items():
    ans = max(ans, v)
print(ans)

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

M=input()
M=int(M)
T=[0]*M
for i in range(M):
    T[i]=input()

A=[]
for i in S:
    A.append(S.count(i)-T.count(i))

print(max(0,max(A)))

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

dic = {}
word = ""

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

li = list(dic.values())

s = max(li)

if s > 0:
    print(s)
else:
    print(0)

Solution (Python):
n = int(input())
r = [input() for i in range(n)]
m = int(input())
b = [input() for i in range(m)]
rb = set(r+b)
ans = 0

for w in rb:
    x = r.count(w)
    y = b.count(w)
    if x-y > ans:
        ans = x-y

print(ans)

Solution (Python):
icase=0
if icase==0:
    s=dict()
    n=int(input())
    for i in range(n):
        si=input()
        if si in s:
            s[si]=s[si]+1
        else:
            s[si]=1
    t=dict()
    m=int(input())
    for i in range(m):
        ti=input()
        if ti in t:
            t[ti]=t[ti]+1
        else:
            t[ti]=1
    smax=0
    for ss in s.items():
        if ss[0] in t:
            st=ss[1]-t[ss[0]]
        else:
            st=ss[1]
        smax=max(smax,st)
    print(smax)

Solution (Python):
N=int(input())
blue_dic={}
for i in range(N):
  s=input()
  if s in blue_dic:
    blue_dic[s]+=1
  else:
    blue_dic[s]=1
    
M=int(input())
red_dic={}
for i in range(M):
  t=input()
  if t in red_dic:
    red_dic[t]+=1
  else:
    red_dic[t]=1
    
answer=0
for s in blue_dic:
  plus=blue_dic[s]
  minus=0
  if s in red_dic:
    minus=red_dic[s]
  
  answer=max(answer,plus-minus)
  
print(answer)

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

tmp=s.copy()
tmp=set(tmp)
tmp=list(tmp)

for i in tmp:
    S=s.count(i)
    T=t.count(i)
    l.append(S-T)
print(max(0,max(l)))

Solution (Python):

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

tmp = s.copy()
tmp = set(tmp)
tmp = list(tmp)

for i in range(len(tmp)):
    S = s.count(tmp[i])
    T = t.count(tmp[i])
    l.append(S-T)

print(max(0,max(l)))

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

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

Solution (Python):

import io

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

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

Solution (Python):
N = int(input())
dict = {}
s = [input() for i in range(N)]
for x in range(N):
    dict[s[x]] = 0
for y in range(N):
    dict[s[y]] += 1


M = int(input())
t = [input() for i in range(M)]
for z in range(M):
    if t[z] in dict:
        dict[t[z]] -= 1
if max(dict.values()) > 0:
    print(max(dict.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 ss in s:
    score = s.count(ss) - t.count(ss)
    if ans < score:
        ans = score
print(ans)

Solution (Python):
N = int(input())
st = set() 
s = [] 

for i in range(N):
    char = input()
    st.add(char) 
    s.append(char) 

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

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

ans = -100 
char = 0

for x in st:
    char = s.count(x)
    char -= t.count(x)
    ans = max(ans, char)

print(ans if 0 <= ans else 0)

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

dicts = {}
small = 0
for i in s:
    if i not in dicts.keys():
        dicts[i] = 1
    else:
        dicts[i] += 1
    
for i in t:
    if i not in dicts.keys():
        dicts[i] = -1
    else:
        dicts[i] -= 1

tmp = max(dicts.values())
print(max(tmp, small))

Solution (Python):
def main():
    N = int(input())
    blue = [input() for _ in range(N)]
    M = int(input())
    red = [input() for _ in range(M)]
    words = set(blue+red)
    x = -1000
    for w in words:
        pos = blue.count(w)
        neg = red.count(w)
        x = max(x, pos - neg)

    if x > 0:
        print(x)
    else:
        print(0)
main()