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):
def card_count(n):
    card_dict={}
    for i in range(n):
        s = input()
        card_dict.setdefault(s,0)
        card_dict[s]+=1
    return card_dict        

N=int(input())
blue=card_count(N)
M=int(input())
red=card_count(M)
for k,v in blue.items():
    v-=red.get(k,0)
    if v<0:
        v=0
    blue[k]=v
print(max(blue.values()))

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

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

ans = 0

sS = set(S)

for i in sS:
    x = CS[i]
    if i in T:
        x -= CT[i]
    ans = max(ans,x)
    
print(ans)

Solution (Python):
n=int(input())
from collections import Counter
a=[input()for i in range(n)]
ca=Counter(a)
m=int(input())
b=[input()for i in range(m)]
cb=Counter(b)

ans=0
for i in a:
    tmp=ca[i]-cb[i]
    ans=max(ans,tmp)
print(max(ans,0))

Solution (Python):

GBN_DEBUG = False
GBN_DEBUG = True
def dprn(s, i):
    if GBN_DEBUG: print(", " + s + " = " + str(i), end = "")
def dprns(s):
    if GBN_DEBUG: print(", " + s, end = "")
def dprni(i):
    if GBN_DEBUG: print(i, end=" ")
def endl(): 
    if GBN_DEBUG: print('')
def puts(s): print(s)




N = int(input())


s = [input() for _ in range(N)]


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

blueSet = set(s) 
numBlueWord = len(blueSet) 
ans = 0
for i in range(numBlueWord):
    blueWord = blueSet.pop() 
                             
                             
                             
    
    earn = s.count(blueWord) 
    loss = t.count(blueWord) 
    ans = max(ans, earn - loss)

print(ans)

Solution (Python):

def main():
    b = int(input())
    d = dict()

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

    r = int(input())

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

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







if __name__ == '__main__':
    main()

Solution (Python):
import collections
n = int(input())
s = [str(input()) for i in range(n)]
m = int(input())
t = [str(input()) for i in range(m)]
set_s = set(s)
set_t = set(t)
blue = set(s) - set(t)
ss = collections.Counter(s)
tt = collections.Counter(t)
set_s_t = set(s) & set(t)
Max = -999999999
for i in set_s_t:
    Max = max(Max,ss[i]-tt[i])
for i in blue:
    Max = max(Max,ss[i])
if Max < 0:
    Max = 0
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)]

cs=Counter(S)
ct=Counter(T).most_common()

for i in range(len(ct)):
    cs[ct[i][0]]-=ct[i][1]

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

Solution (Python):
from collections import Counter
N = int(input())
blue_cards = Counter(input() for _ in range(N))
M = int(input())
red_cards = Counter(input() for _ in range(M))
ans = 0
for blue_word, blue_count in blue_cards.items():
    tmp_ans = blue_count
    if blue_word in red_cards.keys():
        tmp_ans -= red_cards[blue_word]
    if tmp_ans > ans:
        ans = tmp_ans
print(ans)

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

yen=0
for i in set(s):
    num=s.count(i)
    num2=t.count(i)
    yen=max(yen,num-num2)
print(yen)

Solution (Python):
from collections import defaultdict as dd
n=int(input())
d=dd(int)
ans=0
for i in range(n):
    s=input()
    d[s]+=1
m=int(input())
for i in range(m):
    s=input()
    d[s]-=1
v=max(d.values())
print(max(v,0))

Solution (Python):



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


max_cost = 0


for s in s_list:
    s_cost = s_list[s]
    if s in t_list:
        max_cost = max(max_cost, s_cost - t_list[s])
    else:
        max_cost = max(max_cost, s_cost)


print(max_cost)

Solution (Python):
import sys
from collections import deque

def solve():
    input = sys.stdin.readline
    N = int(input())
    point = dict()
    for _ in range(N):
        s = input().strip("\n")
        if s in point: point[s] += 1
        else: point[s] = 1
    M = int(input())
    for _ in range(M):
        s = input().strip("\n")
        if s in point: point[s] -= 1
        else: point[s] = -1
    
    Ans = 0
    for key in point:
        Ans = max(Ans, point[key])
    print(Ans)


    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
n = int(input())
S = {}
for i in range(n):
    s = str(input())
    if s not in S:
        S[s] = 1
    else:
        S[s] += 1
m = int(input())
T = {}
for i in range(m):
    t = str(input())
    if t not in T:
        T[t] = 1
    else:
        T[t] += 1

ans = 0
for k, v in S.items():
    if k in T:
        ans = max(ans, v-T[k])
    else:
        ans = max(ans, v)
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)]
sc=Counter(s)
tc=Counter(t)
u=list(set(s)&set(t))
ans=0
for i in u:
    ans=max(ans,max(0,sc[i]-tc[i]))
v=list(set(s)-set(u))
for i in v:
    ans=max(ans,sc[i])
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())

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

Solution (Python):
if __name__ == "__main__":
    n = int(input())
    s = dict()
    for _ in range(n):
        tmp = input()
        if tmp in s:
            s[tmp] += 1
        else:
            s[tmp] = 1

    m = int(input())
    t = dict()
    for _ in range(m):
        tmp = input()
        if tmp in t:
            t[tmp] += 1
        else:
            t[tmp] = 1

    ans = 0
    for ss in s:
        if ss in t:
            tmp = s[ss] - t[ss]
        else:
            tmp = s[ss]
        if tmp > ans:
            ans = tmp

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

SS = collections.Counter(S)

TT = collections.Counter(T)

ans = 0
for i in S:
    tes = SS[i] - TT[i]
    ans = max(ans,tes)
    
print(ans)

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

from collections import Counter
Sc = Counter(S)
Tc = Counter(T)
ans = 0
for s in set(S):
    tmp = Sc[s] - Tc[s]
    ans = max(ans, tmp)
print(ans)

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

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

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

Solution (Python):
from collections import Counter

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

res = Counter(s)
for i in range(m):
    if t[i] in res:
        res[t[i]] -= 1

ans = 0
for v in res.values():
    ans = max(ans, v)

print(ans)

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

Solution (Python):
from collections import Counter
N = int(input())
s = Counter([input() for k in range(N)])
M = int(input())
t = Counter([input() for k in range(M)])
ans = 0
for e in s:
    if e not in t:
        ans = max(ans,s[e])
    else:
        ans = max(ans,s[e]-t[e])
print(ans)

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

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

Solution (Python):
def main():
    N = int(input())
    A = [input() for i in range(N)]
    M = int(input())
    B = [input() for i in range(M)]
    ans = 0
    from collections import Counter
    S = Counter(A)
    T = Counter(B)
    for k, v in S.items():
        ans = max(ans, v - T[k])
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict

cnt = defaultdict(int)

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

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

ans = 0
for c in cnt.values():
    ans = max(ans, c)
print(ans)

Solution (Python):
from collections import defaultdict

cnt = defaultdict(int)

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

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

ans = 0
for c in cnt.values():
    ans = max(ans, c)

print(ans)

Solution (Python):
from collections import defaultdict
d=defaultdict(int)
for i in range(int(input())):d[input()]+=1
for i in range(int(input())):d[input()]-=1
print(max(max(d[i]for i in d),0))

Solution (Python):
bn = int(input())
bd = []; bdd = {}
for i in range(bn):
    bd = input().split()[0]
    try:
        bdd[str(bd)] += 1
    except:
        bdd[str(bd)] = 1

rn = int(input())
rd = []
for i in range(rn):
    rd = input().split()[0]
    try:
        bdd[str(rd)] -= 1
    except:
        continue
    
l = [s for s in bdd.values()]
l.append(0)
print(max(l))

Solution (Python):
n = int(input())
d = {}
for i in range(n):
    s = input()
    try:
        d[s] += 1
    except:
        d[s] = 1

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

max_num = 0
for item in d.items():
    if item[1] > max_num:
        max_num = item[1]

print(max_num)

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

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

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

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

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

for i in t:
	if(i in s):
		s.pop(s.index(i))




max=0
for i in s:
	if(s.count(i)>max):
		max=s.count(i)

print(max)

Solution (Python):
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
score = []
for i in range(N):
  score.append(s.count(s[i]) - t.count(s[i]))
if max(score) > 0:
  print(max(score))
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)]
l=list(set(s))
print(max(0,max(s.count(l[i])-t.count(l[i]) for i in range(len(l)))))

Solution (Python):


from collections import defaultdict
d = defaultdict(int)

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

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

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

Solution (Python):
import collections
n = int(input())
a = [input() for i in range(n)]
m = int(input())
b = [input() for i in range(m)]
x = collections.Counter(a)
y = collections.Counter(b)
ans = 0
for i in x.keys():
    cnt = x[i]
    if i in y.keys(): cnt -= y[i]
    ans = max(ans,cnt)
print(ans)

Solution (Python):
n = int(input())
a = list(input() for _ in range(n))
m = int(input())
b = list(input() for _ in range(m))

dict_a = {}
dict_b = {}

for i in a:
    if i in dict_a:
        dict_a[i] += 1
    else:
        dict_a[i] = 1

for i in b:
    if i in dict_b:
        dict_b[i] += 1
    else:
        dict_b[i] = 1

for c in dict_a.keys():
    if c in dict_b.keys():
        dict_a[c] -= dict_b[c]
print(max(0, max(dict_a.values())))

Solution (Python):
def main():
    n = int(input())
    ss = [input() for _ in range(n)]
    m = int(input())
    ts = [input() for _ in range(m)]

    fruits = list(set(ss))
    ans = 0
    for fruit in fruits:
        money = 0
        money += ss.count(fruit)
        money -= ts.count(fruit)
        ans = max(ans, money)
    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)]

ans=0

for i in range(n):
    if ans<s.count(s[i])-t.count(s[i]):
        ans=s.count(s[i])-t.count(s[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)]
d = {}
for i in range(n):
    if s[i] in d:
        d[s[i]] += 1
    else:
        d[s[i]] = 1
for i in range(m):
    if t[i] in d:
        d[t[i]] -= 1
    else:
        d[t[i]] = 1


v = max(d.values())
if v >= 0:
    print(max(d.values()))
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)]

mojiretsu = {}

for item in s:
    if not item in mojiretsu:
        mojiretsu.setdefault(item, 1)
    else:
        mojiretsu[item] += 1

for item in t:
    if not item in mojiretsu:
        mojiretsu.setdefault(item, -1)
    else:
        mojiretsu[item] -= 1





max_coin = 0
for i in mojiretsu.values():
    if max_coin < i:
        max_coin = i

print("{}".format(max_coin))

Solution (Python):
n = int(input())
dic = dict()
for i in range(n):
    s = input()
    if s not in dic:
        dic[s] = 0
    dic[s] += 1
m = int(input())
for i in range(m):
    s = input()
    if s not in dic:
        dic[s] = 0
    dic[s] -= 1
ans = list(dic.values())
print(max(max(ans),0))

Solution (Python):
from collections import defaultdict
d = defaultdict(int)
d["D"]=0

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

n=int(input())
for _ in range(n):
  d[input()]-=1
  
print(max(d.values()))

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

Solution (Python):

import sys
import itertools
import math
from collections import Counter

i=0
j=0
s=0
eq=''
diff= 0
N=int(input())

red_list =[[input() for i in range(1)for j in range(N)]]
red_simple_list=red_list[0]




M=int(input())
blue_list =[[input() for i in range(1)for j in range(M)]]
blue_simple_list=blue_list[0]


for j in range(N-1):
 
 
 
 eq=red_simple_list[j]
 
 
 
 diff=red_simple_list.count(eq)-blue_simple_list.count(eq)
 
 if diff > s:
     s= diff
print(s)
















     




















    





first_term=0
second_term=0


     

  
     


     




     
     



'''p[, r]で
長さrのタプル列、重複なしのあらゆる並びを表す
今回はリストlの重複なしの並び替え順序を新たなリストに収納している
並び方を計算しリストに収納しているイメージ
l[0,1,2]
l[0,2,1]これにもリスト番号が0,1,2と割り振られている
これが全通り入っている
これ作った人はすごい
自分も早く理解したい
'''



'''
各経路の距離を足していき全距離分を経路数
で割れば平均距離が出るので各経路ごとの距離は
不必要と判断されている。
'''

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

s_set = set(s)
t_set = set(t)
ans = 0
for i in s_set:
    p = s.count(i)
    q = t.count(i)
    ans = max(ans,p-q)
print(ans)

Solution (Python):
from collections import defaultdict
def main():
    N = int(input())
    ans = 0
    s = defaultdict(int)
    for _ in range(N):
        a = input()
        s[a] += 1
    M = int(input())
    for _ in range(M):
        b = input()
        s[b] -= 1
    for v in s.items():
        ans = max(ans,v[1])
    print(ans)
if __name__ == "__main__":
    main()

Solution (Python):
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor



dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

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

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

x = 0
y = 0
ma = 0
for i in range(len(s)):
    x = s.count(s[i])
    y = t.count(s[i])
    ma = max(ma, (x-y))
print(ma)

Solution (Python):
def Two_Colors(n , sl , m , tl):

    ans = 0
    count = {}

    for i in range(n):
        if sl[i] in count:
            count[sl[i]] += 1
        else:
            count[sl[i]] = 1

    for i in range(m):
        if tl[i] in count:
            count[tl[i]] -= 1
        else:
            count[tl[i]] = -1

    for i in count.values():
        ans = max(ans , i)

    return ans

def main():
    n = int(input())
    sl = [str(input()) for i in range(n)]
    m = int(input())
    tl = [str(input()) for i in range(m)]
    print(Two_Colors(n , sl , m , tl))


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
nn=[]
for i in range(n):
    nn.append(input())
m=int(input())
mm=[]
for i in range(m):
    mm.append(input())
ans=0
nns=set(nn)
for i in nns:
    tmp = nn.count(i)- mm.count(i) 
    ans=max(ans,tmp)

print(ans)

Solution (Python):
from collections import Counter

N = Counter([input() for _ in range(int(input()))])
M = Counter([input() for _ in range(int(input()))])
print(max(0, max(N[key]-M[key] for key in N.keys())))

Solution (Python):
N = int(input())
max1 = 0
blue_dic = {}
red_dic = {}
for i in range(N):
    b = input()
    if b in blue_dic:
        blue_dic[b] += 1
    else:
        blue_dic[b] = 1
M = int(input())
for i in range(M):
    r = input()
    if r in red_dic:
        red_dic[r] += 1
    else:
        red_dic[r] = 1
for kb, vb in blue_dic.items():
    tmp = 0
    tmp += vb
    if kb in red_dic:
        tmp -= red_dic[kb]
    if tmp > max1:
        max1 = tmp
print(max1)

Solution (Python):
N=int(input())
blue=[]
for a in range(N):
    b=input()
    blue.append(b)
M=int(input())
red=[]
for c in range(M):
    d=input()
    red.append(d)
nblue=[]
for a in blue:
    if a in nblue:
        pass
    else:
        nblue.append(a)
numbers=[]
for b in nblue:
    c=blue.count(b)-red.count(b)
    numbers.append(c)
if max(numbers)<=0:
    print(0)
else:
    print(max(numbers))

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

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

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

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

Solution (Python):

n=int(input())
card=dict()
for i in range(n):
    s=input()
    if s not in card:
        card[s]=1
    else:
        card[s]+=1
m=int(input())
for i in range(m):
    t=input()
    if t not in card:
        card[t]=-1
    else:
        card[t]-=1
ans=-m

for i in card.values():
    ans=max(ans,i,0)
print(ans)

Solution (Python):

from collections import defaultdict
import sys

def inpl(): return list(map(int, input().split()))

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 collections import defaultdict
n = int(input())
ss = list(input() for _ in range(n))
m = int(input())
tt = list(input() for _ in range(m))
dic = defaultdict(int)

for s in ss:
    dic[s] += 1
for t in tt:
    dic[t] -= 1

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

Solution (Python):
N=int(input())
s=[]
for i in range(N):
    s+=[input()]
M=int(input())
t=[]
for i in range(M):
    t+=[input()]
ans1=0
ss=list(set(s))
for i in range(len(set(s))):
    ans=s.count(ss[i])-t.count(ss[i])
    ans1=max(ans1,ans)
if ans1<0:
    print(0)
    exit()
print(ans1)

Solution (Python):
from collections import Counter

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

Counter_S = Counter(S)
Counter_T = Counter(T)
Counter_plus = Counter_S - Counter_T
if len(Counter_plus.values()):
    print(max(Counter_plus.values()))
else:
    print(0)

Solution (Python):
N = int(input())
blue = {}
for i in range(N):
    a = input()
    if a not in blue:
        blue[a] = 1
    else:
        blue[a] += 1
        
M = int(input())

for i in range(M):
    a = input()
    if a not in blue:
        blue[a] = -1
    else:
        blue[a] -= 1
print(max(0, max(blue.values())))

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

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


M = int(input())

T = []
for i in range(M):
  T.append(str(input()))

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

print(ans)

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

card={}
card_key=set([])

for _ in range(n):
  temp=input()
  if temp in card_key:
    card[temp]+=1
  else:
    card_key.add(temp)
    card[temp]=1

m=int(input())

for _ in range(m):
  temp=input()
  if temp in card_key:
    card[temp]-=1
  else:
    card_key.add(temp)
    card[temp]=-1

result=0
for item in card_key:
  result=max(result,card[item])
print(result)

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

Solution (Python):
from collections import Counter
N=int(input())
blue = Counter([input() for i in range(N)])
M=int(input())
red = [input() for i in range(M)]
for i in red:
    if i in blue:
        blue[i] -=1
ans = 0
for i in blue.values():
    if ans < i:
        ans = i
print(ans)

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

M = int(input())
for i in range(M):
    tmp = input()
    if tmp in red:
        red[tmp] -= 1

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

Solution (Python):
from collections import *
c=Counter({0:0})
for i in (1,-1):
  for _ in range(int(input())): c[input()]+=i
print(max(c.values()))

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

Solution (Python):
n=int(input())
s=[None]*n
for i in range(n):
  s[i]=input()
m=int(input())
t=[None]*m
for i in range(m):
  t[i]=input()
ans=0
a=[0]*n
for i in range(n):
  for j in range(n):
    if s[i]==s[j]:
      a[i]+=1
    else:
      pass
for i in range(n):
  for j in range(m):
    if s[i]==t[j]:
      a[i]-=1
    else:
      pass

b=max(a)
print(max(ans,b))

Solution (Python):




from collections import Counter





n = int(input())
arrN = []
for _ in range(n):
    arrN += [input()]  
m = int(input())
arrM = []
for _ in range(m):
    arrM += [input()]  

countaN = Counter(arrN)
countaM = Counter(arrM)
countaAns = countaN - countaM

if len(countaAns) !=0:
    s,ans = countaAns.most_common()[0]
else:
    ans = 0

print(ans)

Solution (Python):
from collections import defaultdict

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

print(ans)

Solution (Python):
from collections import defaultdict

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

ds = defaultdict(int)
dt = defaultdict(int)

for i in range(N):
  ds[S[i]] += 1
for i in range(M):
  dt[T[i]] -= 1
  
keys = []
i = 0
for key in ds.keys():
  keys.append(key)
for key in dt.keys():
  keys.append(key)

ans = 0
for s in keys:
  ans = max(ans, ds[s] + dt[s])
print(ans)

Solution (Python):








def resolve():
    n=int(input())
    l1=[str(input()) for i in range(n)]
    m=int(input())
    l2=[str(input())    for i in range(m)]

    ans=0
    for i in l1:
        ans=max(l1.count(i)-l2.count(i),ans)
    for j in l2:
        ans=max(l1.count(i)-l2.count(i),ans)
    print(ans)



resolve()

Solution (Python):
import sys
import os
import re
import datetime

card = {}

N = int(input())
for _ in range(N):
	s = input()
	if s in card:
		card[s] += 1
	else:
		card[s] = 1
		
M = int(input())
for _ in range(M):
	t = input()
	if t in card:
		card[t] -= 1
	else:
		card[t] = -1

maxCount = 0

for count in card:
	maxCount = max(maxCount, max(card.values()))

print(maxCount)

Solution (Python):
N = int(input())
point = dict()
for _ in range(N):
  s = str(input())
  if s in point.keys():
    point[s] += 1
  else:
    point[s] = 1

M = int(input())
for _ in range(M):
  t = str(input())
  if t in point.keys():
    point[t] -= 1

ans = max(max(point.values()), 0)
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())

d = {x: 0 for x in s}
for x in s:
    d[x] += 1

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

ans = max(d.values())

print(max(ans,0))

Solution (Python):
import sys
from collections import defaultdict

input = lambda: sys.stdin.readline().rstrip()

N = int(input())

d = defaultdict(int)

for i in range(N):
    word = input()
    d[word] += 1

M = int(input())

for i in range(M):
    word = input()
    d[word] -= 1

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

if sorted_d[0][1] <= 0:
    print(0)
else:
    print(sorted_d[0][1])

Solution (Python):
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.readline().rstrip())
    S = [str(sys.stdin.readline().rstrip()) for _ in range(N)]
    M = int(sys.stdin.readline().rstrip())
    T = [str(sys.stdin.readline().rstrip()) for _ in range(M)]
    target = set(S)

    ret = 0
    for s in target:
        tmp = S.count(s) - T.count(s)
        if ret < tmp:
            ret = tmp

    print(ret)


if __name__ == '__main__':
    main()

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

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

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

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

get_dict={}
for i in range(N):
  s=input()
  if s in get_dict.keys():
    get_dict[s]+=1
  else:
    get_dict[s]=1
    
M=int(input())
lose_dict={}
for i in range(M):
  s=input()
  if s in lose_dict.keys():
    lose_dict[s]+=1
  else:
    lose_dict[s]=1

ind=list(set(list(get_dict.keys())+list(lose_dict.keys())))
ans=0
for s in ind:
  try:
    a=get_dict[s]
  except:
    a=0
  try:
    b=lose_dict[s]
  except:
    b=0
  ans=max(ans, a-b)
  
print(ans)

Solution (Python):
from collections import Counter

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

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

a=Counter(A)
b=Counter(B)

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

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):
from collections import defaultdict
def solve():
    N = int(input())
    blue = defaultdict(int)
    for i in range(N):
        s = input()
        blue[s] += 1
    
    M = int(input())
    red = defaultdict(int)
    for i in range(M):
        t = input()
        red[t] += 1

    mx = 0
    for item in blue.items():
        mx = max(mx, item[1] - red[item[0]])

    print(mx)
if __name__ == '__main__':
    solve()

Solution (Python):
import sys
import math

a=int(input())
li0=[]
li1=[]
for d in range(a):
  li0.append(input())
b=int(input())
for f in range(b):
  li1.append(input())
jug=0

for i in li0:
  count=0
  for j in li0:
    if i==j:
      count+=1
  for k in li1:
    if i==k:
      count-=1
  jug=max(jug,count)


print(jug)